UNPKG

@etherna/sdk-js

Version:

Etherna SDKs for operations on the network

1,428 lines (1,416 loc) 444 kB
var It = Object.defineProperty; var ht = (n, e, t) => e in n ? It(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var V = (n, e, t) => (ht(n, typeof e != "symbol" ? e + "" : e, t), t); import axios from "axios"; import { produce } from "immer"; const SPAN_SIZE = 8, MAX_CHUNK_PAYLOAD_SIZE = 4096, SEGMENT_SIZE = 32, SEGMENT_PAIR_SIZE = 2 * SEGMENT_SIZE, HASH_SIZE = 32, CAC_SPAN_OFFSET = 0, CAC_PAYLOAD_OFFSET = CAC_SPAN_OFFSET + SPAN_SIZE, IDENTIFIER_SIZE = 32, SIGNATURE_SIZE = 65, SOC_IDENTIFIER_OFFSET = 0, SOC_SIGNATURE_OFFSET = SOC_IDENTIFIER_OFFSET + IDENTIFIER_SIZE, SOC_SPAN_OFFSET = SOC_SIGNATURE_OFFSET + SIGNATURE_SIZE, SOC_PAYLOAD_OFFSET = SOC_SPAN_OFFSET + SPAN_SIZE, STAMPS_DEPTH_MIN = 17, getBatchPercentUtilization = (n) => { const { utilization: e, depth: t, bucketDepth: s } = n; return e / 2 ** (t - s); }, stringToBase64 = (n) => typeof window > "u" ? Buffer.from(n).toString("base64") : window.btoa(n), buffersEquals = (n, e) => n.length === e.length && n.every((t, s) => t === e[s]), BZZ_REFERENCE_REGEX = /^[0-9a-f]{64}$/, isValidReference = (n) => BZZ_REFERENCE_REGEX.test(n); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var extendStatics = function(n, e) { return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, s) { t.__proto__ = s; } || function(t, s) { for (var r in s) s.hasOwnProperty(r) && (t[r] = s[r]); }, extendStatics(n, e); }; function __extends(n, e) { extendStatics(n, e); function t() { this.constructor = n; } n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t()); } /** * @license crypto-ts * MIT license */ var Hex = ( /** @class */ function() { function n() { } return n.stringify = /** * Converts a word array to a hex string. * * \@example * * let hexString = Hex.stringify(wordArray); * @param {?} wordArray The word array. * * @return {?} The hex string. * */ function(e) { for (var t = [], s = 0; s < e.sigBytes; s++) { var r = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255; t.push((r >>> 4).toString(16)), t.push((r & 15).toString(16)); } return t.join(""); }, n.parse = /** * Converts a hex string to a word array. * * \@example * * let wordArray = Hex.parse(hexString); * @param {?} hexStr The hex string. * * @return {?} The word array. * */ function(e) { for (var t = e.length, s = [], r = 0; r < t; r += 2) s[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4; return new WordArray(s, t / 2); }, n; }() ), WordArray = ( /** @class */ function() { function n(e, t) { this.words = e || [], t !== void 0 ? this.sigBytes = t : this.sigBytes = this.words.length * 4; } return n.random = /** * Creates a word array filled with random bytes. * * \@example * * let wordArray = WordArray.random(16); * @param {?} nBytes The number of random bytes to generate. * * @return {?} The random word array. * */ function(e) { for (var t = [], s = function(o) { var F = 987654321, U = 4294967295; return function() { F = 36969 * (F & 65535) + (F >> 16) & U, o = 18e3 * (o & 65535) + (o >> 16) & U; var d = (F << 16) + o & U; return d /= 4294967296, d += 0.5, d * (Math.random() > 0.5 ? 1 : -1); }; }, r = 0, Q = void 0; r < e; r += 4) { var a = s((Q || Math.random()) * 4294967296); Q = a() * 987654071, t.push(a() * 4294967296 | 0); } return new n(t, e); }, n.prototype.toString = /** * Converts this word array to a string. * * \@example * * let string = wordArray + ''; * let string = wordArray.toString(); * let string = wordArray.toString(CryptoJS.enc.Utf8); * @param {?=} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex * * @return {?} The stringified word array. * */ function(e) { return (e || Hex).stringify(this); }, n.prototype.concat = /** * Concatenates a word array to this word array. * * \@example * * wordArray1.concat(wordArray2); * @param {?} wordArray The word array to append. * * @return {?} This word array. * */ function(e) { if (this.clamp(), this.sigBytes % 4) for (var t = 0; t < e.sigBytes; t++) { var s = e.words[t >>> 2] >>> 24 - t % 4 * 8 & 255; this.words[this.sigBytes + t >>> 2] |= s << 24 - (this.sigBytes + t) % 4 * 8; } else for (var t = 0; t < e.sigBytes; t += 4) this.words[this.sigBytes + t >>> 2] = e.words[t >>> 2]; return this.sigBytes += e.sigBytes, this; }, n.prototype.clamp = /** * Removes insignificant bits. * * \@example * * wordArray.clamp(); * @return {?} */ function() { this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8, this.words.length = Math.ceil(this.sigBytes / 4); }, n.prototype.clone = /** * Creates a copy of this word array. * * \@example * * let clone = wordArray.clone(); * @return {?} The clone. * */ function() { return new n(this.words.slice(0), this.sigBytes); }, n; }() ), Latin1 = ( /** @class */ function() { function n() { } return n.stringify = /** * Converts a word array to a Latin1 string. * * \@example * * let latin1String = Latin1.stringify(wordArray); * @param {?} wordArray The word array. * * @return {?} The Latin1 string. * */ function(e) { for (var t = [], s = 0; s < e.sigBytes; s++) { var r = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255; t.push(String.fromCharCode(r)); } return t.join(""); }, n.parse = /** * Converts a Latin1 string to a word array. * * \@example * * let wordArray = Latin1.parse(latin1String); * @param {?} latin1Str The Latin1 string. * * @return {?} The word array. * */ function(e) { for (var t = e.length, s = [], r = 0; r < t; r++) s[r >>> 2] |= (e.charCodeAt(r) & 255) << 24 - r % 4 * 8; return new WordArray(s, t); }, n; }() ), Utf8 = ( /** @class */ function() { function n() { } return n.stringify = /** * Converts a word array to a UTF-8 string. * * \@example * * let utf8String = Utf8.stringify(wordArray); * @param {?} wordArray The word array. * * @return {?} The UTF-8 string. * */ function(e) { try { return decodeURIComponent(escape(Latin1.stringify(e))); } catch { throw new Error("Malformed UTF-8 data"); } }, n.parse = /** * Converts a UTF-8 string to a word array. * * \@example * * let wordArray = Utf8.parse(utf8String); * @param {?} utf8Str The UTF-8 string. * * @return {?} The word array. * */ function(e) { return Latin1.parse(unescape(encodeURIComponent(e))); }, n; }() ), BufferedBlockAlgorithm = ( /** @class */ function() { function n(e) { this._minBufferSize = 0, this.cfg = Object.assign({ blockSize: 1 }, e), this._data = new WordArray(), this._nDataBytes = 0; } return n.prototype.reset = /** * Resets this block algorithm's data buffer to its initial state. * * \@example * * bufferedBlockAlgorithm.reset(); * @return {?} */ function() { this._data = new WordArray(), this._nDataBytes = 0; }, n.prototype._append = /** * Adds new data to this block algorithm's buffer. * * \@example * * bufferedBlockAlgorithm._append('data'); * bufferedBlockAlgorithm._append(wordArray); * @param {?} data The data to append. Strings are converted to a WordArray using UTF-8. * * @return {?} */ function(e) { typeof e == "string" && (e = Utf8.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes; }, n.prototype._process = /** * Processes available data blocks. * * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. * * \@example * * let processedData = bufferedBlockAlgorithm._process(); * let processedData = bufferedBlockAlgorithm._process(!!'flush'); * @param {?=} doFlush Whether all blocks and partial blocks should be processed. * * @return {?} The processed data. * */ function(e) { if (!this.cfg.blockSize) throw new Error("missing blockSize in config"); var t = this.cfg.blockSize * 4, s = this._data.sigBytes / t; e ? s = Math.ceil(s) : s = Math.max((s | 0) - this._minBufferSize, 0); var r = s * this.cfg.blockSize, Q = Math.min(r * 4, this._data.sigBytes), a; if (r) { for (var o = 0; o < r; o += this.cfg.blockSize) this._doProcessBlock(this._data.words, o); a = this._data.words.splice(0, r), this._data.sigBytes -= Q; } return new WordArray(a, Q); }, n.prototype.clone = /** * Creates a copy of this object. * * \@example * * let clone = bufferedBlockAlgorithm.clone(); * @return {?} The clone. * */ function() { var e = this.constructor(); for (var t in this) this.hasOwnProperty(t) && (e[t] = this[t]); return e._data = this._data.clone(), e; }, n; }() ), Base = ( /** @class */ /* @__PURE__ */ function() { function n() { } return n; }() ), CipherParams = ( /** @class */ function(n) { __extends(e, n); function e(t) { var s = n.call(this) || this; return s.ciphertext = t.ciphertext, s.key = t.key, s.iv = t.iv, s.salt = t.salt, s.algorithm = t.algorithm, s.mode = t.mode, s.padding = t.padding, s.blockSize = t.blockSize, s.formatter = t.formatter, s; } return e.prototype.extend = /** * @param {?} additionalParams * @return {?} */ function(t) { return t.ciphertext !== void 0 && (this.ciphertext = t.ciphertext), t.key !== void 0 && (this.key = t.key), t.iv !== void 0 && (this.iv = t.iv), t.salt !== void 0 && (this.salt = t.salt), t.algorithm !== void 0 && (this.algorithm = t.algorithm), t.mode !== void 0 && (this.mode = t.mode), t.padding !== void 0 && (this.padding = t.padding), t.blockSize !== void 0 && (this.blockSize = t.blockSize), t.formatter !== void 0 && (this.formatter = t.formatter), this; }, e.prototype.toString = /** * Converts this cipher params object to a string. * * @throws Error If neither the formatter nor the default formatter is set. * * \@example * * let string = cipherParams + ''; * let string = cipherParams.toString(); * let string = cipherParams.toString(CryptoJS.format.OpenSSL); * @param {?=} formatter (Optional) The formatting strategy to use. * * @return {?} The stringified cipher params. * */ function(t) { if (t) return t.stringify(this); if (this.formatter) return this.formatter.stringify(this); throw new Error("cipher needs a formatter to be able to convert the result into a string"); }, e; }(Base) ), Base64 = ( /** @class */ function() { function n() { } return n.stringify = /** * Converts a word array to a Base64 string. * * \@example * * let base64String = Base64.stringify(wordArray); * @param {?} wordArray The word array. * * @return {?} The Base64 string. * */ function(e) { e.clamp(); for (var t = [], s = 0; s < e.sigBytes; s += 3) for (var r = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255, Q = e.words[s + 1 >>> 2] >>> 24 - (s + 1) % 4 * 8 & 255, a = e.words[s + 2 >>> 2] >>> 24 - (s + 2) % 4 * 8 & 255, o = r << 16 | Q << 8 | a, F = 0; F < 4 && s + F * 0.75 < e.sigBytes; F++) t.push(this._map.charAt(o >>> 6 * (3 - F) & 63)); var U = this._map.charAt(64); if (U) for (; t.length % 4; ) t.push(U); return t.join(""); }, n.parse = /** * Converts a Base64 string to a word array. * * \@example * * let wordArray = Base64.parse(base64String); * @param {?} base64Str The Base64 string. * * @return {?} The word array. * */ function(e) { var t = e.length; if (this._reverseMap === void 0) { this._reverseMap = []; for (var s = 0; s < this._map.length; s++) this._reverseMap[this._map.charCodeAt(s)] = s; } var r = this._map.charAt(64); if (r) { var Q = e.indexOf(r); Q !== -1 && (t = Q); } return this.parseLoop(e, t, this._reverseMap); }, n.parseLoop = /** * @param {?} base64Str * @param {?} base64StrLength * @param {?} reverseMap * @return {?} */ function(e, t, s) { for (var r = [], Q = 0, a = 0; a < t; a++) if (a % 4) { var o = s[e.charCodeAt(a - 1)] << a % 4 * 2, F = s[e.charCodeAt(a)] >>> 6 - a % 4 * 2; r[Q >>> 2] |= (o | F) << 24 - Q % 4 * 8, Q++; } return new WordArray(r, Q); }, n._map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", n._reverseMap = void 0, n; }() ), OpenSSL = ( /** @class */ function() { function n() { } return n.stringify = /** * Converts a cipher params object to an OpenSSL-compatible string. * * \@example * * let openSSLString = OpenSSLFormatter.stringify(cipherParams); * @param {?} cipherParams The cipher params object. * * @return {?} The OpenSSL-compatible string. * */ function(e) { if (!e.ciphertext) throw new Error("missing ciphertext in params"); var t = e.ciphertext, s = e.salt, r; if (s) { if (typeof s == "string") throw new Error("salt is expected to be a WordArray"); r = new WordArray([1398893684, 1701076831]).concat(s).concat(t); } else r = t; return r.toString(Base64); }, n.parse = /** * Converts an OpenSSL-compatible string to a cipher params object. * * \@example * * let cipherParams = OpenSSLFormatter.parse(openSSLString); * @param {?} openSSLStr The OpenSSL-compatible string. * * @return {?} The cipher params object. * */ function(e) { var t = Base64.parse(e), s; return t.words[0] === 1398893684 && t.words[1] === 1701076831 && (s = new WordArray(t.words.slice(2, 4)), t.words.splice(0, 4), t.sigBytes -= 16), new CipherParams({ ciphertext: t, salt: s }); }, n; }() ), SerializableCipher = ( /** @class */ function() { function n() { } return n.encrypt = /** * Encrypts a message. * * \@example * * let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); * let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); * let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { * iv: iv, * format: CryptoJS.format.OpenSSL * }); * @param {?} cipher The cipher algorithm to use. * @param {?} message The message to encrypt. * @param {?} key The key. * @param {?=} cfg (Optional) The configuration options to use for this operation. * * @return {?} A cipher params object. * */ function(e, t, s, r) { var Q = Object.assign({}, this.cfg, r), a = e.createEncryptor(s, Q), o = a.finalize(t); return new CipherParams({ ciphertext: o, key: s, iv: a.cfg.iv, algorithm: e, mode: ( /** @type {?} */ a.cfg.mode ), padding: ( /** @type {?} */ a.cfg.padding ), blockSize: a.cfg.blockSize, formatter: Q.format }); }, n.decrypt = /** * Decrypts serialized ciphertext. * * \@example * * let plaintext = SerializableCipher.decrypt( * AESAlgorithm, * formattedCiphertext, * key, { * iv: iv, * format: CryptoJS.format.OpenSSL * } * ); * * let plaintext = SerializableCipher.decrypt( * AESAlgorithm, * ciphertextParams, * key, { * iv: iv, * format: CryptoJS.format.OpenSSL * } * ); * @param {?} cipher The cipher algorithm to use. * @param {?} ciphertext The ciphertext to decrypt. * @param {?} key The key. * @param {?=} optionalCfg * @return {?} The plaintext. * */ function(e, t, s, r) { var Q = Object.assign({}, this.cfg, r); if (!Q.format) throw new Error("could not determine format"); if (t = this._parse(t, Q.format), !t.ciphertext) throw new Error("could not determine ciphertext"); var a = e.createDecryptor(s, Q).finalize(t.ciphertext); return a; }, n._parse = /** * Converts serialized ciphertext to CipherParams, * else assumed CipherParams already and returns ciphertext unchanged. * * \@example * * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); * @param {?} ciphertext The ciphertext. * @param {?} format The formatting strategy to use to parse serialized ciphertext. * * @return {?} The unserialized ciphertext. * */ function(e, t) { return typeof e == "string" ? t.parse(e) : e; }, n.cfg = { blockSize: 4, iv: new WordArray([]), format: OpenSSL }, n; }() ), Hasher = ( /** @class */ function(n) { __extends(e, n); function e(t) { var s = ( // Apply config defaults n.call(this, Object.assign({ blockSize: 16 }, t)) || this ); return s.reset(), s; } return e._createHelper = /** * Creates a shortcut function to a hasher's object interface. * * \@example * * let SHA256 = Hasher._createHelper(SHA256); * @param {?} hasher The hasher to create a helper for. * * @return {?} The shortcut function. * */ function(t) { function s(r, Q) { var a = t, o = new a(Q); return o.finalize(r); } return s; }, e.prototype.update = /** * Updates this hasher with a message. * * \@example * * hasher.update('message'); * hasher.update(wordArray); * @param {?} messageUpdate The message to append. * * @return {?} This hasher. * */ function(t) { return this._append(t), this._process(), this; }, e.prototype.finalize = /** * Finalizes the hash computation. * Note that the finalize operation is effectively a destructive, read-once operation. * * \@example * * let hash = hasher.finalize(); * let hash = hasher.finalize('message'); * let hash = hasher.finalize(wordArray); * @param {?} messageUpdate (Optional) A final message update. * * @return {?} The hash. * */ function(t) { t && this._append(t); var s = this._doFinalize(); return s; }, e; }(BufferedBlockAlgorithm) ), T = []; for (var i = 0; i < 64; i++) T[i] = Math.abs(Math.sin(i + 1)) * 4294967296 | 0; var MD5 = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.FF = /** * @param {?} a * @param {?} b * @param {?} c * @param {?} d * @param {?} x * @param {?} s * @param {?} t * @return {?} */ function(t, s, r, Q, a, o, F) { var U = t + (s & r | ~s & Q) + a + F; return (U << o | U >>> 32 - o) + s; }, e.GG = /** * @param {?} a * @param {?} b * @param {?} c * @param {?} d * @param {?} x * @param {?} s * @param {?} t * @return {?} */ function(t, s, r, Q, a, o, F) { var U = t + (s & Q | r & ~Q) + a + F; return (U << o | U >>> 32 - o) + s; }, e.HH = /** * @param {?} a * @param {?} b * @param {?} c * @param {?} d * @param {?} x * @param {?} s * @param {?} t * @return {?} */ function(t, s, r, Q, a, o, F) { var U = t + (s ^ r ^ Q) + a + F; return (U << o | U >>> 32 - o) + s; }, e.II = /** * @param {?} a * @param {?} b * @param {?} c * @param {?} d * @param {?} x * @param {?} s * @param {?} t * @return {?} */ function(t, s, r, Q, a, o, F) { var U = t + (r ^ (s | ~Q)) + a + F; return (U << o | U >>> 32 - o) + s; }, e.prototype.reset = /** * @return {?} */ function() { n.prototype.reset.call(this), this._hash = new WordArray([ 1732584193, 4023233417, 2562383102, 271733878 ]); }, e.prototype._doProcessBlock = /** * @param {?} M * @param {?} offset * @return {?} */ function(t, s) { for (var r = 0; r < 16; r++) { var Q = s + r, a = t[Q]; t[Q] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360; } var o = this._hash.words, F = t[s + 0], U = t[s + 1], d = t[s + 2], l = t[s + 3], C = t[s + 4], L = t[s + 5], f = t[s + 6], p = t[s + 7], b = t[s + 8], S = t[s + 9], m = t[s + 10], X = t[s + 11], j = t[s + 12], q = t[s + 13], _ = t[s + 14], O = t[s + 15], g = o[0], h = o[1], x = o[2], E = o[3]; g = e.FF(g, h, x, E, F, 7, T[0]), E = e.FF(E, g, h, x, U, 12, T[1]), x = e.FF(x, E, g, h, d, 17, T[2]), h = e.FF(h, x, E, g, l, 22, T[3]), g = e.FF(g, h, x, E, C, 7, T[4]), E = e.FF(E, g, h, x, L, 12, T[5]), x = e.FF(x, E, g, h, f, 17, T[6]), h = e.FF(h, x, E, g, p, 22, T[7]), g = e.FF(g, h, x, E, b, 7, T[8]), E = e.FF(E, g, h, x, S, 12, T[9]), x = e.FF(x, E, g, h, m, 17, T[10]), h = e.FF(h, x, E, g, X, 22, T[11]), g = e.FF(g, h, x, E, j, 7, T[12]), E = e.FF(E, g, h, x, q, 12, T[13]), x = e.FF(x, E, g, h, _, 17, T[14]), h = e.FF(h, x, E, g, O, 22, T[15]), g = e.GG(g, h, x, E, U, 5, T[16]), E = e.GG(E, g, h, x, f, 9, T[17]), x = e.GG(x, E, g, h, X, 14, T[18]), h = e.GG(h, x, E, g, F, 20, T[19]), g = e.GG(g, h, x, E, L, 5, T[20]), E = e.GG(E, g, h, x, m, 9, T[21]), x = e.GG(x, E, g, h, O, 14, T[22]), h = e.GG(h, x, E, g, C, 20, T[23]), g = e.GG(g, h, x, E, S, 5, T[24]), E = e.GG(E, g, h, x, _, 9, T[25]), x = e.GG(x, E, g, h, l, 14, T[26]), h = e.GG(h, x, E, g, b, 20, T[27]), g = e.GG(g, h, x, E, q, 5, T[28]), E = e.GG(E, g, h, x, d, 9, T[29]), x = e.GG(x, E, g, h, p, 14, T[30]), h = e.GG(h, x, E, g, j, 20, T[31]), g = e.HH(g, h, x, E, L, 4, T[32]), E = e.HH(E, g, h, x, b, 11, T[33]), x = e.HH(x, E, g, h, X, 16, T[34]), h = e.HH(h, x, E, g, _, 23, T[35]), g = e.HH(g, h, x, E, U, 4, T[36]), E = e.HH(E, g, h, x, C, 11, T[37]), x = e.HH(x, E, g, h, p, 16, T[38]), h = e.HH(h, x, E, g, m, 23, T[39]), g = e.HH(g, h, x, E, q, 4, T[40]), E = e.HH(E, g, h, x, F, 11, T[41]), x = e.HH(x, E, g, h, l, 16, T[42]), h = e.HH(h, x, E, g, f, 23, T[43]), g = e.HH(g, h, x, E, S, 4, T[44]), E = e.HH(E, g, h, x, j, 11, T[45]), x = e.HH(x, E, g, h, O, 16, T[46]), h = e.HH(h, x, E, g, d, 23, T[47]), g = e.II(g, h, x, E, F, 6, T[48]), E = e.II(E, g, h, x, p, 10, T[49]), x = e.II(x, E, g, h, _, 15, T[50]), h = e.II(h, x, E, g, L, 21, T[51]), g = e.II(g, h, x, E, j, 6, T[52]), E = e.II(E, g, h, x, l, 10, T[53]), x = e.II(x, E, g, h, m, 15, T[54]), h = e.II(h, x, E, g, U, 21, T[55]), g = e.II(g, h, x, E, b, 6, T[56]), E = e.II(E, g, h, x, O, 10, T[57]), x = e.II(x, E, g, h, f, 15, T[58]), h = e.II(h, x, E, g, q, 21, T[59]), g = e.II(g, h, x, E, C, 6, T[60]), E = e.II(E, g, h, x, X, 10, T[61]), x = e.II(x, E, g, h, d, 15, T[62]), h = e.II(h, x, E, g, S, 21, T[63]), o[0] = o[0] + g | 0, o[1] = o[1] + h | 0, o[2] = o[2] + x | 0, o[3] = o[3] + E | 0; }, e.prototype._doFinalize = /** * @return {?} */ function() { var t = this._data, s = t.words, r = this._nDataBytes * 8, Q = t.sigBytes * 8; s[Q >>> 5] |= 128 << 24 - Q % 32; var a = Math.floor(r / 4294967296), o = r; s[(Q + 64 >>> 9 << 4) + 15] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360, s[(Q + 64 >>> 9 << 4) + 14] = (o << 8 | o >>> 24) & 16711935 | (o << 24 | o >>> 8) & 4278255360, t.sigBytes = (s.length + 1) * 4, this._process(); for (var F = this._hash, U = F.words, d = 0; d < 4; d++) { var l = U[d]; U[d] = (l << 8 | l >>> 24) & 16711935 | (l << 24 | l >>> 8) & 4278255360; } return F; }, e; }(Hasher) ), EvpKDF = ( /** @class */ function() { function n(e) { this.cfg = Object.assign({ keySize: 128 / 32, hasher: MD5, iterations: 1 }, e); } return n.prototype.compute = /** * Derives a key from a password. * * \@example * * let key = kdf.compute(password, salt); * @param {?} password The password. * @param {?} salt A salt. * * @return {?} The derived key. * */ function(e, t) { for (var s = new /** @type {?} */ this.cfg.hasher(), r = new WordArray(), Q; r.words.length < this.cfg.keySize; ) { Q && s.update(Q), Q = s.update(e).finalize(t), s.reset(); for (var a = 1; a < this.cfg.iterations; a++) Q = s.finalize(Q), s.reset(); r.concat(Q); } return r.sigBytes = this.cfg.keySize * 4, r; }, n; }() ), OpenSSLKdf = ( /** @class */ function() { function n() { } return n.execute = /** * Derives a key and IV from a password. * * \@example * * let derivedParams = OpenSSL.execute('Password', 256/32, 128/32); * let derivedParams = OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); * @param {?} password The password to derive from. * @param {?} keySize The size in words of the key to generate. * @param {?} ivSize The size in words of the IV to generate. * @param {?=} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. * * @return {?} A cipher params object with the key, IV, and salt. * */ function(e, t, s, r) { r || (r = WordArray.random(64 / 8)); var Q = new EvpKDF({ keySize: t + s }).compute(e, r), a = new WordArray(Q.words.slice(t), s * 4); return Q.sigBytes = t * 4, new CipherParams({ key: Q, iv: a, salt: r }); }, n; }() ), PasswordBasedCipher = ( /** @class */ function() { function n() { } return n.encrypt = /** * Encrypts a message using a password. * * \@example * * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(AES, message, 'password'); * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(AES, message, 'password', { format: OpenSSL }); * @param {?} cipher The cipher algorithm to use. * @param {?} message The message to encrypt. * @param {?} password The password. * @param {?=} cfg (Optional) The configuration options to use for this operation. * * @return {?} A cipher params object. * */ function(e, t, s, r) { var Q = Object.assign({}, this.cfg, r); if (Q.kdf === void 0) throw new Error("missing kdf in config"); var a = Q.kdf.execute(s, e.keySize, e.ivSize); a.iv !== void 0 && (Q.iv = a.iv); var o = SerializableCipher.encrypt.call(this, e, t, a.key, Q); return o.extend(a); }, n.decrypt = /** * Decrypts serialized ciphertext using a password. * * \@example * * var plaintext = PasswordBasedCipher.decrypt(AES, formattedCiphertext, 'password', { format: OpenSSL }); * var plaintext = PasswordBasedCipher.decrypt(AES, ciphertextParams, 'password', { format: OpenSSL }); * @param {?} cipher The cipher algorithm to use. * @param {?} ciphertext The ciphertext to decrypt. * @param {?} password The password. * @param {?=} cfg (Optional) The configuration options to use for this operation. * * @return {?} The plaintext. * */ function(e, t, s, r) { var Q = Object.assign({}, this.cfg, r); if (Q.format === void 0) throw new Error("missing format in config"); if (t = this._parse(t, Q.format), Q.kdf === void 0) throw new Error("the key derivation function must be set"); var a = Q.kdf.execute(s, e.keySize, e.ivSize, t.salt); a.iv !== void 0 && (Q.iv = a.iv); var o = SerializableCipher.decrypt.call(this, e, t, a.key, Q); return o; }, n._parse = /** * Converts serialized ciphertext to CipherParams, * else assumed CipherParams already and returns ciphertext unchanged. * * \@example * * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); * @param {?} ciphertext The ciphertext. * @param {?} format The formatting strategy to use to parse serialized ciphertext. * * @return {?} The unserialized ciphertext. * */ function(e, t) { return typeof e == "string" ? t.parse(e) : e; }, n.cfg = { blockSize: 4, iv: new WordArray([]), format: OpenSSL, kdf: OpenSSLKdf }, n; }() ), Cipher = ( /** @class */ function(n) { __extends(e, n); function e(t, s, r) { var Q = ( // Apply config defaults n.call(this, Object.assign({ blockSize: 1 }, r)) || this ); return Q._xformMode = t, Q._key = s, Q.reset(), Q; } return e.createEncryptor = /** * Creates this cipher in encryption mode. * * \@example * * let cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); * @param {?} key The key. * @param {?=} cfg (Optional) The configuration options to use for this operation. * * @return {?} A cipher instance. * */ function(t, s) { var r = this; return new r(this._ENC_XFORM_MODE, t, s); }, e.createDecryptor = /** * Creates this cipher in decryption mode. * * \@example * * let cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); * @param {?} key The key. * @param {?=} cfg (Optional) The configuration options to use for this operation. * * @return {?} A cipher instance. * */ function(t, s) { var r = this; return new r(this._DEC_XFORM_MODE, t, s); }, e._createHelper = /** * Creates shortcut functions to a cipher's object interface. * * \@example * * let AES = Cipher._createHelper(AESAlgorithm); * @param {?} cipher The cipher to create a helper for. * * @return {?} An object with encrypt and decrypt shortcut functions. * */ function(t) { function s(Q, a, o) { return typeof a == "string" ? PasswordBasedCipher.encrypt(t, Q, a, o) : SerializableCipher.encrypt(t, Q, a, o); } function r(Q, a, o) { return typeof a == "string" ? PasswordBasedCipher.decrypt(t, Q, a, o) : SerializableCipher.decrypt(t, Q, a, o); } return { encrypt: s, decrypt: r }; }, e.prototype.process = /** * Adds data to be encrypted or decrypted. * * \@example * * let encrypted = cipher.process('data'); * let encrypted = cipher.process(wordArray); * @param {?} dataUpdate The data to encrypt or decrypt. * * @return {?} The data after processing. * */ function(t) { return this._append(t), this._process(); }, e.prototype.finalize = /** * Finalizes the encryption or decryption process. * Note that the finalize operation is effectively a destructive, read-once operation. * * \@example * * var encrypted = cipher.finalize(); * var encrypted = cipher.finalize('data'); * var encrypted = cipher.finalize(wordArray); * @param {?=} dataUpdate The final data to encrypt or decrypt. * * @return {?} The data after final processing. * */ function(t) { t && this._append(t); var s = this._doFinalize(); return s; }, e._ENC_XFORM_MODE = 1, e._DEC_XFORM_MODE = 2, e.keySize = 4, e.ivSize = 4, e; }(BufferedBlockAlgorithm) ), BlockCipherModeAlgorithm = ( /** @class */ function() { function n(e, t) { this.init(e, t); } return n.prototype.init = /** * Initializes a newly created mode. * * \@example * * var mode = CBC.Encryptor.create(cipher, iv.words); * @param {?} cipher A block cipher instance. * @param {?=} iv The IV words. * * @return {?} */ function(e, t) { this._cipher = e, this._iv = t; }, n; }() ), BlockCipherMode = ( /** @class */ function() { function n() { } return n.createEncryptor = /** * Creates this mode for encryption. * * \@example * * var mode = CBC.createEncryptor(cipher, iv.words); * @param {?} cipher A block cipher instance. * @param {?} iv The IV words. * * @return {?} */ function(e, t) { var s = this.Encryptor; return new s(e, t); }, n.createDecryptor = /** * Creates this mode for decryption. * * \@example * * var mode = CBC.createDecryptor(cipher, iv.words); * @param {?} cipher A block cipher instance. * @param {?} iv The IV words. * * @return {?} */ function(e, t) { var s = this.Decryptor; return new s(e, t); }, n.Encryptor = BlockCipherModeAlgorithm, n.Decryptor = BlockCipherModeAlgorithm, n; }() ), CBCEncryptor = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.prototype.processBlock = /** * Processes the data block at offset. * * \@example * * mode.processBlock(data.words, offset); * @param {?} words The data words to operate on. * @param {?} offset The offset where the block starts. * * @return {?} */ function(t, s) { if (this._cipher.cfg.blockSize === void 0) throw new Error("missing blockSize in cipher config"); this.xorBlock(t, s, this._cipher.cfg.blockSize), this._cipher.encryptBlock(t, s), this._prevBlock = t.slice(s, s + this._cipher.cfg.blockSize); }, e.prototype.xorBlock = /** * @param {?} words * @param {?} offset * @param {?} blockSize * @return {?} */ function(t, s, r) { var Q; if (this._iv ? (Q = this._iv, this._iv = void 0) : Q = this._prevBlock, Q !== void 0) for (var a = 0; a < r; a++) t[s + a] ^= Q[a]; }, e; }(BlockCipherModeAlgorithm) ), CBCDecryptor = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.prototype.processBlock = /** * Processes the data block at offset. * * \@example * * mode.processBlock(data.words, offset); * @param {?} words The data words to operate on. * @param {?} offset The offset where the block starts. * * @return {?} */ function(t, s) { if (this._cipher.cfg.blockSize === void 0) throw new Error("missing blockSize in cipher config"); var r = t.slice(s, s + this._cipher.cfg.blockSize); this._cipher.decryptBlock(t, s), this.xorBlock(t, s, this._cipher.cfg.blockSize), this._prevBlock = r; }, e.prototype.xorBlock = /** * @param {?} words * @param {?} offset * @param {?} blockSize * @return {?} */ function(t, s, r) { var Q; if (this._iv ? (Q = this._iv, this._iv = void 0) : Q = this._prevBlock, Q !== void 0) for (var a = 0; a < r; a++) t[s + a] ^= Q[a]; }, e; }(BlockCipherModeAlgorithm) ), CBC = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.Encryptor = CBCEncryptor, e.Decryptor = CBCDecryptor, e; }(BlockCipherMode) ), PKCS7 = ( /** @class */ function() { function n() { } return n.pad = /** * Pads data using the algorithm defined in PKCS #5/7. * * \@example * * PKCS7.pad(wordArray, 4); * @param {?} data The data to pad. * @param {?} blockSize The multiple that the data should be padded to. * * @return {?} */ function(e, t) { for (var s = t * 4, r = s - e.sigBytes % s, Q = r << 24 | r << 16 | r << 8 | r, a = [], o = 0; o < r; o += 4) a.push(Q); var F = new WordArray(a, r); e.concat(F); }, n.unpad = /** * Unpads data that had been padded using the algorithm defined in PKCS #5/7. * * \@example * * PKCS7.unpad(wordArray); * @param {?} data The data to unpad. * * @return {?} */ function(e) { var t = e.words[e.sigBytes - 1 >>> 2] & 255; e.sigBytes -= t; }, n; }() ), BlockCipher = ( /** @class */ function(n) { __extends(e, n); function e(t, s, r) { return n.call(this, t, s, Object.assign({ // default: 128 / 32 blockSize: 4, mode: CBC, padding: PKCS7 }, r)) || this; } return e.prototype.reset = /** * @return {?} */ function() { if (n.prototype.reset.call(this), this.cfg.mode === void 0) throw new Error("missing mode in config"); var t; this._xformMode === /** @type {?} */ this.constructor._ENC_XFORM_MODE ? t = this.cfg.mode.createEncryptor : (t = this.cfg.mode.createDecryptor, this._minBufferSize = 1), this._mode && this._mode.__creator === t ? this._mode.init(this, this.cfg.iv && this.cfg.iv.words) : (this._mode = t.call(this.cfg.mode, this, this.cfg.iv && this.cfg.iv.words), this._mode.__creator = t); }, e.prototype._doProcessBlock = /** * @param {?} words * @param {?} offset * @return {?} */ function(t, s) { this._mode.processBlock(t, s); }, e.prototype._doFinalize = /** * @return {?} */ function() { if (this.cfg.padding === void 0) throw new Error("missing padding in config"); var t; if (this._xformMode === /** @type {?} */ this.constructor._ENC_XFORM_MODE) { if (this.cfg.blockSize === void 0) throw new Error("missing blockSize in config"); this.cfg.padding.pad(this._data, this.cfg.blockSize), t = this._process(!0); } else t = this._process(!0), this.cfg.padding.unpad(t); return t; }, e; }(Cipher) ), SBOX = [], INV_SBOX = [], SUB_MIX_0 = [], SUB_MIX_1 = [], SUB_MIX_2 = [], SUB_MIX_3 = [], INV_SUB_MIX_0 = [], INV_SUB_MIX_1 = [], INV_SUB_MIX_2 = [], INV_SUB_MIX_3 = []; (function() { for (var n = [], e = 0; e < 256; e++) e < 128 ? n[e] = e << 1 : n[e] = e << 1 ^ 283; for (var t = 0, s = 0, e = 0; e < 256; e++) { var r = s ^ s << 1 ^ s << 2 ^ s << 3 ^ s << 4; r = r >>> 8 ^ r & 255 ^ 99, SBOX[t] = r, INV_SBOX[r] = t; var Q = n[t], a = n[Q], o = n[a], F = n[r] * 257 ^ r * 16843008; SUB_MIX_0[t] = F << 24 | F >>> 8, SUB_MIX_1[t] = F << 16 | F >>> 16, SUB_MIX_2[t] = F << 8 | F >>> 24, SUB_MIX_3[t] = F, F = o * 16843009 ^ a * 65537 ^ Q * 257 ^ t * 16843008, INV_SUB_MIX_0[r] = F << 24 | F >>> 8, INV_SUB_MIX_1[r] = F << 16 | F >>> 16, INV_SUB_MIX_2[r] = F << 8 | F >>> 24, INV_SUB_MIX_3[r] = F, t ? (t = Q ^ n[n[n[o ^ Q]]], s ^= n[n[s]]) : t = s = 1; } })(); var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], AES = ( /** @class */ function(n) { __extends(e, n); function e(t, s, r) { return n.call(this, t, s, r) || this; } return e.prototype.reset = /** * @return {?} */ function() { if (n.prototype.reset.call(this), !(this._nRounds && this._keyPriorReset === this._key)) { for (var t = this._keyPriorReset = this._key, s = t.words, r = t.sigBytes / 4, Q = this._nRounds = r + 6, a = (Q + 1) * 4, o = this._keySchedule = [], F = 0; F < a; F++) if (F < r) o[F] = s[F]; else { var U = o[F - 1]; F % r ? r > 6 && F % r === 4 && (U = SBOX[U >>> 24] << 24 | SBOX[U >>> 16 & 255] << 16 | SBOX[U >>> 8 & 255] << 8 | SBOX[U & 255]) : (U = U << 8 | U >>> 24, U = SBOX[U >>> 24] << 24 | SBOX[U >>> 16 & 255] << 16 | SBOX[U >>> 8 & 255] << 8 | SBOX[U & 255], U ^= RCON[F / r | 0] << 24), o[F] = o[F - r] ^ U; } for (var d = this._invKeySchedule = [], l = 0; l < a; l++) { var F = a - l, U = void 0; l % 4 ? U = o[F] : U = o[F - 4], l < 4 || F <= 4 ? d[l] = U : d[l] = INV_SUB_MIX_0[SBOX[U >>> 24]] ^ INV_SUB_MIX_1[SBOX[U >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[U >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[U & 255]]; } } }, e.prototype.encryptBlock = /** * @param {?} M * @param {?} offset * @return {?} */ function(t, s) { this._doCryptBlock(t, s, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); }, e.prototype.decryptBlock = /** * @param {?} M * @param {?} offset * @return {?} */ function(t, s) { var r = t[s + 1]; t[s + 1] = t[s + 3], t[s + 3] = r, this._doCryptBlock(t, s, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX), r = t[s + 1], t[s + 1] = t[s + 3], t[s + 3] = r; }, e.prototype._doCryptBlock = /** * @param {?} M * @param {?} offset * @param {?} keySchedule * @param {?} sub_mix_0 * @param {?} sub_mix_1 * @param {?} sub_mix_2 * @param {?} sub_mix_3 * @param {?} sbox * @return {?} */ function(t, s, r, Q, a, o, F, U) { for (var d = t[s] ^ r[0], l = t[s + 1] ^ r[1], C = t[s + 2] ^ r[2], L = t[s + 3] ^ r[3], f = 4, p = 1; p < this._nRounds; p++) { var b = Q[d >>> 24] ^ a[l >>> 16 & 255] ^ o[C >>> 8 & 255] ^ F[L & 255] ^ r[f++], S = Q[l >>> 24] ^ a[C >>> 16 & 255] ^ o[L >>> 8 & 255] ^ F[d & 255] ^ r[f++], m = Q[C >>> 24] ^ a[L >>> 16 & 255] ^ o[d >>> 8 & 255] ^ F[l & 255] ^ r[f++], X = Q[L >>> 24] ^ a[d >>> 16 & 255] ^ o[l >>> 8 & 255] ^ F[C & 255] ^ r[f++]; d = b, l = S, C = m, L = X; } var j = (U[d >>> 24] << 24 | U[l >>> 16 & 255] << 16 | U[C >>> 8 & 255] << 8 | U[L & 255]) ^ r[f++], q = (U[l >>> 24] << 24 | U[C >>> 16 & 255] << 16 | U[L >>> 8 & 255] << 8 | U[d & 255]) ^ r[f++], _ = (U[C >>> 24] << 24 | U[L >>> 16 & 255] << 16 | U[d >>> 8 & 255] << 8 | U[l & 255]) ^ r[f++], O = (U[L >>> 24] << 24 | U[d >>> 16 & 255] << 16 | U[l >>> 8 & 255] << 8 | U[C & 255]) ^ r[f++]; t[s] = j, t[s + 1] = q, t[s + 2] = _, t[s + 3] = O; }, e.keySize = 8, e; }(BlockCipher) ), H = [], K = [], W$1 = [], SHA256 = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.prototype.reset = /** * @return {?} */ function() { n.prototype.reset.call(this), this._hash = new WordArray(H.slice(0)); }, e.prototype._doProcessBlock = /** * @param {?} M * @param {?} offset * @return {?} */ function(t, s) { for (var r = this._hash.words, Q = r[0], a = r[1], o = r[2], F = r[3], U = r[4], d = r[5], l = r[6], C = r[7], L = 0; L < 64; L++) { if (L < 16) W$1[L] = t[s + L] | 0; else { var f = W$1[L - 15], p = (f << 25 | f >>> 7) ^ (f << 14 | f >>> 18) ^ f >>> 3, b = W$1[L - 2], S = (b << 15 | b >>> 17) ^ (b << 13 | b >>> 19) ^ b >>> 10; W$1[L] = p + W$1[L - 7] + S + W$1[L - 16]; } var m = U & d ^ ~U & l, X = Q & a ^ Q & o ^ a & o, j = (Q << 30 | Q >>> 2) ^ (Q << 19 | Q >>> 13) ^ (Q << 10 | Q >>> 22), q = (U << 26 | U >>> 6) ^ (U << 21 | U >>> 11) ^ (U << 7 | U >>> 25), _ = C + q + m + K[L] + W$1[L], O = j + X; C = l, l = d, d = U, U = F + _ | 0, F = o, o = a, a = Q, Q = _ + O | 0; } r[0] = r[0] + Q | 0, r[1] = r[1] + a | 0, r[2] = r[2] + o | 0, r[3] = r[3] + F | 0, r[4] = r[4] + U | 0, r[5] = r[5] + d | 0, r[6] = r[6] + l | 0, r[7] = r[7] + C | 0; }, e.prototype._doFinalize = /** * @return {?} */ function() { var t = this._nDataBytes * 8, s = this._data.sigBytes * 8; return this._data.words[s >>> 5] |= 128 << 24 - s % 32, this._data.words[(s + 64 >>> 9 << 4) + 14] = Math.floor(t / 4294967296), this._data.words[(s + 64 >>> 9 << 4) + 15] = t, this._data.sigBytes = this._data.words.length * 4, this._process(), this._hash; }, e; }(Hasher) ), ECBEncryptor = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.prototype.processBlock = /** * Processes the data block at offset. * * \@example * * mode.processBlock(data.words, offset); * @param {?} words The data words to operate on. * @param {?} offset The offset where the block starts. * * @return {?} */ function(t, s) { this._cipher.encryptBlock(t, s); }, e; }(BlockCipherModeAlgorithm) ), ECBDecryptor = ( /** @class */ function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.prototype.processBlock = /** * Processes the data block at offset. * * \@example * * mode.processBlock(data.words, offset); * @param {?} words The data words to operate on. * @param {?} offset The offset where the block starts. * * @return {?} */ function(t, s) { this._cipher.decryptBlock(t, s); }, e; }(BlockCipherModeAlgorithm) ); (function(n) { __extends(e, n); function e() { return n !== null && n.apply(this, arguments) || this; } return e.Encryptor = ECBEncryptor, e.Decryptor = ECBDecryptor, e; })(BlockCipherMode); var lib = { BlockCipher, Hasher }, algo = { AES, SHA256 }; lib.BlockCipher._createHelper(algo.AES); lib.Hasher._createHelper(algo.SHA256); var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, dist = { exports: {} }; (function(module, exports) { (function(n, e) { module.exports = e(); })(commonjsGlobal, function() { return (() => { var __webpack_modules__ = { 86: (module, exports, __webpack_require__) => { eval(`var __WEBPACK_AMD_DEFINE_RESULT__;/** * [js-sha3]{@link https://github.com/emn178/js-sha3} * * @version 0.8.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT */ /*jslint bitwise: true */ (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 = __webpack_require__.g; } else if (WEB_WORKER) { root = self; } var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && "object" === 'object' && module.exports; var AMD = true && __webpack_require__.amdO; 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 (bits, padding, outputType) { return function (message) { return new Keccak(bits, padding, bits).update(message)[outputType](); }; }; var createShakeOutputMethod = function (bits, padding, outputType) { return fu