UNPKG

@etherspot/data-utils

Version:
1,667 lines (1,657 loc) 670 kB
import { __commonJS, __export, __toESM } from "./chunk-PVVZGNOS.mjs"; // node_modules/js-sha3/src/sha3.js var require_sha3 = __commonJS({ "node_modules/js-sha3/src/sha3.js"(exports, module) { (function() { "use strict"; var INPUT_ERROR = "input is invalid type"; var FINALIZE_ERROR = "finalize already called"; var WINDOW = typeof window === "object"; var root = WINDOW ? window : {}; if (root.JS_SHA3_NO_WINDOW) { WINDOW = false; } var WEB_WORKER = !WINDOW && typeof self === "object"; var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node; if (NODE_JS) { root = global; } else if (WEB_WORKER) { root = self; } var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === "object" && module.exports; var AMD = typeof define === "function" && define.amd; var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined"; var HEX_CHARS = "0123456789abcdef".split(""); var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; var KECCAK_PADDING = [1, 256, 65536, 16777216]; var PADDING = [6, 1536, 393216, 100663296]; var SHIFT = [0, 8, 16, 24]; var RC = [ 1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648 ]; var BITS = [224, 256, 384, 512]; var SHAKE_BITS = [128, 256]; var OUTPUT_TYPES = ["hex", "buffer", "arrayBuffer", "array", "digest"]; var CSHAKE_BYTEPAD = { "128": 168, "256": 136 }; if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; } if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { ArrayBuffer.isView = function(obj) { return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer; }; } var createOutputMethod = function(bits2, padding2, outputType) { return function(message) { return new Keccak(bits2, padding2, bits2).update(message)[outputType](); }; }; var createShakeOutputMethod = function(bits2, padding2, outputType) { return function(message, outputBits) { return new Keccak(bits2, padding2, outputBits).update(message)[outputType](); }; }; var createCshakeOutputMethod = function(bits2, padding2, outputType) { return function(message, outputBits, n, s) { return methods["cshake" + bits2].update(message, outputBits, n, s)[outputType](); }; }; var createKmacOutputMethod = function(bits2, padding2, outputType) { return function(key2, message, outputBits, s) { return methods["kmac" + bits2].update(key2, message, outputBits, s)[outputType](); }; }; var createOutputMethods = function(method, createMethod2, bits2, padding2) { for (var i2 = 0; i2 < OUTPUT_TYPES.length; ++i2) { var type = OUTPUT_TYPES[i2]; method[type] = createMethod2(bits2, padding2, type); } return method; }; var createMethod = function(bits2, padding2) { var method = createOutputMethod(bits2, padding2, "hex"); method.create = function() { return new Keccak(bits2, padding2, bits2); }; method.update = function(message) { return method.create().update(message); }; return createOutputMethods(method, createOutputMethod, bits2, padding2); }; var createShakeMethod = function(bits2, padding2) { var method = createShakeOutputMethod(bits2, padding2, "hex"); method.create = function(outputBits) { return new Keccak(bits2, padding2, outputBits); }; method.update = function(message, outputBits) { return method.create(outputBits).update(message); }; return createOutputMethods(method, createShakeOutputMethod, bits2, padding2); }; var createCshakeMethod = function(bits2, padding2) { var w = CSHAKE_BYTEPAD[bits2]; var method = createCshakeOutputMethod(bits2, padding2, "hex"); method.create = function(outputBits, n, s) { if (!n && !s) { return methods["shake" + bits2].create(outputBits); } else { return new Keccak(bits2, padding2, outputBits).bytepad([n, s], w); } }; method.update = function(message, outputBits, n, s) { return method.create(outputBits, n, s).update(message); }; return createOutputMethods(method, createCshakeOutputMethod, bits2, padding2); }; var createKmacMethod = function(bits2, padding2) { var w = CSHAKE_BYTEPAD[bits2]; var method = createKmacOutputMethod(bits2, padding2, "hex"); method.create = function(key2, outputBits, s) { return new Kmac(bits2, padding2, outputBits).bytepad(["KMAC", s], w).bytepad([key2], w); }; method.update = function(key2, message, outputBits, s) { return method.create(key2, outputBits, s).update(message); }; return createOutputMethods(method, createKmacOutputMethod, bits2, padding2); }; var algorithms = [ { name: "keccak", padding: KECCAK_PADDING, bits: BITS, createMethod }, { name: "sha3", padding: PADDING, bits: BITS, createMethod }, { name: "shake", padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, { name: "cshake", padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, { name: "kmac", padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } ]; var methods = {}, methodNames = []; for (var i = 0; i < algorithms.length; ++i) { var algorithm = algorithms[i]; var bits = algorithm.bits; for (var j = 0; j < bits.length; ++j) { var methodName = algorithm.name + "_" + bits[j]; methodNames.push(methodName); methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); if (algorithm.name !== "sha3") { var newMethodName = algorithm.name + bits[j]; methodNames.push(newMethodName); methods[newMethodName] = methods[methodName]; } } } function Keccak(bits2, padding2, outputBits) { this.blocks = []; this.s = []; this.padding = padding2; this.outputBits = outputBits; this.reset = true; this.finalized = false; this.block = 0; this.start = 0; this.blockCount = 1600 - (bits2 << 1) >> 5; this.byteCount = this.blockCount << 2; this.outputBlocks = outputBits >> 5; this.extraBytes = (outputBits & 31) >> 3; for (var i2 = 0; i2 < 50; ++i2) { this.s[i2] = 0; } } Keccak.prototype.update = function(message) { if (this.finalized) { throw new Error(FINALIZE_ERROR); } var notString, type = typeof message; if (type !== "string") { if (type === "object") { if (message === null) { throw new Error(INPUT_ERROR); } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { message = new Uint8Array(message); } else if (!Array.isArray(message)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { throw new Error(INPUT_ERROR); } } } else { throw new Error(INPUT_ERROR); } notString = true; } var blocks = this.blocks, byteCount = this.byteCount, length = message.length, blockCount = this.blockCount, index = 0, s = this.s, i2, code; while (index < length) { if (this.reset) { this.reset = false; blocks[0] = this.block; for (i2 = 1; i2 < blockCount + 1; ++i2) { blocks[i2] = 0; } } if (notString) { for (i2 = this.start; index < length && i2 < byteCount; ++index) { blocks[i2 >> 2] |= message[index] << SHIFT[i2++ & 3]; } } else { for (i2 = this.start; index < length && i2 < byteCount; ++index) { code = message.charCodeAt(index); if (code < 128) { blocks[i2 >> 2] |= code << SHIFT[i2++ & 3]; } else if (code < 2048) { blocks[i2 >> 2] |= (192 | code >> 6) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code & 63) << SHIFT[i2++ & 3]; } else if (code < 55296 || code >= 57344) { blocks[i2 >> 2] |= (224 | code >> 12) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code >> 6 & 63) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code & 63) << SHIFT[i2++ & 3]; } else { code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023); blocks[i2 >> 2] |= (240 | code >> 18) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code >> 12 & 63) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code >> 6 & 63) << SHIFT[i2++ & 3]; blocks[i2 >> 2] |= (128 | code & 63) << SHIFT[i2++ & 3]; } } } this.lastByteIndex = i2; if (i2 >= byteCount) { this.start = i2 - byteCount; this.block = blocks[blockCount]; for (i2 = 0; i2 < blockCount; ++i2) { s[i2] ^= blocks[i2]; } f(s); this.reset = true; } else { this.start = i2; } } return this; }; Keccak.prototype.encode = function(x, right) { var o = x & 255, n = 1; var bytes = [o]; x = x >> 8; o = x & 255; while (o > 0) { bytes.unshift(o); x = x >> 8; o = x & 255; ++n; } if (right) { bytes.push(n); } else { bytes.unshift(n); } this.update(bytes); return bytes.length; }; Keccak.prototype.encodeString = function(str) { var notString, type = typeof str; if (type !== "string") { if (type === "object") { if (str === null) { throw new Error(INPUT_ERROR); } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { str = new Uint8Array(str); } else if (!Array.isArray(str)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { throw new Error(INPUT_ERROR); } } } else { throw new Error(INPUT_ERROR); } notString = true; } var bytes = 0, length = str.length; if (notString) { bytes = length; } else { for (var i2 = 0; i2 < str.length; ++i2) { var code = str.charCodeAt(i2); if (code < 128) { bytes += 1; } else if (code < 2048) { bytes += 2; } else if (code < 55296 || code >= 57344) { bytes += 3; } else { code = 65536 + ((code & 1023) << 10 | str.charCodeAt(++i2) & 1023); bytes += 4; } } } bytes += this.encode(bytes * 8); this.update(str); return bytes; }; Keccak.prototype.bytepad = function(strs, w) { var bytes = this.encode(w); for (var i2 = 0; i2 < strs.length; ++i2) { bytes += this.encodeString(strs[i2]); } var paddingBytes = w - bytes % w; var zeros2 = []; zeros2.length = paddingBytes; this.update(zeros2); return this; }; Keccak.prototype.finalize = function() { if (this.finalized) { return; } this.finalized = true; var blocks = this.blocks, i2 = this.lastByteIndex, blockCount = this.blockCount, s = this.s; blocks[i2 >> 2] |= this.padding[i2 & 3]; if (this.lastByteIndex === this.byteCount) { blocks[0] = blocks[blockCount]; for (i2 = 1; i2 < blockCount + 1; ++i2) { blocks[i2] = 0; } } blocks[blockCount - 1] |= 2147483648; for (i2 = 0; i2 < blockCount; ++i2) { s[i2] ^= blocks[i2]; } f(s); }; Keccak.prototype.toString = Keccak.prototype.hex = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i2 = 0, j2 = 0; var hex = "", block; while (j2 < outputBlocks) { for (i2 = 0; i2 < blockCount && j2 < outputBlocks; ++i2, ++j2) { block = s[i2]; hex += HEX_CHARS[block >> 4 & 15] + HEX_CHARS[block & 15] + HEX_CHARS[block >> 12 & 15] + HEX_CHARS[block >> 8 & 15] + HEX_CHARS[block >> 20 & 15] + HEX_CHARS[block >> 16 & 15] + HEX_CHARS[block >> 28 & 15] + HEX_CHARS[block >> 24 & 15]; } if (j2 % blockCount === 0) { f(s); i2 = 0; } } if (extraBytes) { block = s[i2]; hex += HEX_CHARS[block >> 4 & 15] + HEX_CHARS[block & 15]; if (extraBytes > 1) { hex += HEX_CHARS[block >> 12 & 15] + HEX_CHARS[block >> 8 & 15]; } if (extraBytes > 2) { hex += HEX_CHARS[block >> 20 & 15] + HEX_CHARS[block >> 16 & 15]; } } return hex; }; Keccak.prototype.arrayBuffer = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i2 = 0, j2 = 0; var bytes = this.outputBits >> 3; var buffer; if (extraBytes) { buffer = new ArrayBuffer(outputBlocks + 1 << 2); } else { buffer = new ArrayBuffer(bytes); } var array = new Uint32Array(buffer); while (j2 < outputBlocks) { for (i2 = 0; i2 < blockCount && j2 < outputBlocks; ++i2, ++j2) { array[j2] = s[i2]; } if (j2 % blockCount === 0) { f(s); } } if (extraBytes) { array[i2] = s[i2]; buffer = buffer.slice(0, bytes); } return buffer; }; Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; Keccak.prototype.digest = Keccak.prototype.array = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i2 = 0, j2 = 0; var array = [], offset, block; while (j2 < outputBlocks) { for (i2 = 0; i2 < blockCount && j2 < outputBlocks; ++i2, ++j2) { offset = j2 << 2; block = s[i2]; array[offset] = block & 255; array[offset + 1] = block >> 8 & 255; array[offset + 2] = block >> 16 & 255; array[offset + 3] = block >> 24 & 255; } if (j2 % blockCount === 0) { f(s); } } if (extraBytes) { offset = j2 << 2; block = s[i2]; array[offset] = block & 255; if (extraBytes > 1) { array[offset + 1] = block >> 8 & 255; } if (extraBytes > 2) { array[offset + 2] = block >> 16 & 255; } } return array; }; function Kmac(bits2, padding2, outputBits) { Keccak.call(this, bits2, padding2, outputBits); } Kmac.prototype = new Keccak(); Kmac.prototype.finalize = function() { this.encode(this.outputBits, true); return Keccak.prototype.finalize.call(this); }; var f = function(s) { var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; for (n = 0; n < 48; n += 2) { c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; h = c8 ^ (c2 << 1 | c3 >>> 31); l = c9 ^ (c3 << 1 | c2 >>> 31); s[0] ^= h; s[1] ^= l; s[10] ^= h; s[11] ^= l; s[20] ^= h; s[21] ^= l; s[30] ^= h; s[31] ^= l; s[40] ^= h; s[41] ^= l; h = c0 ^ (c4 << 1 | c5 >>> 31); l = c1 ^ (c5 << 1 | c4 >>> 31); s[2] ^= h; s[3] ^= l; s[12] ^= h; s[13] ^= l; s[22] ^= h; s[23] ^= l; s[32] ^= h; s[33] ^= l; s[42] ^= h; s[43] ^= l; h = c2 ^ (c6 << 1 | c7 >>> 31); l = c3 ^ (c7 << 1 | c6 >>> 31); s[4] ^= h; s[5] ^= l; s[14] ^= h; s[15] ^= l; s[24] ^= h; s[25] ^= l; s[34] ^= h; s[35] ^= l; s[44] ^= h; s[45] ^= l; h = c4 ^ (c8 << 1 | c9 >>> 31); l = c5 ^ (c9 << 1 | c8 >>> 31); s[6] ^= h; s[7] ^= l; s[16] ^= h; s[17] ^= l; s[26] ^= h; s[27] ^= l; s[36] ^= h; s[37] ^= l; s[46] ^= h; s[47] ^= l; h = c6 ^ (c0 << 1 | c1 >>> 31); l = c7 ^ (c1 << 1 | c0 >>> 31); s[8] ^= h; s[9] ^= l; s[18] ^= h; s[19] ^= l; s[28] ^= h; s[29] ^= l; s[38] ^= h; s[39] ^= l; s[48] ^= h; s[49] ^= l; b0 = s[0]; b1 = s[1]; b32 = s[11] << 4 | s[10] >>> 28; b33 = s[10] << 4 | s[11] >>> 28; b14 = s[20] << 3 | s[21] >>> 29; b15 = s[21] << 3 | s[20] >>> 29; b46 = s[31] << 9 | s[30] >>> 23; b47 = s[30] << 9 | s[31] >>> 23; b28 = s[40] << 18 | s[41] >>> 14; b29 = s[41] << 18 | s[40] >>> 14; b20 = s[2] << 1 | s[3] >>> 31; b21 = s[3] << 1 | s[2] >>> 31; b2 = s[13] << 12 | s[12] >>> 20; b3 = s[12] << 12 | s[13] >>> 20; b34 = s[22] << 10 | s[23] >>> 22; b35 = s[23] << 10 | s[22] >>> 22; b16 = s[33] << 13 | s[32] >>> 19; b17 = s[32] << 13 | s[33] >>> 19; b48 = s[42] << 2 | s[43] >>> 30; b49 = s[43] << 2 | s[42] >>> 30; b40 = s[5] << 30 | s[4] >>> 2; b41 = s[4] << 30 | s[5] >>> 2; b22 = s[14] << 6 | s[15] >>> 26; b23 = s[15] << 6 | s[14] >>> 26; b4 = s[25] << 11 | s[24] >>> 21; b5 = s[24] << 11 | s[25] >>> 21; b36 = s[34] << 15 | s[35] >>> 17; b37 = s[35] << 15 | s[34] >>> 17; b18 = s[45] << 29 | s[44] >>> 3; b19 = s[44] << 29 | s[45] >>> 3; b10 = s[6] << 28 | s[7] >>> 4; b11 = s[7] << 28 | s[6] >>> 4; b42 = s[17] << 23 | s[16] >>> 9; b43 = s[16] << 23 | s[17] >>> 9; b24 = s[26] << 25 | s[27] >>> 7; b25 = s[27] << 25 | s[26] >>> 7; b6 = s[36] << 21 | s[37] >>> 11; b7 = s[37] << 21 | s[36] >>> 11; b38 = s[47] << 24 | s[46] >>> 8; b39 = s[46] << 24 | s[47] >>> 8; b30 = s[8] << 27 | s[9] >>> 5; b31 = s[9] << 27 | s[8] >>> 5; b12 = s[18] << 20 | s[19] >>> 12; b13 = s[19] << 20 | s[18] >>> 12; b44 = s[29] << 7 | s[28] >>> 25; b45 = s[28] << 7 | s[29] >>> 25; b26 = s[38] << 8 | s[39] >>> 24; b27 = s[39] << 8 | s[38] >>> 24; b8 = s[48] << 14 | s[49] >>> 18; b9 = s[49] << 14 | s[48] >>> 18; s[0] = b0 ^ ~b2 & b4; s[1] = b1 ^ ~b3 & b5; s[10] = b10 ^ ~b12 & b14; s[11] = b11 ^ ~b13 & b15; s[20] = b20 ^ ~b22 & b24; s[21] = b21 ^ ~b23 & b25; s[30] = b30 ^ ~b32 & b34; s[31] = b31 ^ ~b33 & b35; s[40] = b40 ^ ~b42 & b44; s[41] = b41 ^ ~b43 & b45; s[2] = b2 ^ ~b4 & b6; s[3] = b3 ^ ~b5 & b7; s[12] = b12 ^ ~b14 & b16; s[13] = b13 ^ ~b15 & b17; s[22] = b22 ^ ~b24 & b26; s[23] = b23 ^ ~b25 & b27; s[32] = b32 ^ ~b34 & b36; s[33] = b33 ^ ~b35 & b37; s[42] = b42 ^ ~b44 & b46; s[43] = b43 ^ ~b45 & b47; s[4] = b4 ^ ~b6 & b8; s[5] = b5 ^ ~b7 & b9; s[14] = b14 ^ ~b16 & b18; s[15] = b15 ^ ~b17 & b19; s[24] = b24 ^ ~b26 & b28; s[25] = b25 ^ ~b27 & b29; s[34] = b34 ^ ~b36 & b38; s[35] = b35 ^ ~b37 & b39; s[44] = b44 ^ ~b46 & b48; s[45] = b45 ^ ~b47 & b49; s[6] = b6 ^ ~b8 & b0; s[7] = b7 ^ ~b9 & b1; s[16] = b16 ^ ~b18 & b10; s[17] = b17 ^ ~b19 & b11; s[26] = b26 ^ ~b28 & b20; s[27] = b27 ^ ~b29 & b21; s[36] = b36 ^ ~b38 & b30; s[37] = b37 ^ ~b39 & b31; s[46] = b46 ^ ~b48 & b40; s[47] = b47 ^ ~b49 & b41; s[8] = b8 ^ ~b0 & b2; s[9] = b9 ^ ~b1 & b3; s[18] = b18 ^ ~b10 & b12; s[19] = b19 ^ ~b11 & b13; s[28] = b28 ^ ~b20 & b22; s[29] = b29 ^ ~b21 & b23; s[38] = b38 ^ ~b30 & b32; s[39] = b39 ^ ~b31 & b33; s[48] = b48 ^ ~b40 & b42; s[49] = b49 ^ ~b41 & b43; s[0] ^= RC[n]; s[1] ^= RC[n + 1]; } }; if (COMMON_JS) { module.exports = methods; } else { for (i = 0; i < methodNames.length; ++i) { root[methodNames[i]] = methods[methodNames[i]]; } if (AMD) { define(function() { return methods; }); } } })(); } }); // node_modules/minimalistic-assert/index.js var require_minimalistic_assert = __commonJS({ "node_modules/minimalistic-assert/index.js"(exports, module) { module.exports = assert2; function assert2(val, msg) { if (!val) throw new Error(msg || "Assertion failed"); } assert2.equal = function assertEqual2(l, r2, msg) { if (l != r2) throw new Error(msg || "Assertion failed: " + l + " != " + r2); }; } }); // node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "node_modules/inherits/inherits_browser.js"(exports, module) { if (typeof Object.create === "function") { module.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } }; } else { module.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } }; } } }); // node_modules/hash.js/lib/hash/utils.js var require_utils = __commonJS({ "node_modules/hash.js/lib/hash/utils.js"(exports) { "use strict"; var assert2 = require_minimalistic_assert(); var inherits = require_inherits_browser(); exports.inherits = inherits; function isSurrogatePair(msg, i) { if ((msg.charCodeAt(i) & 64512) !== 55296) { return false; } if (i < 0 || i + 1 >= msg.length) { return false; } return (msg.charCodeAt(i + 1) & 64512) === 56320; } function toArray(msg, enc) { if (Array.isArray(msg)) return msg.slice(); if (!msg) return []; var res = []; if (typeof msg === "string") { if (!enc) { var p = 0; for (var i = 0; i < msg.length; i++) { var c = msg.charCodeAt(i); if (c < 128) { res[p++] = c; } else if (c < 2048) { res[p++] = c >> 6 | 192; res[p++] = c & 63 | 128; } else if (isSurrogatePair(msg, i)) { c = 65536 + ((c & 1023) << 10) + (msg.charCodeAt(++i) & 1023); res[p++] = c >> 18 | 240; res[p++] = c >> 12 & 63 | 128; res[p++] = c >> 6 & 63 | 128; res[p++] = c & 63 | 128; } else { res[p++] = c >> 12 | 224; res[p++] = c >> 6 & 63 | 128; res[p++] = c & 63 | 128; } } } else if (enc === "hex") { msg = msg.replace(/[^a-z0-9]+/ig, ""); if (msg.length % 2 !== 0) msg = "0" + msg; for (i = 0; i < msg.length; i += 2) res.push(parseInt(msg[i] + msg[i + 1], 16)); } } else { for (i = 0; i < msg.length; i++) res[i] = msg[i] | 0; } return res; } exports.toArray = toArray; function toHex2(msg) { var res = ""; for (var i = 0; i < msg.length; i++) res += zero2(msg[i].toString(16)); return res; } exports.toHex = toHex2; function htonl(w) { var res = w >>> 24 | w >>> 8 & 65280 | w << 8 & 16711680 | (w & 255) << 24; return res >>> 0; } exports.htonl = htonl; function toHex32(msg, endian) { var res = ""; for (var i = 0; i < msg.length; i++) { var w = msg[i]; if (endian === "little") w = htonl(w); res += zero8(w.toString(16)); } return res; } exports.toHex32 = toHex32; function zero2(word) { if (word.length === 1) return "0" + word; else return word; } exports.zero2 = zero2; function zero8(word) { if (word.length === 7) return "0" + word; else if (word.length === 6) return "00" + word; else if (word.length === 5) return "000" + word; else if (word.length === 4) return "0000" + word; else if (word.length === 3) return "00000" + word; else if (word.length === 2) return "000000" + word; else if (word.length === 1) return "0000000" + word; else return word; } exports.zero8 = zero8; function join32(msg, start, end, endian) { var len = end - start; assert2(len % 4 === 0); var res = new Array(len / 4); for (var i = 0, k = start; i < res.length; i++, k += 4) { var w; if (endian === "big") w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3]; else w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k]; res[i] = w >>> 0; } return res; } exports.join32 = join32; function split32(msg, endian) { var res = new Array(msg.length * 4); for (var i = 0, k = 0; i < msg.length; i++, k += 4) { var m = msg[i]; if (endian === "big") { res[k] = m >>> 24; res[k + 1] = m >>> 16 & 255; res[k + 2] = m >>> 8 & 255; res[k + 3] = m & 255; } else { res[k + 3] = m >>> 24; res[k + 2] = m >>> 16 & 255; res[k + 1] = m >>> 8 & 255; res[k] = m & 255; } } return res; } exports.split32 = split32; function rotr32(w, b) { return w >>> b | w << 32 - b; } exports.rotr32 = rotr32; function rotl32(w, b) { return w << b | w >>> 32 - b; } exports.rotl32 = rotl32; function sum32(a, b) { return a + b >>> 0; } exports.sum32 = sum32; function sum32_3(a, b, c) { return a + b + c >>> 0; } exports.sum32_3 = sum32_3; function sum32_4(a, b, c, d) { return a + b + c + d >>> 0; } exports.sum32_4 = sum32_4; function sum32_5(a, b, c, d, e) { return a + b + c + d + e >>> 0; } exports.sum32_5 = sum32_5; function sum64(buf, pos, ah, al) { var bh = buf[pos]; var bl = buf[pos + 1]; var lo = al + bl >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; buf[pos] = hi >>> 0; buf[pos + 1] = lo; } exports.sum64 = sum64; function sum64_hi(ah, al, bh, bl) { var lo = al + bl >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; return hi >>> 0; } exports.sum64_hi = sum64_hi; function sum64_lo(ah, al, bh, bl) { var lo = al + bl; return lo >>> 0; } exports.sum64_lo = sum64_lo; function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { var carry = 0; var lo = al; lo = lo + bl >>> 0; carry += lo < al ? 1 : 0; lo = lo + cl >>> 0; carry += lo < cl ? 1 : 0; lo = lo + dl >>> 0; carry += lo < dl ? 1 : 0; var hi = ah + bh + ch + dh + carry; return hi >>> 0; } exports.sum64_4_hi = sum64_4_hi; function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { var lo = al + bl + cl + dl; return lo >>> 0; } exports.sum64_4_lo = sum64_4_lo; function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var carry = 0; var lo = al; lo = lo + bl >>> 0; carry += lo < al ? 1 : 0; lo = lo + cl >>> 0; carry += lo < cl ? 1 : 0; lo = lo + dl >>> 0; carry += lo < dl ? 1 : 0; lo = lo + el >>> 0; carry += lo < el ? 1 : 0; var hi = ah + bh + ch + dh + eh + carry; return hi >>> 0; } exports.sum64_5_hi = sum64_5_hi; function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var lo = al + bl + cl + dl + el; return lo >>> 0; } exports.sum64_5_lo = sum64_5_lo; function rotr64_hi(ah, al, num) { var r2 = al << 32 - num | ah >>> num; return r2 >>> 0; } exports.rotr64_hi = rotr64_hi; function rotr64_lo(ah, al, num) { var r2 = ah << 32 - num | al >>> num; return r2 >>> 0; } exports.rotr64_lo = rotr64_lo; function shr64_hi(ah, al, num) { return ah >>> num; } exports.shr64_hi = shr64_hi; function shr64_lo(ah, al, num) { var r2 = ah << 32 - num | al >>> num; return r2 >>> 0; } exports.shr64_lo = shr64_lo; } }); // node_modules/hash.js/lib/hash/common.js var require_common = __commonJS({ "node_modules/hash.js/lib/hash/common.js"(exports) { "use strict"; var utils = require_utils(); var assert2 = require_minimalistic_assert(); function BlockHash() { this.pending = null; this.pendingTotal = 0; this.blockSize = this.constructor.blockSize; this.outSize = this.constructor.outSize; this.hmacStrength = this.constructor.hmacStrength; this.padLength = this.constructor.padLength / 8; this.endian = "big"; this._delta8 = this.blockSize / 8; this._delta32 = this.blockSize / 32; } exports.BlockHash = BlockHash; BlockHash.prototype.update = function update2(msg, enc) { msg = utils.toArray(msg, enc); if (!this.pending) this.pending = msg; else this.pending = this.pending.concat(msg); this.pendingTotal += msg.length; if (this.pending.length >= this._delta8) { msg = this.pending; var r2 = msg.length % this._delta8; this.pending = msg.slice(msg.length - r2, msg.length); if (this.pending.length === 0) this.pending = null; msg = utils.join32(msg, 0, msg.length - r2, this.endian); for (var i = 0; i < msg.length; i += this._delta32) this._update(msg, i, i + this._delta32); } return this; }; BlockHash.prototype.digest = function digest(enc) { this.update(this._pad()); assert2(this.pending === null); return this._digest(enc); }; BlockHash.prototype._pad = function pad() { var len = this.pendingTotal; var bytes = this._delta8; var k = bytes - (len + this.padLength) % bytes; var res = new Array(k + this.padLength); res[0] = 128; for (var i = 1; i < k; i++) res[i] = 0; len <<= 3; if (this.endian === "big") { for (var t = 8; t < this.padLength; t++) res[i++] = 0; res[i++] = 0; res[i++] = 0; res[i++] = 0; res[i++] = 0; res[i++] = len >>> 24 & 255; res[i++] = len >>> 16 & 255; res[i++] = len >>> 8 & 255; res[i++] = len & 255; } else { res[i++] = len & 255; res[i++] = len >>> 8 & 255; res[i++] = len >>> 16 & 255; res[i++] = len >>> 24 & 255; res[i++] = 0; res[i++] = 0; res[i++] = 0; res[i++] = 0; for (t = 8; t < this.padLength; t++) res[i++] = 0; } return res; }; } }); // node_modules/hash.js/lib/hash/sha/common.js var require_common2 = __commonJS({ "node_modules/hash.js/lib/hash/sha/common.js"(exports) { "use strict"; var utils = require_utils(); var rotr32 = utils.rotr32; function ft_1(s, x, y, z) { if (s === 0) return ch32(x, y, z); if (s === 1 || s === 3) return p32(x, y, z); if (s === 2) return maj32(x, y, z); } exports.ft_1 = ft_1; function ch32(x, y, z) { return x & y ^ ~x & z; } exports.ch32 = ch32; function maj32(x, y, z) { return x & y ^ x & z ^ y & z; } exports.maj32 = maj32; function p32(x, y, z) { return x ^ y ^ z; } exports.p32 = p32; function s0_256(x) { return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); } exports.s0_256 = s0_256; function s1_256(x) { return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); } exports.s1_256 = s1_256; function g0_256(x) { return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3; } exports.g0_256 = g0_256; function g1_256(x) { return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10; } exports.g1_256 = g1_256; } }); // node_modules/hash.js/lib/hash/sha/1.js var require__ = __commonJS({ "node_modules/hash.js/lib/hash/sha/1.js"(exports, module) { "use strict"; var utils = require_utils(); var common = require_common(); var shaCommon = require_common2(); var rotl32 = utils.rotl32; var sum32 = utils.sum32; var sum32_5 = utils.sum32_5; var ft_1 = shaCommon.ft_1; var BlockHash = common.BlockHash; var sha1_K = [ 1518500249, 1859775393, 2400959708, 3395469782 ]; function SHA1() { if (!(this instanceof SHA1)) return new SHA1(); BlockHash.call(this); this.h = [ 1732584193, 4023233417, 2562383102, 271733878, 3285377520 ]; this.W = new Array(80); } utils.inherits(SHA1, BlockHash); module.exports = SHA1; SHA1.blockSize = 512; SHA1.outSize = 160; SHA1.hmacStrength = 80; SHA1.padLength = 64; SHA1.prototype._update = function _update(msg, start) { var W = this.W; for (var i = 0; i < 16; i++) W[i] = msg[start + i]; for (; i < W.length; i++) W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); var a = this.h[0]; var b = this.h[1]; var c = this.h[2]; var d = this.h[3]; var e = this.h[4]; for (i = 0; i < W.length; i++) { var s = ~~(i / 20); var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]); e = d; d = c; c = rotl32(b, 30); b = a; a = t; } this.h[0] = sum32(this.h[0], a); this.h[1] = sum32(this.h[1], b); this.h[2] = sum32(this.h[2], c); this.h[3] = sum32(this.h[3], d); this.h[4] = sum32(this.h[4], e); }; SHA1.prototype._digest = function digest(enc) { if (enc === "hex") return utils.toHex32(this.h, "big"); else return utils.split32(this.h, "big"); }; } }); // node_modules/hash.js/lib/hash/sha/256.js var require__2 = __commonJS({ "node_modules/hash.js/lib/hash/sha/256.js"(exports, module) { "use strict"; var utils = require_utils(); var common = require_common(); var shaCommon = require_common2(); var assert2 = require_minimalistic_assert(); var sum32 = utils.sum32; var sum32_4 = utils.sum32_4; var sum32_5 = utils.sum32_5; var ch32 = shaCommon.ch32; var maj32 = shaCommon.maj32; var s0_256 = shaCommon.s0_256; var s1_256 = shaCommon.s1_256; var g0_256 = shaCommon.g0_256; var g1_256 = shaCommon.g1_256; var BlockHash = common.BlockHash; var sha256_K = [ 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298 ]; function SHA256() { if (!(this instanceof SHA256)) return new SHA256(); BlockHash.call(this); this.h = [ 1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225 ]; this.k = sha256_K; this.W = new Array(64); } utils.inherits(SHA256, BlockHash); module.exports = SHA256; SHA256.blockSize = 512; SHA256.outSize = 256; SHA256.hmacStrength = 192; SHA256.padLength = 64; SHA256.prototype._update = function _update(msg, start) { var W = this.W; for (var i = 0; i < 16; i++) W[i] = msg[start + i]; for (; i < W.length; i++) W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); var a = this.h[0]; var b = this.h[1]; var c = this.h[2]; var d = this.h[3]; var e = this.h[4]; var f = this.h[5]; var g = this.h[6]; var h = this.h[7]; assert2(this.k.length === W.length); for (i = 0; i < W.length; i++) { var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); var T2 = sum32(s0_256(a), maj32(a, b, c)); h = g; g = f; f = e; e = sum32(d, T1); d = c; c = b; b = a; a = sum32(T1, T2); } this.h[0] = sum32(this.h[0], a); this.h[1] = sum32(this.h[1], b); this.h[2] = sum32(this.h[2], c); this.h[3] = sum32(this.h[3], d); this.h[4] = sum32(this.h[4], e); this.h[5] = sum32(this.h[5], f); this.h[6] = sum32(this.h[6], g); this.h[7] = sum32(this.h[7], h); }; SHA256.prototype._digest = function digest(enc) { if (enc === "hex") return utils.toHex32(this.h, "big"); else return utils.split32(this.h, "big"); }; } }); // node_modules/hash.js/lib/hash/sha/224.js var require__3 = __commonJS({ "node_modules/hash.js/lib/hash/sha/224.js"(exports, module) { "use strict"; var utils = require_utils(); var SHA256 = require__2(); function SHA224() { if (!(this instanceof SHA224)) return new SHA224(); SHA256.call(this); this.h = [ 3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428 ]; } utils.inherits(SHA224, SHA256); module.exports = SHA224; SHA224.blockSize = 512; SHA224.outSize = 224; SHA224.hmacStrength = 192; SHA224.padLength = 64; SHA224.prototype._digest = function digest(enc) { if (enc === "hex") return utils.toHex32(this.h.slice(0, 7), "big"); else return utils.split32(this.h.slice(0, 7), "big"); }; } }); // node_modules/hash.js/lib/hash/sha/512.js var require__4 = __commonJS({ "node_modules/hash.js/lib/hash/sha/512.js"(exports, module) { "use strict"; var utils = require_utils(); var common = require_common(); var assert2 = require_minimalistic_assert(); var rotr64_hi = utils.rotr64_hi; var rotr64_lo = utils.rotr64_lo; var shr64_hi = utils.shr64_hi; var shr64_lo = utils.shr64_lo; var sum64 = utils.sum64; var sum64_hi = utils.sum64_hi; var sum64_lo = utils.sum64_lo; var sum64_4_hi = utils.sum64_4_hi; var sum64_4_lo = utils.sum64_4_lo; var sum64_5_hi = utils.sum64_5_hi; var sum64_5_lo = utils.sum64_5_lo; var BlockHash = common.BlockHash; var sha512_K = [ 1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591 ]; function SHA512() { if (!(this instanceof SHA512)) return new SHA512(); BlockHash.call(this); this.h = [ 1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209 ]; this.k = sha512_K; this.W = new Array(160); } utils.inherits(SHA512, BlockHash); module.exports = SHA512; SHA512.blockSize = 1024; SHA512.outSize = 512; SHA512.hmacStrength = 192; SHA512.padLength = 128; SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { var W = this.W; for (var i = 0; i < 32; i++) W[i] = msg[start + i]; for (; i < W.length; i += 2) { var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); var c1_hi = W[i - 14]; var c1_lo = W[i - 13]; var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); var c3_hi = W[i - 32]; var c3_lo = W[i - 31]; W[i] = sum64_4_hi( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo ); W[i + 1] = sum64_4_lo( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo ); } }; SHA512.prototype._update = function _update(msg, start) { this._prepareBlock(msg, start); var W = this.W; var ah = this.h[0]; var al = this.h[1]; var bh = this.h[2]; var bl = this.h[3]; var ch = this.h[4]; var cl = this.h[5]; var dh = this.h[6]; var dl = this.h[7]; var eh = this.h[8]; var el = this.h[9]; var fh = this.h[10]; var fl = this.h[11]; var gh = this.h[12]; var gl = this.h[13]; var hh = this.h[14]; var hl = this.h[15]; assert2(this.k.length === W.length); for (var i = 0; i < W.length; i += 2) { var c0_hi = hh; var c0_lo = hl; var c1_hi = s1_512_hi(eh, el); var c1_lo = s1_512_lo(eh, el); var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); var c3_hi = this.k[i]; var c3_lo = this.k[i + 1]; var c4_hi = W[i]; var c4_lo = W[i + 1]; var T1_hi = sum64_5_hi( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo ); var T1_lo = sum64_5_lo( c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo ); c0_hi = s0_512_hi(ah, al); c0_lo = s0_512_lo(ah, al); c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); hh = gh; hl = gl; gh = fh; gl = fl; fh = eh; fl = el; eh = sum64_hi(dh, dl, T1_hi, T1_lo); el = sum64_lo(dl, dl, T1_hi, T1_lo); dh = ch; dl = cl; ch = bh; cl = bl; bh = ah; bl = al; ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); } sum64(this.h, 0, ah, al); sum64(this.h, 2, bh, bl); sum64(this.h, 4, ch, cl); sum64(this.h, 6, dh, dl); sum64(this.h, 8, eh, el); sum64(this.h, 10, fh, fl); sum64(this.h, 12, gh, gl); sum64(this.h, 14, hh, hl); }; SHA512.proto