From 016ebeb34c09090de7ed69a057072aa3da1e7813 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 14 Jul 2021 17:20:48 +0100 Subject: [PATCH 01/22] update models --- app/dashboard/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index a345fce03f2..cbee6aa3f3e 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -301,6 +301,7 @@ class Bounty(SuperModel): ('algorand_ext', 'Algorand Ext'), ('sia_ext', 'Sia Ext'), ('tezos_ext', 'Tezos Ext'), + ('casper_ext', 'Casper Ext'), ('fiat', 'Fiat'), ('manual', 'Manual') ) @@ -1423,6 +1424,7 @@ class BountyFulfillment(SuperModel): ('algorand_ext', 'algorand_ext'), ('sia_ext', 'sia_ext'), ('tezos_ext', 'tezos_ext'), + ('casper_ext', 'casper_ext'), ('manual', 'manual') ] @@ -1443,6 +1445,7 @@ class BountyFulfillment(SuperModel): ('ALGORAND', 'ALGORAND'), ('SIA', 'SIA'), ('TEZOS', 'TEZOS'), + ('CASPER', 'CASPER'), ('OTHERS', 'OTHERS') ] From 7fdb488cc47310334c7c17c70d2b2a12d5a480ab Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 14 Jul 2021 17:23:05 +0100 Subject: [PATCH 02/22] update views --- app/dashboard/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index d65216e17ed..0237baef034 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -6351,7 +6351,7 @@ def fulfill_bounty_v1(request): if payout_type == 'fiat' and not fulfiller_identifier: response['message'] = 'error: missing fulfiller_identifier' return JsonResponse(response) - elif payout_type in ['qr', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext'] and not fulfiller_address: + elif payout_type in ['qr', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext', 'casper_ext'] and not fulfiller_address: response['message'] = 'error: missing fulfiller_address' return JsonResponse(response) @@ -6468,8 +6468,8 @@ def payout_bounty_v1(request, fulfillment_id): if not payout_type: response['message'] = 'error: missing parameter payout_type' return JsonResponse(response) - if payout_type not in ['fiat', 'qr', 'web3_modal', 'polkadot_ext', 'harmony_ext' , 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext', 'manual']: - response['message'] = 'error: parameter payout_type must be fiat / qr / web_modal / polkadot_ext / harmony_ext / binance_ext / rsk_ext / xinfin_ext / nervos_ext / algorand_ext / sia_ext / tezos_ext / manual' + if payout_type not in ['fiat', 'qr', 'web3_modal', 'polkadot_ext', 'harmony_ext' , 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext', 'casper_ext', 'manual']: + response['message'] = 'error: parameter payout_type must be fiat / qr / web_modal / polkadot_ext / harmony_ext / binance_ext / rsk_ext / xinfin_ext / nervos_ext / algorand_ext / sia_ext / tezos_ext / casper_ext / manual' return JsonResponse(response) if payout_type == 'manual' and not bounty.event: response['message'] = 'error: payout_type manual is eligible only for hackathons' @@ -6535,7 +6535,7 @@ def payout_bounty_v1(request, fulfillment_id): fulfillment.save() record_bounty_activity(bounty, user, 'worker_paid', None, fulfillment) - elif payout_type in ['qr', 'web3_modal', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext']: + elif payout_type in ['qr', 'web3_modal', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext', 'casper_ext']: fulfillment.payout_status = 'pending' fulfillment.save() sync_payout(fulfillment) From 6ab78b492bca709b77c4b32a9a6fe90240eb0fbf Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 14 Jul 2021 17:25:44 +0100 Subject: [PATCH 03/22] update utils/mgmt cmd --- .../management/commands/sync_pending_fulfillments.py | 2 +- app/dashboard/utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/dashboard/management/commands/sync_pending_fulfillments.py b/app/dashboard/management/commands/sync_pending_fulfillments.py index 167256632cc..c50979df7da 100644 --- a/app/dashboard/management/commands/sync_pending_fulfillments.py +++ b/app/dashboard/management/commands/sync_pending_fulfillments.py @@ -36,7 +36,7 @@ def handle(self, *args, **options): ) # Extensions - ext_payout_types= ['web3_modal', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext'] + ext_payout_types= ['web3_modal', 'polkadot_ext', 'harmony_ext', 'binance_ext', 'rsk_ext', 'xinfin_ext', 'nervos_ext', 'algorand_ext', 'sia_ext', 'tezos_ext', 'casper_ext'] for ext_payout_type in ext_payout_types: ext_pending_fulfillments = pending_fulfillments.filter(payout_type=ext_payout_type) for fulfillment in ext_pending_fulfillments.all(): diff --git a/app/dashboard/utils.py b/app/dashboard/utils.py index 3ebd0f8238d..74e8d8fd623 100644 --- a/app/dashboard/utils.py +++ b/app/dashboard/utils.py @@ -42,6 +42,7 @@ from dashboard.sync.algorand import sync_algorand_payout from dashboard.sync.binance import sync_binance_payout from dashboard.sync.btc import sync_btc_payout +from dashboard.sync.casper import sync_casper_payout from dashboard.sync.celo import sync_celo_payout from dashboard.sync.etc import sync_etc_payout from dashboard.sync.eth import sync_eth_payout @@ -684,6 +685,9 @@ def sync_payout(fulfillment): elif fulfillment.payout_type == 'tezos_ext': sync_tezos_payout(fulfillment) + elif fulfillment.payout_type == 'casper_ext': + sync_casper_payout(fulfillment) + def get_bounty_id(issue_url, network): issue_url = normalize_url(issue_url) From 8c9ba275692c822a4fbd6c85a1a08e9536e62265 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 14 Jul 2021 19:13:24 +0100 Subject: [PATCH 04/22] sync function --- app/dashboard/sync/binance.py | 4 --- app/dashboard/sync/casper.py | 66 +++++++++++++++++++++++++++++++++++ app/dashboard/sync/tezos.py | 4 +-- 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 app/dashboard/sync/casper.py diff --git a/app/dashboard/sync/binance.py b/app/dashboard/sync/binance.py index 2a533470be2..a769b9d11e9 100644 --- a/app/dashboard/sync/binance.py +++ b/app/dashboard/sync/binance.py @@ -30,10 +30,6 @@ def get_binance_txn_status(fulfillment): 'params': [ txnid ] } - headers = { - 'Host': 'gitcoin.co' - } - binance_response = requests.post(binance_url, json=data).json() result = binance_response['result'] diff --git a/app/dashboard/sync/casper.py b/app/dashboard/sync/casper.py new file mode 100644 index 00000000000..80fb0acaa41 --- /dev/null +++ b/app/dashboard/sync/casper.py @@ -0,0 +1,66 @@ +import logging + +from django.utils import timezone + +import requests +from dashboard.sync.helpers import record_payout_activity + +logger = logging.getLogger(__name__) + + +def get_casper_txn_status(fulfillment): + txnid = fulfillment.payout_tx_id + token_name = fulfillment.token_name + funderAddress = fulfillment.funder_address + amount = fulfillment.payout_amount + payeeAddress = fulfillment.fulfiller_address + + if token_name != 'CSPR' or not txnid: + return None + + try: + data = { + 'id': 0, + 'jsonrpc': '2.0', + 'method': 'info_get_deploy', + 'params': [ txnid ] + } + + casper_response = requests.post('http://3.142.224.108:7777/rpc', json=data).json() + + result = casper_response['result'] + + if result: + if ( + result["deploy"]["hash"] == txnid + and result["deploy"]["header"]["account"] == funderAddress + and [ + x for x in result["deploy"]["session"]["Transfer"]["args"] if x[0] == 'target' + ][0][1]['parsed'] == payeeAddress + and float([ + x for x in result["deploy"]["session"]["Transfer"]["args"] if x[0] == 'amount' + ][0][1]['parsed']) == float(amount) * 10 ** 9 + ): + if result["execution_results"][0]["result"].get("Success", False) != False: + return 'success' + return 'expired' + + except Exception as e: + logger.error(f'error: get_casper_txn_status - {e}') + + return None + + +def sync_casper_payout(fulfillment): + if fulfillment.payout_tx_id: + txn_status = get_casper_txn_status(fulfillment) + + if txn_status == 'success': + fulfillment.payout_status = 'done' + fulfillment.accepted_on = timezone.now() + fulfillment.accepted = True + record_payout_activity(fulfillment) + elif txn_status == 'expired': + fulfillment.payout_status = 'expired' + + fulfillment.save() diff --git a/app/dashboard/sync/tezos.py b/app/dashboard/sync/tezos.py index 8eda1421be8..258c7a9bc93 100644 --- a/app/dashboard/sync/tezos.py +++ b/app/dashboard/sync/tezos.py @@ -56,10 +56,8 @@ def get_tezos_txn_status(fulfillment): and tx_response['sender']['address'] == funderAddress and tx_response['target']['address'] == payeeAddress and tx_response['amount'] == float(amount) * 10 ** 6 - and tx_response['status'] == 'applied' - and confirmations > 0 ): - if tx_response['status'] == 'applied': + if tx_response['status'] == 'applied' and confirmations > 0: return 'success' return 'expired' From 48e8fd49999e6a29cc65c2129f0c02bec288dfcc Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Thu, 15 Jul 2021 16:42:50 +0100 Subject: [PATCH 05/22] update new bounty pages --- app/assets/v2/js/pages/bounty_details2.js | 9 +++++++++ app/assets/v2/js/pages/hackathon_new_bounty.js | 4 ++++ app/assets/v2/js/pages/new_bounty.js | 4 ++++ app/dashboard/templates/bounty/details2.html | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/assets/v2/js/pages/bounty_details2.js b/app/assets/v2/js/pages/bounty_details2.js index 20ce375b631..71a565bfe2d 100644 --- a/app/assets/v2/js/pages/bounty_details2.js +++ b/app/assets/v2/js/pages/bounty_details2.js @@ -492,6 +492,10 @@ Vue.mixin({ tenant = 'TEZOS'; break; + case 'CSPR': + tenant = 'CASPER'; + break; + default: tenant = 'ETH'; } @@ -589,6 +593,10 @@ Vue.mixin({ case 'tezos_ext': payWithTezosExtension(fulfillment_id, fulfiller_address, vm, modal); break; + + case 'casper_ext': + payWithCasperExtension(fulfillment_id, fulfiller_address, vm, modal); + break; } }, closeBounty: function() { @@ -809,6 +817,7 @@ Vue.mixin({ case 'xinfin_ext': case 'algorand_ext': case 'tezos_ext': + case 'casper_ext': vm.fulfillment_context.active_step = 'payout_amount'; break; } diff --git a/app/assets/v2/js/pages/hackathon_new_bounty.js b/app/assets/v2/js/pages/hackathon_new_bounty.js index 86d24f86170..23404d6aef6 100644 --- a/app/assets/v2/js/pages/hackathon_new_bounty.js +++ b/app/assets/v2/js/pages/hackathon_new_bounty.js @@ -186,6 +186,10 @@ Vue.mixin({ // tezos type = 'tezos_ext'; break; + case '82795': + // casper + type = 'casper_ext'; + break; case '666': // paypal type = 'fiat'; diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index bb53be644f6..a436f68dcca 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -255,6 +255,10 @@ Vue.mixin({ // tezos type = 'tezos_ext'; break; + case '82795': + // casper + type = 'casper_ext'; + break; case '666': // paypal type = 'fiat'; diff --git a/app/dashboard/templates/bounty/details2.html b/app/dashboard/templates/bounty/details2.html index c685b78ab8b..274636924cf 100644 --- a/app/dashboard/templates/bounty/details2.html +++ b/app/dashboard/templates/bounty/details2.html @@ -438,7 +438,7 @@
{% trans "SUBMISSIONS" %}
-
+

Payout

From 25424c0dd04c416847fd1b081c029ebb9cb4b078 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Fri, 16 Jul 2021 13:27:43 +0100 Subject: [PATCH 06/22] fetch browserify casper + svg logo --- app/assets/v2/images/chains/casper.svg | 59 + app/assets/v2/js/lib/casper/casper-js-sdk.js | 19243 ++++++++++++++++ app/dashboard/templates/bounty/details2.html | 4 + .../templates/bounty/new_bounty.html | 4 + .../dashboard/hackathon/new_bounty.html | 4 + 5 files changed, 19314 insertions(+) create mode 100644 app/assets/v2/images/chains/casper.svg create mode 100644 app/assets/v2/js/lib/casper/casper-js-sdk.js diff --git a/app/assets/v2/images/chains/casper.svg b/app/assets/v2/images/chains/casper.svg new file mode 100644 index 00000000000..f933898a830 --- /dev/null +++ b/app/assets/v2/images/chains/casper.svg @@ -0,0 +1,59 @@ + + + + + + + + diff --git a/app/assets/v2/js/lib/casper/casper-js-sdk.js b/app/assets/v2/js/lib/casper/casper-js-sdk.js new file mode 100644 index 00000000000..fd27127c1d7 --- /dev/null +++ b/app/assets/v2/js/lib/casper/casper-js-sdk.js @@ -0,0 +1,19243 @@ +function getDefaultExportFromCjs(x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; + } + function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function(path, base) { + return commonjsRequire(path, base === void 0 || base === null ? module.path : base); + } + }, fn(module, module.exports), module.exports; + } + function commonjsRequire() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); + } + var lib = createCommonjsModule(function(module, exports) { + /*! For license information please see lib.js.LICENSE.txt */ + !function(t, e) { + module.exports = e(); + }(self, function() { + return (() => { + var t = {8794: (t2, e2, r2) => { + r2.d(e2, {i: () => n}); + const n = "bignumber/5.1.1"; + }, 2593: (t2, e2, r2) => { + r2.d(e2, {Zm: () => l, O$: () => p, g$: () => v, t2: () => w}); + var n = r2(3550), i = r2.n(n), o = r2(3286), a = r2(711), s = r2(8794), u = i().BN; + const f = new a.Yd(s.i), c = {}, h = 9007199254740991; + function l(t3) { + return t3 != null && (p.isBigNumber(t3) || typeof t3 == "number" && t3 % 1 == 0 || typeof t3 == "string" && !!t3.match(/^-?[0-9]+$/) || (0, o.isHexString)(t3) || typeof t3 == "bigint" || (0, o.isBytes)(t3)); + } + let d = false; + class p { + constructor(t3, e3) { + f.checkNew(new.target, p), t3 !== c && f.throwError("cannot call constructor directly; use BigNumber.from", a.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new (BigNumber)"}), this._hex = e3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t3) { + return m(b(this).fromTwos(t3)); + } + toTwos(t3) { + return m(b(this).toTwos(t3)); + } + abs() { + return this._hex[0] === "-" ? p.from(this._hex.substring(1)) : this; + } + add(t3) { + return m(b(this).add(b(t3))); + } + sub(t3) { + return m(b(this).sub(b(t3))); + } + div(t3) { + return p.from(t3).isZero() && g("division by zero", "div"), m(b(this).div(b(t3))); + } + mul(t3) { + return m(b(this).mul(b(t3))); + } + mod(t3) { + const e3 = b(t3); + return e3.isNeg() && g("cannot modulo negative values", "mod"), m(b(this).umod(e3)); + } + pow(t3) { + const e3 = b(t3); + return e3.isNeg() && g("cannot raise to negative values", "pow"), m(b(this).pow(e3)); + } + and(t3) { + const e3 = b(t3); + return (this.isNegative() || e3.isNeg()) && g("cannot 'and' negative values", "and"), m(b(this).and(e3)); + } + or(t3) { + const e3 = b(t3); + return (this.isNegative() || e3.isNeg()) && g("cannot 'or' negative values", "or"), m(b(this).or(e3)); + } + xor(t3) { + const e3 = b(t3); + return (this.isNegative() || e3.isNeg()) && g("cannot 'xor' negative values", "xor"), m(b(this).xor(e3)); + } + mask(t3) { + return (this.isNegative() || t3 < 0) && g("cannot mask negative values", "mask"), m(b(this).maskn(t3)); + } + shl(t3) { + return (this.isNegative() || t3 < 0) && g("cannot shift negative values", "shl"), m(b(this).shln(t3)); + } + shr(t3) { + return (this.isNegative() || t3 < 0) && g("cannot shift negative values", "shr"), m(b(this).shrn(t3)); + } + eq(t3) { + return b(this).eq(b(t3)); + } + lt(t3) { + return b(this).lt(b(t3)); + } + lte(t3) { + return b(this).lte(b(t3)); + } + gt(t3) { + return b(this).gt(b(t3)); + } + gte(t3) { + return b(this).gte(b(t3)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return b(this).isZero(); + } + toNumber() { + try { + return b(this).toNumber(); + } catch (t3) { + g("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch (t3) { + } + return f.throwError("this platform does not support BigInt", a.Yd.errors.UNSUPPORTED_OPERATION, {value: this.toString()}); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? d || (d = true, f.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? f.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", a.Yd.errors.UNEXPECTED_ARGUMENT, {}) : f.throwError("BigNumber.toString does not accept parameters", a.Yd.errors.UNEXPECTED_ARGUMENT, {})), b(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t3) { + return {type: "BigNumber", hex: this.toHexString()}; + } + static from(t3) { + if (t3 instanceof p) + return t3; + if (typeof t3 == "string") + return t3.match(/^-?0x[0-9a-f]+$/i) ? new p(c, y(t3)) : t3.match(/^-?[0-9]+$/) ? new p(c, y(new u(t3))) : f.throwArgumentError("invalid BigNumber string", "value", t3); + if (typeof t3 == "number") + return t3 % 1 && g("underflow", "BigNumber.from", t3), (t3 >= h || t3 <= -h) && g("overflow", "BigNumber.from", t3), p.from(String(t3)); + const e3 = t3; + if (typeof e3 == "bigint") + return p.from(e3.toString()); + if ((0, o.isBytes)(e3)) + return p.from((0, o.hexlify)(e3)); + if (e3) + if (e3.toHexString) { + const t4 = e3.toHexString(); + if (typeof t4 == "string") + return p.from(t4); + } else { + let t4 = e3._hex; + if (t4 == null && e3.type === "BigNumber" && (t4 = e3.hex), typeof t4 == "string" && ((0, o.isHexString)(t4) || t4[0] === "-" && (0, o.isHexString)(t4.substring(1)))) + return p.from(t4); + } + return f.throwArgumentError("invalid BigNumber value", "value", t3); + } + static isBigNumber(t3) { + return !(!t3 || !t3._isBigNumber); + } + } + function y(t3) { + if (typeof t3 != "string") + return y(t3.toString(16)); + if (t3[0] === "-") + return (t3 = t3.substring(1))[0] === "-" && f.throwArgumentError("invalid hex", "value", t3), (t3 = y(t3)) === "0x00" ? t3 : "-" + t3; + if (t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), t3 === "0x") + return "0x00"; + for (t3.length % 2 && (t3 = "0x0" + t3.substring(2)); t3.length > 4 && t3.substring(0, 4) === "0x00"; ) + t3 = "0x" + t3.substring(4); + return t3; + } + function m(t3) { + return p.from(y(t3)); + } + function b(t3) { + const e3 = p.from(t3).toHexString(); + return e3[0] === "-" ? new u("-" + e3.substring(3), 16) : new u(e3.substring(2), 16); + } + function g(t3, e3, r3) { + const n2 = {fault: t3, operation: e3}; + return r3 != null && (n2.value = r3), f.throwError(t3, a.Yd.errors.NUMERIC_FAULT, n2); + } + function v(t3) { + return new u(t3, 36).toString(16); + } + function w(t3) { + return new u(t3, 16).toString(36); + } + }, 2092: (t2, e2, r2) => { + r2.r(e2), r2.d(e2, {BigNumber: () => n.O$, FixedFormat: () => m, FixedNumber: () => b, _base16To36: () => n.t2, _base36To16: () => n.g$, formatFixed: () => p, parseFixed: () => y}); + var n = r2(2593), i = r2(3286), o = r2(711), a = r2(8794); + const s = new o.Yd(a.i), u = {}, f = n.O$.from(0), c = n.O$.from(-1); + function h(t3, e3, r3, n2) { + const i2 = {fault: e3, operation: r3}; + return n2 !== void 0 && (i2.value = n2), s.throwError(t3, o.Yd.errors.NUMERIC_FAULT, i2); + } + let l = "0"; + for (; l.length < 256; ) + l += l; + function d(t3) { + if (typeof t3 != "number") + try { + t3 = n.O$.from(t3).toNumber(); + } catch (t4) { + } + return typeof t3 == "number" && t3 >= 0 && t3 <= 256 && !(t3 % 1) ? "1" + l.substring(0, t3) : s.throwArgumentError("invalid decimal size", "decimals", t3); + } + function p(t3, e3) { + e3 == null && (e3 = 0); + const r3 = d(e3), i2 = (t3 = n.O$.from(t3)).lt(f); + i2 && (t3 = t3.mul(c)); + let o2 = t3.mod(r3).toString(); + for (; o2.length < r3.length - 1; ) + o2 = "0" + o2; + o2 = o2.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const a2 = t3.div(r3).toString(); + return t3 = a2 + "." + o2, i2 && (t3 = "-" + t3), t3; + } + function y(t3, e3) { + e3 == null && (e3 = 0); + const r3 = d(e3); + if (typeof t3 == "string" && t3.match(/^-?[0-9.,]+$/) || s.throwArgumentError("invalid decimal value", "value", t3), r3.length - 1 == 0) + return n.O$.from(t3); + const i2 = t3.substring(0, 1) === "-"; + i2 && (t3 = t3.substring(1)), t3 === "." && s.throwArgumentError("missing value", "value", t3); + const o2 = t3.split("."); + o2.length > 2 && s.throwArgumentError("too many decimal points", "value", t3); + let a2 = o2[0], u2 = o2[1]; + for (a2 || (a2 = "0"), u2 || (u2 = "0"), u2.length > r3.length - 1 && h("fractional component exceeds decimals", "underflow", "parseFixed"); u2.length < r3.length - 1; ) + u2 += "0"; + const f2 = n.O$.from(a2), l2 = n.O$.from(u2); + let p2 = f2.mul(r3).add(l2); + return i2 && (p2 = p2.mul(c)), p2; + } + class m { + constructor(t3, e3, r3, n2) { + t3 !== u && s.throwError("cannot use FixedFormat constructor; use FixedFormat.from", o.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new FixedFormat"}), this.signed = e3, this.width = r3, this.decimals = n2, this.name = (e3 ? "" : "u") + "fixed" + String(r3) + "x" + String(n2), this._multiplier = d(n2), Object.freeze(this); + } + static from(t3) { + if (t3 instanceof m) + return t3; + let e3 = true, r3 = 128, n2 = 18; + if (typeof t3 == "string") { + if (t3 === "fixed") + ; + else if (t3 === "ufixed") + e3 = false; + else if (t3 != null) { + const i2 = t3.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + i2 || s.throwArgumentError("invalid fixed format", "format", t3), e3 = i2[1] !== "u", r3 = parseInt(i2[2]), n2 = parseInt(i2[3]); + } + } else if (t3) { + const i2 = (e4, r4, n3) => t3[e4] == null ? n3 : (typeof t3[e4] !== r4 && s.throwArgumentError("invalid fixed format (" + e4 + " not " + r4 + ")", "format." + e4, t3[e4]), t3[e4]); + e3 = i2("signed", "boolean", e3), r3 = i2("width", "number", r3), n2 = i2("decimals", "number", n2); + } + return r3 % 8 && s.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", r3), n2 > 80 && s.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n2), new m(u, e3, r3, n2); + } + } + class b { + constructor(t3, e3, r3, n2) { + s.checkNew(new.target, b), t3 !== u && s.throwError("cannot use FixedNumber constructor; use FixedNumber.from", o.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new FixedFormat"}), this.format = n2, this._hex = e3, this._value = r3, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t3) { + this.format.name !== t3.format.name && s.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t3); + } + addUnsafe(t3) { + this._checkFormat(t3); + const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); + return b.fromValue(e3.add(r3), this.format.decimals, this.format); + } + subUnsafe(t3) { + this._checkFormat(t3); + const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); + return b.fromValue(e3.sub(r3), this.format.decimals, this.format); + } + mulUnsafe(t3) { + this._checkFormat(t3); + const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); + return b.fromValue(e3.mul(r3).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t3) { + this._checkFormat(t3); + const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); + return b.fromValue(e3.mul(this.format._multiplier).div(r3), this.format.decimals, this.format); + } + floor() { + let t3 = this.toString().split("."), e3 = b.from(t3[0], this.format); + const r3 = !t3[1].match(/^(0*)$/); + return this.isNegative() && r3 && (e3 = e3.subUnsafe(g)), e3; + } + ceiling() { + let t3 = this.toString().split("."), e3 = b.from(t3[0], this.format); + const r3 = !t3[1].match(/^(0*)$/); + return !this.isNegative() && r3 && (e3 = e3.addUnsafe(g)), e3; + } + round(t3) { + t3 == null && (t3 = 0); + let e3 = this.toString().split("."); + if ((t3 < 0 || t3 > 80 || t3 % 1) && s.throwArgumentError("invalid decimal count", "decimals", t3), e3[1].length <= t3) + return this; + const r3 = b.from("1" + l.substring(0, t3)); + return this.mulUnsafe(r3).addUnsafe(v).floor().divUnsafe(r3); + } + isZero() { + return this._value === "0.0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t3) { + if (t3 == null) + return this._hex; + t3 % 8 && s.throwArgumentError("invalid byte width", "width", t3); + const e3 = n.O$.from(this._hex).fromTwos(this.format.width).toTwos(t3).toHexString(); + return (0, i.hexZeroPad)(e3, t3 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t3) { + return b.fromString(this._value, t3); + } + static fromValue(t3, e3, r3) { + return r3 != null || e3 == null || (0, n.Zm)(e3) || (r3 = e3, e3 = null), e3 == null && (e3 = 0), r3 == null && (r3 = "fixed"), b.fromString(p(t3, e3), m.from(r3)); + } + static fromString(t3, e3) { + e3 == null && (e3 = "fixed"); + const r3 = m.from(e3), n2 = y(t3, r3.decimals); + !r3.signed && n2.lt(f) && h("unsigned value cannot be negative", "overflow", "value", t3); + let o2 = null; + r3.signed ? o2 = n2.toTwos(r3.width).toHexString() : (o2 = n2.toHexString(), o2 = (0, i.hexZeroPad)(o2, r3.width / 8)); + const a2 = p(n2, r3.decimals); + return new b(u, o2, a2, r3); + } + static fromBytes(t3, e3) { + e3 == null && (e3 = "fixed"); + const r3 = m.from(e3); + if ((0, i.arrayify)(t3).length > r3.width / 8) + throw new Error("overflow"); + let o2 = n.O$.from(t3); + r3.signed && (o2 = o2.fromTwos(r3.width)); + const a2 = o2.toTwos((r3.signed ? 0 : 1) + r3.width).toHexString(), s2 = p(o2, r3.decimals); + return new b(u, a2, s2, r3); + } + static from(t3, e3) { + if (typeof t3 == "string") + return b.fromString(t3, e3); + if ((0, i.isBytes)(t3)) + return b.fromBytes(t3, e3); + try { + return b.fromValue(t3, 0, e3); + } catch (t4) { + if (t4.code !== o.Yd.errors.INVALID_ARGUMENT) + throw t4; + } + return s.throwArgumentError("invalid FixedNumber value", "value", t3); + } + static isFixedNumber(t3) { + return !(!t3 || !t3._isFixedNumber); + } + } + const g = b.from(1), v = b.from("0.5"); + }, 3286: (t2, e2, r2) => { + r2.r(e2), r2.d(e2, {arrayify: () => u, concat: () => f, hexConcat: () => b, hexDataLength: () => y, hexDataSlice: () => m, hexStripZeros: () => v, hexValue: () => g, hexZeroPad: () => w, hexlify: () => p, isBytes: () => s, isBytesLike: () => a, isHexString: () => l, joinSignature: () => M, splitSignature: () => _, stripZeros: () => c, zeroPad: () => h}); + const n = new (r2(711)).Yd("bytes/5.1.0"); + function i(t3) { + return !!t3.toHexString; + } + function o(t3) { + return t3.slice || (t3.slice = function() { + const e3 = Array.prototype.slice.call(arguments); + return o(new Uint8Array(Array.prototype.slice.apply(t3, e3))); + }), t3; + } + function a(t3) { + return l(t3) && !(t3.length % 2) || s(t3); + } + function s(t3) { + if (t3 == null) + return false; + if (t3.constructor === Uint8Array) + return true; + if (typeof t3 == "string") + return false; + if (t3.length == null) + return false; + for (let e3 = 0; e3 < t3.length; e3++) { + const r3 = t3[e3]; + if (typeof r3 != "number" || r3 < 0 || r3 >= 256 || r3 % 1) + return false; + } + return true; + } + function u(t3, e3) { + if (e3 || (e3 = {}), typeof t3 == "number") { + n.checkSafeUint53(t3, "invalid arrayify value"); + const e4 = []; + for (; t3; ) + e4.unshift(255 & t3), t3 = parseInt(String(t3 / 256)); + return e4.length === 0 && e4.push(0), o(new Uint8Array(e4)); + } + if (e3.allowMissingPrefix && typeof t3 == "string" && t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), i(t3) && (t3 = t3.toHexString()), l(t3)) { + let r3 = t3.substring(2); + r3.length % 2 && (e3.hexPad === "left" ? r3 = "0x0" + r3.substring(2) : e3.hexPad === "right" ? r3 += "0" : n.throwArgumentError("hex data is odd-length", "value", t3)); + const i2 = []; + for (let t4 = 0; t4 < r3.length; t4 += 2) + i2.push(parseInt(r3.substring(t4, t4 + 2), 16)); + return o(new Uint8Array(i2)); + } + return s(t3) ? o(new Uint8Array(t3)) : n.throwArgumentError("invalid arrayify value", "value", t3); + } + function f(t3) { + const e3 = t3.map((t4) => u(t4)), r3 = e3.reduce((t4, e4) => t4 + e4.length, 0), n2 = new Uint8Array(r3); + return e3.reduce((t4, e4) => (n2.set(e4, t4), t4 + e4.length), 0), o(n2); + } + function c(t3) { + let e3 = u(t3); + if (e3.length === 0) + return e3; + let r3 = 0; + for (; r3 < e3.length && e3[r3] === 0; ) + r3++; + return r3 && (e3 = e3.slice(r3)), e3; + } + function h(t3, e3) { + (t3 = u(t3)).length > e3 && n.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(e3); + return r3.set(t3, e3 - t3.length), o(r3); + } + function l(t3, e3) { + return !(typeof t3 != "string" || !t3.match(/^0x[0-9A-Fa-f]*$/) || e3 && t3.length !== 2 + 2 * e3); + } + const d = "0123456789abcdef"; + function p(t3, e3) { + if (e3 || (e3 = {}), typeof t3 == "number") { + n.checkSafeUint53(t3, "invalid hexlify value"); + let e4 = ""; + for (; t3; ) + e4 = d[15 & t3] + e4, t3 = Math.floor(t3 / 16); + return e4.length ? (e4.length % 2 && (e4 = "0" + e4), "0x" + e4) : "0x00"; + } + if (e3.allowMissingPrefix && typeof t3 == "string" && t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), i(t3)) + return t3.toHexString(); + if (l(t3)) + return t3.length % 2 && (e3.hexPad === "left" ? t3 = "0x0" + t3.substring(2) : e3.hexPad === "right" ? t3 += "0" : n.throwArgumentError("hex data is odd-length", "value", t3)), t3.toLowerCase(); + if (s(t3)) { + let e4 = "0x"; + for (let r3 = 0; r3 < t3.length; r3++) { + let n2 = t3[r3]; + e4 += d[(240 & n2) >> 4] + d[15 & n2]; + } + return e4; + } + return n.throwArgumentError("invalid hexlify value", "value", t3); + } + function y(t3) { + if (typeof t3 != "string") + t3 = p(t3); + else if (!l(t3) || t3.length % 2) + return null; + return (t3.length - 2) / 2; + } + function m(t3, e3, r3) { + return typeof t3 != "string" ? t3 = p(t3) : (!l(t3) || t3.length % 2) && n.throwArgumentError("invalid hexData", "value", t3), e3 = 2 + 2 * e3, r3 != null ? "0x" + t3.substring(e3, 2 + 2 * r3) : "0x" + t3.substring(e3); + } + function b(t3) { + let e3 = "0x"; + return t3.forEach((t4) => { + e3 += p(t4).substring(2); + }), e3; + } + function g(t3) { + const e3 = v(p(t3, {hexPad: "left"})); + return e3 === "0x" ? "0x0" : e3; + } + function v(t3) { + typeof t3 != "string" && (t3 = p(t3)), l(t3) || n.throwArgumentError("invalid hex string", "value", t3), t3 = t3.substring(2); + let e3 = 0; + for (; e3 < t3.length && t3[e3] === "0"; ) + e3++; + return "0x" + t3.substring(e3); + } + function w(t3, e3) { + for (typeof t3 != "string" ? t3 = p(t3) : l(t3) || n.throwArgumentError("invalid hex string", "value", t3), t3.length > 2 * e3 + 2 && n.throwArgumentError("value out of range", "value", arguments[1]); t3.length < 2 * e3 + 2; ) + t3 = "0x0" + t3.substring(2); + return t3; + } + function _(t3) { + const e3 = {r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0}; + if (a(t3)) { + const r3 = u(t3); + r3.length !== 65 && n.throwArgumentError("invalid signature string; must be 65 bytes", "signature", t3), e3.r = p(r3.slice(0, 32)), e3.s = p(r3.slice(32, 64)), e3.v = r3[64], e3.v < 27 && (e3.v === 0 || e3.v === 1 ? e3.v += 27 : n.throwArgumentError("signature invalid v byte", "signature", t3)), e3.recoveryParam = 1 - e3.v % 2, e3.recoveryParam && (r3[32] |= 128), e3._vs = p(r3.slice(32, 64)); + } else { + if (e3.r = t3.r, e3.s = t3.s, e3.v = t3.v, e3.recoveryParam = t3.recoveryParam, e3._vs = t3._vs, e3._vs != null) { + const r4 = h(u(e3._vs), 32); + e3._vs = p(r4); + const i3 = r4[0] >= 128 ? 1 : 0; + e3.recoveryParam == null ? e3.recoveryParam = i3 : e3.recoveryParam !== i3 && n.throwArgumentError("signature recoveryParam mismatch _vs", "signature", t3), r4[0] &= 127; + const o2 = p(r4); + e3.s == null ? e3.s = o2 : e3.s !== o2 && n.throwArgumentError("signature v mismatch _vs", "signature", t3); + } + e3.recoveryParam == null ? e3.v == null ? n.throwArgumentError("signature missing v and recoveryParam", "signature", t3) : e3.v === 0 || e3.v === 1 ? e3.recoveryParam = e3.v : e3.recoveryParam = 1 - e3.v % 2 : e3.v == null ? e3.v = 27 + e3.recoveryParam : e3.recoveryParam !== 1 - e3.v % 2 && n.throwArgumentError("signature recoveryParam mismatch v", "signature", t3), e3.r != null && l(e3.r) ? e3.r = w(e3.r, 32) : n.throwArgumentError("signature missing or invalid r", "signature", t3), e3.s != null && l(e3.s) ? e3.s = w(e3.s, 32) : n.throwArgumentError("signature missing or invalid s", "signature", t3); + const r3 = u(e3.s); + r3[0] >= 128 && n.throwArgumentError("signature s out of range", "signature", t3), e3.recoveryParam && (r3[0] |= 128); + const i2 = p(r3); + e3._vs && (l(e3._vs) || n.throwArgumentError("signature invalid _vs", "signature", t3), e3._vs = w(e3._vs, 32)), e3._vs == null ? e3._vs = i2 : e3._vs !== i2 && n.throwArgumentError("signature _vs mismatch v and s", "signature", t3); + } + return e3; + } + function M(t3) { + return p(f([(t3 = _(t3)).r, t3.s, t3.recoveryParam ? "0x1c" : "0x1b"])); + } + }, 2279: (t2, e2, r2) => { + r2.r(e2), r2.d(e2, {AddressZero: () => n, EtherSymbol: () => l, HashZero: () => h, MaxUint256: () => c, NegativeOne: () => o, One: () => s, Two: () => u, WeiPerEther: () => f, Zero: () => a}); + const n = "0x0000000000000000000000000000000000000000"; + var i = r2(2593); + const o = i.O$.from(-1), a = i.O$.from(0), s = i.O$.from(1), u = i.O$.from(2), f = i.O$.from("1000000000000000000"), c = i.O$.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), h = "0x0000000000000000000000000000000000000000000000000000000000000000", l = "\u039E"; + }, 711: (t2, e2, r2) => { + r2.d(e2, {Yd: () => h}); + let n = false, i = false; + const o = {debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5}; + let a = o.default, s = null; + const u = function() { + try { + const t3 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((e3) => { + try { + if ("test".normalize(e3) !== "test") + throw new Error("bad normalize"); + } catch (r3) { + t3.push(e3); + } + }), t3.length) + throw new Error("missing " + t3.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (t3) { + return t3.message; + } + return null; + }(); + var f, c; + !function(t3) { + t3.DEBUG = "DEBUG", t3.INFO = "INFO", t3.WARNING = "WARNING", t3.ERROR = "ERROR", t3.OFF = "OFF"; + }(f || (f = {})), function(t3) { + t3.UNKNOWN_ERROR = "UNKNOWN_ERROR", t3.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", t3.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", t3.NETWORK_ERROR = "NETWORK_ERROR", t3.SERVER_ERROR = "SERVER_ERROR", t3.TIMEOUT = "TIMEOUT", t3.BUFFER_OVERRUN = "BUFFER_OVERRUN", t3.NUMERIC_FAULT = "NUMERIC_FAULT", t3.MISSING_NEW = "MISSING_NEW", t3.INVALID_ARGUMENT = "INVALID_ARGUMENT", t3.MISSING_ARGUMENT = "MISSING_ARGUMENT", t3.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", t3.CALL_EXCEPTION = "CALL_EXCEPTION", t3.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", t3.NONCE_EXPIRED = "NONCE_EXPIRED", t3.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", t3.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; + }(c || (c = {})); + class h { + constructor(t3) { + Object.defineProperty(this, "version", {enumerable: true, value: t3, writable: false}); + } + _log(t3, e3) { + const r3 = t3.toLowerCase(); + o[r3] == null && this.throwArgumentError("invalid log level name", "logLevel", t3), a > o[r3] || console.log.apply(console, e3); + } + debug(...t3) { + this._log(h.levels.DEBUG, t3); + } + info(...t3) { + this._log(h.levels.INFO, t3); + } + warn(...t3) { + this._log(h.levels.WARNING, t3); + } + makeError(t3, e3, r3) { + if (i) + return this.makeError("censored error", e3, {}); + e3 || (e3 = h.errors.UNKNOWN_ERROR), r3 || (r3 = {}); + const n2 = []; + Object.keys(r3).forEach((t4) => { + try { + n2.push(t4 + "=" + JSON.stringify(r3[t4])); + } catch (e4) { + n2.push(t4 + "=" + JSON.stringify(r3[t4].toString())); + } + }), n2.push(`code=${e3}`), n2.push(`version=${this.version}`); + const o2 = t3; + n2.length && (t3 += " (" + n2.join(", ") + ")"); + const a2 = new Error(t3); + return a2.reason = o2, a2.code = e3, Object.keys(r3).forEach(function(t4) { + a2[t4] = r3[t4]; + }), a2; + } + throwError(t3, e3, r3) { + throw this.makeError(t3, e3, r3); + } + throwArgumentError(t3, e3, r3) { + return this.throwError(t3, h.errors.INVALID_ARGUMENT, {argument: e3, value: r3}); + } + assert(t3, e3, r3, n2) { + t3 || this.throwError(e3, r3, n2); + } + assertArgument(t3, e3, r3, n2) { + t3 || this.throwArgumentError(e3, r3, n2); + } + checkNormalize(t3) { + u && this.throwError("platform missing String.prototype.normalize", h.errors.UNSUPPORTED_OPERATION, {operation: "String.prototype.normalize", form: u}); + } + checkSafeUint53(t3, e3) { + typeof t3 == "number" && (e3 == null && (e3 = "value not safe"), (t3 < 0 || t3 >= 9007199254740991) && this.throwError(e3, h.errors.NUMERIC_FAULT, {operation: "checkSafeInteger", fault: "out-of-safe-range", value: t3}), t3 % 1 && this.throwError(e3, h.errors.NUMERIC_FAULT, {operation: "checkSafeInteger", fault: "non-integer", value: t3})); + } + checkArgumentCount(t3, e3, r3) { + r3 = r3 ? ": " + r3 : "", t3 < e3 && this.throwError("missing argument" + r3, h.errors.MISSING_ARGUMENT, {count: t3, expectedCount: e3}), t3 > e3 && this.throwError("too many arguments" + r3, h.errors.UNEXPECTED_ARGUMENT, {count: t3, expectedCount: e3}); + } + checkNew(t3, e3) { + t3 !== Object && t3 != null || this.throwError("missing new", h.errors.MISSING_NEW, {name: e3.name}); + } + checkAbstract(t3, e3) { + t3 === e3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(e3.name) + " directly; use a sub-class", h.errors.UNSUPPORTED_OPERATION, {name: t3.name, operation: "new"}) : t3 !== Object && t3 != null || this.throwError("missing new", h.errors.MISSING_NEW, {name: e3.name}); + } + static globalLogger() { + return s || (s = new h("logger/5.1.0")), s; + } + static setCensorship(t3, e3) { + if (!t3 && e3 && this.globalLogger().throwError("cannot permanently disable censorship", h.errors.UNSUPPORTED_OPERATION, {operation: "setCensorship"}), n) { + if (!t3) + return; + this.globalLogger().throwError("error censorship permanent", h.errors.UNSUPPORTED_OPERATION, {operation: "setCensorship"}); + } + i = !!t3, n = !!e3; + } + static setLogLevel(t3) { + const e3 = o[t3.toLowerCase()]; + e3 != null ? a = e3 : h.globalLogger().warn("invalid log level - " + t3); + } + static from(t3) { + return new h(t3); + } + } + h.errors = c, h.levels = f; + }, 2440: function(t2, e2) { + var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o) { + function a(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o(t5); + } + } + function s(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a, s); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, n = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o, a = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { + return this; + }), o; + function s(o2) { + return function(s2) { + return function(o3) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o3[1])).done) + return i2; + switch (n2 = 0, i2 && (o3 = [2 & o3[0], i2.value]), o3[0]) { + case 0: + case 1: + i2 = o3; + break; + case 4: + return a.label++, {value: o3[1], done: false}; + case 5: + a.label++, n2 = o3[1], o3 = [0]; + continue; + case 7: + o3 = a.ops.pop(), a.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a.trys).length > 0 && i2[i2.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { + a = 0; + continue; + } + if (o3[0] === 3 && (!i2 || o3[1] > i2[0] && o3[1] < i2[3])) { + a.label = o3[1]; + break; + } + if (o3[0] === 6 && a.label < i2[1]) { + a.label = i2[1], i2 = o3; + break; + } + if (i2 && a.label < i2[2]) { + a.label = i2[2], a.ops.push(o3); + break; + } + i2[2] && a.ops.pop(), a.trys.pop(); + continue; + } + o3 = e3.call(t3, a); + } catch (t4) { + o3 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o3[0]) + throw o3[1]; + return {value: o3[0] ? o3[1] : void 0, done: true}; + }([o2, s2]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var i = function() { + function t3(t4) { + this.requestManager = t4; + } + return t3.prototype.startBatch = function() { + return this.requestManager.startBatch(); + }, t3.prototype.stopBatch = function() { + return this.requestManager.stopBatch(); + }, t3.prototype.request = function(t4, e3) { + return r2(this, void 0, void 0, function() { + return n(this, function(r3) { + switch (r3.label) { + case 0: + return this.requestManager.connectPromise ? [4, this.requestManager.connectPromise] : [3, 2]; + case 1: + r3.sent(), r3.label = 2; + case 2: + return [2, this.requestManager.request(t4, false, e3)]; + } + }); + }); + }, t3.prototype.notify = function(t4) { + return r2(this, void 0, void 0, function() { + return n(this, function(e3) { + switch (e3.label) { + case 0: + return this.requestManager.connectPromise ? [4, this.requestManager.connectPromise] : [3, 2]; + case 1: + e3.sent(), e3.label = 2; + case 2: + return [2, this.requestManager.request(t4, true, null)]; + } + }); + }); + }, t3.prototype.onNotification = function(t4) { + this.requestManager.requestChannel.addListener("notification", t4); + }, t3.prototype.onError = function(t4) { + this.requestManager.requestChannel.addListener("error", t4); + }, t3.prototype.close = function() { + this.requestManager.close(); + }, t3; + }(); + e2.default = i; + }, 9931: function(t2, e2) { + var r2, n = this && this.__extends || (r2 = function(t3, e3) { + return (r2 = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function n2() { + this.constructor = t3; + } + r2(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (n2.prototype = e3.prototype, new n2()); + }); + Object.defineProperty(e2, "__esModule", {value: true}), e2.convertJSONToRPCError = e2.JSONRPCError = e2.ERR_UNKNOWN = e2.ERR_MISSIING_ID = e2.ERR_TIMEOUT = void 0, e2.ERR_TIMEOUT = 7777, e2.ERR_MISSIING_ID = 7878, e2.ERR_UNKNOWN = 7979; + var i = function(t3) { + function e3(e4, r3, n2) { + var i2 = this.constructor, o = t3.call(this, e4) || this; + return o.message = e4, o.code = r3, o.data = n2, Object.setPrototypeOf(o, i2.prototype), o; + } + return n(e3, t3), e3; + }(Error); + e2.JSONRPCError = i, e2.convertJSONToRPCError = function(t3) { + if (t3.error) { + var r3 = t3.error, n2 = r3.message, o = r3.code, a = r3.data; + return new i(n2, o, a); + } + return new i("Unknown error", e2.ERR_UNKNOWN, t3); + }; + }, 7182: (t2, e2) => { + Object.defineProperty(e2, "__esModule", {value: true}), e2.getNotifications = e2.getBatchRequests = e2.isNotification = void 0, e2.isNotification = function(t3) { + return t3.request.id === void 0 || t3.request.id === null; + }, e2.getBatchRequests = function(t3) { + return t3 instanceof Array ? t3.filter(function(t4) { + return t4.request.request.id != null; + }).map(function(t4) { + return t4.request; + }) : []; + }, e2.getNotifications = function(t3) { + return t3 instanceof Array ? t3.filter(function(t4) { + return e2.isNotification(t4.request); + }).map(function(t4) { + return t4.request; + }) : e2.isNotification(t3) ? [t3] : []; + }; + }, 2752: function(t2, e2, r2) { + var n = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, i = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s(o3) { + return function(s2) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s2]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var o = r2(7187), a = function() { + function t3(t4) { + this.batch = [], this.batchStarted = false, this.lastId = -1, this.transports = t4, this.requests = {}, this.connectPromise = this.connect(), this.requestChannel = new o.EventEmitter(); + } + return t3.prototype.connect = function() { + var t4 = this; + return Promise.all(this.transports.map(function(e3) { + return n(t4, void 0, void 0, function() { + return i(this, function(t5) { + switch (t5.label) { + case 0: + return e3.subscribe("error", this.handleError.bind(this)), e3.subscribe("notification", this.handleNotification.bind(this)), [4, e3.connect()]; + case 1: + return t5.sent(), [2]; + } + }); + }); + })); + }, t3.prototype.getPrimaryTransport = function() { + return this.transports[0]; + }, t3.prototype.request = function(t4, e3, r3) { + return e3 === void 0 && (e3 = false), n(this, void 0, void 0, function() { + var n2, o2, a2, s = this; + return i(this, function(i2) { + return n2 = (++this.lastId).toString(), o2 = e3 ? null : n2, a2 = {request: this.makeRequest(t4.method, t4.params || [], o2), internalID: n2}, this.batchStarted ? [2, new Promise(function(t5, e4) { + s.batch.push({resolve: t5, reject: e4, request: a2}); + })] : [2, this.getPrimaryTransport().sendData(a2, r3)]; + }); + }); + }, t3.prototype.close = function() { + this.requestChannel.removeAllListeners(), this.transports.forEach(function(t4) { + t4.unsubscribe(), t4.close(); + }); + }, t3.prototype.startBatch = function() { + this.batchStarted = true; + }, t3.prototype.stopBatch = function() { + if (this.batchStarted === false) + throw new Error("cannot end that which has never started"); + this.batch.length !== 0 ? (this.getPrimaryTransport().sendData(this.batch), this.batch = [], this.batchStarted = false) : this.batchStarted = false; + }, t3.prototype.makeRequest = function(t4, e3, r3) { + return r3 ? {jsonrpc: "2.0", id: r3, method: t4, params: e3} : {jsonrpc: "2.0", method: t4, params: e3}; + }, t3.prototype.handleError = function(t4) { + this.requestChannel.emit("error", t4); + }, t3.prototype.handleNotification = function(t4) { + this.requestChannel.emit("notification", t4); + }, t3; + }(); + e2.default = a; + }, 4927: function(t2, e2, r2) { + var n = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.PostMessageIframeTransport = e2.PostMessageWindowTransport = e2.JSONRPCError = e2.WebSocketTransport = e2.EventEmitterTransport = e2.HTTPTransport = e2.RequestManager = e2.Client = void 0; + var i = n(r2(2752)); + e2.RequestManager = i.default; + var o = n(r2(2300)); + e2.EventEmitterTransport = o.default; + var a = n(r2(2855)); + e2.HTTPTransport = a.default; + var s = n(r2(6628)); + e2.WebSocketTransport = s.default; + var u = n(r2(6514)); + e2.PostMessageWindowTransport = u.default; + var f = n(r2(5280)); + e2.PostMessageIframeTransport = f.default; + var c = r2(9931); + Object.defineProperty(e2, "JSONRPCError", {enumerable: true, get: function() { + return c.JSONRPCError; + }}); + var h = n(r2(2440)); + e2.Client = h.default, e2.default = h.default; + }, 2300: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }); + Object.defineProperty(e2, "__esModule", {value: true}); + var o = r2(3629), a = r2(7182), s = r2(9931), u = function(t3) { + function e3(e4, r3, n2) { + var i2 = t3.call(this) || this; + return i2.connection = e4, i2.reqUri = r3, i2.resUri = n2, i2; + } + return i(e3, t3), e3.prototype.connect = function() { + var t4 = this; + return this.connection.on(this.resUri, function(e4) { + t4.transportRequestManager.resolveResponse(e4); + }), Promise.resolve(); + }, e3.prototype.sendData = function(t4, e4) { + e4 === void 0 && (e4 = null); + var r3 = this.transportRequestManager.addRequest(t4, e4), n2 = a.getNotifications(t4), i2 = this.parseData(t4); + try { + return this.connection.emit(this.reqUri, i2), this.transportRequestManager.settlePendingRequest(n2), r3; + } catch (t5) { + var o2 = new s.JSONRPCError(t5.message, s.ERR_UNKNOWN, t5); + return this.transportRequestManager.settlePendingRequest(n2, o2), Promise.reject(o2); + } + }, e3.prototype.close = function() { + this.connection.removeAllListeners(); + }, e3; + }(o.Transport); + e2.default = u; + }, 2855: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), o = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u2(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u2(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u2(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u2((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, a = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }, s = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.HTTPTransport = void 0; + var u = s(r2(4301)), f = r2(3629), c = r2(7182), h = r2(9931), l = function(t3) { + function e3(r3, n2) { + var i2 = t3.call(this) || this; + return i2.onlyNotifications = function(t4) { + return t4 instanceof Array ? t4.every(function(t5) { + return t5.request.request.id === null || t5.request.request.id === void 0; + }) : t4.request.id === null || t4.request.id === void 0; + }, i2.uri = r3, i2.credentials = n2 && n2.credentials, i2.headers = e3.setupHeaders(n2 && n2.headers), i2; + } + return i(e3, t3), e3.prototype.connect = function() { + return Promise.resolve(); + }, e3.prototype.sendData = function(t4, e4) { + return e4 === void 0 && (e4 = null), o(this, void 0, void 0, function() { + var r3, n2, i2, o2, s2, f2, l2; + return a(this, function(a2) { + switch (a2.label) { + case 0: + r3 = this.transportRequestManager.addRequest(t4, e4), n2 = c.getNotifications(t4), i2 = c.getBatchRequests(t4), a2.label = 1; + case 1: + return a2.trys.push([1, 4, , 5]), [4, u.default(this.uri, {method: "POST", headers: this.headers, body: JSON.stringify(this.parseData(t4)), credentials: this.credentials})]; + case 2: + return o2 = a2.sent(), this.transportRequestManager.settlePendingRequest(n2), this.onlyNotifications(t4) ? [2, Promise.resolve()] : [4, o2.text()]; + case 3: + return s2 = a2.sent(), (l2 = this.transportRequestManager.resolveResponse(s2)) ? (this.transportRequestManager.settlePendingRequest(i2, l2), [2, Promise.reject(l2)]) : [3, 5]; + case 4: + return f2 = a2.sent(), l2 = new h.JSONRPCError(f2.message, h.ERR_UNKNOWN, f2), this.transportRequestManager.settlePendingRequest(n2, l2), this.transportRequestManager.settlePendingRequest(c.getBatchRequests(t4), l2), [2, Promise.reject(l2)]; + case 5: + return [2, r3]; + } + }); + }); + }, e3.prototype.close = function() { + }, e3.setupHeaders = function(t4) { + var e4 = new Headers(t4); + return e4.set("Content-Type", "application/json"), e4; + }, e3; + }(f.Transport); + e2.HTTPTransport = l, e2.default = l; + }, 5280: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), o = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, a = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var s = function(t3) { + function e3(e4) { + var r3 = t3.call(this) || this; + return r3.messageHandler = function(t4) { + r3.transportRequestManager.resolveResponse(JSON.stringify(t4.data)); + }, r3.uri = e4, r3.postMessageID = "post-message-transport-" + Math.random(), r3; + } + return i(e3, t3), e3.prototype.createWindow = function(t4) { + var e4 = this; + return new Promise(function(r3, n2) { + var i2, o2 = document.createElement("iframe"); + o2.setAttribute("id", e4.postMessageID), o2.setAttribute("width", "0px"), o2.setAttribute("height", "0px"), o2.setAttribute("style", "visiblity:hidden;border:none;outline:none;"), o2.addEventListener("load", function() { + r3(i2); + }), o2.setAttribute("src", t4), window.document.body.appendChild(o2), i2 = o2.contentWindow; + }); + }, e3.prototype.connect = function() { + var t4 = this, e4 = /^(http|https):\/\/.*$/; + return new Promise(function(r3, n2) { + return o(t4, void 0, void 0, function() { + var t5; + return a(this, function(i2) { + switch (i2.label) { + case 0: + return e4.test(this.uri) || n2(new Error("Bad URI")), t5 = this, [4, this.createWindow(this.uri)]; + case 1: + return t5.frame = i2.sent(), window.addEventListener("message", this.messageHandler), r3(), [2]; + } + }); + }); + }); + }, e3.prototype.sendData = function(t4, e4) { + return o(this, void 0, void 0, function() { + var e5; + return a(this, function(r3) { + return e5 = this.transportRequestManager.addRequest(t4, null), this.frame && this.frame.postMessage(t4.request, "*"), [2, e5]; + }); + }); + }, e3.prototype.close = function() { + var t4 = document.getElementById(this.postMessageID); + t4 == null || t4.remove(), window.removeEventListener("message", this.messageHandler); + }, e3; + }(r2(3629).Transport); + e2.default = s; + }, 6514: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), o = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, a = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var s = function(t3) { + function e3(e4) { + var r3 = t3.call(this) || this; + return r3.messageHandler = function(t4) { + r3.transportRequestManager.resolveResponse(JSON.stringify(t4.data)); + }, r3.uri = e4, r3.postMessageID = "post-message-transport-" + Math.random(), r3; + } + return i(e3, t3), e3.prototype.createWindow = function(t4) { + return new Promise(function(e4, r3) { + var n2, i2, o2; + i2 = t4, o2 = window.screen.height, n2 = window.open(i2, "inspector:popup", "left=0,top=0,width=400,height=" + o2 + ",resizable,scrollbars=yes,status=1"), setTimeout(function() { + e4(n2); + }, 3e3); + }); + }, e3.prototype.connect = function() { + var t4 = this, e4 = /^(http|https):\/\/.*$/; + return new Promise(function(r3, n2) { + return o(t4, void 0, void 0, function() { + var t5; + return a(this, function(i2) { + switch (i2.label) { + case 0: + return e4.test(this.uri) || n2(new Error("Bad URI")), t5 = this, [4, this.createWindow(this.uri)]; + case 1: + return t5.frame = i2.sent(), window.addEventListener("message", this.messageHandler), r3(), [2]; + } + }); + }); + }); + }, e3.prototype.sendData = function(t4, e4) { + return o(this, void 0, void 0, function() { + var e5; + return a(this, function(r3) { + return e5 = this.transportRequestManager.addRequest(t4, null), this.frame && this.frame.postMessage(t4.request, this.uri), [2, e5]; + }); + }); + }, e3.prototype.close = function() { + this.frame && (window.removeEventListener("message", this.messageHandler), this.frame.close()); + }, e3; + }(r2(3629).Transport); + e2.default = s; + }, 3629: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}), e2.Transport = void 0; + var n = r2(7016), i = function() { + function t3() { + this.transportRequestManager = new n.TransportRequestManager(), this.transportRequestManager.transportEventChannel.on("error", function() { + }); + } + return t3.prototype.subscribe = function(t4, e3) { + this.transportRequestManager.transportEventChannel.addListener(t4, e3); + }, t3.prototype.unsubscribe = function(t4, e3) { + if (!t4) + return this.transportRequestManager.transportEventChannel.removeAllListeners(); + t4 && e3 && this.transportRequestManager.transportEventChannel.removeListener(t4, e3); + }, t3.prototype.parseData = function(t4) { + return t4 instanceof Array ? t4.map(function(t5) { + return t5.request.request; + }) : t4.request; + }, t3; + }(); + e2.Transport = i; + }, 7016: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}), e2.TransportRequestManager = void 0; + var n = r2(7187), i = r2(9931), o = function() { + function t3() { + this.pendingRequest = {}, this.pendingBatchRequest = {}, this.transportEventChannel = new n.EventEmitter(); + } + return t3.prototype.addRequest = function(t4, e3) { + return this.transportEventChannel.emit("pending", t4), t4 instanceof Array ? (this.addBatchReq(t4, e3), Promise.resolve()) : this.addReq(t4.internalID, e3); + }, t3.prototype.settlePendingRequest = function(t4, e3) { + var r3 = this; + t4.forEach(function(t5) { + var n2 = r3.pendingRequest[t5.internalID]; + delete r3.pendingBatchRequest[t5.internalID], n2 !== void 0 && (e3 ? n2.reject(e3) : n2.resolve()); + }); + }, t3.prototype.resolveResponse = function(t4, e3) { + e3 === void 0 && (e3 = true); + var r3 = t4; + try { + if (r3 = JSON.parse(t4), this.checkJSONRPC(r3) === false) + return; + return r3 instanceof Array ? this.resolveBatch(r3, e3) : this.resolveRes(r3, e3); + } catch (r4) { + var n2 = new i.JSONRPCError("Bad response format", i.ERR_UNKNOWN, t4); + return e3 && this.transportEventChannel.emit("error", n2), n2; + } + }, t3.prototype.addBatchReq = function(t4, e3) { + var r3 = this; + return t4.forEach(function(t5) { + var e4 = t5.resolve, n2 = t5.reject, i2 = t5.request.internalID; + r3.pendingBatchRequest[i2] = true, r3.pendingRequest[i2] = {resolve: e4, reject: n2}; + }), Promise.resolve(); + }, t3.prototype.addReq = function(t4, e3) { + var r3 = this; + return new Promise(function(n2, i2) { + e3 !== null && e3 && r3.setRequestTimeout(t4, e3, i2), r3.pendingRequest[t4] = {resolve: n2, reject: i2}; + }); + }, t3.prototype.checkJSONRPC = function(t4) { + var e3 = [t4]; + return t4 instanceof Array && (e3 = t4), e3.every(function(t5) { + return t5.result !== void 0 || t5.error !== void 0 || t5.method !== void 0; + }); + }, t3.prototype.processResult = function(t4, e3) { + if (t4.error) { + var r3 = i.convertJSONToRPCError(t4); + e3.reject(r3); + } else + e3.resolve(t4.result); + }, t3.prototype.resolveBatch = function(t4, e3) { + var r3 = this, n2 = t4.map(function(t5) { + return r3.resolveRes(t5, e3); + }).filter(function(t5) { + return t5; + }); + if (n2.length > 0) + return n2[0]; + }, t3.prototype.resolveRes = function(t4, e3) { + var r3, n2 = t4.id, o2 = t4.error, a = this.pendingRequest[n2]; + return a ? (delete this.pendingRequest[n2], this.processResult(t4, a), void this.transportEventChannel.emit("response", t4)) : n2 !== void 0 || o2 !== void 0 ? (o2 && (r3 = i.convertJSONToRPCError(t4)), e3 && o2 && r3 && this.transportEventChannel.emit("error", r3), r3) : void this.transportEventChannel.emit("notification", t4); + }, t3.prototype.setRequestTimeout = function(t4, e3, r3) { + var n2 = this; + setTimeout(function() { + delete n2.pendingRequest[t4], r3(new i.JSONRPCError("Request timeout request took longer than " + e3 + " ms to resolve", i.ERR_TIMEOUT)); + }, e3); + }, t3; + }(); + e2.TransportRequestManager = o; + }, 6628: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), o = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u2(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u2(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u2(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u2((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, a = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }, s = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var u = s(r2(6792)), f = r2(3629), c = r2(7182), h = r2(9931), l = function(t3) { + function e3(e4) { + var r3 = t3.call(this) || this; + return r3.uri = e4, r3.connection = new u.default(e4), r3; + } + return i(e3, t3), e3.prototype.connect = function() { + var t4 = this; + return new Promise(function(e4, r3) { + var n2 = function() { + t4.connection.removeEventListener("open", n2), e4(); + }; + t4.connection.addEventListener("open", n2), t4.connection.addEventListener("message", function(e5) { + var r4 = e5.data; + t4.transportRequestManager.resolveResponse(r4); + }); + }); + }, e3.prototype.sendData = function(t4, e4) { + return e4 === void 0 && (e4 = 5e3), o(this, void 0, void 0, function() { + var r3, n2, i2 = this; + return a(this, function(o2) { + return r3 = this.transportRequestManager.addRequest(t4, e4), n2 = c.getNotifications(t4), this.connection.send(JSON.stringify(this.parseData(t4)), function(e5) { + if (e5) { + var o3 = new h.JSONRPCError(e5.message, h.ERR_UNKNOWN, e5); + i2.transportRequestManager.settlePendingRequest(n2, o3), i2.transportRequestManager.settlePendingRequest(c.getBatchRequests(t4), o3), r3 = Promise.reject(o3); + } + i2.transportRequestManager.settlePendingRequest(n2); + }), [2, r3]; + }); + }); + }, e3.prototype.close = function() { + this.connection.close(); + }, e3; + }(f.Transport); + e2.default = l; + }, 2190: (t2) => { + t2.exports = function(t3, r2, n) { + if (t3.filter) + return t3.filter(r2, n); + if (t3 == null) + throw new TypeError(); + if (typeof r2 != "function") + throw new TypeError(); + for (var i = [], o = 0; o < t3.length; o++) + if (e2.call(t3, o)) { + var a = t3[o]; + r2.call(n, a, o, t3) && i.push(a); + } + return i; + }; + var e2 = Object.prototype.hasOwnProperty; + }, 9809: (t2, e2, r2) => { + const n = e2; + n.bignum = r2(3550), n.define = r2(2500).define, n.base = r2(1979), n.constants = r2(6826), n.decoders = r2(8307), n.encoders = r2(6579); + }, 2500: (t2, e2, r2) => { + const n = r2(6579), i = r2(8307), o = r2(5717); + function a(t3, e3) { + this.name = t3, this.body = e3, this.decoders = {}, this.encoders = {}; + } + e2.define = function(t3, e3) { + return new a(t3, e3); + }, a.prototype._createNamed = function(t3) { + const e3 = this.name; + function r3(t4) { + this._initNamed(t4, e3); + } + return o(r3, t3), r3.prototype._initNamed = function(e4, r4) { + t3.call(this, e4, r4); + }, new r3(this); + }, a.prototype._getDecoder = function(t3) { + return t3 = t3 || "der", this.decoders.hasOwnProperty(t3) || (this.decoders[t3] = this._createNamed(i[t3])), this.decoders[t3]; + }, a.prototype.decode = function(t3, e3, r3) { + return this._getDecoder(e3).decode(t3, r3); + }, a.prototype._getEncoder = function(t3) { + return t3 = t3 || "der", this.encoders.hasOwnProperty(t3) || (this.encoders[t3] = this._createNamed(n[t3])), this.encoders[t3]; + }, a.prototype.encode = function(t3, e3, r3) { + return this._getEncoder(e3).encode(t3, r3); + }; + }, 6625: (t2, e2, r2) => { + const n = r2(5717), i = r2(8465).b, o = r2(2399).Buffer; + function a(t3, e3) { + i.call(this, e3), o.isBuffer(t3) ? (this.base = t3, this.offset = 0, this.length = t3.length) : this.error("Input not Buffer"); + } + function s(t3, e3) { + if (Array.isArray(t3)) + this.length = 0, this.value = t3.map(function(t4) { + return s.isEncoderBuffer(t4) || (t4 = new s(t4, e3)), this.length += t4.length, t4; + }, this); + else if (typeof t3 == "number") { + if (!(0 <= t3 && t3 <= 255)) + return e3.error("non-byte EncoderBuffer value"); + this.value = t3, this.length = 1; + } else if (typeof t3 == "string") + this.value = t3, this.length = o.byteLength(t3); + else { + if (!o.isBuffer(t3)) + return e3.error("Unsupported type: " + typeof t3); + this.value = t3, this.length = t3.length; + } + } + n(a, i), e2.C = a, a.isDecoderBuffer = function(t3) { + return t3 instanceof a || typeof t3 == "object" && o.isBuffer(t3.base) && t3.constructor.name === "DecoderBuffer" && typeof t3.offset == "number" && typeof t3.length == "number" && typeof t3.save == "function" && typeof t3.restore == "function" && typeof t3.isEmpty == "function" && typeof t3.readUInt8 == "function" && typeof t3.skip == "function" && typeof t3.raw == "function"; + }, a.prototype.save = function() { + return {offset: this.offset, reporter: i.prototype.save.call(this)}; + }, a.prototype.restore = function(t3) { + const e3 = new a(this.base); + return e3.offset = t3.offset, e3.length = this.offset, this.offset = t3.offset, i.prototype.restore.call(this, t3.reporter), e3; + }, a.prototype.isEmpty = function() { + return this.offset === this.length; + }, a.prototype.readUInt8 = function(t3) { + return this.offset + 1 <= this.length ? this.base.readUInt8(this.offset++, true) : this.error(t3 || "DecoderBuffer overrun"); + }, a.prototype.skip = function(t3, e3) { + if (!(this.offset + t3 <= this.length)) + return this.error(e3 || "DecoderBuffer overrun"); + const r3 = new a(this.base); + return r3._reporterState = this._reporterState, r3.offset = this.offset, r3.length = this.offset + t3, this.offset += t3, r3; + }, a.prototype.raw = function(t3) { + return this.base.slice(t3 ? t3.offset : this.offset, this.length); + }, e2.R = s, s.isEncoderBuffer = function(t3) { + return t3 instanceof s || typeof t3 == "object" && t3.constructor.name === "EncoderBuffer" && typeof t3.length == "number" && typeof t3.join == "function"; + }, s.prototype.join = function(t3, e3) { + return t3 || (t3 = o.alloc(this.length)), e3 || (e3 = 0), this.length === 0 || (Array.isArray(this.value) ? this.value.forEach(function(r3) { + r3.join(t3, e3), e3 += r3.length; + }) : (typeof this.value == "number" ? t3[e3] = this.value : typeof this.value == "string" ? t3.write(this.value, e3) : o.isBuffer(this.value) && this.value.copy(t3, e3), e3 += this.length)), t3; + }; + }, 1979: (t2, e2, r2) => { + const n = e2; + n.Reporter = r2(8465).b, n.DecoderBuffer = r2(6625).C, n.EncoderBuffer = r2(6625).R, n.Node = r2(1949); + }, 1949: (t2, e2, r2) => { + const n = r2(8465).b, i = r2(6625).R, o = r2(6625).C, a = r2(9746), s = ["seq", "seqof", "set", "setof", "objid", "bool", "gentime", "utctime", "null_", "enum", "int", "objDesc", "bitstr", "bmpstr", "charstr", "genstr", "graphstr", "ia5str", "iso646str", "numstr", "octstr", "printstr", "t61str", "unistr", "utf8str", "videostr"], u = ["key", "obj", "use", "optional", "explicit", "implicit", "def", "choice", "any", "contains"].concat(s); + function f(t3, e3, r3) { + const n2 = {}; + this._baseState = n2, n2.name = r3, n2.enc = t3, n2.parent = e3 || null, n2.children = null, n2.tag = null, n2.args = null, n2.reverseArgs = null, n2.choice = null, n2.optional = false, n2.any = false, n2.obj = false, n2.use = null, n2.useDecoder = null, n2.key = null, n2.default = null, n2.explicit = null, n2.implicit = null, n2.contains = null, n2.parent || (n2.children = [], this._wrap()); + } + t2.exports = f; + const c = ["enc", "parent", "children", "tag", "args", "reverseArgs", "choice", "optional", "any", "obj", "use", "alteredUse", "key", "default", "explicit", "implicit", "contains"]; + f.prototype.clone = function() { + const t3 = this._baseState, e3 = {}; + c.forEach(function(r4) { + e3[r4] = t3[r4]; + }); + const r3 = new this.constructor(e3.parent); + return r3._baseState = e3, r3; + }, f.prototype._wrap = function() { + const t3 = this._baseState; + u.forEach(function(e3) { + this[e3] = function() { + const r3 = new this.constructor(this); + return t3.children.push(r3), r3[e3].apply(r3, arguments); + }; + }, this); + }, f.prototype._init = function(t3) { + const e3 = this._baseState; + a(e3.parent === null), t3.call(this), e3.children = e3.children.filter(function(t4) { + return t4._baseState.parent === this; + }, this), a.equal(e3.children.length, 1, "Root node can have only one child"); + }, f.prototype._useArgs = function(t3) { + const e3 = this._baseState, r3 = t3.filter(function(t4) { + return t4 instanceof this.constructor; + }, this); + t3 = t3.filter(function(t4) { + return !(t4 instanceof this.constructor); + }, this), r3.length !== 0 && (a(e3.children === null), e3.children = r3, r3.forEach(function(t4) { + t4._baseState.parent = this; + }, this)), t3.length !== 0 && (a(e3.args === null), e3.args = t3, e3.reverseArgs = t3.map(function(t4) { + if (typeof t4 != "object" || t4.constructor !== Object) + return t4; + const e4 = {}; + return Object.keys(t4).forEach(function(r4) { + r4 == (0 | r4) && (r4 |= 0); + const n2 = t4[r4]; + e4[n2] = r4; + }), e4; + })); + }, ["_peekTag", "_decodeTag", "_use", "_decodeStr", "_decodeObjid", "_decodeTime", "_decodeNull", "_decodeInt", "_decodeBool", "_decodeList", "_encodeComposite", "_encodeStr", "_encodeObjid", "_encodeTime", "_encodeNull", "_encodeInt", "_encodeBool"].forEach(function(t3) { + f.prototype[t3] = function() { + const e3 = this._baseState; + throw new Error(t3 + " not implemented for encoding: " + e3.enc); + }; + }), s.forEach(function(t3) { + f.prototype[t3] = function() { + const e3 = this._baseState, r3 = Array.prototype.slice.call(arguments); + return a(e3.tag === null), e3.tag = t3, this._useArgs(r3), this; + }; + }), f.prototype.use = function(t3) { + a(t3); + const e3 = this._baseState; + return a(e3.use === null), e3.use = t3, this; + }, f.prototype.optional = function() { + return this._baseState.optional = true, this; + }, f.prototype.def = function(t3) { + const e3 = this._baseState; + return a(e3.default === null), e3.default = t3, e3.optional = true, this; + }, f.prototype.explicit = function(t3) { + const e3 = this._baseState; + return a(e3.explicit === null && e3.implicit === null), e3.explicit = t3, this; + }, f.prototype.implicit = function(t3) { + const e3 = this._baseState; + return a(e3.explicit === null && e3.implicit === null), e3.implicit = t3, this; + }, f.prototype.obj = function() { + const t3 = this._baseState, e3 = Array.prototype.slice.call(arguments); + return t3.obj = true, e3.length !== 0 && this._useArgs(e3), this; + }, f.prototype.key = function(t3) { + const e3 = this._baseState; + return a(e3.key === null), e3.key = t3, this; + }, f.prototype.any = function() { + return this._baseState.any = true, this; + }, f.prototype.choice = function(t3) { + const e3 = this._baseState; + return a(e3.choice === null), e3.choice = t3, this._useArgs(Object.keys(t3).map(function(e4) { + return t3[e4]; + })), this; + }, f.prototype.contains = function(t3) { + const e3 = this._baseState; + return a(e3.use === null), e3.contains = t3, this; + }, f.prototype._decode = function(t3, e3) { + const r3 = this._baseState; + if (r3.parent === null) + return t3.wrapResult(r3.children[0]._decode(t3, e3)); + let n2, i2 = r3.default, a2 = true, s2 = null; + if (r3.key !== null && (s2 = t3.enterKey(r3.key)), r3.optional) { + let n3 = null; + if (r3.explicit !== null ? n3 = r3.explicit : r3.implicit !== null ? n3 = r3.implicit : r3.tag !== null && (n3 = r3.tag), n3 !== null || r3.any) { + if (a2 = this._peekTag(t3, n3, r3.any), t3.isError(a2)) + return a2; + } else { + const n4 = t3.save(); + try { + r3.choice === null ? this._decodeGeneric(r3.tag, t3, e3) : this._decodeChoice(t3, e3), a2 = true; + } catch (t4) { + a2 = false; + } + t3.restore(n4); + } + } + if (r3.obj && a2 && (n2 = t3.enterObject()), a2) { + if (r3.explicit !== null) { + const e4 = this._decodeTag(t3, r3.explicit); + if (t3.isError(e4)) + return e4; + t3 = e4; + } + const n3 = t3.offset; + if (r3.use === null && r3.choice === null) { + let e4; + r3.any && (e4 = t3.save()); + const n4 = this._decodeTag(t3, r3.implicit !== null ? r3.implicit : r3.tag, r3.any); + if (t3.isError(n4)) + return n4; + r3.any ? i2 = t3.raw(e4) : t3 = n4; + } + if (e3 && e3.track && r3.tag !== null && e3.track(t3.path(), n3, t3.length, "tagged"), e3 && e3.track && r3.tag !== null && e3.track(t3.path(), t3.offset, t3.length, "content"), r3.any || (i2 = r3.choice === null ? this._decodeGeneric(r3.tag, t3, e3) : this._decodeChoice(t3, e3)), t3.isError(i2)) + return i2; + if (r3.any || r3.choice !== null || r3.children === null || r3.children.forEach(function(r4) { + r4._decode(t3, e3); + }), r3.contains && (r3.tag === "octstr" || r3.tag === "bitstr")) { + const n4 = new o(i2); + i2 = this._getUse(r3.contains, t3._reporterState.obj)._decode(n4, e3); + } + } + return r3.obj && a2 && (i2 = t3.leaveObject(n2)), r3.key === null || i2 === null && a2 !== true ? s2 !== null && t3.exitKey(s2) : t3.leaveKey(s2, r3.key, i2), i2; + }, f.prototype._decodeGeneric = function(t3, e3, r3) { + const n2 = this._baseState; + return t3 === "seq" || t3 === "set" ? null : t3 === "seqof" || t3 === "setof" ? this._decodeList(e3, t3, n2.args[0], r3) : /str$/.test(t3) ? this._decodeStr(e3, t3, r3) : t3 === "objid" && n2.args ? this._decodeObjid(e3, n2.args[0], n2.args[1], r3) : t3 === "objid" ? this._decodeObjid(e3, null, null, r3) : t3 === "gentime" || t3 === "utctime" ? this._decodeTime(e3, t3, r3) : t3 === "null_" ? this._decodeNull(e3, r3) : t3 === "bool" ? this._decodeBool(e3, r3) : t3 === "objDesc" ? this._decodeStr(e3, t3, r3) : t3 === "int" || t3 === "enum" ? this._decodeInt(e3, n2.args && n2.args[0], r3) : n2.use !== null ? this._getUse(n2.use, e3._reporterState.obj)._decode(e3, r3) : e3.error("unknown tag: " + t3); + }, f.prototype._getUse = function(t3, e3) { + const r3 = this._baseState; + return r3.useDecoder = this._use(t3, e3), a(r3.useDecoder._baseState.parent === null), r3.useDecoder = r3.useDecoder._baseState.children[0], r3.implicit !== r3.useDecoder._baseState.implicit && (r3.useDecoder = r3.useDecoder.clone(), r3.useDecoder._baseState.implicit = r3.implicit), r3.useDecoder; + }, f.prototype._decodeChoice = function(t3, e3) { + const r3 = this._baseState; + let n2 = null, i2 = false; + return Object.keys(r3.choice).some(function(o2) { + const a2 = t3.save(), s2 = r3.choice[o2]; + try { + const r4 = s2._decode(t3, e3); + if (t3.isError(r4)) + return false; + n2 = {type: o2, value: r4}, i2 = true; + } catch (e4) { + return t3.restore(a2), false; + } + return true; + }, this), i2 ? n2 : t3.error("Choice not matched"); + }, f.prototype._createEncoderBuffer = function(t3) { + return new i(t3, this.reporter); + }, f.prototype._encode = function(t3, e3, r3) { + const n2 = this._baseState; + if (n2.default !== null && n2.default === t3) + return; + const i2 = this._encodeValue(t3, e3, r3); + return i2 === void 0 || this._skipDefault(i2, e3, r3) ? void 0 : i2; + }, f.prototype._encodeValue = function(t3, e3, r3) { + const i2 = this._baseState; + if (i2.parent === null) + return i2.children[0]._encode(t3, e3 || new n()); + let o2 = null; + if (this.reporter = e3, i2.optional && t3 === void 0) { + if (i2.default === null) + return; + t3 = i2.default; + } + let a2 = null, s2 = false; + if (i2.any) + o2 = this._createEncoderBuffer(t3); + else if (i2.choice) + o2 = this._encodeChoice(t3, e3); + else if (i2.contains) + a2 = this._getUse(i2.contains, r3)._encode(t3, e3), s2 = true; + else if (i2.children) + a2 = i2.children.map(function(r4) { + if (r4._baseState.tag === "null_") + return r4._encode(null, e3, t3); + if (r4._baseState.key === null) + return e3.error("Child should have a key"); + const n2 = e3.enterKey(r4._baseState.key); + if (typeof t3 != "object") + return e3.error("Child expected, but input is not object"); + const i3 = r4._encode(t3[r4._baseState.key], e3, t3); + return e3.leaveKey(n2), i3; + }, this).filter(function(t4) { + return t4; + }), a2 = this._createEncoderBuffer(a2); + else if (i2.tag === "seqof" || i2.tag === "setof") { + if (!i2.args || i2.args.length !== 1) + return e3.error("Too many args for : " + i2.tag); + if (!Array.isArray(t3)) + return e3.error("seqof/setof, but data is not Array"); + const r4 = this.clone(); + r4._baseState.implicit = null, a2 = this._createEncoderBuffer(t3.map(function(r5) { + const n2 = this._baseState; + return this._getUse(n2.args[0], t3)._encode(r5, e3); + }, r4)); + } else + i2.use !== null ? o2 = this._getUse(i2.use, r3)._encode(t3, e3) : (a2 = this._encodePrimitive(i2.tag, t3), s2 = true); + if (!i2.any && i2.choice === null) { + const t4 = i2.implicit !== null ? i2.implicit : i2.tag, r4 = i2.implicit === null ? "universal" : "context"; + t4 === null ? i2.use === null && e3.error("Tag could be omitted only for .use()") : i2.use === null && (o2 = this._encodeComposite(t4, s2, r4, a2)); + } + return i2.explicit !== null && (o2 = this._encodeComposite(i2.explicit, false, "context", o2)), o2; + }, f.prototype._encodeChoice = function(t3, e3) { + const r3 = this._baseState, n2 = r3.choice[t3.type]; + return n2 || a(false, t3.type + " not found in " + JSON.stringify(Object.keys(r3.choice))), n2._encode(t3.value, e3); + }, f.prototype._encodePrimitive = function(t3, e3) { + const r3 = this._baseState; + if (/str$/.test(t3)) + return this._encodeStr(e3, t3); + if (t3 === "objid" && r3.args) + return this._encodeObjid(e3, r3.reverseArgs[0], r3.args[1]); + if (t3 === "objid") + return this._encodeObjid(e3, null, null); + if (t3 === "gentime" || t3 === "utctime") + return this._encodeTime(e3, t3); + if (t3 === "null_") + return this._encodeNull(); + if (t3 === "int" || t3 === "enum") + return this._encodeInt(e3, r3.args && r3.reverseArgs[0]); + if (t3 === "bool") + return this._encodeBool(e3); + if (t3 === "objDesc") + return this._encodeStr(e3, t3); + throw new Error("Unsupported tag: " + t3); + }, f.prototype._isNumstr = function(t3) { + return /^[0-9 ]*$/.test(t3); + }, f.prototype._isPrintstr = function(t3) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(t3); + }; + }, 8465: (t2, e2, r2) => { + const n = r2(5717); + function i(t3) { + this._reporterState = {obj: null, path: [], options: t3 || {}, errors: []}; + } + function o(t3, e3) { + this.path = t3, this.rethrow(e3); + } + e2.b = i, i.prototype.isError = function(t3) { + return t3 instanceof o; + }, i.prototype.save = function() { + const t3 = this._reporterState; + return {obj: t3.obj, pathLen: t3.path.length}; + }, i.prototype.restore = function(t3) { + const e3 = this._reporterState; + e3.obj = t3.obj, e3.path = e3.path.slice(0, t3.pathLen); + }, i.prototype.enterKey = function(t3) { + return this._reporterState.path.push(t3); + }, i.prototype.exitKey = function(t3) { + const e3 = this._reporterState; + e3.path = e3.path.slice(0, t3 - 1); + }, i.prototype.leaveKey = function(t3, e3, r3) { + const n2 = this._reporterState; + this.exitKey(t3), n2.obj !== null && (n2.obj[e3] = r3); + }, i.prototype.path = function() { + return this._reporterState.path.join("/"); + }, i.prototype.enterObject = function() { + const t3 = this._reporterState, e3 = t3.obj; + return t3.obj = {}, e3; + }, i.prototype.leaveObject = function(t3) { + const e3 = this._reporterState, r3 = e3.obj; + return e3.obj = t3, r3; + }, i.prototype.error = function(t3) { + let e3; + const r3 = this._reporterState, n2 = t3 instanceof o; + if (e3 = n2 ? t3 : new o(r3.path.map(function(t4) { + return "[" + JSON.stringify(t4) + "]"; + }).join(""), t3.message || t3, t3.stack), !r3.options.partial) + throw e3; + return n2 || r3.errors.push(e3), e3; + }, i.prototype.wrapResult = function(t3) { + const e3 = this._reporterState; + return e3.options.partial ? {result: this.isError(t3) ? null : t3, errors: e3.errors} : t3; + }, n(o, Error), o.prototype.rethrow = function(t3) { + if (this.message = t3 + " at: " + (this.path || "(shallow)"), Error.captureStackTrace && Error.captureStackTrace(this, o), !this.stack) + try { + throw new Error(this.message); + } catch (t4) { + this.stack = t4.stack; + } + return this; + }; + }, 160: (t2, e2) => { + function r2(t3) { + const e3 = {}; + return Object.keys(t3).forEach(function(r3) { + (0 | r3) == r3 && (r3 |= 0); + const n = t3[r3]; + e3[n] = r3; + }), e3; + } + e2.tagClass = {0: "universal", 1: "application", 2: "context", 3: "private"}, e2.tagClassByName = r2(e2.tagClass), e2.tag = {0: "end", 1: "bool", 2: "int", 3: "bitstr", 4: "octstr", 5: "null_", 6: "objid", 7: "objDesc", 8: "external", 9: "real", 10: "enum", 11: "embed", 12: "utf8str", 13: "relativeOid", 16: "seq", 17: "set", 18: "numstr", 19: "printstr", 20: "t61str", 21: "videostr", 22: "ia5str", 23: "utctime", 24: "gentime", 25: "graphstr", 26: "iso646str", 27: "genstr", 28: "unistr", 29: "charstr", 30: "bmpstr"}, e2.tagByName = r2(e2.tag); + }, 6826: (t2, e2, r2) => { + const n = e2; + n._reverse = function(t3) { + const e3 = {}; + return Object.keys(t3).forEach(function(r3) { + (0 | r3) == r3 && (r3 |= 0); + const n2 = t3[r3]; + e3[n2] = r3; + }), e3; + }, n.der = r2(160); + }, 1671: (t2, e2, r2) => { + const n = r2(5717), i = r2(3550), o = r2(6625).C, a = r2(1949), s = r2(160); + function u(t3) { + this.enc = "der", this.name = t3.name, this.entity = t3, this.tree = new f(), this.tree._init(t3.body); + } + function f(t3) { + a.call(this, "der", t3); + } + function c(t3, e3) { + let r3 = t3.readUInt8(e3); + if (t3.isError(r3)) + return r3; + const n2 = s.tagClass[r3 >> 6], i2 = (32 & r3) == 0; + if ((31 & r3) == 31) { + let n3 = r3; + for (r3 = 0; (128 & n3) == 128; ) { + if (n3 = t3.readUInt8(e3), t3.isError(n3)) + return n3; + r3 <<= 7, r3 |= 127 & n3; + } + } else + r3 &= 31; + return {cls: n2, primitive: i2, tag: r3, tagStr: s.tag[r3]}; + } + function h(t3, e3, r3) { + let n2 = t3.readUInt8(r3); + if (t3.isError(n2)) + return n2; + if (!e3 && n2 === 128) + return null; + if ((128 & n2) == 0) + return n2; + const i2 = 127 & n2; + if (i2 > 4) + return t3.error("length octect is too long"); + n2 = 0; + for (let e4 = 0; e4 < i2; e4++) { + n2 <<= 8; + const e5 = t3.readUInt8(r3); + if (t3.isError(e5)) + return e5; + n2 |= e5; + } + return n2; + } + t2.exports = u, u.prototype.decode = function(t3, e3) { + return o.isDecoderBuffer(t3) || (t3 = new o(t3, e3)), this.tree._decode(t3, e3); + }, n(f, a), f.prototype._peekTag = function(t3, e3, r3) { + if (t3.isEmpty()) + return false; + const n2 = t3.save(), i2 = c(t3, 'Failed to peek tag: "' + e3 + '"'); + return t3.isError(i2) ? i2 : (t3.restore(n2), i2.tag === e3 || i2.tagStr === e3 || i2.tagStr + "of" === e3 || r3); + }, f.prototype._decodeTag = function(t3, e3, r3) { + const n2 = c(t3, 'Failed to decode tag of "' + e3 + '"'); + if (t3.isError(n2)) + return n2; + let i2 = h(t3, n2.primitive, 'Failed to get length of "' + e3 + '"'); + if (t3.isError(i2)) + return i2; + if (!r3 && n2.tag !== e3 && n2.tagStr !== e3 && n2.tagStr + "of" !== e3) + return t3.error('Failed to match tag: "' + e3 + '"'); + if (n2.primitive || i2 !== null) + return t3.skip(i2, 'Failed to match body of: "' + e3 + '"'); + const o2 = t3.save(), a2 = this._skipUntilEnd(t3, 'Failed to skip indefinite length body: "' + this.tag + '"'); + return t3.isError(a2) ? a2 : (i2 = t3.offset - o2.offset, t3.restore(o2), t3.skip(i2, 'Failed to match body of: "' + e3 + '"')); + }, f.prototype._skipUntilEnd = function(t3, e3) { + for (; ; ) { + const r3 = c(t3, e3); + if (t3.isError(r3)) + return r3; + const n2 = h(t3, r3.primitive, e3); + if (t3.isError(n2)) + return n2; + let i2; + if (i2 = r3.primitive || n2 !== null ? t3.skip(n2) : this._skipUntilEnd(t3, e3), t3.isError(i2)) + return i2; + if (r3.tagStr === "end") + break; + } + }, f.prototype._decodeList = function(t3, e3, r3, n2) { + const i2 = []; + for (; !t3.isEmpty(); ) { + const e4 = this._peekTag(t3, "end"); + if (t3.isError(e4)) + return e4; + const o2 = r3.decode(t3, "der", n2); + if (t3.isError(o2) && e4) + break; + i2.push(o2); + } + return i2; + }, f.prototype._decodeStr = function(t3, e3) { + if (e3 === "bitstr") { + const e4 = t3.readUInt8(); + return t3.isError(e4) ? e4 : {unused: e4, data: t3.raw()}; + } + if (e3 === "bmpstr") { + const e4 = t3.raw(); + if (e4.length % 2 == 1) + return t3.error("Decoding of string type: bmpstr length mismatch"); + let r3 = ""; + for (let t4 = 0; t4 < e4.length / 2; t4++) + r3 += String.fromCharCode(e4.readUInt16BE(2 * t4)); + return r3; + } + if (e3 === "numstr") { + const e4 = t3.raw().toString("ascii"); + return this._isNumstr(e4) ? e4 : t3.error("Decoding of string type: numstr unsupported characters"); + } + if (e3 === "octstr") + return t3.raw(); + if (e3 === "objDesc") + return t3.raw(); + if (e3 === "printstr") { + const e4 = t3.raw().toString("ascii"); + return this._isPrintstr(e4) ? e4 : t3.error("Decoding of string type: printstr unsupported characters"); + } + return /str$/.test(e3) ? t3.raw().toString() : t3.error("Decoding of string type: " + e3 + " unsupported"); + }, f.prototype._decodeObjid = function(t3, e3, r3) { + let n2; + const i2 = []; + let o2 = 0, a2 = 0; + for (; !t3.isEmpty(); ) + a2 = t3.readUInt8(), o2 <<= 7, o2 |= 127 & a2, (128 & a2) == 0 && (i2.push(o2), o2 = 0); + 128 & a2 && i2.push(o2); + const s2 = i2[0] / 40 | 0, u2 = i2[0] % 40; + if (n2 = r3 ? i2 : [s2, u2].concat(i2.slice(1)), e3) { + let t4 = e3[n2.join(" ")]; + t4 === void 0 && (t4 = e3[n2.join(".")]), t4 !== void 0 && (n2 = t4); + } + return n2; + }, f.prototype._decodeTime = function(t3, e3) { + const r3 = t3.raw().toString(); + let n2, i2, o2, a2, s2, u2; + if (e3 === "gentime") + n2 = 0 | r3.slice(0, 4), i2 = 0 | r3.slice(4, 6), o2 = 0 | r3.slice(6, 8), a2 = 0 | r3.slice(8, 10), s2 = 0 | r3.slice(10, 12), u2 = 0 | r3.slice(12, 14); + else { + if (e3 !== "utctime") + return t3.error("Decoding " + e3 + " time is not supported yet"); + n2 = 0 | r3.slice(0, 2), i2 = 0 | r3.slice(2, 4), o2 = 0 | r3.slice(4, 6), a2 = 0 | r3.slice(6, 8), s2 = 0 | r3.slice(8, 10), u2 = 0 | r3.slice(10, 12), n2 = n2 < 70 ? 2e3 + n2 : 1900 + n2; + } + return Date.UTC(n2, i2 - 1, o2, a2, s2, u2, 0); + }, f.prototype._decodeNull = function() { + return null; + }, f.prototype._decodeBool = function(t3) { + const e3 = t3.readUInt8(); + return t3.isError(e3) ? e3 : e3 !== 0; + }, f.prototype._decodeInt = function(t3, e3) { + const r3 = t3.raw(); + let n2 = new i(r3); + return e3 && (n2 = e3[n2.toString(10)] || n2), n2; + }, f.prototype._use = function(t3, e3) { + return typeof t3 == "function" && (t3 = t3(e3)), t3._getDecoder("der").tree; + }; + }, 8307: (t2, e2, r2) => { + const n = e2; + n.der = r2(1671), n.pem = r2(9631); + }, 9631: (t2, e2, r2) => { + const n = r2(5717), i = r2(2399).Buffer, o = r2(1671); + function a(t3) { + o.call(this, t3), this.enc = "pem"; + } + n(a, o), t2.exports = a, a.prototype.decode = function(t3, e3) { + const r3 = t3.toString().split(/[\r\n]+/g), n2 = e3.label.toUpperCase(), a2 = /^-----(BEGIN|END) ([^-]+)-----$/; + let s = -1, u = -1; + for (let t4 = 0; t4 < r3.length; t4++) { + const e4 = r3[t4].match(a2); + if (e4 !== null && e4[2] === n2) { + if (s !== -1) { + if (e4[1] !== "END") + break; + u = t4; + break; + } + if (e4[1] !== "BEGIN") + break; + s = t4; + } + } + if (s === -1 || u === -1) + throw new Error("PEM section not found for: " + n2); + const f = r3.slice(s + 1, u).join(""); + f.replace(/[^a-z0-9+/=]+/gi, ""); + const c = i.from(f, "base64"); + return o.prototype.decode.call(this, c, e3); + }; + }, 6984: (t2, e2, r2) => { + const n = r2(5717), i = r2(2399).Buffer, o = r2(1949), a = r2(160); + function s(t3) { + this.enc = "der", this.name = t3.name, this.entity = t3, this.tree = new u(), this.tree._init(t3.body); + } + function u(t3) { + o.call(this, "der", t3); + } + function f(t3) { + return t3 < 10 ? "0" + t3 : t3; + } + t2.exports = s, s.prototype.encode = function(t3, e3) { + return this.tree._encode(t3, e3).join(); + }, n(u, o), u.prototype._encodeComposite = function(t3, e3, r3, n2) { + const o2 = function(t4, e4, r4, n3) { + let i2; + if (t4 === "seqof" ? t4 = "seq" : t4 === "setof" && (t4 = "set"), a.tagByName.hasOwnProperty(t4)) + i2 = a.tagByName[t4]; + else { + if (typeof t4 != "number" || (0 | t4) !== t4) + return n3.error("Unknown tag: " + t4); + i2 = t4; + } + return i2 >= 31 ? n3.error("Multi-octet tag encoding unsupported") : (e4 || (i2 |= 32), i2 |= a.tagClassByName[r4 || "universal"] << 6, i2); + }(t3, e3, r3, this.reporter); + if (n2.length < 128) { + const t4 = i.alloc(2); + return t4[0] = o2, t4[1] = n2.length, this._createEncoderBuffer([t4, n2]); + } + let s2 = 1; + for (let t4 = n2.length; t4 >= 256; t4 >>= 8) + s2++; + const u2 = i.alloc(2 + s2); + u2[0] = o2, u2[1] = 128 | s2; + for (let t4 = 1 + s2, e4 = n2.length; e4 > 0; t4--, e4 >>= 8) + u2[t4] = 255 & e4; + return this._createEncoderBuffer([u2, n2]); + }, u.prototype._encodeStr = function(t3, e3) { + if (e3 === "bitstr") + return this._createEncoderBuffer([0 | t3.unused, t3.data]); + if (e3 === "bmpstr") { + const e4 = i.alloc(2 * t3.length); + for (let r3 = 0; r3 < t3.length; r3++) + e4.writeUInt16BE(t3.charCodeAt(r3), 2 * r3); + return this._createEncoderBuffer(e4); + } + return e3 === "numstr" ? this._isNumstr(t3) ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: numstr supports only digits and space") : e3 === "printstr" ? this._isPrintstr(t3) ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark") : /str$/.test(e3) || e3 === "objDesc" ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: " + e3 + " unsupported"); + }, u.prototype._encodeObjid = function(t3, e3, r3) { + if (typeof t3 == "string") { + if (!e3) + return this.reporter.error("string objid given, but no values map found"); + if (!e3.hasOwnProperty(t3)) + return this.reporter.error("objid not found in values map"); + t3 = e3[t3].split(/[\s.]+/g); + for (let e4 = 0; e4 < t3.length; e4++) + t3[e4] |= 0; + } else if (Array.isArray(t3)) { + t3 = t3.slice(); + for (let e4 = 0; e4 < t3.length; e4++) + t3[e4] |= 0; + } + if (!Array.isArray(t3)) + return this.reporter.error("objid() should be either array or string, got: " + JSON.stringify(t3)); + if (!r3) { + if (t3[1] >= 40) + return this.reporter.error("Second objid identifier OOB"); + t3.splice(0, 2, 40 * t3[0] + t3[1]); + } + let n2 = 0; + for (let e4 = 0; e4 < t3.length; e4++) { + let r4 = t3[e4]; + for (n2++; r4 >= 128; r4 >>= 7) + n2++; + } + const o2 = i.alloc(n2); + let a2 = o2.length - 1; + for (let e4 = t3.length - 1; e4 >= 0; e4--) { + let r4 = t3[e4]; + for (o2[a2--] = 127 & r4; (r4 >>= 7) > 0; ) + o2[a2--] = 128 | 127 & r4; + } + return this._createEncoderBuffer(o2); + }, u.prototype._encodeTime = function(t3, e3) { + let r3; + const n2 = new Date(t3); + return e3 === "gentime" ? r3 = [f(n2.getUTCFullYear()), f(n2.getUTCMonth() + 1), f(n2.getUTCDate()), f(n2.getUTCHours()), f(n2.getUTCMinutes()), f(n2.getUTCSeconds()), "Z"].join("") : e3 === "utctime" ? r3 = [f(n2.getUTCFullYear() % 100), f(n2.getUTCMonth() + 1), f(n2.getUTCDate()), f(n2.getUTCHours()), f(n2.getUTCMinutes()), f(n2.getUTCSeconds()), "Z"].join("") : this.reporter.error("Encoding " + e3 + " time is not supported yet"), this._encodeStr(r3, "octstr"); + }, u.prototype._encodeNull = function() { + return this._createEncoderBuffer(""); + }, u.prototype._encodeInt = function(t3, e3) { + if (typeof t3 == "string") { + if (!e3) + return this.reporter.error("String int or enum given, but no values map"); + if (!e3.hasOwnProperty(t3)) + return this.reporter.error("Values map doesn't contain: " + JSON.stringify(t3)); + t3 = e3[t3]; + } + if (typeof t3 != "number" && !i.isBuffer(t3)) { + const e4 = t3.toArray(); + !t3.sign && 128 & e4[0] && e4.unshift(0), t3 = i.from(e4); + } + if (i.isBuffer(t3)) { + let e4 = t3.length; + t3.length === 0 && e4++; + const r4 = i.alloc(e4); + return t3.copy(r4), t3.length === 0 && (r4[0] = 0), this._createEncoderBuffer(r4); + } + if (t3 < 128) + return this._createEncoderBuffer(t3); + if (t3 < 256) + return this._createEncoderBuffer([0, t3]); + let r3 = 1; + for (let e4 = t3; e4 >= 256; e4 >>= 8) + r3++; + const n2 = new Array(r3); + for (let e4 = n2.length - 1; e4 >= 0; e4--) + n2[e4] = 255 & t3, t3 >>= 8; + return 128 & n2[0] && n2.unshift(0), this._createEncoderBuffer(i.from(n2)); + }, u.prototype._encodeBool = function(t3) { + return this._createEncoderBuffer(t3 ? 255 : 0); + }, u.prototype._use = function(t3, e3) { + return typeof t3 == "function" && (t3 = t3(e3)), t3._getEncoder("der").tree; + }, u.prototype._skipDefault = function(t3, e3, r3) { + const n2 = this._baseState; + let i2; + if (n2.default === null) + return false; + const o2 = t3.join(); + if (n2.defaultBuffer === void 0 && (n2.defaultBuffer = this._encodeValue(n2.default, e3, r3).join()), o2.length !== n2.defaultBuffer.length) + return false; + for (i2 = 0; i2 < o2.length; i2++) + if (o2[i2] !== n2.defaultBuffer[i2]) + return false; + return true; + }; + }, 6579: (t2, e2, r2) => { + const n = e2; + n.der = r2(6984), n.pem = r2(2883); + }, 2883: (t2, e2, r2) => { + const n = r2(5717), i = r2(6984); + function o(t3) { + i.call(this, t3), this.enc = "pem"; + } + n(o, i), t2.exports = o, o.prototype.encode = function(t3, e3) { + const r3 = i.prototype.encode.call(this, t3).toString("base64"), n2 = ["-----BEGIN " + e3.label + "-----"]; + for (let t4 = 0; t4 < r3.length; t4 += 64) + n2.push(r3.slice(t4, t4 + 64)); + return n2.push("-----END " + e3.label + "-----"), n2.join("\n"); + }; + }, 9282: (t2, e2, r2) => { + var n = r2(4155); + function i(t3) { + return (i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { + return typeof t4; + } : function(t4) { + return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; + })(t3); + } + var o, a, s = r2(2136).codes, u = s.ERR_AMBIGUOUS_ARGUMENT, f = s.ERR_INVALID_ARG_TYPE, c = s.ERR_INVALID_ARG_VALUE, h = s.ERR_INVALID_RETURN_VALUE, l = s.ERR_MISSING_ARGS, d = r2(5961), p = r2(9539).inspect, y = r2(9539).types, m = y.isPromise, b = y.isRegExp, g = Object.assign ? Object.assign : r2(8091).assign, v = Object.is ? Object.is : r2(609); + function w() { + var t3 = r2(9158); + o = t3.isDeepEqual, a = t3.isDeepStrictEqual; + } + var _ = false, M = t2.exports = k, S = {}; + function E(t3) { + if (t3.message instanceof Error) + throw t3.message; + throw new d(t3); + } + function A(t3, e3, r3, n2) { + if (!r3) { + var i2 = false; + if (e3 === 0) + i2 = true, n2 = "No value argument passed to `assert.ok()`"; + else if (n2 instanceof Error) + throw n2; + var o2 = new d({actual: r3, expected: true, message: n2, operator: "==", stackStartFn: t3}); + throw o2.generatedMessage = i2, o2; + } + } + function k() { + for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) + e3[r3] = arguments[r3]; + A.apply(void 0, [k, e3.length].concat(e3)); + } + M.fail = function t3(e3, r3, i2, o2, a2) { + var s2, u2 = arguments.length; + if (u2 === 0) + s2 = "Failed"; + else if (u2 === 1) + i2 = e3, e3 = void 0; + else { + if (_ === false) { + _ = true; + var f2 = n.emitWarning ? n.emitWarning : console.warn.bind(console); + f2("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.", "DeprecationWarning", "DEP0094"); + } + u2 === 2 && (o2 = "!="); + } + if (i2 instanceof Error) + throw i2; + var c2 = {actual: e3, expected: r3, operator: o2 === void 0 ? "fail" : o2, stackStartFn: a2 || t3}; + i2 !== void 0 && (c2.message = i2); + var h2 = new d(c2); + throw s2 && (h2.message = s2, h2.generatedMessage = true), h2; + }, M.AssertionError = d, M.ok = k, M.equal = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + e3 != r3 && E({actual: e3, expected: r3, message: n2, operator: "==", stackStartFn: t3}); + }, M.notEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + e3 == r3 && E({actual: e3, expected: r3, message: n2, operator: "!=", stackStartFn: t3}); + }, M.deepEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + o === void 0 && w(), o(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "deepEqual", stackStartFn: t3}); + }, M.notDeepEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + o === void 0 && w(), o(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notDeepEqual", stackStartFn: t3}); + }, M.deepStrictEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + o === void 0 && w(), a(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "deepStrictEqual", stackStartFn: t3}); + }, M.notDeepStrictEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + o === void 0 && w(), a(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notDeepStrictEqual", stackStartFn: t3}); + }, M.strictEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + v(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "strictEqual", stackStartFn: t3}); + }, M.notStrictEqual = function t3(e3, r3, n2) { + if (arguments.length < 2) + throw new l("actual", "expected"); + v(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notStrictEqual", stackStartFn: t3}); + }; + var B = function t3(e3, r3, n2) { + var i2 = this; + !function(t4, e4) { + if (!(t4 instanceof e4)) + throw new TypeError("Cannot call a class as a function"); + }(this, t3), r3.forEach(function(t4) { + t4 in e3 && (n2 !== void 0 && typeof n2[t4] == "string" && b(e3[t4]) && e3[t4].test(n2[t4]) ? i2[t4] = n2[t4] : i2[t4] = e3[t4]); + }); + }; + function T(t3, e3, r3, n2, i2, o2) { + if (!(r3 in t3) || !a(t3[r3], e3[r3])) { + if (!n2) { + var s2 = new B(t3, i2), u2 = new B(e3, i2, t3), f2 = new d({actual: s2, expected: u2, operator: "deepStrictEqual", stackStartFn: o2}); + throw f2.actual = t3, f2.expected = e3, f2.operator = o2.name, f2; + } + E({actual: t3, expected: e3, message: n2, operator: o2.name, stackStartFn: o2}); + } + } + function x(t3, e3, r3, n2) { + if (typeof e3 != "function") { + if (b(e3)) + return e3.test(t3); + if (arguments.length === 2) + throw new f("expected", ["Function", "RegExp"], e3); + if (i(t3) !== "object" || t3 === null) { + var a2 = new d({actual: t3, expected: e3, message: r3, operator: "deepStrictEqual", stackStartFn: n2}); + throw a2.operator = n2.name, a2; + } + var s2 = Object.keys(e3); + if (e3 instanceof Error) + s2.push("name", "message"); + else if (s2.length === 0) + throw new c("error", e3, "may not be an empty object"); + return o === void 0 && w(), s2.forEach(function(i2) { + typeof t3[i2] == "string" && b(e3[i2]) && e3[i2].test(t3[i2]) || T(t3, e3, i2, r3, s2, n2); + }), true; + } + return e3.prototype !== void 0 && t3 instanceof e3 || !Error.isPrototypeOf(e3) && e3.call({}, t3) === true; + } + function O(t3) { + if (typeof t3 != "function") + throw new f("fn", "Function", t3); + try { + t3(); + } catch (t4) { + return t4; + } + return S; + } + function R(t3) { + return m(t3) || t3 !== null && i(t3) === "object" && typeof t3.then == "function" && typeof t3.catch == "function"; + } + function P(t3) { + return Promise.resolve().then(function() { + var e3; + if (typeof t3 == "function") { + if (!R(e3 = t3())) + throw new h("instance of Promise", "promiseFn", e3); + } else { + if (!R(t3)) + throw new f("promiseFn", ["Function", "Promise"], t3); + e3 = t3; + } + return Promise.resolve().then(function() { + return e3; + }).then(function() { + return S; + }).catch(function(t4) { + return t4; + }); + }); + } + function I(t3, e3, r3, n2) { + if (typeof r3 == "string") { + if (arguments.length === 4) + throw new f("error", ["Object", "Error", "Function", "RegExp"], r3); + if (i(e3) === "object" && e3 !== null) { + if (e3.message === r3) + throw new u("error/message", 'The error message "'.concat(e3.message, '" is identical to the message.')); + } else if (e3 === r3) + throw new u("error/message", 'The error "'.concat(e3, '" is identical to the message.')); + n2 = r3, r3 = void 0; + } else if (r3 != null && i(r3) !== "object" && typeof r3 != "function") + throw new f("error", ["Object", "Error", "Function", "RegExp"], r3); + if (e3 === S) { + var o2 = ""; + r3 && r3.name && (o2 += " (".concat(r3.name, ")")), o2 += n2 ? ": ".concat(n2) : "."; + var a2 = t3.name === "rejects" ? "rejection" : "exception"; + E({actual: void 0, expected: r3, operator: t3.name, message: "Missing expected ".concat(a2).concat(o2), stackStartFn: t3}); + } + if (r3 && !x(e3, r3, n2, t3)) + throw e3; + } + function j(t3, e3, r3, n2) { + if (e3 !== S) { + if (typeof r3 == "string" && (n2 = r3, r3 = void 0), !r3 || x(e3, r3)) { + var i2 = n2 ? ": ".concat(n2) : ".", o2 = t3.name === "doesNotReject" ? "rejection" : "exception"; + E({actual: e3, expected: r3, operator: t3.name, message: "Got unwanted ".concat(o2).concat(i2, "\n") + 'Actual message: "'.concat(e3 && e3.message, '"'), stackStartFn: t3}); + } + throw e3; + } + } + function U() { + for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) + e3[r3] = arguments[r3]; + A.apply(void 0, [U, e3.length].concat(e3)); + } + M.throws = function t3(e3) { + for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) + n2[i2 - 1] = arguments[i2]; + I.apply(void 0, [t3, O(e3)].concat(n2)); + }, M.rejects = function t3(e3) { + for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) + n2[i2 - 1] = arguments[i2]; + return P(e3).then(function(e4) { + return I.apply(void 0, [t3, e4].concat(n2)); + }); + }, M.doesNotThrow = function t3(e3) { + for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) + n2[i2 - 1] = arguments[i2]; + j.apply(void 0, [t3, O(e3)].concat(n2)); + }, M.doesNotReject = function t3(e3) { + for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) + n2[i2 - 1] = arguments[i2]; + return P(e3).then(function(e4) { + return j.apply(void 0, [t3, e4].concat(n2)); + }); + }, M.ifError = function t3(e3) { + if (e3 != null) { + var r3 = "ifError got unwanted exception: "; + i(e3) === "object" && typeof e3.message == "string" ? e3.message.length === 0 && e3.constructor ? r3 += e3.constructor.name : r3 += e3.message : r3 += p(e3); + var n2 = new d({actual: e3, expected: null, operator: "ifError", message: r3, stackStartFn: t3}), o2 = e3.stack; + if (typeof o2 == "string") { + var a2 = o2.split("\n"); + a2.shift(); + for (var s2 = n2.stack.split("\n"), u2 = 0; u2 < a2.length; u2++) { + var f2 = s2.indexOf(a2[u2]); + if (f2 !== -1) { + s2 = s2.slice(0, f2); + break; + } + } + n2.stack = "".concat(s2.join("\n"), "\n").concat(a2.join("\n")); + } + throw n2; + } + }, M.strict = g(U, M, {equal: M.strictEqual, deepEqual: M.deepStrictEqual, notEqual: M.notStrictEqual, notDeepEqual: M.notDeepStrictEqual}), M.strict.strict = M.strict; + }, 5961: (t2, e2, r2) => { + var n = r2(4155); + function i(t3, e3, r3) { + return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; + } + function o(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) { + var n2 = e3[r3]; + n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(t3, n2.key, n2); + } + } + function a(t3, e3) { + return !e3 || d(e3) !== "object" && typeof e3 != "function" ? s(t3) : e3; + } + function s(t3) { + if (t3 === void 0) + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return t3; + } + function u(t3) { + var e3 = typeof Map == "function" ? new Map() : void 0; + return (u = function(t4) { + if (t4 === null || (r3 = t4, Function.toString.call(r3).indexOf("[native code]") === -1)) + return t4; + var r3; + if (typeof t4 != "function") + throw new TypeError("Super expression must either be null or a function"); + if (e3 !== void 0) { + if (e3.has(t4)) + return e3.get(t4); + e3.set(t4, n2); + } + function n2() { + return c(t4, arguments, l(this).constructor); + } + return n2.prototype = Object.create(t4.prototype, {constructor: {value: n2, enumerable: false, writable: true, configurable: true}}), h(n2, t4); + })(t3); + } + function f() { + if (typeof Reflect == "undefined" || !Reflect.construct) + return false; + if (Reflect.construct.sham) + return false; + if (typeof Proxy == "function") + return true; + try { + return Date.prototype.toString.call(Reflect.construct(Date, [], function() { + })), true; + } catch (t3) { + return false; + } + } + function c(t3, e3, r3) { + return (c = f() ? Reflect.construct : function(t4, e4, r4) { + var n2 = [null]; + n2.push.apply(n2, e4); + var i2 = new (Function.bind.apply(t4, n2))(); + return r4 && h(i2, r4.prototype), i2; + }).apply(null, arguments); + } + function h(t3, e3) { + return (h = Object.setPrototypeOf || function(t4, e4) { + return t4.__proto__ = e4, t4; + })(t3, e3); + } + function l(t3) { + return (l = Object.setPrototypeOf ? Object.getPrototypeOf : function(t4) { + return t4.__proto__ || Object.getPrototypeOf(t4); + })(t3); + } + function d(t3) { + return (d = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { + return typeof t4; + } : function(t4) { + return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; + })(t3); + } + var p = r2(9539).inspect, y = r2(2136).codes.ERR_INVALID_ARG_TYPE; + function m(t3, e3, r3) { + return (r3 === void 0 || r3 > t3.length) && (r3 = t3.length), t3.substring(r3 - e3.length, r3) === e3; + } + var b = "", g = "", v = "", w = "", _ = {deepStrictEqual: "Expected values to be strictly deep-equal:", strictEqual: "Expected values to be strictly equal:", strictEqualObject: 'Expected "actual" to be reference-equal to "expected":', deepEqual: "Expected values to be loosely deep-equal:", equal: "Expected values to be loosely equal:", notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:', notStrictEqual: 'Expected "actual" to be strictly unequal to:', notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', notEqual: 'Expected "actual" to be loosely unequal to:', notIdentical: "Values identical but not reference-equal:"}; + function M(t3) { + var e3 = Object.keys(t3), r3 = Object.create(Object.getPrototypeOf(t3)); + return e3.forEach(function(e4) { + r3[e4] = t3[e4]; + }), Object.defineProperty(r3, "message", {value: t3.message}), r3; + } + function S(t3) { + return p(t3, {compact: false, customInspect: false, depth: 1e3, maxArrayLength: 1 / 0, showHidden: false, breakLength: 1 / 0, showProxy: false, sorted: true, getters: true}); + } + var E = function(t3) { + function e3(t4) { + var r4; + if (function(t5, e4) { + if (!(t5 instanceof e4)) + throw new TypeError("Cannot call a class as a function"); + }(this, e3), d(t4) !== "object" || t4 === null) + throw new y("options", "Object", t4); + var i2 = t4.message, o2 = t4.operator, u3 = t4.stackStartFn, f2 = t4.actual, c2 = t4.expected, h2 = Error.stackTraceLimit; + if (Error.stackTraceLimit = 0, i2 != null) + r4 = a(this, l(e3).call(this, String(i2))); + else if (n.stderr && n.stderr.isTTY && (n.stderr && n.stderr.getColorDepth && n.stderr.getColorDepth() !== 1 ? (b = "", g = "", w = "", v = "") : (b = "", g = "", w = "", v = "")), d(f2) === "object" && f2 !== null && d(c2) === "object" && c2 !== null && "stack" in f2 && f2 instanceof Error && "stack" in c2 && c2 instanceof Error && (f2 = M(f2), c2 = M(c2)), o2 === "deepStrictEqual" || o2 === "strictEqual") + r4 = a(this, l(e3).call(this, function(t5, e4, r5) { + var i3 = "", o3 = "", a2 = 0, s2 = "", u4 = false, f3 = S(t5), c3 = f3.split("\n"), h3 = S(e4).split("\n"), l2 = 0, p3 = ""; + if (r5 === "strictEqual" && d(t5) === "object" && d(e4) === "object" && t5 !== null && e4 !== null && (r5 = "strictEqualObject"), c3.length === 1 && h3.length === 1 && c3[0] !== h3[0]) { + var y2 = c3[0].length + h3[0].length; + if (y2 <= 10) { + if (!(d(t5) === "object" && t5 !== null || d(e4) === "object" && e4 !== null || t5 === 0 && e4 === 0)) + return "".concat(_[r5], "\n\n") + "".concat(c3[0], " !== ").concat(h3[0], "\n"); + } else if (r5 !== "strictEqualObject" && y2 < (n.stderr && n.stderr.isTTY ? n.stderr.columns : 80)) { + for (; c3[0][l2] === h3[0][l2]; ) + l2++; + l2 > 2 && (p3 = "\n ".concat(function(t6, e5) { + if (e5 = Math.floor(e5), t6.length == 0 || e5 == 0) + return ""; + var r6 = t6.length * e5; + for (e5 = Math.floor(Math.log(e5) / Math.log(2)); e5; ) + t6 += t6, e5--; + return t6 + t6.substring(0, r6 - t6.length); + }(" ", l2), "^"), l2 = 0); + } + } + for (var M2 = c3[c3.length - 1], E3 = h3[h3.length - 1]; M2 === E3 && (l2++ < 2 ? s2 = "\n ".concat(M2).concat(s2) : i3 = M2, c3.pop(), h3.pop(), c3.length !== 0 && h3.length !== 0); ) + M2 = c3[c3.length - 1], E3 = h3[h3.length - 1]; + var A2 = Math.max(c3.length, h3.length); + if (A2 === 0) { + var k2 = f3.split("\n"); + if (k2.length > 30) + for (k2[26] = "".concat(b, "...").concat(w); k2.length > 27; ) + k2.pop(); + return "".concat(_.notIdentical, "\n\n").concat(k2.join("\n"), "\n"); + } + l2 > 3 && (s2 = "\n".concat(b, "...").concat(w).concat(s2), u4 = true), i3 !== "" && (s2 = "\n ".concat(i3).concat(s2), i3 = ""); + var B2 = 0, T = _[r5] + "\n".concat(g, "+ actual").concat(w, " ").concat(v, "- expected").concat(w), x = " ".concat(b, "...").concat(w, " Lines skipped"); + for (l2 = 0; l2 < A2; l2++) { + var O = l2 - a2; + if (c3.length < l2 + 1) + O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(h3[l2 - 2]), B2++), o3 += "\n ".concat(h3[l2 - 1]), B2++), a2 = l2, i3 += "\n".concat(v, "-").concat(w, " ").concat(h3[l2]), B2++; + else if (h3.length < l2 + 1) + O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(c3[l2 - 2]), B2++), o3 += "\n ".concat(c3[l2 - 1]), B2++), a2 = l2, o3 += "\n".concat(g, "+").concat(w, " ").concat(c3[l2]), B2++; + else { + var R = h3[l2], P = c3[l2], I = P !== R && (!m(P, ",") || P.slice(0, -1) !== R); + I && m(R, ",") && R.slice(0, -1) === P && (I = false, P += ","), I ? (O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(c3[l2 - 2]), B2++), o3 += "\n ".concat(c3[l2 - 1]), B2++), a2 = l2, o3 += "\n".concat(g, "+").concat(w, " ").concat(P), i3 += "\n".concat(v, "-").concat(w, " ").concat(R), B2 += 2) : (o3 += i3, i3 = "", O !== 1 && l2 !== 0 || (o3 += "\n ".concat(P), B2++)); + } + if (B2 > 20 && l2 < A2 - 2) + return "".concat(T).concat(x, "\n").concat(o3, "\n").concat(b, "...").concat(w).concat(i3, "\n") + "".concat(b, "...").concat(w); + } + return "".concat(T).concat(u4 ? x : "", "\n").concat(o3).concat(i3).concat(s2).concat(p3); + }(f2, c2, o2))); + else if (o2 === "notDeepStrictEqual" || o2 === "notStrictEqual") { + var p2 = _[o2], E2 = S(f2).split("\n"); + if (o2 === "notStrictEqual" && d(f2) === "object" && f2 !== null && (p2 = _.notStrictEqualObject), E2.length > 30) + for (E2[26] = "".concat(b, "...").concat(w); E2.length > 27; ) + E2.pop(); + r4 = E2.length === 1 ? a(this, l(e3).call(this, "".concat(p2, " ").concat(E2[0]))) : a(this, l(e3).call(this, "".concat(p2, "\n\n").concat(E2.join("\n"), "\n"))); + } else { + var A = S(f2), k = "", B = _[o2]; + o2 === "notDeepEqual" || o2 === "notEqual" ? (A = "".concat(_[o2], "\n\n").concat(A)).length > 1024 && (A = "".concat(A.slice(0, 1021), "...")) : (k = "".concat(S(c2)), A.length > 512 && (A = "".concat(A.slice(0, 509), "...")), k.length > 512 && (k = "".concat(k.slice(0, 509), "...")), o2 === "deepEqual" || o2 === "equal" ? A = "".concat(B, "\n\n").concat(A, "\n\nshould equal\n\n") : k = " ".concat(o2, " ").concat(k)), r4 = a(this, l(e3).call(this, "".concat(A).concat(k))); + } + return Error.stackTraceLimit = h2, r4.generatedMessage = !i2, Object.defineProperty(s(r4), "name", {value: "AssertionError [ERR_ASSERTION]", enumerable: false, writable: true, configurable: true}), r4.code = "ERR_ASSERTION", r4.actual = f2, r4.expected = c2, r4.operator = o2, Error.captureStackTrace && Error.captureStackTrace(s(r4), u3), r4.stack, r4.name = "AssertionError", a(r4); + } + var r3, u2; + return function(t4, e4) { + if (typeof e4 != "function" && e4 !== null) + throw new TypeError("Super expression must either be null or a function"); + t4.prototype = Object.create(e4 && e4.prototype, {constructor: {value: t4, writable: true, configurable: true}}), e4 && h(t4, e4); + }(e3, t3), r3 = e3, (u2 = [{key: "toString", value: function() { + return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message); + }}, {key: p.custom, value: function(t4, e4) { + return p(this, function(t5) { + for (var e5 = 1; e5 < arguments.length; e5++) { + var r4 = arguments[e5] != null ? arguments[e5] : {}, n2 = Object.keys(r4); + typeof Object.getOwnPropertySymbols == "function" && (n2 = n2.concat(Object.getOwnPropertySymbols(r4).filter(function(t6) { + return Object.getOwnPropertyDescriptor(r4, t6).enumerable; + }))), n2.forEach(function(e6) { + i(t5, e6, r4[e6]); + }); + } + return t5; + }({}, e4, {customInspect: false, depth: 0})); + }}]) && o(r3.prototype, u2), e3; + }(u(Error)); + t2.exports = E; + }, 2136: (t2, e2, r2) => { + function n(t3) { + return (n = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { + return typeof t4; + } : function(t4) { + return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; + })(t3); + } + function i(t3) { + return (i = Object.setPrototypeOf ? Object.getPrototypeOf : function(t4) { + return t4.__proto__ || Object.getPrototypeOf(t4); + })(t3); + } + function o(t3, e3) { + return (o = Object.setPrototypeOf || function(t4, e4) { + return t4.__proto__ = e4, t4; + })(t3, e3); + } + var a, s, u = {}; + function f(t3, e3, r3) { + r3 || (r3 = Error); + var a2 = function(r4) { + function a3(r5, o2, s2) { + var u2; + return function(t4, e4) { + if (!(t4 instanceof e4)) + throw new TypeError("Cannot call a class as a function"); + }(this, a3), (u2 = function(t4, e4) { + return !e4 || n(e4) !== "object" && typeof e4 != "function" ? function(t5) { + if (t5 === void 0) + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return t5; + }(t4) : e4; + }(this, i(a3).call(this, function(t4, r6, n2) { + return typeof e3 == "string" ? e3 : e3(t4, r6, n2); + }(r5, o2, s2)))).code = t3, u2; + } + return function(t4, e4) { + if (typeof e4 != "function" && e4 !== null) + throw new TypeError("Super expression must either be null or a function"); + t4.prototype = Object.create(e4 && e4.prototype, {constructor: {value: t4, writable: true, configurable: true}}), e4 && o(t4, e4); + }(a3, r4), a3; + }(r3); + u[t3] = a2; + } + function c(t3, e3) { + if (Array.isArray(t3)) { + var r3 = t3.length; + return t3 = t3.map(function(t4) { + return String(t4); + }), r3 > 2 ? "one of ".concat(e3, " ").concat(t3.slice(0, r3 - 1).join(", "), ", or ") + t3[r3 - 1] : r3 === 2 ? "one of ".concat(e3, " ").concat(t3[0], " or ").concat(t3[1]) : "of ".concat(e3, " ").concat(t3[0]); + } + return "of ".concat(e3, " ").concat(String(t3)); + } + f("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), f("ERR_INVALID_ARG_TYPE", function(t3, e3, i2) { + var o2, s2, u2, f2, h; + if (a === void 0 && (a = r2(9282)), a(typeof t3 == "string", "'name' must be a string"), typeof e3 == "string" && (s2 = "not ", e3.substr(0, s2.length) === s2) ? (o2 = "must not be", e3 = e3.replace(/^not /, "")) : o2 = "must be", function(t4, e4, r3) { + return (r3 === void 0 || r3 > t4.length) && (r3 = t4.length), t4.substring(r3 - e4.length, r3) === e4; + }(t3, " argument")) + u2 = "The ".concat(t3, " ").concat(o2, " ").concat(c(e3, "type")); + else { + var l = (typeof h != "number" && (h = 0), h + ".".length > (f2 = t3).length || f2.indexOf(".", h) === -1 ? "argument" : "property"); + u2 = 'The "'.concat(t3, '" ').concat(l, " ").concat(o2, " ").concat(c(e3, "type")); + } + return u2 + ". Received type ".concat(n(i2)); + }, TypeError), f("ERR_INVALID_ARG_VALUE", function(t3, e3) { + var n2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "is invalid"; + s === void 0 && (s = r2(9539)); + var i2 = s.inspect(e3); + return i2.length > 128 && (i2 = "".concat(i2.slice(0, 128), "...")), "The argument '".concat(t3, "' ").concat(n2, ". Received ").concat(i2); + }, TypeError), f("ERR_INVALID_RETURN_VALUE", function(t3, e3, r3) { + var i2; + return i2 = r3 && r3.constructor && r3.constructor.name ? "instance of ".concat(r3.constructor.name) : "type ".concat(n(r3)), "Expected ".concat(t3, ' to be returned from the "').concat(e3, '"') + " function but got ".concat(i2, "."); + }, TypeError), f("ERR_MISSING_ARGS", function() { + for (var t3 = arguments.length, e3 = new Array(t3), n2 = 0; n2 < t3; n2++) + e3[n2] = arguments[n2]; + a === void 0 && (a = r2(9282)), a(e3.length > 0, "At least one arg needs to be specified"); + var i2 = "The ", o2 = e3.length; + switch (e3 = e3.map(function(t4) { + return '"'.concat(t4, '"'); + }), o2) { + case 1: + i2 += "".concat(e3[0], " argument"); + break; + case 2: + i2 += "".concat(e3[0], " and ").concat(e3[1], " arguments"); + break; + default: + i2 += e3.slice(0, o2 - 1).join(", "), i2 += ", and ".concat(e3[o2 - 1], " arguments"); + } + return "".concat(i2, " must be specified"); + }, TypeError), t2.exports.codes = u; + }, 9158: (t2, e2, r2) => { + function n(t3, e3) { + return function(t4) { + if (Array.isArray(t4)) + return t4; + }(t3) || function(t4, e4) { + var r3 = [], n2 = true, i2 = false, o2 = void 0; + try { + for (var a2, s2 = t4[Symbol.iterator](); !(n2 = (a2 = s2.next()).done) && (r3.push(a2.value), !e4 || r3.length !== e4); n2 = true) + ; + } catch (t5) { + i2 = true, o2 = t5; + } finally { + try { + n2 || s2.return == null || s2.return(); + } finally { + if (i2) + throw o2; + } + } + return r3; + }(t3, e3) || function() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + }(); + } + function i(t3) { + return (i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { + return typeof t4; + } : function(t4) { + return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; + })(t3); + } + var o = /a/g.flags !== void 0, a = function(t3) { + var e3 = []; + return t3.forEach(function(t4) { + return e3.push(t4); + }), e3; + }, s = function(t3) { + var e3 = []; + return t3.forEach(function(t4, r3) { + return e3.push([r3, t4]); + }), e3; + }, u = Object.is ? Object.is : r2(609), f = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function() { + return []; + }, c = Number.isNaN ? Number.isNaN : r2(360); + function h(t3) { + return t3.call.bind(t3); + } + var l = h(Object.prototype.hasOwnProperty), d = h(Object.prototype.propertyIsEnumerable), p = h(Object.prototype.toString), y = r2(9539).types, m = y.isAnyArrayBuffer, b = y.isArrayBufferView, g = y.isDate, v = y.isMap, w = y.isRegExp, _ = y.isSet, M = y.isNativeError, S = y.isBoxedPrimitive, E = y.isNumberObject, A = y.isStringObject, k = y.isBooleanObject, B = y.isBigIntObject, T = y.isSymbolObject, x = y.isFloat32Array, O = y.isFloat64Array; + function R(t3) { + if (t3.length === 0 || t3.length > 10) + return true; + for (var e3 = 0; e3 < t3.length; e3++) { + var r3 = t3.charCodeAt(e3); + if (r3 < 48 || r3 > 57) + return true; + } + return t3.length === 10 && t3 >= Math.pow(2, 32); + } + function P(t3) { + return Object.keys(t3).filter(R).concat(f(t3).filter(Object.prototype.propertyIsEnumerable.bind(t3))); + } + function I(t3, e3) { + if (t3 === e3) + return 0; + for (var r3 = t3.length, n2 = e3.length, i2 = 0, o2 = Math.min(r3, n2); i2 < o2; ++i2) + if (t3[i2] !== e3[i2]) { + r3 = t3[i2], n2 = e3[i2]; + break; + } + return r3 < n2 ? -1 : n2 < r3 ? 1 : 0; + } + function j(t3, e3, r3, n2) { + if (t3 === e3) + return t3 !== 0 || !r3 || u(t3, e3); + if (r3) { + if (i(t3) !== "object") + return typeof t3 == "number" && c(t3) && c(e3); + if (i(e3) !== "object" || t3 === null || e3 === null) + return false; + if (Object.getPrototypeOf(t3) !== Object.getPrototypeOf(e3)) + return false; + } else { + if (t3 === null || i(t3) !== "object") + return (e3 === null || i(e3) !== "object") && t3 == e3; + if (e3 === null || i(e3) !== "object") + return false; + } + var a2, s2, f2, h2, l2 = p(t3); + if (l2 !== p(e3)) + return false; + if (Array.isArray(t3)) { + if (t3.length !== e3.length) + return false; + var d2 = P(t3), y2 = P(e3); + return d2.length === y2.length && N(t3, e3, r3, n2, 1, d2); + } + if (l2 === "[object Object]" && (!v(t3) && v(e3) || !_(t3) && _(e3))) + return false; + if (g(t3)) { + if (!g(e3) || Date.prototype.getTime.call(t3) !== Date.prototype.getTime.call(e3)) + return false; + } else if (w(t3)) { + if (!w(e3) || (f2 = t3, h2 = e3, !(o ? f2.source === h2.source && f2.flags === h2.flags : RegExp.prototype.toString.call(f2) === RegExp.prototype.toString.call(h2)))) + return false; + } else if (M(t3) || t3 instanceof Error) { + if (t3.message !== e3.message || t3.name !== e3.name) + return false; + } else { + if (b(t3)) { + if (r3 || !x(t3) && !O(t3)) { + if (!function(t4, e4) { + return t4.byteLength === e4.byteLength && I(new Uint8Array(t4.buffer, t4.byteOffset, t4.byteLength), new Uint8Array(e4.buffer, e4.byteOffset, e4.byteLength)) === 0; + }(t3, e3)) + return false; + } else if (!function(t4, e4) { + if (t4.byteLength !== e4.byteLength) + return false; + for (var r4 = 0; r4 < t4.byteLength; r4++) + if (t4[r4] !== e4[r4]) + return false; + return true; + }(t3, e3)) + return false; + var R2 = P(t3), j2 = P(e3); + return R2.length === j2.length && N(t3, e3, r3, n2, 0, R2); + } + if (_(t3)) + return !(!_(e3) || t3.size !== e3.size) && N(t3, e3, r3, n2, 2); + if (v(t3)) + return !(!v(e3) || t3.size !== e3.size) && N(t3, e3, r3, n2, 3); + if (m(t3)) { + if (s2 = e3, (a2 = t3).byteLength !== s2.byteLength || I(new Uint8Array(a2), new Uint8Array(s2)) !== 0) + return false; + } else if (S(t3) && !function(t4, e4) { + return E(t4) ? E(e4) && u(Number.prototype.valueOf.call(t4), Number.prototype.valueOf.call(e4)) : A(t4) ? A(e4) && String.prototype.valueOf.call(t4) === String.prototype.valueOf.call(e4) : k(t4) ? k(e4) && Boolean.prototype.valueOf.call(t4) === Boolean.prototype.valueOf.call(e4) : B(t4) ? B(e4) && BigInt.prototype.valueOf.call(t4) === BigInt.prototype.valueOf.call(e4) : T(e4) && Symbol.prototype.valueOf.call(t4) === Symbol.prototype.valueOf.call(e4); + }(t3, e3)) + return false; + } + return N(t3, e3, r3, n2, 0); + } + function U(t3, e3) { + return e3.filter(function(e4) { + return d(t3, e4); + }); + } + function N(t3, e3, r3, n2, i2, o2) { + if (arguments.length === 5) { + o2 = Object.keys(t3); + var a2 = Object.keys(e3); + if (o2.length !== a2.length) + return false; + } + for (var s2 = 0; s2 < o2.length; s2++) + if (!l(e3, o2[s2])) + return false; + if (r3 && arguments.length === 5) { + var u2 = f(t3); + if (u2.length !== 0) { + var c2 = 0; + for (s2 = 0; s2 < u2.length; s2++) { + var h2 = u2[s2]; + if (d(t3, h2)) { + if (!d(e3, h2)) + return false; + o2.push(h2), c2++; + } else if (d(e3, h2)) + return false; + } + var p2 = f(e3); + if (u2.length !== p2.length && U(e3, p2).length !== c2) + return false; + } else { + var y2 = f(e3); + if (y2.length !== 0 && U(e3, y2).length !== 0) + return false; + } + } + if (o2.length === 0 && (i2 === 0 || i2 === 1 && t3.length === 0 || t3.size === 0)) + return true; + if (n2 === void 0) + n2 = {val1: new Map(), val2: new Map(), position: 0}; + else { + var m2 = n2.val1.get(t3); + if (m2 !== void 0) { + var b2 = n2.val2.get(e3); + if (b2 !== void 0) + return m2 === b2; + } + n2.position++; + } + n2.val1.set(t3, n2.position), n2.val2.set(e3, n2.position); + var g2 = q(t3, e3, r3, o2, n2, i2); + return n2.val1.delete(t3), n2.val2.delete(e3), g2; + } + function C(t3, e3, r3, n2) { + for (var i2 = a(t3), o2 = 0; o2 < i2.length; o2++) { + var s2 = i2[o2]; + if (j(e3, s2, r3, n2)) + return t3.delete(s2), true; + } + return false; + } + function D(t3) { + switch (i(t3)) { + case "undefined": + return null; + case "object": + return; + case "symbol": + return false; + case "string": + t3 = +t3; + case "number": + if (c(t3)) + return false; + } + return true; + } + function L(t3, e3, r3) { + var n2 = D(r3); + return n2 != null ? n2 : e3.has(n2) && !t3.has(n2); + } + function K(t3, e3, r3, n2, i2) { + var o2 = D(r3); + if (o2 != null) + return o2; + var a2 = e3.get(o2); + return !(a2 === void 0 && !e3.has(o2) || !j(n2, a2, false, i2)) && !t3.has(o2) && j(n2, a2, false, i2); + } + function z(t3, e3, r3, n2, i2, o2) { + for (var s2 = a(t3), u2 = 0; u2 < s2.length; u2++) { + var f2 = s2[u2]; + if (j(r3, f2, i2, o2) && j(n2, e3.get(f2), i2, o2)) + return t3.delete(f2), true; + } + return false; + } + function q(t3, e3, r3, o2, u2, f2) { + var c2 = 0; + if (f2 === 2) { + if (!function(t4, e4, r4, n2) { + for (var o3 = null, s2 = a(t4), u3 = 0; u3 < s2.length; u3++) { + var f3 = s2[u3]; + if (i(f3) === "object" && f3 !== null) + o3 === null && (o3 = new Set()), o3.add(f3); + else if (!e4.has(f3)) { + if (r4) + return false; + if (!L(t4, e4, f3)) + return false; + o3 === null && (o3 = new Set()), o3.add(f3); + } + } + if (o3 !== null) { + for (var c3 = a(e4), h3 = 0; h3 < c3.length; h3++) { + var l2 = c3[h3]; + if (i(l2) === "object" && l2 !== null) { + if (!C(o3, l2, r4, n2)) + return false; + } else if (!r4 && !t4.has(l2) && !C(o3, l2, r4, n2)) + return false; + } + return o3.size === 0; + } + return true; + }(t3, e3, r3, u2)) + return false; + } else if (f2 === 3) { + if (!function(t4, e4, r4, o3) { + for (var a2 = null, u3 = s(t4), f3 = 0; f3 < u3.length; f3++) { + var c3 = n(u3[f3], 2), h3 = c3[0], l2 = c3[1]; + if (i(h3) === "object" && h3 !== null) + a2 === null && (a2 = new Set()), a2.add(h3); + else { + var d3 = e4.get(h3); + if (d3 === void 0 && !e4.has(h3) || !j(l2, d3, r4, o3)) { + if (r4) + return false; + if (!K(t4, e4, h3, l2, o3)) + return false; + a2 === null && (a2 = new Set()), a2.add(h3); + } + } + } + if (a2 !== null) { + for (var p3 = s(e4), y2 = 0; y2 < p3.length; y2++) { + var m2 = n(p3[y2], 2), b2 = (h3 = m2[0], m2[1]); + if (i(h3) === "object" && h3 !== null) { + if (!z(a2, t4, h3, b2, r4, o3)) + return false; + } else if (!(r4 || t4.has(h3) && j(t4.get(h3), b2, false, o3) || z(a2, t4, h3, b2, false, o3))) + return false; + } + return a2.size === 0; + } + return true; + }(t3, e3, r3, u2)) + return false; + } else if (f2 === 1) + for (; c2 < t3.length; c2++) { + if (!l(t3, c2)) { + if (l(e3, c2)) + return false; + for (var h2 = Object.keys(t3); c2 < h2.length; c2++) { + var d2 = h2[c2]; + if (!l(e3, d2) || !j(t3[d2], e3[d2], r3, u2)) + return false; + } + return h2.length === Object.keys(e3).length; + } + if (!l(e3, c2) || !j(t3[c2], e3[c2], r3, u2)) + return false; + } + for (c2 = 0; c2 < o2.length; c2++) { + var p2 = o2[c2]; + if (!j(t3[p2], e3[p2], r3, u2)) + return false; + } + return true; + } + t2.exports = {isDeepEqual: function(t3, e3) { + return j(t3, e3, false); + }, isDeepStrictEqual: function(t3, e3) { + return j(t3, e3, true); + }}; + }, 6314: (t2, e2, r2) => { + var n = r2(2190); + t2.exports = function() { + return n(["BigInt64Array", "BigUint64Array", "Float32Array", "Float64Array", "Int16Array", "Int32Array", "Int8Array", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray"], function(t3) { + return typeof r2.g[t3] == "function"; + }); + }; + }, 8162: (t2, e2, r2) => { + var n = r2(9509).Buffer; + t2.exports = function(t3) { + if (t3.length >= 255) + throw new TypeError("Alphabet too long"); + for (var e3 = new Uint8Array(256), r3 = 0; r3 < e3.length; r3++) + e3[r3] = 255; + for (var i = 0; i < t3.length; i++) { + var o = t3.charAt(i), a = o.charCodeAt(0); + if (e3[a] !== 255) + throw new TypeError(o + " is ambiguous"); + e3[a] = i; + } + var s = t3.length, u = t3.charAt(0), f = Math.log(s) / Math.log(256), c = Math.log(256) / Math.log(s); + function h(t4) { + if (typeof t4 != "string") + throw new TypeError("Expected String"); + if (t4.length === 0) + return n.alloc(0); + var r4 = 0; + if (t4[r4] !== " ") { + for (var i2 = 0, o2 = 0; t4[r4] === u; ) + i2++, r4++; + for (var a2 = (t4.length - r4) * f + 1 >>> 0, c2 = new Uint8Array(a2); t4[r4]; ) { + var h2 = e3[t4.charCodeAt(r4)]; + if (h2 === 255) + return; + for (var l = 0, d = a2 - 1; (h2 !== 0 || l < o2) && d !== -1; d--, l++) + h2 += s * c2[d] >>> 0, c2[d] = h2 % 256 >>> 0, h2 = h2 / 256 >>> 0; + if (h2 !== 0) + throw new Error("Non-zero carry"); + o2 = l, r4++; + } + if (t4[r4] !== " ") { + for (var p = a2 - o2; p !== a2 && c2[p] === 0; ) + p++; + var y = n.allocUnsafe(i2 + (a2 - p)); + y.fill(0, 0, i2); + for (var m = i2; p !== a2; ) + y[m++] = c2[p++]; + return y; + } + } + } + return {encode: function(e4) { + if ((Array.isArray(e4) || e4 instanceof Uint8Array) && (e4 = n.from(e4)), !n.isBuffer(e4)) + throw new TypeError("Expected Buffer"); + if (e4.length === 0) + return ""; + for (var r4 = 0, i2 = 0, o2 = 0, a2 = e4.length; o2 !== a2 && e4[o2] === 0; ) + o2++, r4++; + for (var f2 = (a2 - o2) * c + 1 >>> 0, h2 = new Uint8Array(f2); o2 !== a2; ) { + for (var l = e4[o2], d = 0, p = f2 - 1; (l !== 0 || d < i2) && p !== -1; p--, d++) + l += 256 * h2[p] >>> 0, h2[p] = l % s >>> 0, l = l / s >>> 0; + if (l !== 0) + throw new Error("Non-zero carry"); + i2 = d, o2++; + } + for (var y = f2 - i2; y !== f2 && h2[y] === 0; ) + y++; + for (var m = u.repeat(r4); y < f2; ++y) + m += t3.charAt(h2[y]); + return m; + }, decodeUnsafe: h, decode: function(t4) { + var e4 = h(t4); + if (e4) + return e4; + throw new Error("Non-base" + s + " character"); + }}; + }; + }, 9742: (t2, e2) => { + e2.byteLength = function(t3) { + var e3 = u(t3), r3 = e3[0], n2 = e3[1]; + return 3 * (r3 + n2) / 4 - n2; + }, e2.toByteArray = function(t3) { + var e3, r3, o2 = u(t3), a2 = o2[0], s2 = o2[1], f2 = new i(function(t4, e4, r4) { + return 3 * (e4 + r4) / 4 - r4; + }(0, a2, s2)), c = 0, h = s2 > 0 ? a2 - 4 : a2; + for (r3 = 0; r3 < h; r3 += 4) + e3 = n[t3.charCodeAt(r3)] << 18 | n[t3.charCodeAt(r3 + 1)] << 12 | n[t3.charCodeAt(r3 + 2)] << 6 | n[t3.charCodeAt(r3 + 3)], f2[c++] = e3 >> 16 & 255, f2[c++] = e3 >> 8 & 255, f2[c++] = 255 & e3; + return s2 === 2 && (e3 = n[t3.charCodeAt(r3)] << 2 | n[t3.charCodeAt(r3 + 1)] >> 4, f2[c++] = 255 & e3), s2 === 1 && (e3 = n[t3.charCodeAt(r3)] << 10 | n[t3.charCodeAt(r3 + 1)] << 4 | n[t3.charCodeAt(r3 + 2)] >> 2, f2[c++] = e3 >> 8 & 255, f2[c++] = 255 & e3), f2; + }, e2.fromByteArray = function(t3) { + for (var e3, n2 = t3.length, i2 = n2 % 3, o2 = [], a2 = 16383, s2 = 0, u2 = n2 - i2; s2 < u2; s2 += a2) + o2.push(f(t3, s2, s2 + a2 > u2 ? u2 : s2 + a2)); + return i2 === 1 ? (e3 = t3[n2 - 1], o2.push(r2[e3 >> 2] + r2[e3 << 4 & 63] + "==")) : i2 === 2 && (e3 = (t3[n2 - 2] << 8) + t3[n2 - 1], o2.push(r2[e3 >> 10] + r2[e3 >> 4 & 63] + r2[e3 << 2 & 63] + "=")), o2.join(""); + }; + for (var r2 = [], n = [], i = typeof Uint8Array != "undefined" ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = 0, s = o.length; a < s; ++a) + r2[a] = o[a], n[o.charCodeAt(a)] = a; + function u(t3) { + var e3 = t3.length; + if (e3 % 4 > 0) + throw new Error("Invalid string. Length must be a multiple of 4"); + var r3 = t3.indexOf("="); + return r3 === -1 && (r3 = e3), [r3, r3 === e3 ? 0 : 4 - r3 % 4]; + } + function f(t3, e3, n2) { + for (var i2, o2, a2 = [], s2 = e3; s2 < n2; s2 += 3) + i2 = (t3[s2] << 16 & 16711680) + (t3[s2 + 1] << 8 & 65280) + (255 & t3[s2 + 2]), a2.push(r2[(o2 = i2) >> 18 & 63] + r2[o2 >> 12 & 63] + r2[o2 >> 6 & 63] + r2[63 & o2]); + return a2.join(""); + } + n["-".charCodeAt(0)] = 62, n["_".charCodeAt(0)] = 63; + }, 8442: (t2, e2, r2) => { + var n = r2(9488); + function i(t3, e3, r3) { + var n2 = t3[e3] + t3[r3], i2 = t3[e3 + 1] + t3[r3 + 1]; + n2 >= 4294967296 && i2++, t3[e3] = n2, t3[e3 + 1] = i2; + } + function o(t3, e3, r3, n2) { + var i2 = t3[e3] + r3; + r3 < 0 && (i2 += 4294967296); + var o2 = t3[e3 + 1] + n2; + i2 >= 4294967296 && o2++, t3[e3] = i2, t3[e3 + 1] = o2; + } + function a(t3, e3) { + return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; + } + function s(t3, e3, r3, n2, a2, s2) { + var u2 = h[a2], f2 = h[a2 + 1], l2 = h[s2], d2 = h[s2 + 1]; + i(c, t3, e3), o(c, t3, u2, f2); + var p2 = c[n2] ^ c[t3], y2 = c[n2 + 1] ^ c[t3 + 1]; + c[n2] = y2, c[n2 + 1] = p2, i(c, r3, n2), p2 = c[e3] ^ c[r3], y2 = c[e3 + 1] ^ c[r3 + 1], c[e3] = p2 >>> 24 ^ y2 << 8, c[e3 + 1] = y2 >>> 24 ^ p2 << 8, i(c, t3, e3), o(c, t3, l2, d2), p2 = c[n2] ^ c[t3], y2 = c[n2 + 1] ^ c[t3 + 1], c[n2] = p2 >>> 16 ^ y2 << 16, c[n2 + 1] = y2 >>> 16 ^ p2 << 16, i(c, r3, n2), p2 = c[e3] ^ c[r3], y2 = c[e3 + 1] ^ c[r3 + 1], c[e3] = y2 >>> 31 ^ p2 << 1, c[e3 + 1] = p2 >>> 31 ^ y2 << 1; + } + var u = new Uint32Array([4089235720, 1779033703, 2227873595, 3144134277, 4271175723, 1013904242, 1595750129, 2773480762, 2917565137, 1359893119, 725511199, 2600822924, 4215389547, 528734635, 327033209, 1541459225]), f = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3].map(function(t3) { + return 2 * t3; + })), c = new Uint32Array(32), h = new Uint32Array(32); + function l(t3, e3) { + var r3 = 0; + for (r3 = 0; r3 < 16; r3++) + c[r3] = t3.h[r3], c[r3 + 16] = u[r3]; + for (c[24] = c[24] ^ t3.t, c[25] = c[25] ^ t3.t / 4294967296, e3 && (c[28] = ~c[28], c[29] = ~c[29]), r3 = 0; r3 < 32; r3++) + h[r3] = a(t3.b, 4 * r3); + for (r3 = 0; r3 < 12; r3++) + s(0, 8, 16, 24, f[16 * r3 + 0], f[16 * r3 + 1]), s(2, 10, 18, 26, f[16 * r3 + 2], f[16 * r3 + 3]), s(4, 12, 20, 28, f[16 * r3 + 4], f[16 * r3 + 5]), s(6, 14, 22, 30, f[16 * r3 + 6], f[16 * r3 + 7]), s(0, 10, 20, 30, f[16 * r3 + 8], f[16 * r3 + 9]), s(2, 12, 22, 24, f[16 * r3 + 10], f[16 * r3 + 11]), s(4, 14, 16, 26, f[16 * r3 + 12], f[16 * r3 + 13]), s(6, 8, 18, 28, f[16 * r3 + 14], f[16 * r3 + 15]); + for (r3 = 0; r3 < 16; r3++) + t3.h[r3] = t3.h[r3] ^ c[r3] ^ c[r3 + 16]; + } + function d(t3, e3) { + if (t3 === 0 || t3 > 64) + throw new Error("Illegal output length, expected 0 < length <= 64"); + if (e3 && e3.length > 64) + throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64"); + for (var r3 = {b: new Uint8Array(128), h: new Uint32Array(16), t: 0, c: 0, outlen: t3}, n2 = 0; n2 < 16; n2++) + r3.h[n2] = u[n2]; + var i2 = e3 ? e3.length : 0; + return r3.h[0] ^= 16842752 ^ i2 << 8 ^ t3, e3 && (p(r3, e3), r3.c = 128), r3; + } + function p(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) + t3.c === 128 && (t3.t += t3.c, l(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; + } + function y(t3) { + for (t3.t += t3.c; t3.c < 128; ) + t3.b[t3.c++] = 0; + l(t3, true); + for (var e3 = new Uint8Array(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) + e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3); + return e3; + } + function m(t3, e3, r3) { + r3 = r3 || 64, t3 = n.normalizeInput(t3); + var i2 = d(r3, e3); + return p(i2, t3), y(i2); + } + t2.exports = {blake2b: m, blake2bHex: function(t3, e3, r3) { + var i2 = m(t3, e3, r3); + return n.toHex(i2); + }, blake2bInit: d, blake2bUpdate: p, blake2bFinal: y}; + }, 5297: (t2, e2, r2) => { + var n = r2(9488); + function i(t3, e3) { + return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; + } + function o(t3, e3, r3, n2, i2, o2) { + f[t3] = f[t3] + f[e3] + i2, f[n2] = a(f[n2] ^ f[t3], 16), f[r3] = f[r3] + f[n2], f[e3] = a(f[e3] ^ f[r3], 12), f[t3] = f[t3] + f[e3] + o2, f[n2] = a(f[n2] ^ f[t3], 8), f[r3] = f[r3] + f[n2], f[e3] = a(f[e3] ^ f[r3], 7); + } + function a(t3, e3) { + return t3 >>> e3 ^ t3 << 32 - e3; + } + var s = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), u = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]), f = new Uint32Array(16), c = new Uint32Array(16); + function h(t3, e3) { + var r3 = 0; + for (r3 = 0; r3 < 8; r3++) + f[r3] = t3.h[r3], f[r3 + 8] = s[r3]; + for (f[12] ^= t3.t, f[13] ^= t3.t / 4294967296, e3 && (f[14] = ~f[14]), r3 = 0; r3 < 16; r3++) + c[r3] = i(t3.b, 4 * r3); + for (r3 = 0; r3 < 10; r3++) + o(0, 4, 8, 12, c[u[16 * r3 + 0]], c[u[16 * r3 + 1]]), o(1, 5, 9, 13, c[u[16 * r3 + 2]], c[u[16 * r3 + 3]]), o(2, 6, 10, 14, c[u[16 * r3 + 4]], c[u[16 * r3 + 5]]), o(3, 7, 11, 15, c[u[16 * r3 + 6]], c[u[16 * r3 + 7]]), o(0, 5, 10, 15, c[u[16 * r3 + 8]], c[u[16 * r3 + 9]]), o(1, 6, 11, 12, c[u[16 * r3 + 10]], c[u[16 * r3 + 11]]), o(2, 7, 8, 13, c[u[16 * r3 + 12]], c[u[16 * r3 + 13]]), o(3, 4, 9, 14, c[u[16 * r3 + 14]], c[u[16 * r3 + 15]]); + for (r3 = 0; r3 < 8; r3++) + t3.h[r3] ^= f[r3] ^ f[r3 + 8]; + } + function l(t3, e3) { + if (!(t3 > 0 && t3 <= 32)) + throw new Error("Incorrect output length, should be in [1, 32]"); + var r3 = e3 ? e3.length : 0; + if (e3 && !(r3 > 0 && r3 <= 32)) + throw new Error("Incorrect key length, should be in [1, 32]"); + var n2 = {h: new Uint32Array(s), b: new Uint32Array(64), c: 0, t: 0, outlen: t3}; + return n2.h[0] ^= 16842752 ^ r3 << 8 ^ t3, r3 > 0 && (d(n2, e3), n2.c = 64), n2; + } + function d(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) + t3.c === 64 && (t3.t += t3.c, h(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; + } + function p(t3) { + for (t3.t += t3.c; t3.c < 64; ) + t3.b[t3.c++] = 0; + h(t3, true); + for (var e3 = new Uint8Array(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) + e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3) & 255; + return e3; + } + function y(t3, e3, r3) { + r3 = r3 || 32, t3 = n.normalizeInput(t3); + var i2 = l(r3, e3); + return d(i2, t3), p(i2); + } + t2.exports = {blake2s: y, blake2sHex: function(t3, e3, r3) { + var i2 = y(t3, e3, r3); + return n.toHex(i2); + }, blake2sInit: l, blake2sUpdate: d, blake2sFinal: p}; + }, 1191: (t2, e2, r2) => { + var n = r2(8442), i = r2(5297); + t2.exports = {blake2b: n.blake2b, blake2bHex: n.blake2bHex, blake2bInit: n.blake2bInit, blake2bUpdate: n.blake2bUpdate, blake2bFinal: n.blake2bFinal, blake2s: i.blake2s, blake2sHex: i.blake2sHex, blake2sInit: i.blake2sInit, blake2sUpdate: i.blake2sUpdate, blake2sFinal: i.blake2sFinal}; + }, 9488: (t2, e2, r2) => { + var n = r2(8764).Buffer; + function i(t3) { + return (4294967296 + t3).toString(16).substring(1); + } + t2.exports = {normalizeInput: function(t3) { + var e3; + if (t3 instanceof Uint8Array) + e3 = t3; + else if (t3 instanceof n) + e3 = new Uint8Array(t3); + else { + if (typeof t3 != "string") + throw new Error("Input must be an string, Buffer or Uint8Array"); + e3 = new Uint8Array(n.from(t3, "utf8")); + } + return e3; + }, toHex: function(t3) { + return Array.prototype.map.call(t3, function(t4) { + return (t4 < 16 ? "0" : "") + t4.toString(16); + }).join(""); + }, debugPrint: function(t3, e3, r3) { + for (var n2 = "\n" + t3 + " = ", o = 0; o < e3.length; o += 2) { + if (r3 === 32) + n2 += i(e3[o]).toUpperCase(), n2 += " ", n2 += i(e3[o + 1]).toUpperCase(); + else { + if (r3 !== 64) + throw new Error("Invalid size " + r3); + n2 += i(e3[o + 1]).toUpperCase(), n2 += i(e3[o]).toUpperCase(); + } + o % 6 == 4 ? n2 += "\n" + new Array(t3.length + 4).join(" ") : o < e3.length - 2 && (n2 += " "); + } + console.log(n2); + }, testSpeed: function(t3, e3, r3) { + for (var n2 = new Date().getTime(), i2 = new Uint8Array(e3), o = 0; o < e3; o++) + i2[o] = o % 256; + var a = new Date().getTime(); + for (console.log("Generated random input in " + (a - n2) + "ms"), n2 = a, o = 0; o < r3; o++) { + var s = t3(i2), u = new Date().getTime(), f = u - n2; + n2 = u, console.log("Hashed in " + f + "ms: " + s.substring(0, 20) + "..."), console.log(Math.round(e3 / (1 << 20) / (f / 1e3) * 100) / 100 + " MB PER SECOND"); + } + }}; + }, 3550: function(t2, e2, r2) { + !function(t3, e3) { + function n(t4, e4) { + if (!t4) + throw new Error(e4 || "Assertion failed"); + } + function i(t4, e4) { + t4.super_ = e4; + var r3 = function() { + }; + r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; + } + function o(t4, e4, r3) { + if (o.isBN(t4)) + return t4; + this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); + } + var a; + typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; + try { + a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(6601).Buffer; + } catch (t4) { + } + function s(t4, e4) { + var r3 = t4.charCodeAt(e4); + return r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : r3 - 48 & 15; + } + function u(t4, e4, r3) { + var n2 = s(t4, r3); + return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; + } + function f(t4, e4, r3, n2) { + for (var i2 = 0, o2 = Math.min(t4.length, r3), a2 = e4; a2 < o2; a2++) { + var s2 = t4.charCodeAt(a2) - 48; + i2 *= n2, i2 += s2 >= 49 ? s2 - 49 + 10 : s2 >= 17 ? s2 - 17 + 10 : s2; + } + return i2; + } + o.isBN = function(t4) { + return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); + }, o.max = function(t4, e4) { + return t4.cmp(e4) > 0 ? t4 : e4; + }, o.min = function(t4, e4) { + return t4.cmp(e4) < 0 ? t4 : e4; + }, o.prototype._init = function(t4, e4, r3) { + if (typeof t4 == "number") + return this._initNumber(t4, e4, r3); + if (typeof t4 == "object") + return this._initArray(t4, e4, r3); + e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); + var i2 = 0; + (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); + }, o.prototype._initNumber = function(t4, e4, r3) { + t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); + }, o.prototype._initArray = function(t4, e4, r3) { + if (n(typeof t4.length == "number"), t4.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); + for (var i2 = 0; i2 < this.length; i2++) + this.words[i2] = 0; + var o2, a2, s2 = 0; + if (r3 === "be") + for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) + a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + else if (r3 === "le") + for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) + a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + return this.strip(); + }, o.prototype._parseHex = function(t4, e4, r3) { + this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); + for (var n2 = 0; n2 < this.length; n2++) + this.words[n2] = 0; + var i2, o2 = 0, a2 = 0; + if (r3 === "be") + for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + else + for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + this.strip(); + }, o.prototype._parseBase = function(t4, e4, r3) { + this.words = [0], this.length = 1; + for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) + n2++; + n2--, i2 = i2 / e4 | 0; + for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) + u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + if (a2 !== 0) { + var h2 = 1; + for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) + h2 *= e4; + this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + } + this.strip(); + }, o.prototype.copy = function(t4) { + t4.words = new Array(this.length); + for (var e4 = 0; e4 < this.length; e4++) + t4.words[e4] = this.words[e4]; + t4.length = this.length, t4.negative = this.negative, t4.red = this.red; + }, o.prototype.clone = function() { + var t4 = new o(null); + return this.copy(t4), t4; + }, o.prototype._expand = function(t4) { + for (; this.length < t4; ) + this.words[this.length++] = 0; + return this; + }, o.prototype.strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, o.prototype.inspect = function() { + return (this.red ? ""; + }; + var c = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], h = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], l = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + function d(t4, e4, r3) { + r3.negative = e4.negative ^ t4.negative; + var n2 = t4.length + e4.length | 0; + r3.length = n2, n2 = n2 - 1 | 0; + var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; + r3.words[0] = s2; + for (var f2 = 1; f2 < n2; f2++) { + for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { + var p2 = f2 - d2 | 0; + c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; + } + r3.words[f2] = 0 | h2, u2 = 0 | c2; + } + return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3.strip(); + } + o.prototype.toString = function(t4, e4) { + var r3; + if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { + r3 = ""; + for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { + var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); + r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? c[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); + } + for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { + var f2 = h[t4], d2 = l[t4]; + r3 = ""; + var p2 = this.clone(); + for (p2.negative = 0; !p2.isZero(); ) { + var y2 = p2.modn(d2).toString(t4); + r3 = (p2 = p2.idivn(d2)).isZero() ? y2 + r3 : c[f2 - y2.length] + y2 + r3; + } + for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + n(false, "Base should be between 2 and 36"); + }, o.prototype.toNumber = function() { + var t4 = this.words[0]; + return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; + }, o.prototype.toJSON = function() { + return this.toString(16); + }, o.prototype.toBuffer = function(t4, e4) { + return n(a !== void 0), this.toArrayLike(a, t4, e4); + }, o.prototype.toArray = function(t4, e4) { + return this.toArrayLike(Array, t4, e4); + }, o.prototype.toArrayLike = function(t4, e4, r3) { + var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); + n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"), this.strip(); + var a2, s2, u2 = e4 === "le", f2 = new t4(o2), c2 = this.clone(); + if (u2) { + for (s2 = 0; !c2.isZero(); s2++) + a2 = c2.andln(255), c2.iushrn(8), f2[s2] = a2; + for (; s2 < o2; s2++) + f2[s2] = 0; + } else { + for (s2 = 0; s2 < o2 - i2; s2++) + f2[s2] = 0; + for (s2 = 0; !c2.isZero(); s2++) + a2 = c2.andln(255), c2.iushrn(8), f2[o2 - s2 - 1] = a2; + } + return f2; + }, Math.clz32 ? o.prototype._countBits = function(t4) { + return 32 - Math.clz32(t4); + } : o.prototype._countBits = function(t4) { + var e4 = t4, r3 = 0; + return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; + }, o.prototype._zeroBits = function(t4) { + if (t4 === 0) + return 26; + var e4 = t4, r3 = 0; + return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; + }, o.prototype.bitLength = function() { + var t4 = this.words[this.length - 1], e4 = this._countBits(t4); + return 26 * (this.length - 1) + e4; + }, o.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { + var r3 = this._zeroBits(this.words[e4]); + if (t4 += r3, r3 !== 26) + break; + } + return t4; + }, o.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o.prototype.toTwos = function(t4) { + return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); + }, o.prototype.fromTwos = function(t4) { + return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); + }, o.prototype.isNeg = function() { + return this.negative !== 0; + }, o.prototype.neg = function() { + return this.clone().ineg(); + }, o.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o.prototype.iuor = function(t4) { + for (; this.length < t4.length; ) + this.words[this.length++] = 0; + for (var e4 = 0; e4 < t4.length; e4++) + this.words[e4] = this.words[e4] | t4.words[e4]; + return this.strip(); + }, o.prototype.ior = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuor(t4); + }, o.prototype.or = function(t4) { + return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); + }, o.prototype.uor = function(t4) { + return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); + }, o.prototype.iuand = function(t4) { + var e4; + e4 = this.length > t4.length ? t4 : this; + for (var r3 = 0; r3 < e4.length; r3++) + this.words[r3] = this.words[r3] & t4.words[r3]; + return this.length = e4.length, this.strip(); + }, o.prototype.iand = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuand(t4); + }, o.prototype.and = function(t4) { + return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); + }, o.prototype.uand = function(t4) { + return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); + }, o.prototype.iuxor = function(t4) { + var e4, r3; + this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); + for (var n2 = 0; n2 < r3.length; n2++) + this.words[n2] = e4.words[n2] ^ r3.words[n2]; + if (this !== e4) + for (; n2 < e4.length; n2++) + this.words[n2] = e4.words[n2]; + return this.length = e4.length, this.strip(); + }, o.prototype.ixor = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuxor(t4); + }, o.prototype.xor = function(t4) { + return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); + }, o.prototype.uxor = function(t4) { + return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); + }, o.prototype.inotn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; + this._expand(e4), r3 > 0 && e4--; + for (var i2 = 0; i2 < e4; i2++) + this.words[i2] = 67108863 & ~this.words[i2]; + return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this.strip(); + }, o.prototype.notn = function(t4) { + return this.clone().inotn(t4); + }, o.prototype.setn = function(t4, e4) { + n(typeof t4 == "number" && t4 >= 0); + var r3 = t4 / 26 | 0, i2 = t4 % 26; + return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this.strip(); + }, o.prototype.iadd = function(t4) { + var e4, r3, n2; + if (this.negative !== 0 && t4.negative === 0) + return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && t4.negative !== 0) + return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); + this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) + e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + for (; i2 !== 0 && o2 < r3.length; o2++) + e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + if (this.length = r3.length, i2 !== 0) + this.words[this.length] = i2, this.length++; + else if (r3 !== this) + for (; o2 < r3.length; o2++) + this.words[o2] = r3.words[o2]; + return this; + }, o.prototype.add = function(t4) { + var e4; + return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); + }, o.prototype.isub = function(t4) { + if (t4.negative !== 0) { + t4.negative = 0; + var e4 = this.iadd(t4); + return t4.negative = 1, e4._normSign(); + } + if (this.negative !== 0) + return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); + var r3, n2, i2 = this.cmp(t4); + if (i2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + for (; o2 !== 0 && a2 < r3.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + if (o2 === 0 && a2 < r3.length && r3 !== this) + for (; a2 < r3.length; a2++) + this.words[a2] = r3.words[a2]; + return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this.strip(); + }, o.prototype.sub = function(t4) { + return this.clone().isub(t4); + }; + var p = function(t4, e4, r3) { + var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v2 = 0 | a2[3], w2 = 8191 & v2, _2 = v2 >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A = 0 | a2[5], k = 8191 & A, B = A >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; + r3.negative = t4.negative ^ e4.negative, r3.length = 19; + var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; + f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); + var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; + var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; + var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; + var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k, z), i2 = (i2 = Math.imul(k, q)) + Math.imul(B, z) | 0, o2 = Math.imul(B, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; + var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k, F) | 0, i2 = (i2 = i2 + Math.imul(k, V) | 0) + Math.imul(B, F) | 0, o2 = o2 + Math.imul(B, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; + var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k, J) | 0, i2 = (i2 = i2 + Math.imul(k, $) | 0) + Math.imul(B, J) | 0, o2 = o2 + Math.imul(B, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; + var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k, Z) | 0, i2 = (i2 = i2 + Math.imul(k, Y) | 0) + Math.imul(B, Z) | 0, o2 = o2 + Math.imul(B, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; + var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k, Q) | 0, i2 = (i2 = i2 + Math.imul(k, tt) | 0) + Math.imul(B, Q) | 0, o2 = o2 + Math.imul(B, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; + var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k, rt) | 0, i2 = (i2 = i2 + Math.imul(k, nt) | 0) + Math.imul(B, rt) | 0, o2 = o2 + Math.imul(B, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; + var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k, ot) | 0, i2 = (i2 = i2 + Math.imul(k, at) | 0) + Math.imul(B, ot) | 0, o2 = o2 + Math.imul(B, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; + var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k, ut) | 0, i2 = (i2 = i2 + Math.imul(k, ft) | 0) + Math.imul(B, ut) | 0, o2 = o2 + Math.imul(B, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; + var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k, ht) | 0, i2 = (i2 = i2 + Math.imul(k, lt) | 0) + Math.imul(B, ht) | 0, o2 = o2 + Math.imul(B, lt) | 0; + var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; + var Ot = (f2 + (n2 = n2 + Math.imul(k, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k, yt) | 0) + Math.imul(B, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(B, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; + var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; + var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); + var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; + var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; + return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; + }; + function y(t4, e4, r3) { + return new m().mulp(t4, e4, r3); + } + function m(t4, e4) { + this.x = t4, this.y = e4; + } + Math.imul || (p = d), o.prototype.mulTo = function(t4, e4) { + var r3 = this.length + t4.length; + return this.length === 10 && t4.length === 10 ? p(this, t4, e4) : r3 < 63 ? d(this, t4, e4) : r3 < 1024 ? function(t5, e5, r4) { + r4.negative = e5.negative ^ t5.negative, r4.length = t5.length + e5.length; + for (var n2 = 0, i2 = 0, o2 = 0; o2 < r4.length - 1; o2++) { + var a2 = i2; + i2 = 0; + for (var s2 = 67108863 & n2, u2 = Math.min(o2, e5.length - 1), f2 = Math.max(0, o2 - t5.length + 1); f2 <= u2; f2++) { + var c2 = o2 - f2, h2 = (0 | t5.words[c2]) * (0 | e5.words[f2]), l2 = 67108863 & h2; + s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; + } + r4.words[o2] = s2, n2 = a2, a2 = i2; + } + return n2 !== 0 ? r4.words[o2] = n2 : r4.length--, r4.strip(); + }(this, t4, e4) : y(this, t4, e4); + }, m.prototype.makeRBT = function(t4) { + for (var e4 = new Array(t4), r3 = o.prototype._countBits(t4) - 1, n2 = 0; n2 < t4; n2++) + e4[n2] = this.revBin(n2, r3, t4); + return e4; + }, m.prototype.revBin = function(t4, e4, r3) { + if (t4 === 0 || t4 === r3 - 1) + return t4; + for (var n2 = 0, i2 = 0; i2 < e4; i2++) + n2 |= (1 & t4) << e4 - i2 - 1, t4 >>= 1; + return n2; + }, m.prototype.permute = function(t4, e4, r3, n2, i2, o2) { + for (var a2 = 0; a2 < o2; a2++) + n2[a2] = e4[t4[a2]], i2[a2] = r3[t4[a2]]; + }, m.prototype.transform = function(t4, e4, r3, n2, i2, o2) { + this.permute(o2, t4, e4, r3, n2, i2); + for (var a2 = 1; a2 < i2; a2 <<= 1) + for (var s2 = a2 << 1, u2 = Math.cos(2 * Math.PI / s2), f2 = Math.sin(2 * Math.PI / s2), c2 = 0; c2 < i2; c2 += s2) + for (var h2 = u2, l2 = f2, d2 = 0; d2 < a2; d2++) { + var p2 = r3[c2 + d2], y2 = n2[c2 + d2], m2 = r3[c2 + d2 + a2], b2 = n2[c2 + d2 + a2], g2 = h2 * m2 - l2 * b2; + b2 = h2 * b2 + l2 * m2, m2 = g2, r3[c2 + d2] = p2 + m2, n2[c2 + d2] = y2 + b2, r3[c2 + d2 + a2] = p2 - m2, n2[c2 + d2 + a2] = y2 - b2, d2 !== s2 && (g2 = u2 * h2 - f2 * l2, l2 = u2 * l2 + f2 * h2, h2 = g2); + } + }, m.prototype.guessLen13b = function(t4, e4) { + var r3 = 1 | Math.max(e4, t4), n2 = 1 & r3, i2 = 0; + for (r3 = r3 / 2 | 0; r3; r3 >>>= 1) + i2++; + return 1 << i2 + 1 + n2; + }, m.prototype.conjugate = function(t4, e4, r3) { + if (!(r3 <= 1)) + for (var n2 = 0; n2 < r3 / 2; n2++) { + var i2 = t4[n2]; + t4[n2] = t4[r3 - n2 - 1], t4[r3 - n2 - 1] = i2, i2 = e4[n2], e4[n2] = -e4[r3 - n2 - 1], e4[r3 - n2 - 1] = -i2; + } + }, m.prototype.normalize13b = function(t4, e4) { + for (var r3 = 0, n2 = 0; n2 < e4 / 2; n2++) { + var i2 = 8192 * Math.round(t4[2 * n2 + 1] / e4) + Math.round(t4[2 * n2] / e4) + r3; + t4[n2] = 67108863 & i2, r3 = i2 < 67108864 ? 0 : i2 / 67108864 | 0; + } + return t4; + }, m.prototype.convert13b = function(t4, e4, r3, i2) { + for (var o2 = 0, a2 = 0; a2 < e4; a2++) + o2 += 0 | t4[a2], r3[2 * a2] = 8191 & o2, o2 >>>= 13, r3[2 * a2 + 1] = 8191 & o2, o2 >>>= 13; + for (a2 = 2 * e4; a2 < i2; ++a2) + r3[a2] = 0; + n(o2 === 0), n((-8192 & o2) == 0); + }, m.prototype.stub = function(t4) { + for (var e4 = new Array(t4), r3 = 0; r3 < t4; r3++) + e4[r3] = 0; + return e4; + }, m.prototype.mulp = function(t4, e4, r3) { + var n2 = 2 * this.guessLen13b(t4.length, e4.length), i2 = this.makeRBT(n2), o2 = this.stub(n2), a2 = new Array(n2), s2 = new Array(n2), u2 = new Array(n2), f2 = new Array(n2), c2 = new Array(n2), h2 = new Array(n2), l2 = r3.words; + l2.length = n2, this.convert13b(t4.words, t4.length, a2, n2), this.convert13b(e4.words, e4.length, f2, n2), this.transform(a2, o2, s2, u2, n2, i2), this.transform(f2, o2, c2, h2, n2, i2); + for (var d2 = 0; d2 < n2; d2++) { + var p2 = s2[d2] * c2[d2] - u2[d2] * h2[d2]; + u2[d2] = s2[d2] * h2[d2] + u2[d2] * c2[d2], s2[d2] = p2; + } + return this.conjugate(s2, u2, n2), this.transform(s2, u2, l2, o2, n2, i2), this.conjugate(l2, o2, n2), this.normalize13b(l2, n2), r3.negative = t4.negative ^ e4.negative, r3.length = t4.length + e4.length, r3.strip(); + }, o.prototype.mul = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); + }, o.prototype.mulf = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), y(this, t4, e4); + }, o.prototype.imul = function(t4) { + return this.clone().mulTo(t4, this); + }, o.prototype.imuln = function(t4) { + n(typeof t4 == "number"), n(t4 < 67108864); + for (var e4 = 0, r3 = 0; r3 < this.length; r3++) { + var i2 = (0 | this.words[r3]) * t4, o2 = (67108863 & i2) + (67108863 & e4); + e4 >>= 26, e4 += i2 / 67108864 | 0, e4 += o2 >>> 26, this.words[r3] = 67108863 & o2; + } + return e4 !== 0 && (this.words[r3] = e4, this.length++), this; + }, o.prototype.muln = function(t4) { + return this.clone().imuln(t4); + }, o.prototype.sqr = function() { + return this.mul(this); + }, o.prototype.isqr = function() { + return this.imul(this.clone()); + }, o.prototype.pow = function(t4) { + var e4 = function(t5) { + for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { + var n3 = r4 / 26 | 0, i3 = r4 % 26; + e5[r4] = (t5.words[n3] & 1 << i3) >>> i3; + } + return e5; + }(t4); + if (e4.length === 0) + return new o(1); + for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) + ; + if (++n2 < e4.length) + for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) + e4[n2] !== 0 && (r3 = r3.mul(i2)); + return r3; + }, o.prototype.iushln = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; + if (r3 !== 0) { + var a2 = 0; + for (e4 = 0; e4 < this.length; e4++) { + var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; + this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; + } + a2 && (this.words[e4] = a2, this.length++); + } + if (i2 !== 0) { + for (e4 = this.length - 1; e4 >= 0; e4--) + this.words[e4 + i2] = this.words[e4]; + for (e4 = 0; e4 < i2; e4++) + this.words[e4] = 0; + this.length += i2; + } + return this.strip(); + }, o.prototype.ishln = function(t4) { + return n(this.negative === 0), this.iushln(t4); + }, o.prototype.iushrn = function(t4, e4, r3) { + var i2; + n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; + var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; + if (i2 -= a2, i2 = Math.max(0, i2), u2) { + for (var f2 = 0; f2 < a2; f2++) + u2.words[f2] = this.words[f2]; + u2.length = a2; + } + if (a2 === 0) + ; + else if (this.length > a2) + for (this.length -= a2, f2 = 0; f2 < this.length; f2++) + this.words[f2] = this.words[f2 + a2]; + else + this.words[0] = 0, this.length = 1; + var c2 = 0; + for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { + var h2 = 0 | this.words[f2]; + this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; + } + return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this.strip(); + }, o.prototype.ishrn = function(t4, e4, r3) { + return n(this.negative === 0), this.iushrn(t4, e4, r3); + }, o.prototype.shln = function(t4) { + return this.clone().ishln(t4); + }, o.prototype.ushln = function(t4) { + return this.clone().iushln(t4); + }, o.prototype.shrn = function(t4) { + return this.clone().ishrn(t4); + }, o.prototype.ushrn = function(t4) { + return this.clone().iushrn(t4); + }, o.prototype.testn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + return !(this.length <= r3 || !(this.words[r3] & i2)); + }, o.prototype.imaskn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26; + if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) + return this; + if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { + var i2 = 67108863 ^ 67108863 >>> e4 << e4; + this.words[this.length - 1] &= i2; + } + return this.strip(); + }, o.prototype.maskn = function(t4) { + return this.clone().imaskn(t4); + }, o.prototype.iaddn = function(t4) { + return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) < t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); + }, o.prototype._iaddn = function(t4) { + this.words[0] += t4; + for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) + this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; + return this.length = Math.max(this.length, e4 + 1), this; + }, o.prototype.isubn = function(t4) { + if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) + return this.iaddn(-t4); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(t4), this.negative = 1, this; + if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) + this.words[e4] += 67108864, this.words[e4 + 1] -= 1; + return this.strip(); + }, o.prototype.addn = function(t4) { + return this.clone().iaddn(t4); + }, o.prototype.subn = function(t4) { + return this.clone().isubn(t4); + }, o.prototype.iabs = function() { + return this.negative = 0, this; + }, o.prototype.abs = function() { + return this.clone().iabs(); + }, o.prototype._ishlnsubmul = function(t4, e4, r3) { + var i2, o2, a2 = t4.length + r3; + this._expand(a2); + var s2 = 0; + for (i2 = 0; i2 < t4.length; i2++) { + o2 = (0 | this.words[i2 + r3]) + s2; + var u2 = (0 | t4.words[i2]) * e4; + s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; + } + for (; i2 < this.length - r3; i2++) + s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; + if (s2 === 0) + return this.strip(); + for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) + s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; + return this.negative = 1, this.strip(); + }, o.prototype._wordDiv = function(t4, e4) { + var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; + (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); + var s2, u2 = n2.length - i2.length; + if (e4 !== "mod") { + (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); + for (var f2 = 0; f2 < s2.length; f2++) + s2.words[f2] = 0; + } + var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); + c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); + for (var h2 = u2 - 1; h2 >= 0; h2--) { + var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); + for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) + l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); + s2 && (s2.words[h2] = l2); + } + return s2 && s2.strip(), n2.strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; + }, o.prototype.divmod = function(t4, e4, r3) { + return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modn(t4.words[0]))} : this._wordDiv(t4, e4); + var i2, a2, s2; + }, o.prototype.div = function(t4) { + return this.divmod(t4, "div", false).div; + }, o.prototype.mod = function(t4) { + return this.divmod(t4, "mod", false).mod; + }, o.prototype.umod = function(t4) { + return this.divmod(t4, "mod", true).mod; + }, o.prototype.divRound = function(t4) { + var e4 = this.divmod(t4); + if (e4.mod.isZero()) + return e4.div; + var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); + return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); + }, o.prototype.modn = function(t4) { + n(t4 <= 67108863); + for (var e4 = (1 << 26) % t4, r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) + r3 = (e4 * r3 + (0 | this.words[i2])) % t4; + return r3; + }, o.prototype.idivn = function(t4) { + n(t4 <= 67108863); + for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { + var i2 = (0 | this.words[r3]) + 67108864 * e4; + this.words[r3] = i2 / t4 | 0, e4 = i2 % t4; + } + return this.strip(); + }, o.prototype.divn = function(t4) { + return this.clone().idivn(t4); + }, o.prototype.egcd = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) + e4.iushrn(1), r3.iushrn(1), ++f2; + for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { + for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) + ; + if (l2 > 0) + for (e4.iushrn(l2); l2-- > 0; ) + (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); + for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) + ; + if (p2 > 0) + for (r3.iushrn(p2); p2-- > 0; ) + (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); + } + return {a: s2, b: u2, gcd: r3.iushln(f2)}; + }, o.prototype._invmp = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { + for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) + ; + if (f2 > 0) + for (e4.iushrn(f2); f2-- > 0; ) + a2.isOdd() && a2.iadd(u2), a2.iushrn(1); + for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) + ; + if (h2 > 0) + for (r3.iushrn(h2); h2-- > 0; ) + s2.isOdd() && s2.iadd(u2), s2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); + } + return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; + }, o.prototype.gcd = function(t4) { + if (this.isZero()) + return t4.abs(); + if (t4.isZero()) + return this.abs(); + var e4 = this.clone(), r3 = t4.clone(); + e4.negative = 0, r3.negative = 0; + for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) + e4.iushrn(1), r3.iushrn(1); + for (; ; ) { + for (; e4.isEven(); ) + e4.iushrn(1); + for (; r3.isEven(); ) + r3.iushrn(1); + var i2 = e4.cmp(r3); + if (i2 < 0) { + var o2 = e4; + e4 = r3, r3 = o2; + } else if (i2 === 0 || r3.cmpn(1) === 0) + break; + e4.isub(r3); + } + return r3.iushln(n2); + }, o.prototype.invm = function(t4) { + return this.egcd(t4).a.umod(t4); + }, o.prototype.isEven = function() { + return (1 & this.words[0]) == 0; + }, o.prototype.isOdd = function() { + return (1 & this.words[0]) == 1; + }, o.prototype.andln = function(t4) { + return this.words[0] & t4; + }, o.prototype.bincn = function(t4) { + n(typeof t4 == "number"); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + if (this.length <= r3) + return this._expand(r3 + 1), this.words[r3] |= i2, this; + for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { + var s2 = 0 | this.words[a2]; + o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; + } + return o2 !== 0 && (this.words[a2] = o2, this.length++), this; + }, o.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o.prototype.cmpn = function(t4) { + var e4, r3 = t4 < 0; + if (this.negative !== 0 && !r3) + return -1; + if (this.negative === 0 && r3) + return 1; + if (this.strip(), this.length > 1) + e4 = 1; + else { + r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); + var i2 = 0 | this.words[0]; + e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; + } + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.cmp = function(t4) { + if (this.negative !== 0 && t4.negative === 0) + return -1; + if (this.negative === 0 && t4.negative !== 0) + return 1; + var e4 = this.ucmp(t4); + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.ucmp = function(t4) { + if (this.length > t4.length) + return 1; + if (this.length < t4.length) + return -1; + for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { + var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; + if (n2 !== i2) { + n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); + break; + } + } + return e4; + }, o.prototype.gtn = function(t4) { + return this.cmpn(t4) === 1; + }, o.prototype.gt = function(t4) { + return this.cmp(t4) === 1; + }, o.prototype.gten = function(t4) { + return this.cmpn(t4) >= 0; + }, o.prototype.gte = function(t4) { + return this.cmp(t4) >= 0; + }, o.prototype.ltn = function(t4) { + return this.cmpn(t4) === -1; + }, o.prototype.lt = function(t4) { + return this.cmp(t4) === -1; + }, o.prototype.lten = function(t4) { + return this.cmpn(t4) <= 0; + }, o.prototype.lte = function(t4) { + return this.cmp(t4) <= 0; + }, o.prototype.eqn = function(t4) { + return this.cmpn(t4) === 0; + }, o.prototype.eq = function(t4) { + return this.cmp(t4) === 0; + }, o.red = function(t4) { + return new S(t4); + }, o.prototype.toRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); + }, o.prototype.fromRed = function() { + return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o.prototype._forceRed = function(t4) { + return this.red = t4, this; + }, o.prototype.forceRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); + }, o.prototype.redAdd = function(t4) { + return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); + }, o.prototype.redIAdd = function(t4) { + return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); + }, o.prototype.redSub = function(t4) { + return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); + }, o.prototype.redISub = function(t4) { + return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); + }, o.prototype.redShl = function(t4) { + return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); + }, o.prototype.redMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); + }, o.prototype.redIMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); + }, o.prototype.redSqr = function() { + return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o.prototype.redISqr = function() { + return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o.prototype.redSqrt = function() { + return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o.prototype.redInvm = function() { + return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o.prototype.redNeg = function() { + return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o.prototype.redPow = function(t4) { + return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); + }; + var b = {k256: null, p224: null, p192: null, p25519: null}; + function g(t4, e4) { + this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + function v() { + g.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + function w() { + g.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + function _() { + g.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + function M() { + g.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + function S(t4) { + if (typeof t4 == "string") { + var e4 = o._prime(t4); + this.m = e4.p, this.prime = e4; + } else + n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; + } + function E(t4) { + S.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); + } + g.prototype._tmp = function() { + var t4 = new o(null); + return t4.words = new Array(Math.ceil(this.n / 13)), t4; + }, g.prototype.ireduce = function(t4) { + var e4, r3 = t4; + do { + this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); + } while (e4 > this.n); + var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); + return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; + }, g.prototype.split = function(t4, e4) { + t4.iushrn(this.n, 0, e4); + }, g.prototype.imulK = function(t4) { + return t4.imul(this.k); + }, i(v, g), v.prototype.split = function(t4, e4) { + for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) + e4.words[i2] = t4.words[i2]; + if (e4.length = n2, t4.length <= 9) + return t4.words[0] = 0, void (t4.length = 1); + var o2 = t4.words[9]; + for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { + var a2 = 0 | t4.words[i2]; + t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; + } + o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; + }, v.prototype.imulK = function(t4) { + t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 0 | t4.words[r3]; + e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); + } + return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; + }, i(w, g), i(_, g), i(M, g), M.prototype.imulK = function(t4) { + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; + n2 >>>= 26, t4.words[r3] = i2, e4 = n2; + } + return e4 !== 0 && (t4.words[t4.length++] = e4), t4; + }, o._prime = function(t4) { + if (b[t4]) + return b[t4]; + var e4; + if (t4 === "k256") + e4 = new v(); + else if (t4 === "p224") + e4 = new w(); + else if (t4 === "p192") + e4 = new _(); + else { + if (t4 !== "p25519") + throw new Error("Unknown prime " + t4); + e4 = new M(); + } + return b[t4] = e4, e4; + }, S.prototype._verify1 = function(t4) { + n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); + }, S.prototype._verify2 = function(t4, e4) { + n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); + }, S.prototype.imod = function(t4) { + return this.prime ? this.prime.ireduce(t4)._forceRed(this) : t4.umod(this.m)._forceRed(this); + }, S.prototype.neg = function(t4) { + return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); + }, S.prototype.add = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.add(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); + }, S.prototype.iadd = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.iadd(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; + }, S.prototype.sub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.sub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); + }, S.prototype.isub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.isub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; + }, S.prototype.shl = function(t4, e4) { + return this._verify1(t4), this.imod(t4.ushln(e4)); + }, S.prototype.imul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.imul(e4)); + }, S.prototype.mul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.mul(e4)); + }, S.prototype.isqr = function(t4) { + return this.imul(t4, t4.clone()); + }, S.prototype.sqr = function(t4) { + return this.mul(t4, t4); + }, S.prototype.sqrt = function(t4) { + if (t4.isZero()) + return t4.clone(); + var e4 = this.m.andln(3); + if (n(e4 % 2 == 1), e4 === 3) { + var r3 = this.m.add(new o(1)).iushrn(2); + return this.pow(t4, r3); + } + for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) + a2++, i2.iushrn(1); + n(!i2.isZero()); + var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); + for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) + c2.redIAdd(u2); + for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { + for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) + y2 = y2.redSqr(); + n(m2 < p2); + var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); + l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; + } + return l2; + }, S.prototype.invm = function(t4) { + var e4 = t4._invmp(this.m); + return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); + }, S.prototype.pow = function(t4, e4) { + if (e4.isZero()) + return new o(1).toRed(this); + if (e4.cmpn(1) === 0) + return t4.clone(); + var r3 = new Array(16); + r3[0] = new o(1).toRed(this), r3[1] = t4; + for (var n2 = 2; n2 < r3.length; n2++) + r3[n2] = this.mul(r3[n2 - 1], t4); + var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; + for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { + for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { + var h2 = f2 >> c2 & 1; + i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; + } + u2 = 26; + } + return i2; + }, S.prototype.convertTo = function(t4) { + var e4 = t4.umod(this.m); + return e4 === t4 ? e4.clone() : e4; + }, S.prototype.convertFrom = function(t4) { + var e4 = t4.clone(); + return e4.red = null, e4; + }, o.mont = function(t4) { + return new E(t4); + }, i(E, S), E.prototype.convertTo = function(t4) { + return this.imod(t4.ushln(this.shift)); + }, E.prototype.convertFrom = function(t4) { + var e4 = this.imod(t4.mul(this.rinv)); + return e4.red = null, e4; + }, E.prototype.imul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return t4.words[0] = 0, t4.length = 1, t4; + var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; + return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); + }, E.prototype.mul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return new o(0)._forceRed(this); + var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; + return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); + }, E.prototype.invm = function(t4) { + return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); + }; + }(t2 = r2.nmd(t2), this); + }, 7376: (t2, e2, r2) => { + var n; + function i(t3) { + this.rand = t3; + } + if (t2.exports = function(t3) { + return n || (n = new i(null)), n.generate(t3); + }, t2.exports.Rand = i, i.prototype.generate = function(t3) { + return this._rand(t3); + }, i.prototype._rand = function(t3) { + if (this.rand.getBytes) + return this.rand.getBytes(t3); + for (var e3 = new Uint8Array(t3), r3 = 0; r3 < e3.length; r3++) + e3[r3] = this.rand.getByte(); + return e3; + }, typeof self == "object") + self.crypto && self.crypto.getRandomValues ? i.prototype._rand = function(t3) { + var e3 = new Uint8Array(t3); + return self.crypto.getRandomValues(e3), e3; + } : self.msCrypto && self.msCrypto.getRandomValues ? i.prototype._rand = function(t3) { + var e3 = new Uint8Array(t3); + return self.msCrypto.getRandomValues(e3), e3; + } : typeof window == "object" && (i.prototype._rand = function() { + throw new Error("Not implemented yet"); + }); + else + try { + var o = r2(9214); + if (typeof o.randomBytes != "function") + throw new Error("Not supported"); + i.prototype._rand = function(t3) { + return o.randomBytes(t3); + }; + } catch (t3) { + } + }, 4497: (t2, e2, r2) => { + var n = r2(9509).Buffer; + function i(t3) { + n.isBuffer(t3) || (t3 = n.from(t3)); + for (var e3 = t3.length / 4 | 0, r3 = new Array(e3), i2 = 0; i2 < e3; i2++) + r3[i2] = t3.readUInt32BE(4 * i2); + return r3; + } + function o(t3) { + for (; 0 < t3.length; t3++) + t3[0] = 0; + } + function a(t3, e3, r3, n2, i2) { + for (var o2, a2, s2, u2, f2 = r3[0], c = r3[1], h = r3[2], l = r3[3], d = t3[0] ^ e3[0], p = t3[1] ^ e3[1], y = t3[2] ^ e3[2], m = t3[3] ^ e3[3], b = 4, g = 1; g < i2; g++) + o2 = f2[d >>> 24] ^ c[p >>> 16 & 255] ^ h[y >>> 8 & 255] ^ l[255 & m] ^ e3[b++], a2 = f2[p >>> 24] ^ c[y >>> 16 & 255] ^ h[m >>> 8 & 255] ^ l[255 & d] ^ e3[b++], s2 = f2[y >>> 24] ^ c[m >>> 16 & 255] ^ h[d >>> 8 & 255] ^ l[255 & p] ^ e3[b++], u2 = f2[m >>> 24] ^ c[d >>> 16 & 255] ^ h[p >>> 8 & 255] ^ l[255 & y] ^ e3[b++], d = o2, p = a2, y = s2, m = u2; + return o2 = (n2[d >>> 24] << 24 | n2[p >>> 16 & 255] << 16 | n2[y >>> 8 & 255] << 8 | n2[255 & m]) ^ e3[b++], a2 = (n2[p >>> 24] << 24 | n2[y >>> 16 & 255] << 16 | n2[m >>> 8 & 255] << 8 | n2[255 & d]) ^ e3[b++], s2 = (n2[y >>> 24] << 24 | n2[m >>> 16 & 255] << 16 | n2[d >>> 8 & 255] << 8 | n2[255 & p]) ^ e3[b++], u2 = (n2[m >>> 24] << 24 | n2[d >>> 16 & 255] << 16 | n2[p >>> 8 & 255] << 8 | n2[255 & y]) ^ e3[b++], [o2 >>>= 0, a2 >>>= 0, s2 >>>= 0, u2 >>>= 0]; + } + var s = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], u = function() { + for (var t3 = new Array(256), e3 = 0; e3 < 256; e3++) + t3[e3] = e3 < 128 ? e3 << 1 : e3 << 1 ^ 283; + for (var r3 = [], n2 = [], i2 = [[], [], [], []], o2 = [[], [], [], []], a2 = 0, s2 = 0, u2 = 0; u2 < 256; ++u2) { + var f2 = s2 ^ s2 << 1 ^ s2 << 2 ^ s2 << 3 ^ s2 << 4; + f2 = f2 >>> 8 ^ 255 & f2 ^ 99, r3[a2] = f2, n2[f2] = a2; + var c = t3[a2], h = t3[c], l = t3[h], d = 257 * t3[f2] ^ 16843008 * f2; + i2[0][a2] = d << 24 | d >>> 8, i2[1][a2] = d << 16 | d >>> 16, i2[2][a2] = d << 8 | d >>> 24, i2[3][a2] = d, d = 16843009 * l ^ 65537 * h ^ 257 * c ^ 16843008 * a2, o2[0][f2] = d << 24 | d >>> 8, o2[1][f2] = d << 16 | d >>> 16, o2[2][f2] = d << 8 | d >>> 24, o2[3][f2] = d, a2 === 0 ? a2 = s2 = 1 : (a2 = c ^ t3[t3[t3[l ^ c]]], s2 ^= t3[t3[s2]]); + } + return {SBOX: r3, INV_SBOX: n2, SUB_MIX: i2, INV_SUB_MIX: o2}; + }(); + function f(t3) { + this._key = i(t3), this._reset(); + } + f.blockSize = 16, f.keySize = 32, f.prototype.blockSize = f.blockSize, f.prototype.keySize = f.keySize, f.prototype._reset = function() { + for (var t3 = this._key, e3 = t3.length, r3 = e3 + 6, n2 = 4 * (r3 + 1), i2 = [], o2 = 0; o2 < e3; o2++) + i2[o2] = t3[o2]; + for (o2 = e3; o2 < n2; o2++) { + var a2 = i2[o2 - 1]; + o2 % e3 == 0 ? (a2 = a2 << 8 | a2 >>> 24, a2 = u.SBOX[a2 >>> 24] << 24 | u.SBOX[a2 >>> 16 & 255] << 16 | u.SBOX[a2 >>> 8 & 255] << 8 | u.SBOX[255 & a2], a2 ^= s[o2 / e3 | 0] << 24) : e3 > 6 && o2 % e3 == 4 && (a2 = u.SBOX[a2 >>> 24] << 24 | u.SBOX[a2 >>> 16 & 255] << 16 | u.SBOX[a2 >>> 8 & 255] << 8 | u.SBOX[255 & a2]), i2[o2] = i2[o2 - e3] ^ a2; + } + for (var f2 = [], c = 0; c < n2; c++) { + var h = n2 - c, l = i2[h - (c % 4 ? 0 : 4)]; + f2[c] = c < 4 || h <= 4 ? l : u.INV_SUB_MIX[0][u.SBOX[l >>> 24]] ^ u.INV_SUB_MIX[1][u.SBOX[l >>> 16 & 255]] ^ u.INV_SUB_MIX[2][u.SBOX[l >>> 8 & 255]] ^ u.INV_SUB_MIX[3][u.SBOX[255 & l]]; + } + this._nRounds = r3, this._keySchedule = i2, this._invKeySchedule = f2; + }, f.prototype.encryptBlockRaw = function(t3) { + return a(t3 = i(t3), this._keySchedule, u.SUB_MIX, u.SBOX, this._nRounds); + }, f.prototype.encryptBlock = function(t3) { + var e3 = this.encryptBlockRaw(t3), r3 = n.allocUnsafe(16); + return r3.writeUInt32BE(e3[0], 0), r3.writeUInt32BE(e3[1], 4), r3.writeUInt32BE(e3[2], 8), r3.writeUInt32BE(e3[3], 12), r3; + }, f.prototype.decryptBlock = function(t3) { + var e3 = (t3 = i(t3))[1]; + t3[1] = t3[3], t3[3] = e3; + var r3 = a(t3, this._invKeySchedule, u.INV_SUB_MIX, u.INV_SBOX, this._nRounds), o2 = n.allocUnsafe(16); + return o2.writeUInt32BE(r3[0], 0), o2.writeUInt32BE(r3[3], 4), o2.writeUInt32BE(r3[2], 8), o2.writeUInt32BE(r3[1], 12), o2; + }, f.prototype.scrub = function() { + o(this._keySchedule), o(this._invKeySchedule), o(this._key); + }, t2.exports.AES = f; + }, 2422: (t2, e2, r2) => { + var n = r2(4497), i = r2(9509).Buffer, o = r2(1027), a = r2(5717), s = r2(3288), u = r2(7295), f = r2(685); + function c(t3, e3, r3, a2) { + o.call(this); + var u2 = i.alloc(4, 0); + this._cipher = new n.AES(e3); + var c2 = this._cipher.encryptBlock(u2); + this._ghash = new s(c2), r3 = function(t4, e4, r4) { + if (e4.length === 12) + return t4._finID = i.concat([e4, i.from([0, 0, 0, 1])]), i.concat([e4, i.from([0, 0, 0, 2])]); + var n2 = new s(r4), o2 = e4.length, a3 = o2 % 16; + n2.update(e4), a3 && (a3 = 16 - a3, n2.update(i.alloc(a3, 0))), n2.update(i.alloc(8, 0)); + var u3 = 8 * o2, c3 = i.alloc(8); + c3.writeUIntBE(u3, 0, 8), n2.update(c3), t4._finID = n2.state; + var h = i.from(t4._finID); + return f(h), h; + }(this, r3, c2), this._prev = i.from(r3), this._cache = i.allocUnsafe(0), this._secCache = i.allocUnsafe(0), this._decrypt = a2, this._alen = 0, this._len = 0, this._mode = t3, this._authTag = null, this._called = false; + } + a(c, o), c.prototype._update = function(t3) { + if (!this._called && this._alen) { + var e3 = 16 - this._alen % 16; + e3 < 16 && (e3 = i.alloc(e3, 0), this._ghash.update(e3)); + } + this._called = true; + var r3 = this._mode.encrypt(this, t3); + return this._decrypt ? this._ghash.update(t3) : this._ghash.update(r3), this._len += t3.length, r3; + }, c.prototype._final = function() { + if (this._decrypt && !this._authTag) + throw new Error("Unsupported state or unable to authenticate data"); + var t3 = u(this._ghash.final(8 * this._alen, 8 * this._len), this._cipher.encryptBlock(this._finID)); + if (this._decrypt && function(t4, e3) { + var r3 = 0; + t4.length !== e3.length && r3++; + for (var n2 = Math.min(t4.length, e3.length), i2 = 0; i2 < n2; ++i2) + r3 += t4[i2] ^ e3[i2]; + return r3; + }(t3, this._authTag)) + throw new Error("Unsupported state or unable to authenticate data"); + this._authTag = t3, this._cipher.scrub(); + }, c.prototype.getAuthTag = function() { + if (this._decrypt || !i.isBuffer(this._authTag)) + throw new Error("Attempting to get auth tag in unsupported state"); + return this._authTag; + }, c.prototype.setAuthTag = function(t3) { + if (!this._decrypt) + throw new Error("Attempting to set auth tag in unsupported state"); + this._authTag = t3; + }, c.prototype.setAAD = function(t3) { + if (this._called) + throw new Error("Attempting to set AAD in unsupported state"); + this._ghash.update(t3), this._alen += t3.length; + }, t2.exports = c; + }, 4696: (t2, e2, r2) => { + var n = r2(1494), i = r2(6193), o = r2(5415); + e2.createCipher = e2.Cipher = n.createCipher, e2.createCipheriv = e2.Cipheriv = n.createCipheriv, e2.createDecipher = e2.Decipher = i.createDecipher, e2.createDecipheriv = e2.Decipheriv = i.createDecipheriv, e2.listCiphers = e2.getCiphers = function() { + return Object.keys(o); + }; + }, 6193: (t2, e2, r2) => { + var n = r2(2422), i = r2(9509).Buffer, o = r2(45), a = r2(5969), s = r2(1027), u = r2(4497), f = r2(3048); + function c(t3, e3, r3) { + s.call(this), this._cache = new h(), this._last = void 0, this._cipher = new u.AES(e3), this._prev = i.from(r3), this._mode = t3, this._autopadding = true; + } + function h() { + this.cache = i.allocUnsafe(0); + } + function l(t3, e3, r3) { + var s2 = o[t3.toLowerCase()]; + if (!s2) + throw new TypeError("invalid suite type"); + if (typeof r3 == "string" && (r3 = i.from(r3)), s2.mode !== "GCM" && r3.length !== s2.iv) + throw new TypeError("invalid iv length " + r3.length); + if (typeof e3 == "string" && (e3 = i.from(e3)), e3.length !== s2.key / 8) + throw new TypeError("invalid key length " + e3.length); + return s2.type === "stream" ? new a(s2.module, e3, r3, true) : s2.type === "auth" ? new n(s2.module, e3, r3, true) : new c(s2.module, e3, r3); + } + r2(5717)(c, s), c.prototype._update = function(t3) { + var e3, r3; + this._cache.add(t3); + for (var n2 = []; e3 = this._cache.get(this._autopadding); ) + r3 = this._mode.decrypt(this, e3), n2.push(r3); + return i.concat(n2); + }, c.prototype._final = function() { + var t3 = this._cache.flush(); + if (this._autopadding) + return function(t4) { + var e3 = t4[15]; + if (e3 < 1 || e3 > 16) + throw new Error("unable to decrypt data"); + for (var r3 = -1; ++r3 < e3; ) + if (t4[r3 + (16 - e3)] !== e3) + throw new Error("unable to decrypt data"); + if (e3 !== 16) + return t4.slice(0, 16 - e3); + }(this._mode.decrypt(this, t3)); + if (t3) + throw new Error("data not multiple of block length"); + }, c.prototype.setAutoPadding = function(t3) { + return this._autopadding = !!t3, this; + }, h.prototype.add = function(t3) { + this.cache = i.concat([this.cache, t3]); + }, h.prototype.get = function(t3) { + var e3; + if (t3) { + if (this.cache.length > 16) + return e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), e3; + } else if (this.cache.length >= 16) + return e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), e3; + return null; + }, h.prototype.flush = function() { + if (this.cache.length) + return this.cache; + }, e2.createDecipher = function(t3, e3) { + var r3 = o[t3.toLowerCase()]; + if (!r3) + throw new TypeError("invalid suite type"); + var n2 = f(e3, false, r3.key, r3.iv); + return l(t3, n2.key, n2.iv); + }, e2.createDecipheriv = l; + }, 1494: (t2, e2, r2) => { + var n = r2(45), i = r2(2422), o = r2(9509).Buffer, a = r2(5969), s = r2(1027), u = r2(4497), f = r2(3048); + function c(t3, e3, r3) { + s.call(this), this._cache = new l(), this._cipher = new u.AES(e3), this._prev = o.from(r3), this._mode = t3, this._autopadding = true; + } + r2(5717)(c, s), c.prototype._update = function(t3) { + var e3, r3; + this._cache.add(t3); + for (var n2 = []; e3 = this._cache.get(); ) + r3 = this._mode.encrypt(this, e3), n2.push(r3); + return o.concat(n2); + }; + var h = o.alloc(16, 16); + function l() { + this.cache = o.allocUnsafe(0); + } + function d(t3, e3, r3) { + var s2 = n[t3.toLowerCase()]; + if (!s2) + throw new TypeError("invalid suite type"); + if (typeof e3 == "string" && (e3 = o.from(e3)), e3.length !== s2.key / 8) + throw new TypeError("invalid key length " + e3.length); + if (typeof r3 == "string" && (r3 = o.from(r3)), s2.mode !== "GCM" && r3.length !== s2.iv) + throw new TypeError("invalid iv length " + r3.length); + return s2.type === "stream" ? new a(s2.module, e3, r3) : s2.type === "auth" ? new i(s2.module, e3, r3) : new c(s2.module, e3, r3); + } + c.prototype._final = function() { + var t3 = this._cache.flush(); + if (this._autopadding) + return t3 = this._mode.encrypt(this, t3), this._cipher.scrub(), t3; + if (!t3.equals(h)) + throw this._cipher.scrub(), new Error("data not multiple of block length"); + }, c.prototype.setAutoPadding = function(t3) { + return this._autopadding = !!t3, this; + }, l.prototype.add = function(t3) { + this.cache = o.concat([this.cache, t3]); + }, l.prototype.get = function() { + if (this.cache.length > 15) { + var t3 = this.cache.slice(0, 16); + return this.cache = this.cache.slice(16), t3; + } + return null; + }, l.prototype.flush = function() { + for (var t3 = 16 - this.cache.length, e3 = o.allocUnsafe(t3), r3 = -1; ++r3 < t3; ) + e3.writeUInt8(t3, r3); + return o.concat([this.cache, e3]); + }, e2.createCipheriv = d, e2.createCipher = function(t3, e3) { + var r3 = n[t3.toLowerCase()]; + if (!r3) + throw new TypeError("invalid suite type"); + var i2 = f(e3, false, r3.key, r3.iv); + return d(t3, i2.key, i2.iv); + }; + }, 3288: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = n.alloc(16, 0); + function o(t3) { + var e3 = n.allocUnsafe(16); + return e3.writeUInt32BE(t3[0] >>> 0, 0), e3.writeUInt32BE(t3[1] >>> 0, 4), e3.writeUInt32BE(t3[2] >>> 0, 8), e3.writeUInt32BE(t3[3] >>> 0, 12), e3; + } + function a(t3) { + this.h = t3, this.state = n.alloc(16, 0), this.cache = n.allocUnsafe(0); + } + a.prototype.ghash = function(t3) { + for (var e3 = -1; ++e3 < t3.length; ) + this.state[e3] ^= t3[e3]; + this._multiply(); + }, a.prototype._multiply = function() { + for (var t3, e3, r3, n2 = [(t3 = this.h).readUInt32BE(0), t3.readUInt32BE(4), t3.readUInt32BE(8), t3.readUInt32BE(12)], i2 = [0, 0, 0, 0], a2 = -1; ++a2 < 128; ) { + for ((this.state[~~(a2 / 8)] & 1 << 7 - a2 % 8) != 0 && (i2[0] ^= n2[0], i2[1] ^= n2[1], i2[2] ^= n2[2], i2[3] ^= n2[3]), r3 = (1 & n2[3]) != 0, e3 = 3; e3 > 0; e3--) + n2[e3] = n2[e3] >>> 1 | (1 & n2[e3 - 1]) << 31; + n2[0] = n2[0] >>> 1, r3 && (n2[0] = n2[0] ^ 225 << 24); + } + this.state = o(i2); + }, a.prototype.update = function(t3) { + var e3; + for (this.cache = n.concat([this.cache, t3]); this.cache.length >= 16; ) + e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), this.ghash(e3); + }, a.prototype.final = function(t3, e3) { + return this.cache.length && this.ghash(n.concat([this.cache, i], 16)), this.ghash(o([0, t3, 0, e3])), this.state; + }, t2.exports = a; + }, 685: (t2) => { + t2.exports = function(t3) { + for (var e2, r2 = t3.length; r2--; ) { + if ((e2 = t3.readUInt8(r2)) !== 255) { + e2++, t3.writeUInt8(e2, r2); + break; + } + t3.writeUInt8(0, r2); + } + }; + }, 5292: (t2, e2, r2) => { + var n = r2(7295); + e2.encrypt = function(t3, e3) { + var r3 = n(e3, t3._prev); + return t3._prev = t3._cipher.encryptBlock(r3), t3._prev; + }, e2.decrypt = function(t3, e3) { + var r3 = t3._prev; + t3._prev = e3; + var i = t3._cipher.decryptBlock(e3); + return n(i, r3); + }; + }, 6311: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(7295); + function o(t3, e3, r3) { + var o2 = e3.length, a = i(e3, t3._cache); + return t3._cache = t3._cache.slice(o2), t3._prev = n.concat([t3._prev, r3 ? e3 : a]), a; + } + e2.encrypt = function(t3, e3, r3) { + for (var i2, a = n.allocUnsafe(0); e3.length; ) { + if (t3._cache.length === 0 && (t3._cache = t3._cipher.encryptBlock(t3._prev), t3._prev = n.allocUnsafe(0)), !(t3._cache.length <= e3.length)) { + a = n.concat([a, o(t3, e3, r3)]); + break; + } + i2 = t3._cache.length, a = n.concat([a, o(t3, e3.slice(0, i2), r3)]), e3 = e3.slice(i2); + } + return a; + }; + }, 1510: (t2, e2, r2) => { + var n = r2(9509).Buffer; + function i(t3, e3, r3) { + for (var n2, i2, a = -1, s = 0; ++a < 8; ) + n2 = e3 & 1 << 7 - a ? 128 : 0, s += (128 & (i2 = t3._cipher.encryptBlock(t3._prev)[0] ^ n2)) >> a % 8, t3._prev = o(t3._prev, r3 ? n2 : i2); + return s; + } + function o(t3, e3) { + var r3 = t3.length, i2 = -1, o2 = n.allocUnsafe(t3.length); + for (t3 = n.concat([t3, n.from([e3])]); ++i2 < r3; ) + o2[i2] = t3[i2] << 1 | t3[i2 + 1] >> 7; + return o2; + } + e2.encrypt = function(t3, e3, r3) { + for (var o2 = e3.length, a = n.allocUnsafe(o2), s = -1; ++s < o2; ) + a[s] = i(t3, e3[s], r3); + return a; + }; + }, 1964: (t2, e2, r2) => { + var n = r2(9509).Buffer; + function i(t3, e3, r3) { + var i2 = t3._cipher.encryptBlock(t3._prev)[0] ^ e3; + return t3._prev = n.concat([t3._prev.slice(1), n.from([r3 ? e3 : i2])]), i2; + } + e2.encrypt = function(t3, e3, r3) { + for (var o = e3.length, a = n.allocUnsafe(o), s = -1; ++s < o; ) + a[s] = i(t3, e3[s], r3); + return a; + }; + }, 6009: (t2, e2, r2) => { + var n = r2(7295), i = r2(9509).Buffer, o = r2(685); + function a(t3) { + var e3 = t3._cipher.encryptBlockRaw(t3._prev); + return o(t3._prev), e3; + } + e2.encrypt = function(t3, e3) { + var r3 = Math.ceil(e3.length / 16), o2 = t3._cache.length; + t3._cache = i.concat([t3._cache, i.allocUnsafe(16 * r3)]); + for (var s = 0; s < r3; s++) { + var u = a(t3), f = o2 + 16 * s; + t3._cache.writeUInt32BE(u[0], f + 0), t3._cache.writeUInt32BE(u[1], f + 4), t3._cache.writeUInt32BE(u[2], f + 8), t3._cache.writeUInt32BE(u[3], f + 12); + } + var c = t3._cache.slice(0, e3.length); + return t3._cache = t3._cache.slice(e3.length), n(e3, c); + }; + }, 1084: (t2, e2) => { + e2.encrypt = function(t3, e3) { + return t3._cipher.encryptBlock(e3); + }, e2.decrypt = function(t3, e3) { + return t3._cipher.decryptBlock(e3); + }; + }, 45: (t2, e2, r2) => { + var n = {ECB: r2(1084), CBC: r2(5292), CFB: r2(6311), CFB8: r2(1964), CFB1: r2(1510), OFB: r2(8861), CTR: r2(6009), GCM: r2(6009)}, i = r2(5415); + for (var o in i) + i[o].module = n[i[o].mode]; + t2.exports = i; + }, 5415: (t2) => { + t2.exports = JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}'); + }, 8861: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(7295); + function o(t3) { + return t3._prev = t3._cipher.encryptBlock(t3._prev), t3._prev; + } + e2.encrypt = function(t3, e3) { + for (; t3._cache.length < e3.length; ) + t3._cache = n.concat([t3._cache, o(t3)]); + var r3 = t3._cache.slice(0, e3.length); + return t3._cache = t3._cache.slice(e3.length), i(e3, r3); + }; + }, 5969: (t2, e2, r2) => { + var n = r2(4497), i = r2(9509).Buffer, o = r2(1027); + function a(t3, e3, r3, a2) { + o.call(this), this._cipher = new n.AES(e3), this._prev = i.from(r3), this._cache = i.allocUnsafe(0), this._secCache = i.allocUnsafe(0), this._decrypt = a2, this._mode = t3; + } + r2(5717)(a, o), a.prototype._update = function(t3) { + return this._mode.encrypt(this, t3, this._decrypt); + }, a.prototype._final = function() { + this._cipher.scrub(); + }, t2.exports = a; + }, 3614: (t2, e2, r2) => { + var n = r2(7667), i = r2(4696), o = r2(45), a = r2(9715), s = r2(3048); + function u(t3, e3, r3) { + if (t3 = t3.toLowerCase(), o[t3]) + return i.createCipheriv(t3, e3, r3); + if (a[t3]) + return new n({key: e3, iv: r3, mode: t3}); + throw new TypeError("invalid suite type"); + } + function f(t3, e3, r3) { + if (t3 = t3.toLowerCase(), o[t3]) + return i.createDecipheriv(t3, e3, r3); + if (a[t3]) + return new n({key: e3, iv: r3, mode: t3, decrypt: true}); + throw new TypeError("invalid suite type"); + } + e2.createCipher = e2.Cipher = function(t3, e3) { + var r3, n2; + if (t3 = t3.toLowerCase(), o[t3]) + r3 = o[t3].key, n2 = o[t3].iv; + else { + if (!a[t3]) + throw new TypeError("invalid suite type"); + r3 = 8 * a[t3].key, n2 = a[t3].iv; + } + var i2 = s(e3, false, r3, n2); + return u(t3, i2.key, i2.iv); + }, e2.createCipheriv = e2.Cipheriv = u, e2.createDecipher = e2.Decipher = function(t3, e3) { + var r3, n2; + if (t3 = t3.toLowerCase(), o[t3]) + r3 = o[t3].key, n2 = o[t3].iv; + else { + if (!a[t3]) + throw new TypeError("invalid suite type"); + r3 = 8 * a[t3].key, n2 = a[t3].iv; + } + var i2 = s(e3, false, r3, n2); + return f(t3, i2.key, i2.iv); + }, e2.createDecipheriv = e2.Decipheriv = f, e2.listCiphers = e2.getCiphers = function() { + return Object.keys(a).concat(i.getCiphers()); + }; + }, 7667: (t2, e2, r2) => { + var n = r2(1027), i = r2(5251), o = r2(5717), a = r2(9509).Buffer, s = {"des-ede3-cbc": i.CBC.instantiate(i.EDE), "des-ede3": i.EDE, "des-ede-cbc": i.CBC.instantiate(i.EDE), "des-ede": i.EDE, "des-cbc": i.CBC.instantiate(i.DES), "des-ecb": i.DES}; + function u(t3) { + n.call(this); + var e3, r3 = t3.mode.toLowerCase(), i2 = s[r3]; + e3 = t3.decrypt ? "decrypt" : "encrypt"; + var o2 = t3.key; + a.isBuffer(o2) || (o2 = a.from(o2)), r3 !== "des-ede" && r3 !== "des-ede-cbc" || (o2 = a.concat([o2, o2.slice(0, 8)])); + var u2 = t3.iv; + a.isBuffer(u2) || (u2 = a.from(u2)), this._des = i2.create({key: o2, iv: u2, type: e3}); + } + s.des = s["des-cbc"], s.des3 = s["des-ede3-cbc"], t2.exports = u, o(u, n), u.prototype._update = function(t3) { + return a.from(this._des.update(t3)); + }, u.prototype._final = function() { + return a.from(this._des.final()); + }; + }, 9715: (t2, e2) => { + e2["des-ecb"] = {key: 8, iv: 0}, e2["des-cbc"] = e2.des = {key: 8, iv: 8}, e2["des-ede3-cbc"] = e2.des3 = {key: 24, iv: 8}, e2["des-ede3"] = {key: 24, iv: 0}, e2["des-ede-cbc"] = {key: 16, iv: 8}, e2["des-ede"] = {key: 16, iv: 0}; + }, 3663: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(3982), o = r2(1798); + function a(t3) { + var e3, r3 = t3.modulus.byteLength(); + do { + e3 = new i(o(r3)); + } while (e3.cmp(t3.modulus) >= 0 || !e3.umod(t3.prime1) || !e3.umod(t3.prime2)); + return e3; + } + function s(t3, e3) { + var r3 = function(t4) { + var e4 = a(t4); + return {blinder: e4.toRed(i.mont(t4.modulus)).redPow(new i(t4.publicExponent)).fromRed(), unblinder: e4.invm(t4.modulus)}; + }(e3), o2 = e3.modulus.byteLength(), s2 = new i(t3).mul(r3.blinder).umod(e3.modulus), u = s2.toRed(i.mont(e3.prime1)), f = s2.toRed(i.mont(e3.prime2)), c = e3.coefficient, h = e3.prime1, l = e3.prime2, d = u.redPow(e3.exponent1).fromRed(), p = f.redPow(e3.exponent2).fromRed(), y = d.isub(p).imul(c).umod(h).imul(l); + return p.iadd(y).imul(r3.unblinder).umod(e3.modulus).toArrayLike(n, "be", o2); + } + s.getr = a, t2.exports = s; + }, 3982: function(t2, e2, r2) { + !function(t3, e3) { + function n(t4, e4) { + if (!t4) + throw new Error(e4 || "Assertion failed"); + } + function i(t4, e4) { + t4.super_ = e4; + var r3 = function() { + }; + r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; + } + function o(t4, e4, r3) { + if (o.isBN(t4)) + return t4; + this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); + } + var a; + typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; + try { + a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(1922).Buffer; + } catch (t4) { + } + function s(t4, e4) { + var r3 = t4.charCodeAt(e4); + return r3 >= 48 && r3 <= 57 ? r3 - 48 : r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : void n(false, "Invalid character in " + t4); + } + function u(t4, e4, r3) { + var n2 = s(t4, r3); + return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; + } + function f(t4, e4, r3, i2) { + for (var o2 = 0, a2 = 0, s2 = Math.min(t4.length, r3), u2 = e4; u2 < s2; u2++) { + var f2 = t4.charCodeAt(u2) - 48; + o2 *= i2, a2 = f2 >= 49 ? f2 - 49 + 10 : f2 >= 17 ? f2 - 17 + 10 : f2, n(f2 >= 0 && a2 < i2, "Invalid character"), o2 += a2; + } + return o2; + } + function c(t4, e4) { + t4.words = e4.words, t4.length = e4.length, t4.negative = e4.negative, t4.red = e4.red; + } + if (o.isBN = function(t4) { + return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); + }, o.max = function(t4, e4) { + return t4.cmp(e4) > 0 ? t4 : e4; + }, o.min = function(t4, e4) { + return t4.cmp(e4) < 0 ? t4 : e4; + }, o.prototype._init = function(t4, e4, r3) { + if (typeof t4 == "number") + return this._initNumber(t4, e4, r3); + if (typeof t4 == "object") + return this._initArray(t4, e4, r3); + e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); + var i2 = 0; + (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); + }, o.prototype._initNumber = function(t4, e4, r3) { + t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); + }, o.prototype._initArray = function(t4, e4, r3) { + if (n(typeof t4.length == "number"), t4.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); + for (var i2 = 0; i2 < this.length; i2++) + this.words[i2] = 0; + var o2, a2, s2 = 0; + if (r3 === "be") + for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) + a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + else if (r3 === "le") + for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) + a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + return this._strip(); + }, o.prototype._parseHex = function(t4, e4, r3) { + this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); + for (var n2 = 0; n2 < this.length; n2++) + this.words[n2] = 0; + var i2, o2 = 0, a2 = 0; + if (r3 === "be") + for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + else + for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + this._strip(); + }, o.prototype._parseBase = function(t4, e4, r3) { + this.words = [0], this.length = 1; + for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) + n2++; + n2--, i2 = i2 / e4 | 0; + for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) + u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + if (a2 !== 0) { + var h2 = 1; + for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) + h2 *= e4; + this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + } + this._strip(); + }, o.prototype.copy = function(t4) { + t4.words = new Array(this.length); + for (var e4 = 0; e4 < this.length; e4++) + t4.words[e4] = this.words[e4]; + t4.length = this.length, t4.negative = this.negative, t4.red = this.red; + }, o.prototype._move = function(t4) { + c(t4, this); + }, o.prototype.clone = function() { + var t4 = new o(null); + return this.copy(t4), t4; + }, o.prototype._expand = function(t4) { + for (; this.length < t4; ) + this.words[this.length++] = 0; + return this; + }, o.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol != "undefined" && typeof Symbol.for == "function") + try { + o.prototype[Symbol.for("nodejs.util.inspect.custom")] = h; + } catch (t4) { + o.prototype.inspect = h; + } + else + o.prototype.inspect = h; + function h() { + return (this.red ? ""; + } + var l = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], d = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], p = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + function y(t4, e4, r3) { + r3.negative = e4.negative ^ t4.negative; + var n2 = t4.length + e4.length | 0; + r3.length = n2, n2 = n2 - 1 | 0; + var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; + r3.words[0] = s2; + for (var f2 = 1; f2 < n2; f2++) { + for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { + var p2 = f2 - d2 | 0; + c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; + } + r3.words[f2] = 0 | h2, u2 = 0 | c2; + } + return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3._strip(); + } + o.prototype.toString = function(t4, e4) { + var r3; + if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { + r3 = ""; + for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { + var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); + r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? l[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); + } + for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { + var f2 = d[t4], c2 = p[t4]; + r3 = ""; + var h2 = this.clone(); + for (h2.negative = 0; !h2.isZero(); ) { + var y2 = h2.modrn(c2).toString(t4); + r3 = (h2 = h2.idivn(c2)).isZero() ? y2 + r3 : l[f2 - y2.length] + y2 + r3; + } + for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + n(false, "Base should be between 2 and 36"); + }, o.prototype.toNumber = function() { + var t4 = this.words[0]; + return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; + }, o.prototype.toJSON = function() { + return this.toString(16, 2); + }, a && (o.prototype.toBuffer = function(t4, e4) { + return this.toArrayLike(a, t4, e4); + }), o.prototype.toArray = function(t4, e4) { + return this.toArrayLike(Array, t4, e4); + }, o.prototype.toArrayLike = function(t4, e4, r3) { + this._strip(); + var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); + n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"); + var a2 = function(t5, e5) { + return t5.allocUnsafe ? t5.allocUnsafe(e5) : new t5(e5); + }(t4, o2); + return this["_toArrayLike" + (e4 === "le" ? "LE" : "BE")](a2, i2), a2; + }, o.prototype._toArrayLikeLE = function(t4, e4) { + for (var r3 = 0, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { + var a2 = this.words[i2] << o2 | n2; + t4[r3++] = 255 & a2, r3 < t4.length && (t4[r3++] = a2 >> 8 & 255), r3 < t4.length && (t4[r3++] = a2 >> 16 & 255), o2 === 6 ? (r3 < t4.length && (t4[r3++] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); + } + if (r3 < t4.length) + for (t4[r3++] = n2; r3 < t4.length; ) + t4[r3++] = 0; + }, o.prototype._toArrayLikeBE = function(t4, e4) { + for (var r3 = t4.length - 1, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { + var a2 = this.words[i2] << o2 | n2; + t4[r3--] = 255 & a2, r3 >= 0 && (t4[r3--] = a2 >> 8 & 255), r3 >= 0 && (t4[r3--] = a2 >> 16 & 255), o2 === 6 ? (r3 >= 0 && (t4[r3--] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); + } + if (r3 >= 0) + for (t4[r3--] = n2; r3 >= 0; ) + t4[r3--] = 0; + }, Math.clz32 ? o.prototype._countBits = function(t4) { + return 32 - Math.clz32(t4); + } : o.prototype._countBits = function(t4) { + var e4 = t4, r3 = 0; + return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; + }, o.prototype._zeroBits = function(t4) { + if (t4 === 0) + return 26; + var e4 = t4, r3 = 0; + return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; + }, o.prototype.bitLength = function() { + var t4 = this.words[this.length - 1], e4 = this._countBits(t4); + return 26 * (this.length - 1) + e4; + }, o.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { + var r3 = this._zeroBits(this.words[e4]); + if (t4 += r3, r3 !== 26) + break; + } + return t4; + }, o.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o.prototype.toTwos = function(t4) { + return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); + }, o.prototype.fromTwos = function(t4) { + return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); + }, o.prototype.isNeg = function() { + return this.negative !== 0; + }, o.prototype.neg = function() { + return this.clone().ineg(); + }, o.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o.prototype.iuor = function(t4) { + for (; this.length < t4.length; ) + this.words[this.length++] = 0; + for (var e4 = 0; e4 < t4.length; e4++) + this.words[e4] = this.words[e4] | t4.words[e4]; + return this._strip(); + }, o.prototype.ior = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuor(t4); + }, o.prototype.or = function(t4) { + return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); + }, o.prototype.uor = function(t4) { + return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); + }, o.prototype.iuand = function(t4) { + var e4; + e4 = this.length > t4.length ? t4 : this; + for (var r3 = 0; r3 < e4.length; r3++) + this.words[r3] = this.words[r3] & t4.words[r3]; + return this.length = e4.length, this._strip(); + }, o.prototype.iand = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuand(t4); + }, o.prototype.and = function(t4) { + return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); + }, o.prototype.uand = function(t4) { + return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); + }, o.prototype.iuxor = function(t4) { + var e4, r3; + this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); + for (var n2 = 0; n2 < r3.length; n2++) + this.words[n2] = e4.words[n2] ^ r3.words[n2]; + if (this !== e4) + for (; n2 < e4.length; n2++) + this.words[n2] = e4.words[n2]; + return this.length = e4.length, this._strip(); + }, o.prototype.ixor = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuxor(t4); + }, o.prototype.xor = function(t4) { + return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); + }, o.prototype.uxor = function(t4) { + return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); + }, o.prototype.inotn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; + this._expand(e4), r3 > 0 && e4--; + for (var i2 = 0; i2 < e4; i2++) + this.words[i2] = 67108863 & ~this.words[i2]; + return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this._strip(); + }, o.prototype.notn = function(t4) { + return this.clone().inotn(t4); + }, o.prototype.setn = function(t4, e4) { + n(typeof t4 == "number" && t4 >= 0); + var r3 = t4 / 26 | 0, i2 = t4 % 26; + return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this._strip(); + }, o.prototype.iadd = function(t4) { + var e4, r3, n2; + if (this.negative !== 0 && t4.negative === 0) + return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && t4.negative !== 0) + return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); + this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) + e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + for (; i2 !== 0 && o2 < r3.length; o2++) + e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + if (this.length = r3.length, i2 !== 0) + this.words[this.length] = i2, this.length++; + else if (r3 !== this) + for (; o2 < r3.length; o2++) + this.words[o2] = r3.words[o2]; + return this; + }, o.prototype.add = function(t4) { + var e4; + return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); + }, o.prototype.isub = function(t4) { + if (t4.negative !== 0) { + t4.negative = 0; + var e4 = this.iadd(t4); + return t4.negative = 1, e4._normSign(); + } + if (this.negative !== 0) + return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); + var r3, n2, i2 = this.cmp(t4); + if (i2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + for (; o2 !== 0 && a2 < r3.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + if (o2 === 0 && a2 < r3.length && r3 !== this) + for (; a2 < r3.length; a2++) + this.words[a2] = r3.words[a2]; + return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this._strip(); + }, o.prototype.sub = function(t4) { + return this.clone().isub(t4); + }; + var m = function(t4, e4, r3) { + var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v = 0 | a2[3], w2 = 8191 & v, _2 = v >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A2 = 0 | a2[5], k2 = 8191 & A2, B2 = A2 >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; + r3.negative = t4.negative ^ e4.negative, r3.length = 19; + var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; + f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); + var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; + var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; + var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; + var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k2, z), i2 = (i2 = Math.imul(k2, q)) + Math.imul(B2, z) | 0, o2 = Math.imul(B2, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; + var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k2, F) | 0, i2 = (i2 = i2 + Math.imul(k2, V) | 0) + Math.imul(B2, F) | 0, o2 = o2 + Math.imul(B2, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; + var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k2, J) | 0, i2 = (i2 = i2 + Math.imul(k2, $) | 0) + Math.imul(B2, J) | 0, o2 = o2 + Math.imul(B2, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; + var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k2, Z) | 0, i2 = (i2 = i2 + Math.imul(k2, Y) | 0) + Math.imul(B2, Z) | 0, o2 = o2 + Math.imul(B2, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; + var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k2, Q) | 0, i2 = (i2 = i2 + Math.imul(k2, tt) | 0) + Math.imul(B2, Q) | 0, o2 = o2 + Math.imul(B2, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; + var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k2, rt) | 0, i2 = (i2 = i2 + Math.imul(k2, nt) | 0) + Math.imul(B2, rt) | 0, o2 = o2 + Math.imul(B2, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; + var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k2, ot) | 0, i2 = (i2 = i2 + Math.imul(k2, at) | 0) + Math.imul(B2, ot) | 0, o2 = o2 + Math.imul(B2, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; + var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k2, ut) | 0, i2 = (i2 = i2 + Math.imul(k2, ft) | 0) + Math.imul(B2, ut) | 0, o2 = o2 + Math.imul(B2, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; + var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k2, ht) | 0, i2 = (i2 = i2 + Math.imul(k2, lt) | 0) + Math.imul(B2, ht) | 0, o2 = o2 + Math.imul(B2, lt) | 0; + var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; + var Ot = (f2 + (n2 = n2 + Math.imul(k2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k2, yt) | 0) + Math.imul(B2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(B2, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; + var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; + var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); + var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; + var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; + return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; + }; + function b(t4, e4, r3) { + r3.negative = e4.negative ^ t4.negative, r3.length = t4.length + e4.length; + for (var n2 = 0, i2 = 0, o2 = 0; o2 < r3.length - 1; o2++) { + var a2 = i2; + i2 = 0; + for (var s2 = 67108863 & n2, u2 = Math.min(o2, e4.length - 1), f2 = Math.max(0, o2 - t4.length + 1); f2 <= u2; f2++) { + var c2 = o2 - f2, h2 = (0 | t4.words[c2]) * (0 | e4.words[f2]), l2 = 67108863 & h2; + s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; + } + r3.words[o2] = s2, n2 = a2, a2 = i2; + } + return n2 !== 0 ? r3.words[o2] = n2 : r3.length--, r3._strip(); + } + function g(t4, e4, r3) { + return b(t4, e4, r3); + } + Math.imul || (m = y), o.prototype.mulTo = function(t4, e4) { + var r3 = this.length + t4.length; + return this.length === 10 && t4.length === 10 ? m(this, t4, e4) : r3 < 63 ? y(this, t4, e4) : r3 < 1024 ? b(this, t4, e4) : g(this, t4, e4); + }, o.prototype.mul = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); + }, o.prototype.mulf = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), g(this, t4, e4); + }, o.prototype.imul = function(t4) { + return this.clone().mulTo(t4, this); + }, o.prototype.imuln = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(typeof t4 == "number"), n(t4 < 67108864); + for (var r3 = 0, i2 = 0; i2 < this.length; i2++) { + var o2 = (0 | this.words[i2]) * t4, a2 = (67108863 & o2) + (67108863 & r3); + r3 >>= 26, r3 += o2 / 67108864 | 0, r3 += a2 >>> 26, this.words[i2] = 67108863 & a2; + } + return r3 !== 0 && (this.words[i2] = r3, this.length++), e4 ? this.ineg() : this; + }, o.prototype.muln = function(t4) { + return this.clone().imuln(t4); + }, o.prototype.sqr = function() { + return this.mul(this); + }, o.prototype.isqr = function() { + return this.imul(this.clone()); + }, o.prototype.pow = function(t4) { + var e4 = function(t5) { + for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { + var n3 = r4 / 26 | 0, i3 = r4 % 26; + e5[r4] = t5.words[n3] >>> i3 & 1; + } + return e5; + }(t4); + if (e4.length === 0) + return new o(1); + for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) + ; + if (++n2 < e4.length) + for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) + e4[n2] !== 0 && (r3 = r3.mul(i2)); + return r3; + }, o.prototype.iushln = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; + if (r3 !== 0) { + var a2 = 0; + for (e4 = 0; e4 < this.length; e4++) { + var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; + this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; + } + a2 && (this.words[e4] = a2, this.length++); + } + if (i2 !== 0) { + for (e4 = this.length - 1; e4 >= 0; e4--) + this.words[e4 + i2] = this.words[e4]; + for (e4 = 0; e4 < i2; e4++) + this.words[e4] = 0; + this.length += i2; + } + return this._strip(); + }, o.prototype.ishln = function(t4) { + return n(this.negative === 0), this.iushln(t4); + }, o.prototype.iushrn = function(t4, e4, r3) { + var i2; + n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; + var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; + if (i2 -= a2, i2 = Math.max(0, i2), u2) { + for (var f2 = 0; f2 < a2; f2++) + u2.words[f2] = this.words[f2]; + u2.length = a2; + } + if (a2 === 0) + ; + else if (this.length > a2) + for (this.length -= a2, f2 = 0; f2 < this.length; f2++) + this.words[f2] = this.words[f2 + a2]; + else + this.words[0] = 0, this.length = 1; + var c2 = 0; + for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { + var h2 = 0 | this.words[f2]; + this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; + } + return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o.prototype.ishrn = function(t4, e4, r3) { + return n(this.negative === 0), this.iushrn(t4, e4, r3); + }, o.prototype.shln = function(t4) { + return this.clone().ishln(t4); + }, o.prototype.ushln = function(t4) { + return this.clone().iushln(t4); + }, o.prototype.shrn = function(t4) { + return this.clone().ishrn(t4); + }, o.prototype.ushrn = function(t4) { + return this.clone().iushrn(t4); + }, o.prototype.testn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + return !(this.length <= r3 || !(this.words[r3] & i2)); + }, o.prototype.imaskn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26; + if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) + return this; + if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { + var i2 = 67108863 ^ 67108863 >>> e4 << e4; + this.words[this.length - 1] &= i2; + } + return this._strip(); + }, o.prototype.maskn = function(t4) { + return this.clone().imaskn(t4); + }, o.prototype.iaddn = function(t4) { + return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) <= t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); + }, o.prototype._iaddn = function(t4) { + this.words[0] += t4; + for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) + this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; + return this.length = Math.max(this.length, e4 + 1), this; + }, o.prototype.isubn = function(t4) { + if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) + return this.iaddn(-t4); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(t4), this.negative = 1, this; + if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) + this.words[e4] += 67108864, this.words[e4 + 1] -= 1; + return this._strip(); + }, o.prototype.addn = function(t4) { + return this.clone().iaddn(t4); + }, o.prototype.subn = function(t4) { + return this.clone().isubn(t4); + }, o.prototype.iabs = function() { + return this.negative = 0, this; + }, o.prototype.abs = function() { + return this.clone().iabs(); + }, o.prototype._ishlnsubmul = function(t4, e4, r3) { + var i2, o2, a2 = t4.length + r3; + this._expand(a2); + var s2 = 0; + for (i2 = 0; i2 < t4.length; i2++) { + o2 = (0 | this.words[i2 + r3]) + s2; + var u2 = (0 | t4.words[i2]) * e4; + s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; + } + for (; i2 < this.length - r3; i2++) + s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; + if (s2 === 0) + return this._strip(); + for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) + s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; + return this.negative = 1, this._strip(); + }, o.prototype._wordDiv = function(t4, e4) { + var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; + (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); + var s2, u2 = n2.length - i2.length; + if (e4 !== "mod") { + (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); + for (var f2 = 0; f2 < s2.length; f2++) + s2.words[f2] = 0; + } + var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); + c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); + for (var h2 = u2 - 1; h2 >= 0; h2--) { + var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); + for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) + l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); + s2 && (s2.words[h2] = l2); + } + return s2 && s2._strip(), n2._strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; + }, o.prototype.divmod = function(t4, e4, r3) { + return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modrn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modrn(t4.words[0]))} : this._wordDiv(t4, e4); + var i2, a2, s2; + }, o.prototype.div = function(t4) { + return this.divmod(t4, "div", false).div; + }, o.prototype.mod = function(t4) { + return this.divmod(t4, "mod", false).mod; + }, o.prototype.umod = function(t4) { + return this.divmod(t4, "mod", true).mod; + }, o.prototype.divRound = function(t4) { + var e4 = this.divmod(t4); + if (e4.mod.isZero()) + return e4.div; + var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); + return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); + }, o.prototype.modrn = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(t4 <= 67108863); + for (var r3 = (1 << 26) % t4, i2 = 0, o2 = this.length - 1; o2 >= 0; o2--) + i2 = (r3 * i2 + (0 | this.words[o2])) % t4; + return e4 ? -i2 : i2; + }, o.prototype.modn = function(t4) { + return this.modrn(t4); + }, o.prototype.idivn = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(t4 <= 67108863); + for (var r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) { + var o2 = (0 | this.words[i2]) + 67108864 * r3; + this.words[i2] = o2 / t4 | 0, r3 = o2 % t4; + } + return this._strip(), e4 ? this.ineg() : this; + }, o.prototype.divn = function(t4) { + return this.clone().idivn(t4); + }, o.prototype.egcd = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) + e4.iushrn(1), r3.iushrn(1), ++f2; + for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { + for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) + ; + if (l2 > 0) + for (e4.iushrn(l2); l2-- > 0; ) + (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); + for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) + ; + if (p2 > 0) + for (r3.iushrn(p2); p2-- > 0; ) + (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); + } + return {a: s2, b: u2, gcd: r3.iushln(f2)}; + }, o.prototype._invmp = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { + for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) + ; + if (f2 > 0) + for (e4.iushrn(f2); f2-- > 0; ) + a2.isOdd() && a2.iadd(u2), a2.iushrn(1); + for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) + ; + if (h2 > 0) + for (r3.iushrn(h2); h2-- > 0; ) + s2.isOdd() && s2.iadd(u2), s2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); + } + return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; + }, o.prototype.gcd = function(t4) { + if (this.isZero()) + return t4.abs(); + if (t4.isZero()) + return this.abs(); + var e4 = this.clone(), r3 = t4.clone(); + e4.negative = 0, r3.negative = 0; + for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) + e4.iushrn(1), r3.iushrn(1); + for (; ; ) { + for (; e4.isEven(); ) + e4.iushrn(1); + for (; r3.isEven(); ) + r3.iushrn(1); + var i2 = e4.cmp(r3); + if (i2 < 0) { + var o2 = e4; + e4 = r3, r3 = o2; + } else if (i2 === 0 || r3.cmpn(1) === 0) + break; + e4.isub(r3); + } + return r3.iushln(n2); + }, o.prototype.invm = function(t4) { + return this.egcd(t4).a.umod(t4); + }, o.prototype.isEven = function() { + return (1 & this.words[0]) == 0; + }, o.prototype.isOdd = function() { + return (1 & this.words[0]) == 1; + }, o.prototype.andln = function(t4) { + return this.words[0] & t4; + }, o.prototype.bincn = function(t4) { + n(typeof t4 == "number"); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + if (this.length <= r3) + return this._expand(r3 + 1), this.words[r3] |= i2, this; + for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { + var s2 = 0 | this.words[a2]; + o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; + } + return o2 !== 0 && (this.words[a2] = o2, this.length++), this; + }, o.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o.prototype.cmpn = function(t4) { + var e4, r3 = t4 < 0; + if (this.negative !== 0 && !r3) + return -1; + if (this.negative === 0 && r3) + return 1; + if (this._strip(), this.length > 1) + e4 = 1; + else { + r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); + var i2 = 0 | this.words[0]; + e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; + } + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.cmp = function(t4) { + if (this.negative !== 0 && t4.negative === 0) + return -1; + if (this.negative === 0 && t4.negative !== 0) + return 1; + var e4 = this.ucmp(t4); + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.ucmp = function(t4) { + if (this.length > t4.length) + return 1; + if (this.length < t4.length) + return -1; + for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { + var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; + if (n2 !== i2) { + n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); + break; + } + } + return e4; + }, o.prototype.gtn = function(t4) { + return this.cmpn(t4) === 1; + }, o.prototype.gt = function(t4) { + return this.cmp(t4) === 1; + }, o.prototype.gten = function(t4) { + return this.cmpn(t4) >= 0; + }, o.prototype.gte = function(t4) { + return this.cmp(t4) >= 0; + }, o.prototype.ltn = function(t4) { + return this.cmpn(t4) === -1; + }, o.prototype.lt = function(t4) { + return this.cmp(t4) === -1; + }, o.prototype.lten = function(t4) { + return this.cmpn(t4) <= 0; + }, o.prototype.lte = function(t4) { + return this.cmp(t4) <= 0; + }, o.prototype.eqn = function(t4) { + return this.cmpn(t4) === 0; + }, o.prototype.eq = function(t4) { + return this.cmp(t4) === 0; + }, o.red = function(t4) { + return new k(t4); + }, o.prototype.toRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); + }, o.prototype.fromRed = function() { + return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o.prototype._forceRed = function(t4) { + return this.red = t4, this; + }, o.prototype.forceRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); + }, o.prototype.redAdd = function(t4) { + return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); + }, o.prototype.redIAdd = function(t4) { + return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); + }, o.prototype.redSub = function(t4) { + return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); + }, o.prototype.redISub = function(t4) { + return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); + }, o.prototype.redShl = function(t4) { + return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); + }, o.prototype.redMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); + }, o.prototype.redIMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); + }, o.prototype.redSqr = function() { + return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o.prototype.redISqr = function() { + return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o.prototype.redSqrt = function() { + return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o.prototype.redInvm = function() { + return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o.prototype.redNeg = function() { + return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o.prototype.redPow = function(t4) { + return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); + }; + var w = {k256: null, p224: null, p192: null, p25519: null}; + function _(t4, e4) { + this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + function M() { + _.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + function S() { + _.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + function E() { + _.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + function A() { + _.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + function k(t4) { + if (typeof t4 == "string") { + var e4 = o._prime(t4); + this.m = e4.p, this.prime = e4; + } else + n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; + } + function B(t4) { + k.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); + } + _.prototype._tmp = function() { + var t4 = new o(null); + return t4.words = new Array(Math.ceil(this.n / 13)), t4; + }, _.prototype.ireduce = function(t4) { + var e4, r3 = t4; + do { + this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); + } while (e4 > this.n); + var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); + return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; + }, _.prototype.split = function(t4, e4) { + t4.iushrn(this.n, 0, e4); + }, _.prototype.imulK = function(t4) { + return t4.imul(this.k); + }, i(M, _), M.prototype.split = function(t4, e4) { + for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) + e4.words[i2] = t4.words[i2]; + if (e4.length = n2, t4.length <= 9) + return t4.words[0] = 0, void (t4.length = 1); + var o2 = t4.words[9]; + for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { + var a2 = 0 | t4.words[i2]; + t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; + } + o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; + }, M.prototype.imulK = function(t4) { + t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 0 | t4.words[r3]; + e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); + } + return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; + }, i(S, _), i(E, _), i(A, _), A.prototype.imulK = function(t4) { + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; + n2 >>>= 26, t4.words[r3] = i2, e4 = n2; + } + return e4 !== 0 && (t4.words[t4.length++] = e4), t4; + }, o._prime = function(t4) { + if (w[t4]) + return w[t4]; + var e4; + if (t4 === "k256") + e4 = new M(); + else if (t4 === "p224") + e4 = new S(); + else if (t4 === "p192") + e4 = new E(); + else { + if (t4 !== "p25519") + throw new Error("Unknown prime " + t4); + e4 = new A(); + } + return w[t4] = e4, e4; + }, k.prototype._verify1 = function(t4) { + n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); + }, k.prototype._verify2 = function(t4, e4) { + n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); + }, k.prototype.imod = function(t4) { + return this.prime ? this.prime.ireduce(t4)._forceRed(this) : (c(t4, t4.umod(this.m)._forceRed(this)), t4); + }, k.prototype.neg = function(t4) { + return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); + }, k.prototype.add = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.add(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); + }, k.prototype.iadd = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.iadd(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; + }, k.prototype.sub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.sub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); + }, k.prototype.isub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.isub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; + }, k.prototype.shl = function(t4, e4) { + return this._verify1(t4), this.imod(t4.ushln(e4)); + }, k.prototype.imul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.imul(e4)); + }, k.prototype.mul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.mul(e4)); + }, k.prototype.isqr = function(t4) { + return this.imul(t4, t4.clone()); + }, k.prototype.sqr = function(t4) { + return this.mul(t4, t4); + }, k.prototype.sqrt = function(t4) { + if (t4.isZero()) + return t4.clone(); + var e4 = this.m.andln(3); + if (n(e4 % 2 == 1), e4 === 3) { + var r3 = this.m.add(new o(1)).iushrn(2); + return this.pow(t4, r3); + } + for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) + a2++, i2.iushrn(1); + n(!i2.isZero()); + var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); + for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) + c2.redIAdd(u2); + for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { + for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) + y2 = y2.redSqr(); + n(m2 < p2); + var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); + l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; + } + return l2; + }, k.prototype.invm = function(t4) { + var e4 = t4._invmp(this.m); + return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); + }, k.prototype.pow = function(t4, e4) { + if (e4.isZero()) + return new o(1).toRed(this); + if (e4.cmpn(1) === 0) + return t4.clone(); + var r3 = new Array(16); + r3[0] = new o(1).toRed(this), r3[1] = t4; + for (var n2 = 2; n2 < r3.length; n2++) + r3[n2] = this.mul(r3[n2 - 1], t4); + var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; + for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { + for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { + var h2 = f2 >> c2 & 1; + i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; + } + u2 = 26; + } + return i2; + }, k.prototype.convertTo = function(t4) { + var e4 = t4.umod(this.m); + return e4 === t4 ? e4.clone() : e4; + }, k.prototype.convertFrom = function(t4) { + var e4 = t4.clone(); + return e4.red = null, e4; + }, o.mont = function(t4) { + return new B(t4); + }, i(B, k), B.prototype.convertTo = function(t4) { + return this.imod(t4.ushln(this.shift)); + }, B.prototype.convertFrom = function(t4) { + var e4 = this.imod(t4.mul(this.rinv)); + return e4.red = null, e4; + }, B.prototype.imul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return t4.words[0] = 0, t4.length = 1, t4; + var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; + return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); + }, B.prototype.mul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return new o(0)._forceRed(this); + var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; + return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); + }, B.prototype.invm = function(t4) { + return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); + }; + }(t2 = r2.nmd(t2), this); + }, 6042: (t2, e2, r2) => { + t2.exports = r2(2063); + }, 2063: (t2) => { + t2.exports = JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}'); + }, 2236: (t2) => { + t2.exports = JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}'); + }, 4743: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(3482), o = r2(8473), a = r2(5717), s = r2(2957), u = r2(7753), f = r2(2063); + function c(t3) { + o.Writable.call(this); + var e3 = f[t3]; + if (!e3) + throw new Error("Unknown message digest"); + this._hashType = e3.hash, this._hash = i(e3.hash), this._tag = e3.id, this._signType = e3.sign; + } + function h(t3) { + o.Writable.call(this); + var e3 = f[t3]; + if (!e3) + throw new Error("Unknown message digest"); + this._hash = i(e3.hash), this._tag = e3.id, this._signType = e3.sign; + } + function l(t3) { + return new c(t3); + } + function d(t3) { + return new h(t3); + } + Object.keys(f).forEach(function(t3) { + f[t3].id = n.from(f[t3].id, "hex"), f[t3.toLowerCase()] = f[t3]; + }), a(c, o.Writable), c.prototype._write = function(t3, e3, r3) { + this._hash.update(t3), r3(); + }, c.prototype.update = function(t3, e3) { + return typeof t3 == "string" && (t3 = n.from(t3, e3)), this._hash.update(t3), this; + }, c.prototype.sign = function(t3, e3) { + this.end(); + var r3 = this._hash.digest(), n2 = s(r3, t3, this._hashType, this._signType, this._tag); + return e3 ? n2.toString(e3) : n2; + }, a(h, o.Writable), h.prototype._write = function(t3, e3, r3) { + this._hash.update(t3), r3(); + }, h.prototype.update = function(t3, e3) { + return typeof t3 == "string" && (t3 = n.from(t3, e3)), this._hash.update(t3), this; + }, h.prototype.verify = function(t3, e3, r3) { + typeof e3 == "string" && (e3 = n.from(e3, r3)), this.end(); + var i2 = this._hash.digest(); + return u(e3, i2, t3, this._signType, this._tag); + }, t2.exports = {Sign: l, Verify: d, createSign: l, createVerify: d}; + }, 2957: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(8355), o = r2(3663), a = r2(6266).ec, s = r2(8815), u = r2(980), f = r2(2236); + function c(t3, e3, r3, o2) { + if ((t3 = n.from(t3.toArray())).length < e3.byteLength()) { + var a2 = n.alloc(e3.byteLength() - t3.length); + t3 = n.concat([a2, t3]); + } + var s2 = r3.length, u2 = function(t4, e4) { + t4 = (t4 = h(t4, e4)).mod(e4); + var r4 = n.from(t4.toArray()); + if (r4.length < e4.byteLength()) { + var i2 = n.alloc(e4.byteLength() - r4.length); + r4 = n.concat([i2, r4]); + } + return r4; + }(r3, e3), f2 = n.alloc(s2); + f2.fill(1); + var c2 = n.alloc(s2); + return c2 = i(o2, c2).update(f2).update(n.from([0])).update(t3).update(u2).digest(), f2 = i(o2, c2).update(f2).digest(), {k: c2 = i(o2, c2).update(f2).update(n.from([1])).update(t3).update(u2).digest(), v: f2 = i(o2, c2).update(f2).digest()}; + } + function h(t3, e3) { + var r3 = new s(t3), n2 = (t3.length << 3) - e3.bitLength(); + return n2 > 0 && r3.ishrn(n2), r3; + } + function l(t3, e3, r3) { + var o2, a2; + do { + for (o2 = n.alloc(0); 8 * o2.length < t3.bitLength(); ) + e3.v = i(r3, e3.k).update(e3.v).digest(), o2 = n.concat([o2, e3.v]); + a2 = h(o2, t3), e3.k = i(r3, e3.k).update(e3.v).update(n.from([0])).digest(), e3.v = i(r3, e3.k).update(e3.v).digest(); + } while (a2.cmp(t3) !== -1); + return a2; + } + function d(t3, e3, r3, n2) { + return t3.toRed(s.mont(r3)).redPow(e3).fromRed().mod(n2); + } + t2.exports = function(t3, e3, r3, i2, p) { + var y = u(e3); + if (y.curve) { + if (i2 !== "ecdsa" && i2 !== "ecdsa/rsa") + throw new Error("wrong private key type"); + return function(t4, e4) { + var r4 = f[e4.curve.join(".")]; + if (!r4) + throw new Error("unknown curve " + e4.curve.join(".")); + var i3 = new a(r4).keyFromPrivate(e4.privateKey).sign(t4); + return n.from(i3.toDER()); + }(t3, y); + } + if (y.type === "dsa") { + if (i2 !== "dsa") + throw new Error("wrong private key type"); + return function(t4, e4, r4) { + for (var i3, o2 = e4.params.priv_key, a2 = e4.params.p, u2 = e4.params.q, f2 = e4.params.g, p2 = new s(0), y2 = h(t4, u2).mod(u2), m2 = false, b2 = c(o2, u2, t4, r4); m2 === false; ) + p2 = d(f2, i3 = l(u2, b2, r4), a2, u2), (m2 = i3.invm(u2).imul(y2.add(o2.mul(p2))).mod(u2)).cmpn(0) === 0 && (m2 = false, p2 = new s(0)); + return function(t5, e5) { + t5 = t5.toArray(), e5 = e5.toArray(), 128 & t5[0] && (t5 = [0].concat(t5)), 128 & e5[0] && (e5 = [0].concat(e5)); + var r5 = [48, t5.length + e5.length + 4, 2, t5.length]; + return r5 = r5.concat(t5, [2, e5.length], e5), n.from(r5); + }(p2, m2); + }(t3, y, r3); + } + if (i2 !== "rsa" && i2 !== "ecdsa/rsa") + throw new Error("wrong private key type"); + t3 = n.concat([p, t3]); + for (var m = y.modulus.byteLength(), b = [0, 1]; t3.length + b.length + 1 < m; ) + b.push(255); + b.push(0); + for (var g = -1; ++g < t3.length; ) + b.push(t3[g]); + return o(b, y); + }, t2.exports.getKey = c, t2.exports.makeKey = l; + }, 7753: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(8815), o = r2(6266).ec, a = r2(980), s = r2(2236); + function u(t3, e3) { + if (t3.cmpn(0) <= 0) + throw new Error("invalid sig"); + if (t3.cmp(e3) >= e3) + throw new Error("invalid sig"); + } + t2.exports = function(t3, e3, r3, f, c) { + var h = a(r3); + if (h.type === "ec") { + if (f !== "ecdsa" && f !== "ecdsa/rsa") + throw new Error("wrong public key type"); + return function(t4, e4, r4) { + var n2 = s[r4.data.algorithm.curve.join(".")]; + if (!n2) + throw new Error("unknown curve " + r4.data.algorithm.curve.join(".")); + var i2 = new o(n2), a2 = r4.data.subjectPrivateKey.data; + return i2.verify(e4, t4, a2); + }(t3, e3, h); + } + if (h.type === "dsa") { + if (f !== "dsa") + throw new Error("wrong public key type"); + return function(t4, e4, r4) { + var n2 = r4.data.p, o2 = r4.data.q, s2 = r4.data.g, f2 = r4.data.pub_key, c2 = a.signature.decode(t4, "der"), h2 = c2.s, l2 = c2.r; + u(h2, o2), u(l2, o2); + var d2 = i.mont(n2), p2 = h2.invm(o2); + return s2.toRed(d2).redPow(new i(e4).mul(p2).mod(o2)).fromRed().mul(f2.toRed(d2).redPow(l2.mul(p2).mod(o2)).fromRed()).mod(n2).mod(o2).cmp(l2) === 0; + }(t3, e3, h); + } + if (f !== "rsa" && f !== "ecdsa/rsa") + throw new Error("wrong public key type"); + e3 = n.concat([c, e3]); + for (var l = h.modulus.byteLength(), d = [1], p = 0; e3.length + d.length + 2 < l; ) + d.push(255), p++; + d.push(0); + for (var y = -1; ++y < e3.length; ) + d.push(e3[y]); + d = n.from(d); + var m = i.mont(h.modulus); + t3 = (t3 = new i(t3).toRed(m)).redPow(new i(h.publicExponent)), t3 = n.from(t3.fromRed().toArray()); + var b = p < 8 ? 1 : 0; + for (l = Math.min(t3.length, d.length), t3.length !== d.length && (b = 1), y = -1; ++y < l; ) + b |= t3[y] ^ d[y]; + return b === 0; + }; + }, 8815: function(t2, e2, r2) { + !function(t3, e3) { + function n(t4, e4) { + if (!t4) + throw new Error(e4 || "Assertion failed"); + } + function i(t4, e4) { + t4.super_ = e4; + var r3 = function() { + }; + r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; + } + function o(t4, e4, r3) { + if (o.isBN(t4)) + return t4; + this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); + } + var a; + typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; + try { + a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(2363).Buffer; + } catch (t4) { + } + function s(t4, e4) { + var r3 = t4.charCodeAt(e4); + return r3 >= 48 && r3 <= 57 ? r3 - 48 : r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : void n(false, "Invalid character in " + t4); + } + function u(t4, e4, r3) { + var n2 = s(t4, r3); + return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; + } + function f(t4, e4, r3, i2) { + for (var o2 = 0, a2 = 0, s2 = Math.min(t4.length, r3), u2 = e4; u2 < s2; u2++) { + var f2 = t4.charCodeAt(u2) - 48; + o2 *= i2, a2 = f2 >= 49 ? f2 - 49 + 10 : f2 >= 17 ? f2 - 17 + 10 : f2, n(f2 >= 0 && a2 < i2, "Invalid character"), o2 += a2; + } + return o2; + } + function c(t4, e4) { + t4.words = e4.words, t4.length = e4.length, t4.negative = e4.negative, t4.red = e4.red; + } + if (o.isBN = function(t4) { + return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); + }, o.max = function(t4, e4) { + return t4.cmp(e4) > 0 ? t4 : e4; + }, o.min = function(t4, e4) { + return t4.cmp(e4) < 0 ? t4 : e4; + }, o.prototype._init = function(t4, e4, r3) { + if (typeof t4 == "number") + return this._initNumber(t4, e4, r3); + if (typeof t4 == "object") + return this._initArray(t4, e4, r3); + e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); + var i2 = 0; + (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); + }, o.prototype._initNumber = function(t4, e4, r3) { + t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); + }, o.prototype._initArray = function(t4, e4, r3) { + if (n(typeof t4.length == "number"), t4.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); + for (var i2 = 0; i2 < this.length; i2++) + this.words[i2] = 0; + var o2, a2, s2 = 0; + if (r3 === "be") + for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) + a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + else if (r3 === "le") + for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) + a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); + return this._strip(); + }, o.prototype._parseHex = function(t4, e4, r3) { + this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); + for (var n2 = 0; n2 < this.length; n2++) + this.words[n2] = 0; + var i2, o2 = 0, a2 = 0; + if (r3 === "be") + for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + else + for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) + i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; + this._strip(); + }, o.prototype._parseBase = function(t4, e4, r3) { + this.words = [0], this.length = 1; + for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) + n2++; + n2--, i2 = i2 / e4 | 0; + for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) + u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + if (a2 !== 0) { + var h2 = 1; + for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) + h2 *= e4; + this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); + } + this._strip(); + }, o.prototype.copy = function(t4) { + t4.words = new Array(this.length); + for (var e4 = 0; e4 < this.length; e4++) + t4.words[e4] = this.words[e4]; + t4.length = this.length, t4.negative = this.negative, t4.red = this.red; + }, o.prototype._move = function(t4) { + c(t4, this); + }, o.prototype.clone = function() { + var t4 = new o(null); + return this.copy(t4), t4; + }, o.prototype._expand = function(t4) { + for (; this.length < t4; ) + this.words[this.length++] = 0; + return this; + }, o.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol != "undefined" && typeof Symbol.for == "function") + try { + o.prototype[Symbol.for("nodejs.util.inspect.custom")] = h; + } catch (t4) { + o.prototype.inspect = h; + } + else + o.prototype.inspect = h; + function h() { + return (this.red ? ""; + } + var l = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], d = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], p = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + function y(t4, e4, r3) { + r3.negative = e4.negative ^ t4.negative; + var n2 = t4.length + e4.length | 0; + r3.length = n2, n2 = n2 - 1 | 0; + var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; + r3.words[0] = s2; + for (var f2 = 1; f2 < n2; f2++) { + for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { + var p2 = f2 - d2 | 0; + c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; + } + r3.words[f2] = 0 | h2, u2 = 0 | c2; + } + return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3._strip(); + } + o.prototype.toString = function(t4, e4) { + var r3; + if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { + r3 = ""; + for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { + var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); + r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? l[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); + } + for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { + var f2 = d[t4], c2 = p[t4]; + r3 = ""; + var h2 = this.clone(); + for (h2.negative = 0; !h2.isZero(); ) { + var y2 = h2.modrn(c2).toString(t4); + r3 = (h2 = h2.idivn(c2)).isZero() ? y2 + r3 : l[f2 - y2.length] + y2 + r3; + } + for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) + r3 = "0" + r3; + return this.negative !== 0 && (r3 = "-" + r3), r3; + } + n(false, "Base should be between 2 and 36"); + }, o.prototype.toNumber = function() { + var t4 = this.words[0]; + return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; + }, o.prototype.toJSON = function() { + return this.toString(16, 2); + }, a && (o.prototype.toBuffer = function(t4, e4) { + return this.toArrayLike(a, t4, e4); + }), o.prototype.toArray = function(t4, e4) { + return this.toArrayLike(Array, t4, e4); + }, o.prototype.toArrayLike = function(t4, e4, r3) { + this._strip(); + var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); + n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"); + var a2 = function(t5, e5) { + return t5.allocUnsafe ? t5.allocUnsafe(e5) : new t5(e5); + }(t4, o2); + return this["_toArrayLike" + (e4 === "le" ? "LE" : "BE")](a2, i2), a2; + }, o.prototype._toArrayLikeLE = function(t4, e4) { + for (var r3 = 0, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { + var a2 = this.words[i2] << o2 | n2; + t4[r3++] = 255 & a2, r3 < t4.length && (t4[r3++] = a2 >> 8 & 255), r3 < t4.length && (t4[r3++] = a2 >> 16 & 255), o2 === 6 ? (r3 < t4.length && (t4[r3++] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); + } + if (r3 < t4.length) + for (t4[r3++] = n2; r3 < t4.length; ) + t4[r3++] = 0; + }, o.prototype._toArrayLikeBE = function(t4, e4) { + for (var r3 = t4.length - 1, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { + var a2 = this.words[i2] << o2 | n2; + t4[r3--] = 255 & a2, r3 >= 0 && (t4[r3--] = a2 >> 8 & 255), r3 >= 0 && (t4[r3--] = a2 >> 16 & 255), o2 === 6 ? (r3 >= 0 && (t4[r3--] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); + } + if (r3 >= 0) + for (t4[r3--] = n2; r3 >= 0; ) + t4[r3--] = 0; + }, Math.clz32 ? o.prototype._countBits = function(t4) { + return 32 - Math.clz32(t4); + } : o.prototype._countBits = function(t4) { + var e4 = t4, r3 = 0; + return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; + }, o.prototype._zeroBits = function(t4) { + if (t4 === 0) + return 26; + var e4 = t4, r3 = 0; + return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; + }, o.prototype.bitLength = function() { + var t4 = this.words[this.length - 1], e4 = this._countBits(t4); + return 26 * (this.length - 1) + e4; + }, o.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { + var r3 = this._zeroBits(this.words[e4]); + if (t4 += r3, r3 !== 26) + break; + } + return t4; + }, o.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o.prototype.toTwos = function(t4) { + return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); + }, o.prototype.fromTwos = function(t4) { + return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); + }, o.prototype.isNeg = function() { + return this.negative !== 0; + }, o.prototype.neg = function() { + return this.clone().ineg(); + }, o.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o.prototype.iuor = function(t4) { + for (; this.length < t4.length; ) + this.words[this.length++] = 0; + for (var e4 = 0; e4 < t4.length; e4++) + this.words[e4] = this.words[e4] | t4.words[e4]; + return this._strip(); + }, o.prototype.ior = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuor(t4); + }, o.prototype.or = function(t4) { + return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); + }, o.prototype.uor = function(t4) { + return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); + }, o.prototype.iuand = function(t4) { + var e4; + e4 = this.length > t4.length ? t4 : this; + for (var r3 = 0; r3 < e4.length; r3++) + this.words[r3] = this.words[r3] & t4.words[r3]; + return this.length = e4.length, this._strip(); + }, o.prototype.iand = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuand(t4); + }, o.prototype.and = function(t4) { + return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); + }, o.prototype.uand = function(t4) { + return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); + }, o.prototype.iuxor = function(t4) { + var e4, r3; + this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); + for (var n2 = 0; n2 < r3.length; n2++) + this.words[n2] = e4.words[n2] ^ r3.words[n2]; + if (this !== e4) + for (; n2 < e4.length; n2++) + this.words[n2] = e4.words[n2]; + return this.length = e4.length, this._strip(); + }, o.prototype.ixor = function(t4) { + return n((this.negative | t4.negative) == 0), this.iuxor(t4); + }, o.prototype.xor = function(t4) { + return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); + }, o.prototype.uxor = function(t4) { + return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); + }, o.prototype.inotn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; + this._expand(e4), r3 > 0 && e4--; + for (var i2 = 0; i2 < e4; i2++) + this.words[i2] = 67108863 & ~this.words[i2]; + return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this._strip(); + }, o.prototype.notn = function(t4) { + return this.clone().inotn(t4); + }, o.prototype.setn = function(t4, e4) { + n(typeof t4 == "number" && t4 >= 0); + var r3 = t4 / 26 | 0, i2 = t4 % 26; + return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this._strip(); + }, o.prototype.iadd = function(t4) { + var e4, r3, n2; + if (this.negative !== 0 && t4.negative === 0) + return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && t4.negative !== 0) + return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); + this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) + e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + for (; i2 !== 0 && o2 < r3.length; o2++) + e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; + if (this.length = r3.length, i2 !== 0) + this.words[this.length] = i2, this.length++; + else if (r3 !== this) + for (; o2 < r3.length; o2++) + this.words[o2] = r3.words[o2]; + return this; + }, o.prototype.add = function(t4) { + var e4; + return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); + }, o.prototype.isub = function(t4) { + if (t4.negative !== 0) { + t4.negative = 0; + var e4 = this.iadd(t4); + return t4.negative = 1, e4._normSign(); + } + if (this.negative !== 0) + return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); + var r3, n2, i2 = this.cmp(t4); + if (i2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); + for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + for (; o2 !== 0 && a2 < r3.length; a2++) + o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; + if (o2 === 0 && a2 < r3.length && r3 !== this) + for (; a2 < r3.length; a2++) + this.words[a2] = r3.words[a2]; + return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this._strip(); + }, o.prototype.sub = function(t4) { + return this.clone().isub(t4); + }; + var m = function(t4, e4, r3) { + var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v = 0 | a2[3], w2 = 8191 & v, _2 = v >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A2 = 0 | a2[5], k2 = 8191 & A2, B2 = A2 >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; + r3.negative = t4.negative ^ e4.negative, r3.length = 19; + var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; + f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); + var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; + var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; + var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; + var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k2, z), i2 = (i2 = Math.imul(k2, q)) + Math.imul(B2, z) | 0, o2 = Math.imul(B2, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; + var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k2, F) | 0, i2 = (i2 = i2 + Math.imul(k2, V) | 0) + Math.imul(B2, F) | 0, o2 = o2 + Math.imul(B2, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; + var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k2, J) | 0, i2 = (i2 = i2 + Math.imul(k2, $) | 0) + Math.imul(B2, J) | 0, o2 = o2 + Math.imul(B2, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; + var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k2, Z) | 0, i2 = (i2 = i2 + Math.imul(k2, Y) | 0) + Math.imul(B2, Z) | 0, o2 = o2 + Math.imul(B2, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; + var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k2, Q) | 0, i2 = (i2 = i2 + Math.imul(k2, tt) | 0) + Math.imul(B2, Q) | 0, o2 = o2 + Math.imul(B2, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; + var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k2, rt) | 0, i2 = (i2 = i2 + Math.imul(k2, nt) | 0) + Math.imul(B2, rt) | 0, o2 = o2 + Math.imul(B2, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; + var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k2, ot) | 0, i2 = (i2 = i2 + Math.imul(k2, at) | 0) + Math.imul(B2, ot) | 0, o2 = o2 + Math.imul(B2, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; + var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k2, ut) | 0, i2 = (i2 = i2 + Math.imul(k2, ft) | 0) + Math.imul(B2, ut) | 0, o2 = o2 + Math.imul(B2, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; + var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k2, ht) | 0, i2 = (i2 = i2 + Math.imul(k2, lt) | 0) + Math.imul(B2, ht) | 0, o2 = o2 + Math.imul(B2, lt) | 0; + var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; + var Ot = (f2 + (n2 = n2 + Math.imul(k2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k2, yt) | 0) + Math.imul(B2, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(B2, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; + var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; + var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); + var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; + f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; + var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; + return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; + }; + function b(t4, e4, r3) { + r3.negative = e4.negative ^ t4.negative, r3.length = t4.length + e4.length; + for (var n2 = 0, i2 = 0, o2 = 0; o2 < r3.length - 1; o2++) { + var a2 = i2; + i2 = 0; + for (var s2 = 67108863 & n2, u2 = Math.min(o2, e4.length - 1), f2 = Math.max(0, o2 - t4.length + 1); f2 <= u2; f2++) { + var c2 = o2 - f2, h2 = (0 | t4.words[c2]) * (0 | e4.words[f2]), l2 = 67108863 & h2; + s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; + } + r3.words[o2] = s2, n2 = a2, a2 = i2; + } + return n2 !== 0 ? r3.words[o2] = n2 : r3.length--, r3._strip(); + } + function g(t4, e4, r3) { + return b(t4, e4, r3); + } + Math.imul || (m = y), o.prototype.mulTo = function(t4, e4) { + var r3 = this.length + t4.length; + return this.length === 10 && t4.length === 10 ? m(this, t4, e4) : r3 < 63 ? y(this, t4, e4) : r3 < 1024 ? b(this, t4, e4) : g(this, t4, e4); + }, o.prototype.mul = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); + }, o.prototype.mulf = function(t4) { + var e4 = new o(null); + return e4.words = new Array(this.length + t4.length), g(this, t4, e4); + }, o.prototype.imul = function(t4) { + return this.clone().mulTo(t4, this); + }, o.prototype.imuln = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(typeof t4 == "number"), n(t4 < 67108864); + for (var r3 = 0, i2 = 0; i2 < this.length; i2++) { + var o2 = (0 | this.words[i2]) * t4, a2 = (67108863 & o2) + (67108863 & r3); + r3 >>= 26, r3 += o2 / 67108864 | 0, r3 += a2 >>> 26, this.words[i2] = 67108863 & a2; + } + return r3 !== 0 && (this.words[i2] = r3, this.length++), e4 ? this.ineg() : this; + }, o.prototype.muln = function(t4) { + return this.clone().imuln(t4); + }, o.prototype.sqr = function() { + return this.mul(this); + }, o.prototype.isqr = function() { + return this.imul(this.clone()); + }, o.prototype.pow = function(t4) { + var e4 = function(t5) { + for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { + var n3 = r4 / 26 | 0, i3 = r4 % 26; + e5[r4] = t5.words[n3] >>> i3 & 1; + } + return e5; + }(t4); + if (e4.length === 0) + return new o(1); + for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) + ; + if (++n2 < e4.length) + for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) + e4[n2] !== 0 && (r3 = r3.mul(i2)); + return r3; + }, o.prototype.iushln = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; + if (r3 !== 0) { + var a2 = 0; + for (e4 = 0; e4 < this.length; e4++) { + var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; + this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; + } + a2 && (this.words[e4] = a2, this.length++); + } + if (i2 !== 0) { + for (e4 = this.length - 1; e4 >= 0; e4--) + this.words[e4 + i2] = this.words[e4]; + for (e4 = 0; e4 < i2; e4++) + this.words[e4] = 0; + this.length += i2; + } + return this._strip(); + }, o.prototype.ishln = function(t4) { + return n(this.negative === 0), this.iushln(t4); + }, o.prototype.iushrn = function(t4, e4, r3) { + var i2; + n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; + var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; + if (i2 -= a2, i2 = Math.max(0, i2), u2) { + for (var f2 = 0; f2 < a2; f2++) + u2.words[f2] = this.words[f2]; + u2.length = a2; + } + if (a2 === 0) + ; + else if (this.length > a2) + for (this.length -= a2, f2 = 0; f2 < this.length; f2++) + this.words[f2] = this.words[f2 + a2]; + else + this.words[0] = 0, this.length = 1; + var c2 = 0; + for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { + var h2 = 0 | this.words[f2]; + this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; + } + return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o.prototype.ishrn = function(t4, e4, r3) { + return n(this.negative === 0), this.iushrn(t4, e4, r3); + }, o.prototype.shln = function(t4) { + return this.clone().ishln(t4); + }, o.prototype.ushln = function(t4) { + return this.clone().iushln(t4); + }, o.prototype.shrn = function(t4) { + return this.clone().ishrn(t4); + }, o.prototype.ushrn = function(t4) { + return this.clone().iushrn(t4); + }, o.prototype.testn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + return !(this.length <= r3 || !(this.words[r3] & i2)); + }, o.prototype.imaskn = function(t4) { + n(typeof t4 == "number" && t4 >= 0); + var e4 = t4 % 26, r3 = (t4 - e4) / 26; + if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) + return this; + if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { + var i2 = 67108863 ^ 67108863 >>> e4 << e4; + this.words[this.length - 1] &= i2; + } + return this._strip(); + }, o.prototype.maskn = function(t4) { + return this.clone().imaskn(t4); + }, o.prototype.iaddn = function(t4) { + return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) <= t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); + }, o.prototype._iaddn = function(t4) { + this.words[0] += t4; + for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) + this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; + return this.length = Math.max(this.length, e4 + 1), this; + }, o.prototype.isubn = function(t4) { + if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) + return this.iaddn(-t4); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(t4), this.negative = 1, this; + if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) + this.words[e4] += 67108864, this.words[e4 + 1] -= 1; + return this._strip(); + }, o.prototype.addn = function(t4) { + return this.clone().iaddn(t4); + }, o.prototype.subn = function(t4) { + return this.clone().isubn(t4); + }, o.prototype.iabs = function() { + return this.negative = 0, this; + }, o.prototype.abs = function() { + return this.clone().iabs(); + }, o.prototype._ishlnsubmul = function(t4, e4, r3) { + var i2, o2, a2 = t4.length + r3; + this._expand(a2); + var s2 = 0; + for (i2 = 0; i2 < t4.length; i2++) { + o2 = (0 | this.words[i2 + r3]) + s2; + var u2 = (0 | t4.words[i2]) * e4; + s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; + } + for (; i2 < this.length - r3; i2++) + s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; + if (s2 === 0) + return this._strip(); + for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) + s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; + return this.negative = 1, this._strip(); + }, o.prototype._wordDiv = function(t4, e4) { + var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; + (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); + var s2, u2 = n2.length - i2.length; + if (e4 !== "mod") { + (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); + for (var f2 = 0; f2 < s2.length; f2++) + s2.words[f2] = 0; + } + var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); + c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); + for (var h2 = u2 - 1; h2 >= 0; h2--) { + var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); + for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) + l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); + s2 && (s2.words[h2] = l2); + } + return s2 && s2._strip(), n2._strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; + }, o.prototype.divmod = function(t4, e4, r3) { + return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modrn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modrn(t4.words[0]))} : this._wordDiv(t4, e4); + var i2, a2, s2; + }, o.prototype.div = function(t4) { + return this.divmod(t4, "div", false).div; + }, o.prototype.mod = function(t4) { + return this.divmod(t4, "mod", false).mod; + }, o.prototype.umod = function(t4) { + return this.divmod(t4, "mod", true).mod; + }, o.prototype.divRound = function(t4) { + var e4 = this.divmod(t4); + if (e4.mod.isZero()) + return e4.div; + var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); + return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); + }, o.prototype.modrn = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(t4 <= 67108863); + for (var r3 = (1 << 26) % t4, i2 = 0, o2 = this.length - 1; o2 >= 0; o2--) + i2 = (r3 * i2 + (0 | this.words[o2])) % t4; + return e4 ? -i2 : i2; + }, o.prototype.modn = function(t4) { + return this.modrn(t4); + }, o.prototype.idivn = function(t4) { + var e4 = t4 < 0; + e4 && (t4 = -t4), n(t4 <= 67108863); + for (var r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) { + var o2 = (0 | this.words[i2]) + 67108864 * r3; + this.words[i2] = o2 / t4 | 0, r3 = o2 % t4; + } + return this._strip(), e4 ? this.ineg() : this; + }, o.prototype.divn = function(t4) { + return this.clone().idivn(t4); + }, o.prototype.egcd = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) + e4.iushrn(1), r3.iushrn(1), ++f2; + for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { + for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) + ; + if (l2 > 0) + for (e4.iushrn(l2); l2-- > 0; ) + (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); + for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) + ; + if (p2 > 0) + for (r3.iushrn(p2); p2-- > 0; ) + (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); + } + return {a: s2, b: u2, gcd: r3.iushln(f2)}; + }, o.prototype._invmp = function(t4) { + n(t4.negative === 0), n(!t4.isZero()); + var e4 = this, r3 = t4.clone(); + e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); + for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { + for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) + ; + if (f2 > 0) + for (e4.iushrn(f2); f2-- > 0; ) + a2.isOdd() && a2.iadd(u2), a2.iushrn(1); + for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) + ; + if (h2 > 0) + for (r3.iushrn(h2); h2-- > 0; ) + s2.isOdd() && s2.iadd(u2), s2.iushrn(1); + e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); + } + return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; + }, o.prototype.gcd = function(t4) { + if (this.isZero()) + return t4.abs(); + if (t4.isZero()) + return this.abs(); + var e4 = this.clone(), r3 = t4.clone(); + e4.negative = 0, r3.negative = 0; + for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) + e4.iushrn(1), r3.iushrn(1); + for (; ; ) { + for (; e4.isEven(); ) + e4.iushrn(1); + for (; r3.isEven(); ) + r3.iushrn(1); + var i2 = e4.cmp(r3); + if (i2 < 0) { + var o2 = e4; + e4 = r3, r3 = o2; + } else if (i2 === 0 || r3.cmpn(1) === 0) + break; + e4.isub(r3); + } + return r3.iushln(n2); + }, o.prototype.invm = function(t4) { + return this.egcd(t4).a.umod(t4); + }, o.prototype.isEven = function() { + return (1 & this.words[0]) == 0; + }, o.prototype.isOdd = function() { + return (1 & this.words[0]) == 1; + }, o.prototype.andln = function(t4) { + return this.words[0] & t4; + }, o.prototype.bincn = function(t4) { + n(typeof t4 == "number"); + var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; + if (this.length <= r3) + return this._expand(r3 + 1), this.words[r3] |= i2, this; + for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { + var s2 = 0 | this.words[a2]; + o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; + } + return o2 !== 0 && (this.words[a2] = o2, this.length++), this; + }, o.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o.prototype.cmpn = function(t4) { + var e4, r3 = t4 < 0; + if (this.negative !== 0 && !r3) + return -1; + if (this.negative === 0 && r3) + return 1; + if (this._strip(), this.length > 1) + e4 = 1; + else { + r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); + var i2 = 0 | this.words[0]; + e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; + } + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.cmp = function(t4) { + if (this.negative !== 0 && t4.negative === 0) + return -1; + if (this.negative === 0 && t4.negative !== 0) + return 1; + var e4 = this.ucmp(t4); + return this.negative !== 0 ? 0 | -e4 : e4; + }, o.prototype.ucmp = function(t4) { + if (this.length > t4.length) + return 1; + if (this.length < t4.length) + return -1; + for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { + var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; + if (n2 !== i2) { + n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); + break; + } + } + return e4; + }, o.prototype.gtn = function(t4) { + return this.cmpn(t4) === 1; + }, o.prototype.gt = function(t4) { + return this.cmp(t4) === 1; + }, o.prototype.gten = function(t4) { + return this.cmpn(t4) >= 0; + }, o.prototype.gte = function(t4) { + return this.cmp(t4) >= 0; + }, o.prototype.ltn = function(t4) { + return this.cmpn(t4) === -1; + }, o.prototype.lt = function(t4) { + return this.cmp(t4) === -1; + }, o.prototype.lten = function(t4) { + return this.cmpn(t4) <= 0; + }, o.prototype.lte = function(t4) { + return this.cmp(t4) <= 0; + }, o.prototype.eqn = function(t4) { + return this.cmpn(t4) === 0; + }, o.prototype.eq = function(t4) { + return this.cmp(t4) === 0; + }, o.red = function(t4) { + return new k(t4); + }, o.prototype.toRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); + }, o.prototype.fromRed = function() { + return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o.prototype._forceRed = function(t4) { + return this.red = t4, this; + }, o.prototype.forceRed = function(t4) { + return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); + }, o.prototype.redAdd = function(t4) { + return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); + }, o.prototype.redIAdd = function(t4) { + return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); + }, o.prototype.redSub = function(t4) { + return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); + }, o.prototype.redISub = function(t4) { + return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); + }, o.prototype.redShl = function(t4) { + return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); + }, o.prototype.redMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); + }, o.prototype.redIMul = function(t4) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); + }, o.prototype.redSqr = function() { + return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o.prototype.redISqr = function() { + return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o.prototype.redSqrt = function() { + return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o.prototype.redInvm = function() { + return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o.prototype.redNeg = function() { + return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o.prototype.redPow = function(t4) { + return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); + }; + var w = {k256: null, p224: null, p192: null, p25519: null}; + function _(t4, e4) { + this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + function M() { + _.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + function S() { + _.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + function E() { + _.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + function A() { + _.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + function k(t4) { + if (typeof t4 == "string") { + var e4 = o._prime(t4); + this.m = e4.p, this.prime = e4; + } else + n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; + } + function B(t4) { + k.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); + } + _.prototype._tmp = function() { + var t4 = new o(null); + return t4.words = new Array(Math.ceil(this.n / 13)), t4; + }, _.prototype.ireduce = function(t4) { + var e4, r3 = t4; + do { + this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); + } while (e4 > this.n); + var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); + return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; + }, _.prototype.split = function(t4, e4) { + t4.iushrn(this.n, 0, e4); + }, _.prototype.imulK = function(t4) { + return t4.imul(this.k); + }, i(M, _), M.prototype.split = function(t4, e4) { + for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) + e4.words[i2] = t4.words[i2]; + if (e4.length = n2, t4.length <= 9) + return t4.words[0] = 0, void (t4.length = 1); + var o2 = t4.words[9]; + for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { + var a2 = 0 | t4.words[i2]; + t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; + } + o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; + }, M.prototype.imulK = function(t4) { + t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 0 | t4.words[r3]; + e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); + } + return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; + }, i(S, _), i(E, _), i(A, _), A.prototype.imulK = function(t4) { + for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { + var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; + n2 >>>= 26, t4.words[r3] = i2, e4 = n2; + } + return e4 !== 0 && (t4.words[t4.length++] = e4), t4; + }, o._prime = function(t4) { + if (w[t4]) + return w[t4]; + var e4; + if (t4 === "k256") + e4 = new M(); + else if (t4 === "p224") + e4 = new S(); + else if (t4 === "p192") + e4 = new E(); + else { + if (t4 !== "p25519") + throw new Error("Unknown prime " + t4); + e4 = new A(); + } + return w[t4] = e4, e4; + }, k.prototype._verify1 = function(t4) { + n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); + }, k.prototype._verify2 = function(t4, e4) { + n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); + }, k.prototype.imod = function(t4) { + return this.prime ? this.prime.ireduce(t4)._forceRed(this) : (c(t4, t4.umod(this.m)._forceRed(this)), t4); + }, k.prototype.neg = function(t4) { + return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); + }, k.prototype.add = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.add(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); + }, k.prototype.iadd = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.iadd(e4); + return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; + }, k.prototype.sub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.sub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); + }, k.prototype.isub = function(t4, e4) { + this._verify2(t4, e4); + var r3 = t4.isub(e4); + return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; + }, k.prototype.shl = function(t4, e4) { + return this._verify1(t4), this.imod(t4.ushln(e4)); + }, k.prototype.imul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.imul(e4)); + }, k.prototype.mul = function(t4, e4) { + return this._verify2(t4, e4), this.imod(t4.mul(e4)); + }, k.prototype.isqr = function(t4) { + return this.imul(t4, t4.clone()); + }, k.prototype.sqr = function(t4) { + return this.mul(t4, t4); + }, k.prototype.sqrt = function(t4) { + if (t4.isZero()) + return t4.clone(); + var e4 = this.m.andln(3); + if (n(e4 % 2 == 1), e4 === 3) { + var r3 = this.m.add(new o(1)).iushrn(2); + return this.pow(t4, r3); + } + for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) + a2++, i2.iushrn(1); + n(!i2.isZero()); + var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); + for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) + c2.redIAdd(u2); + for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { + for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) + y2 = y2.redSqr(); + n(m2 < p2); + var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); + l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; + } + return l2; + }, k.prototype.invm = function(t4) { + var e4 = t4._invmp(this.m); + return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); + }, k.prototype.pow = function(t4, e4) { + if (e4.isZero()) + return new o(1).toRed(this); + if (e4.cmpn(1) === 0) + return t4.clone(); + var r3 = new Array(16); + r3[0] = new o(1).toRed(this), r3[1] = t4; + for (var n2 = 2; n2 < r3.length; n2++) + r3[n2] = this.mul(r3[n2 - 1], t4); + var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; + for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { + for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { + var h2 = f2 >> c2 & 1; + i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; + } + u2 = 26; + } + return i2; + }, k.prototype.convertTo = function(t4) { + var e4 = t4.umod(this.m); + return e4 === t4 ? e4.clone() : e4; + }, k.prototype.convertFrom = function(t4) { + var e4 = t4.clone(); + return e4.red = null, e4; + }, o.mont = function(t4) { + return new B(t4); + }, i(B, k), B.prototype.convertTo = function(t4) { + return this.imod(t4.ushln(this.shift)); + }, B.prototype.convertFrom = function(t4) { + var e4 = this.imod(t4.mul(this.rinv)); + return e4.red = null, e4; + }, B.prototype.imul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return t4.words[0] = 0, t4.length = 1, t4; + var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; + return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); + }, B.prototype.mul = function(t4, e4) { + if (t4.isZero() || e4.isZero()) + return new o(0)._forceRed(this); + var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; + return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); + }, B.prototype.invm = function(t4) { + return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); + }; + }(t2 = r2.nmd(t2), this); + }, 7191: (t2, e2, r2) => { + var n = r2(8162); + t2.exports = n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + }, 3310: (t2, e2, r2) => { + var n = r2(7191), i = r2(9509).Buffer; + t2.exports = function(t3) { + function e3(e4) { + var r3 = e4.slice(0, -4), n2 = e4.slice(-4), i2 = t3(r3); + if (!(n2[0] ^ i2[0] | n2[1] ^ i2[1] | n2[2] ^ i2[2] | n2[3] ^ i2[3])) + return r3; + } + return {encode: function(e4) { + var r3 = t3(e4); + return n.encode(i.concat([e4, r3], e4.length + 4)); + }, decode: function(t4) { + var r3 = e3(n.decode(t4)); + if (!r3) + throw new Error("Invalid checksum"); + return r3; + }, decodeUnsafe: function(t4) { + var r3 = n.decodeUnsafe(t4); + if (r3) + return e3(r3); + }}; + }; + }, 8334: (t2, e2, r2) => { + var n = r2(3482), i = r2(3310); + t2.exports = i(function(t3) { + var e3 = n("sha256").update(t3).digest(); + return n("sha256").update(e3).digest(); + }); + }, 7295: (t2, e2, r2) => { + var n = r2(8764).Buffer; + t2.exports = function(t3, e3) { + for (var r3 = Math.min(t3.length, e3.length), i = new n(r3), o = 0; o < r3; ++o) + i[o] = t3[o] ^ e3[o]; + return i; + }; + }, 8764: (t2, e2, r2) => { + const n = r2(9742), i = r2(645), o = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null; + e2.Buffer = u, e2.SlowBuffer = function(t3) { + return +t3 != t3 && (t3 = 0), u.alloc(+t3); + }, e2.INSPECT_MAX_BYTES = 50; + const a = 2147483647; + function s(t3) { + if (t3 > a) + throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); + const e3 = new Uint8Array(t3); + return Object.setPrototypeOf(e3, u.prototype), e3; + } + function u(t3, e3, r3) { + if (typeof t3 == "number") { + if (typeof e3 == "string") + throw new TypeError('The "string" argument must be of type string. Received type number'); + return h(t3); + } + return f(t3, e3, r3); + } + function f(t3, e3, r3) { + if (typeof t3 == "string") + return function(t4, e4) { + if (typeof e4 == "string" && e4 !== "" || (e4 = "utf8"), !u.isEncoding(e4)) + throw new TypeError("Unknown encoding: " + e4); + const r4 = 0 | y(t4, e4); + let n3 = s(r4); + const i3 = n3.write(t4, e4); + return i3 !== r4 && (n3 = n3.slice(0, i3)), n3; + }(t3, e3); + if (ArrayBuffer.isView(t3)) + return function(t4) { + if (G(t4, Uint8Array)) { + const e4 = new Uint8Array(t4); + return d(e4.buffer, e4.byteOffset, e4.byteLength); + } + return l(t4); + }(t3); + if (t3 == null) + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); + if (G(t3, ArrayBuffer) || t3 && G(t3.buffer, ArrayBuffer)) + return d(t3, e3, r3); + if (typeof SharedArrayBuffer != "undefined" && (G(t3, SharedArrayBuffer) || t3 && G(t3.buffer, SharedArrayBuffer))) + return d(t3, e3, r3); + if (typeof t3 == "number") + throw new TypeError('The "value" argument must not be of type number. Received type number'); + const n2 = t3.valueOf && t3.valueOf(); + if (n2 != null && n2 !== t3) + return u.from(n2, e3, r3); + const i2 = function(t4) { + if (u.isBuffer(t4)) { + const e4 = 0 | p(t4.length), r4 = s(e4); + return r4.length === 0 || t4.copy(r4, 0, 0, e4), r4; + } + return t4.length !== void 0 ? typeof t4.length != "number" || Z(t4.length) ? s(0) : l(t4) : t4.type === "Buffer" && Array.isArray(t4.data) ? l(t4.data) : void 0; + }(t3); + if (i2) + return i2; + if (typeof Symbol != "undefined" && Symbol.toPrimitive != null && typeof t3[Symbol.toPrimitive] == "function") + return u.from(t3[Symbol.toPrimitive]("string"), e3, r3); + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); + } + function c(t3) { + if (typeof t3 != "number") + throw new TypeError('"size" argument must be of type number'); + if (t3 < 0) + throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); + } + function h(t3) { + return c(t3), s(t3 < 0 ? 0 : 0 | p(t3)); + } + function l(t3) { + const e3 = t3.length < 0 ? 0 : 0 | p(t3.length), r3 = s(e3); + for (let n2 = 0; n2 < e3; n2 += 1) + r3[n2] = 255 & t3[n2]; + return r3; + } + function d(t3, e3, r3) { + if (e3 < 0 || t3.byteLength < e3) + throw new RangeError('"offset" is outside of buffer bounds'); + if (t3.byteLength < e3 + (r3 || 0)) + throw new RangeError('"length" is outside of buffer bounds'); + let n2; + return n2 = e3 === void 0 && r3 === void 0 ? new Uint8Array(t3) : r3 === void 0 ? new Uint8Array(t3, e3) : new Uint8Array(t3, e3, r3), Object.setPrototypeOf(n2, u.prototype), n2; + } + function p(t3) { + if (t3 >= a) + throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a.toString(16) + " bytes"); + return 0 | t3; + } + function y(t3, e3) { + if (u.isBuffer(t3)) + return t3.length; + if (ArrayBuffer.isView(t3) || G(t3, ArrayBuffer)) + return t3.byteLength; + if (typeof t3 != "string") + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof t3); + const r3 = t3.length, n2 = arguments.length > 2 && arguments[2] === true; + if (!n2 && r3 === 0) + return 0; + let i2 = false; + for (; ; ) + switch (e3) { + case "ascii": + case "latin1": + case "binary": + return r3; + case "utf8": + case "utf-8": + return W(t3).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return 2 * r3; + case "hex": + return r3 >>> 1; + case "base64": + return J(t3).length; + default: + if (i2) + return n2 ? -1 : W(t3).length; + e3 = ("" + e3).toLowerCase(), i2 = true; + } + } + function m(t3, e3, r3) { + let n2 = false; + if ((e3 === void 0 || e3 < 0) && (e3 = 0), e3 > this.length) + return ""; + if ((r3 === void 0 || r3 > this.length) && (r3 = this.length), r3 <= 0) + return ""; + if ((r3 >>>= 0) <= (e3 >>>= 0)) + return ""; + for (t3 || (t3 = "utf8"); ; ) + switch (t3) { + case "hex": + return O(this, e3, r3); + case "utf8": + case "utf-8": + return k(this, e3, r3); + case "ascii": + return T(this, e3, r3); + case "latin1": + case "binary": + return x(this, e3, r3); + case "base64": + return A(this, e3, r3); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return R(this, e3, r3); + default: + if (n2) + throw new TypeError("Unknown encoding: " + t3); + t3 = (t3 + "").toLowerCase(), n2 = true; + } + } + function b(t3, e3, r3) { + const n2 = t3[e3]; + t3[e3] = t3[r3], t3[r3] = n2; + } + function g(t3, e3, r3, n2, i2) { + if (t3.length === 0) + return -1; + if (typeof r3 == "string" ? (n2 = r3, r3 = 0) : r3 > 2147483647 ? r3 = 2147483647 : r3 < -2147483648 && (r3 = -2147483648), Z(r3 = +r3) && (r3 = i2 ? 0 : t3.length - 1), r3 < 0 && (r3 = t3.length + r3), r3 >= t3.length) { + if (i2) + return -1; + r3 = t3.length - 1; + } else if (r3 < 0) { + if (!i2) + return -1; + r3 = 0; + } + if (typeof e3 == "string" && (e3 = u.from(e3, n2)), u.isBuffer(e3)) + return e3.length === 0 ? -1 : v(t3, e3, r3, n2, i2); + if (typeof e3 == "number") + return e3 &= 255, typeof Uint8Array.prototype.indexOf == "function" ? i2 ? Uint8Array.prototype.indexOf.call(t3, e3, r3) : Uint8Array.prototype.lastIndexOf.call(t3, e3, r3) : v(t3, [e3], r3, n2, i2); + throw new TypeError("val must be string, number or Buffer"); + } + function v(t3, e3, r3, n2, i2) { + let o2, a2 = 1, s2 = t3.length, u2 = e3.length; + if (n2 !== void 0 && ((n2 = String(n2).toLowerCase()) === "ucs2" || n2 === "ucs-2" || n2 === "utf16le" || n2 === "utf-16le")) { + if (t3.length < 2 || e3.length < 2) + return -1; + a2 = 2, s2 /= 2, u2 /= 2, r3 /= 2; + } + function f2(t4, e4) { + return a2 === 1 ? t4[e4] : t4.readUInt16BE(e4 * a2); + } + if (i2) { + let n3 = -1; + for (o2 = r3; o2 < s2; o2++) + if (f2(t3, o2) === f2(e3, n3 === -1 ? 0 : o2 - n3)) { + if (n3 === -1 && (n3 = o2), o2 - n3 + 1 === u2) + return n3 * a2; + } else + n3 !== -1 && (o2 -= o2 - n3), n3 = -1; + } else + for (r3 + u2 > s2 && (r3 = s2 - u2), o2 = r3; o2 >= 0; o2--) { + let r4 = true; + for (let n3 = 0; n3 < u2; n3++) + if (f2(t3, o2 + n3) !== f2(e3, n3)) { + r4 = false; + break; + } + if (r4) + return o2; + } + return -1; + } + function w(t3, e3, r3, n2) { + r3 = Number(r3) || 0; + const i2 = t3.length - r3; + n2 ? (n2 = Number(n2)) > i2 && (n2 = i2) : n2 = i2; + const o2 = e3.length; + let a2; + for (n2 > o2 / 2 && (n2 = o2 / 2), a2 = 0; a2 < n2; ++a2) { + const n3 = parseInt(e3.substr(2 * a2, 2), 16); + if (Z(n3)) + return a2; + t3[r3 + a2] = n3; + } + return a2; + } + function _(t3, e3, r3, n2) { + return $(W(e3, t3.length - r3), t3, r3, n2); + } + function M(t3, e3, r3, n2) { + return $(function(t4) { + const e4 = []; + for (let r4 = 0; r4 < t4.length; ++r4) + e4.push(255 & t4.charCodeAt(r4)); + return e4; + }(e3), t3, r3, n2); + } + function S(t3, e3, r3, n2) { + return $(J(e3), t3, r3, n2); + } + function E(t3, e3, r3, n2) { + return $(function(t4, e4) { + let r4, n3, i2; + const o2 = []; + for (let a2 = 0; a2 < t4.length && !((e4 -= 2) < 0); ++a2) + r4 = t4.charCodeAt(a2), n3 = r4 >> 8, i2 = r4 % 256, o2.push(i2), o2.push(n3); + return o2; + }(e3, t3.length - r3), t3, r3, n2); + } + function A(t3, e3, r3) { + return e3 === 0 && r3 === t3.length ? n.fromByteArray(t3) : n.fromByteArray(t3.slice(e3, r3)); + } + function k(t3, e3, r3) { + r3 = Math.min(t3.length, r3); + const n2 = []; + let i2 = e3; + for (; i2 < r3; ) { + const e4 = t3[i2]; + let o2 = null, a2 = e4 > 239 ? 4 : e4 > 223 ? 3 : e4 > 191 ? 2 : 1; + if (i2 + a2 <= r3) { + let r4, n3, s2, u2; + switch (a2) { + case 1: + e4 < 128 && (o2 = e4); + break; + case 2: + r4 = t3[i2 + 1], (192 & r4) == 128 && (u2 = (31 & e4) << 6 | 63 & r4, u2 > 127 && (o2 = u2)); + break; + case 3: + r4 = t3[i2 + 1], n3 = t3[i2 + 2], (192 & r4) == 128 && (192 & n3) == 128 && (u2 = (15 & e4) << 12 | (63 & r4) << 6 | 63 & n3, u2 > 2047 && (u2 < 55296 || u2 > 57343) && (o2 = u2)); + break; + case 4: + r4 = t3[i2 + 1], n3 = t3[i2 + 2], s2 = t3[i2 + 3], (192 & r4) == 128 && (192 & n3) == 128 && (192 & s2) == 128 && (u2 = (15 & e4) << 18 | (63 & r4) << 12 | (63 & n3) << 6 | 63 & s2, u2 > 65535 && u2 < 1114112 && (o2 = u2)); + } + } + o2 === null ? (o2 = 65533, a2 = 1) : o2 > 65535 && (o2 -= 65536, n2.push(o2 >>> 10 & 1023 | 55296), o2 = 56320 | 1023 & o2), n2.push(o2), i2 += a2; + } + return function(t4) { + const e4 = t4.length; + if (e4 <= B) + return String.fromCharCode.apply(String, t4); + let r4 = "", n3 = 0; + for (; n3 < e4; ) + r4 += String.fromCharCode.apply(String, t4.slice(n3, n3 += B)); + return r4; + }(n2); + } + e2.kMaxLength = a, u.TYPED_ARRAY_SUPPORT = function() { + try { + const t3 = new Uint8Array(1), e3 = {foo: function() { + return 42; + }}; + return Object.setPrototypeOf(e3, Uint8Array.prototype), Object.setPrototypeOf(t3, e3), t3.foo() === 42; + } catch (t3) { + return false; + } + }(), u.TYPED_ARRAY_SUPPORT || typeof console == "undefined" || typeof console.error != "function" || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(u.prototype, "parent", {enumerable: true, get: function() { + if (u.isBuffer(this)) + return this.buffer; + }}), Object.defineProperty(u.prototype, "offset", {enumerable: true, get: function() { + if (u.isBuffer(this)) + return this.byteOffset; + }}), u.poolSize = 8192, u.from = function(t3, e3, r3) { + return f(t3, e3, r3); + }, Object.setPrototypeOf(u.prototype, Uint8Array.prototype), Object.setPrototypeOf(u, Uint8Array), u.alloc = function(t3, e3, r3) { + return function(t4, e4, r4) { + return c(t4), t4 <= 0 ? s(t4) : e4 !== void 0 ? typeof r4 == "string" ? s(t4).fill(e4, r4) : s(t4).fill(e4) : s(t4); + }(t3, e3, r3); + }, u.allocUnsafe = function(t3) { + return h(t3); + }, u.allocUnsafeSlow = function(t3) { + return h(t3); + }, u.isBuffer = function(t3) { + return t3 != null && t3._isBuffer === true && t3 !== u.prototype; + }, u.compare = function(t3, e3) { + if (G(t3, Uint8Array) && (t3 = u.from(t3, t3.offset, t3.byteLength)), G(e3, Uint8Array) && (e3 = u.from(e3, e3.offset, e3.byteLength)), !u.isBuffer(t3) || !u.isBuffer(e3)) + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + if (t3 === e3) + return 0; + let r3 = t3.length, n2 = e3.length; + for (let i2 = 0, o2 = Math.min(r3, n2); i2 < o2; ++i2) + if (t3[i2] !== e3[i2]) { + r3 = t3[i2], n2 = e3[i2]; + break; + } + return r3 < n2 ? -1 : n2 < r3 ? 1 : 0; + }, u.isEncoding = function(t3) { + switch (String(t3).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return true; + default: + return false; + } + }, u.concat = function(t3, e3) { + if (!Array.isArray(t3)) + throw new TypeError('"list" argument must be an Array of Buffers'); + if (t3.length === 0) + return u.alloc(0); + let r3; + if (e3 === void 0) + for (e3 = 0, r3 = 0; r3 < t3.length; ++r3) + e3 += t3[r3].length; + const n2 = u.allocUnsafe(e3); + let i2 = 0; + for (r3 = 0; r3 < t3.length; ++r3) { + let e4 = t3[r3]; + if (G(e4, Uint8Array)) + i2 + e4.length > n2.length ? (u.isBuffer(e4) || (e4 = u.from(e4)), e4.copy(n2, i2)) : Uint8Array.prototype.set.call(n2, e4, i2); + else { + if (!u.isBuffer(e4)) + throw new TypeError('"list" argument must be an Array of Buffers'); + e4.copy(n2, i2); + } + i2 += e4.length; + } + return n2; + }, u.byteLength = y, u.prototype._isBuffer = true, u.prototype.swap16 = function() { + const t3 = this.length; + if (t3 % 2 != 0) + throw new RangeError("Buffer size must be a multiple of 16-bits"); + for (let e3 = 0; e3 < t3; e3 += 2) + b(this, e3, e3 + 1); + return this; + }, u.prototype.swap32 = function() { + const t3 = this.length; + if (t3 % 4 != 0) + throw new RangeError("Buffer size must be a multiple of 32-bits"); + for (let e3 = 0; e3 < t3; e3 += 4) + b(this, e3, e3 + 3), b(this, e3 + 1, e3 + 2); + return this; + }, u.prototype.swap64 = function() { + const t3 = this.length; + if (t3 % 8 != 0) + throw new RangeError("Buffer size must be a multiple of 64-bits"); + for (let e3 = 0; e3 < t3; e3 += 8) + b(this, e3, e3 + 7), b(this, e3 + 1, e3 + 6), b(this, e3 + 2, e3 + 5), b(this, e3 + 3, e3 + 4); + return this; + }, u.prototype.toString = function() { + const t3 = this.length; + return t3 === 0 ? "" : arguments.length === 0 ? k(this, 0, t3) : m.apply(this, arguments); + }, u.prototype.toLocaleString = u.prototype.toString, u.prototype.equals = function(t3) { + if (!u.isBuffer(t3)) + throw new TypeError("Argument must be a Buffer"); + return this === t3 || u.compare(this, t3) === 0; + }, u.prototype.inspect = function() { + let t3 = ""; + const r3 = e2.INSPECT_MAX_BYTES; + return t3 = this.toString("hex", 0, r3).replace(/(.{2})/g, "$1 ").trim(), this.length > r3 && (t3 += " ... "), ""; + }, o && (u.prototype[o] = u.prototype.inspect), u.prototype.compare = function(t3, e3, r3, n2, i2) { + if (G(t3, Uint8Array) && (t3 = u.from(t3, t3.offset, t3.byteLength)), !u.isBuffer(t3)) + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t3); + if (e3 === void 0 && (e3 = 0), r3 === void 0 && (r3 = t3 ? t3.length : 0), n2 === void 0 && (n2 = 0), i2 === void 0 && (i2 = this.length), e3 < 0 || r3 > t3.length || n2 < 0 || i2 > this.length) + throw new RangeError("out of range index"); + if (n2 >= i2 && e3 >= r3) + return 0; + if (n2 >= i2) + return -1; + if (e3 >= r3) + return 1; + if (this === t3) + return 0; + let o2 = (i2 >>>= 0) - (n2 >>>= 0), a2 = (r3 >>>= 0) - (e3 >>>= 0); + const s2 = Math.min(o2, a2), f2 = this.slice(n2, i2), c2 = t3.slice(e3, r3); + for (let t4 = 0; t4 < s2; ++t4) + if (f2[t4] !== c2[t4]) { + o2 = f2[t4], a2 = c2[t4]; + break; + } + return o2 < a2 ? -1 : a2 < o2 ? 1 : 0; + }, u.prototype.includes = function(t3, e3, r3) { + return this.indexOf(t3, e3, r3) !== -1; + }, u.prototype.indexOf = function(t3, e3, r3) { + return g(this, t3, e3, r3, true); + }, u.prototype.lastIndexOf = function(t3, e3, r3) { + return g(this, t3, e3, r3, false); + }, u.prototype.write = function(t3, e3, r3, n2) { + if (e3 === void 0) + n2 = "utf8", r3 = this.length, e3 = 0; + else if (r3 === void 0 && typeof e3 == "string") + n2 = e3, r3 = this.length, e3 = 0; + else { + if (!isFinite(e3)) + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + e3 >>>= 0, isFinite(r3) ? (r3 >>>= 0, n2 === void 0 && (n2 = "utf8")) : (n2 = r3, r3 = void 0); + } + const i2 = this.length - e3; + if ((r3 === void 0 || r3 > i2) && (r3 = i2), t3.length > 0 && (r3 < 0 || e3 < 0) || e3 > this.length) + throw new RangeError("Attempt to write outside buffer bounds"); + n2 || (n2 = "utf8"); + let o2 = false; + for (; ; ) + switch (n2) { + case "hex": + return w(this, t3, e3, r3); + case "utf8": + case "utf-8": + return _(this, t3, e3, r3); + case "ascii": + case "latin1": + case "binary": + return M(this, t3, e3, r3); + case "base64": + return S(this, t3, e3, r3); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return E(this, t3, e3, r3); + default: + if (o2) + throw new TypeError("Unknown encoding: " + n2); + n2 = ("" + n2).toLowerCase(), o2 = true; + } + }, u.prototype.toJSON = function() { + return {type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0)}; + }; + const B = 4096; + function T(t3, e3, r3) { + let n2 = ""; + r3 = Math.min(t3.length, r3); + for (let i2 = e3; i2 < r3; ++i2) + n2 += String.fromCharCode(127 & t3[i2]); + return n2; + } + function x(t3, e3, r3) { + let n2 = ""; + r3 = Math.min(t3.length, r3); + for (let i2 = e3; i2 < r3; ++i2) + n2 += String.fromCharCode(t3[i2]); + return n2; + } + function O(t3, e3, r3) { + const n2 = t3.length; + (!e3 || e3 < 0) && (e3 = 0), (!r3 || r3 < 0 || r3 > n2) && (r3 = n2); + let i2 = ""; + for (let n3 = e3; n3 < r3; ++n3) + i2 += Y[t3[n3]]; + return i2; + } + function R(t3, e3, r3) { + const n2 = t3.slice(e3, r3); + let i2 = ""; + for (let t4 = 0; t4 < n2.length - 1; t4 += 2) + i2 += String.fromCharCode(n2[t4] + 256 * n2[t4 + 1]); + return i2; + } + function P(t3, e3, r3) { + if (t3 % 1 != 0 || t3 < 0) + throw new RangeError("offset is not uint"); + if (t3 + e3 > r3) + throw new RangeError("Trying to access beyond buffer length"); + } + function I(t3, e3, r3, n2, i2, o2) { + if (!u.isBuffer(t3)) + throw new TypeError('"buffer" argument must be a Buffer instance'); + if (e3 > i2 || e3 < o2) + throw new RangeError('"value" argument is out of bounds'); + if (r3 + n2 > t3.length) + throw new RangeError("Index out of range"); + } + function j(t3, e3, r3, n2, i2) { + q(e3, n2, i2, t3, r3, 7); + let o2 = Number(e3 & BigInt(4294967295)); + t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2; + let a2 = Number(e3 >> BigInt(32) & BigInt(4294967295)); + return t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, r3; + } + function U(t3, e3, r3, n2, i2) { + q(e3, n2, i2, t3, r3, 7); + let o2 = Number(e3 & BigInt(4294967295)); + t3[r3 + 7] = o2, o2 >>= 8, t3[r3 + 6] = o2, o2 >>= 8, t3[r3 + 5] = o2, o2 >>= 8, t3[r3 + 4] = o2; + let a2 = Number(e3 >> BigInt(32) & BigInt(4294967295)); + return t3[r3 + 3] = a2, a2 >>= 8, t3[r3 + 2] = a2, a2 >>= 8, t3[r3 + 1] = a2, a2 >>= 8, t3[r3] = a2, r3 + 8; + } + function N(t3, e3, r3, n2, i2, o2) { + if (r3 + n2 > t3.length) + throw new RangeError("Index out of range"); + if (r3 < 0) + throw new RangeError("Index out of range"); + } + function C(t3, e3, r3, n2, o2) { + return e3 = +e3, r3 >>>= 0, o2 || N(t3, 0, r3, 4), i.write(t3, e3, r3, n2, 23, 4), r3 + 4; + } + function D(t3, e3, r3, n2, o2) { + return e3 = +e3, r3 >>>= 0, o2 || N(t3, 0, r3, 8), i.write(t3, e3, r3, n2, 52, 8), r3 + 8; + } + u.prototype.slice = function(t3, e3) { + const r3 = this.length; + (t3 = ~~t3) < 0 ? (t3 += r3) < 0 && (t3 = 0) : t3 > r3 && (t3 = r3), (e3 = e3 === void 0 ? r3 : ~~e3) < 0 ? (e3 += r3) < 0 && (e3 = 0) : e3 > r3 && (e3 = r3), e3 < t3 && (e3 = t3); + const n2 = this.subarray(t3, e3); + return Object.setPrototypeOf(n2, u.prototype), n2; + }, u.prototype.readUintLE = u.prototype.readUIntLE = function(t3, e3, r3) { + t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); + let n2 = this[t3], i2 = 1, o2 = 0; + for (; ++o2 < e3 && (i2 *= 256); ) + n2 += this[t3 + o2] * i2; + return n2; + }, u.prototype.readUintBE = u.prototype.readUIntBE = function(t3, e3, r3) { + t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); + let n2 = this[t3 + --e3], i2 = 1; + for (; e3 > 0 && (i2 *= 256); ) + n2 += this[t3 + --e3] * i2; + return n2; + }, u.prototype.readUint8 = u.prototype.readUInt8 = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 1, this.length), this[t3]; + }, u.prototype.readUint16LE = u.prototype.readUInt16LE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 2, this.length), this[t3] | this[t3 + 1] << 8; + }, u.prototype.readUint16BE = u.prototype.readUInt16BE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 2, this.length), this[t3] << 8 | this[t3 + 1]; + }, u.prototype.readUint32LE = u.prototype.readUInt32LE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), (this[t3] | this[t3 + 1] << 8 | this[t3 + 2] << 16) + 16777216 * this[t3 + 3]; + }, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), 16777216 * this[t3] + (this[t3 + 1] << 16 | this[t3 + 2] << 8 | this[t3 + 3]); + }, u.prototype.readBigUInt64LE = X(function(t3) { + H(t3 >>>= 0, "offset"); + const e3 = this[t3], r3 = this[t3 + 7]; + e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); + const n2 = e3 + 256 * this[++t3] + 65536 * this[++t3] + this[++t3] * 2 ** 24, i2 = this[++t3] + 256 * this[++t3] + 65536 * this[++t3] + r3 * 2 ** 24; + return BigInt(n2) + (BigInt(i2) << BigInt(32)); + }), u.prototype.readBigUInt64BE = X(function(t3) { + H(t3 >>>= 0, "offset"); + const e3 = this[t3], r3 = this[t3 + 7]; + e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); + const n2 = e3 * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + this[++t3], i2 = this[++t3] * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + r3; + return (BigInt(n2) << BigInt(32)) + BigInt(i2); + }), u.prototype.readIntLE = function(t3, e3, r3) { + t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); + let n2 = this[t3], i2 = 1, o2 = 0; + for (; ++o2 < e3 && (i2 *= 256); ) + n2 += this[t3 + o2] * i2; + return i2 *= 128, n2 >= i2 && (n2 -= Math.pow(2, 8 * e3)), n2; + }, u.prototype.readIntBE = function(t3, e3, r3) { + t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); + let n2 = e3, i2 = 1, o2 = this[t3 + --n2]; + for (; n2 > 0 && (i2 *= 256); ) + o2 += this[t3 + --n2] * i2; + return i2 *= 128, o2 >= i2 && (o2 -= Math.pow(2, 8 * e3)), o2; + }, u.prototype.readInt8 = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 1, this.length), 128 & this[t3] ? -1 * (255 - this[t3] + 1) : this[t3]; + }, u.prototype.readInt16LE = function(t3, e3) { + t3 >>>= 0, e3 || P(t3, 2, this.length); + const r3 = this[t3] | this[t3 + 1] << 8; + return 32768 & r3 ? 4294901760 | r3 : r3; + }, u.prototype.readInt16BE = function(t3, e3) { + t3 >>>= 0, e3 || P(t3, 2, this.length); + const r3 = this[t3 + 1] | this[t3] << 8; + return 32768 & r3 ? 4294901760 | r3 : r3; + }, u.prototype.readInt32LE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), this[t3] | this[t3 + 1] << 8 | this[t3 + 2] << 16 | this[t3 + 3] << 24; + }, u.prototype.readInt32BE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), this[t3] << 24 | this[t3 + 1] << 16 | this[t3 + 2] << 8 | this[t3 + 3]; + }, u.prototype.readBigInt64LE = X(function(t3) { + H(t3 >>>= 0, "offset"); + const e3 = this[t3], r3 = this[t3 + 7]; + e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); + const n2 = this[t3 + 4] + 256 * this[t3 + 5] + 65536 * this[t3 + 6] + (r3 << 24); + return (BigInt(n2) << BigInt(32)) + BigInt(e3 + 256 * this[++t3] + 65536 * this[++t3] + this[++t3] * 2 ** 24); + }), u.prototype.readBigInt64BE = X(function(t3) { + H(t3 >>>= 0, "offset"); + const e3 = this[t3], r3 = this[t3 + 7]; + e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); + const n2 = (e3 << 24) + 65536 * this[++t3] + 256 * this[++t3] + this[++t3]; + return (BigInt(n2) << BigInt(32)) + BigInt(this[++t3] * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + r3); + }), u.prototype.readFloatLE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), i.read(this, t3, true, 23, 4); + }, u.prototype.readFloatBE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 4, this.length), i.read(this, t3, false, 23, 4); + }, u.prototype.readDoubleLE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 8, this.length), i.read(this, t3, true, 52, 8); + }, u.prototype.readDoubleBE = function(t3, e3) { + return t3 >>>= 0, e3 || P(t3, 8, this.length), i.read(this, t3, false, 52, 8); + }, u.prototype.writeUintLE = u.prototype.writeUIntLE = function(t3, e3, r3, n2) { + t3 = +t3, e3 >>>= 0, r3 >>>= 0, n2 || I(this, t3, e3, r3, Math.pow(2, 8 * r3) - 1, 0); + let i2 = 1, o2 = 0; + for (this[e3] = 255 & t3; ++o2 < r3 && (i2 *= 256); ) + this[e3 + o2] = t3 / i2 & 255; + return e3 + r3; + }, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(t3, e3, r3, n2) { + t3 = +t3, e3 >>>= 0, r3 >>>= 0, n2 || I(this, t3, e3, r3, Math.pow(2, 8 * r3) - 1, 0); + let i2 = r3 - 1, o2 = 1; + for (this[e3 + i2] = 255 & t3; --i2 >= 0 && (o2 *= 256); ) + this[e3 + i2] = t3 / o2 & 255; + return e3 + r3; + }, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 1, 255, 0), this[e3] = 255 & t3, e3 + 1; + }, u.prototype.writeUint16LE = u.prototype.writeUInt16LE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 65535, 0), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, e3 + 2; + }, u.prototype.writeUint16BE = u.prototype.writeUInt16BE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 65535, 0), this[e3] = t3 >>> 8, this[e3 + 1] = 255 & t3, e3 + 2; + }, u.prototype.writeUint32LE = u.prototype.writeUInt32LE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 4294967295, 0), this[e3 + 3] = t3 >>> 24, this[e3 + 2] = t3 >>> 16, this[e3 + 1] = t3 >>> 8, this[e3] = 255 & t3, e3 + 4; + }, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 4294967295, 0), this[e3] = t3 >>> 24, this[e3 + 1] = t3 >>> 16, this[e3 + 2] = t3 >>> 8, this[e3 + 3] = 255 & t3, e3 + 4; + }, u.prototype.writeBigUInt64LE = X(function(t3, e3 = 0) { + return j(this, t3, e3, BigInt(0), BigInt("0xffffffffffffffff")); + }), u.prototype.writeBigUInt64BE = X(function(t3, e3 = 0) { + return U(this, t3, e3, BigInt(0), BigInt("0xffffffffffffffff")); + }), u.prototype.writeIntLE = function(t3, e3, r3, n2) { + if (t3 = +t3, e3 >>>= 0, !n2) { + const n3 = Math.pow(2, 8 * r3 - 1); + I(this, t3, e3, r3, n3 - 1, -n3); + } + let i2 = 0, o2 = 1, a2 = 0; + for (this[e3] = 255 & t3; ++i2 < r3 && (o2 *= 256); ) + t3 < 0 && a2 === 0 && this[e3 + i2 - 1] !== 0 && (a2 = 1), this[e3 + i2] = (t3 / o2 >> 0) - a2 & 255; + return e3 + r3; + }, u.prototype.writeIntBE = function(t3, e3, r3, n2) { + if (t3 = +t3, e3 >>>= 0, !n2) { + const n3 = Math.pow(2, 8 * r3 - 1); + I(this, t3, e3, r3, n3 - 1, -n3); + } + let i2 = r3 - 1, o2 = 1, a2 = 0; + for (this[e3 + i2] = 255 & t3; --i2 >= 0 && (o2 *= 256); ) + t3 < 0 && a2 === 0 && this[e3 + i2 + 1] !== 0 && (a2 = 1), this[e3 + i2] = (t3 / o2 >> 0) - a2 & 255; + return e3 + r3; + }, u.prototype.writeInt8 = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 1, 127, -128), t3 < 0 && (t3 = 255 + t3 + 1), this[e3] = 255 & t3, e3 + 1; + }, u.prototype.writeInt16LE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 32767, -32768), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, e3 + 2; + }, u.prototype.writeInt16BE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 32767, -32768), this[e3] = t3 >>> 8, this[e3 + 1] = 255 & t3, e3 + 2; + }, u.prototype.writeInt32LE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 2147483647, -2147483648), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, this[e3 + 2] = t3 >>> 16, this[e3 + 3] = t3 >>> 24, e3 + 4; + }, u.prototype.writeInt32BE = function(t3, e3, r3) { + return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 2147483647, -2147483648), t3 < 0 && (t3 = 4294967295 + t3 + 1), this[e3] = t3 >>> 24, this[e3 + 1] = t3 >>> 16, this[e3 + 2] = t3 >>> 8, this[e3 + 3] = 255 & t3, e3 + 4; + }, u.prototype.writeBigInt64LE = X(function(t3, e3 = 0) { + return j(this, t3, e3, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }), u.prototype.writeBigInt64BE = X(function(t3, e3 = 0) { + return U(this, t3, e3, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }), u.prototype.writeFloatLE = function(t3, e3, r3) { + return C(this, t3, e3, true, r3); + }, u.prototype.writeFloatBE = function(t3, e3, r3) { + return C(this, t3, e3, false, r3); + }, u.prototype.writeDoubleLE = function(t3, e3, r3) { + return D(this, t3, e3, true, r3); + }, u.prototype.writeDoubleBE = function(t3, e3, r3) { + return D(this, t3, e3, false, r3); + }, u.prototype.copy = function(t3, e3, r3, n2) { + if (!u.isBuffer(t3)) + throw new TypeError("argument should be a Buffer"); + if (r3 || (r3 = 0), n2 || n2 === 0 || (n2 = this.length), e3 >= t3.length && (e3 = t3.length), e3 || (e3 = 0), n2 > 0 && n2 < r3 && (n2 = r3), n2 === r3) + return 0; + if (t3.length === 0 || this.length === 0) + return 0; + if (e3 < 0) + throw new RangeError("targetStart out of bounds"); + if (r3 < 0 || r3 >= this.length) + throw new RangeError("Index out of range"); + if (n2 < 0) + throw new RangeError("sourceEnd out of bounds"); + n2 > this.length && (n2 = this.length), t3.length - e3 < n2 - r3 && (n2 = t3.length - e3 + r3); + const i2 = n2 - r3; + return this === t3 && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(e3, r3, n2) : Uint8Array.prototype.set.call(t3, this.subarray(r3, n2), e3), i2; + }, u.prototype.fill = function(t3, e3, r3, n2) { + if (typeof t3 == "string") { + if (typeof e3 == "string" ? (n2 = e3, e3 = 0, r3 = this.length) : typeof r3 == "string" && (n2 = r3, r3 = this.length), n2 !== void 0 && typeof n2 != "string") + throw new TypeError("encoding must be a string"); + if (typeof n2 == "string" && !u.isEncoding(n2)) + throw new TypeError("Unknown encoding: " + n2); + if (t3.length === 1) { + const e4 = t3.charCodeAt(0); + (n2 === "utf8" && e4 < 128 || n2 === "latin1") && (t3 = e4); + } + } else + typeof t3 == "number" ? t3 &= 255 : typeof t3 == "boolean" && (t3 = Number(t3)); + if (e3 < 0 || this.length < e3 || this.length < r3) + throw new RangeError("Out of range index"); + if (r3 <= e3) + return this; + let i2; + if (e3 >>>= 0, r3 = r3 === void 0 ? this.length : r3 >>> 0, t3 || (t3 = 0), typeof t3 == "number") + for (i2 = e3; i2 < r3; ++i2) + this[i2] = t3; + else { + const o2 = u.isBuffer(t3) ? t3 : u.from(t3, n2), a2 = o2.length; + if (a2 === 0) + throw new TypeError('The value "' + t3 + '" is invalid for argument "value"'); + for (i2 = 0; i2 < r3 - e3; ++i2) + this[i2 + e3] = o2[i2 % a2]; + } + return this; + }; + const L = {}; + function K(t3, e3, r3) { + L[t3] = class extends r3 { + constructor() { + super(), Object.defineProperty(this, "message", {value: e3.apply(this, arguments), writable: true, configurable: true}), this.name = `${this.name} [${t3}]`, this.stack, delete this.name; + } + get code() { + return t3; + } + set code(t4) { + Object.defineProperty(this, "code", {configurable: true, enumerable: true, value: t4, writable: true}); + } + toString() { + return `${this.name} [${t3}]: ${this.message}`; + } + }; + } + function z(t3) { + let e3 = "", r3 = t3.length; + const n2 = t3[0] === "-" ? 1 : 0; + for (; r3 >= n2 + 4; r3 -= 3) + e3 = `_${t3.slice(r3 - 3, r3)}${e3}`; + return `${t3.slice(0, r3)}${e3}`; + } + function q(t3, e3, r3, n2, i2, o2) { + if (t3 > r3 || t3 < e3) { + const n3 = typeof e3 == "bigint" ? "n" : ""; + let i3; + throw i3 = o2 > 3 ? e3 === 0 || e3 === BigInt(0) ? `>= 0${n3} and < 2${n3} ** ${8 * (o2 + 1)}${n3}` : `>= -(2${n3} ** ${8 * (o2 + 1) - 1}${n3}) and < 2 ** ${8 * (o2 + 1) - 1}${n3}` : `>= ${e3}${n3} and <= ${r3}${n3}`, new L.ERR_OUT_OF_RANGE("value", i3, t3); + } + !function(t4, e4, r4) { + H(e4, "offset"), t4[e4] !== void 0 && t4[e4 + r4] !== void 0 || F(e4, t4.length - (r4 + 1)); + }(n2, i2, o2); + } + function H(t3, e3) { + if (typeof t3 != "number") + throw new L.ERR_INVALID_ARG_TYPE(e3, "number", t3); + } + function F(t3, e3, r3) { + if (Math.floor(t3) !== t3) + throw H(t3, r3), new L.ERR_OUT_OF_RANGE(r3 || "offset", "an integer", t3); + if (e3 < 0) + throw new L.ERR_BUFFER_OUT_OF_BOUNDS(); + throw new L.ERR_OUT_OF_RANGE(r3 || "offset", `>= ${r3 ? 1 : 0} and <= ${e3}`, t3); + } + K("ERR_BUFFER_OUT_OF_BOUNDS", function(t3) { + return t3 ? `${t3} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds"; + }, RangeError), K("ERR_INVALID_ARG_TYPE", function(t3, e3) { + return `The "${t3}" argument must be of type number. Received type ${typeof e3}`; + }, TypeError), K("ERR_OUT_OF_RANGE", function(t3, e3, r3) { + let n2 = `The value of "${t3}" is out of range.`, i2 = r3; + return Number.isInteger(r3) && Math.abs(r3) > 2 ** 32 ? i2 = z(String(r3)) : typeof r3 == "bigint" && (i2 = String(r3), (r3 > BigInt(2) ** BigInt(32) || r3 < -(BigInt(2) ** BigInt(32))) && (i2 = z(i2)), i2 += "n"), n2 += ` It must be ${e3}. Received ${i2}`, n2; + }, RangeError); + const V = /[^+/0-9A-Za-z-_]/g; + function W(t3, e3) { + let r3; + e3 = e3 || 1 / 0; + const n2 = t3.length; + let i2 = null; + const o2 = []; + for (let a2 = 0; a2 < n2; ++a2) { + if (r3 = t3.charCodeAt(a2), r3 > 55295 && r3 < 57344) { + if (!i2) { + if (r3 > 56319) { + (e3 -= 3) > -1 && o2.push(239, 191, 189); + continue; + } + if (a2 + 1 === n2) { + (e3 -= 3) > -1 && o2.push(239, 191, 189); + continue; + } + i2 = r3; + continue; + } + if (r3 < 56320) { + (e3 -= 3) > -1 && o2.push(239, 191, 189), i2 = r3; + continue; + } + r3 = 65536 + (i2 - 55296 << 10 | r3 - 56320); + } else + i2 && (e3 -= 3) > -1 && o2.push(239, 191, 189); + if (i2 = null, r3 < 128) { + if ((e3 -= 1) < 0) + break; + o2.push(r3); + } else if (r3 < 2048) { + if ((e3 -= 2) < 0) + break; + o2.push(r3 >> 6 | 192, 63 & r3 | 128); + } else if (r3 < 65536) { + if ((e3 -= 3) < 0) + break; + o2.push(r3 >> 12 | 224, r3 >> 6 & 63 | 128, 63 & r3 | 128); + } else { + if (!(r3 < 1114112)) + throw new Error("Invalid code point"); + if ((e3 -= 4) < 0) + break; + o2.push(r3 >> 18 | 240, r3 >> 12 & 63 | 128, r3 >> 6 & 63 | 128, 63 & r3 | 128); + } + } + return o2; + } + function J(t3) { + return n.toByteArray(function(t4) { + if ((t4 = (t4 = t4.split("=")[0]).trim().replace(V, "")).length < 2) + return ""; + for (; t4.length % 4 != 0; ) + t4 += "="; + return t4; + }(t3)); + } + function $(t3, e3, r3, n2) { + let i2; + for (i2 = 0; i2 < n2 && !(i2 + r3 >= e3.length || i2 >= t3.length); ++i2) + e3[i2 + r3] = t3[i2]; + return i2; + } + function G(t3, e3) { + return t3 instanceof e3 || t3 != null && t3.constructor != null && t3.constructor.name != null && t3.constructor.name === e3.name; + } + function Z(t3) { + return t3 != t3; + } + const Y = function() { + const t3 = "0123456789abcdef", e3 = new Array(256); + for (let r3 = 0; r3 < 16; ++r3) { + const n2 = 16 * r3; + for (let i2 = 0; i2 < 16; ++i2) + e3[n2 + i2] = t3[r3] + t3[i2]; + } + return e3; + }(); + function X(t3) { + return typeof BigInt == "undefined" ? Q : t3; + } + function Q() { + throw new Error("BigInt not supported"); + } + }, 1924: (t2, e2, r2) => { + var n = r2(210), i = r2(5559), o = i(n("String.prototype.indexOf")); + t2.exports = function(t3, e3) { + var r3 = n(t3, !!e3); + return typeof r3 == "function" && o(t3, ".prototype.") > -1 ? i(r3) : r3; + }; + }, 5559: (t2, e2, r2) => { + var n = r2(8612), i = r2(210), o = i("%Function.prototype.apply%"), a = i("%Function.prototype.call%"), s = i("%Reflect.apply%", true) || n.call(a, o), u = i("%Object.getOwnPropertyDescriptor%", true), f = i("%Object.defineProperty%", true), c = i("%Math.max%"); + if (f) + try { + f({}, "a", {value: 1}); + } catch (t3) { + f = null; + } + t2.exports = function(t3) { + var e3 = s(n, a, arguments); + if (u && f) { + var r3 = u(e3, "length"); + r3.configurable && f(e3, "length", {value: 1 + c(0, t3.length - (arguments.length - 1))}); + } + return e3; + }; + var h = function() { + return s(n, o, arguments); + }; + f ? f(t2.exports, "apply", {value: h}) : t2.exports.apply = h; + }, 1027: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(2830).Transform, o = r2(2553).s; + function a(t3) { + i.call(this), this.hashMode = typeof t3 == "string", this.hashMode ? this[t3] = this._finalOrDigest : this.final = this._finalOrDigest, this._final && (this.__final = this._final, this._final = null), this._decoder = null, this._encoding = null; + } + r2(5717)(a, i), a.prototype.update = function(t3, e3, r3) { + typeof t3 == "string" && (t3 = n.from(t3, e3)); + var i2 = this._update(t3); + return this.hashMode ? this : (r3 && (i2 = this._toString(i2, r3)), i2); + }, a.prototype.setAutoPadding = function() { + }, a.prototype.getAuthTag = function() { + throw new Error("trying to get auth tag in unsupported state"); + }, a.prototype.setAuthTag = function() { + throw new Error("trying to set auth tag in unsupported state"); + }, a.prototype.setAAD = function() { + throw new Error("trying to set aad in unsupported state"); + }, a.prototype._transform = function(t3, e3, r3) { + var n2; + try { + this.hashMode ? this._update(t3) : this.push(this._update(t3)); + } catch (t4) { + n2 = t4; + } finally { + r3(n2); + } + }, a.prototype._flush = function(t3) { + var e3; + try { + this.push(this.__final()); + } catch (t4) { + e3 = t4; + } + t3(e3); + }, a.prototype._finalOrDigest = function(t3) { + var e3 = this.__final() || n.alloc(0); + return t3 && (e3 = this._toString(e3, t3, true)), e3; + }, a.prototype._toString = function(t3, e3, r3) { + if (this._decoder || (this._decoder = new o(e3), this._encoding = e3), this._encoding !== e3) + throw new Error("can't switch encodings"); + var n2 = this._decoder.write(t3); + return r3 && (n2 += this._decoder.end()), n2; + }, t2.exports = a; + }, 6393: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(6266), o = r2(3550); + t2.exports = function(t3) { + return new s(t3); + }; + var a = {secp256k1: {name: "secp256k1", byteLength: 32}, secp224r1: {name: "p224", byteLength: 28}, prime256v1: {name: "p256", byteLength: 32}, prime192v1: {name: "p192", byteLength: 24}, ed25519: {name: "ed25519", byteLength: 32}, secp384r1: {name: "p384", byteLength: 48}, secp521r1: {name: "p521", byteLength: 66}}; + function s(t3) { + this.curveType = a[t3], this.curveType || (this.curveType = {name: t3}), this.curve = new i.ec(this.curveType.name), this.keys = void 0; + } + function u(t3, e3, r3) { + Array.isArray(t3) || (t3 = t3.toArray()); + var i2 = new n(t3); + if (r3 && i2.length < r3) { + var o2 = new n(r3 - i2.length); + o2.fill(0), i2 = n.concat([o2, i2]); + } + return e3 ? i2.toString(e3) : i2; + } + a.p224 = a.secp224r1, a.p256 = a.secp256r1 = a.prime256v1, a.p192 = a.secp192r1 = a.prime192v1, a.p384 = a.secp384r1, a.p521 = a.secp521r1, s.prototype.generateKeys = function(t3, e3) { + return this.keys = this.curve.genKeyPair(), this.getPublicKey(t3, e3); + }, s.prototype.computeSecret = function(t3, e3, r3) { + return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), u(this.curve.keyFromPublic(t3).getPublic().mul(this.keys.getPrivate()).getX(), r3, this.curveType.byteLength); + }, s.prototype.getPublicKey = function(t3, e3) { + var r3 = this.keys.getPublic(e3 === "compressed", true); + return e3 === "hybrid" && (r3[r3.length - 1] % 2 ? r3[0] = 7 : r3[0] = 6), u(r3, t3); + }, s.prototype.getPrivateKey = function(t3) { + return u(this.keys.getPrivate(), t3); + }, s.prototype.setPublicKey = function(t3, e3) { + return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this.keys._importPublic(t3), this; + }, s.prototype.setPrivateKey = function(t3, e3) { + e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)); + var r3 = new o(t3); + return r3 = r3.toString(16), this.keys = this.curve.genKeyPair(), this.keys._importPrivate(r3), this; + }; + }, 3482: (t2, e2, r2) => { + var n = r2(5717), i = r2(2318), o = r2(9785), a = r2(9072), s = r2(1027); + function u(t3) { + s.call(this, "digest"), this._hash = t3; + } + n(u, s), u.prototype._update = function(t3) { + this._hash.update(t3); + }, u.prototype._final = function() { + return this._hash.digest(); + }, t2.exports = function(t3) { + return (t3 = t3.toLowerCase()) === "md5" ? new i() : t3 === "rmd160" || t3 === "ripemd160" ? new o() : new u(a(t3)); + }; + }, 8028: (t2, e2, r2) => { + var n = r2(2318); + t2.exports = function(t3) { + return new n().update(t3).digest(); + }; + }, 8355: (t2, e2, r2) => { + var n = r2(5717), i = r2(1031), o = r2(1027), a = r2(9509).Buffer, s = r2(8028), u = r2(9785), f = r2(9072), c = a.alloc(128); + function h(t3, e3) { + o.call(this, "digest"), typeof e3 == "string" && (e3 = a.from(e3)); + var r3 = t3 === "sha512" || t3 === "sha384" ? 128 : 64; + this._alg = t3, this._key = e3, e3.length > r3 ? e3 = (t3 === "rmd160" ? new u() : f(t3)).update(e3).digest() : e3.length < r3 && (e3 = a.concat([e3, c], r3)); + for (var n2 = this._ipad = a.allocUnsafe(r3), i2 = this._opad = a.allocUnsafe(r3), s2 = 0; s2 < r3; s2++) + n2[s2] = 54 ^ e3[s2], i2[s2] = 92 ^ e3[s2]; + this._hash = t3 === "rmd160" ? new u() : f(t3), this._hash.update(n2); + } + n(h, o), h.prototype._update = function(t3) { + this._hash.update(t3); + }, h.prototype._final = function() { + var t3 = this._hash.digest(); + return (this._alg === "rmd160" ? new u() : f(this._alg)).update(this._opad).update(t3).digest(); + }, t2.exports = function(t3, e3) { + return (t3 = t3.toLowerCase()) === "rmd160" || t3 === "ripemd160" ? new h("rmd160", e3) : t3 === "md5" ? new i(s, e3) : new h(t3, e3); + }; + }, 1031: (t2, e2, r2) => { + var n = r2(5717), i = r2(9509).Buffer, o = r2(1027), a = i.alloc(128), s = 64; + function u(t3, e3) { + o.call(this, "digest"), typeof e3 == "string" && (e3 = i.from(e3)), this._alg = t3, this._key = e3, e3.length > s ? e3 = t3(e3) : e3.length < s && (e3 = i.concat([e3, a], s)); + for (var r3 = this._ipad = i.allocUnsafe(s), n2 = this._opad = i.allocUnsafe(s), u2 = 0; u2 < s; u2++) + r3[u2] = 54 ^ e3[u2], n2[u2] = 92 ^ e3[u2]; + this._hash = [r3]; + } + n(u, o), u.prototype._update = function(t3) { + this._hash.push(t3); + }, u.prototype._final = function() { + var t3 = this._alg(i.concat(this._hash)); + return this._alg(i.concat([this._opad, t3])); + }, t2.exports = u; + }, 5835: (t2, e2, r2) => { + e2.randomBytes = e2.rng = e2.pseudoRandomBytes = e2.prng = r2(1798), e2.createHash = e2.Hash = r2(3482), e2.createHmac = e2.Hmac = r2(8355); + var n = r2(6042), i = Object.keys(n), o = ["sha1", "sha224", "sha256", "sha384", "sha512", "md5", "rmd160"].concat(i); + e2.getHashes = function() { + return o; + }; + var a = r2(5632); + e2.pbkdf2 = a.pbkdf2, e2.pbkdf2Sync = a.pbkdf2Sync; + var s = r2(3614); + e2.Cipher = s.Cipher, e2.createCipher = s.createCipher, e2.Cipheriv = s.Cipheriv, e2.createCipheriv = s.createCipheriv, e2.Decipher = s.Decipher, e2.createDecipher = s.createDecipher, e2.Decipheriv = s.Decipheriv, e2.createDecipheriv = s.createDecipheriv, e2.getCiphers = s.getCiphers, e2.listCiphers = s.listCiphers; + var u = r2(2607); + e2.DiffieHellmanGroup = u.DiffieHellmanGroup, e2.createDiffieHellmanGroup = u.createDiffieHellmanGroup, e2.getDiffieHellman = u.getDiffieHellman, e2.createDiffieHellman = u.createDiffieHellman, e2.DiffieHellman = u.DiffieHellman; + var f = r2(4743); + e2.createSign = f.createSign, e2.Sign = f.Sign, e2.createVerify = f.createVerify, e2.Verify = f.Verify, e2.createECDH = r2(6393); + var c = r2(7900); + e2.publicEncrypt = c.publicEncrypt, e2.privateEncrypt = c.privateEncrypt, e2.publicDecrypt = c.publicDecrypt, e2.privateDecrypt = c.privateDecrypt; + var h = r2(7963); + e2.randomFill = h.randomFill, e2.randomFillSync = h.randomFillSync, e2.createCredentials = function() { + throw new Error(["sorry, createCredentials is not implemented yet", "we accept pull requests", "https://github.com/crypto-browserify/crypto-browserify"].join("\n")); + }, e2.constants = {DH_CHECK_P_NOT_SAFE_PRIME: 2, DH_CHECK_P_NOT_PRIME: 1, DH_UNABLE_TO_CHECK_GENERATOR: 4, DH_NOT_SUITABLE_GENERATOR: 8, NPN_ENABLED: 1, ALPN_ENABLED: 1, RSA_PKCS1_PADDING: 1, RSA_SSLV23_PADDING: 2, RSA_NO_PADDING: 3, RSA_PKCS1_OAEP_PADDING: 4, RSA_X931_PADDING: 5, RSA_PKCS1_PSS_PADDING: 6, POINT_CONVERSION_COMPRESSED: 2, POINT_CONVERSION_UNCOMPRESSED: 4, POINT_CONVERSION_HYBRID: 6}; + }, 4289: (t2, e2, r2) => { + var n = r2(2215), i = typeof Symbol == "function" && typeof Symbol("foo") == "symbol", o = Object.prototype.toString, a = Array.prototype.concat, s = Object.defineProperty, u = s && function() { + var t3 = {}; + try { + for (var e3 in s(t3, "x", {enumerable: false, value: t3}), t3) + return false; + return t3.x === t3; + } catch (t4) { + return false; + } + }(), f = function(t3, e3, r3, n2) { + var i2; + (!(e3 in t3) || typeof (i2 = n2) == "function" && o.call(i2) === "[object Function]" && n2()) && (u ? s(t3, e3, {configurable: true, enumerable: false, value: r3, writable: true}) : t3[e3] = r3); + }, c = function(t3, e3) { + var r3 = arguments.length > 2 ? arguments[2] : {}, o2 = n(e3); + i && (o2 = a.call(o2, Object.getOwnPropertySymbols(e3))); + for (var s2 = 0; s2 < o2.length; s2 += 1) + f(t3, o2[s2], e3[o2[s2]], r3[o2[s2]]); + }; + c.supportsDescriptors = !!u, t2.exports = c; + }, 5251: (t2, e2, r2) => { + e2.utils = r2(1278), e2.Cipher = r2(5756), e2.DES = r2(778), e2.CBC = r2(9051), e2.EDE = r2(651); + }, 9051: (t2, e2, r2) => { + var n = r2(9746), i = r2(5717), o = {}; + function a(t3) { + n.equal(t3.length, 8, "Invalid IV length"), this.iv = new Array(8); + for (var e3 = 0; e3 < this.iv.length; e3++) + this.iv[e3] = t3[e3]; + } + e2.instantiate = function(t3) { + function e3(e4) { + t3.call(this, e4), this._cbcInit(); + } + i(e3, t3); + for (var r3 = Object.keys(o), n2 = 0; n2 < r3.length; n2++) { + var a2 = r3[n2]; + e3.prototype[a2] = o[a2]; + } + return e3.create = function(t4) { + return new e3(t4); + }, e3; + }, o._cbcInit = function() { + var t3 = new a(this.options.iv); + this._cbcState = t3; + }, o._update = function(t3, e3, r3, n2) { + var i2 = this._cbcState, o2 = this.constructor.super_.prototype, a2 = i2.iv; + if (this.type === "encrypt") { + for (var s = 0; s < this.blockSize; s++) + a2[s] ^= t3[e3 + s]; + for (o2._update.call(this, a2, 0, r3, n2), s = 0; s < this.blockSize; s++) + a2[s] = r3[n2 + s]; + } else { + for (o2._update.call(this, t3, e3, r3, n2), s = 0; s < this.blockSize; s++) + r3[n2 + s] ^= a2[s]; + for (s = 0; s < this.blockSize; s++) + a2[s] = t3[e3 + s]; + } + }; + }, 5756: (t2, e2, r2) => { + var n = r2(9746); + function i(t3) { + this.options = t3, this.type = this.options.type, this.blockSize = 8, this._init(), this.buffer = new Array(this.blockSize), this.bufferOff = 0; + } + t2.exports = i, i.prototype._init = function() { + }, i.prototype.update = function(t3) { + return t3.length === 0 ? [] : this.type === "decrypt" ? this._updateDecrypt(t3) : this._updateEncrypt(t3); + }, i.prototype._buffer = function(t3, e3) { + for (var r3 = Math.min(this.buffer.length - this.bufferOff, t3.length - e3), n2 = 0; n2 < r3; n2++) + this.buffer[this.bufferOff + n2] = t3[e3 + n2]; + return this.bufferOff += r3, r3; + }, i.prototype._flushBuffer = function(t3, e3) { + return this._update(this.buffer, 0, t3, e3), this.bufferOff = 0, this.blockSize; + }, i.prototype._updateEncrypt = function(t3) { + var e3 = 0, r3 = 0, n2 = (this.bufferOff + t3.length) / this.blockSize | 0, i2 = new Array(n2 * this.blockSize); + this.bufferOff !== 0 && (e3 += this._buffer(t3, e3), this.bufferOff === this.buffer.length && (r3 += this._flushBuffer(i2, r3))); + for (var o = t3.length - (t3.length - e3) % this.blockSize; e3 < o; e3 += this.blockSize) + this._update(t3, e3, i2, r3), r3 += this.blockSize; + for (; e3 < t3.length; e3++, this.bufferOff++) + this.buffer[this.bufferOff] = t3[e3]; + return i2; + }, i.prototype._updateDecrypt = function(t3) { + for (var e3 = 0, r3 = 0, n2 = Math.ceil((this.bufferOff + t3.length) / this.blockSize) - 1, i2 = new Array(n2 * this.blockSize); n2 > 0; n2--) + e3 += this._buffer(t3, e3), r3 += this._flushBuffer(i2, r3); + return e3 += this._buffer(t3, e3), i2; + }, i.prototype.final = function(t3) { + var e3, r3; + return t3 && (e3 = this.update(t3)), r3 = this.type === "encrypt" ? this._finalEncrypt() : this._finalDecrypt(), e3 ? e3.concat(r3) : r3; + }, i.prototype._pad = function(t3, e3) { + if (e3 === 0) + return false; + for (; e3 < t3.length; ) + t3[e3++] = 0; + return true; + }, i.prototype._finalEncrypt = function() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + var t3 = new Array(this.blockSize); + return this._update(this.buffer, 0, t3, 0), t3; + }, i.prototype._unpad = function(t3) { + return t3; + }, i.prototype._finalDecrypt = function() { + n.equal(this.bufferOff, this.blockSize, "Not enough data to decrypt"); + var t3 = new Array(this.blockSize); + return this._flushBuffer(t3, 0), this._unpad(t3); + }; + }, 778: (t2, e2, r2) => { + var n = r2(9746), i = r2(5717), o = r2(1278), a = r2(5756); + function s() { + this.tmp = new Array(2), this.keys = null; + } + function u(t3) { + a.call(this, t3); + var e3 = new s(); + this._desState = e3, this.deriveKeys(e3, t3.key); + } + i(u, a), t2.exports = u, u.create = function(t3) { + return new u(t3); + }; + var f = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]; + u.prototype.deriveKeys = function(t3, e3) { + t3.keys = new Array(32), n.equal(e3.length, this.blockSize, "Invalid key length"); + var r3 = o.readUInt32BE(e3, 0), i2 = o.readUInt32BE(e3, 4); + o.pc1(r3, i2, t3.tmp, 0), r3 = t3.tmp[0], i2 = t3.tmp[1]; + for (var a2 = 0; a2 < t3.keys.length; a2 += 2) { + var s2 = f[a2 >>> 1]; + r3 = o.r28shl(r3, s2), i2 = o.r28shl(i2, s2), o.pc2(r3, i2, t3.keys, a2); + } + }, u.prototype._update = function(t3, e3, r3, n2) { + var i2 = this._desState, a2 = o.readUInt32BE(t3, e3), s2 = o.readUInt32BE(t3, e3 + 4); + o.ip(a2, s2, i2.tmp, 0), a2 = i2.tmp[0], s2 = i2.tmp[1], this.type === "encrypt" ? this._encrypt(i2, a2, s2, i2.tmp, 0) : this._decrypt(i2, a2, s2, i2.tmp, 0), a2 = i2.tmp[0], s2 = i2.tmp[1], o.writeUInt32BE(r3, a2, n2), o.writeUInt32BE(r3, s2, n2 + 4); + }, u.prototype._pad = function(t3, e3) { + for (var r3 = t3.length - e3, n2 = e3; n2 < t3.length; n2++) + t3[n2] = r3; + return true; + }, u.prototype._unpad = function(t3) { + for (var e3 = t3[t3.length - 1], r3 = t3.length - e3; r3 < t3.length; r3++) + n.equal(t3[r3], e3); + return t3.slice(0, t3.length - e3); + }, u.prototype._encrypt = function(t3, e3, r3, n2, i2) { + for (var a2 = e3, s2 = r3, u2 = 0; u2 < t3.keys.length; u2 += 2) { + var f2 = t3.keys[u2], c = t3.keys[u2 + 1]; + o.expand(s2, t3.tmp, 0), f2 ^= t3.tmp[0], c ^= t3.tmp[1]; + var h = o.substitute(f2, c), l = s2; + s2 = (a2 ^ o.permute(h)) >>> 0, a2 = l; + } + o.rip(s2, a2, n2, i2); + }, u.prototype._decrypt = function(t3, e3, r3, n2, i2) { + for (var a2 = r3, s2 = e3, u2 = t3.keys.length - 2; u2 >= 0; u2 -= 2) { + var f2 = t3.keys[u2], c = t3.keys[u2 + 1]; + o.expand(a2, t3.tmp, 0), f2 ^= t3.tmp[0], c ^= t3.tmp[1]; + var h = o.substitute(f2, c), l = a2; + a2 = (s2 ^ o.permute(h)) >>> 0, s2 = l; + } + o.rip(a2, s2, n2, i2); + }; + }, 651: (t2, e2, r2) => { + var n = r2(9746), i = r2(5717), o = r2(5756), a = r2(778); + function s(t3, e3) { + n.equal(e3.length, 24, "Invalid key length"); + var r3 = e3.slice(0, 8), i2 = e3.slice(8, 16), o2 = e3.slice(16, 24); + this.ciphers = t3 === "encrypt" ? [a.create({type: "encrypt", key: r3}), a.create({type: "decrypt", key: i2}), a.create({type: "encrypt", key: o2})] : [a.create({type: "decrypt", key: o2}), a.create({type: "encrypt", key: i2}), a.create({type: "decrypt", key: r3})]; + } + function u(t3) { + o.call(this, t3); + var e3 = new s(this.type, this.options.key); + this._edeState = e3; + } + i(u, o), t2.exports = u, u.create = function(t3) { + return new u(t3); + }, u.prototype._update = function(t3, e3, r3, n2) { + var i2 = this._edeState; + i2.ciphers[0]._update(t3, e3, r3, n2), i2.ciphers[1]._update(r3, n2, r3, n2), i2.ciphers[2]._update(r3, n2, r3, n2); + }, u.prototype._pad = a.prototype._pad, u.prototype._unpad = a.prototype._unpad; + }, 1278: (t2, e2) => { + e2.readUInt32BE = function(t3, e3) { + return (t3[0 + e3] << 24 | t3[1 + e3] << 16 | t3[2 + e3] << 8 | t3[3 + e3]) >>> 0; + }, e2.writeUInt32BE = function(t3, e3, r3) { + t3[0 + r3] = e3 >>> 24, t3[1 + r3] = e3 >>> 16 & 255, t3[2 + r3] = e3 >>> 8 & 255, t3[3 + r3] = 255 & e3; + }, e2.ip = function(t3, e3, r3, n2) { + for (var i2 = 0, o = 0, a = 6; a >= 0; a -= 2) { + for (var s = 0; s <= 24; s += 8) + i2 <<= 1, i2 |= e3 >>> s + a & 1; + for (s = 0; s <= 24; s += 8) + i2 <<= 1, i2 |= t3 >>> s + a & 1; + } + for (a = 6; a >= 0; a -= 2) { + for (s = 1; s <= 25; s += 8) + o <<= 1, o |= e3 >>> s + a & 1; + for (s = 1; s <= 25; s += 8) + o <<= 1, o |= t3 >>> s + a & 1; + } + r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; + }, e2.rip = function(t3, e3, r3, n2) { + for (var i2 = 0, o = 0, a = 0; a < 4; a++) + for (var s = 24; s >= 0; s -= 8) + i2 <<= 1, i2 |= e3 >>> s + a & 1, i2 <<= 1, i2 |= t3 >>> s + a & 1; + for (a = 4; a < 8; a++) + for (s = 24; s >= 0; s -= 8) + o <<= 1, o |= e3 >>> s + a & 1, o <<= 1, o |= t3 >>> s + a & 1; + r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; + }, e2.pc1 = function(t3, e3, r3, n2) { + for (var i2 = 0, o = 0, a = 7; a >= 5; a--) { + for (var s = 0; s <= 24; s += 8) + i2 <<= 1, i2 |= e3 >> s + a & 1; + for (s = 0; s <= 24; s += 8) + i2 <<= 1, i2 |= t3 >> s + a & 1; + } + for (s = 0; s <= 24; s += 8) + i2 <<= 1, i2 |= e3 >> s + a & 1; + for (a = 1; a <= 3; a++) { + for (s = 0; s <= 24; s += 8) + o <<= 1, o |= e3 >> s + a & 1; + for (s = 0; s <= 24; s += 8) + o <<= 1, o |= t3 >> s + a & 1; + } + for (s = 0; s <= 24; s += 8) + o <<= 1, o |= t3 >> s + a & 1; + r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; + }, e2.r28shl = function(t3, e3) { + return t3 << e3 & 268435455 | t3 >>> 28 - e3; + }; + var r2 = [14, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, 15, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24]; + e2.pc2 = function(t3, e3, n2, i2) { + for (var o = 0, a = 0, s = r2.length >>> 1, u = 0; u < s; u++) + o <<= 1, o |= t3 >>> r2[u] & 1; + for (u = s; u < r2.length; u++) + a <<= 1, a |= e3 >>> r2[u] & 1; + n2[i2 + 0] = o >>> 0, n2[i2 + 1] = a >>> 0; + }, e2.expand = function(t3, e3, r3) { + var n2 = 0, i2 = 0; + n2 = (1 & t3) << 5 | t3 >>> 27; + for (var o = 23; o >= 15; o -= 4) + n2 <<= 6, n2 |= t3 >>> o & 63; + for (o = 11; o >= 3; o -= 4) + i2 |= t3 >>> o & 63, i2 <<= 6; + i2 |= (31 & t3) << 1 | t3 >>> 31, e3[r3 + 0] = n2 >>> 0, e3[r3 + 1] = i2 >>> 0; + }; + var n = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11]; + e2.substitute = function(t3, e3) { + for (var r3 = 0, i2 = 0; i2 < 4; i2++) + r3 <<= 4, r3 |= n[64 * i2 + (t3 >>> 18 - 6 * i2 & 63)]; + for (i2 = 0; i2 < 4; i2++) + r3 <<= 4, r3 |= n[256 + 64 * i2 + (e3 >>> 18 - 6 * i2 & 63)]; + return r3 >>> 0; + }; + var i = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7]; + e2.permute = function(t3) { + for (var e3 = 0, r3 = 0; r3 < i.length; r3++) + e3 <<= 1, e3 |= t3 >>> i[r3] & 1; + return e3 >>> 0; + }, e2.padSplit = function(t3, e3, r3) { + for (var n2 = t3.toString(2); n2.length < e3; ) + n2 = "0" + n2; + for (var i2 = [], o = 0; o < e3; o += r3) + i2.push(n2.slice(o, o + r3)); + return i2.join(" "); + }; + }, 2607: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(3590), o = r2(1930), a = r2(7426), s = {binary: true, hex: true, base64: true}; + e2.DiffieHellmanGroup = e2.createDiffieHellmanGroup = e2.getDiffieHellman = function(t3) { + var e3 = new n(o[t3].prime, "hex"), r3 = new n(o[t3].gen, "hex"); + return new a(e3, r3); + }, e2.createDiffieHellman = e2.DiffieHellman = function t3(e3, r3, o2, u) { + return n.isBuffer(r3) || s[r3] === void 0 ? t3(e3, "binary", r3, o2) : (r3 = r3 || "binary", u = u || "binary", o2 = o2 || new n([2]), n.isBuffer(o2) || (o2 = new n(o2, u)), typeof e3 == "number" ? new a(i(e3, o2), o2, true) : (n.isBuffer(e3) || (e3 = new n(e3, r3)), new a(e3, o2, true))); + }; + }, 7426: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(3550), o = new (r2(3047))(), a = new i(24), s = new i(11), u = new i(10), f = new i(3), c = new i(7), h = r2(3590), l = r2(1798); + function d(t3, e3) { + return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this._pub = new i(t3), this; + } + function p(t3, e3) { + return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this._priv = new i(t3), this; + } + t2.exports = m; + var y = {}; + function m(t3, e3, r3) { + this.setGenerator(e3), this.__prime = new i(t3), this._prime = i.mont(this.__prime), this._primeLen = t3.length, this._pub = void 0, this._priv = void 0, this._primeCode = void 0, r3 ? (this.setPublicKey = d, this.setPrivateKey = p) : this._primeCode = 8; + } + function b(t3, e3) { + var r3 = new n(t3.toArray()); + return e3 ? r3.toString(e3) : r3; + } + Object.defineProperty(m.prototype, "verifyError", {enumerable: true, get: function() { + return typeof this._primeCode != "number" && (this._primeCode = function(t3, e3) { + var r3 = e3.toString("hex"), n2 = [r3, t3.toString(16)].join("_"); + if (n2 in y) + return y[n2]; + var i2, l2 = 0; + if (t3.isEven() || !h.simpleSieve || !h.fermatTest(t3) || !o.test(t3)) + return l2 += 1, l2 += r3 === "02" || r3 === "05" ? 8 : 4, y[n2] = l2, l2; + switch (o.test(t3.shrn(1)) || (l2 += 2), r3) { + case "02": + t3.mod(a).cmp(s) && (l2 += 8); + break; + case "05": + (i2 = t3.mod(u)).cmp(f) && i2.cmp(c) && (l2 += 8); + break; + default: + l2 += 4; + } + return y[n2] = l2, l2; + }(this.__prime, this.__gen)), this._primeCode; + }}), m.prototype.generateKeys = function() { + return this._priv || (this._priv = new i(l(this._primeLen))), this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(), this.getPublicKey(); + }, m.prototype.computeSecret = function(t3) { + var e3 = (t3 = (t3 = new i(t3)).toRed(this._prime)).redPow(this._priv).fromRed(), r3 = new n(e3.toArray()), o2 = this.getPrime(); + if (r3.length < o2.length) { + var a2 = new n(o2.length - r3.length); + a2.fill(0), r3 = n.concat([a2, r3]); + } + return r3; + }, m.prototype.getPublicKey = function(t3) { + return b(this._pub, t3); + }, m.prototype.getPrivateKey = function(t3) { + return b(this._priv, t3); + }, m.prototype.getPrime = function(t3) { + return b(this.__prime, t3); + }, m.prototype.getGenerator = function(t3) { + return b(this._gen, t3); + }, m.prototype.setGenerator = function(t3, e3) { + return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this.__gen = t3, this._gen = new i(t3), this; + }; + }, 3590: (t2, e2, r2) => { + var n = r2(1798); + t2.exports = g, g.simpleSieve = m, g.fermatTest = b; + var i = r2(3550), o = new i(24), a = new (r2(3047))(), s = new i(1), u = new i(2), f = new i(5), c = (new i(16), new i(8), new i(10)), h = new i(3), l = (new i(7), new i(11)), d = new i(4), p = (new i(12), null); + function y() { + if (p !== null) + return p; + var t3 = []; + t3[0] = 2; + for (var e3 = 1, r3 = 3; r3 < 1048576; r3 += 2) { + for (var n2 = Math.ceil(Math.sqrt(r3)), i2 = 0; i2 < e3 && t3[i2] <= n2 && r3 % t3[i2] != 0; i2++) + ; + e3 !== i2 && t3[i2] <= n2 || (t3[e3++] = r3); + } + return p = t3, t3; + } + function m(t3) { + for (var e3 = y(), r3 = 0; r3 < e3.length; r3++) + if (t3.modn(e3[r3]) === 0) + return t3.cmpn(e3[r3]) === 0; + return true; + } + function b(t3) { + var e3 = i.mont(t3); + return u.toRed(e3).redPow(t3.subn(1)).fromRed().cmpn(1) === 0; + } + function g(t3, e3) { + if (t3 < 16) + return new i(e3 === 2 || e3 === 5 ? [140, 123] : [140, 39]); + var r3, p2; + for (e3 = new i(e3); ; ) { + for (r3 = new i(n(Math.ceil(t3 / 8))); r3.bitLength() > t3; ) + r3.ishrn(1); + if (r3.isEven() && r3.iadd(s), r3.testn(1) || r3.iadd(u), e3.cmp(u)) { + if (!e3.cmp(f)) + for (; r3.mod(c).cmp(h); ) + r3.iadd(d); + } else + for (; r3.mod(o).cmp(l); ) + r3.iadd(d); + if (m(p2 = r3.shrn(1)) && m(r3) && b(p2) && b(r3) && a.test(p2) && a.test(r3)) + return r3; + } + } + }, 1930: (t2) => { + t2.exports = JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}'); + }, 6215: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = new (r2(6266)).ec("secp256k1"), o = r2.g.crypto || r2.g.msCrypto || {}, a = o.subtle || o.webkitSubtle, s = r2(5835); + const u = n.from("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", "hex"), f = n.alloc(32, 0); + function c(t3, e3) { + if (!t3) + throw new Error(e3 || "Assertion failed"); + } + function h(t3) { + return e3 = t3, !(!n.isBuffer(e3) || e3.length !== 32) && t3.compare(f) > 0 && t3.compare(u) < 0; + var e3; + } + function l(t3) { + var e3 = new Uint8Array(t3); + return o.getRandomValues === void 0 ? n.from(s.randomBytes(t3)) : (o.getRandomValues(e3), n.from(e3)); + } + function d(t3) { + return new Promise(function(e3) { + var r3 = s.createHash("sha512").update(t3).digest(); + e3(new Uint8Array(r3)); + }); + } + function p(t3) { + return function(e3, r3, i2) { + return new Promise(function(o2) { + if (a) + return a.importKey("raw", r3, {name: "AES-CBC"}, false, [t3]).then(function(r4) { + var n2 = {name: "AES-CBC", iv: e3}; + return a[t3](n2, r4, i2); + }).then(function(t4) { + o2(n.from(new Uint8Array(t4))); + }); + if (t3 === "encrypt") { + var u2 = s.createCipheriv("aes-256-cbc", r3, e3); + let t4 = u2.update(i2), a2 = u2.final(); + o2(n.concat([t4, a2])); + } else if (t3 === "decrypt") { + var f2 = s.createDecipheriv("aes-256-cbc", r3, e3); + let t4 = f2.update(i2), a2 = f2.final(); + o2(n.concat([t4, a2])); + } + }); + }; + } + var y = p("encrypt"), m = p("decrypt"); + e2.generatePrivate = function() { + for (var t3 = l(32); !h(t3); ) + t3 = l(32); + return t3; + }; + var b = e2.getPublic = function(t3) { + return c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), n.from(i.keyFromPrivate(t3).getPublic("arr")); + }; + e2.getPublicCompressed = function(t3) { + return c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), n.from(i.keyFromPrivate(t3).getPublic(true, "arr")); + }, e2.sign = function(t3, e3) { + return new Promise(function(r3) { + c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), c(e3.length > 0, "Message should not be empty"), c(e3.length <= 32, "Message is too long"), r3(n.from(i.sign(e3, t3, {canonical: true}).toDER())); + }); + }, e2.verify = function(t3, e3, r3) { + return new Promise(function(n2, o2) { + c(t3.length === 65 || t3.length === 33, "Bad public key"), t3.length === 65 && c(t3[0] === 4, "Bad public key"), t3.length === 33 && c(t3[0] === 2 || t3[0] === 3, "Bad public key"), c(e3.length > 0, "Message should not be empty"), c(e3.length <= 32, "Message is too long"), i.verify(e3, r3, t3) ? n2(null) : o2(new Error("Bad signature")); + }); + }; + var g = e2.derive = function(t3, e3) { + return new Promise(function(r3) { + c(n.isBuffer(t3), "Bad private key"), c(n.isBuffer(e3), "Bad public key"), c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), c(e3.length === 65 || e3.length === 33, "Bad public key"), e3.length === 65 && c(e3[0] === 4, "Bad public key"), e3.length === 33 && c(e3[0] === 2 || e3[0] === 3, "Bad public key"); + var o2 = i.keyFromPrivate(t3), a2 = i.keyFromPublic(e3), s2 = o2.derive(a2.getPublic()); + r3(n.from(s2.toArray())); + }); + }; + e2.encrypt = function(t3, e3, r3) { + var i2, o2, a2, u2; + return r3 = r3 || {}, new Promise(function(e4) { + for (var n2 = r3.ephemPrivateKey || l(32); !h(n2); ) + n2 = r3.ephemPrivateKey || l(32); + o2 = b(n2), e4(g(n2, t3)); + }).then(function(t4) { + return d(t4); + }).then(function(t4) { + i2 = r3.iv || l(16); + var n2 = t4.slice(0, 32); + return u2 = t4.slice(32), y(i2, n2, e3); + }).then(function(t4) { + a2 = t4; + var e4 = n.concat([i2, o2, a2]); + return function(t5, e5) { + return new Promise(function(r4) { + var i3 = s.createHmac("sha256", n.from(t5)); + i3.update(e5), r4(i3.digest()); + }); + }(u2, e4); + }).then(function(t4) { + return {iv: i2, ephemPublicKey: o2, ciphertext: a2, mac: t4}; + }); + }, e2.decrypt = function(t3, e3) { + var r3; + return g(t3, e3.ephemPublicKey).then(function(t4) { + return d(t4); + }).then(function(t4) { + r3 = t4.slice(0, 32); + var i2, o2, a2, u2 = t4.slice(32), f2 = n.concat([e3.iv, e3.ephemPublicKey, e3.ciphertext]); + return i2 = u2, o2 = f2, a2 = e3.mac, new Promise(function(t5) { + var e4 = s.createHmac("sha256", n.from(i2)); + e4.update(o2), t5(function(t6, e5) { + if (t6.length !== e5.length) + return false; + for (var r4 = 0, n2 = 0; n2 < t6.length; n2++) + r4 |= t6[n2] ^ e5[n2]; + return r4 === 0; + }(e4.digest(), a2)); + }); + }).then(function(t4) { + return c(t4, "Bad MAC"), m(e3.iv, r3, e3.ciphertext); + }).then(function(t4) { + return n.from(new Uint8Array(t4)); + }); + }; + }, 6266: (t2, e2, r2) => { + var n = e2; + n.version = r2(7519).i8, n.utils = r2(953), n.rand = r2(7376), n.curve = r2(8254), n.curves = r2(5427), n.ec = r2(7954), n.eddsa = r2(5980); + }, 4918: (t2, e2, r2) => { + var n = r2(3550), i = r2(953), o = i.getNAF, a = i.getJSF, s = i.assert; + function u(t3, e3) { + this.type = t3, this.p = new n(e3.p, 16), this.red = e3.prime ? n.red(e3.prime) : n.mont(this.p), this.zero = new n(0).toRed(this.red), this.one = new n(1).toRed(this.red), this.two = new n(2).toRed(this.red), this.n = e3.n && new n(e3.n, 16), this.g = e3.g && this.pointFromJSON(e3.g, e3.gRed), this._wnafT1 = new Array(4), this._wnafT2 = new Array(4), this._wnafT3 = new Array(4), this._wnafT4 = new Array(4), this._bitLength = this.n ? this.n.bitLength() : 0; + var r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + function f(t3, e3) { + this.curve = t3, this.type = e3, this.precomputed = null; + } + t2.exports = u, u.prototype.point = function() { + throw new Error("Not implemented"); + }, u.prototype.validate = function() { + throw new Error("Not implemented"); + }, u.prototype._fixedNafMul = function(t3, e3) { + s(t3.precomputed); + var r3 = t3._getDoubles(), n2 = o(e3, 1, this._bitLength), i2 = (1 << r3.step + 1) - (r3.step % 2 == 0 ? 2 : 1); + i2 /= 3; + var a2, u2, f2 = []; + for (a2 = 0; a2 < n2.length; a2 += r3.step) { + u2 = 0; + for (var c = a2 + r3.step - 1; c >= a2; c--) + u2 = (u2 << 1) + n2[c]; + f2.push(u2); + } + for (var h = this.jpoint(null, null, null), l = this.jpoint(null, null, null), d = i2; d > 0; d--) { + for (a2 = 0; a2 < f2.length; a2++) + (u2 = f2[a2]) === d ? l = l.mixedAdd(r3.points[a2]) : u2 === -d && (l = l.mixedAdd(r3.points[a2].neg())); + h = h.add(l); + } + return h.toP(); + }, u.prototype._wnafMul = function(t3, e3) { + var r3 = 4, n2 = t3._getNAFPoints(r3); + r3 = n2.wnd; + for (var i2 = n2.points, a2 = o(e3, r3, this._bitLength), u2 = this.jpoint(null, null, null), f2 = a2.length - 1; f2 >= 0; f2--) { + for (var c = 0; f2 >= 0 && a2[f2] === 0; f2--) + c++; + if (f2 >= 0 && c++, u2 = u2.dblp(c), f2 < 0) + break; + var h = a2[f2]; + s(h !== 0), u2 = t3.type === "affine" ? h > 0 ? u2.mixedAdd(i2[h - 1 >> 1]) : u2.mixedAdd(i2[-h - 1 >> 1].neg()) : h > 0 ? u2.add(i2[h - 1 >> 1]) : u2.add(i2[-h - 1 >> 1].neg()); + } + return t3.type === "affine" ? u2.toP() : u2; + }, u.prototype._wnafMulAdd = function(t3, e3, r3, n2, i2) { + var s2, u2, f2, c = this._wnafT1, h = this._wnafT2, l = this._wnafT3, d = 0; + for (s2 = 0; s2 < n2; s2++) { + var p = (f2 = e3[s2])._getNAFPoints(t3); + c[s2] = p.wnd, h[s2] = p.points; + } + for (s2 = n2 - 1; s2 >= 1; s2 -= 2) { + var y = s2 - 1, m = s2; + if (c[y] === 1 && c[m] === 1) { + var b = [e3[y], null, null, e3[m]]; + e3[y].y.cmp(e3[m].y) === 0 ? (b[1] = e3[y].add(e3[m]), b[2] = e3[y].toJ().mixedAdd(e3[m].neg())) : e3[y].y.cmp(e3[m].y.redNeg()) === 0 ? (b[1] = e3[y].toJ().mixedAdd(e3[m]), b[2] = e3[y].add(e3[m].neg())) : (b[1] = e3[y].toJ().mixedAdd(e3[m]), b[2] = e3[y].toJ().mixedAdd(e3[m].neg())); + var g = [-3, -1, -5, -7, 0, 7, 5, 1, 3], v = a(r3[y], r3[m]); + for (d = Math.max(v[0].length, d), l[y] = new Array(d), l[m] = new Array(d), u2 = 0; u2 < d; u2++) { + var w = 0 | v[0][u2], _ = 0 | v[1][u2]; + l[y][u2] = g[3 * (w + 1) + (_ + 1)], l[m][u2] = 0, h[y] = b; + } + } else + l[y] = o(r3[y], c[y], this._bitLength), l[m] = o(r3[m], c[m], this._bitLength), d = Math.max(l[y].length, d), d = Math.max(l[m].length, d); + } + var M = this.jpoint(null, null, null), S = this._wnafT4; + for (s2 = d; s2 >= 0; s2--) { + for (var E = 0; s2 >= 0; ) { + var A = true; + for (u2 = 0; u2 < n2; u2++) + S[u2] = 0 | l[u2][s2], S[u2] !== 0 && (A = false); + if (!A) + break; + E++, s2--; + } + if (s2 >= 0 && E++, M = M.dblp(E), s2 < 0) + break; + for (u2 = 0; u2 < n2; u2++) { + var k = S[u2]; + k !== 0 && (k > 0 ? f2 = h[u2][k - 1 >> 1] : k < 0 && (f2 = h[u2][-k - 1 >> 1].neg()), M = f2.type === "affine" ? M.mixedAdd(f2) : M.add(f2)); + } + } + for (s2 = 0; s2 < n2; s2++) + h[s2] = null; + return i2 ? M : M.toP(); + }, u.BasePoint = f, f.prototype.eq = function() { + throw new Error("Not implemented"); + }, f.prototype.validate = function() { + return this.curve.validate(this); + }, u.prototype.decodePoint = function(t3, e3) { + t3 = i.toArray(t3, e3); + var r3 = this.p.byteLength(); + if ((t3[0] === 4 || t3[0] === 6 || t3[0] === 7) && t3.length - 1 == 2 * r3) + return t3[0] === 6 ? s(t3[t3.length - 1] % 2 == 0) : t3[0] === 7 && s(t3[t3.length - 1] % 2 == 1), this.point(t3.slice(1, 1 + r3), t3.slice(1 + r3, 1 + 2 * r3)); + if ((t3[0] === 2 || t3[0] === 3) && t3.length - 1 === r3) + return this.pointFromX(t3.slice(1, 1 + r3), t3[0] === 3); + throw new Error("Unknown point format"); + }, f.prototype.encodeCompressed = function(t3) { + return this.encode(t3, true); + }, f.prototype._encode = function(t3) { + var e3 = this.curve.p.byteLength(), r3 = this.getX().toArray("be", e3); + return t3 ? [this.getY().isEven() ? 2 : 3].concat(r3) : [4].concat(r3, this.getY().toArray("be", e3)); + }, f.prototype.encode = function(t3, e3) { + return i.encode(this._encode(e3), t3); + }, f.prototype.precompute = function(t3) { + if (this.precomputed) + return this; + var e3 = {doubles: null, naf: null, beta: null}; + return e3.naf = this._getNAFPoints(8), e3.doubles = this._getDoubles(4, t3), e3.beta = this._getBeta(), this.precomputed = e3, this; + }, f.prototype._hasDoubles = function(t3) { + if (!this.precomputed) + return false; + var e3 = this.precomputed.doubles; + return !!e3 && e3.points.length >= Math.ceil((t3.bitLength() + 1) / e3.step); + }, f.prototype._getDoubles = function(t3, e3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var r3 = [this], n2 = this, i2 = 0; i2 < e3; i2 += t3) { + for (var o2 = 0; o2 < t3; o2++) + n2 = n2.dbl(); + r3.push(n2); + } + return {step: t3, points: r3}; + }, f.prototype._getNAFPoints = function(t3) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var e3 = [this], r3 = (1 << t3) - 1, n2 = r3 === 1 ? null : this.dbl(), i2 = 1; i2 < r3; i2++) + e3[i2] = e3[i2 - 1].add(n2); + return {wnd: t3, points: e3}; + }, f.prototype._getBeta = function() { + return null; + }, f.prototype.dblp = function(t3) { + for (var e3 = this, r3 = 0; r3 < t3; r3++) + e3 = e3.dbl(); + return e3; + }; + }, 1138: (t2, e2, r2) => { + var n = r2(953), i = r2(3550), o = r2(5717), a = r2(4918), s = n.assert; + function u(t3) { + this.twisted = (0 | t3.a) != 1, this.mOneA = this.twisted && (0 | t3.a) == -1, this.extended = this.mOneA, a.call(this, "edwards", t3), this.a = new i(t3.a, 16).umod(this.red.m), this.a = this.a.toRed(this.red), this.c = new i(t3.c, 16).toRed(this.red), this.c2 = this.c.redSqr(), this.d = new i(t3.d, 16).toRed(this.red), this.dd = this.d.redAdd(this.d), s(!this.twisted || this.c.fromRed().cmpn(1) === 0), this.oneC = (0 | t3.c) == 1; + } + function f(t3, e3, r3, n2, o2) { + a.BasePoint.call(this, t3, "projective"), e3 === null && r3 === null && n2 === null ? (this.x = this.curve.zero, this.y = this.curve.one, this.z = this.curve.one, this.t = this.curve.zero, this.zOne = true) : (this.x = new i(e3, 16), this.y = new i(r3, 16), this.z = n2 ? new i(n2, 16) : this.curve.one, this.t = o2 && new i(o2, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.t && !this.t.red && (this.t = this.t.toRed(this.curve.red)), this.zOne = this.z === this.curve.one, this.curve.extended && !this.t && (this.t = this.x.redMul(this.y), this.zOne || (this.t = this.t.redMul(this.z.redInvm())))); + } + o(u, a), t2.exports = u, u.prototype._mulA = function(t3) { + return this.mOneA ? t3.redNeg() : this.a.redMul(t3); + }, u.prototype._mulC = function(t3) { + return this.oneC ? t3 : this.c.redMul(t3); + }, u.prototype.jpoint = function(t3, e3, r3, n2) { + return this.point(t3, e3, r3, n2); + }, u.prototype.pointFromX = function(t3, e3) { + (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); + var r3 = t3.redSqr(), n2 = this.c2.redSub(this.a.redMul(r3)), o2 = this.one.redSub(this.c2.redMul(this.d).redMul(r3)), a2 = n2.redMul(o2.redInvm()), s2 = a2.redSqrt(); + if (s2.redSqr().redSub(a2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var u2 = s2.fromRed().isOdd(); + return (e3 && !u2 || !e3 && u2) && (s2 = s2.redNeg()), this.point(t3, s2); + }, u.prototype.pointFromY = function(t3, e3) { + (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); + var r3 = t3.redSqr(), n2 = r3.redSub(this.c2), o2 = r3.redMul(this.d).redMul(this.c2).redSub(this.a), a2 = n2.redMul(o2.redInvm()); + if (a2.cmp(this.zero) === 0) { + if (e3) + throw new Error("invalid point"); + return this.point(this.zero, t3); + } + var s2 = a2.redSqrt(); + if (s2.redSqr().redSub(a2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + return s2.fromRed().isOdd() !== e3 && (s2 = s2.redNeg()), this.point(s2, t3); + }, u.prototype.validate = function(t3) { + if (t3.isInfinity()) + return true; + t3.normalize(); + var e3 = t3.x.redSqr(), r3 = t3.y.redSqr(), n2 = e3.redMul(this.a).redAdd(r3), i2 = this.c2.redMul(this.one.redAdd(this.d.redMul(e3).redMul(r3))); + return n2.cmp(i2) === 0; + }, o(f, a.BasePoint), u.prototype.pointFromJSON = function(t3) { + return f.fromJSON(this, t3); + }, u.prototype.point = function(t3, e3, r3, n2) { + return new f(this, t3, e3, r3, n2); + }, f.fromJSON = function(t3, e3) { + return new f(t3, e3[0], e3[1], e3[2]); + }, f.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, f.prototype.isInfinity = function() { + return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); + }, f.prototype._extDbl = function() { + var t3 = this.x.redSqr(), e3 = this.y.redSqr(), r3 = this.z.redSqr(); + r3 = r3.redIAdd(r3); + var n2 = this.curve._mulA(t3), i2 = this.x.redAdd(this.y).redSqr().redISub(t3).redISub(e3), o2 = n2.redAdd(e3), a2 = o2.redSub(r3), s2 = n2.redSub(e3), u2 = i2.redMul(a2), f2 = o2.redMul(s2), c = i2.redMul(s2), h = a2.redMul(o2); + return this.curve.point(u2, f2, h, c); + }, f.prototype._projDbl = function() { + var t3, e3, r3, n2, i2, o2, a2 = this.x.redAdd(this.y).redSqr(), s2 = this.x.redSqr(), u2 = this.y.redSqr(); + if (this.curve.twisted) { + var f2 = (n2 = this.curve._mulA(s2)).redAdd(u2); + this.zOne ? (t3 = a2.redSub(s2).redSub(u2).redMul(f2.redSub(this.curve.two)), e3 = f2.redMul(n2.redSub(u2)), r3 = f2.redSqr().redSub(f2).redSub(f2)) : (i2 = this.z.redSqr(), o2 = f2.redSub(i2).redISub(i2), t3 = a2.redSub(s2).redISub(u2).redMul(o2), e3 = f2.redMul(n2.redSub(u2)), r3 = f2.redMul(o2)); + } else + n2 = s2.redAdd(u2), i2 = this.curve._mulC(this.z).redSqr(), o2 = n2.redSub(i2).redSub(i2), t3 = this.curve._mulC(a2.redISub(n2)).redMul(o2), e3 = this.curve._mulC(n2).redMul(s2.redISub(u2)), r3 = n2.redMul(o2); + return this.curve.point(t3, e3, r3); + }, f.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.extended ? this._extDbl() : this._projDbl(); + }, f.prototype._extAdd = function(t3) { + var e3 = this.y.redSub(this.x).redMul(t3.y.redSub(t3.x)), r3 = this.y.redAdd(this.x).redMul(t3.y.redAdd(t3.x)), n2 = this.t.redMul(this.curve.dd).redMul(t3.t), i2 = this.z.redMul(t3.z.redAdd(t3.z)), o2 = r3.redSub(e3), a2 = i2.redSub(n2), s2 = i2.redAdd(n2), u2 = r3.redAdd(e3), f2 = o2.redMul(a2), c = s2.redMul(u2), h = o2.redMul(u2), l = a2.redMul(s2); + return this.curve.point(f2, c, l, h); + }, f.prototype._projAdd = function(t3) { + var e3, r3, n2 = this.z.redMul(t3.z), i2 = n2.redSqr(), o2 = this.x.redMul(t3.x), a2 = this.y.redMul(t3.y), s2 = this.curve.d.redMul(o2).redMul(a2), u2 = i2.redSub(s2), f2 = i2.redAdd(s2), c = this.x.redAdd(this.y).redMul(t3.x.redAdd(t3.y)).redISub(o2).redISub(a2), h = n2.redMul(u2).redMul(c); + return this.curve.twisted ? (e3 = n2.redMul(f2).redMul(a2.redSub(this.curve._mulA(o2))), r3 = u2.redMul(f2)) : (e3 = n2.redMul(f2).redMul(a2.redSub(o2)), r3 = this.curve._mulC(u2).redMul(f2)), this.curve.point(h, e3, r3); + }, f.prototype.add = function(t3) { + return this.isInfinity() ? t3 : t3.isInfinity() ? this : this.curve.extended ? this._extAdd(t3) : this._projAdd(t3); + }, f.prototype.mul = function(t3) { + return this._hasDoubles(t3) ? this.curve._fixedNafMul(this, t3) : this.curve._wnafMul(this, t3); + }, f.prototype.mulAdd = function(t3, e3, r3) { + return this.curve._wnafMulAdd(1, [this, e3], [t3, r3], 2, false); + }, f.prototype.jmulAdd = function(t3, e3, r3) { + return this.curve._wnafMulAdd(1, [this, e3], [t3, r3], 2, true); + }, f.prototype.normalize = function() { + if (this.zOne) + return this; + var t3 = this.z.redInvm(); + return this.x = this.x.redMul(t3), this.y = this.y.redMul(t3), this.t && (this.t = this.t.redMul(t3)), this.z = this.curve.one, this.zOne = true, this; + }, f.prototype.neg = function() { + return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); + }, f.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }, f.prototype.getY = function() { + return this.normalize(), this.y.fromRed(); + }, f.prototype.eq = function(t3) { + return this === t3 || this.getX().cmp(t3.getX()) === 0 && this.getY().cmp(t3.getY()) === 0; + }, f.prototype.eqXToP = function(t3) { + var e3 = t3.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(e3) === 0) + return true; + for (var r3 = t3.clone(), n2 = this.curve.redN.redMul(this.z); ; ) { + if (r3.iadd(this.curve.n), r3.cmp(this.curve.p) >= 0) + return false; + if (e3.redIAdd(n2), this.x.cmp(e3) === 0) + return true; + } + }, f.prototype.toP = f.prototype.normalize, f.prototype.mixedAdd = f.prototype.add; + }, 8254: (t2, e2, r2) => { + var n = e2; + n.base = r2(4918), n.short = r2(6673), n.mont = r2(2881), n.edwards = r2(1138); + }, 2881: (t2, e2, r2) => { + var n = r2(3550), i = r2(5717), o = r2(4918), a = r2(953); + function s(t3) { + o.call(this, "mont", t3), this.a = new n(t3.a, 16).toRed(this.red), this.b = new n(t3.b, 16).toRed(this.red), this.i4 = new n(4).toRed(this.red).redInvm(), this.two = new n(2).toRed(this.red), this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + function u(t3, e3, r3) { + o.BasePoint.call(this, t3, "projective"), e3 === null && r3 === null ? (this.x = this.curve.one, this.z = this.curve.zero) : (this.x = new n(e3, 16), this.z = new n(r3, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red))); + } + i(s, o), t2.exports = s, s.prototype.validate = function(t3) { + var e3 = t3.normalize().x, r3 = e3.redSqr(), n2 = r3.redMul(e3).redAdd(r3.redMul(this.a)).redAdd(e3); + return n2.redSqrt().redSqr().cmp(n2) === 0; + }, i(u, o.BasePoint), s.prototype.decodePoint = function(t3, e3) { + return this.point(a.toArray(t3, e3), 1); + }, s.prototype.point = function(t3, e3) { + return new u(this, t3, e3); + }, s.prototype.pointFromJSON = function(t3) { + return u.fromJSON(this, t3); + }, u.prototype.precompute = function() { + }, u.prototype._encode = function() { + return this.getX().toArray("be", this.curve.p.byteLength()); + }, u.fromJSON = function(t3, e3) { + return new u(t3, e3[0], e3[1] || t3.one); + }, u.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, u.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }, u.prototype.dbl = function() { + var t3 = this.x.redAdd(this.z).redSqr(), e3 = this.x.redSub(this.z).redSqr(), r3 = t3.redSub(e3), n2 = t3.redMul(e3), i2 = r3.redMul(e3.redAdd(this.curve.a24.redMul(r3))); + return this.curve.point(n2, i2); + }, u.prototype.add = function() { + throw new Error("Not supported on Montgomery curve"); + }, u.prototype.diffAdd = function(t3, e3) { + var r3 = this.x.redAdd(this.z), n2 = this.x.redSub(this.z), i2 = t3.x.redAdd(t3.z), o2 = t3.x.redSub(t3.z).redMul(r3), a2 = i2.redMul(n2), s2 = e3.z.redMul(o2.redAdd(a2).redSqr()), u2 = e3.x.redMul(o2.redISub(a2).redSqr()); + return this.curve.point(s2, u2); + }, u.prototype.mul = function(t3) { + for (var e3 = t3.clone(), r3 = this, n2 = this.curve.point(null, null), i2 = []; e3.cmpn(0) !== 0; e3.iushrn(1)) + i2.push(e3.andln(1)); + for (var o2 = i2.length - 1; o2 >= 0; o2--) + i2[o2] === 0 ? (r3 = r3.diffAdd(n2, this), n2 = n2.dbl()) : (n2 = r3.diffAdd(n2, this), r3 = r3.dbl()); + return n2; + }, u.prototype.mulAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, u.prototype.jumlAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, u.prototype.eq = function(t3) { + return this.getX().cmp(t3.getX()) === 0; + }, u.prototype.normalize = function() { + return this.x = this.x.redMul(this.z.redInvm()), this.z = this.curve.one, this; + }, u.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }; + }, 6673: (t2, e2, r2) => { + var n = r2(953), i = r2(3550), o = r2(5717), a = r2(4918), s = n.assert; + function u(t3) { + a.call(this, "short", t3), this.a = new i(t3.a, 16).toRed(this.red), this.b = new i(t3.b, 16).toRed(this.red), this.tinv = this.two.redInvm(), this.zeroA = this.a.fromRed().cmpn(0) === 0, this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0, this.endo = this._getEndomorphism(t3), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + function f(t3, e3, r3, n2) { + a.BasePoint.call(this, t3, "affine"), e3 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new i(e3, 16), this.y = new i(r3, 16), n2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + function c(t3, e3, r3, n2) { + a.BasePoint.call(this, t3, "jacobian"), e3 === null && r3 === null && n2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new i(0)) : (this.x = new i(e3, 16), this.y = new i(r3, 16), this.z = new i(n2, 16)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.zOne = this.z === this.curve.one; + } + o(u, a), t2.exports = u, u.prototype._getEndomorphism = function(t3) { + if (this.zeroA && this.g && this.n && this.p.modn(3) === 1) { + var e3, r3; + if (t3.beta) + e3 = new i(t3.beta, 16).toRed(this.red); + else { + var n2 = this._getEndoRoots(this.p); + e3 = (e3 = n2[0].cmp(n2[1]) < 0 ? n2[0] : n2[1]).toRed(this.red); + } + if (t3.lambda) + r3 = new i(t3.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(e3)) === 0 ? r3 = o2[0] : (r3 = o2[1], s(this.g.mul(r3).x.cmp(this.g.x.redMul(e3)) === 0)); + } + return {beta: e3, lambda: r3, basis: t3.basis ? t3.basis.map(function(t4) { + return {a: new i(t4.a, 16), b: new i(t4.b, 16)}; + }) : this._getEndoBasis(r3)}; + } + }, u.prototype._getEndoRoots = function(t3) { + var e3 = t3 === this.p ? this.red : i.mont(t3), r3 = new i(2).toRed(e3).redInvm(), n2 = r3.redNeg(), o2 = new i(3).toRed(e3).redNeg().redSqrt().redMul(r3); + return [n2.redAdd(o2).fromRed(), n2.redSub(o2).fromRed()]; + }, u.prototype._getEndoBasis = function(t3) { + for (var e3, r3, n2, o2, a2, s2, u2, f2, c2, h = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), l = t3, d = this.n.clone(), p = new i(1), y = new i(0), m = new i(0), b = new i(1), g = 0; l.cmpn(0) !== 0; ) { + var v = d.div(l); + f2 = d.sub(v.mul(l)), c2 = m.sub(v.mul(p)); + var w = b.sub(v.mul(y)); + if (!n2 && f2.cmp(h) < 0) + e3 = u2.neg(), r3 = p, n2 = f2.neg(), o2 = c2; + else if (n2 && ++g == 2) + break; + u2 = f2, d = l, l = f2, m = p, p = c2, b = y, y = w; + } + a2 = f2.neg(), s2 = c2; + var _ = n2.sqr().add(o2.sqr()); + return a2.sqr().add(s2.sqr()).cmp(_) >= 0 && (a2 = e3, s2 = r3), n2.negative && (n2 = n2.neg(), o2 = o2.neg()), a2.negative && (a2 = a2.neg(), s2 = s2.neg()), [{a: n2, b: o2}, {a: a2, b: s2}]; + }, u.prototype._endoSplit = function(t3) { + var e3 = this.endo.basis, r3 = e3[0], n2 = e3[1], i2 = n2.b.mul(t3).divRound(this.n), o2 = r3.b.neg().mul(t3).divRound(this.n), a2 = i2.mul(r3.a), s2 = o2.mul(n2.a), u2 = i2.mul(r3.b), f2 = o2.mul(n2.b); + return {k1: t3.sub(a2).sub(s2), k2: u2.add(f2).neg()}; + }, u.prototype.pointFromX = function(t3, e3) { + (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); + var r3 = t3.redSqr().redMul(t3).redIAdd(t3.redMul(this.a)).redIAdd(this.b), n2 = r3.redSqrt(); + if (n2.redSqr().redSub(r3).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n2.fromRed().isOdd(); + return (e3 && !o2 || !e3 && o2) && (n2 = n2.redNeg()), this.point(t3, n2); + }, u.prototype.validate = function(t3) { + if (t3.inf) + return true; + var e3 = t3.x, r3 = t3.y, n2 = this.a.redMul(e3), i2 = e3.redSqr().redMul(e3).redIAdd(n2).redIAdd(this.b); + return r3.redSqr().redISub(i2).cmpn(0) === 0; + }, u.prototype._endoWnafMulAdd = function(t3, e3, r3) { + for (var n2 = this._endoWnafT1, i2 = this._endoWnafT2, o2 = 0; o2 < t3.length; o2++) { + var a2 = this._endoSplit(e3[o2]), s2 = t3[o2], u2 = s2._getBeta(); + a2.k1.negative && (a2.k1.ineg(), s2 = s2.neg(true)), a2.k2.negative && (a2.k2.ineg(), u2 = u2.neg(true)), n2[2 * o2] = s2, n2[2 * o2 + 1] = u2, i2[2 * o2] = a2.k1, i2[2 * o2 + 1] = a2.k2; + } + for (var f2 = this._wnafMulAdd(1, n2, i2, 2 * o2, r3), c2 = 0; c2 < 2 * o2; c2++) + n2[c2] = null, i2[c2] = null; + return f2; + }, o(f, a.BasePoint), u.prototype.point = function(t3, e3, r3) { + return new f(this, t3, e3, r3); + }, u.prototype.pointFromJSON = function(t3, e3) { + return f.fromJSON(this, t3, e3); + }, f.prototype._getBeta = function() { + if (this.curve.endo) { + var t3 = this.precomputed; + if (t3 && t3.beta) + return t3.beta; + var e3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t3) { + var r3 = this.curve, n2 = function(t4) { + return r3.point(t4.x.redMul(r3.endo.beta), t4.y); + }; + t3.beta = e3, e3.precomputed = {beta: null, naf: t3.naf && {wnd: t3.naf.wnd, points: t3.naf.points.map(n2)}, doubles: t3.doubles && {step: t3.doubles.step, points: t3.doubles.points.map(n2)}}; + } + return e3; + } + }, f.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && {doubles: this.precomputed.doubles && {step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1)}, naf: this.precomputed.naf && {wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1)}}] : [this.x, this.y]; + }, f.fromJSON = function(t3, e3, r3) { + typeof e3 == "string" && (e3 = JSON.parse(e3)); + var n2 = t3.point(e3[0], e3[1], r3); + if (!e3[2]) + return n2; + function i2(e4) { + return t3.point(e4[0], e4[1], r3); + } + var o2 = e3[2]; + return n2.precomputed = {beta: null, doubles: o2.doubles && {step: o2.doubles.step, points: [n2].concat(o2.doubles.points.map(i2))}, naf: o2.naf && {wnd: o2.naf.wnd, points: [n2].concat(o2.naf.points.map(i2))}}, n2; + }, f.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, f.prototype.isInfinity = function() { + return this.inf; + }, f.prototype.add = function(t3) { + if (this.inf) + return t3; + if (t3.inf) + return this; + if (this.eq(t3)) + return this.dbl(); + if (this.neg().eq(t3)) + return this.curve.point(null, null); + if (this.x.cmp(t3.x) === 0) + return this.curve.point(null, null); + var e3 = this.y.redSub(t3.y); + e3.cmpn(0) !== 0 && (e3 = e3.redMul(this.x.redSub(t3.x).redInvm())); + var r3 = e3.redSqr().redISub(this.x).redISub(t3.x), n2 = e3.redMul(this.x.redSub(r3)).redISub(this.y); + return this.curve.point(r3, n2); + }, f.prototype.dbl = function() { + if (this.inf) + return this; + var t3 = this.y.redAdd(this.y); + if (t3.cmpn(0) === 0) + return this.curve.point(null, null); + var e3 = this.curve.a, r3 = this.x.redSqr(), n2 = t3.redInvm(), i2 = r3.redAdd(r3).redIAdd(r3).redIAdd(e3).redMul(n2), o2 = i2.redSqr().redISub(this.x.redAdd(this.x)), a2 = i2.redMul(this.x.redSub(o2)).redISub(this.y); + return this.curve.point(o2, a2); + }, f.prototype.getX = function() { + return this.x.fromRed(); + }, f.prototype.getY = function() { + return this.y.fromRed(); + }, f.prototype.mul = function(t3) { + return t3 = new i(t3, 16), this.isInfinity() ? this : this._hasDoubles(t3) ? this.curve._fixedNafMul(this, t3) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t3]) : this.curve._wnafMul(this, t3); + }, f.prototype.mulAdd = function(t3, e3, r3) { + var n2 = [this, e3], i2 = [t3, r3]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, i2) : this.curve._wnafMulAdd(1, n2, i2, 2); + }, f.prototype.jmulAdd = function(t3, e3, r3) { + var n2 = [this, e3], i2 = [t3, r3]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, i2, true) : this.curve._wnafMulAdd(1, n2, i2, 2, true); + }, f.prototype.eq = function(t3) { + return this === t3 || this.inf === t3.inf && (this.inf || this.x.cmp(t3.x) === 0 && this.y.cmp(t3.y) === 0); + }, f.prototype.neg = function(t3) { + if (this.inf) + return this; + var e3 = this.curve.point(this.x, this.y.redNeg()); + if (t3 && this.precomputed) { + var r3 = this.precomputed, n2 = function(t4) { + return t4.neg(); + }; + e3.precomputed = {naf: r3.naf && {wnd: r3.naf.wnd, points: r3.naf.points.map(n2)}, doubles: r3.doubles && {step: r3.doubles.step, points: r3.doubles.points.map(n2)}}; + } + return e3; + }, f.prototype.toJ = function() { + return this.inf ? this.curve.jpoint(null, null, null) : this.curve.jpoint(this.x, this.y, this.curve.one); + }, o(c, a.BasePoint), u.prototype.jpoint = function(t3, e3, r3) { + return new c(this, t3, e3, r3); + }, c.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t3 = this.z.redInvm(), e3 = t3.redSqr(), r3 = this.x.redMul(e3), n2 = this.y.redMul(e3).redMul(t3); + return this.curve.point(r3, n2); + }, c.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, c.prototype.add = function(t3) { + if (this.isInfinity()) + return t3; + if (t3.isInfinity()) + return this; + var e3 = t3.z.redSqr(), r3 = this.z.redSqr(), n2 = this.x.redMul(e3), i2 = t3.x.redMul(r3), o2 = this.y.redMul(e3.redMul(t3.z)), a2 = t3.y.redMul(r3.redMul(this.z)), s2 = n2.redSub(i2), u2 = o2.redSub(a2); + if (s2.cmpn(0) === 0) + return u2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var f2 = s2.redSqr(), c2 = f2.redMul(s2), h = n2.redMul(f2), l = u2.redSqr().redIAdd(c2).redISub(h).redISub(h), d = u2.redMul(h.redISub(l)).redISub(o2.redMul(c2)), p = this.z.redMul(t3.z).redMul(s2); + return this.curve.jpoint(l, d, p); + }, c.prototype.mixedAdd = function(t3) { + if (this.isInfinity()) + return t3.toJ(); + if (t3.isInfinity()) + return this; + var e3 = this.z.redSqr(), r3 = this.x, n2 = t3.x.redMul(e3), i2 = this.y, o2 = t3.y.redMul(e3).redMul(this.z), a2 = r3.redSub(n2), s2 = i2.redSub(o2); + if (a2.cmpn(0) === 0) + return s2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var u2 = a2.redSqr(), f2 = u2.redMul(a2), c2 = r3.redMul(u2), h = s2.redSqr().redIAdd(f2).redISub(c2).redISub(c2), l = s2.redMul(c2.redISub(h)).redISub(i2.redMul(f2)), d = this.z.redMul(a2); + return this.curve.jpoint(h, l, d); + }, c.prototype.dblp = function(t3) { + if (t3 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t3) + return this.dbl(); + var e3; + if (this.curve.zeroA || this.curve.threeA) { + var r3 = this; + for (e3 = 0; e3 < t3; e3++) + r3 = r3.dbl(); + return r3; + } + var n2 = this.curve.a, i2 = this.curve.tinv, o2 = this.x, a2 = this.y, s2 = this.z, u2 = s2.redSqr().redSqr(), f2 = a2.redAdd(a2); + for (e3 = 0; e3 < t3; e3++) { + var c2 = o2.redSqr(), h = f2.redSqr(), l = h.redSqr(), d = c2.redAdd(c2).redIAdd(c2).redIAdd(n2.redMul(u2)), p = o2.redMul(h), y = d.redSqr().redISub(p.redAdd(p)), m = p.redISub(y), b = d.redMul(m); + b = b.redIAdd(b).redISub(l); + var g = f2.redMul(s2); + e3 + 1 < t3 && (u2 = u2.redMul(l)), o2 = y, s2 = g, f2 = b; + } + return this.curve.jpoint(o2, f2.redMul(i2), s2); + }, c.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, c.prototype._zeroDbl = function() { + var t3, e3, r3; + if (this.zOne) { + var n2 = this.x.redSqr(), i2 = this.y.redSqr(), o2 = i2.redSqr(), a2 = this.x.redAdd(i2).redSqr().redISub(n2).redISub(o2); + a2 = a2.redIAdd(a2); + var s2 = n2.redAdd(n2).redIAdd(n2), u2 = s2.redSqr().redISub(a2).redISub(a2), f2 = o2.redIAdd(o2); + f2 = (f2 = f2.redIAdd(f2)).redIAdd(f2), t3 = u2, e3 = s2.redMul(a2.redISub(u2)).redISub(f2), r3 = this.y.redAdd(this.y); + } else { + var c2 = this.x.redSqr(), h = this.y.redSqr(), l = h.redSqr(), d = this.x.redAdd(h).redSqr().redISub(c2).redISub(l); + d = d.redIAdd(d); + var p = c2.redAdd(c2).redIAdd(c2), y = p.redSqr(), m = l.redIAdd(l); + m = (m = m.redIAdd(m)).redIAdd(m), t3 = y.redISub(d).redISub(d), e3 = p.redMul(d.redISub(t3)).redISub(m), r3 = (r3 = this.y.redMul(this.z)).redIAdd(r3); + } + return this.curve.jpoint(t3, e3, r3); + }, c.prototype._threeDbl = function() { + var t3, e3, r3; + if (this.zOne) { + var n2 = this.x.redSqr(), i2 = this.y.redSqr(), o2 = i2.redSqr(), a2 = this.x.redAdd(i2).redSqr().redISub(n2).redISub(o2); + a2 = a2.redIAdd(a2); + var s2 = n2.redAdd(n2).redIAdd(n2).redIAdd(this.curve.a), u2 = s2.redSqr().redISub(a2).redISub(a2); + t3 = u2; + var f2 = o2.redIAdd(o2); + f2 = (f2 = f2.redIAdd(f2)).redIAdd(f2), e3 = s2.redMul(a2.redISub(u2)).redISub(f2), r3 = this.y.redAdd(this.y); + } else { + var c2 = this.z.redSqr(), h = this.y.redSqr(), l = this.x.redMul(h), d = this.x.redSub(c2).redMul(this.x.redAdd(c2)); + d = d.redAdd(d).redIAdd(d); + var p = l.redIAdd(l), y = (p = p.redIAdd(p)).redAdd(p); + t3 = d.redSqr().redISub(y), r3 = this.y.redAdd(this.z).redSqr().redISub(h).redISub(c2); + var m = h.redSqr(); + m = (m = (m = m.redIAdd(m)).redIAdd(m)).redIAdd(m), e3 = d.redMul(p.redISub(t3)).redISub(m); + } + return this.curve.jpoint(t3, e3, r3); + }, c.prototype._dbl = function() { + var t3 = this.curve.a, e3 = this.x, r3 = this.y, n2 = this.z, i2 = n2.redSqr().redSqr(), o2 = e3.redSqr(), a2 = r3.redSqr(), s2 = o2.redAdd(o2).redIAdd(o2).redIAdd(t3.redMul(i2)), u2 = e3.redAdd(e3), f2 = (u2 = u2.redIAdd(u2)).redMul(a2), c2 = s2.redSqr().redISub(f2.redAdd(f2)), h = f2.redISub(c2), l = a2.redSqr(); + l = (l = (l = l.redIAdd(l)).redIAdd(l)).redIAdd(l); + var d = s2.redMul(h).redISub(l), p = r3.redAdd(r3).redMul(n2); + return this.curve.jpoint(c2, d, p); + }, c.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t3 = this.x.redSqr(), e3 = this.y.redSqr(), r3 = this.z.redSqr(), n2 = e3.redSqr(), i2 = t3.redAdd(t3).redIAdd(t3), o2 = i2.redSqr(), a2 = this.x.redAdd(e3).redSqr().redISub(t3).redISub(n2), s2 = (a2 = (a2 = (a2 = a2.redIAdd(a2)).redAdd(a2).redIAdd(a2)).redISub(o2)).redSqr(), u2 = n2.redIAdd(n2); + u2 = (u2 = (u2 = u2.redIAdd(u2)).redIAdd(u2)).redIAdd(u2); + var f2 = i2.redIAdd(a2).redSqr().redISub(o2).redISub(s2).redISub(u2), c2 = e3.redMul(f2); + c2 = (c2 = c2.redIAdd(c2)).redIAdd(c2); + var h = this.x.redMul(s2).redISub(c2); + h = (h = h.redIAdd(h)).redIAdd(h); + var l = this.y.redMul(f2.redMul(u2.redISub(f2)).redISub(a2.redMul(s2))); + l = (l = (l = l.redIAdd(l)).redIAdd(l)).redIAdd(l); + var d = this.z.redAdd(a2).redSqr().redISub(r3).redISub(s2); + return this.curve.jpoint(h, l, d); + }, c.prototype.mul = function(t3, e3) { + return t3 = new i(t3, e3), this.curve._wnafMul(this, t3); + }, c.prototype.eq = function(t3) { + if (t3.type === "affine") + return this.eq(t3.toJ()); + if (this === t3) + return true; + var e3 = this.z.redSqr(), r3 = t3.z.redSqr(); + if (this.x.redMul(r3).redISub(t3.x.redMul(e3)).cmpn(0) !== 0) + return false; + var n2 = e3.redMul(this.z), i2 = r3.redMul(t3.z); + return this.y.redMul(i2).redISub(t3.y.redMul(n2)).cmpn(0) === 0; + }, c.prototype.eqXToP = function(t3) { + var e3 = this.z.redSqr(), r3 = t3.toRed(this.curve.red).redMul(e3); + if (this.x.cmp(r3) === 0) + return true; + for (var n2 = t3.clone(), i2 = this.curve.redN.redMul(e3); ; ) { + if (n2.iadd(this.curve.n), n2.cmp(this.curve.p) >= 0) + return false; + if (r3.redIAdd(i2), this.x.cmp(r3) === 0) + return true; + } + }, c.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, c.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }; + }, 5427: (t2, e2, r2) => { + var n, i = e2, o = r2(3715), a = r2(8254), s = r2(953).assert; + function u(t3) { + t3.type === "short" ? this.curve = new a.short(t3) : t3.type === "edwards" ? this.curve = new a.edwards(t3) : this.curve = new a.mont(t3), this.g = this.curve.g, this.n = this.curve.n, this.hash = t3.hash, s(this.g.validate(), "Invalid curve"), s(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + function f(t3, e3) { + Object.defineProperty(i, t3, {configurable: true, enumerable: true, get: function() { + var r3 = new u(e3); + return Object.defineProperty(i, t3, {configurable: true, enumerable: true, value: r3}), r3; + }}); + } + i.PresetCurve = u, f("p192", {type: "short", prime: "p192", p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", hash: o.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}), f("p224", {type: "short", prime: "p224", p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", hash: o.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}), f("p256", {type: "short", prime: null, p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", hash: o.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}), f("p384", {type: "short", prime: null, p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", hash: o.sha384, gRed: false, g: ["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}), f("p521", {type: "short", prime: null, p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", hash: o.sha512, gRed: false, g: ["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}), f("curve25519", {type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: o.sha256, gRed: false, g: ["9"]}), f("ed25519", {type: "edwards", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "-1", c: "1", d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: o.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"]}); + try { + n = r2(1037); + } catch (t3) { + n = void 0; + } + f("secp256k1", {type: "short", prime: "k256", p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", a: "0", b: "7", n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", h: "1", hash: o.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3"}, {a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15"}], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", n]}); + }, 7954: (t2, e2, r2) => { + var n = r2(3550), i = r2(2156), o = r2(953), a = r2(5427), s = r2(7376), u = o.assert, f = r2(1251), c = r2(611); + function h(t3) { + if (!(this instanceof h)) + return new h(t3); + typeof t3 == "string" && (u(Object.prototype.hasOwnProperty.call(a, t3), "Unknown curve " + t3), t3 = a[t3]), t3 instanceof a.PresetCurve && (t3 = {curve: t3}), this.curve = t3.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = t3.curve.g, this.g.precompute(t3.curve.n.bitLength() + 1), this.hash = t3.hash || t3.curve.hash; + } + t2.exports = h, h.prototype.keyPair = function(t3) { + return new f(this, t3); + }, h.prototype.keyFromPrivate = function(t3, e3) { + return f.fromPrivate(this, t3, e3); + }, h.prototype.keyFromPublic = function(t3, e3) { + return f.fromPublic(this, t3, e3); + }, h.prototype.genKeyPair = function(t3) { + t3 || (t3 = {}); + for (var e3 = new i({hash: this.hash, pers: t3.pers, persEnc: t3.persEnc || "utf8", entropy: t3.entropy || s(this.hash.hmacStrength), entropyEnc: t3.entropy && t3.entropyEnc || "utf8", nonce: this.n.toArray()}), r3 = this.n.byteLength(), o2 = this.n.sub(new n(2)); ; ) { + var a2 = new n(e3.generate(r3)); + if (!(a2.cmp(o2) > 0)) + return a2.iaddn(1), this.keyFromPrivate(a2); + } + }, h.prototype._truncateToN = function(t3, e3) { + var r3 = 8 * t3.byteLength() - this.n.bitLength(); + return r3 > 0 && (t3 = t3.ushrn(r3)), !e3 && t3.cmp(this.n) >= 0 ? t3.sub(this.n) : t3; + }, h.prototype.sign = function(t3, e3, r3, o2) { + typeof r3 == "object" && (o2 = r3, r3 = null), o2 || (o2 = {}), e3 = this.keyFromPrivate(e3, r3), t3 = this._truncateToN(new n(t3, 16)); + for (var a2 = this.n.byteLength(), s2 = e3.getPrivate().toArray("be", a2), u2 = t3.toArray("be", a2), f2 = new i({hash: this.hash, entropy: s2, nonce: u2, pers: o2.pers, persEnc: o2.persEnc || "utf8"}), h2 = this.n.sub(new n(1)), l = 0; ; l++) { + var d = o2.k ? o2.k(l) : new n(f2.generate(this.n.byteLength())); + if (!((d = this._truncateToN(d, true)).cmpn(1) <= 0 || d.cmp(h2) >= 0)) { + var p = this.g.mul(d); + if (!p.isInfinity()) { + var y = p.getX(), m = y.umod(this.n); + if (m.cmpn(0) !== 0) { + var b = d.invm(this.n).mul(m.mul(e3.getPrivate()).iadd(t3)); + if ((b = b.umod(this.n)).cmpn(0) !== 0) { + var g = (p.getY().isOdd() ? 1 : 0) | (y.cmp(m) !== 0 ? 2 : 0); + return o2.canonical && b.cmp(this.nh) > 0 && (b = this.n.sub(b), g ^= 1), new c({r: m, s: b, recoveryParam: g}); + } + } + } + } + } + }, h.prototype.verify = function(t3, e3, r3, i2) { + t3 = this._truncateToN(new n(t3, 16)), r3 = this.keyFromPublic(r3, i2); + var o2 = (e3 = new c(e3, "hex")).r, a2 = e3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0) + return false; + if (a2.cmpn(1) < 0 || a2.cmp(this.n) >= 0) + return false; + var s2, u2 = a2.invm(this.n), f2 = u2.mul(t3).umod(this.n), h2 = u2.mul(o2).umod(this.n); + return this.curve._maxwellTrick ? !(s2 = this.g.jmulAdd(f2, r3.getPublic(), h2)).isInfinity() && s2.eqXToP(o2) : !(s2 = this.g.mulAdd(f2, r3.getPublic(), h2)).isInfinity() && s2.getX().umod(this.n).cmp(o2) === 0; + }, h.prototype.recoverPubKey = function(t3, e3, r3, i2) { + u((3 & r3) === r3, "The recovery param is more than two bits"), e3 = new c(e3, i2); + var o2 = this.n, a2 = new n(t3), s2 = e3.r, f2 = e3.s, h2 = 1 & r3, l = r3 >> 1; + if (s2.cmp(this.curve.p.umod(this.curve.n)) >= 0 && l) + throw new Error("Unable to find sencond key candinate"); + s2 = l ? this.curve.pointFromX(s2.add(this.curve.n), h2) : this.curve.pointFromX(s2, h2); + var d = e3.r.invm(o2), p = o2.sub(a2).mul(d).umod(o2), y = f2.mul(d).umod(o2); + return this.g.mulAdd(p, s2, y); + }, h.prototype.getKeyRecoveryParam = function(t3, e3, r3, n2) { + if ((e3 = new c(e3, n2)).recoveryParam !== null) + return e3.recoveryParam; + for (var i2 = 0; i2 < 4; i2++) { + var o2; + try { + o2 = this.recoverPubKey(t3, e3, i2); + } catch (t4) { + continue; + } + if (o2.eq(r3)) + return i2; + } + throw new Error("Unable to find valid recovery factor"); + }; + }, 1251: (t2, e2, r2) => { + var n = r2(3550), i = r2(953).assert; + function o(t3, e3) { + this.ec = t3, this.priv = null, this.pub = null, e3.priv && this._importPrivate(e3.priv, e3.privEnc), e3.pub && this._importPublic(e3.pub, e3.pubEnc); + } + t2.exports = o, o.fromPublic = function(t3, e3, r3) { + return e3 instanceof o ? e3 : new o(t3, {pub: e3, pubEnc: r3}); + }, o.fromPrivate = function(t3, e3, r3) { + return e3 instanceof o ? e3 : new o(t3, {priv: e3, privEnc: r3}); + }, o.prototype.validate = function() { + var t3 = this.getPublic(); + return t3.isInfinity() ? {result: false, reason: "Invalid public key"} : t3.validate() ? t3.mul(this.ec.curve.n).isInfinity() ? {result: true, reason: null} : {result: false, reason: "Public key * N != O"} : {result: false, reason: "Public key is not a point"}; + }, o.prototype.getPublic = function(t3, e3) { + return typeof t3 == "string" && (e3 = t3, t3 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), e3 ? this.pub.encode(e3, t3) : this.pub; + }, o.prototype.getPrivate = function(t3) { + return t3 === "hex" ? this.priv.toString(16, 2) : this.priv; + }, o.prototype._importPrivate = function(t3, e3) { + this.priv = new n(t3, e3 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, o.prototype._importPublic = function(t3, e3) { + if (t3.x || t3.y) + return this.ec.curve.type === "mont" ? i(t3.x, "Need x coordinate") : this.ec.curve.type !== "short" && this.ec.curve.type !== "edwards" || i(t3.x && t3.y, "Need both x and y coordinate"), void (this.pub = this.ec.curve.point(t3.x, t3.y)); + this.pub = this.ec.curve.decodePoint(t3, e3); + }, o.prototype.derive = function(t3) { + return t3.validate() || i(t3.validate(), "public point not validated"), t3.mul(this.priv).getX(); + }, o.prototype.sign = function(t3, e3, r3) { + return this.ec.sign(t3, this, e3, r3); + }, o.prototype.verify = function(t3, e3) { + return this.ec.verify(t3, e3, this); + }, o.prototype.inspect = function() { + return ""; + }; + }, 611: (t2, e2, r2) => { + var n = r2(3550), i = r2(953), o = i.assert; + function a(t3, e3) { + if (t3 instanceof a) + return t3; + this._importDER(t3, e3) || (o(t3.r && t3.s, "Signature without r or s"), this.r = new n(t3.r, 16), this.s = new n(t3.s, 16), t3.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = t3.recoveryParam); + } + function s() { + this.place = 0; + } + function u(t3, e3) { + var r3 = t3[e3.place++]; + if (!(128 & r3)) + return r3; + var n2 = 15 & r3; + if (n2 === 0 || n2 > 4) + return false; + for (var i2 = 0, o2 = 0, a2 = e3.place; o2 < n2; o2++, a2++) + i2 <<= 8, i2 |= t3[a2], i2 >>>= 0; + return !(i2 <= 127) && (e3.place = a2, i2); + } + function f(t3) { + for (var e3 = 0, r3 = t3.length - 1; !t3[e3] && !(128 & t3[e3 + 1]) && e3 < r3; ) + e3++; + return e3 === 0 ? t3 : t3.slice(e3); + } + function c(t3, e3) { + if (e3 < 128) + t3.push(e3); + else { + var r3 = 1 + (Math.log(e3) / Math.LN2 >>> 3); + for (t3.push(128 | r3); --r3; ) + t3.push(e3 >>> (r3 << 3) & 255); + t3.push(e3); + } + } + t2.exports = a, a.prototype._importDER = function(t3, e3) { + t3 = i.toArray(t3, e3); + var r3 = new s(); + if (t3[r3.place++] !== 48) + return false; + var o2 = u(t3, r3); + if (o2 === false) + return false; + if (o2 + r3.place !== t3.length) + return false; + if (t3[r3.place++] !== 2) + return false; + var a2 = u(t3, r3); + if (a2 === false) + return false; + var f2 = t3.slice(r3.place, a2 + r3.place); + if (r3.place += a2, t3[r3.place++] !== 2) + return false; + var c2 = u(t3, r3); + if (c2 === false) + return false; + if (t3.length !== c2 + r3.place) + return false; + var h = t3.slice(r3.place, c2 + r3.place); + if (f2[0] === 0) { + if (!(128 & f2[1])) + return false; + f2 = f2.slice(1); + } + if (h[0] === 0) { + if (!(128 & h[1])) + return false; + h = h.slice(1); + } + return this.r = new n(f2), this.s = new n(h), this.recoveryParam = null, true; + }, a.prototype.toDER = function(t3) { + var e3 = this.r.toArray(), r3 = this.s.toArray(); + for (128 & e3[0] && (e3 = [0].concat(e3)), 128 & r3[0] && (r3 = [0].concat(r3)), e3 = f(e3), r3 = f(r3); !(r3[0] || 128 & r3[1]); ) + r3 = r3.slice(1); + var n2 = [2]; + c(n2, e3.length), (n2 = n2.concat(e3)).push(2), c(n2, r3.length); + var o2 = n2.concat(r3), a2 = [48]; + return c(a2, o2.length), a2 = a2.concat(o2), i.encode(a2, t3); + }; + }, 5980: (t2, e2, r2) => { + var n = r2(3715), i = r2(5427), o = r2(953), a = o.assert, s = o.parseBytes, u = r2(9087), f = r2(3622); + function c(t3) { + if (a(t3 === "ed25519", "only tested with ed25519 so far"), !(this instanceof c)) + return new c(t3); + t3 = i[t3].curve, this.curve = t3, this.g = t3.g, this.g.precompute(t3.n.bitLength() + 1), this.pointClass = t3.point().constructor, this.encodingLength = Math.ceil(t3.n.bitLength() / 8), this.hash = n.sha512; + } + t2.exports = c, c.prototype.sign = function(t3, e3) { + t3 = s(t3); + var r3 = this.keyFromSecret(e3), n2 = this.hashInt(r3.messagePrefix(), t3), i2 = this.g.mul(n2), o2 = this.encodePoint(i2), a2 = this.hashInt(o2, r3.pubBytes(), t3).mul(r3.priv()), u2 = n2.add(a2).umod(this.curve.n); + return this.makeSignature({R: i2, S: u2, Rencoded: o2}); + }, c.prototype.verify = function(t3, e3, r3) { + t3 = s(t3), e3 = this.makeSignature(e3); + var n2 = this.keyFromPublic(r3), i2 = this.hashInt(e3.Rencoded(), n2.pubBytes(), t3), o2 = this.g.mul(e3.S()); + return e3.R().add(n2.pub().mul(i2)).eq(o2); + }, c.prototype.hashInt = function() { + for (var t3 = this.hash(), e3 = 0; e3 < arguments.length; e3++) + t3.update(arguments[e3]); + return o.intFromLE(t3.digest()).umod(this.curve.n); + }, c.prototype.keyFromPublic = function(t3) { + return u.fromPublic(this, t3); + }, c.prototype.keyFromSecret = function(t3) { + return u.fromSecret(this, t3); + }, c.prototype.makeSignature = function(t3) { + return t3 instanceof f ? t3 : new f(this, t3); + }, c.prototype.encodePoint = function(t3) { + var e3 = t3.getY().toArray("le", this.encodingLength); + return e3[this.encodingLength - 1] |= t3.getX().isOdd() ? 128 : 0, e3; + }, c.prototype.decodePoint = function(t3) { + var e3 = (t3 = o.parseBytes(t3)).length - 1, r3 = t3.slice(0, e3).concat(-129 & t3[e3]), n2 = (128 & t3[e3]) != 0, i2 = o.intFromLE(r3); + return this.curve.pointFromY(i2, n2); + }, c.prototype.encodeInt = function(t3) { + return t3.toArray("le", this.encodingLength); + }, c.prototype.decodeInt = function(t3) { + return o.intFromLE(t3); + }, c.prototype.isPoint = function(t3) { + return t3 instanceof this.pointClass; + }; + }, 9087: (t2, e2, r2) => { + var n = r2(953), i = n.assert, o = n.parseBytes, a = n.cachedProperty; + function s(t3, e3) { + this.eddsa = t3, this._secret = o(e3.secret), t3.isPoint(e3.pub) ? this._pub = e3.pub : this._pubBytes = o(e3.pub); + } + s.fromPublic = function(t3, e3) { + return e3 instanceof s ? e3 : new s(t3, {pub: e3}); + }, s.fromSecret = function(t3, e3) { + return e3 instanceof s ? e3 : new s(t3, {secret: e3}); + }, s.prototype.secret = function() { + return this._secret; + }, a(s, "pubBytes", function() { + return this.eddsa.encodePoint(this.pub()); + }), a(s, "pub", function() { + return this._pubBytes ? this.eddsa.decodePoint(this._pubBytes) : this.eddsa.g.mul(this.priv()); + }), a(s, "privBytes", function() { + var t3 = this.eddsa, e3 = this.hash(), r3 = t3.encodingLength - 1, n2 = e3.slice(0, t3.encodingLength); + return n2[0] &= 248, n2[r3] &= 127, n2[r3] |= 64, n2; + }), a(s, "priv", function() { + return this.eddsa.decodeInt(this.privBytes()); + }), a(s, "hash", function() { + return this.eddsa.hash().update(this.secret()).digest(); + }), a(s, "messagePrefix", function() { + return this.hash().slice(this.eddsa.encodingLength); + }), s.prototype.sign = function(t3) { + return i(this._secret, "KeyPair can only verify"), this.eddsa.sign(t3, this); + }, s.prototype.verify = function(t3, e3) { + return this.eddsa.verify(t3, e3, this); + }, s.prototype.getSecret = function(t3) { + return i(this._secret, "KeyPair is public only"), n.encode(this.secret(), t3); + }, s.prototype.getPublic = function(t3) { + return n.encode(this.pubBytes(), t3); + }, t2.exports = s; + }, 3622: (t2, e2, r2) => { + var n = r2(3550), i = r2(953), o = i.assert, a = i.cachedProperty, s = i.parseBytes; + function u(t3, e3) { + this.eddsa = t3, typeof e3 != "object" && (e3 = s(e3)), Array.isArray(e3) && (e3 = {R: e3.slice(0, t3.encodingLength), S: e3.slice(t3.encodingLength)}), o(e3.R && e3.S, "Signature without R or S"), t3.isPoint(e3.R) && (this._R = e3.R), e3.S instanceof n && (this._S = e3.S), this._Rencoded = Array.isArray(e3.R) ? e3.R : e3.Rencoded, this._Sencoded = Array.isArray(e3.S) ? e3.S : e3.Sencoded; + } + a(u, "S", function() { + return this.eddsa.decodeInt(this.Sencoded()); + }), a(u, "R", function() { + return this.eddsa.decodePoint(this.Rencoded()); + }), a(u, "Rencoded", function() { + return this.eddsa.encodePoint(this.R()); + }), a(u, "Sencoded", function() { + return this.eddsa.encodeInt(this.S()); + }), u.prototype.toBytes = function() { + return this.Rencoded().concat(this.Sencoded()); + }, u.prototype.toHex = function() { + return i.encode(this.toBytes(), "hex").toUpperCase(); + }, t2.exports = u; + }, 1037: (t2) => { + t2.exports = {doubles: {step: 4, points: [["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a", "f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"], ["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508", "11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"], ["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739", "d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"], ["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640", "4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"], ["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c", "4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"], ["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda", "96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"], ["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa", "5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"], ["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0", "cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"], ["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d", "9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"], ["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d", "e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"], ["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1", "9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"], ["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0", "5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"], ["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047", "10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"], ["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862", "283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"], ["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7", "7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"], ["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd", "56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"], ["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83", "7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"], ["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a", "53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"], ["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8", "bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"], ["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d", "4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"], ["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725", "7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"], ["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754", "4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"], ["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c", "17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"], ["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6", "6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"], ["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39", "c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"], ["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891", "893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"], ["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b", "febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"], ["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03", "2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"], ["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d", "eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"], ["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070", "7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"], ["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4", "e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"], ["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da", "662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"], ["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11", "1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"], ["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e", "efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"], ["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41", "2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"], ["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef", "67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"], ["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8", "db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"], ["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d", "648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"], ["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96", "35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"], ["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd", "ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"], ["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5", "9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"], ["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266", "40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"], ["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71", "34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"], ["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac", "c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"], ["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751", "1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"], ["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e", "493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"], ["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241", "c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"], ["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3", "be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"], ["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f", "4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"], ["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19", "aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"], ["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be", "b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"], ["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9", "6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"], ["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2", "8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"], ["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13", "7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"], ["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c", "ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"], ["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba", "2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"], ["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151", "e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"], ["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073", "d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"], ["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458", "38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"], ["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b", "69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"], ["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366", "d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"], ["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa", "40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"], ["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0", "620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"], ["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787", "7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"], ["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e", "ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]}, naf: {wnd: 7, points: [["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9", "388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"], ["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4", "d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"], ["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc", "6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"], ["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe", "cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"], ["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb", "d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"], ["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8", "ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"], ["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"], ["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34", "4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"], ["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c", "85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"], ["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5", "321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"], ["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f", "2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"], ["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714", "73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"], ["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729", "a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"], ["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db", "2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"], ["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4", "e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"], ["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5", "b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"], ["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479", "2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"], ["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d", "80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"], ["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f", "1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"], ["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb", "d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"], ["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9", "eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"], ["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963", "758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"], ["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74", "958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"], ["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530", "e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"], ["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b", "5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"], ["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247", "cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"], ["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1", "cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"], ["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120", "4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"], ["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435", "91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"], ["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18", "673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"], ["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8", "59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"], ["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb", "3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"], ["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f", "55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"], ["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143", "efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"], ["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba", "e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"], ["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45", "f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"], ["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a", "744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"], ["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e", "c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"], ["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8", "e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"], ["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c", "30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"], ["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519", "e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"], ["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab", "100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"], ["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca", "ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"], ["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf", "8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"], ["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610", "68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"], ["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4", "f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"], ["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c", "d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"], ["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940", "edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"], ["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980", "a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"], ["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3", "66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"], ["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf", "9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"], ["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63", "4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"], ["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448", "fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"], ["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf", "5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"], ["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5", "8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"], ["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6", "8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"], ["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5", "5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"], ["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99", "f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"], ["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51", "f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"], ["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5", "42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"], ["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5", "204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"], ["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997", "4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"], ["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881", "73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"], ["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5", "39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"], ["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66", "d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"], ["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726", "ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"], ["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede", "6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"], ["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94", "60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"], ["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31", "3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"], ["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51", "b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"], ["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252", "ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"], ["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5", "cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"], ["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b", "6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"], ["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4", "322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"], ["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f", "6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"], ["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889", "2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"], ["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246", "b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"], ["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984", "998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"], ["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a", "b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"], ["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030", "bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"], ["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197", "6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"], ["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593", "c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"], ["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef", "21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"], ["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38", "60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"], ["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a", "49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"], ["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111", "5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"], ["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502", "7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"], ["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea", "be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"], ["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26", "8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"], ["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986", "39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"], ["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e", "62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"], ["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4", "25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"], ["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda", "ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"], ["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859", "cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"], ["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f", "f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"], ["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c", "6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"], ["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942", "fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"], ["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a", "1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"], ["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80", "5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"], ["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d", "438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"], ["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1", "cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"], ["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63", "c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"], ["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352", "6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"], ["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193", "ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"], ["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00", "9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"], ["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58", "ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"], ["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7", "d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"], ["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8", "c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"], ["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e", "67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"], ["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d", "cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"], ["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b", "299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"], ["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f", "f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"], ["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6", "462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"], ["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297", "62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"], ["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a", "7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"], ["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c", "ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"], ["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52", "4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"], ["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb", "bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"], ["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065", "bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"], ["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917", "603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"], ["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9", "cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"], ["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3", "553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"], ["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57", "712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"], ["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66", "ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"], ["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8", "9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"], ["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721", "9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"], ["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180", "4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}; + }, 953: (t2, e2, r2) => { + var n = e2, i = r2(3550), o = r2(9746), a = r2(4504); + n.assert = o, n.toArray = a.toArray, n.zero2 = a.zero2, n.toHex = a.toHex, n.encode = a.encode, n.getNAF = function(t3, e3, r3) { + var n2 = new Array(Math.max(t3.bitLength(), r3) + 1); + n2.fill(0); + for (var i2 = 1 << e3 + 1, o2 = t3.clone(), a2 = 0; a2 < n2.length; a2++) { + var s, u = o2.andln(i2 - 1); + o2.isOdd() ? (s = u > (i2 >> 1) - 1 ? (i2 >> 1) - u : u, o2.isubn(s)) : s = 0, n2[a2] = s, o2.iushrn(1); + } + return n2; + }, n.getJSF = function(t3, e3) { + var r3 = [[], []]; + t3 = t3.clone(), e3 = e3.clone(); + for (var n2, i2 = 0, o2 = 0; t3.cmpn(-i2) > 0 || e3.cmpn(-o2) > 0; ) { + var a2, s, u = t3.andln(3) + i2 & 3, f = e3.andln(3) + o2 & 3; + u === 3 && (u = -1), f === 3 && (f = -1), a2 = (1 & u) == 0 ? 0 : (n2 = t3.andln(7) + i2 & 7) != 3 && n2 !== 5 || f !== 2 ? u : -u, r3[0].push(a2), s = (1 & f) == 0 ? 0 : (n2 = e3.andln(7) + o2 & 7) != 3 && n2 !== 5 || u !== 2 ? f : -f, r3[1].push(s), 2 * i2 === a2 + 1 && (i2 = 1 - i2), 2 * o2 === s + 1 && (o2 = 1 - o2), t3.iushrn(1), e3.iushrn(1); + } + return r3; + }, n.cachedProperty = function(t3, e3, r3) { + var n2 = "_" + e3; + t3.prototype[e3] = function() { + return this[n2] !== void 0 ? this[n2] : this[n2] = r3.call(this); + }; + }, n.parseBytes = function(t3) { + return typeof t3 == "string" ? n.toArray(t3, "hex") : t3; + }, n.intFromLE = function(t3) { + return new i(t3, "hex", "le"); + }; + }, 7519: (t2) => { + t2.exports = {i8: "6.5.4"}; + }, 4079: (t2, e2, r2) => { + var n = r2(210)("%Object.getOwnPropertyDescriptor%"); + if (n) + try { + n([], "length"); + } catch (t3) { + n = null; + } + t2.exports = n; + }, 8091: (t2) => { + function e2(t3, e3) { + if (t3 == null) + throw new TypeError("Cannot convert first argument to object"); + for (var r2 = Object(t3), n = 1; n < arguments.length; n++) { + var i = arguments[n]; + if (i != null) + for (var o = Object.keys(Object(i)), a = 0, s = o.length; a < s; a++) { + var u = o[a], f = Object.getOwnPropertyDescriptor(i, u); + f !== void 0 && f.enumerable && (r2[u] = i[u]); + } + } + return r2; + } + t2.exports = {assign: e2, polyfill: function() { + Object.assign || Object.defineProperty(Object, "assign", {enumerable: false, configurable: true, writable: true, value: e2}); + }}; + }, 5443: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}), e2.createHashFunction = function(t3) { + return function(e3) { + var r3 = t3(); + return r3.update(e3), n.from(r3.digest()); + }; + }; + }, 949: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}); + var n = r2(6167); + e2.HDKey = n; + }, 682: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}); + var n = r2(2949).ripemd160, i = r2(5443); + e2.ripemd160 = i.createHashFunction(function() { + return new n(); + }); + }, 4237: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}); + var n = r2(9344), i = r2(5443); + e2.sha256 = i.createHashFunction(function() { + return new n(); + }); + }, 2326: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}); + var i = r2(682), o = r2(4237); + e2.createHmac = r2(8355), e2.randomBytes = r2(1798); + var a = function() { + function t3(t4) { + this.hashFunction = t4, this.buffers = []; + } + return t3.prototype.update = function(t4) { + if (!n.isBuffer(t4)) + throw new Error("hdkey-crypto shim is outdated"); + return this.buffers.push(t4), this; + }, t3.prototype.digest = function(t4) { + if (t4) + throw new Error("hdkey-crypto shim is outdated"); + return this.hashFunction(n.concat(this.buffers)); + }, t3; + }(); + e2.createHash = function(t3) { + if (t3 === "ripemd160") + return new a(i.ripemd160); + if (t3 === "sha256") + return new a(o.sha256); + throw new Error("hdkey-crypto shim is outdated"); + }; + }, 4863: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}), function(t3) { + for (var r3 in t3) + e2.hasOwnProperty(r3) || (e2[r3] = t3[r3]); + }(r2(6454)); + }, 6167: (t2, e2, r2) => { + function n(t3) { + return t3 && typeof t3 == "object" && "default" in t3 ? t3.default : t3; + } + var i = n(r2(9282)), o = n(r2(9509)), a = n(r2(8334)), s = r2(2326), u = r2(4863), f = o.Buffer, c = f.from("Bitcoin seed", "utf8"), h = 2147483648, l = {private: 76066276, public: 76067358}; + function d(t3) { + this.versions = t3 || l, this.depth = 0, this.index = 0, this._privateKey = null, this._publicKey = null, this.chainCode = null, this._fingerprint = 0, this.parentFingerprint = 0; + } + function p(t3, e3, r3) { + var n2 = f.allocUnsafe(78); + n2.writeUInt32BE(e3, 0), n2.writeUInt8(t3.depth, 4); + var i2 = t3.depth ? t3.parentFingerprint : 0; + return n2.writeUInt32BE(i2, 5), n2.writeUInt32BE(t3.index, 9), t3.chainCode.copy(n2, 13), r3.copy(n2, 45), n2; + } + function y(t3) { + var e3 = s.createHash("sha256").update(t3).digest(); + return s.createHash("ripemd160").update(e3).digest(); + } + Object.defineProperty(d.prototype, "fingerprint", {get: function() { + return this._fingerprint; + }}), Object.defineProperty(d.prototype, "identifier", {get: function() { + return this._identifier; + }}), Object.defineProperty(d.prototype, "pubKeyHash", {get: function() { + return this.identifier; + }}), Object.defineProperty(d.prototype, "privateKey", {get: function() { + return this._privateKey; + }, set: function(t3) { + i.equal(t3.length, 32, "Private key must be 32 bytes."), i(u.privateKeyVerify(t3) === true, "Invalid private key"), this._privateKey = t3, this._publicKey = u.publicKeyCreate(t3, true), this._identifier = y(this.publicKey), this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); + }}), Object.defineProperty(d.prototype, "publicKey", {get: function() { + return this._publicKey; + }, set: function(t3) { + i(t3.length === 33 || t3.length === 65, "Public key must be 33 or 65 bytes."), i(u.publicKeyVerify(t3) === true, "Invalid public key"), this._publicKey = u.publicKeyConvert(t3, true), this._identifier = y(this.publicKey), this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0), this._privateKey = null; + }}), Object.defineProperty(d.prototype, "privateExtendedKey", {get: function() { + return this._privateKey ? a.encode(p(this, this.versions.private, f.concat([f.alloc(1, 0), this.privateKey]))) : null; + }}), Object.defineProperty(d.prototype, "publicExtendedKey", {get: function() { + return a.encode(p(this, this.versions.public, this.publicKey)); + }}), d.prototype.derive = function(t3) { + if (t3 === "m" || t3 === "M" || t3 === "m'" || t3 === "M'") + return this; + var e3 = t3.split("/"), r3 = this; + return e3.forEach(function(t4, e4) { + if (e4 !== 0) { + var n2 = t4.length > 1 && t4[t4.length - 1] === "'", o2 = parseInt(t4, 10); + i(o2 < h, "Invalid index"), n2 && (o2 += h), r3 = r3.deriveChild(o2); + } else + i(/^[mM]{1}/.test(t4), 'Path must start with "m" or "M"'); + }), r3; + }, d.prototype.deriveChild = function(t3) { + var e3, r3 = t3 >= h, n2 = f.allocUnsafe(4); + if (n2.writeUInt32BE(t3, 0), r3) { + i(this.privateKey, "Could not derive hardened child key"); + var o2 = this.privateKey, a2 = f.alloc(1, 0); + o2 = f.concat([a2, o2]), e3 = f.concat([o2, n2]); + } else + e3 = f.concat([this.publicKey, n2]); + var c2 = s.createHmac("sha512", this.chainCode).update(e3).digest(), l2 = c2.slice(0, 32), p2 = c2.slice(32), y2 = new d(this.versions); + if (this.privateKey) + try { + y2.privateKey = u.privateKeyTweakAdd(this.privateKey, l2); + } catch (e4) { + return this.deriveChild(t3 + 1); + } + else + try { + y2.publicKey = u.publicKeyTweakAdd(this.publicKey, l2, true); + } catch (e4) { + return this.deriveChild(t3 + 1); + } + return y2.chainCode = p2, y2.depth = this.depth + 1, y2.parentFingerprint = this.fingerprint, y2.index = t3, y2; + }, d.prototype.sign = function(t3) { + return u.sign(t3, this.privateKey).signature; + }, d.prototype.verify = function(t3, e3) { + return u.verify(t3, e3, this.publicKey); + }, d.prototype.wipePrivateData = function() { + return this._privateKey && s.randomBytes(this._privateKey.length).copy(this._privateKey), this._privateKey = null, this; + }, d.prototype.toJSON = function() { + return {xpriv: this.privateExtendedKey, xpub: this.publicExtendedKey}; + }, d.fromMasterSeed = function(t3, e3) { + var r3 = s.createHmac("sha512", c).update(t3).digest(), n2 = r3.slice(0, 32), i2 = r3.slice(32), o2 = new d(e3); + return o2.chainCode = i2, o2.privateKey = n2, o2; + }, d.fromExtendedKey = function(t3, e3) { + var r3 = new d(e3 = e3 || l), n2 = a.decode(t3), o2 = n2.readUInt32BE(0); + i(o2 === e3.private || o2 === e3.public, "Version mismatch: does not match private or public"), r3.depth = n2.readUInt8(4), r3.parentFingerprint = n2.readUInt32BE(5), r3.index = n2.readUInt32BE(9), r3.chainCode = n2.slice(13, 45); + var s2 = n2.slice(45); + return s2.readUInt8(0) === 0 ? (i(o2 === e3.private, "Version mismatch: version does not match private"), r3.privateKey = s2.slice(1)) : (i(o2 === e3.public, "Version mismatch: version does not match public"), r3.publicKey = s2), r3; + }, d.fromJSON = function(t3) { + return d.fromExtendedKey(t3.xpriv); + }, d.HARDENED_OFFSET = h; + var m = d; + t2.exports = m; + }, 472: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}); + var n = r2(1798); + e2.getRandomBytes = function(t3) { + return new Promise(function(e3, r3) { + n(t3, function(t4, n2) { + t4 ? r3(t4) : e3(n2); + }); + }); + }, e2.getRandomBytesSync = function(t3) { + return n(t3); + }; + }, 5053: function(t2, e2, r2) { + var n = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, i = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s(o3) { + return function(s2) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s2]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var o = r2(7221), a = r2(472); + e2.createPrivateKey = function() { + return n(this, void 0, void 0, function() { + var t3; + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, a.getRandomBytes(32)]; + case 1: + return t3 = e3.sent(), o.privateKeyVerify(t3) ? [2, t3] : [3, 0]; + case 2: + return [2]; + } + }); + }); + }, e2.createPrivateKeySync = function() { + for (; ; ) { + var t3 = a.getRandomBytesSync(32); + if (o.privateKeyVerify(t3)) + return t3; + } + }, function(t3) { + for (var r3 in t3) + e2.hasOwnProperty(r3) || (e2[r3] = t3[r3]); + }(r2(7221)); + }, 6454: function(t2, e2, r2) { + var n = r2(8764).Buffer, i = this && this.__importStar || function(t3) { + if (t3 && t3.__esModule) + return t3; + var e3 = {}; + if (t3 != null) + for (var r3 in t3) + Object.hasOwnProperty.call(t3, r3) && (e3[r3] = t3[r3]); + return e3.default = t3, e3; + }; + Object.defineProperty(e2, "__esModule", {value: true}); + var o = i(r2(7221)); + e2.privateKeyVerify = function(t3) { + return o.privateKeyVerify(t3); + }, e2.publicKeyCreate = function(t3, e3) { + return e3 === void 0 && (e3 = true), n.from(o.publicKeyCreate(t3, e3)); + }, e2.publicKeyVerify = function(t3) { + return o.publicKeyVerify(t3); + }, e2.publicKeyConvert = function(t3, e3) { + return e3 === void 0 && (e3 = true), n.from(o.publicKeyConvert(t3, e3)); + }, e2.privateKeyTweakAdd = function(t3, e3) { + return n.from(o.privateKeyTweakAdd(n.from(t3), e3)); + }, e2.publicKeyTweakAdd = function(t3, e3, r3) { + return r3 === void 0 && (r3 = true), n.from(o.publicKeyTweakAdd(n.from(t3), e3, r3)); + }, e2.sign = function(t3, e3) { + var r3 = o.ecdsaSign(t3, e3); + return {signature: n.from(r3.signature), recovery: r3.recid}; + }, e2.verify = function(t3, e3, r3) { + return o.ecdsaVerify(e3, t3, r3); + }; + }, 7187: (t2) => { + var e2, r2 = typeof Reflect == "object" ? Reflect : null, n = r2 && typeof r2.apply == "function" ? r2.apply : function(t3, e3, r3) { + return Function.prototype.apply.call(t3, e3, r3); + }; + e2 = r2 && typeof r2.ownKeys == "function" ? r2.ownKeys : Object.getOwnPropertySymbols ? function(t3) { + return Object.getOwnPropertyNames(t3).concat(Object.getOwnPropertySymbols(t3)); + } : function(t3) { + return Object.getOwnPropertyNames(t3); + }; + var i = Number.isNaN || function(t3) { + return t3 != t3; + }; + function o() { + o.init.call(this); + } + t2.exports = o, t2.exports.once = function(t3, e3) { + return new Promise(function(r3, n2) { + function i2(r4) { + t3.removeListener(e3, o2), n2(r4); + } + function o2() { + typeof t3.removeListener == "function" && t3.removeListener("error", i2), r3([].slice.call(arguments)); + } + y(t3, e3, o2, {once: true}), e3 !== "error" && function(t4, e4, r4) { + typeof t4.on == "function" && y(t4, "error", e4, {once: true}); + }(t3, i2); + }); + }, o.EventEmitter = o, o.prototype._events = void 0, o.prototype._eventsCount = 0, o.prototype._maxListeners = void 0; + var a = 10; + function s(t3) { + if (typeof t3 != "function") + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t3); + } + function u(t3) { + return t3._maxListeners === void 0 ? o.defaultMaxListeners : t3._maxListeners; + } + function f(t3, e3, r3, n2) { + var i2, o2, a2, f2; + if (s(r3), (o2 = t3._events) === void 0 ? (o2 = t3._events = Object.create(null), t3._eventsCount = 0) : (o2.newListener !== void 0 && (t3.emit("newListener", e3, r3.listener ? r3.listener : r3), o2 = t3._events), a2 = o2[e3]), a2 === void 0) + a2 = o2[e3] = r3, ++t3._eventsCount; + else if (typeof a2 == "function" ? a2 = o2[e3] = n2 ? [r3, a2] : [a2, r3] : n2 ? a2.unshift(r3) : a2.push(r3), (i2 = u(t3)) > 0 && a2.length > i2 && !a2.warned) { + a2.warned = true; + var c2 = new Error("Possible EventEmitter memory leak detected. " + a2.length + " " + String(e3) + " listeners added. Use emitter.setMaxListeners() to increase limit"); + c2.name = "MaxListenersExceededWarning", c2.emitter = t3, c2.type = e3, c2.count = a2.length, f2 = c2, console && console.warn && console.warn(f2); + } + return t3; + } + function c() { + if (!this.fired) + return this.target.removeListener(this.type, this.wrapFn), this.fired = true, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); + } + function h(t3, e3, r3) { + var n2 = {fired: false, wrapFn: void 0, target: t3, type: e3, listener: r3}, i2 = c.bind(n2); + return i2.listener = r3, n2.wrapFn = i2, i2; + } + function l(t3, e3, r3) { + var n2 = t3._events; + if (n2 === void 0) + return []; + var i2 = n2[e3]; + return i2 === void 0 ? [] : typeof i2 == "function" ? r3 ? [i2.listener || i2] : [i2] : r3 ? function(t4) { + for (var e4 = new Array(t4.length), r4 = 0; r4 < e4.length; ++r4) + e4[r4] = t4[r4].listener || t4[r4]; + return e4; + }(i2) : p(i2, i2.length); + } + function d(t3) { + var e3 = this._events; + if (e3 !== void 0) { + var r3 = e3[t3]; + if (typeof r3 == "function") + return 1; + if (r3 !== void 0) + return r3.length; + } + return 0; + } + function p(t3, e3) { + for (var r3 = new Array(e3), n2 = 0; n2 < e3; ++n2) + r3[n2] = t3[n2]; + return r3; + } + function y(t3, e3, r3, n2) { + if (typeof t3.on == "function") + n2.once ? t3.once(e3, r3) : t3.on(e3, r3); + else { + if (typeof t3.addEventListener != "function") + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t3); + t3.addEventListener(e3, function i2(o2) { + n2.once && t3.removeEventListener(e3, i2), r3(o2); + }); + } + } + Object.defineProperty(o, "defaultMaxListeners", {enumerable: true, get: function() { + return a; + }, set: function(t3) { + if (typeof t3 != "number" || t3 < 0 || i(t3)) + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t3 + "."); + a = t3; + }}), o.init = function() { + this._events !== void 0 && this._events !== Object.getPrototypeOf(this)._events || (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; + }, o.prototype.setMaxListeners = function(t3) { + if (typeof t3 != "number" || t3 < 0 || i(t3)) + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + t3 + "."); + return this._maxListeners = t3, this; + }, o.prototype.getMaxListeners = function() { + return u(this); + }, o.prototype.emit = function(t3) { + for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) + e3.push(arguments[r3]); + var i2 = t3 === "error", o2 = this._events; + if (o2 !== void 0) + i2 = i2 && o2.error === void 0; + else if (!i2) + return false; + if (i2) { + var a2; + if (e3.length > 0 && (a2 = e3[0]), a2 instanceof Error) + throw a2; + var s2 = new Error("Unhandled error." + (a2 ? " (" + a2.message + ")" : "")); + throw s2.context = a2, s2; + } + var u2 = o2[t3]; + if (u2 === void 0) + return false; + if (typeof u2 == "function") + n(u2, this, e3); + else { + var f2 = u2.length, c2 = p(u2, f2); + for (r3 = 0; r3 < f2; ++r3) + n(c2[r3], this, e3); + } + return true; + }, o.prototype.addListener = function(t3, e3) { + return f(this, t3, e3, false); + }, o.prototype.on = o.prototype.addListener, o.prototype.prependListener = function(t3, e3) { + return f(this, t3, e3, true); + }, o.prototype.once = function(t3, e3) { + return s(e3), this.on(t3, h(this, t3, e3)), this; + }, o.prototype.prependOnceListener = function(t3, e3) { + return s(e3), this.prependListener(t3, h(this, t3, e3)), this; + }, o.prototype.removeListener = function(t3, e3) { + var r3, n2, i2, o2, a2; + if (s(e3), (n2 = this._events) === void 0) + return this; + if ((r3 = n2[t3]) === void 0) + return this; + if (r3 === e3 || r3.listener === e3) + --this._eventsCount == 0 ? this._events = Object.create(null) : (delete n2[t3], n2.removeListener && this.emit("removeListener", t3, r3.listener || e3)); + else if (typeof r3 != "function") { + for (i2 = -1, o2 = r3.length - 1; o2 >= 0; o2--) + if (r3[o2] === e3 || r3[o2].listener === e3) { + a2 = r3[o2].listener, i2 = o2; + break; + } + if (i2 < 0) + return this; + i2 === 0 ? r3.shift() : function(t4, e4) { + for (; e4 + 1 < t4.length; e4++) + t4[e4] = t4[e4 + 1]; + t4.pop(); + }(r3, i2), r3.length === 1 && (n2[t3] = r3[0]), n2.removeListener !== void 0 && this.emit("removeListener", t3, a2 || e3); + } + return this; + }, o.prototype.off = o.prototype.removeListener, o.prototype.removeAllListeners = function(t3) { + var e3, r3, n2; + if ((r3 = this._events) === void 0) + return this; + if (r3.removeListener === void 0) + return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : r3[t3] !== void 0 && (--this._eventsCount == 0 ? this._events = Object.create(null) : delete r3[t3]), this; + if (arguments.length === 0) { + var i2, o2 = Object.keys(r3); + for (n2 = 0; n2 < o2.length; ++n2) + (i2 = o2[n2]) !== "removeListener" && this.removeAllListeners(i2); + return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this; + } + if (typeof (e3 = r3[t3]) == "function") + this.removeListener(t3, e3); + else if (e3 !== void 0) + for (n2 = e3.length - 1; n2 >= 0; n2--) + this.removeListener(t3, e3[n2]); + return this; + }, o.prototype.listeners = function(t3) { + return l(this, t3, true); + }, o.prototype.rawListeners = function(t3) { + return l(this, t3, false); + }, o.listenerCount = function(t3, e3) { + return typeof t3.listenerCount == "function" ? t3.listenerCount(e3) : d.call(t3, e3); + }, o.prototype.listenerCount = d, o.prototype.eventNames = function() { + return this._eventsCount > 0 ? e2(this._events) : []; + }; + }, 3048: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(2318); + t2.exports = function(t3, e3, r3, o) { + if (n.isBuffer(t3) || (t3 = n.from(t3, "binary")), e3 && (n.isBuffer(e3) || (e3 = n.from(e3, "binary")), e3.length !== 8)) + throw new RangeError("salt should be Buffer with 8 byte length"); + for (var a = r3 / 8, s = n.alloc(a), u = n.alloc(o || 0), f = n.alloc(0); a > 0 || o > 0; ) { + var c = new i(); + c.update(f), c.update(t3), e3 && c.update(e3), f = c.digest(); + var h = 0; + if (a > 0) { + var l = s.length - a; + h = Math.min(a, f.length), f.copy(s, l, 0, h), a -= h; + } + if (h < f.length && o > 0) { + var d = u.length - o, p = Math.min(o, f.length - h); + f.copy(u, d, h, h + p), o -= p; + } + } + return f.fill(0), {key: s, iv: u}; + }; + }, 9804: (t2) => { + var e2 = Object.prototype.hasOwnProperty, r2 = Object.prototype.toString; + t2.exports = function(t3, n, i) { + if (r2.call(n) !== "[object Function]") + throw new TypeError("iterator must be a function"); + var o = t3.length; + if (o === +o) + for (var a = 0; a < o; a++) + n.call(i, t3[a], a, t3); + else + for (var s in t3) + e2.call(t3, s) && n.call(i, t3[s], s, t3); + }; + }, 7648: (t2) => { + var e2 = "Function.prototype.bind called on incompatible ", r2 = Array.prototype.slice, n = Object.prototype.toString, i = "[object Function]"; + t2.exports = function(t3) { + var o = this; + if (typeof o != "function" || n.call(o) !== i) + throw new TypeError(e2 + o); + for (var a, s = r2.call(arguments, 1), u = function() { + if (this instanceof a) { + var e3 = o.apply(this, s.concat(r2.call(arguments))); + return Object(e3) === e3 ? e3 : this; + } + return o.apply(t3, s.concat(r2.call(arguments))); + }, f = Math.max(0, o.length - s.length), c = [], h = 0; h < f; h++) + c.push("$" + h); + if (a = Function("binder", "return function (" + c.join(",") + "){ return binder.apply(this,arguments); }")(u), o.prototype) { + var l = function() { + }; + l.prototype = o.prototype, a.prototype = new l(), l.prototype = null; + } + return a; + }; + }, 8612: (t2, e2, r2) => { + var n = r2(7648); + t2.exports = Function.prototype.bind || n; + }, 210: (t2, e2, r2) => { + var n, i = SyntaxError, o = Function, a = TypeError, s = function(t3) { + try { + return o('"use strict"; return (' + t3 + ").constructor;")(); + } catch (t4) { + } + }, u = Object.getOwnPropertyDescriptor; + if (u) + try { + u({}, ""); + } catch (t3) { + u = null; + } + var f = function() { + throw new a(); + }, c = u ? function() { + try { + return f; + } catch (t3) { + try { + return u(arguments, "callee").get; + } catch (t4) { + return f; + } + } + }() : f, h = r2(1405)(), l = Object.getPrototypeOf || function(t3) { + return t3.__proto__; + }, d = {}, p = typeof Uint8Array == "undefined" ? n : l(Uint8Array), y = {"%AggregateError%": typeof AggregateError == "undefined" ? n : AggregateError, "%Array%": Array, "%ArrayBuffer%": typeof ArrayBuffer == "undefined" ? n : ArrayBuffer, "%ArrayIteratorPrototype%": h ? l([][Symbol.iterator]()) : n, "%AsyncFromSyncIteratorPrototype%": n, "%AsyncFunction%": d, "%AsyncGenerator%": d, "%AsyncGeneratorFunction%": d, "%AsyncIteratorPrototype%": d, "%Atomics%": typeof Atomics == "undefined" ? n : Atomics, "%BigInt%": typeof BigInt == "undefined" ? n : BigInt, "%Boolean%": Boolean, "%DataView%": typeof DataView == "undefined" ? n : DataView, "%Date%": Date, "%decodeURI%": decodeURI, "%decodeURIComponent%": decodeURIComponent, "%encodeURI%": encodeURI, "%encodeURIComponent%": encodeURIComponent, "%Error%": Error, "%eval%": eval, "%EvalError%": EvalError, "%Float32Array%": typeof Float32Array == "undefined" ? n : Float32Array, "%Float64Array%": typeof Float64Array == "undefined" ? n : Float64Array, "%FinalizationRegistry%": typeof FinalizationRegistry == "undefined" ? n : FinalizationRegistry, "%Function%": o, "%GeneratorFunction%": d, "%Int8Array%": typeof Int8Array == "undefined" ? n : Int8Array, "%Int16Array%": typeof Int16Array == "undefined" ? n : Int16Array, "%Int32Array%": typeof Int32Array == "undefined" ? n : Int32Array, "%isFinite%": isFinite, "%isNaN%": isNaN, "%IteratorPrototype%": h ? l(l([][Symbol.iterator]())) : n, "%JSON%": typeof JSON == "object" ? JSON : n, "%Map%": typeof Map == "undefined" ? n : Map, "%MapIteratorPrototype%": typeof Map != "undefined" && h ? l(new Map()[Symbol.iterator]()) : n, "%Math%": Math, "%Number%": Number, "%Object%": Object, "%parseFloat%": parseFloat, "%parseInt%": parseInt, "%Promise%": typeof Promise == "undefined" ? n : Promise, "%Proxy%": typeof Proxy == "undefined" ? n : Proxy, "%RangeError%": RangeError, "%ReferenceError%": ReferenceError, "%Reflect%": typeof Reflect == "undefined" ? n : Reflect, "%RegExp%": RegExp, "%Set%": typeof Set == "undefined" ? n : Set, "%SetIteratorPrototype%": typeof Set != "undefined" && h ? l(new Set()[Symbol.iterator]()) : n, "%SharedArrayBuffer%": typeof SharedArrayBuffer == "undefined" ? n : SharedArrayBuffer, "%String%": String, "%StringIteratorPrototype%": h ? l(""[Symbol.iterator]()) : n, "%Symbol%": h ? Symbol : n, "%SyntaxError%": i, "%ThrowTypeError%": c, "%TypedArray%": p, "%TypeError%": a, "%Uint8Array%": typeof Uint8Array == "undefined" ? n : Uint8Array, "%Uint8ClampedArray%": typeof Uint8ClampedArray == "undefined" ? n : Uint8ClampedArray, "%Uint16Array%": typeof Uint16Array == "undefined" ? n : Uint16Array, "%Uint32Array%": typeof Uint32Array == "undefined" ? n : Uint32Array, "%URIError%": URIError, "%WeakMap%": typeof WeakMap == "undefined" ? n : WeakMap, "%WeakRef%": typeof WeakRef == "undefined" ? n : WeakRef, "%WeakSet%": typeof WeakSet == "undefined" ? n : WeakSet}, m = function t3(e3) { + var r3; + if (e3 === "%AsyncFunction%") + r3 = s("async function () {}"); + else if (e3 === "%GeneratorFunction%") + r3 = s("function* () {}"); + else if (e3 === "%AsyncGeneratorFunction%") + r3 = s("async function* () {}"); + else if (e3 === "%AsyncGenerator%") { + var n2 = t3("%AsyncGeneratorFunction%"); + n2 && (r3 = n2.prototype); + } else if (e3 === "%AsyncIteratorPrototype%") { + var i2 = t3("%AsyncGenerator%"); + i2 && (r3 = l(i2.prototype)); + } + return y[e3] = r3, r3; + }, b = {"%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"], "%ArrayPrototype%": ["Array", "prototype"], "%ArrayProto_entries%": ["Array", "prototype", "entries"], "%ArrayProto_forEach%": ["Array", "prototype", "forEach"], "%ArrayProto_keys%": ["Array", "prototype", "keys"], "%ArrayProto_values%": ["Array", "prototype", "values"], "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"], "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"], "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"], "%BooleanPrototype%": ["Boolean", "prototype"], "%DataViewPrototype%": ["DataView", "prototype"], "%DatePrototype%": ["Date", "prototype"], "%ErrorPrototype%": ["Error", "prototype"], "%EvalErrorPrototype%": ["EvalError", "prototype"], "%Float32ArrayPrototype%": ["Float32Array", "prototype"], "%Float64ArrayPrototype%": ["Float64Array", "prototype"], "%FunctionPrototype%": ["Function", "prototype"], "%Generator%": ["GeneratorFunction", "prototype"], "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"], "%Int8ArrayPrototype%": ["Int8Array", "prototype"], "%Int16ArrayPrototype%": ["Int16Array", "prototype"], "%Int32ArrayPrototype%": ["Int32Array", "prototype"], "%JSONParse%": ["JSON", "parse"], "%JSONStringify%": ["JSON", "stringify"], "%MapPrototype%": ["Map", "prototype"], "%NumberPrototype%": ["Number", "prototype"], "%ObjectPrototype%": ["Object", "prototype"], "%ObjProto_toString%": ["Object", "prototype", "toString"], "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"], "%PromisePrototype%": ["Promise", "prototype"], "%PromiseProto_then%": ["Promise", "prototype", "then"], "%Promise_all%": ["Promise", "all"], "%Promise_reject%": ["Promise", "reject"], "%Promise_resolve%": ["Promise", "resolve"], "%RangeErrorPrototype%": ["RangeError", "prototype"], "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"], "%RegExpPrototype%": ["RegExp", "prototype"], "%SetPrototype%": ["Set", "prototype"], "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"], "%StringPrototype%": ["String", "prototype"], "%SymbolPrototype%": ["Symbol", "prototype"], "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"], "%TypedArrayPrototype%": ["TypedArray", "prototype"], "%TypeErrorPrototype%": ["TypeError", "prototype"], "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"], "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"], "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"], "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"], "%URIErrorPrototype%": ["URIError", "prototype"], "%WeakMapPrototype%": ["WeakMap", "prototype"], "%WeakSetPrototype%": ["WeakSet", "prototype"]}, g = r2(8612), v = r2(7642), w = g.call(Function.call, Array.prototype.concat), _ = g.call(Function.apply, Array.prototype.splice), M = g.call(Function.call, String.prototype.replace), S = g.call(Function.call, String.prototype.slice), E = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, A = /\\(\\)?/g, k = function(t3) { + var e3 = S(t3, 0, 1), r3 = S(t3, -1); + if (e3 === "%" && r3 !== "%") + throw new i("invalid intrinsic syntax, expected closing `%`"); + if (r3 === "%" && e3 !== "%") + throw new i("invalid intrinsic syntax, expected opening `%`"); + var n2 = []; + return M(t3, E, function(t4, e4, r4, i2) { + n2[n2.length] = r4 ? M(i2, A, "$1") : e4 || t4; + }), n2; + }, B = function(t3, e3) { + var r3, n2 = t3; + if (v(b, n2) && (n2 = "%" + (r3 = b[n2])[0] + "%"), v(y, n2)) { + var o2 = y[n2]; + if (o2 === d && (o2 = m(n2)), o2 === void 0 && !e3) + throw new a("intrinsic " + t3 + " exists, but is not available. Please file an issue!"); + return {alias: r3, name: n2, value: o2}; + } + throw new i("intrinsic " + t3 + " does not exist!"); + }; + t2.exports = function(t3, e3) { + if (typeof t3 != "string" || t3.length === 0) + throw new a("intrinsic name must be a non-empty string"); + if (arguments.length > 1 && typeof e3 != "boolean") + throw new a('"allowMissing" argument must be a boolean'); + var r3 = k(t3), n2 = r3.length > 0 ? r3[0] : "", o2 = B("%" + n2 + "%", e3), s2 = o2.name, f2 = o2.value, c2 = false, h2 = o2.alias; + h2 && (n2 = h2[0], _(r3, w([0, 1], h2))); + for (var l2 = 1, d2 = true; l2 < r3.length; l2 += 1) { + var p2 = r3[l2], m2 = S(p2, 0, 1), b2 = S(p2, -1); + if ((m2 === '"' || m2 === "'" || m2 === "`" || b2 === '"' || b2 === "'" || b2 === "`") && m2 !== b2) + throw new i("property names with quotes must have matching quotes"); + if (p2 !== "constructor" && d2 || (c2 = true), v(y, s2 = "%" + (n2 += "." + p2) + "%")) + f2 = y[s2]; + else if (f2 != null) { + if (!(p2 in f2)) { + if (!e3) + throw new a("base intrinsic for " + t3 + " exists, but the property is not available."); + return; + } + if (u && l2 + 1 >= r3.length) { + var g2 = u(f2, p2); + f2 = (d2 = !!g2) && "get" in g2 && !("originalValue" in g2.get) ? g2.get : f2[p2]; + } else + d2 = v(f2, p2), f2 = f2[p2]; + d2 && !c2 && (y[s2] = f2); + } + } + return f2; + }; + }, 1405: (t2, e2, r2) => { + var n = typeof Symbol != "undefined" && Symbol, i = r2(5419); + t2.exports = function() { + return typeof n == "function" && typeof Symbol == "function" && typeof n("foo") == "symbol" && typeof Symbol("bar") == "symbol" && i(); + }; + }, 5419: (t2) => { + t2.exports = function() { + if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function") + return false; + if (typeof Symbol.iterator == "symbol") + return true; + var t3 = {}, e2 = Symbol("test"), r2 = Object(e2); + if (typeof e2 == "string") + return false; + if (Object.prototype.toString.call(e2) !== "[object Symbol]") + return false; + if (Object.prototype.toString.call(r2) !== "[object Symbol]") + return false; + for (e2 in t3[e2] = 42, t3) + return false; + if (typeof Object.keys == "function" && Object.keys(t3).length !== 0) + return false; + if (typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(t3).length !== 0) + return false; + var n = Object.getOwnPropertySymbols(t3); + if (n.length !== 1 || n[0] !== e2) + return false; + if (!Object.prototype.propertyIsEnumerable.call(t3, e2)) + return false; + if (typeof Object.getOwnPropertyDescriptor == "function") { + var i = Object.getOwnPropertyDescriptor(t3, e2); + if (i.value !== 42 || i.enumerable !== true) + return false; + } + return true; + }; + }, 7642: (t2, e2, r2) => { + var n = r2(8612); + t2.exports = n.call(Function.call, Object.prototype.hasOwnProperty); + }, 3349: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = r2(8473).Transform; + function o(t3) { + i.call(this), this._block = n.allocUnsafe(t3), this._blockSize = t3, this._blockOffset = 0, this._length = [0, 0, 0, 0], this._finalized = false; + } + r2(5717)(o, i), o.prototype._transform = function(t3, e3, r3) { + var n2 = null; + try { + this.update(t3, e3); + } catch (t4) { + n2 = t4; + } + r3(n2); + }, o.prototype._flush = function(t3) { + var e3 = null; + try { + this.push(this.digest()); + } catch (t4) { + e3 = t4; + } + t3(e3); + }, o.prototype.update = function(t3, e3) { + if (function(t4, e4) { + if (!n.isBuffer(t4) && typeof t4 != "string") + throw new TypeError("Data must be a string or a buffer"); + }(t3), this._finalized) + throw new Error("Digest already called"); + n.isBuffer(t3) || (t3 = n.from(t3, e3)); + for (var r3 = this._block, i2 = 0; this._blockOffset + t3.length - i2 >= this._blockSize; ) { + for (var o2 = this._blockOffset; o2 < this._blockSize; ) + r3[o2++] = t3[i2++]; + this._update(), this._blockOffset = 0; + } + for (; i2 < t3.length; ) + r3[this._blockOffset++] = t3[i2++]; + for (var a = 0, s = 8 * t3.length; s > 0; ++a) + this._length[a] += s, (s = this._length[a] / 4294967296 | 0) > 0 && (this._length[a] -= 4294967296 * s); + return this; + }, o.prototype._update = function() { + throw new Error("_update is not implemented"); + }, o.prototype.digest = function(t3) { + if (this._finalized) + throw new Error("Digest already called"); + this._finalized = true; + var e3 = this._digest(); + t3 !== void 0 && (e3 = e3.toString(t3)), this._block.fill(0), this._blockOffset = 0; + for (var r3 = 0; r3 < 4; ++r3) + this._length[r3] = 0; + return e3; + }, o.prototype._digest = function() { + throw new Error("_digest is not implemented"); + }, t2.exports = o; + }, 3715: (t2, e2, r2) => { + var n = e2; + n.utils = r2(6436), n.common = r2(5772), n.sha = r2(9041), n.ripemd = r2(2949), n.hmac = r2(2344), n.sha1 = n.sha.sha1, n.sha256 = n.sha.sha256, n.sha224 = n.sha.sha224, n.sha384 = n.sha.sha384, n.sha512 = n.sha.sha512, n.ripemd160 = n.ripemd.ripemd160; + }, 5772: (t2, e2, r2) => { + var n = r2(6436), i = r2(9746); + function o() { + 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; + } + e2.BlockHash = o, o.prototype.update = function(t3, e3) { + if (t3 = n.toArray(t3, e3), this.pending ? this.pending = this.pending.concat(t3) : this.pending = t3, this.pendingTotal += t3.length, this.pending.length >= this._delta8) { + var r3 = (t3 = this.pending).length % this._delta8; + this.pending = t3.slice(t3.length - r3, t3.length), this.pending.length === 0 && (this.pending = null), t3 = n.join32(t3, 0, t3.length - r3, this.endian); + for (var i2 = 0; i2 < t3.length; i2 += this._delta32) + this._update(t3, i2, i2 + this._delta32); + } + return this; + }, o.prototype.digest = function(t3) { + return this.update(this._pad()), i(this.pending === null), this._digest(t3); + }, o.prototype._pad = function() { + var t3 = this.pendingTotal, e3 = this._delta8, r3 = e3 - (t3 + this.padLength) % e3, n2 = new Array(r3 + this.padLength); + n2[0] = 128; + for (var i2 = 1; i2 < r3; i2++) + n2[i2] = 0; + if (t3 <<= 3, this.endian === "big") { + for (var o2 = 8; o2 < this.padLength; o2++) + n2[i2++] = 0; + n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = t3 >>> 24 & 255, n2[i2++] = t3 >>> 16 & 255, n2[i2++] = t3 >>> 8 & 255, n2[i2++] = 255 & t3; + } else + for (n2[i2++] = 255 & t3, n2[i2++] = t3 >>> 8 & 255, n2[i2++] = t3 >>> 16 & 255, n2[i2++] = t3 >>> 24 & 255, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, o2 = 8; o2 < this.padLength; o2++) + n2[i2++] = 0; + return n2; + }; + }, 2344: (t2, e2, r2) => { + var n = r2(6436), i = r2(9746); + function o(t3, e3, r3) { + if (!(this instanceof o)) + return new o(t3, e3, r3); + this.Hash = t3, this.blockSize = t3.blockSize / 8, this.outSize = t3.outSize / 8, this.inner = null, this.outer = null, this._init(n.toArray(e3, r3)); + } + t2.exports = o, o.prototype._init = function(t3) { + t3.length > this.blockSize && (t3 = new this.Hash().update(t3).digest()), i(t3.length <= this.blockSize); + for (var e3 = t3.length; e3 < this.blockSize; e3++) + t3.push(0); + for (e3 = 0; e3 < t3.length; e3++) + t3[e3] ^= 54; + for (this.inner = new this.Hash().update(t3), e3 = 0; e3 < t3.length; e3++) + t3[e3] ^= 106; + this.outer = new this.Hash().update(t3); + }, o.prototype.update = function(t3, e3) { + return this.inner.update(t3, e3), this; + }, o.prototype.digest = function(t3) { + return this.outer.update(this.inner.digest()), this.outer.digest(t3); + }; + }, 2949: (t2, e2, r2) => { + var n = r2(6436), i = r2(5772), o = n.rotl32, a = n.sum32, s = n.sum32_3, u = n.sum32_4, f = i.BlockHash; + function c() { + if (!(this instanceof c)) + return new c(); + f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + function h(t3, e3, r3, n2) { + return t3 <= 15 ? e3 ^ r3 ^ n2 : t3 <= 31 ? e3 & r3 | ~e3 & n2 : t3 <= 47 ? (e3 | ~r3) ^ n2 : t3 <= 63 ? e3 & n2 | r3 & ~n2 : e3 ^ (r3 | ~n2); + } + function l(t3) { + return t3 <= 15 ? 0 : t3 <= 31 ? 1518500249 : t3 <= 47 ? 1859775393 : t3 <= 63 ? 2400959708 : 2840853838; + } + function d(t3) { + return t3 <= 15 ? 1352829926 : t3 <= 31 ? 1548603684 : t3 <= 47 ? 1836072691 : t3 <= 63 ? 2053994217 : 0; + } + n.inherits(c, f), e2.ripemd160 = c, c.blockSize = 512, c.outSize = 160, c.hmacStrength = 192, c.padLength = 64, c.prototype._update = function(t3, e3) { + for (var r3 = this.h[0], n2 = this.h[1], i2 = this.h[2], f2 = this.h[3], c2 = this.h[4], g = r3, v = n2, w = i2, _ = f2, M = c2, S = 0; S < 80; S++) { + var E = a(o(u(r3, h(S, n2, i2, f2), t3[p[S] + e3], l(S)), m[S]), c2); + r3 = c2, c2 = f2, f2 = o(i2, 10), i2 = n2, n2 = E, E = a(o(u(g, h(79 - S, v, w, _), t3[y[S] + e3], d(S)), b[S]), M), g = M, M = _, _ = o(w, 10), w = v, v = E; + } + E = s(this.h[1], i2, _), this.h[1] = s(this.h[2], f2, M), this.h[2] = s(this.h[3], c2, g), this.h[3] = s(this.h[4], r3, v), this.h[4] = s(this.h[0], n2, w), this.h[0] = E; + }, c.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h, "little") : n.split32(this.h, "little"); + }; + var p = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], y = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], m = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], b = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + }, 9041: (t2, e2, r2) => { + e2.sha1 = r2(4761), e2.sha224 = r2(799), e2.sha256 = r2(9344), e2.sha384 = r2(772), e2.sha512 = r2(5900); + }, 4761: (t2, e2, r2) => { + var n = r2(6436), i = r2(5772), o = r2(7038), a = n.rotl32, s = n.sum32, u = n.sum32_5, f = o.ft_1, c = i.BlockHash, h = [1518500249, 1859775393, 2400959708, 3395469782]; + function l() { + if (!(this instanceof l)) + return new l(); + c.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + n.inherits(l, c), t2.exports = l, l.blockSize = 512, l.outSize = 160, l.hmacStrength = 80, l.padLength = 64, l.prototype._update = function(t3, e3) { + for (var r3 = this.W, n2 = 0; n2 < 16; n2++) + r3[n2] = t3[e3 + n2]; + for (; n2 < r3.length; n2++) + r3[n2] = a(r3[n2 - 3] ^ r3[n2 - 8] ^ r3[n2 - 14] ^ r3[n2 - 16], 1); + var i2 = this.h[0], o2 = this.h[1], c2 = this.h[2], l2 = this.h[3], d = this.h[4]; + for (n2 = 0; n2 < r3.length; n2++) { + var p = ~~(n2 / 20), y = u(a(i2, 5), f(p, o2, c2, l2), d, r3[n2], h[p]); + d = l2, l2 = c2, c2 = a(o2, 30), o2 = i2, i2 = y; + } + this.h[0] = s(this.h[0], i2), this.h[1] = s(this.h[1], o2), this.h[2] = s(this.h[2], c2), this.h[3] = s(this.h[3], l2), this.h[4] = s(this.h[4], d); + }, l.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); + }; + }, 799: (t2, e2, r2) => { + var n = r2(6436), i = r2(9344); + function o() { + if (!(this instanceof o)) + return new o(); + i.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + n.inherits(o, i), t2.exports = o, o.blockSize = 512, o.outSize = 224, o.hmacStrength = 192, o.padLength = 64, o.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h.slice(0, 7), "big") : n.split32(this.h.slice(0, 7), "big"); + }; + }, 9344: (t2, e2, r2) => { + var n = r2(6436), i = r2(5772), o = r2(7038), a = r2(9746), s = n.sum32, u = n.sum32_4, f = n.sum32_5, c = o.ch32, h = o.maj32, l = o.s0_256, d = o.s1_256, p = o.g0_256, y = o.g1_256, m = i.BlockHash, b = [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 g() { + if (!(this instanceof g)) + return new g(); + m.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = b, this.W = new Array(64); + } + n.inherits(g, m), t2.exports = g, g.blockSize = 512, g.outSize = 256, g.hmacStrength = 192, g.padLength = 64, g.prototype._update = function(t3, e3) { + for (var r3 = this.W, n2 = 0; n2 < 16; n2++) + r3[n2] = t3[e3 + n2]; + for (; n2 < r3.length; n2++) + r3[n2] = u(y(r3[n2 - 2]), r3[n2 - 7], p(r3[n2 - 15]), r3[n2 - 16]); + var i2 = this.h[0], o2 = this.h[1], m2 = this.h[2], b2 = this.h[3], g2 = this.h[4], v = this.h[5], w = this.h[6], _ = this.h[7]; + for (a(this.k.length === r3.length), n2 = 0; n2 < r3.length; n2++) { + var M = f(_, d(g2), c(g2, v, w), this.k[n2], r3[n2]), S = s(l(i2), h(i2, o2, m2)); + _ = w, w = v, v = g2, g2 = s(b2, M), b2 = m2, m2 = o2, o2 = i2, i2 = s(M, S); + } + this.h[0] = s(this.h[0], i2), this.h[1] = s(this.h[1], o2), this.h[2] = s(this.h[2], m2), this.h[3] = s(this.h[3], b2), this.h[4] = s(this.h[4], g2), this.h[5] = s(this.h[5], v), this.h[6] = s(this.h[6], w), this.h[7] = s(this.h[7], _); + }, g.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); + }; + }, 772: (t2, e2, r2) => { + var n = r2(6436), i = r2(5900); + function o() { + if (!(this instanceof o)) + return new o(); + i.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + n.inherits(o, i), t2.exports = o, o.blockSize = 1024, o.outSize = 384, o.hmacStrength = 192, o.padLength = 128, o.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h.slice(0, 12), "big") : n.split32(this.h.slice(0, 12), "big"); + }; + }, 5900: (t2, e2, r2) => { + var n = r2(6436), i = r2(5772), o = r2(9746), a = n.rotr64_hi, s = n.rotr64_lo, u = n.shr64_hi, f = n.shr64_lo, c = n.sum64, h = n.sum64_hi, l = n.sum64_lo, d = n.sum64_4_hi, p = n.sum64_4_lo, y = n.sum64_5_hi, m = n.sum64_5_lo, b = i.BlockHash, g = [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 v() { + if (!(this instanceof v)) + return new v(); + b.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = g, this.W = new Array(160); + } + function w(t3, e3, r3, n2, i2) { + var o2 = t3 & r3 ^ ~t3 & i2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function _(t3, e3, r3, n2, i2, o2) { + var a2 = e3 & n2 ^ ~e3 & o2; + return a2 < 0 && (a2 += 4294967296), a2; + } + function M(t3, e3, r3, n2, i2) { + var o2 = t3 & r3 ^ t3 & i2 ^ r3 & i2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function S(t3, e3, r3, n2, i2, o2) { + var a2 = e3 & n2 ^ e3 & o2 ^ n2 & o2; + return a2 < 0 && (a2 += 4294967296), a2; + } + function E(t3, e3) { + var r3 = a(t3, e3, 28) ^ a(e3, t3, 2) ^ a(e3, t3, 7); + return r3 < 0 && (r3 += 4294967296), r3; + } + function A(t3, e3) { + var r3 = s(t3, e3, 28) ^ s(e3, t3, 2) ^ s(e3, t3, 7); + return r3 < 0 && (r3 += 4294967296), r3; + } + function k(t3, e3) { + var r3 = s(t3, e3, 14) ^ s(t3, e3, 18) ^ s(e3, t3, 9); + return r3 < 0 && (r3 += 4294967296), r3; + } + function B(t3, e3) { + var r3 = a(t3, e3, 1) ^ a(t3, e3, 8) ^ u(t3, e3, 7); + return r3 < 0 && (r3 += 4294967296), r3; + } + function T(t3, e3) { + var r3 = s(t3, e3, 1) ^ s(t3, e3, 8) ^ f(t3, e3, 7); + return r3 < 0 && (r3 += 4294967296), r3; + } + function x(t3, e3) { + var r3 = s(t3, e3, 19) ^ s(e3, t3, 29) ^ f(t3, e3, 6); + return r3 < 0 && (r3 += 4294967296), r3; + } + n.inherits(v, b), t2.exports = v, v.blockSize = 1024, v.outSize = 512, v.hmacStrength = 192, v.padLength = 128, v.prototype._prepareBlock = function(t3, e3) { + for (var r3 = this.W, n2 = 0; n2 < 32; n2++) + r3[n2] = t3[e3 + n2]; + for (; n2 < r3.length; n2 += 2) { + var i2 = (m2 = r3[n2 - 4], b2 = r3[n2 - 3], g2 = void 0, (g2 = a(m2, b2, 19) ^ a(b2, m2, 29) ^ u(m2, b2, 6)) < 0 && (g2 += 4294967296), g2), o2 = x(r3[n2 - 4], r3[n2 - 3]), s2 = r3[n2 - 14], f2 = r3[n2 - 13], c2 = B(r3[n2 - 30], r3[n2 - 29]), h2 = T(r3[n2 - 30], r3[n2 - 29]), l2 = r3[n2 - 32], y2 = r3[n2 - 31]; + r3[n2] = d(i2, o2, s2, f2, c2, h2, l2, y2), r3[n2 + 1] = p(i2, o2, s2, f2, c2, h2, l2, y2); + } + var m2, b2, g2; + }, v.prototype._update = function(t3, e3) { + this._prepareBlock(t3, e3); + var r3, n2, i2, s2 = this.W, u2 = this.h[0], f2 = this.h[1], d2 = this.h[2], p2 = this.h[3], b2 = this.h[4], g2 = this.h[5], v2 = this.h[6], B2 = this.h[7], T2 = this.h[8], x2 = this.h[9], O = this.h[10], R = this.h[11], P = this.h[12], I = this.h[13], j = this.h[14], U = this.h[15]; + o(this.k.length === s2.length); + for (var N = 0; N < s2.length; N += 2) { + var C = j, D = U, L = (i2 = void 0, (i2 = a(r3 = T2, n2 = x2, 14) ^ a(r3, n2, 18) ^ a(n2, r3, 9)) < 0 && (i2 += 4294967296), i2), K = k(T2, x2), z = w(T2, 0, O, 0, P), q = _(0, x2, 0, R, 0, I), H = this.k[N], F = this.k[N + 1], V = s2[N], W = s2[N + 1], J = y(C, D, L, K, z, q, H, F, V, W), $ = m(C, D, L, K, z, q, H, F, V, W); + C = E(u2, f2), D = A(u2, f2), L = M(u2, 0, d2, 0, b2), K = S(0, f2, 0, p2, 0, g2); + var G = h(C, D, L, K), Z = l(C, D, L, K); + j = P, U = I, P = O, I = R, O = T2, R = x2, T2 = h(v2, B2, J, $), x2 = l(B2, B2, J, $), v2 = b2, B2 = g2, b2 = d2, g2 = p2, d2 = u2, p2 = f2, u2 = h(J, $, G, Z), f2 = l(J, $, G, Z); + } + c(this.h, 0, u2, f2), c(this.h, 2, d2, p2), c(this.h, 4, b2, g2), c(this.h, 6, v2, B2), c(this.h, 8, T2, x2), c(this.h, 10, O, R), c(this.h, 12, P, I), c(this.h, 14, j, U); + }, v.prototype._digest = function(t3) { + return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); + }; + }, 7038: (t2, e2, r2) => { + var n = r2(6436).rotr32; + function i(t3, e3, r3) { + return t3 & e3 ^ ~t3 & r3; + } + function o(t3, e3, r3) { + return t3 & e3 ^ t3 & r3 ^ e3 & r3; + } + function a(t3, e3, r3) { + return t3 ^ e3 ^ r3; + } + e2.ft_1 = function(t3, e3, r3, n2) { + return t3 === 0 ? i(e3, r3, n2) : t3 === 1 || t3 === 3 ? a(e3, r3, n2) : t3 === 2 ? o(e3, r3, n2) : void 0; + }, e2.ch32 = i, e2.maj32 = o, e2.p32 = a, e2.s0_256 = function(t3) { + return n(t3, 2) ^ n(t3, 13) ^ n(t3, 22); + }, e2.s1_256 = function(t3) { + return n(t3, 6) ^ n(t3, 11) ^ n(t3, 25); + }, e2.g0_256 = function(t3) { + return n(t3, 7) ^ n(t3, 18) ^ t3 >>> 3; + }, e2.g1_256 = function(t3) { + return n(t3, 17) ^ n(t3, 19) ^ t3 >>> 10; + }; + }, 6436: (t2, e2, r2) => { + var n = r2(9746), i = r2(5717); + function o(t3, e3) { + return (64512 & t3.charCodeAt(e3)) == 55296 && !(e3 < 0 || e3 + 1 >= t3.length) && (64512 & t3.charCodeAt(e3 + 1)) == 56320; + } + function a(t3) { + return (t3 >>> 24 | t3 >>> 8 & 65280 | t3 << 8 & 16711680 | (255 & t3) << 24) >>> 0; + } + function s(t3) { + return t3.length === 1 ? "0" + t3 : t3; + } + function u(t3) { + return t3.length === 7 ? "0" + t3 : t3.length === 6 ? "00" + t3 : t3.length === 5 ? "000" + t3 : t3.length === 4 ? "0000" + t3 : t3.length === 3 ? "00000" + t3 : t3.length === 2 ? "000000" + t3 : t3.length === 1 ? "0000000" + t3 : t3; + } + e2.inherits = i, e2.toArray = function(t3, e3) { + if (Array.isArray(t3)) + return t3.slice(); + if (!t3) + return []; + var r3 = []; + if (typeof t3 == "string") + if (e3) { + if (e3 === "hex") + for ((t3 = t3.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (t3 = "0" + t3), i2 = 0; i2 < t3.length; i2 += 2) + r3.push(parseInt(t3[i2] + t3[i2 + 1], 16)); + } else + for (var n2 = 0, i2 = 0; i2 < t3.length; i2++) { + var a2 = t3.charCodeAt(i2); + a2 < 128 ? r3[n2++] = a2 : a2 < 2048 ? (r3[n2++] = a2 >> 6 | 192, r3[n2++] = 63 & a2 | 128) : o(t3, i2) ? (a2 = 65536 + ((1023 & a2) << 10) + (1023 & t3.charCodeAt(++i2)), r3[n2++] = a2 >> 18 | 240, r3[n2++] = a2 >> 12 & 63 | 128, r3[n2++] = a2 >> 6 & 63 | 128, r3[n2++] = 63 & a2 | 128) : (r3[n2++] = a2 >> 12 | 224, r3[n2++] = a2 >> 6 & 63 | 128, r3[n2++] = 63 & a2 | 128); + } + else + for (i2 = 0; i2 < t3.length; i2++) + r3[i2] = 0 | t3[i2]; + return r3; + }, e2.toHex = function(t3) { + for (var e3 = "", r3 = 0; r3 < t3.length; r3++) + e3 += s(t3[r3].toString(16)); + return e3; + }, e2.htonl = a, e2.toHex32 = function(t3, e3) { + for (var r3 = "", n2 = 0; n2 < t3.length; n2++) { + var i2 = t3[n2]; + e3 === "little" && (i2 = a(i2)), r3 += u(i2.toString(16)); + } + return r3; + }, e2.zero2 = s, e2.zero8 = u, e2.join32 = function(t3, e3, r3, i2) { + var o2 = r3 - e3; + n(o2 % 4 == 0); + for (var a2 = new Array(o2 / 4), s2 = 0, u2 = e3; s2 < a2.length; s2++, u2 += 4) { + var f; + f = i2 === "big" ? t3[u2] << 24 | t3[u2 + 1] << 16 | t3[u2 + 2] << 8 | t3[u2 + 3] : t3[u2 + 3] << 24 | t3[u2 + 2] << 16 | t3[u2 + 1] << 8 | t3[u2], a2[s2] = f >>> 0; + } + return a2; + }, e2.split32 = function(t3, e3) { + for (var r3 = new Array(4 * t3.length), n2 = 0, i2 = 0; n2 < t3.length; n2++, i2 += 4) { + var o2 = t3[n2]; + e3 === "big" ? (r3[i2] = o2 >>> 24, r3[i2 + 1] = o2 >>> 16 & 255, r3[i2 + 2] = o2 >>> 8 & 255, r3[i2 + 3] = 255 & o2) : (r3[i2 + 3] = o2 >>> 24, r3[i2 + 2] = o2 >>> 16 & 255, r3[i2 + 1] = o2 >>> 8 & 255, r3[i2] = 255 & o2); + } + return r3; + }, e2.rotr32 = function(t3, e3) { + return t3 >>> e3 | t3 << 32 - e3; + }, e2.rotl32 = function(t3, e3) { + return t3 << e3 | t3 >>> 32 - e3; + }, e2.sum32 = function(t3, e3) { + return t3 + e3 >>> 0; + }, e2.sum32_3 = function(t3, e3, r3) { + return t3 + e3 + r3 >>> 0; + }, e2.sum32_4 = function(t3, e3, r3, n2) { + return t3 + e3 + r3 + n2 >>> 0; + }, e2.sum32_5 = function(t3, e3, r3, n2, i2) { + return t3 + e3 + r3 + n2 + i2 >>> 0; + }, e2.sum64 = function(t3, e3, r3, n2) { + var i2 = t3[e3], o2 = n2 + t3[e3 + 1] >>> 0, a2 = (o2 < n2 ? 1 : 0) + r3 + i2; + t3[e3] = a2 >>> 0, t3[e3 + 1] = o2; + }, e2.sum64_hi = function(t3, e3, r3, n2) { + return (e3 + n2 >>> 0 < e3 ? 1 : 0) + t3 + r3 >>> 0; + }, e2.sum64_lo = function(t3, e3, r3, n2) { + return e3 + n2 >>> 0; + }, e2.sum64_4_hi = function(t3, e3, r3, n2, i2, o2, a2, s2) { + var u2 = 0, f = e3; + return u2 += (f = f + n2 >>> 0) < e3 ? 1 : 0, u2 += (f = f + o2 >>> 0) < o2 ? 1 : 0, t3 + r3 + i2 + a2 + (u2 += (f = f + s2 >>> 0) < s2 ? 1 : 0) >>> 0; + }, e2.sum64_4_lo = function(t3, e3, r3, n2, i2, o2, a2, s2) { + return e3 + n2 + o2 + s2 >>> 0; + }, e2.sum64_5_hi = function(t3, e3, r3, n2, i2, o2, a2, s2, u2, f) { + var c = 0, h = e3; + return c += (h = h + n2 >>> 0) < e3 ? 1 : 0, c += (h = h + o2 >>> 0) < o2 ? 1 : 0, c += (h = h + s2 >>> 0) < s2 ? 1 : 0, t3 + r3 + i2 + a2 + u2 + (c += (h = h + f >>> 0) < f ? 1 : 0) >>> 0; + }, e2.sum64_5_lo = function(t3, e3, r3, n2, i2, o2, a2, s2, u2, f) { + return e3 + n2 + o2 + s2 + f >>> 0; + }, e2.rotr64_hi = function(t3, e3, r3) { + return (e3 << 32 - r3 | t3 >>> r3) >>> 0; + }, e2.rotr64_lo = function(t3, e3, r3) { + return (t3 << 32 - r3 | e3 >>> r3) >>> 0; + }, e2.shr64_hi = function(t3, e3, r3) { + return t3 >>> r3; + }, e2.shr64_lo = function(t3, e3, r3) { + return (t3 << 32 - r3 | e3 >>> r3) >>> 0; + }; + }, 2156: (t2, e2, r2) => { + var n = r2(3715), i = r2(4504), o = r2(9746); + function a(t3) { + if (!(this instanceof a)) + return new a(t3); + this.hash = t3.hash, this.predResist = !!t3.predResist, this.outLen = this.hash.outSize, this.minEntropy = t3.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var e3 = i.toArray(t3.entropy, t3.entropyEnc || "hex"), r3 = i.toArray(t3.nonce, t3.nonceEnc || "hex"), n2 = i.toArray(t3.pers, t3.persEnc || "hex"); + o(e3.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(e3, r3, n2); + } + t2.exports = a, a.prototype._init = function(t3, e3, r3) { + var n2 = t3.concat(e3).concat(r3); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var i2 = 0; i2 < this.V.length; i2++) + this.K[i2] = 0, this.V[i2] = 1; + this._update(n2), this._reseed = 1, this.reseedInterval = 281474976710656; + }, a.prototype._hmac = function() { + return new n.hmac(this.hash, this.K); + }, a.prototype._update = function(t3) { + var e3 = this._hmac().update(this.V).update([0]); + t3 && (e3 = e3.update(t3)), this.K = e3.digest(), this.V = this._hmac().update(this.V).digest(), t3 && (this.K = this._hmac().update(this.V).update([1]).update(t3).digest(), this.V = this._hmac().update(this.V).digest()); + }, a.prototype.reseed = function(t3, e3, r3, n2) { + typeof e3 != "string" && (n2 = r3, r3 = e3, e3 = null), t3 = i.toArray(t3, e3), r3 = i.toArray(r3, n2), o(t3.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t3.concat(r3 || [])), this._reseed = 1; + }, a.prototype.generate = function(t3, e3, r3, n2) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof e3 != "string" && (n2 = r3, r3 = e3, e3 = null), r3 && (r3 = i.toArray(r3, n2 || "hex"), this._update(r3)); + for (var o2 = []; o2.length < t3; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var a2 = o2.slice(0, t3); + return this._update(r3), this._reseed++, i.encode(a2, e3); + }; + }, 9695: (t2, e2, r2) => { + var n; + !function() { + var i = {y: function(t3) { + return t3 === 1 ? "\u03C7\u03C1\u03CC\u03BD\u03BF\u03C2" : "\u03C7\u03C1\u03CC\u03BD\u03B9\u03B1"; + }, mo: function(t3) { + return t3 === 1 ? "\u03BC\u03AE\u03BD\u03B1\u03C2" : "\u03BC\u03AE\u03BD\u03B5\u03C2"; + }, w: function(t3) { + return t3 === 1 ? "\u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1" : "\u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2"; + }, d: function(t3) { + return t3 === 1 ? "\u03BC\u03AD\u03C1\u03B1" : "\u03BC\u03AD\u03C1\u03B5\u03C2"; + }, h: function(t3) { + return t3 === 1 ? "\u03CE\u03C1\u03B1" : "\u03CE\u03C1\u03B5\u03C2"; + }, m: function(t3) { + return t3 === 1 ? "\u03BB\u03B5\u03C0\u03C4\u03CC" : "\u03BB\u03B5\u03C0\u03C4\u03AC"; + }, s: function(t3) { + return t3 === 1 ? "\u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF" : "\u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1"; + }, ms: function(t3) { + return t3 === 1 ? "\u03C7\u03B9\u03BB\u03B9\u03BF\u03C3\u03C4\u03CC \u03C4\u03BF\u03C5 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03BF\u03BB\u03AD\u03C0\u03C4\u03BF\u03C5" : "\u03C7\u03B9\u03BB\u03B9\u03BF\u03C3\u03C4\u03AC \u03C4\u03BF\u03C5 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03BF\u03BB\u03AD\u03C0\u03C4\u03BF\u03C5"; + }, decimal: ","}, o = {ar: {y: function(t3) { + return t3 === 1 ? "\u0633\u0646\u0629" : "\u0633\u0646\u0648\u0627\u062A"; + }, mo: function(t3) { + return t3 === 1 ? "\u0634\u0647\u0631" : "\u0623\u0634\u0647\u0631"; + }, w: function(t3) { + return t3 === 1 ? "\u0623\u0633\u0628\u0648\u0639" : "\u0623\u0633\u0627\u0628\u064A\u0639"; + }, d: function(t3) { + return t3 === 1 ? "\u064A\u0648\u0645" : "\u0623\u064A\u0627\u0645"; + }, h: function(t3) { + return t3 === 1 ? "\u0633\u0627\u0639\u0629" : "\u0633\u0627\u0639\u0627\u062A"; + }, m: function(t3) { + return t3 > 2 && t3 < 11 ? "\u062F\u0642\u0627\u0626\u0642" : "\u062F\u0642\u064A\u0642\u0629"; + }, s: function(t3) { + return t3 === 1 ? "\u062B\u0627\u0646\u064A\u0629" : "\u062B\u0648\u0627\u0646\u064A"; + }, ms: function(t3) { + return t3 === 1 ? "\u062C\u0632\u0621 \u0645\u0646 \u0627\u0644\u062B\u0627\u0646\u064A\u0629" : "\u0623\u062C\u0632\u0627\u0621 \u0645\u0646 \u0627\u0644\u062B\u0627\u0646\u064A\u0629"; + }, decimal: ","}, bg: {y: function(t3) { + return ["\u0433\u043E\u0434\u0438\u043D\u0438", "\u0433\u043E\u0434\u0438\u043D\u0430", "\u0433\u043E\u0434\u0438\u043D\u0438"][h(t3)]; + }, mo: function(t3) { + return ["\u043C\u0435\u0441\u0435\u0446\u0430", "\u043C\u0435\u0441\u0435\u0446", "\u043C\u0435\u0441\u0435\u0446\u0430"][h(t3)]; + }, w: function(t3) { + return ["\u0441\u0435\u0434\u043C\u0438\u0446\u0438", "\u0441\u0435\u0434\u043C\u0438\u0446\u0430", "\u0441\u0435\u0434\u043C\u0438\u0446\u0438"][h(t3)]; + }, d: function(t3) { + return ["\u0434\u043D\u0438", "\u0434\u0435\u043D", "\u0434\u043D\u0438"][h(t3)]; + }, h: function(t3) { + return ["\u0447\u0430\u0441\u0430", "\u0447\u0430\u0441", "\u0447\u0430\u0441\u0430"][h(t3)]; + }, m: function(t3) { + return ["\u043C\u0438\u043D\u0443\u0442\u0438", "\u043C\u0438\u043D\u0443\u0442\u0430", "\u043C\u0438\u043D\u0443\u0442\u0438"][h(t3)]; + }, s: function(t3) { + return ["\u0441\u0435\u043A\u0443\u043D\u0434\u0438", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; + }, ms: function(t3) { + return ["\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0438", "\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; + }, decimal: ","}, ca: {y: function(t3) { + return "any" + (t3 === 1 ? "" : "s"); + }, mo: function(t3) { + return "mes" + (t3 === 1 ? "" : "os"); + }, w: function(t3) { + return "setman" + (t3 === 1 ? "a" : "es"); + }, d: function(t3) { + return "di" + (t3 === 1 ? "a" : "es"); + }, h: function(t3) { + return "hor" + (t3 === 1 ? "a" : "es"); + }, m: function(t3) { + return "minut" + (t3 === 1 ? "" : "s"); + }, s: function(t3) { + return "segon" + (t3 === 1 ? "" : "s"); + }, ms: function(t3) { + return "milisegon" + (t3 === 1 ? "" : "s"); + }, decimal: ","}, cs: {y: function(t3) { + return ["rok", "roku", "roky", "let"][l(t3)]; + }, mo: function(t3) { + return ["m\u011Bs\xEDc", "m\u011Bs\xEDce", "m\u011Bs\xEDce", "m\u011Bs\xEDc\u016F"][l(t3)]; + }, w: function(t3) { + return ["t\xFDden", "t\xFDdne", "t\xFDdny", "t\xFDdn\u016F"][l(t3)]; + }, d: function(t3) { + return ["den", "dne", "dny", "dn\xED"][l(t3)]; + }, h: function(t3) { + return ["hodina", "hodiny", "hodiny", "hodin"][l(t3)]; + }, m: function(t3) { + return ["minuta", "minuty", "minuty", "minut"][l(t3)]; + }, s: function(t3) { + return ["sekunda", "sekundy", "sekundy", "sekund"][l(t3)]; + }, ms: function(t3) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][l(t3)]; + }, decimal: ","}, da: {y: "\xE5r", mo: function(t3) { + return "m\xE5ned" + (t3 === 1 ? "" : "er"); + }, w: function(t3) { + return "uge" + (t3 === 1 ? "" : "r"); + }, d: function(t3) { + return "dag" + (t3 === 1 ? "" : "e"); + }, h: function(t3) { + return "time" + (t3 === 1 ? "" : "r"); + }, m: function(t3) { + return "minut" + (t3 === 1 ? "" : "ter"); + }, s: function(t3) { + return "sekund" + (t3 === 1 ? "" : "er"); + }, ms: function(t3) { + return "millisekund" + (t3 === 1 ? "" : "er"); + }, decimal: ","}, de: {y: function(t3) { + return "Jahr" + (t3 === 1 ? "" : "e"); + }, mo: function(t3) { + return "Monat" + (t3 === 1 ? "" : "e"); + }, w: function(t3) { + return "Woche" + (t3 === 1 ? "" : "n"); + }, d: function(t3) { + return "Tag" + (t3 === 1 ? "" : "e"); + }, h: function(t3) { + return "Stunde" + (t3 === 1 ? "" : "n"); + }, m: function(t3) { + return "Minute" + (t3 === 1 ? "" : "n"); + }, s: function(t3) { + return "Sekunde" + (t3 === 1 ? "" : "n"); + }, ms: function(t3) { + return "Millisekunde" + (t3 === 1 ? "" : "n"); + }, decimal: ","}, el: i, en: {y: function(t3) { + return "year" + (t3 === 1 ? "" : "s"); + }, mo: function(t3) { + return "month" + (t3 === 1 ? "" : "s"); + }, w: function(t3) { + return "week" + (t3 === 1 ? "" : "s"); + }, d: function(t3) { + return "day" + (t3 === 1 ? "" : "s"); + }, h: function(t3) { + return "hour" + (t3 === 1 ? "" : "s"); + }, m: function(t3) { + return "minute" + (t3 === 1 ? "" : "s"); + }, s: function(t3) { + return "second" + (t3 === 1 ? "" : "s"); + }, ms: function(t3) { + return "millisecond" + (t3 === 1 ? "" : "s"); + }, decimal: "."}, es: {y: function(t3) { + return "a\xF1o" + (t3 === 1 ? "" : "s"); + }, mo: function(t3) { + return "mes" + (t3 === 1 ? "" : "es"); + }, w: function(t3) { + return "semana" + (t3 === 1 ? "" : "s"); + }, d: function(t3) { + return "d\xEDa" + (t3 === 1 ? "" : "s"); + }, h: function(t3) { + return "hora" + (t3 === 1 ? "" : "s"); + }, m: function(t3) { + return "minuto" + (t3 === 1 ? "" : "s"); + }, s: function(t3) { + return "segundo" + (t3 === 1 ? "" : "s"); + }, ms: function(t3) { + return "milisegundo" + (t3 === 1 ? "" : "s"); + }, decimal: ","}, et: {y: function(t3) { + return "aasta" + (t3 === 1 ? "" : "t"); + }, mo: function(t3) { + return "kuu" + (t3 === 1 ? "" : "d"); + }, w: function(t3) { + return "n\xE4dal" + (t3 === 1 ? "" : "at"); + }, d: function(t3) { + return "p\xE4ev" + (t3 === 1 ? "" : "a"); + }, h: function(t3) { + return "tund" + (t3 === 1 ? "" : "i"); + }, m: function(t3) { + return "minut" + (t3 === 1 ? "" : "it"); + }, s: function(t3) { + return "sekund" + (t3 === 1 ? "" : "it"); + }, ms: function(t3) { + return "millisekund" + (t3 === 1 ? "" : "it"); + }, decimal: ","}, fa: {y: "\u0633\u0627\u0644", mo: "\u0645\u0627\u0647", w: "\u0647\u0641\u062A\u0647", d: "\u0631\u0648\u0632", h: "\u0633\u0627\u0639\u062A", m: "\u062F\u0642\u06CC\u0642\u0647", s: "\u062B\u0627\u0646\u06CC\u0647", ms: "\u0645\u06CC\u0644\u06CC \u062B\u0627\u0646\u06CC\u0647", decimal: "."}, fi: {y: function(t3) { + return t3 === 1 ? "vuosi" : "vuotta"; + }, mo: function(t3) { + return t3 === 1 ? "kuukausi" : "kuukautta"; + }, w: function(t3) { + return "viikko" + (t3 === 1 ? "" : "a"); + }, d: function(t3) { + return "p\xE4iv\xE4" + (t3 === 1 ? "" : "\xE4"); + }, h: function(t3) { + return "tunti" + (t3 === 1 ? "" : "a"); + }, m: function(t3) { + return "minuutti" + (t3 === 1 ? "" : "a"); + }, s: function(t3) { + return "sekunti" + (t3 === 1 ? "" : "a"); + }, ms: function(t3) { + return "millisekunti" + (t3 === 1 ? "" : "a"); + }, decimal: ","}, fo: {y: "\xE1r", mo: function(t3) { + return t3 === 1 ? "m\xE1na\xF0ur" : "m\xE1na\xF0ir"; + }, w: function(t3) { + return t3 === 1 ? "vika" : "vikur"; + }, d: function(t3) { + return t3 === 1 ? "dagur" : "dagar"; + }, h: function(t3) { + return t3 === 1 ? "t\xEDmi" : "t\xEDmar"; + }, m: function(t3) { + return t3 === 1 ? "minuttur" : "minuttir"; + }, s: "sekund", ms: "millisekund", decimal: ","}, fr: {y: function(t3) { + return "an" + (t3 >= 2 ? "s" : ""); + }, mo: "mois", w: function(t3) { + return "semaine" + (t3 >= 2 ? "s" : ""); + }, d: function(t3) { + return "jour" + (t3 >= 2 ? "s" : ""); + }, h: function(t3) { + return "heure" + (t3 >= 2 ? "s" : ""); + }, m: function(t3) { + return "minute" + (t3 >= 2 ? "s" : ""); + }, s: function(t3) { + return "seconde" + (t3 >= 2 ? "s" : ""); + }, ms: function(t3) { + return "milliseconde" + (t3 >= 2 ? "s" : ""); + }, decimal: ","}, gr: i, he: {y: function(t3) { + return t3 === 1 ? "\u05E9\u05E0\u05D4" : "\u05E9\u05E0\u05D9\u05DD"; + }, mo: function(t3) { + return t3 === 1 ? "\u05D7\u05D5\u05D3\u05E9" : "\u05D7\u05D5\u05D3\u05E9\u05D9\u05DD"; + }, w: function(t3) { + return t3 === 1 ? "\u05E9\u05D1\u05D5\u05E2" : "\u05E9\u05D1\u05D5\u05E2\u05D5\u05EA"; + }, d: function(t3) { + return t3 === 1 ? "\u05D9\u05D5\u05DD" : "\u05D9\u05DE\u05D9\u05DD"; + }, h: function(t3) { + return t3 === 1 ? "\u05E9\u05E2\u05D4" : "\u05E9\u05E2\u05D5\u05EA"; + }, m: function(t3) { + return t3 === 1 ? "\u05D3\u05E7\u05D4" : "\u05D3\u05E7\u05D5\u05EA"; + }, s: function(t3) { + return t3 === 1 ? "\u05E9\u05E0\u05D9\u05D4" : "\u05E9\u05E0\u05D9\u05D5\u05EA"; + }, ms: function(t3) { + return t3 === 1 ? "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D9\u05D4" : "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D5\u05EA"; + }, decimal: "."}, hr: {y: function(t3) { + return t3 % 10 == 2 || t3 % 10 == 3 || t3 % 10 == 4 ? "godine" : "godina"; + }, mo: function(t3) { + return t3 === 1 ? "mjesec" : t3 === 2 || t3 === 3 || t3 === 4 ? "mjeseca" : "mjeseci"; + }, w: function(t3) { + return t3 % 10 == 1 && t3 !== 11 ? "tjedan" : "tjedna"; + }, d: function(t3) { + return t3 === 1 ? "dan" : "dana"; + }, h: function(t3) { + return t3 === 1 ? "sat" : t3 === 2 || t3 === 3 || t3 === 4 ? "sata" : "sati"; + }, m: function(t3) { + var e3 = t3 % 10; + return e3 !== 2 && e3 !== 3 && e3 !== 4 || !(t3 < 10 || t3 > 14) ? "minuta" : "minute"; + }, s: function(t3) { + var e3 = t3 % 10; + return e3 === 5 || Math.floor(t3) === t3 && t3 >= 10 && t3 <= 19 ? "sekundi" : e3 === 1 ? "sekunda" : e3 === 2 || e3 === 3 || e3 === 4 ? "sekunde" : "sekundi"; + }, ms: function(t3) { + return t3 === 1 ? "milisekunda" : t3 % 10 == 2 || t3 % 10 == 3 || t3 % 10 == 4 ? "milisekunde" : "milisekundi"; + }, decimal: ","}, hi: {y: "\u0938\u093E\u0932", mo: function(t3) { + return t3 === 1 ? "\u092E\u0939\u0940\u0928\u093E" : "\u092E\u0939\u0940\u0928\u0947"; + }, w: function(t3) { + return t3 === 1 ? "\u0939\u095E\u094D\u0924\u093E" : "\u0939\u092B\u094D\u0924\u0947"; + }, d: "\u0926\u093F\u0928", h: function(t3) { + return t3 === 1 ? "\u0918\u0902\u091F\u093E" : "\u0918\u0902\u091F\u0947"; + }, m: "\u092E\u093F\u0928\u091F", s: "\u0938\u0947\u0915\u0902\u0921", ms: "\u092E\u093F\u0932\u0940\u0938\u0947\u0915\u0902\u0921", decimal: "."}, hu: {y: "\xE9v", mo: "h\xF3nap", w: "h\xE9t", d: "nap", h: "\xF3ra", m: "perc", s: "m\xE1sodperc", ms: "ezredm\xE1sodperc", decimal: ","}, id: {y: "tahun", mo: "bulan", w: "minggu", d: "hari", h: "jam", m: "menit", s: "detik", ms: "milidetik", decimal: "."}, is: {y: "\xE1r", mo: function(t3) { + return "m\xE1nu\xF0" + (t3 === 1 ? "ur" : "ir"); + }, w: function(t3) { + return "vik" + (t3 === 1 ? "a" : "ur"); + }, d: function(t3) { + return "dag" + (t3 === 1 ? "ur" : "ar"); + }, h: function(t3) { + return "klukkut\xEDm" + (t3 === 1 ? "i" : "ar"); + }, m: function(t3) { + return "m\xEDn\xFAt" + (t3 === 1 ? "a" : "ur"); + }, s: function(t3) { + return "sek\xFAnd" + (t3 === 1 ? "a" : "ur"); + }, ms: function(t3) { + return "millisek\xFAnd" + (t3 === 1 ? "a" : "ur"); + }, decimal: "."}, it: {y: function(t3) { + return "ann" + (t3 === 1 ? "o" : "i"); + }, mo: function(t3) { + return "mes" + (t3 === 1 ? "e" : "i"); + }, w: function(t3) { + return "settiman" + (t3 === 1 ? "a" : "e"); + }, d: function(t3) { + return "giorn" + (t3 === 1 ? "o" : "i"); + }, h: function(t3) { + return "or" + (t3 === 1 ? "a" : "e"); + }, m: function(t3) { + return "minut" + (t3 === 1 ? "o" : "i"); + }, s: function(t3) { + return "second" + (t3 === 1 ? "o" : "i"); + }, ms: function(t3) { + return "millisecond" + (t3 === 1 ? "o" : "i"); + }, decimal: ","}, ja: {y: "\u5E74", mo: "\u6708", w: "\u9031", d: "\u65E5", h: "\u6642\u9593", m: "\u5206", s: "\u79D2", ms: "\u30DF\u30EA\u79D2", decimal: "."}, ko: {y: "\uB144", mo: "\uAC1C\uC6D4", w: "\uC8FC\uC77C", d: "\uC77C", h: "\uC2DC\uAC04", m: "\uBD84", s: "\uCD08", ms: "\uBC00\uB9AC \uCD08", decimal: "."}, lo: {y: "\u0E9B\u0EB5", mo: "\u0EC0\u0E94\u0EB7\u0EAD\u0E99", w: "\u0EAD\u0EB2\u0E97\u0EB4\u0E94", d: "\u0EA1\u0EB7\u0EC9", h: "\u0E8A\u0EBB\u0EC8\u0EA7\u0EC2\u0EA1\u0E87", m: "\u0E99\u0EB2\u0E97\u0EB5", s: "\u0EA7\u0EB4\u0E99\u0EB2\u0E97\u0EB5", ms: "\u0EA1\u0EB4\u0E99\u0EA5\u0EB4\u0EA7\u0EB4\u0E99\u0EB2\u0E97\u0EB5", decimal: ","}, lt: {y: function(t3) { + return t3 % 10 == 0 || t3 % 100 >= 10 && t3 % 100 <= 20 ? "met\u0173" : "metai"; + }, mo: function(t3) { + return ["m\u0117nuo", "m\u0117nesiai", "m\u0117nesi\u0173"][d(t3)]; + }, w: function(t3) { + return ["savait\u0117", "savait\u0117s", "savai\u010Di\u0173"][d(t3)]; + }, d: function(t3) { + return ["diena", "dienos", "dien\u0173"][d(t3)]; + }, h: function(t3) { + return ["valanda", "valandos", "valand\u0173"][d(t3)]; + }, m: function(t3) { + return ["minut\u0117", "minut\u0117s", "minu\u010Di\u0173"][d(t3)]; + }, s: function(t3) { + return ["sekund\u0117", "sekund\u0117s", "sekund\u017Ei\u0173"][d(t3)]; + }, ms: function(t3) { + return ["milisekund\u0117", "milisekund\u0117s", "milisekund\u017Ei\u0173"][d(t3)]; + }, decimal: ","}, lv: {y: function(t3) { + return p(t3) ? "gads" : "gadi"; + }, mo: function(t3) { + return p(t3) ? "m\u0113nesis" : "m\u0113ne\u0161i"; + }, w: function(t3) { + return p(t3) ? "ned\u0113\u013Ca" : "ned\u0113\u013Cas"; + }, d: function(t3) { + return p(t3) ? "diena" : "dienas"; + }, h: function(t3) { + return p(t3) ? "stunda" : "stundas"; + }, m: function(t3) { + return p(t3) ? "min\u016Bte" : "min\u016Btes"; + }, s: function(t3) { + return p(t3) ? "sekunde" : "sekundes"; + }, ms: function(t3) { + return p(t3) ? "milisekunde" : "milisekundes"; + }, decimal: ","}, ms: {y: "tahun", mo: "bulan", w: "minggu", d: "hari", h: "jam", m: "minit", s: "saat", ms: "milisaat", decimal: "."}, nl: {y: "jaar", mo: function(t3) { + return t3 === 1 ? "maand" : "maanden"; + }, w: function(t3) { + return t3 === 1 ? "week" : "weken"; + }, d: function(t3) { + return t3 === 1 ? "dag" : "dagen"; + }, h: "uur", m: function(t3) { + return t3 === 1 ? "minuut" : "minuten"; + }, s: function(t3) { + return t3 === 1 ? "seconde" : "seconden"; + }, ms: function(t3) { + return t3 === 1 ? "milliseconde" : "milliseconden"; + }, decimal: ","}, no: {y: "\xE5r", mo: function(t3) { + return "m\xE5ned" + (t3 === 1 ? "" : "er"); + }, w: function(t3) { + return "uke" + (t3 === 1 ? "" : "r"); + }, d: function(t3) { + return "dag" + (t3 === 1 ? "" : "er"); + }, h: function(t3) { + return "time" + (t3 === 1 ? "" : "r"); + }, m: function(t3) { + return "minutt" + (t3 === 1 ? "" : "er"); + }, s: function(t3) { + return "sekund" + (t3 === 1 ? "" : "er"); + }, ms: function(t3) { + return "millisekund" + (t3 === 1 ? "" : "er"); + }, decimal: ","}, pl: {y: function(t3) { + return ["rok", "roku", "lata", "lat"][c(t3)]; + }, mo: function(t3) { + return ["miesi\u0105c", "miesi\u0105ca", "miesi\u0105ce", "miesi\u0119cy"][c(t3)]; + }, w: function(t3) { + return ["tydzie\u0144", "tygodnia", "tygodnie", "tygodni"][c(t3)]; + }, d: function(t3) { + return ["dzie\u0144", "dnia", "dni", "dni"][c(t3)]; + }, h: function(t3) { + return ["godzina", "godziny", "godziny", "godzin"][c(t3)]; + }, m: function(t3) { + return ["minuta", "minuty", "minuty", "minut"][c(t3)]; + }, s: function(t3) { + return ["sekunda", "sekundy", "sekundy", "sekund"][c(t3)]; + }, ms: function(t3) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][c(t3)]; + }, decimal: ","}, pt: {y: function(t3) { + return "ano" + (t3 === 1 ? "" : "s"); + }, mo: function(t3) { + return t3 === 1 ? "m\xEAs" : "meses"; + }, w: function(t3) { + return "semana" + (t3 === 1 ? "" : "s"); + }, d: function(t3) { + return "dia" + (t3 === 1 ? "" : "s"); + }, h: function(t3) { + return "hora" + (t3 === 1 ? "" : "s"); + }, m: function(t3) { + return "minuto" + (t3 === 1 ? "" : "s"); + }, s: function(t3) { + return "segundo" + (t3 === 1 ? "" : "s"); + }, ms: function(t3) { + return "milissegundo" + (t3 === 1 ? "" : "s"); + }, decimal: ","}, ro: {y: function(t3) { + return t3 === 1 ? "an" : "ani"; + }, mo: function(t3) { + return t3 === 1 ? "lun\u0103" : "luni"; + }, w: function(t3) { + return t3 === 1 ? "s\u0103pt\u0103m\xE2n\u0103" : "s\u0103pt\u0103m\xE2ni"; + }, d: function(t3) { + return t3 === 1 ? "zi" : "zile"; + }, h: function(t3) { + return t3 === 1 ? "or\u0103" : "ore"; + }, m: function(t3) { + return t3 === 1 ? "minut" : "minute"; + }, s: function(t3) { + return t3 === 1 ? "secund\u0103" : "secunde"; + }, ms: function(t3) { + return t3 === 1 ? "milisecund\u0103" : "milisecunde"; + }, decimal: ","}, ru: {y: function(t3) { + return ["\u043B\u0435\u0442", "\u0433\u043E\u0434", "\u0433\u043E\u0434\u0430"][h(t3)]; + }, mo: function(t3) { + return ["\u043C\u0435\u0441\u044F\u0446\u0435\u0432", "\u043C\u0435\u0441\u044F\u0446", "\u043C\u0435\u0441\u044F\u0446\u0430"][h(t3)]; + }, w: function(t3) { + return ["\u043D\u0435\u0434\u0435\u043B\u044C", "\u043D\u0435\u0434\u0435\u043B\u044F", "\u043D\u0435\u0434\u0435\u043B\u0438"][h(t3)]; + }, d: function(t3) { + return ["\u0434\u043D\u0435\u0439", "\u0434\u0435\u043D\u044C", "\u0434\u043D\u044F"][h(t3)]; + }, h: function(t3) { + return ["\u0447\u0430\u0441\u043E\u0432", "\u0447\u0430\u0441", "\u0447\u0430\u0441\u0430"][h(t3)]; + }, m: function(t3) { + return ["\u043C\u0438\u043D\u0443\u0442", "\u043C\u0438\u043D\u0443\u0442\u0430", "\u043C\u0438\u043D\u0443\u0442\u044B"][h(t3)]; + }, s: function(t3) { + return ["\u0441\u0435\u043A\u0443\u043D\u0434", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u044B"][h(t3)]; + }, ms: function(t3) { + return ["\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434", "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u044B"][h(t3)]; + }, decimal: ","}, uk: {y: function(t3) { + return ["\u0440\u043E\u043A\u0456\u0432", "\u0440\u0456\u043A", "\u0440\u043E\u043A\u0438"][h(t3)]; + }, mo: function(t3) { + return ["\u043C\u0456\u0441\u044F\u0446\u0456\u0432", "\u043C\u0456\u0441\u044F\u0446\u044C", "\u043C\u0456\u0441\u044F\u0446\u0456"][h(t3)]; + }, w: function(t3) { + return ["\u0442\u0438\u0436\u043D\u0456\u0432", "\u0442\u0438\u0436\u0434\u0435\u043D\u044C", "\u0442\u0438\u0436\u043D\u0456"][h(t3)]; + }, d: function(t3) { + return ["\u0434\u043D\u0456\u0432", "\u0434\u0435\u043D\u044C", "\u0434\u043D\u0456"][h(t3)]; + }, h: function(t3) { + return ["\u0433\u043E\u0434\u0438\u043D", "\u0433\u043E\u0434\u0438\u043D\u0430", "\u0433\u043E\u0434\u0438\u043D\u0438"][h(t3)]; + }, m: function(t3) { + return ["\u0445\u0432\u0438\u043B\u0438\u043D", "\u0445\u0432\u0438\u043B\u0438\u043D\u0430", "\u0445\u0432\u0438\u043B\u0438\u043D\u0438"][h(t3)]; + }, s: function(t3) { + return ["\u0441\u0435\u043A\u0443\u043D\u0434", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; + }, ms: function(t3) { + return ["\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434", "\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; + }, decimal: ","}, ur: {y: "\u0633\u0627\u0644", mo: function(t3) { + return t3 === 1 ? "\u0645\u06C1\u06CC\u0646\u06C1" : "\u0645\u06C1\u06CC\u0646\u06D2"; + }, w: function(t3) { + return t3 === 1 ? "\u06C1\u0641\u062A\u06C1" : "\u06C1\u0641\u062A\u06D2"; + }, d: "\u062F\u0646", h: function(t3) { + return t3 === 1 ? "\u06AF\u06BE\u0646\u0679\u06C1" : "\u06AF\u06BE\u0646\u0679\u06D2"; + }, m: "\u0645\u0646\u0679", s: "\u0633\u06CC\u06A9\u0646\u0688", ms: "\u0645\u0644\u06CC \u0633\u06CC\u06A9\u0646\u0688", decimal: "."}, sk: {y: function(t3) { + return ["rok", "roky", "roky", "rokov"][l(t3)]; + }, mo: function(t3) { + return ["mesiac", "mesiace", "mesiace", "mesiacov"][l(t3)]; + }, w: function(t3) { + return ["t\xFD\u017Ede\u0148", "t\xFD\u017Edne", "t\xFD\u017Edne", "t\xFD\u017Ed\u0148ov"][l(t3)]; + }, d: function(t3) { + return ["de\u0148", "dni", "dni", "dn\xED"][l(t3)]; + }, h: function(t3) { + return ["hodina", "hodiny", "hodiny", "hod\xEDn"][l(t3)]; + }, m: function(t3) { + return ["min\xFAta", "min\xFAty", "min\xFAty", "min\xFAt"][l(t3)]; + }, s: function(t3) { + return ["sekunda", "sekundy", "sekundy", "sek\xFAnd"][l(t3)]; + }, ms: function(t3) { + return ["milisekunda", "milisekundy", "milisekundy", "milisek\xFAnd"][l(t3)]; + }, decimal: ","}, sl: {y: function(t3) { + return t3 % 10 == 1 ? "leto" : t3 % 100 == 2 ? "leti" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 && t3 % 100 <= 5 ? "leta" : "let"; + }, mo: function(t3) { + return t3 % 10 == 1 ? "mesec" : t3 % 100 == 2 || Math.floor(t3) !== t3 && t3 % 100 <= 5 ? "meseca" : t3 % 10 == 3 || t3 % 10 == 4 ? "mesece" : "mesecev"; + }, w: function(t3) { + return t3 % 10 == 1 ? "teden" : t3 % 10 == 2 || Math.floor(t3) !== t3 && t3 % 100 <= 4 ? "tedna" : t3 % 10 == 3 || t3 % 10 == 4 ? "tedne" : "tednov"; + }, d: function(t3) { + return t3 % 100 == 1 ? "dan" : "dni"; + }, h: function(t3) { + return t3 % 10 == 1 ? "ura" : t3 % 100 == 2 ? "uri" : t3 % 10 == 3 || t3 % 10 == 4 || Math.floor(t3) !== t3 ? "ure" : "ur"; + }, m: function(t3) { + return t3 % 10 == 1 ? "minuta" : t3 % 10 == 2 ? "minuti" : t3 % 10 == 3 || t3 % 10 == 4 || Math.floor(t3) !== t3 && t3 % 100 <= 4 ? "minute" : "minut"; + }, s: function(t3) { + return t3 % 10 == 1 ? "sekunda" : t3 % 100 == 2 ? "sekundi" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 ? "sekunde" : "sekund"; + }, ms: function(t3) { + return t3 % 10 == 1 ? "milisekunda" : t3 % 100 == 2 ? "milisekundi" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 ? "milisekunde" : "milisekund"; + }, decimal: ","}, sv: {y: "\xE5r", mo: function(t3) { + return "m\xE5nad" + (t3 === 1 ? "" : "er"); + }, w: function(t3) { + return "veck" + (t3 === 1 ? "a" : "or"); + }, d: function(t3) { + return "dag" + (t3 === 1 ? "" : "ar"); + }, h: function(t3) { + return "timm" + (t3 === 1 ? "e" : "ar"); + }, m: function(t3) { + return "minut" + (t3 === 1 ? "" : "er"); + }, s: function(t3) { + return "sekund" + (t3 === 1 ? "" : "er"); + }, ms: function(t3) { + return "millisekund" + (t3 === 1 ? "" : "er"); + }, decimal: ","}, sw: {y: function(t3) { + return t3 === 1 ? "mwaka" : "miaka"; + }, mo: function(t3) { + return t3 === 1 ? "mwezi" : "miezi"; + }, w: "wiki", d: function(t3) { + return t3 === 1 ? "siku" : "masiku"; + }, h: function(t3) { + return t3 === 1 ? "saa" : "masaa"; + }, m: "dakika", s: "sekunde", ms: "milisekunde", decimal: "."}, tr: {y: "y\u0131l", mo: "ay", w: "hafta", d: "g\xFCn", h: "saat", m: "dakika", s: "saniye", ms: "milisaniye", decimal: ","}, th: {y: "\u0E1B\u0E35", mo: "\u0E40\u0E14\u0E37\u0E2D\u0E19", w: "\u0E2A\u0E31\u0E1B\u0E14\u0E32\u0E2B\u0E4C", d: "\u0E27\u0E31\u0E19", h: "\u0E0A\u0E31\u0E48\u0E27\u0E42\u0E21\u0E07", m: "\u0E19\u0E32\u0E17\u0E35", s: "\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", ms: "\u0E21\u0E34\u0E25\u0E25\u0E34\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", decimal: "."}, vi: {y: "n\u0103m", mo: "th\xE1ng", w: "tu\u1EA7n", d: "ng\xE0y", h: "gi\u1EDD", m: "ph\xFAt", s: "gi\xE2y", ms: "mili gi\xE2y", decimal: ","}, zh_CN: {y: "\u5E74", mo: "\u4E2A\u6708", w: "\u5468", d: "\u5929", h: "\u5C0F\u65F6", m: "\u5206\u949F", s: "\u79D2", ms: "\u6BEB\u79D2", decimal: "."}, zh_TW: {y: "\u5E74", mo: "\u500B\u6708", w: "\u5468", d: "\u5929", h: "\u5C0F\u6642", m: "\u5206\u9418", s: "\u79D2", ms: "\u6BEB\u79D2", decimal: "."}}; + function a(t3) { + var e3 = function(t4, r3) { + return function(t5, e4) { + var r4, n2, i2; + t5 = Math.abs(t5); + var a2, s2, f2, c2 = function(t6) { + var e5 = [t6.language]; + if (m(t6, "fallbacks")) { + if (!y(t6.fallbacks) || !t6.fallbacks.length) + throw new Error("fallbacks must be an array with at least one element"); + e5 = e5.concat(t6.fallbacks); + } + for (var r5 = 0; r5 < e5.length; r5++) { + var n3 = e5[r5]; + if (m(t6.languages, n3)) + return t6.languages[n3]; + if (m(o, n3)) + return o[n3]; + } + throw new Error("No language found."); + }(e4), h2 = []; + for (r4 = 0, n2 = e4.units.length; r4 < n2; r4++) { + if (a2 = e4.units[r4], s2 = e4.unitMeasures[a2], r4 + 1 === n2) + if (m(e4, "maxDecimalPoints")) { + var l2 = Math.pow(10, e4.maxDecimalPoints), d2 = t5 / s2; + f2 = parseFloat((Math.floor(l2 * d2) / l2).toFixed(e4.maxDecimalPoints)); + } else + f2 = t5 / s2; + else + f2 = Math.floor(t5 / s2); + h2.push({unitCount: f2, unitName: a2}), t5 -= f2 * s2; + } + var p2, b, g = 0; + for (r4 = 0; r4 < h2.length; r4++) + if (h2[r4].unitCount) { + g = r4; + break; + } + if (e4.round) + for (r4 = h2.length - 1; r4 >= 0 && ((i2 = h2[r4]).unitCount = Math.round(i2.unitCount), r4 !== 0); r4--) + b = h2[r4 - 1], p2 = e4.unitMeasures[b.unitName] / e4.unitMeasures[i2.unitName], (i2.unitCount % p2 == 0 || e4.largest && e4.largest - 1 < r4 - g) && (b.unitCount += i2.unitCount / p2, i2.unitCount = 0); + var v = []; + for (r4 = 0, h2.length; r4 < n2 && ((i2 = h2[r4]).unitCount && v.push(u(i2.unitCount, i2.unitName, c2, e4)), v.length !== e4.largest); r4++) + ; + return v.length ? e4.conjunction && v.length !== 1 ? v.length === 2 ? v.join(e4.conjunction) : v.length > 2 ? v.slice(0, -1).join(e4.delimiter) + (e4.serialComma ? "," : "") + e4.conjunction + v.slice(-1) : void 0 : v.join(e4.delimiter) : u(0, e4.units[e4.units.length - 1], c2, e4); + }(t4, f({}, e3, r3 || {})); + }; + return f(e3, {language: "en", delimiter: ", ", spacer: " ", conjunction: "", serialComma: true, units: ["y", "mo", "w", "d", "h", "m", "s"], languages: {}, round: false, unitMeasures: {y: 315576e5, mo: 26298e5, w: 6048e5, d: 864e5, h: 36e5, m: 6e4, s: 1e3, ms: 1}}, t3); + } + var s = a({}); + function u(t3, e3, r3, n2) { + var i2; + i2 = m(n2, "decimal") ? n2.decimal : m(r3, "decimal") ? r3.decimal : "."; + var o2, a2 = t3.toString().replace(".", i2), s2 = r3[e3]; + return o2 = typeof s2 == "function" ? s2(t3) : s2, a2 + n2.spacer + o2; + } + function f(t3) { + for (var e3, r3 = 1; r3 < arguments.length; r3++) + for (var n2 in e3 = arguments[r3]) + m(e3, n2) && (t3[n2] = e3[n2]); + return t3; + } + function c(t3) { + return t3 === 1 ? 0 : Math.floor(t3) !== t3 ? 1 : t3 % 10 >= 2 && t3 % 10 <= 4 && !(t3 % 100 > 10 && t3 % 100 < 20) ? 2 : 3; + } + function h(t3) { + return Math.floor(t3) !== t3 ? 2 : t3 % 100 >= 5 && t3 % 100 <= 20 || t3 % 10 >= 5 && t3 % 10 <= 9 || t3 % 10 == 0 ? 0 : t3 % 10 == 1 ? 1 : t3 > 1 ? 2 : 0; + } + function l(t3) { + return t3 === 1 ? 0 : Math.floor(t3) !== t3 ? 1 : t3 % 10 >= 2 && t3 % 10 <= 4 && t3 % 100 < 10 ? 2 : 3; + } + function d(t3) { + return t3 === 1 || t3 % 10 == 1 && t3 % 100 > 20 ? 0 : Math.floor(t3) !== t3 || t3 % 10 >= 2 && t3 % 100 > 20 || t3 % 10 >= 2 && t3 % 100 < 10 ? 1 : 2; + } + function p(t3) { + return t3 % 10 == 1 && t3 % 100 != 11; + } + var y = Array.isArray || function(t3) { + return Object.prototype.toString.call(t3) === "[object Array]"; + }; + function m(t3, e3) { + return Object.prototype.hasOwnProperty.call(t3, e3); + } + s.getSupportedLanguages = function() { + var t3 = []; + for (var e3 in o) + m(o, e3) && e3 !== "gr" && t3.push(e3); + return t3; + }, s.humanizer = a, (n = function() { + return s; + }.call(e2, r2, e2, t2)) === void 0 || (t2.exports = n); + }(); + }, 645: (t2, e2) => { + e2.read = function(t3, e3, r2, n, i) { + var o, a, s = 8 * i - n - 1, u = (1 << s) - 1, f = u >> 1, c = -7, h = r2 ? i - 1 : 0, l = r2 ? -1 : 1, d = t3[e3 + h]; + for (h += l, o = d & (1 << -c) - 1, d >>= -c, c += s; c > 0; o = 256 * o + t3[e3 + h], h += l, c -= 8) + ; + for (a = o & (1 << -c) - 1, o >>= -c, c += n; c > 0; a = 256 * a + t3[e3 + h], h += l, c -= 8) + ; + if (o === 0) + o = 1 - f; + else { + if (o === u) + return a ? NaN : 1 / 0 * (d ? -1 : 1); + a += Math.pow(2, n), o -= f; + } + return (d ? -1 : 1) * a * Math.pow(2, o - n); + }, e2.write = function(t3, e3, r2, n, i, o) { + var a, s, u, f = 8 * o - i - 1, c = (1 << f) - 1, h = c >> 1, l = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = n ? 0 : o - 1, p = n ? 1 : -1, y = e3 < 0 || e3 === 0 && 1 / e3 < 0 ? 1 : 0; + for (e3 = Math.abs(e3), isNaN(e3) || e3 === 1 / 0 ? (s = isNaN(e3) ? 1 : 0, a = c) : (a = Math.floor(Math.log(e3) / Math.LN2), e3 * (u = Math.pow(2, -a)) < 1 && (a--, u *= 2), (e3 += a + h >= 1 ? l / u : l * Math.pow(2, 1 - h)) * u >= 2 && (a++, u /= 2), a + h >= c ? (s = 0, a = c) : a + h >= 1 ? (s = (e3 * u - 1) * Math.pow(2, i), a += h) : (s = e3 * Math.pow(2, h - 1) * Math.pow(2, i), a = 0)); i >= 8; t3[r2 + d] = 255 & s, d += p, s /= 256, i -= 8) + ; + for (a = a << i | s, f += i; f > 0; t3[r2 + d] = 255 & a, d += p, a /= 256, f -= 8) + ; + t3[r2 + d - p] |= 128 * y; + }; + }, 5717: (t2) => { + typeof Object.create == "function" ? t2.exports = function(t3, e2) { + e2 && (t3.super_ = e2, t3.prototype = Object.create(e2.prototype, {constructor: {value: t3, enumerable: false, writable: true, configurable: true}})); + } : t2.exports = function(t3, e2) { + if (e2) { + t3.super_ = e2; + var r2 = function() { + }; + r2.prototype = e2.prototype, t3.prototype = new r2(), t3.prototype.constructor = t3; + } + }; + }, 2584: (t2, e2, r2) => { + var n = typeof Symbol == "function" && typeof Symbol.toStringTag == "symbol", i = r2(1924)("Object.prototype.toString"), o = function(t3) { + return !(n && t3 && typeof t3 == "object" && Symbol.toStringTag in t3) && i(t3) === "[object Arguments]"; + }, a = function(t3) { + return !!o(t3) || t3 !== null && typeof t3 == "object" && typeof t3.length == "number" && t3.length >= 0 && i(t3) !== "[object Array]" && i(t3.callee) === "[object Function]"; + }, s = function() { + return o(arguments); + }(); + o.isLegacyArguments = a, t2.exports = s ? o : a; + }, 8662: (t2) => { + var e2 = Object.prototype.toString, r2 = Function.prototype.toString, n = /^\s*(?:function)?\*/, i = typeof Symbol == "function" && typeof Symbol.toStringTag == "symbol", o = Object.getPrototypeOf, a = function() { + if (!i) + return false; + try { + return Function("return function*() {}")(); + } catch (t3) { + } + }(), s = !(!o || !a) && o(a); + t2.exports = function(t3) { + return typeof t3 == "function" && (!!n.test(r2.call(t3)) || (i ? o && o(t3) === s : e2.call(t3) === "[object GeneratorFunction]")); + }; + }, 8611: (t2) => { + t2.exports = function(t3) { + return t3 != t3; + }; + }, 360: (t2, e2, r2) => { + var n = r2(5559), i = r2(4289), o = r2(8611), a = r2(9415), s = r2(3194), u = n(a(), Number); + i(u, {getPolyfill: a, implementation: o, shim: s}), t2.exports = u; + }, 9415: (t2, e2, r2) => { + var n = r2(8611); + t2.exports = function() { + return Number.isNaN && Number.isNaN(NaN) && !Number.isNaN("a") ? Number.isNaN : n; + }; + }, 3194: (t2, e2, r2) => { + var n = r2(4289), i = r2(9415); + t2.exports = function() { + var t3 = i(); + return n(Number, {isNaN: t3}, {isNaN: function() { + return Number.isNaN !== t3; + }}), t3; + }; + }, 5692: (t2, e2, r2) => { + var n = r2(9804), i = r2(6314), o = r2(1924), a = o("Object.prototype.toString"), s = r2(1405)() && typeof Symbol.toStringTag == "symbol", u = i(), f = o("Array.prototype.indexOf", true) || function(t3, e3) { + for (var r3 = 0; r3 < t3.length; r3 += 1) + if (t3[r3] === e3) + return r3; + return -1; + }, c = o("String.prototype.slice"), h = {}, l = r2(4079), d = Object.getPrototypeOf; + s && l && d && n(u, function(t3) { + var e3 = new r2.g[t3](); + if (!(Symbol.toStringTag in e3)) + throw new EvalError("this engine has support for Symbol.toStringTag, but " + t3 + " does not have the property! Please report this."); + var n2 = d(e3), i2 = l(n2, Symbol.toStringTag); + if (!i2) { + var o2 = d(n2); + i2 = l(o2, Symbol.toStringTag); + } + h[t3] = i2.get; + }), t2.exports = function(t3) { + if (!t3 || typeof t3 != "object") + return false; + if (!s) { + var e3 = c(a(t3), 8, -1); + return f(u, e3) > -1; + } + return !!l && function(t4) { + var e4 = false; + return n(h, function(r3, n2) { + if (!e4) + try { + e4 = r3.call(t4) === n2; + } catch (t5) { + } + }), e4; + }(t3); + }; + }, 4301: (t2, e2, r2) => { + r2(7147), t2.exports = self.fetch.bind(self); + }, 6792: (t2, e2, r2) => { + var n = null; + typeof WebSocket != "undefined" ? n = WebSocket : typeof MozWebSocket != "undefined" ? n = MozWebSocket : r2.g !== void 0 ? n = r2.g.WebSocket || r2.g.MozWebSocket : typeof window != "undefined" ? n = window.WebSocket || window.MozWebSocket : typeof self != "undefined" && (n = self.WebSocket || self.MozWebSocket), t2.exports = n; + }, 8917: (t2, e2, r2) => { + Object.defineProperty(e2, "__esModule", {value: true}); + const n = r2(2491); + e2.default = n.default; + }, 2491: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}); + const i = r2(6266), o = r2(9809), a = r2(3550), s = o.define("ECPrivateKey", function() { + const t3 = this; + t3.seq().obj(t3.key("version").int(), t3.key("privateKey").octstr(), t3.key("parameters").explicit(0).objid().optional(), t3.key("publicKey").explicit(1).bitstr().optional()); + }), u = o.define("SubjectPublicKeyInfo", function() { + const t3 = this; + t3.seq().obj(t3.key("algorithm").seq().obj(t3.key("id").objid(), t3.key("curve").objid()), t3.key("pub").bitstr()); + }), f = {secp256k1: {curveParameters: [1, 3, 132, 0, 10], privatePEMOptions: {label: "EC PRIVATE KEY"}, publicPEMOptions: {label: "PUBLIC KEY"}, curve: new i.ec("secp256k1")}}; + class c { + constructor(t3) { + if (typeof t3 == "string") { + if (t3 !== "secp256k1") + throw new Error("Unknown curve " + t3); + t3 = f[t3]; + } + this.options = t3, this.algorithmID = [1, 2, 840, 10045, 2, 1]; + } + privateKeyObject(t3, e3) { + const r3 = {version: new a(1), privateKey: n.from(t3, "hex"), parameters: this.options.curveParameters}; + return e3 && (r3.publicKey = {unused: 0, data: n.from(e3, "hex")}), r3; + } + publicKeyObject(t3) { + return {algorithm: {id: this.algorithmID, curve: this.options.curveParameters}, pub: {unused: 0, data: n.from(t3, "hex")}}; + } + encodePrivate(t3, e3, r3) { + let i2; + if (e3 === "raw") { + if (typeof t3 != "string") + throw "private key must be a string"; + let e4 = this.options.curve.keyFromPrivate(t3, "hex").getPublic("hex"); + i2 = this.privateKeyObject(t3, e4); + } else if (e3 === "der") { + if (typeof t3 != "string") + ; + else { + if (typeof t3 != "string") + throw "private key must be a buffer or a string"; + t3 = n.from(t3, "hex"); + } + i2 = s.decode(t3, "der"); + } else { + if (e3 !== "pem") + throw "invalid private key format"; + if (typeof t3 != "string") + throw "private key must be a string"; + i2 = s.decode(t3, "pem", this.options.privatePEMOptions); + } + if (r3 === "raw") + return i2.privateKey.toString("hex"); + if (r3 === "der") + return s.encode(i2, "der").toString("hex"); + if (r3 === "pem") + return s.encode(i2, "pem", this.options.privatePEMOptions); + throw "invalid destination format for private key"; + } + encodePublic(t3, e3, r3) { + let i2; + if (e3 === "raw") { + if (typeof t3 != "string") + throw "public key must be a string"; + i2 = this.publicKeyObject(t3); + } else if (e3 === "der") { + if (typeof t3 != "string") + ; + else { + if (typeof t3 != "string") + throw "public key must be a buffer or a string"; + t3 = n.from(t3, "hex"); + } + i2 = u.decode(t3, "der"); + } else { + if (e3 !== "pem") + throw "invalid public key format"; + if (typeof t3 != "string") + throw "public key must be a string"; + i2 = u.decode(t3, "pem", this.options.publicPEMOptions); + } + if (r3 === "raw") + return i2.pub.data.toString("hex"); + if (r3 === "der") + return u.encode(i2, "der").toString("hex"); + if (r3 === "pem") + return u.encode(i2, "pem", this.options.publicPEMOptions); + throw "invalid destination format for public key"; + } + } + e2.default = c, c.ECPrivateKeyASN = s, c.SubjectPublicKeyInfoASN = u; + }, 2318: (t2, e2, r2) => { + var n = r2(5717), i = r2(3349), o = r2(9509).Buffer, a = new Array(16); + function s() { + i.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878; + } + function u(t3, e3) { + return t3 << e3 | t3 >>> 32 - e3; + } + function f(t3, e3, r3, n2, i2, o2, a2) { + return u(t3 + (e3 & r3 | ~e3 & n2) + i2 + o2 | 0, a2) + e3 | 0; + } + function c(t3, e3, r3, n2, i2, o2, a2) { + return u(t3 + (e3 & n2 | r3 & ~n2) + i2 + o2 | 0, a2) + e3 | 0; + } + function h(t3, e3, r3, n2, i2, o2, a2) { + return u(t3 + (e3 ^ r3 ^ n2) + i2 + o2 | 0, a2) + e3 | 0; + } + function l(t3, e3, r3, n2, i2, o2, a2) { + return u(t3 + (r3 ^ (e3 | ~n2)) + i2 + o2 | 0, a2) + e3 | 0; + } + n(s, i), s.prototype._update = function() { + for (var t3 = a, e3 = 0; e3 < 16; ++e3) + t3[e3] = this._block.readInt32LE(4 * e3); + var r3 = this._a, n2 = this._b, i2 = this._c, o2 = this._d; + r3 = f(r3, n2, i2, o2, t3[0], 3614090360, 7), o2 = f(o2, r3, n2, i2, t3[1], 3905402710, 12), i2 = f(i2, o2, r3, n2, t3[2], 606105819, 17), n2 = f(n2, i2, o2, r3, t3[3], 3250441966, 22), r3 = f(r3, n2, i2, o2, t3[4], 4118548399, 7), o2 = f(o2, r3, n2, i2, t3[5], 1200080426, 12), i2 = f(i2, o2, r3, n2, t3[6], 2821735955, 17), n2 = f(n2, i2, o2, r3, t3[7], 4249261313, 22), r3 = f(r3, n2, i2, o2, t3[8], 1770035416, 7), o2 = f(o2, r3, n2, i2, t3[9], 2336552879, 12), i2 = f(i2, o2, r3, n2, t3[10], 4294925233, 17), n2 = f(n2, i2, o2, r3, t3[11], 2304563134, 22), r3 = f(r3, n2, i2, o2, t3[12], 1804603682, 7), o2 = f(o2, r3, n2, i2, t3[13], 4254626195, 12), i2 = f(i2, o2, r3, n2, t3[14], 2792965006, 17), r3 = c(r3, n2 = f(n2, i2, o2, r3, t3[15], 1236535329, 22), i2, o2, t3[1], 4129170786, 5), o2 = c(o2, r3, n2, i2, t3[6], 3225465664, 9), i2 = c(i2, o2, r3, n2, t3[11], 643717713, 14), n2 = c(n2, i2, o2, r3, t3[0], 3921069994, 20), r3 = c(r3, n2, i2, o2, t3[5], 3593408605, 5), o2 = c(o2, r3, n2, i2, t3[10], 38016083, 9), i2 = c(i2, o2, r3, n2, t3[15], 3634488961, 14), n2 = c(n2, i2, o2, r3, t3[4], 3889429448, 20), r3 = c(r3, n2, i2, o2, t3[9], 568446438, 5), o2 = c(o2, r3, n2, i2, t3[14], 3275163606, 9), i2 = c(i2, o2, r3, n2, t3[3], 4107603335, 14), n2 = c(n2, i2, o2, r3, t3[8], 1163531501, 20), r3 = c(r3, n2, i2, o2, t3[13], 2850285829, 5), o2 = c(o2, r3, n2, i2, t3[2], 4243563512, 9), i2 = c(i2, o2, r3, n2, t3[7], 1735328473, 14), r3 = h(r3, n2 = c(n2, i2, o2, r3, t3[12], 2368359562, 20), i2, o2, t3[5], 4294588738, 4), o2 = h(o2, r3, n2, i2, t3[8], 2272392833, 11), i2 = h(i2, o2, r3, n2, t3[11], 1839030562, 16), n2 = h(n2, i2, o2, r3, t3[14], 4259657740, 23), r3 = h(r3, n2, i2, o2, t3[1], 2763975236, 4), o2 = h(o2, r3, n2, i2, t3[4], 1272893353, 11), i2 = h(i2, o2, r3, n2, t3[7], 4139469664, 16), n2 = h(n2, i2, o2, r3, t3[10], 3200236656, 23), r3 = h(r3, n2, i2, o2, t3[13], 681279174, 4), o2 = h(o2, r3, n2, i2, t3[0], 3936430074, 11), i2 = h(i2, o2, r3, n2, t3[3], 3572445317, 16), n2 = h(n2, i2, o2, r3, t3[6], 76029189, 23), r3 = h(r3, n2, i2, o2, t3[9], 3654602809, 4), o2 = h(o2, r3, n2, i2, t3[12], 3873151461, 11), i2 = h(i2, o2, r3, n2, t3[15], 530742520, 16), r3 = l(r3, n2 = h(n2, i2, o2, r3, t3[2], 3299628645, 23), i2, o2, t3[0], 4096336452, 6), o2 = l(o2, r3, n2, i2, t3[7], 1126891415, 10), i2 = l(i2, o2, r3, n2, t3[14], 2878612391, 15), n2 = l(n2, i2, o2, r3, t3[5], 4237533241, 21), r3 = l(r3, n2, i2, o2, t3[12], 1700485571, 6), o2 = l(o2, r3, n2, i2, t3[3], 2399980690, 10), i2 = l(i2, o2, r3, n2, t3[10], 4293915773, 15), n2 = l(n2, i2, o2, r3, t3[1], 2240044497, 21), r3 = l(r3, n2, i2, o2, t3[8], 1873313359, 6), o2 = l(o2, r3, n2, i2, t3[15], 4264355552, 10), i2 = l(i2, o2, r3, n2, t3[6], 2734768916, 15), n2 = l(n2, i2, o2, r3, t3[13], 1309151649, 21), r3 = l(r3, n2, i2, o2, t3[4], 4149444226, 6), o2 = l(o2, r3, n2, i2, t3[11], 3174756917, 10), i2 = l(i2, o2, r3, n2, t3[2], 718787259, 15), n2 = l(n2, i2, o2, r3, t3[9], 3951481745, 21), this._a = this._a + r3 | 0, this._b = this._b + n2 | 0, this._c = this._c + i2 | 0, this._d = this._d + o2 | 0; + }, s.prototype._digest = function() { + this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); + var t3 = o.allocUnsafe(16); + return t3.writeInt32LE(this._a, 0), t3.writeInt32LE(this._b, 4), t3.writeInt32LE(this._c, 8), t3.writeInt32LE(this._d, 12), t3; + }, t2.exports = s; + }, 3047: (t2, e2, r2) => { + var n = r2(3550), i = r2(7376); + function o(t3) { + this.rand = t3 || new i.Rand(); + } + t2.exports = o, o.create = function(t3) { + return new o(t3); + }, o.prototype._randbelow = function(t3) { + var e3 = t3.bitLength(), r3 = Math.ceil(e3 / 8); + do { + var i2 = new n(this.rand.generate(r3)); + } while (i2.cmp(t3) >= 0); + return i2; + }, o.prototype._randrange = function(t3, e3) { + var r3 = e3.sub(t3); + return t3.add(this._randbelow(r3)); + }, o.prototype.test = function(t3, e3, r3) { + var i2 = t3.bitLength(), o2 = n.mont(t3), a = new n(1).toRed(o2); + e3 || (e3 = Math.max(1, i2 / 48 | 0)); + for (var s = t3.subn(1), u = 0; !s.testn(u); u++) + ; + for (var f = t3.shrn(u), c = s.toRed(o2); e3 > 0; e3--) { + var h = this._randrange(new n(2), s); + r3 && r3(h); + var l = h.toRed(o2).redPow(f); + if (l.cmp(a) !== 0 && l.cmp(c) !== 0) { + for (var d = 1; d < u; d++) { + if ((l = l.redSqr()).cmp(a) === 0) + return false; + if (l.cmp(c) === 0) + break; + } + if (d === u) + return false; + } + } + return true; + }, o.prototype.getDivisor = function(t3, e3) { + var r3 = t3.bitLength(), i2 = n.mont(t3), o2 = new n(1).toRed(i2); + e3 || (e3 = Math.max(1, r3 / 48 | 0)); + for (var a = t3.subn(1), s = 0; !a.testn(s); s++) + ; + for (var u = t3.shrn(s), f = a.toRed(i2); e3 > 0; e3--) { + var c = this._randrange(new n(2), a), h = t3.gcd(c); + if (h.cmpn(1) !== 0) + return h; + var l = c.toRed(i2).redPow(u); + if (l.cmp(o2) !== 0 && l.cmp(f) !== 0) { + for (var d = 1; d < s; d++) { + if ((l = l.redSqr()).cmp(o2) === 0) + return l.fromRed().subn(1).gcd(t3); + if (l.cmp(f) === 0) + break; + } + if (d === s) + return (l = l.redSqr()).fromRed().subn(1).gcd(t3); + } + } + return false; + }; + }, 9746: (t2) => { + function e2(t3, e3) { + if (!t3) + throw new Error(e3 || "Assertion failed"); + } + t2.exports = e2, e2.equal = function(t3, e3, r2) { + if (t3 != e3) + throw new Error(r2 || "Assertion failed: " + t3 + " != " + e3); + }; + }, 4504: (t2, e2) => { + var r2 = e2; + function n(t3) { + return t3.length === 1 ? "0" + t3 : t3; + } + function i(t3) { + for (var e3 = "", r3 = 0; r3 < t3.length; r3++) + e3 += n(t3[r3].toString(16)); + return e3; + } + r2.toArray = function(t3, e3) { + if (Array.isArray(t3)) + return t3.slice(); + if (!t3) + return []; + var r3 = []; + if (typeof t3 != "string") { + for (var n2 = 0; n2 < t3.length; n2++) + r3[n2] = 0 | t3[n2]; + return r3; + } + if (e3 === "hex") + for ((t3 = t3.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (t3 = "0" + t3), n2 = 0; n2 < t3.length; n2 += 2) + r3.push(parseInt(t3[n2] + t3[n2 + 1], 16)); + else + for (n2 = 0; n2 < t3.length; n2++) { + var i2 = t3.charCodeAt(n2), o = i2 >> 8, a = 255 & i2; + o ? r3.push(o, a) : r3.push(a); + } + return r3; + }, r2.zero2 = n, r2.toHex = i, r2.encode = function(t3, e3) { + return e3 === "hex" ? i(t3) : t3; + }; + }, 4244: (t2) => { + var e2 = function(t3) { + return t3 != t3; + }; + t2.exports = function(t3, r2) { + return t3 === 0 && r2 === 0 ? 1 / t3 == 1 / r2 : t3 === r2 || !(!e2(t3) || !e2(r2)); + }; + }, 609: (t2, e2, r2) => { + var n = r2(4289), i = r2(5559), o = r2(4244), a = r2(5624), s = r2(2281), u = i(a(), Object); + n(u, {getPolyfill: a, implementation: o, shim: s}), t2.exports = u; + }, 5624: (t2, e2, r2) => { + var n = r2(4244); + t2.exports = function() { + return typeof Object.is == "function" ? Object.is : n; + }; + }, 2281: (t2, e2, r2) => { + var n = r2(5624), i = r2(4289); + t2.exports = function() { + var t3 = n(); + return i(Object, {is: t3}, {is: function() { + return Object.is !== t3; + }}), t3; + }; + }, 8987: (t2, e2, r2) => { + var n; + if (!Object.keys) { + var i = Object.prototype.hasOwnProperty, o = Object.prototype.toString, a = r2(1414), s = Object.prototype.propertyIsEnumerable, u = !s.call({toString: null}, "toString"), f = s.call(function() { + }, "prototype"), c = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], h = function(t3) { + var e3 = t3.constructor; + return e3 && e3.prototype === t3; + }, l = {$applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true}, d = function() { + if (typeof window == "undefined") + return false; + for (var t3 in window) + try { + if (!l["$" + t3] && i.call(window, t3) && window[t3] !== null && typeof window[t3] == "object") + try { + h(window[t3]); + } catch (t4) { + return true; + } + } catch (t4) { + return true; + } + return false; + }(); + n = function(t3) { + var e3 = t3 !== null && typeof t3 == "object", r3 = o.call(t3) === "[object Function]", n2 = a(t3), s2 = e3 && o.call(t3) === "[object String]", l2 = []; + if (!e3 && !r3 && !n2) + throw new TypeError("Object.keys called on a non-object"); + var p = f && r3; + if (s2 && t3.length > 0 && !i.call(t3, 0)) + for (var y = 0; y < t3.length; ++y) + l2.push(String(y)); + if (n2 && t3.length > 0) + for (var m = 0; m < t3.length; ++m) + l2.push(String(m)); + else + for (var b in t3) + p && b === "prototype" || !i.call(t3, b) || l2.push(String(b)); + if (u) + for (var g = function(t4) { + if (typeof window == "undefined" || !d) + return h(t4); + try { + return h(t4); + } catch (t5) { + return false; + } + }(t3), v = 0; v < c.length; ++v) + g && c[v] === "constructor" || !i.call(t3, c[v]) || l2.push(c[v]); + return l2; + }; + } + t2.exports = n; + }, 2215: (t2, e2, r2) => { + var n = Array.prototype.slice, i = r2(1414), o = Object.keys, a = o ? function(t3) { + return o(t3); + } : r2(8987), s = Object.keys; + a.shim = function() { + return Object.keys ? function() { + var t3 = Object.keys(arguments); + return t3 && t3.length === arguments.length; + }(1, 2) || (Object.keys = function(t3) { + return i(t3) ? s(n.call(t3)) : s(t3); + }) : Object.keys = a, Object.keys || a; + }, t2.exports = a; + }, 1414: (t2) => { + var e2 = Object.prototype.toString; + t2.exports = function(t3) { + var r2 = e2.call(t3), n = r2 === "[object Arguments]"; + return n || (n = r2 !== "[object Array]" && t3 !== null && typeof t3 == "object" && typeof t3.length == "number" && t3.length >= 0 && e2.call(t3.callee) === "[object Function]"), n; + }; + }, 873: (t2) => { + t2.exports = JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}'); + }, 2818: (t2, e2, r2) => { + var n = r2(9809); + e2.certificate = r2(1934); + var i = n.define("RSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("modulus").int(), this.key("publicExponent").int(), this.key("privateExponent").int(), this.key("prime1").int(), this.key("prime2").int(), this.key("exponent1").int(), this.key("exponent2").int(), this.key("coefficient").int()); + }); + e2.RSAPrivateKey = i; + var o = n.define("RSAPublicKey", function() { + this.seq().obj(this.key("modulus").int(), this.key("publicExponent").int()); + }); + e2.RSAPublicKey = o; + var a = n.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(s), this.key("subjectPublicKey").bitstr()); + }); + e2.PublicKey = a; + var s = n.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional()); + }), u = n.define("PrivateKeyInfo", function() { + this.seq().obj(this.key("version").int(), this.key("algorithm").use(s), this.key("subjectPrivateKey").octstr()); + }); + e2.PrivateKey = u; + var f = n.define("EncryptedPrivateKeyInfo", function() { + this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(), this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(), this.key("kdeparams").seq().obj(this.key("salt").octstr(), this.key("iters").int())), this.key("cipher").seq().obj(this.key("algo").objid(), this.key("iv").octstr()))), this.key("subjectPrivateKey").octstr()); + }); + e2.EncryptedPrivateKey = f; + var c = n.define("DSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("p").int(), this.key("q").int(), this.key("g").int(), this.key("pub_key").int(), this.key("priv_key").int()); + }); + e2.DSAPrivateKey = c, e2.DSAparam = n.define("DSAparam", function() { + this.int(); + }); + var h = n.define("ECPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("privateKey").octstr(), this.key("parameters").optional().explicit(0).use(l), this.key("publicKey").optional().explicit(1).bitstr()); + }); + e2.ECPrivateKey = h; + var l = n.define("ECParameters", function() { + this.choice({namedCurve: this.objid()}); + }); + e2.signature = n.define("signature", function() { + this.seq().obj(this.key("r").int(), this.key("s").int()); + }); + }, 1934: (t2, e2, r2) => { + var n = r2(9809), i = n.define("Time", function() { + this.choice({utcTime: this.utctime(), generalTime: this.gentime()}); + }), o = n.define("AttributeTypeValue", function() { + this.seq().obj(this.key("type").objid(), this.key("value").any()); + }), a = n.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("parameters").optional(), this.key("curve").objid().optional()); + }), s = n.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(a), this.key("subjectPublicKey").bitstr()); + }), u = n.define("RelativeDistinguishedName", function() { + this.setof(o); + }), f = n.define("RDNSequence", function() { + this.seqof(u); + }), c = n.define("Name", function() { + this.choice({rdnSequence: this.use(f)}); + }), h = n.define("Validity", function() { + this.seq().obj(this.key("notBefore").use(i), this.key("notAfter").use(i)); + }), l = n.define("Extension", function() { + this.seq().obj(this.key("extnID").objid(), this.key("critical").bool().def(false), this.key("extnValue").octstr()); + }), d = n.define("TBSCertificate", function() { + this.seq().obj(this.key("version").explicit(0).int().optional(), this.key("serialNumber").int(), this.key("signature").use(a), this.key("issuer").use(c), this.key("validity").use(h), this.key("subject").use(c), this.key("subjectPublicKeyInfo").use(s), this.key("issuerUniqueID").implicit(1).bitstr().optional(), this.key("subjectUniqueID").implicit(2).bitstr().optional(), this.key("extensions").explicit(3).seqof(l).optional()); + }), p = n.define("X509Certificate", function() { + this.seq().obj(this.key("tbsCertificate").use(d), this.key("signatureAlgorithm").use(a), this.key("signatureValue").bitstr()); + }); + t2.exports = p; + }, 7631: (t2, e2, r2) => { + var n = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m, i = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m, o = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m, a = r2(3048), s = r2(4696), u = r2(9509).Buffer; + t2.exports = function(t3, e3) { + var r3, f = t3.toString(), c = f.match(n); + if (c) { + var h = "aes" + c[1], l = u.from(c[2], "hex"), d = u.from(c[3].replace(/[\r\n]/g, ""), "base64"), p = a(e3, l.slice(0, 8), parseInt(c[1], 10)).key, y = [], m = s.createDecipheriv(h, p, l); + y.push(m.update(d)), y.push(m.final()), r3 = u.concat(y); + } else { + var b = f.match(o); + r3 = u.from(b[2].replace(/[\r\n]/g, ""), "base64"); + } + return {tag: f.match(i)[1], data: r3}; + }; + }, 980: (t2, e2, r2) => { + var n = r2(2818), i = r2(873), o = r2(7631), a = r2(4696), s = r2(5632), u = r2(9509).Buffer; + function f(t3) { + var e3; + typeof t3 != "object" || u.isBuffer(t3) || (e3 = t3.passphrase, t3 = t3.key), typeof t3 == "string" && (t3 = u.from(t3)); + var r3, f2, c = o(t3, e3), h = c.tag, l = c.data; + switch (h) { + case "CERTIFICATE": + f2 = n.certificate.decode(l, "der").tbsCertificate.subjectPublicKeyInfo; + case "PUBLIC KEY": + switch (f2 || (f2 = n.PublicKey.decode(l, "der")), r3 = f2.algorithm.algorithm.join(".")) { + case "1.2.840.113549.1.1.1": + return n.RSAPublicKey.decode(f2.subjectPublicKey.data, "der"); + case "1.2.840.10045.2.1": + return f2.subjectPrivateKey = f2.subjectPublicKey, {type: "ec", data: f2}; + case "1.2.840.10040.4.1": + return f2.algorithm.params.pub_key = n.DSAparam.decode(f2.subjectPublicKey.data, "der"), {type: "dsa", data: f2.algorithm.params}; + default: + throw new Error("unknown key id " + r3); + } + case "ENCRYPTED PRIVATE KEY": + l = function(t4, e4) { + var r4 = t4.algorithm.decrypt.kde.kdeparams.salt, n2 = parseInt(t4.algorithm.decrypt.kde.kdeparams.iters.toString(), 10), o2 = i[t4.algorithm.decrypt.cipher.algo.join(".")], f3 = t4.algorithm.decrypt.cipher.iv, c2 = t4.subjectPrivateKey, h2 = parseInt(o2.split("-")[1], 10) / 8, l2 = s.pbkdf2Sync(e4, r4, n2, h2, "sha1"), d = a.createDecipheriv(o2, l2, f3), p = []; + return p.push(d.update(c2)), p.push(d.final()), u.concat(p); + }(l = n.EncryptedPrivateKey.decode(l, "der"), e3); + case "PRIVATE KEY": + switch (r3 = (f2 = n.PrivateKey.decode(l, "der")).algorithm.algorithm.join(".")) { + case "1.2.840.113549.1.1.1": + return n.RSAPrivateKey.decode(f2.subjectPrivateKey, "der"); + case "1.2.840.10045.2.1": + return {curve: f2.algorithm.curve, privateKey: n.ECPrivateKey.decode(f2.subjectPrivateKey, "der").privateKey}; + case "1.2.840.10040.4.1": + return f2.algorithm.params.priv_key = n.DSAparam.decode(f2.subjectPrivateKey, "der"), {type: "dsa", params: f2.algorithm.params}; + default: + throw new Error("unknown key id " + r3); + } + case "RSA PUBLIC KEY": + return n.RSAPublicKey.decode(l, "der"); + case "RSA PRIVATE KEY": + return n.RSAPrivateKey.decode(l, "der"); + case "DSA PRIVATE KEY": + return {type: "dsa", params: n.DSAPrivateKey.decode(l, "der")}; + case "EC PRIVATE KEY": + return {curve: (l = n.ECPrivateKey.decode(l, "der")).parameters.value, privateKey: l.privateKey}; + default: + throw new Error("unknown key type " + h); + } + } + t2.exports = f, f.signature = n.signature; + }, 5632: (t2, e2, r2) => { + e2.pbkdf2 = r2(8638), e2.pbkdf2Sync = r2(1257); + }, 8638: (t2, e2, r2) => { + var n, i, o = r2(9509).Buffer, a = r2(7357), s = r2(2368), u = r2(1257), f = r2(7777), c = r2.g.crypto && r2.g.crypto.subtle, h = {sha: "SHA-1", "sha-1": "SHA-1", sha1: "SHA-1", sha256: "SHA-256", "sha-256": "SHA-256", sha384: "SHA-384", "sha-384": "SHA-384", "sha-512": "SHA-512", sha512: "SHA-512"}, l = []; + function d() { + return i || (i = r2.g.process && r2.g.process.nextTick ? r2.g.process.nextTick : r2.g.queueMicrotask ? r2.g.queueMicrotask : r2.g.setImmediate ? r2.g.setImmediate : r2.g.setTimeout); + } + function p(t3, e3, r3, n2, i2) { + return c.importKey("raw", t3, {name: "PBKDF2"}, false, ["deriveBits"]).then(function(t4) { + return c.deriveBits({name: "PBKDF2", salt: e3, iterations: r3, hash: {name: i2}}, t4, n2 << 3); + }).then(function(t4) { + return o.from(t4); + }); + } + t2.exports = function(t3, e3, i2, y, m, b) { + typeof m == "function" && (b = m, m = void 0); + var g = h[(m = m || "sha1").toLowerCase()]; + if (g && typeof r2.g.Promise == "function") { + if (a(i2, y), t3 = f(t3, s, "Password"), e3 = f(e3, s, "Salt"), typeof b != "function") + throw new Error("No callback provided to pbkdf2"); + !function(t4, e4) { + t4.then(function(t5) { + d()(function() { + e4(null, t5); + }); + }, function(t5) { + d()(function() { + e4(t5); + }); + }); + }(function(t4) { + if (r2.g.process && !r2.g.process.browser) + return Promise.resolve(false); + if (!c || !c.importKey || !c.deriveBits) + return Promise.resolve(false); + if (l[t4] !== void 0) + return l[t4]; + var e4 = p(n = n || o.alloc(8), n, 10, 128, t4).then(function() { + return true; + }).catch(function() { + return false; + }); + return l[t4] = e4, e4; + }(g).then(function(r3) { + return r3 ? p(t3, e3, i2, y, g) : u(t3, e3, i2, y, m); + }), b); + } else + d()(function() { + var r3; + try { + r3 = u(t3, e3, i2, y, m); + } catch (t4) { + return b(t4); + } + b(null, r3); + }); + }; + }, 2368: (t2, e2, r2) => { + var n, i = r2(4155); + n = r2.g.process && r2.g.process.browser ? "utf-8" : r2.g.process && r2.g.process.version ? parseInt(i.version.split(".")[0].slice(1), 10) >= 6 ? "utf-8" : "binary" : "utf-8", t2.exports = n; + }, 7357: (t2) => { + var e2 = Math.pow(2, 30) - 1; + t2.exports = function(t3, r2) { + if (typeof t3 != "number") + throw new TypeError("Iterations not a number"); + if (t3 < 0) + throw new TypeError("Bad iterations"); + if (typeof r2 != "number") + throw new TypeError("Key length not a number"); + if (r2 < 0 || r2 > e2 || r2 != r2) + throw new TypeError("Bad key length"); + }; + }, 1257: (t2, e2, r2) => { + var n = r2(8028), i = r2(9785), o = r2(9072), a = r2(9509).Buffer, s = r2(7357), u = r2(2368), f = r2(7777), c = a.alloc(128), h = {md5: 16, sha1: 20, sha224: 28, sha256: 32, sha384: 48, sha512: 64, rmd160: 20, ripemd160: 20}; + function l(t3, e3, r3) { + var s2 = function(t4) { + return t4 === "rmd160" || t4 === "ripemd160" ? function(t5) { + return new i().update(t5).digest(); + } : t4 === "md5" ? n : function(e4) { + return o(t4).update(e4).digest(); + }; + }(t3), u2 = t3 === "sha512" || t3 === "sha384" ? 128 : 64; + e3.length > u2 ? e3 = s2(e3) : e3.length < u2 && (e3 = a.concat([e3, c], u2)); + for (var f2 = a.allocUnsafe(u2 + h[t3]), l2 = a.allocUnsafe(u2 + h[t3]), d = 0; d < u2; d++) + f2[d] = 54 ^ e3[d], l2[d] = 92 ^ e3[d]; + var p = a.allocUnsafe(u2 + r3 + 4); + f2.copy(p, 0, 0, u2), this.ipad1 = p, this.ipad2 = f2, this.opad = l2, this.alg = t3, this.blocksize = u2, this.hash = s2, this.size = h[t3]; + } + l.prototype.run = function(t3, e3) { + return t3.copy(e3, this.blocksize), this.hash(e3).copy(this.opad, this.blocksize), this.hash(this.opad); + }, t2.exports = function(t3, e3, r3, n2, i2) { + s(r3, n2); + var o2 = new l(i2 = i2 || "sha1", t3 = f(t3, u, "Password"), (e3 = f(e3, u, "Salt")).length), c2 = a.allocUnsafe(n2), d = a.allocUnsafe(e3.length + 4); + e3.copy(d, 0, 0, e3.length); + for (var p = 0, y = h[i2], m = Math.ceil(n2 / y), b = 1; b <= m; b++) { + d.writeUInt32BE(b, e3.length); + for (var g = o2.run(d, o2.ipad1), v = g, w = 1; w < r3; w++) { + v = o2.run(v, o2.ipad2); + for (var _ = 0; _ < y; _++) + g[_] ^= v[_]; + } + g.copy(c2, p), p += y; + } + return c2; + }; + }, 7777: (t2, e2, r2) => { + var n = r2(9509).Buffer; + t2.exports = function(t3, e3, r3) { + if (n.isBuffer(t3)) + return t3; + if (typeof t3 == "string") + return n.from(t3, e3); + if (ArrayBuffer.isView(t3)) + return n.from(t3.buffer); + throw new TypeError(r3 + " must be a string, a Buffer, a typed array or a DataView"); + }; + }, 4155: (t2) => { + var e2, r2, n = t2.exports = {}; + function i() { + throw new Error("setTimeout has not been defined"); + } + function o() { + throw new Error("clearTimeout has not been defined"); + } + function a(t3) { + if (e2 === setTimeout) + return setTimeout(t3, 0); + if ((e2 === i || !e2) && setTimeout) + return e2 = setTimeout, setTimeout(t3, 0); + try { + return e2(t3, 0); + } catch (r3) { + try { + return e2.call(null, t3, 0); + } catch (r4) { + return e2.call(this, t3, 0); + } + } + } + !function() { + try { + e2 = typeof setTimeout == "function" ? setTimeout : i; + } catch (t3) { + e2 = i; + } + try { + r2 = typeof clearTimeout == "function" ? clearTimeout : o; + } catch (t3) { + r2 = o; + } + }(); + var s, u = [], f = false, c = -1; + function h() { + f && s && (f = false, s.length ? u = s.concat(u) : c = -1, u.length && l()); + } + function l() { + if (!f) { + var t3 = a(h); + f = true; + for (var e3 = u.length; e3; ) { + for (s = u, u = []; ++c < e3; ) + s && s[c].run(); + c = -1, e3 = u.length; + } + s = null, f = false, function(t4) { + if (r2 === clearTimeout) + return clearTimeout(t4); + if ((r2 === o || !r2) && clearTimeout) + return r2 = clearTimeout, clearTimeout(t4); + try { + r2(t4); + } catch (e4) { + try { + return r2.call(null, t4); + } catch (e5) { + return r2.call(this, t4); + } + } + }(t3); + } + } + function d(t3, e3) { + this.fun = t3, this.array = e3; + } + function p() { + } + n.nextTick = function(t3) { + var e3 = new Array(arguments.length - 1); + if (arguments.length > 1) + for (var r3 = 1; r3 < arguments.length; r3++) + e3[r3 - 1] = arguments[r3]; + u.push(new d(t3, e3)), u.length !== 1 || f || a(l); + }, d.prototype.run = function() { + this.fun.apply(null, this.array); + }, n.title = "browser", n.browser = true, n.env = {}, n.argv = [], n.version = "", n.versions = {}, n.on = p, n.addListener = p, n.once = p, n.off = p, n.removeListener = p, n.removeAllListeners = p, n.emit = p, n.prependListener = p, n.prependOnceListener = p, n.listeners = function(t3) { + return []; + }, n.binding = function(t3) { + throw new Error("process.binding is not supported"); + }, n.cwd = function() { + return "/"; + }, n.chdir = function(t3) { + throw new Error("process.chdir is not supported"); + }, n.umask = function() { + return 0; + }; + }, 7900: (t2, e2, r2) => { + e2.publicEncrypt = r2(6559), e2.privateDecrypt = r2(6138), e2.privateEncrypt = function(t3, r3) { + return e2.publicEncrypt(t3, r3, true); + }, e2.publicDecrypt = function(t3, r3) { + return e2.privateDecrypt(t3, r3, true); + }; + }, 9199: (t2, e2, r2) => { + var n = r2(3482), i = r2(9509).Buffer; + function o(t3) { + var e3 = i.allocUnsafe(4); + return e3.writeUInt32BE(t3, 0), e3; + } + t2.exports = function(t3, e3) { + for (var r3, a = i.alloc(0), s = 0; a.length < e3; ) + r3 = o(s++), a = i.concat([a, n("sha1").update(t3).update(r3).digest()]); + return a.slice(0, e3); + }; + }, 6138: (t2, e2, r2) => { + var n = r2(980), i = r2(9199), o = r2(7859), a = r2(3550), s = r2(3663), u = r2(3482), f = r2(4818), c = r2(9509).Buffer; + t2.exports = function(t3, e3, r3) { + var h; + h = t3.padding ? t3.padding : r3 ? 1 : 4; + var l, d = n(t3), p = d.modulus.byteLength(); + if (e3.length > p || new a(e3).cmp(d.modulus) >= 0) + throw new Error("decryption error"); + l = r3 ? f(new a(e3), d) : s(e3, d); + var y = c.alloc(p - l.length); + if (l = c.concat([y, l], p), h === 4) + return function(t4, e4) { + var r4 = t4.modulus.byteLength(), n2 = u("sha1").update(c.alloc(0)).digest(), a2 = n2.length; + if (e4[0] !== 0) + throw new Error("decryption error"); + var s2 = e4.slice(1, a2 + 1), f2 = e4.slice(a2 + 1), h2 = o(s2, i(f2, a2)), l2 = o(f2, i(h2, r4 - a2 - 1)); + if (function(t5, e5) { + t5 = c.from(t5), e5 = c.from(e5); + var r5 = 0, n3 = t5.length; + t5.length !== e5.length && (r5++, n3 = Math.min(t5.length, e5.length)); + for (var i2 = -1; ++i2 < n3; ) + r5 += t5[i2] ^ e5[i2]; + return r5; + }(n2, l2.slice(0, a2))) + throw new Error("decryption error"); + for (var d2 = a2; l2[d2] === 0; ) + d2++; + if (l2[d2++] !== 1) + throw new Error("decryption error"); + return l2.slice(d2); + }(d, l); + if (h === 1) + return function(t4, e4, r4) { + for (var n2 = e4.slice(0, 2), i2 = 2, o2 = 0; e4[i2++] !== 0; ) + if (i2 >= e4.length) { + o2++; + break; + } + var a2 = e4.slice(2, i2 - 1); + if ((n2.toString("hex") !== "0002" && !r4 || n2.toString("hex") !== "0001" && r4) && o2++, a2.length < 8 && o2++, o2) + throw new Error("decryption error"); + return e4.slice(i2); + }(0, l, r3); + if (h === 3) + return l; + throw new Error("unknown padding"); + }; + }, 6559: (t2, e2, r2) => { + var n = r2(980), i = r2(1798), o = r2(3482), a = r2(9199), s = r2(7859), u = r2(3550), f = r2(4818), c = r2(3663), h = r2(9509).Buffer; + t2.exports = function(t3, e3, r3) { + var l; + l = t3.padding ? t3.padding : r3 ? 1 : 4; + var d, p = n(t3); + if (l === 4) + d = function(t4, e4) { + var r4 = t4.modulus.byteLength(), n2 = e4.length, f2 = o("sha1").update(h.alloc(0)).digest(), c2 = f2.length, l2 = 2 * c2; + if (n2 > r4 - l2 - 2) + throw new Error("message too long"); + var d2 = h.alloc(r4 - n2 - l2 - 2), p2 = r4 - c2 - 1, y = i(c2), m = s(h.concat([f2, d2, h.alloc(1, 1), e4], p2), a(y, p2)), b = s(y, a(m, c2)); + return new u(h.concat([h.alloc(1), b, m], r4)); + }(p, e3); + else if (l === 1) + d = function(t4, e4, r4) { + var n2, o2 = e4.length, a2 = t4.modulus.byteLength(); + if (o2 > a2 - 11) + throw new Error("message too long"); + return n2 = r4 ? h.alloc(a2 - o2 - 3, 255) : function(t5) { + for (var e5, r5 = h.allocUnsafe(t5), n3 = 0, o3 = i(2 * t5), a3 = 0; n3 < t5; ) + a3 === o3.length && (o3 = i(2 * t5), a3 = 0), (e5 = o3[a3++]) && (r5[n3++] = e5); + return r5; + }(a2 - o2 - 3), new u(h.concat([h.from([0, r4 ? 1 : 2]), n2, h.alloc(1), e4], a2)); + }(p, e3, r3); + else { + if (l !== 3) + throw new Error("unknown padding"); + if ((d = new u(e3)).cmp(p.modulus) >= 0) + throw new Error("data too long for modulus"); + } + return r3 ? c(d, p) : f(d, p); + }; + }, 4818: (t2, e2, r2) => { + var n = r2(3550), i = r2(9509).Buffer; + t2.exports = function(t3, e3) { + return i.from(t3.toRed(n.mont(e3.modulus)).redPow(new n(e3.publicExponent)).fromRed().toArray()); + }; + }, 7859: (t2) => { + t2.exports = function(t3, e2) { + for (var r2 = t3.length, n = -1; ++n < r2; ) + t3[n] ^= e2[n]; + return t3; + }; + }, 1798: (t2, e2, r2) => { + var n = r2(4155), i = 65536, o = r2(9509).Buffer, a = r2.g.crypto || r2.g.msCrypto; + a && a.getRandomValues ? t2.exports = function(t3, e3) { + if (t3 > 4294967295) + throw new RangeError("requested too many random bytes"); + var r3 = o.allocUnsafe(t3); + if (t3 > 0) + if (t3 > i) + for (var s = 0; s < t3; s += i) + a.getRandomValues(r3.slice(s, s + i)); + else + a.getRandomValues(r3); + return typeof e3 == "function" ? n.nextTick(function() { + e3(null, r3); + }) : r3; + } : t2.exports = function() { + throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"); + }; + }, 7963: (t2, e2, r2) => { + var n = r2(4155); + function i() { + throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11"); + } + var o = r2(9509), a = r2(1798), s = o.Buffer, u = o.kMaxLength, f = r2.g.crypto || r2.g.msCrypto, c = Math.pow(2, 32) - 1; + function h(t3, e3) { + if (typeof t3 != "number" || t3 != t3) + throw new TypeError("offset must be a number"); + if (t3 > c || t3 < 0) + throw new TypeError("offset must be a uint32"); + if (t3 > u || t3 > e3) + throw new RangeError("offset out of range"); + } + function l(t3, e3, r3) { + if (typeof t3 != "number" || t3 != t3) + throw new TypeError("size must be a number"); + if (t3 > c || t3 < 0) + throw new TypeError("size must be a uint32"); + if (t3 + e3 > r3 || t3 > u) + throw new RangeError("buffer too small"); + } + function d(t3, e3, r3, i2) { + if (n.browser) { + var o2 = t3.buffer, s2 = new Uint8Array(o2, e3, r3); + return f.getRandomValues(s2), i2 ? void n.nextTick(function() { + i2(null, t3); + }) : t3; + } + if (!i2) + return a(r3).copy(t3, e3), t3; + a(r3, function(r4, n2) { + if (r4) + return i2(r4); + n2.copy(t3, e3), i2(null, t3); + }); + } + f && f.getRandomValues || !n.browser ? (e2.randomFill = function(t3, e3, n2, i2) { + if (!(s.isBuffer(t3) || t3 instanceof r2.g.Uint8Array)) + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + if (typeof e3 == "function") + i2 = e3, e3 = 0, n2 = t3.length; + else if (typeof n2 == "function") + i2 = n2, n2 = t3.length - e3; + else if (typeof i2 != "function") + throw new TypeError('"cb" argument must be a function'); + return h(e3, t3.length), l(n2, e3, t3.length), d(t3, e3, n2, i2); + }, e2.randomFillSync = function(t3, e3, n2) { + if (e3 === void 0 && (e3 = 0), !(s.isBuffer(t3) || t3 instanceof r2.g.Uint8Array)) + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + return h(e3, t3.length), n2 === void 0 && (n2 = t3.length - e3), l(n2, e3, t3.length), d(t3, e3, n2); + }) : (e2.randomFill = i, e2.randomFillSync = i); + }, 4281: (t2) => { + var e2 = {}; + function r2(t3, r3, n2) { + n2 || (n2 = Error); + var i = function(t4) { + var e3, n3; + function i2(e4, n4, i3) { + return t4.call(this, function(t5, e5, n5) { + return typeof r3 == "string" ? r3 : r3(t5, e5, n5); + }(e4, n4, i3)) || this; + } + return n3 = t4, (e3 = i2).prototype = Object.create(n3.prototype), e3.prototype.constructor = e3, e3.__proto__ = n3, i2; + }(n2); + i.prototype.name = n2.name, i.prototype.code = t3, e2[t3] = i; + } + function n(t3, e3) { + if (Array.isArray(t3)) { + var r3 = t3.length; + return t3 = t3.map(function(t4) { + return String(t4); + }), r3 > 2 ? "one of ".concat(e3, " ").concat(t3.slice(0, r3 - 1).join(", "), ", or ") + t3[r3 - 1] : r3 === 2 ? "one of ".concat(e3, " ").concat(t3[0], " or ").concat(t3[1]) : "of ".concat(e3, " ").concat(t3[0]); + } + return "of ".concat(e3, " ").concat(String(t3)); + } + r2("ERR_INVALID_OPT_VALUE", function(t3, e3) { + return 'The value "' + e3 + '" is invalid for option "' + t3 + '"'; + }, TypeError), r2("ERR_INVALID_ARG_TYPE", function(t3, e3, r3) { + var i, o, a, s, u; + if (typeof e3 == "string" && (o = "not ", e3.substr(0, o.length) === o) ? (i = "must not be", e3 = e3.replace(/^not /, "")) : i = "must be", function(t4, e4, r4) { + return (r4 === void 0 || r4 > t4.length) && (r4 = t4.length), t4.substring(r4 - e4.length, r4) === e4; + }(t3, " argument")) + a = "The ".concat(t3, " ").concat(i, " ").concat(n(e3, "type")); + else { + var f = (typeof u != "number" && (u = 0), u + ".".length > (s = t3).length || s.indexOf(".", u) === -1 ? "argument" : "property"); + a = 'The "'.concat(t3, '" ').concat(f, " ").concat(i, " ").concat(n(e3, "type")); + } + return a + ". Received type ".concat(typeof r3); + }, TypeError), r2("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"), r2("ERR_METHOD_NOT_IMPLEMENTED", function(t3) { + return "The " + t3 + " method is not implemented"; + }), r2("ERR_STREAM_PREMATURE_CLOSE", "Premature close"), r2("ERR_STREAM_DESTROYED", function(t3) { + return "Cannot call " + t3 + " after a stream was destroyed"; + }), r2("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"), r2("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"), r2("ERR_STREAM_WRITE_AFTER_END", "write after end"), r2("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError), r2("ERR_UNKNOWN_ENCODING", function(t3) { + return "Unknown encoding: " + t3; + }, TypeError), r2("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"), t2.exports.q = e2; + }, 6753: (t2, e2, r2) => { + var n = r2(4155), i = Object.keys || function(t3) { + var e3 = []; + for (var r3 in t3) + e3.push(r3); + return e3; + }; + t2.exports = c; + var o = r2(9481), a = r2(4229); + r2(5717)(c, o); + for (var s = i(a.prototype), u = 0; u < s.length; u++) { + var f = s[u]; + c.prototype[f] || (c.prototype[f] = a.prototype[f]); + } + function c(t3) { + if (!(this instanceof c)) + return new c(t3); + o.call(this, t3), a.call(this, t3), this.allowHalfOpen = true, t3 && (t3.readable === false && (this.readable = false), t3.writable === false && (this.writable = false), t3.allowHalfOpen === false && (this.allowHalfOpen = false, this.once("end", h))); + } + function h() { + this._writableState.ended || n.nextTick(l, this); + } + function l(t3) { + t3.end(); + } + Object.defineProperty(c.prototype, "writableHighWaterMark", {enumerable: false, get: function() { + return this._writableState.highWaterMark; + }}), Object.defineProperty(c.prototype, "writableBuffer", {enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + }}), Object.defineProperty(c.prototype, "writableLength", {enumerable: false, get: function() { + return this._writableState.length; + }}), Object.defineProperty(c.prototype, "destroyed", {enumerable: false, get: function() { + return this._readableState !== void 0 && this._writableState !== void 0 && this._readableState.destroyed && this._writableState.destroyed; + }, set: function(t3) { + this._readableState !== void 0 && this._writableState !== void 0 && (this._readableState.destroyed = t3, this._writableState.destroyed = t3); + }}); + }, 2725: (t2, e2, r2) => { + t2.exports = i; + var n = r2(4605); + function i(t3) { + if (!(this instanceof i)) + return new i(t3); + n.call(this, t3); + } + r2(5717)(i, n), i.prototype._transform = function(t3, e3, r3) { + r3(null, t3); + }; + }, 9481: (t2, e2, r2) => { + var n, i = r2(4155); + t2.exports = A, A.ReadableState = E, r2(7187).EventEmitter; + var o, a = function(t3, e3) { + return t3.listeners(e3).length; + }, s = r2(2503), u = r2(8764).Buffer, f = r2.g.Uint8Array || function() { + }, c = r2(4616); + o = c && c.debuglog ? c.debuglog("stream") : function() { + }; + var h, l, d, p = r2(7327), y = r2(1195), m = r2(2457).getHighWaterMark, b = r2(4281).q, g = b.ERR_INVALID_ARG_TYPE, v = b.ERR_STREAM_PUSH_AFTER_EOF, w = b.ERR_METHOD_NOT_IMPLEMENTED, _ = b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + r2(5717)(A, s); + var M = y.errorOrDestroy, S = ["error", "close", "destroy", "pause", "resume"]; + function E(t3, e3, i2) { + n = n || r2(6753), t3 = t3 || {}, typeof i2 != "boolean" && (i2 = e3 instanceof n), this.objectMode = !!t3.objectMode, i2 && (this.objectMode = this.objectMode || !!t3.readableObjectMode), this.highWaterMark = m(this, t3, "readableHighWaterMark", i2), this.buffer = new p(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = false, this.endEmitted = false, this.reading = false, this.sync = true, this.needReadable = false, this.emittedReadable = false, this.readableListening = false, this.resumeScheduled = false, this.paused = true, this.emitClose = t3.emitClose !== false, this.autoDestroy = !!t3.autoDestroy, this.destroyed = false, this.defaultEncoding = t3.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = false, this.decoder = null, this.encoding = null, t3.encoding && (h || (h = r2(2553).s), this.decoder = new h(t3.encoding), this.encoding = t3.encoding); + } + function A(t3) { + if (n = n || r2(6753), !(this instanceof A)) + return new A(t3); + var e3 = this instanceof n; + this._readableState = new E(t3, this, e3), this.readable = true, t3 && (typeof t3.read == "function" && (this._read = t3.read), typeof t3.destroy == "function" && (this._destroy = t3.destroy)), s.call(this); + } + function k(t3, e3, r3, n2, i2) { + o("readableAddChunk", e3); + var a2, s2 = t3._readableState; + if (e3 === null) + s2.reading = false, function(t4, e4) { + if (o("onEofChunk"), !e4.ended) { + if (e4.decoder) { + var r4 = e4.decoder.end(); + r4 && r4.length && (e4.buffer.push(r4), e4.length += e4.objectMode ? 1 : r4.length); + } + e4.ended = true, e4.sync ? O(t4) : (e4.needReadable = false, e4.emittedReadable || (e4.emittedReadable = true, R(t4))); + } + }(t3, s2); + else if (i2 || (a2 = function(t4, e4) { + var r4, n3; + return n3 = e4, u.isBuffer(n3) || n3 instanceof f || typeof e4 == "string" || e4 === void 0 || t4.objectMode || (r4 = new g("chunk", ["string", "Buffer", "Uint8Array"], e4)), r4; + }(s2, e3)), a2) + M(t3, a2); + else if (s2.objectMode || e3 && e3.length > 0) + if (typeof e3 == "string" || s2.objectMode || Object.getPrototypeOf(e3) === u.prototype || (e3 = function(t4) { + return u.from(t4); + }(e3)), n2) + s2.endEmitted ? M(t3, new _()) : B(t3, s2, e3, true); + else if (s2.ended) + M(t3, new v()); + else { + if (s2.destroyed) + return false; + s2.reading = false, s2.decoder && !r3 ? (e3 = s2.decoder.write(e3), s2.objectMode || e3.length !== 0 ? B(t3, s2, e3, false) : P(t3, s2)) : B(t3, s2, e3, false); + } + else + n2 || (s2.reading = false, P(t3, s2)); + return !s2.ended && (s2.length < s2.highWaterMark || s2.length === 0); + } + function B(t3, e3, r3, n2) { + e3.flowing && e3.length === 0 && !e3.sync ? (e3.awaitDrain = 0, t3.emit("data", r3)) : (e3.length += e3.objectMode ? 1 : r3.length, n2 ? e3.buffer.unshift(r3) : e3.buffer.push(r3), e3.needReadable && O(t3)), P(t3, e3); + } + Object.defineProperty(A.prototype, "destroyed", {enumerable: false, get: function() { + return this._readableState !== void 0 && this._readableState.destroyed; + }, set: function(t3) { + this._readableState && (this._readableState.destroyed = t3); + }}), A.prototype.destroy = y.destroy, A.prototype._undestroy = y.undestroy, A.prototype._destroy = function(t3, e3) { + e3(t3); + }, A.prototype.push = function(t3, e3) { + var r3, n2 = this._readableState; + return n2.objectMode ? r3 = true : typeof t3 == "string" && ((e3 = e3 || n2.defaultEncoding) !== n2.encoding && (t3 = u.from(t3, e3), e3 = ""), r3 = true), k(this, t3, e3, false, r3); + }, A.prototype.unshift = function(t3) { + return k(this, t3, null, true, false); + }, A.prototype.isPaused = function() { + return this._readableState.flowing === false; + }, A.prototype.setEncoding = function(t3) { + h || (h = r2(2553).s); + var e3 = new h(t3); + this._readableState.decoder = e3, this._readableState.encoding = this._readableState.decoder.encoding; + for (var n2 = this._readableState.buffer.head, i2 = ""; n2 !== null; ) + i2 += e3.write(n2.data), n2 = n2.next; + return this._readableState.buffer.clear(), i2 !== "" && this._readableState.buffer.push(i2), this._readableState.length = i2.length, this; + }; + var T = 1073741824; + function x(t3, e3) { + return t3 <= 0 || e3.length === 0 && e3.ended ? 0 : e3.objectMode ? 1 : t3 != t3 ? e3.flowing && e3.length ? e3.buffer.head.data.length : e3.length : (t3 > e3.highWaterMark && (e3.highWaterMark = function(t4) { + return t4 >= T ? t4 = T : (t4--, t4 |= t4 >>> 1, t4 |= t4 >>> 2, t4 |= t4 >>> 4, t4 |= t4 >>> 8, t4 |= t4 >>> 16, t4++), t4; + }(t3)), t3 <= e3.length ? t3 : e3.ended ? e3.length : (e3.needReadable = true, 0)); + } + function O(t3) { + var e3 = t3._readableState; + o("emitReadable", e3.needReadable, e3.emittedReadable), e3.needReadable = false, e3.emittedReadable || (o("emitReadable", e3.flowing), e3.emittedReadable = true, i.nextTick(R, t3)); + } + function R(t3) { + var e3 = t3._readableState; + o("emitReadable_", e3.destroyed, e3.length, e3.ended), e3.destroyed || !e3.length && !e3.ended || (t3.emit("readable"), e3.emittedReadable = false), e3.needReadable = !e3.flowing && !e3.ended && e3.length <= e3.highWaterMark, C(t3); + } + function P(t3, e3) { + e3.readingMore || (e3.readingMore = true, i.nextTick(I, t3, e3)); + } + function I(t3, e3) { + for (; !e3.reading && !e3.ended && (e3.length < e3.highWaterMark || e3.flowing && e3.length === 0); ) { + var r3 = e3.length; + if (o("maybeReadMore read 0"), t3.read(0), r3 === e3.length) + break; + } + e3.readingMore = false; + } + function j(t3) { + var e3 = t3._readableState; + e3.readableListening = t3.listenerCount("readable") > 0, e3.resumeScheduled && !e3.paused ? e3.flowing = true : t3.listenerCount("data") > 0 && t3.resume(); + } + function U(t3) { + o("readable nexttick read 0"), t3.read(0); + } + function N(t3, e3) { + o("resume", e3.reading), e3.reading || t3.read(0), e3.resumeScheduled = false, t3.emit("resume"), C(t3), e3.flowing && !e3.reading && t3.read(0); + } + function C(t3) { + var e3 = t3._readableState; + for (o("flow", e3.flowing); e3.flowing && t3.read() !== null; ) + ; + } + function D(t3, e3) { + return e3.length === 0 ? null : (e3.objectMode ? r3 = e3.buffer.shift() : !t3 || t3 >= e3.length ? (r3 = e3.decoder ? e3.buffer.join("") : e3.buffer.length === 1 ? e3.buffer.first() : e3.buffer.concat(e3.length), e3.buffer.clear()) : r3 = e3.buffer.consume(t3, e3.decoder), r3); + var r3; + } + function L(t3) { + var e3 = t3._readableState; + o("endReadable", e3.endEmitted), e3.endEmitted || (e3.ended = true, i.nextTick(K, e3, t3)); + } + function K(t3, e3) { + if (o("endReadableNT", t3.endEmitted, t3.length), !t3.endEmitted && t3.length === 0 && (t3.endEmitted = true, e3.readable = false, e3.emit("end"), t3.autoDestroy)) { + var r3 = e3._writableState; + (!r3 || r3.autoDestroy && r3.finished) && e3.destroy(); + } + } + function z(t3, e3) { + for (var r3 = 0, n2 = t3.length; r3 < n2; r3++) + if (t3[r3] === e3) + return r3; + return -1; + } + A.prototype.read = function(t3) { + o("read", t3), t3 = parseInt(t3, 10); + var e3 = this._readableState, r3 = t3; + if (t3 !== 0 && (e3.emittedReadable = false), t3 === 0 && e3.needReadable && ((e3.highWaterMark !== 0 ? e3.length >= e3.highWaterMark : e3.length > 0) || e3.ended)) + return o("read: emitReadable", e3.length, e3.ended), e3.length === 0 && e3.ended ? L(this) : O(this), null; + if ((t3 = x(t3, e3)) === 0 && e3.ended) + return e3.length === 0 && L(this), null; + var n2, i2 = e3.needReadable; + return o("need readable", i2), (e3.length === 0 || e3.length - t3 < e3.highWaterMark) && o("length less than watermark", i2 = true), e3.ended || e3.reading ? o("reading or ended", i2 = false) : i2 && (o("do read"), e3.reading = true, e3.sync = true, e3.length === 0 && (e3.needReadable = true), this._read(e3.highWaterMark), e3.sync = false, e3.reading || (t3 = x(r3, e3))), (n2 = t3 > 0 ? D(t3, e3) : null) === null ? (e3.needReadable = e3.length <= e3.highWaterMark, t3 = 0) : (e3.length -= t3, e3.awaitDrain = 0), e3.length === 0 && (e3.ended || (e3.needReadable = true), r3 !== t3 && e3.ended && L(this)), n2 !== null && this.emit("data", n2), n2; + }, A.prototype._read = function(t3) { + M(this, new w("_read()")); + }, A.prototype.pipe = function(t3, e3) { + var r3 = this, n2 = this._readableState; + switch (n2.pipesCount) { + case 0: + n2.pipes = t3; + break; + case 1: + n2.pipes = [n2.pipes, t3]; + break; + default: + n2.pipes.push(t3); + } + n2.pipesCount += 1, o("pipe count=%d opts=%j", n2.pipesCount, e3); + var s2 = e3 && e3.end === false || t3 === i.stdout || t3 === i.stderr ? y2 : u2; + function u2() { + o("onend"), t3.end(); + } + n2.endEmitted ? i.nextTick(s2) : r3.once("end", s2), t3.on("unpipe", function e4(i2, a2) { + o("onunpipe"), i2 === r3 && a2 && a2.hasUnpiped === false && (a2.hasUnpiped = true, o("cleanup"), t3.removeListener("close", d2), t3.removeListener("finish", p2), t3.removeListener("drain", f2), t3.removeListener("error", l2), t3.removeListener("unpipe", e4), r3.removeListener("end", u2), r3.removeListener("end", y2), r3.removeListener("data", h2), c2 = true, !n2.awaitDrain || t3._writableState && !t3._writableState.needDrain || f2()); + }); + var f2 = function(t4) { + return function() { + var e4 = t4._readableState; + o("pipeOnDrain", e4.awaitDrain), e4.awaitDrain && e4.awaitDrain--, e4.awaitDrain === 0 && a(t4, "data") && (e4.flowing = true, C(t4)); + }; + }(r3); + t3.on("drain", f2); + var c2 = false; + function h2(e4) { + o("ondata"); + var i2 = t3.write(e4); + o("dest.write", i2), i2 === false && ((n2.pipesCount === 1 && n2.pipes === t3 || n2.pipesCount > 1 && z(n2.pipes, t3) !== -1) && !c2 && (o("false write response, pause", n2.awaitDrain), n2.awaitDrain++), r3.pause()); + } + function l2(e4) { + o("onerror", e4), y2(), t3.removeListener("error", l2), a(t3, "error") === 0 && M(t3, e4); + } + function d2() { + t3.removeListener("finish", p2), y2(); + } + function p2() { + o("onfinish"), t3.removeListener("close", d2), y2(); + } + function y2() { + o("unpipe"), r3.unpipe(t3); + } + return r3.on("data", h2), function(t4, e4, r4) { + if (typeof t4.prependListener == "function") + return t4.prependListener(e4, r4); + t4._events && t4._events.error ? Array.isArray(t4._events.error) ? t4._events.error.unshift(r4) : t4._events.error = [r4, t4._events.error] : t4.on(e4, r4); + }(t3, "error", l2), t3.once("close", d2), t3.once("finish", p2), t3.emit("pipe", r3), n2.flowing || (o("pipe resume"), r3.resume()), t3; + }, A.prototype.unpipe = function(t3) { + var e3 = this._readableState, r3 = {hasUnpiped: false}; + if (e3.pipesCount === 0) + return this; + if (e3.pipesCount === 1) + return t3 && t3 !== e3.pipes || (t3 || (t3 = e3.pipes), e3.pipes = null, e3.pipesCount = 0, e3.flowing = false, t3 && t3.emit("unpipe", this, r3)), this; + if (!t3) { + var n2 = e3.pipes, i2 = e3.pipesCount; + e3.pipes = null, e3.pipesCount = 0, e3.flowing = false; + for (var o2 = 0; o2 < i2; o2++) + n2[o2].emit("unpipe", this, {hasUnpiped: false}); + return this; + } + var a2 = z(e3.pipes, t3); + return a2 === -1 || (e3.pipes.splice(a2, 1), e3.pipesCount -= 1, e3.pipesCount === 1 && (e3.pipes = e3.pipes[0]), t3.emit("unpipe", this, r3)), this; + }, A.prototype.on = function(t3, e3) { + var r3 = s.prototype.on.call(this, t3, e3), n2 = this._readableState; + return t3 === "data" ? (n2.readableListening = this.listenerCount("readable") > 0, n2.flowing !== false && this.resume()) : t3 === "readable" && (n2.endEmitted || n2.readableListening || (n2.readableListening = n2.needReadable = true, n2.flowing = false, n2.emittedReadable = false, o("on readable", n2.length, n2.reading), n2.length ? O(this) : n2.reading || i.nextTick(U, this))), r3; + }, A.prototype.addListener = A.prototype.on, A.prototype.removeListener = function(t3, e3) { + var r3 = s.prototype.removeListener.call(this, t3, e3); + return t3 === "readable" && i.nextTick(j, this), r3; + }, A.prototype.removeAllListeners = function(t3) { + var e3 = s.prototype.removeAllListeners.apply(this, arguments); + return t3 !== "readable" && t3 !== void 0 || i.nextTick(j, this), e3; + }, A.prototype.resume = function() { + var t3 = this._readableState; + return t3.flowing || (o("resume"), t3.flowing = !t3.readableListening, function(t4, e3) { + e3.resumeScheduled || (e3.resumeScheduled = true, i.nextTick(N, t4, e3)); + }(this, t3)), t3.paused = false, this; + }, A.prototype.pause = function() { + return o("call pause flowing=%j", this._readableState.flowing), this._readableState.flowing !== false && (o("pause"), this._readableState.flowing = false, this.emit("pause")), this._readableState.paused = true, this; + }, A.prototype.wrap = function(t3) { + var e3 = this, r3 = this._readableState, n2 = false; + for (var i2 in t3.on("end", function() { + if (o("wrapped end"), r3.decoder && !r3.ended) { + var t4 = r3.decoder.end(); + t4 && t4.length && e3.push(t4); + } + e3.push(null); + }), t3.on("data", function(i3) { + o("wrapped data"), r3.decoder && (i3 = r3.decoder.write(i3)), r3.objectMode && i3 == null || (r3.objectMode || i3 && i3.length) && (e3.push(i3) || (n2 = true, t3.pause())); + }), t3) + this[i2] === void 0 && typeof t3[i2] == "function" && (this[i2] = function(e4) { + return function() { + return t3[e4].apply(t3, arguments); + }; + }(i2)); + for (var a2 = 0; a2 < S.length; a2++) + t3.on(S[a2], this.emit.bind(this, S[a2])); + return this._read = function(e4) { + o("wrapped _read", e4), n2 && (n2 = false, t3.resume()); + }, this; + }, typeof Symbol == "function" && (A.prototype[Symbol.asyncIterator] = function() { + return l === void 0 && (l = r2(5850)), l(this); + }), Object.defineProperty(A.prototype, "readableHighWaterMark", {enumerable: false, get: function() { + return this._readableState.highWaterMark; + }}), Object.defineProperty(A.prototype, "readableBuffer", {enumerable: false, get: function() { + return this._readableState && this._readableState.buffer; + }}), Object.defineProperty(A.prototype, "readableFlowing", {enumerable: false, get: function() { + return this._readableState.flowing; + }, set: function(t3) { + this._readableState && (this._readableState.flowing = t3); + }}), A._fromList = D, Object.defineProperty(A.prototype, "readableLength", {enumerable: false, get: function() { + return this._readableState.length; + }}), typeof Symbol == "function" && (A.from = function(t3, e3) { + return d === void 0 && (d = r2(5167)), d(A, t3, e3); + }); + }, 4605: (t2, e2, r2) => { + t2.exports = c; + var n = r2(4281).q, i = n.ERR_METHOD_NOT_IMPLEMENTED, o = n.ERR_MULTIPLE_CALLBACK, a = n.ERR_TRANSFORM_ALREADY_TRANSFORMING, s = n.ERR_TRANSFORM_WITH_LENGTH_0, u = r2(6753); + function f(t3, e3) { + var r3 = this._transformState; + r3.transforming = false; + var n2 = r3.writecb; + if (n2 === null) + return this.emit("error", new o()); + r3.writechunk = null, r3.writecb = null, e3 != null && this.push(e3), n2(t3); + var i2 = this._readableState; + i2.reading = false, (i2.needReadable || i2.length < i2.highWaterMark) && this._read(i2.highWaterMark); + } + function c(t3) { + if (!(this instanceof c)) + return new c(t3); + u.call(this, t3), this._transformState = {afterTransform: f.bind(this), needTransform: false, transforming: false, writecb: null, writechunk: null, writeencoding: null}, this._readableState.needReadable = true, this._readableState.sync = false, t3 && (typeof t3.transform == "function" && (this._transform = t3.transform), typeof t3.flush == "function" && (this._flush = t3.flush)), this.on("prefinish", h); + } + function h() { + var t3 = this; + typeof this._flush != "function" || this._readableState.destroyed ? l(this, null, null) : this._flush(function(e3, r3) { + l(t3, e3, r3); + }); + } + function l(t3, e3, r3) { + if (e3) + return t3.emit("error", e3); + if (r3 != null && t3.push(r3), t3._writableState.length) + throw new s(); + if (t3._transformState.transforming) + throw new a(); + return t3.push(null); + } + r2(5717)(c, u), c.prototype.push = function(t3, e3) { + return this._transformState.needTransform = false, u.prototype.push.call(this, t3, e3); + }, c.prototype._transform = function(t3, e3, r3) { + r3(new i("_transform()")); + }, c.prototype._write = function(t3, e3, r3) { + var n2 = this._transformState; + if (n2.writecb = r3, n2.writechunk = t3, n2.writeencoding = e3, !n2.transforming) { + var i2 = this._readableState; + (n2.needTransform || i2.needReadable || i2.length < i2.highWaterMark) && this._read(i2.highWaterMark); + } + }, c.prototype._read = function(t3) { + var e3 = this._transformState; + e3.writechunk === null || e3.transforming ? e3.needTransform = true : (e3.transforming = true, this._transform(e3.writechunk, e3.writeencoding, e3.afterTransform)); + }, c.prototype._destroy = function(t3, e3) { + u.prototype._destroy.call(this, t3, function(t4) { + e3(t4); + }); + }; + }, 4229: (t2, e2, r2) => { + var n, i = r2(4155); + function o(t3) { + var e3 = this; + this.next = null, this.entry = null, this.finish = function() { + !function(t4, e4, r3) { + var n2 = t4.entry; + for (t4.entry = null; n2; ) { + var i2 = n2.callback; + e4.pendingcb--, i2(void 0), n2 = n2.next; + } + e4.corkedRequestsFree.next = t4; + }(e3, t3); + }; + } + t2.exports = A, A.WritableState = E; + var a, s = {deprecate: r2(7781)}, u = r2(2503), f = r2(8764).Buffer, c = r2.g.Uint8Array || function() { + }, h = r2(1195), l = r2(2457).getHighWaterMark, d = r2(4281).q, p = d.ERR_INVALID_ARG_TYPE, y = d.ERR_METHOD_NOT_IMPLEMENTED, m = d.ERR_MULTIPLE_CALLBACK, b = d.ERR_STREAM_CANNOT_PIPE, g = d.ERR_STREAM_DESTROYED, v = d.ERR_STREAM_NULL_VALUES, w = d.ERR_STREAM_WRITE_AFTER_END, _ = d.ERR_UNKNOWN_ENCODING, M = h.errorOrDestroy; + function S() { + } + function E(t3, e3, a2) { + n = n || r2(6753), t3 = t3 || {}, typeof a2 != "boolean" && (a2 = e3 instanceof n), this.objectMode = !!t3.objectMode, a2 && (this.objectMode = this.objectMode || !!t3.writableObjectMode), this.highWaterMark = l(this, t3, "writableHighWaterMark", a2), this.finalCalled = false, this.needDrain = false, this.ending = false, this.ended = false, this.finished = false, this.destroyed = false; + var s2 = t3.decodeStrings === false; + this.decodeStrings = !s2, this.defaultEncoding = t3.defaultEncoding || "utf8", this.length = 0, this.writing = false, this.corked = 0, this.sync = true, this.bufferProcessing = false, this.onwrite = function(t4) { + !function(t5, e4) { + var r3 = t5._writableState, n2 = r3.sync, o2 = r3.writecb; + if (typeof o2 != "function") + throw new m(); + if (function(t6) { + t6.writing = false, t6.writecb = null, t6.length -= t6.writelen, t6.writelen = 0; + }(r3), e4) + !function(t6, e5, r4, n3, o3) { + --e5.pendingcb, r4 ? (i.nextTick(o3, n3), i.nextTick(R, t6, e5), t6._writableState.errorEmitted = true, M(t6, n3)) : (o3(n3), t6._writableState.errorEmitted = true, M(t6, n3), R(t6, e5)); + }(t5, r3, n2, e4, o2); + else { + var a3 = x(r3) || t5.destroyed; + a3 || r3.corked || r3.bufferProcessing || !r3.bufferedRequest || T(t5, r3), n2 ? i.nextTick(B, t5, r3, a3, o2) : B(t5, r3, a3, o2); + } + }(e3, t4); + }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = false, this.errorEmitted = false, this.emitClose = t3.emitClose !== false, this.autoDestroy = !!t3.autoDestroy, this.bufferedRequestCount = 0, this.corkedRequestsFree = new o(this); + } + function A(t3) { + var e3 = this instanceof (n = n || r2(6753)); + if (!e3 && !a.call(A, this)) + return new A(t3); + this._writableState = new E(t3, this, e3), this.writable = true, t3 && (typeof t3.write == "function" && (this._write = t3.write), typeof t3.writev == "function" && (this._writev = t3.writev), typeof t3.destroy == "function" && (this._destroy = t3.destroy), typeof t3.final == "function" && (this._final = t3.final)), u.call(this); + } + function k(t3, e3, r3, n2, i2, o2, a2) { + e3.writelen = n2, e3.writecb = a2, e3.writing = true, e3.sync = true, e3.destroyed ? e3.onwrite(new g("write")) : r3 ? t3._writev(i2, e3.onwrite) : t3._write(i2, o2, e3.onwrite), e3.sync = false; + } + function B(t3, e3, r3, n2) { + r3 || function(t4, e4) { + e4.length === 0 && e4.needDrain && (e4.needDrain = false, t4.emit("drain")); + }(t3, e3), e3.pendingcb--, n2(), R(t3, e3); + } + function T(t3, e3) { + e3.bufferProcessing = true; + var r3 = e3.bufferedRequest; + if (t3._writev && r3 && r3.next) { + var n2 = e3.bufferedRequestCount, i2 = new Array(n2), a2 = e3.corkedRequestsFree; + a2.entry = r3; + for (var s2 = 0, u2 = true; r3; ) + i2[s2] = r3, r3.isBuf || (u2 = false), r3 = r3.next, s2 += 1; + i2.allBuffers = u2, k(t3, e3, true, e3.length, i2, "", a2.finish), e3.pendingcb++, e3.lastBufferedRequest = null, a2.next ? (e3.corkedRequestsFree = a2.next, a2.next = null) : e3.corkedRequestsFree = new o(e3), e3.bufferedRequestCount = 0; + } else { + for (; r3; ) { + var f2 = r3.chunk, c2 = r3.encoding, h2 = r3.callback; + if (k(t3, e3, false, e3.objectMode ? 1 : f2.length, f2, c2, h2), r3 = r3.next, e3.bufferedRequestCount--, e3.writing) + break; + } + r3 === null && (e3.lastBufferedRequest = null); + } + e3.bufferedRequest = r3, e3.bufferProcessing = false; + } + function x(t3) { + return t3.ending && t3.length === 0 && t3.bufferedRequest === null && !t3.finished && !t3.writing; + } + function O(t3, e3) { + t3._final(function(r3) { + e3.pendingcb--, r3 && M(t3, r3), e3.prefinished = true, t3.emit("prefinish"), R(t3, e3); + }); + } + function R(t3, e3) { + var r3 = x(e3); + if (r3 && (function(t4, e4) { + e4.prefinished || e4.finalCalled || (typeof t4._final != "function" || e4.destroyed ? (e4.prefinished = true, t4.emit("prefinish")) : (e4.pendingcb++, e4.finalCalled = true, i.nextTick(O, t4, e4))); + }(t3, e3), e3.pendingcb === 0 && (e3.finished = true, t3.emit("finish"), e3.autoDestroy))) { + var n2 = t3._readableState; + (!n2 || n2.autoDestroy && n2.endEmitted) && t3.destroy(); + } + return r3; + } + r2(5717)(A, u), E.prototype.getBuffer = function() { + for (var t3 = this.bufferedRequest, e3 = []; t3; ) + e3.push(t3), t3 = t3.next; + return e3; + }, function() { + try { + Object.defineProperty(E.prototype, "buffer", {get: s.deprecate(function() { + return this.getBuffer(); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")}); + } catch (t3) { + } + }(), typeof Symbol == "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] == "function" ? (a = Function.prototype[Symbol.hasInstance], Object.defineProperty(A, Symbol.hasInstance, {value: function(t3) { + return !!a.call(this, t3) || this === A && t3 && t3._writableState instanceof E; + }})) : a = function(t3) { + return t3 instanceof this; + }, A.prototype.pipe = function() { + M(this, new b()); + }, A.prototype.write = function(t3, e3, r3) { + var n2, o2 = this._writableState, a2 = false, s2 = !o2.objectMode && (n2 = t3, f.isBuffer(n2) || n2 instanceof c); + return s2 && !f.isBuffer(t3) && (t3 = function(t4) { + return f.from(t4); + }(t3)), typeof e3 == "function" && (r3 = e3, e3 = null), s2 ? e3 = "buffer" : e3 || (e3 = o2.defaultEncoding), typeof r3 != "function" && (r3 = S), o2.ending ? function(t4, e4) { + var r4 = new w(); + M(t4, r4), i.nextTick(e4, r4); + }(this, r3) : (s2 || function(t4, e4, r4, n3) { + var o3; + return r4 === null ? o3 = new v() : typeof r4 == "string" || e4.objectMode || (o3 = new p("chunk", ["string", "Buffer"], r4)), !o3 || (M(t4, o3), i.nextTick(n3, o3), false); + }(this, o2, t3, r3)) && (o2.pendingcb++, a2 = function(t4, e4, r4, n3, i2, o3) { + if (!r4) { + var a3 = function(t5, e5, r5) { + return t5.objectMode || t5.decodeStrings === false || typeof e5 != "string" || (e5 = f.from(e5, r5)), e5; + }(e4, n3, i2); + n3 !== a3 && (r4 = true, i2 = "buffer", n3 = a3); + } + var s3 = e4.objectMode ? 1 : n3.length; + e4.length += s3; + var u2 = e4.length < e4.highWaterMark; + if (u2 || (e4.needDrain = true), e4.writing || e4.corked) { + var c2 = e4.lastBufferedRequest; + e4.lastBufferedRequest = {chunk: n3, encoding: i2, isBuf: r4, callback: o3, next: null}, c2 ? c2.next = e4.lastBufferedRequest : e4.bufferedRequest = e4.lastBufferedRequest, e4.bufferedRequestCount += 1; + } else + k(t4, e4, false, s3, n3, i2, o3); + return u2; + }(this, o2, s2, t3, e3, r3)), a2; + }, A.prototype.cork = function() { + this._writableState.corked++; + }, A.prototype.uncork = function() { + var t3 = this._writableState; + t3.corked && (t3.corked--, t3.writing || t3.corked || t3.bufferProcessing || !t3.bufferedRequest || T(this, t3)); + }, A.prototype.setDefaultEncoding = function(t3) { + if (typeof t3 == "string" && (t3 = t3.toLowerCase()), !(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((t3 + "").toLowerCase()) > -1)) + throw new _(t3); + return this._writableState.defaultEncoding = t3, this; + }, Object.defineProperty(A.prototype, "writableBuffer", {enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + }}), Object.defineProperty(A.prototype, "writableHighWaterMark", {enumerable: false, get: function() { + return this._writableState.highWaterMark; + }}), A.prototype._write = function(t3, e3, r3) { + r3(new y("_write()")); + }, A.prototype._writev = null, A.prototype.end = function(t3, e3, r3) { + var n2 = this._writableState; + return typeof t3 == "function" ? (r3 = t3, t3 = null, e3 = null) : typeof e3 == "function" && (r3 = e3, e3 = null), t3 != null && this.write(t3, e3), n2.corked && (n2.corked = 1, this.uncork()), n2.ending || function(t4, e4, r4) { + e4.ending = true, R(t4, e4), r4 && (e4.finished ? i.nextTick(r4) : t4.once("finish", r4)), e4.ended = true, t4.writable = false; + }(this, n2, r3), this; + }, Object.defineProperty(A.prototype, "writableLength", {enumerable: false, get: function() { + return this._writableState.length; + }}), Object.defineProperty(A.prototype, "destroyed", {enumerable: false, get: function() { + return this._writableState !== void 0 && this._writableState.destroyed; + }, set: function(t3) { + this._writableState && (this._writableState.destroyed = t3); + }}), A.prototype.destroy = h.destroy, A.prototype._undestroy = h.undestroy, A.prototype._destroy = function(t3, e3) { + e3(t3); + }; + }, 5850: (t2, e2, r2) => { + var n, i = r2(4155); + function o(t3, e3, r3) { + return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; + } + var a = r2(8610), s = Symbol("lastResolve"), u = Symbol("lastReject"), f = Symbol("error"), c = Symbol("ended"), h = Symbol("lastPromise"), l = Symbol("handlePromise"), d = Symbol("stream"); + function p(t3, e3) { + return {value: t3, done: e3}; + } + function y(t3) { + var e3 = t3[s]; + if (e3 !== null) { + var r3 = t3[d].read(); + r3 !== null && (t3[h] = null, t3[s] = null, t3[u] = null, e3(p(r3, false))); + } + } + function m(t3) { + i.nextTick(y, t3); + } + var b = Object.getPrototypeOf(function() { + }), g = Object.setPrototypeOf((o(n = {get stream() { + return this[d]; + }, next: function() { + var t3 = this, e3 = this[f]; + if (e3 !== null) + return Promise.reject(e3); + if (this[c]) + return Promise.resolve(p(void 0, true)); + if (this[d].destroyed) + return new Promise(function(e4, r4) { + i.nextTick(function() { + t3[f] ? r4(t3[f]) : e4(p(void 0, true)); + }); + }); + var r3, n2 = this[h]; + if (n2) + r3 = new Promise(function(t4, e4) { + return function(r4, n3) { + t4.then(function() { + e4[c] ? r4(p(void 0, true)) : e4[l](r4, n3); + }, n3); + }; + }(n2, this)); + else { + var o2 = this[d].read(); + if (o2 !== null) + return Promise.resolve(p(o2, false)); + r3 = new Promise(this[l]); + } + return this[h] = r3, r3; + }}, Symbol.asyncIterator, function() { + return this; + }), o(n, "return", function() { + var t3 = this; + return new Promise(function(e3, r3) { + t3[d].destroy(null, function(t4) { + t4 ? r3(t4) : e3(p(void 0, true)); + }); + }); + }), n), b); + t2.exports = function(t3) { + var e3, r3 = Object.create(g, (o(e3 = {}, d, {value: t3, writable: true}), o(e3, s, {value: null, writable: true}), o(e3, u, {value: null, writable: true}), o(e3, f, {value: null, writable: true}), o(e3, c, {value: t3._readableState.endEmitted, writable: true}), o(e3, l, {value: function(t4, e4) { + var n2 = r3[d].read(); + n2 ? (r3[h] = null, r3[s] = null, r3[u] = null, t4(p(n2, false))) : (r3[s] = t4, r3[u] = e4); + }, writable: true}), e3)); + return r3[h] = null, a(t3, function(t4) { + if (t4 && t4.code !== "ERR_STREAM_PREMATURE_CLOSE") { + var e4 = r3[u]; + return e4 !== null && (r3[h] = null, r3[s] = null, r3[u] = null, e4(t4)), void (r3[f] = t4); + } + var n2 = r3[s]; + n2 !== null && (r3[h] = null, r3[s] = null, r3[u] = null, n2(p(void 0, true))), r3[c] = true; + }), t3.on("readable", m.bind(null, r3)), r3; + }; + }, 7327: (t2, e2, r2) => { + function n(t3, e3) { + var r3 = Object.keys(t3); + if (Object.getOwnPropertySymbols) { + var n2 = Object.getOwnPropertySymbols(t3); + e3 && (n2 = n2.filter(function(e4) { + return Object.getOwnPropertyDescriptor(t3, e4).enumerable; + })), r3.push.apply(r3, n2); + } + return r3; + } + function i(t3, e3, r3) { + return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; + } + function o(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) { + var n2 = e3[r3]; + n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(t3, n2.key, n2); + } + } + var a = r2(8764).Buffer, s = r2(2361).inspect, u = s && s.custom || "inspect"; + t2.exports = function() { + function t3() { + !function(t4, e4) { + if (!(t4 instanceof e4)) + throw new TypeError("Cannot call a class as a function"); + }(this, t3), this.head = null, this.tail = null, this.length = 0; + } + var e3, r3; + return e3 = t3, (r3 = [{key: "push", value: function(t4) { + var e4 = {data: t4, next: null}; + this.length > 0 ? this.tail.next = e4 : this.head = e4, this.tail = e4, ++this.length; + }}, {key: "unshift", value: function(t4) { + var e4 = {data: t4, next: this.head}; + this.length === 0 && (this.tail = e4), this.head = e4, ++this.length; + }}, {key: "shift", value: function() { + if (this.length !== 0) { + var t4 = this.head.data; + return this.length === 1 ? this.head = this.tail = null : this.head = this.head.next, --this.length, t4; + } + }}, {key: "clear", value: function() { + this.head = this.tail = null, this.length = 0; + }}, {key: "join", value: function(t4) { + if (this.length === 0) + return ""; + for (var e4 = this.head, r4 = "" + e4.data; e4 = e4.next; ) + r4 += t4 + e4.data; + return r4; + }}, {key: "concat", value: function(t4) { + if (this.length === 0) + return a.alloc(0); + for (var e4, r4, n2, i2 = a.allocUnsafe(t4 >>> 0), o2 = this.head, s2 = 0; o2; ) + e4 = o2.data, r4 = i2, n2 = s2, a.prototype.copy.call(e4, r4, n2), s2 += o2.data.length, o2 = o2.next; + return i2; + }}, {key: "consume", value: function(t4, e4) { + var r4; + return t4 < this.head.data.length ? (r4 = this.head.data.slice(0, t4), this.head.data = this.head.data.slice(t4)) : r4 = t4 === this.head.data.length ? this.shift() : e4 ? this._getString(t4) : this._getBuffer(t4), r4; + }}, {key: "first", value: function() { + return this.head.data; + }}, {key: "_getString", value: function(t4) { + var e4 = this.head, r4 = 1, n2 = e4.data; + for (t4 -= n2.length; e4 = e4.next; ) { + var i2 = e4.data, o2 = t4 > i2.length ? i2.length : t4; + if (o2 === i2.length ? n2 += i2 : n2 += i2.slice(0, t4), (t4 -= o2) == 0) { + o2 === i2.length ? (++r4, e4.next ? this.head = e4.next : this.head = this.tail = null) : (this.head = e4, e4.data = i2.slice(o2)); + break; + } + ++r4; + } + return this.length -= r4, n2; + }}, {key: "_getBuffer", value: function(t4) { + var e4 = a.allocUnsafe(t4), r4 = this.head, n2 = 1; + for (r4.data.copy(e4), t4 -= r4.data.length; r4 = r4.next; ) { + var i2 = r4.data, o2 = t4 > i2.length ? i2.length : t4; + if (i2.copy(e4, e4.length - t4, 0, o2), (t4 -= o2) == 0) { + o2 === i2.length ? (++n2, r4.next ? this.head = r4.next : this.head = this.tail = null) : (this.head = r4, r4.data = i2.slice(o2)); + break; + } + ++n2; + } + return this.length -= n2, e4; + }}, {key: u, value: function(t4, e4) { + return s(this, function(t5) { + for (var e5 = 1; e5 < arguments.length; e5++) { + var r4 = arguments[e5] != null ? arguments[e5] : {}; + e5 % 2 ? n(Object(r4), true).forEach(function(e6) { + i(t5, e6, r4[e6]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t5, Object.getOwnPropertyDescriptors(r4)) : n(Object(r4)).forEach(function(e6) { + Object.defineProperty(t5, e6, Object.getOwnPropertyDescriptor(r4, e6)); + }); + } + return t5; + }({}, e4, {depth: 0, customInspect: false})); + }}]) && o(e3.prototype, r3), t3; + }(); + }, 1195: (t2, e2, r2) => { + var n = r2(4155); + function i(t3, e3) { + a(t3, e3), o(t3); + } + function o(t3) { + t3._writableState && !t3._writableState.emitClose || t3._readableState && !t3._readableState.emitClose || t3.emit("close"); + } + function a(t3, e3) { + t3.emit("error", e3); + } + t2.exports = {destroy: function(t3, e3) { + var r3 = this, s = this._readableState && this._readableState.destroyed, u = this._writableState && this._writableState.destroyed; + return s || u ? (e3 ? e3(t3) : t3 && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = true, n.nextTick(a, this, t3)) : n.nextTick(a, this, t3)), this) : (this._readableState && (this._readableState.destroyed = true), this._writableState && (this._writableState.destroyed = true), this._destroy(t3 || null, function(t4) { + !e3 && t4 ? r3._writableState ? r3._writableState.errorEmitted ? n.nextTick(o, r3) : (r3._writableState.errorEmitted = true, n.nextTick(i, r3, t4)) : n.nextTick(i, r3, t4) : e3 ? (n.nextTick(o, r3), e3(t4)) : n.nextTick(o, r3); + }), this); + }, undestroy: function() { + this._readableState && (this._readableState.destroyed = false, this._readableState.reading = false, this._readableState.ended = false, this._readableState.endEmitted = false), this._writableState && (this._writableState.destroyed = false, this._writableState.ended = false, this._writableState.ending = false, this._writableState.finalCalled = false, this._writableState.prefinished = false, this._writableState.finished = false, this._writableState.errorEmitted = false); + }, errorOrDestroy: function(t3, e3) { + var r3 = t3._readableState, n2 = t3._writableState; + r3 && r3.autoDestroy || n2 && n2.autoDestroy ? t3.destroy(e3) : t3.emit("error", e3); + }}; + }, 8610: (t2, e2, r2) => { + var n = r2(4281).q.ERR_STREAM_PREMATURE_CLOSE; + function i() { + } + t2.exports = function t3(e3, r3, o) { + if (typeof r3 == "function") + return t3(e3, null, r3); + r3 || (r3 = {}), o = function(t4) { + var e4 = false; + return function() { + if (!e4) { + e4 = true; + for (var r4 = arguments.length, n2 = new Array(r4), i2 = 0; i2 < r4; i2++) + n2[i2] = arguments[i2]; + t4.apply(this, n2); + } + }; + }(o || i); + var a = r3.readable || r3.readable !== false && e3.readable, s = r3.writable || r3.writable !== false && e3.writable, u = function() { + e3.writable || c(); + }, f = e3._writableState && e3._writableState.finished, c = function() { + s = false, f = true, a || o.call(e3); + }, h = e3._readableState && e3._readableState.endEmitted, l = function() { + a = false, h = true, s || o.call(e3); + }, d = function(t4) { + o.call(e3, t4); + }, p = function() { + var t4; + return a && !h ? (e3._readableState && e3._readableState.ended || (t4 = new n()), o.call(e3, t4)) : s && !f ? (e3._writableState && e3._writableState.ended || (t4 = new n()), o.call(e3, t4)) : void 0; + }, y = function() { + e3.req.on("finish", c); + }; + return function(t4) { + return t4.setHeader && typeof t4.abort == "function"; + }(e3) ? (e3.on("complete", c), e3.on("abort", p), e3.req ? y() : e3.on("request", y)) : s && !e3._writableState && (e3.on("end", u), e3.on("close", u)), e3.on("end", l), e3.on("finish", c), r3.error !== false && e3.on("error", d), e3.on("close", p), function() { + e3.removeListener("complete", c), e3.removeListener("abort", p), e3.removeListener("request", y), e3.req && e3.req.removeListener("finish", c), e3.removeListener("end", u), e3.removeListener("close", u), e3.removeListener("finish", c), e3.removeListener("end", l), e3.removeListener("error", d), e3.removeListener("close", p); + }; + }; + }, 5167: (t2) => { + t2.exports = function() { + throw new Error("Readable.from is not available in the browser"); + }; + }, 9946: (t2, e2, r2) => { + var n, i = r2(4281).q, o = i.ERR_MISSING_ARGS, a = i.ERR_STREAM_DESTROYED; + function s(t3) { + if (t3) + throw t3; + } + function u(t3, e3, i2, o2) { + o2 = function(t4) { + var e4 = false; + return function() { + e4 || (e4 = true, t4.apply(void 0, arguments)); + }; + }(o2); + var s2 = false; + t3.on("close", function() { + s2 = true; + }), n === void 0 && (n = r2(8610)), n(t3, {readable: e3, writable: i2}, function(t4) { + if (t4) + return o2(t4); + s2 = true, o2(); + }); + var u2 = false; + return function(e4) { + if (!s2 && !u2) + return u2 = true, function(t4) { + return t4.setHeader && typeof t4.abort == "function"; + }(t3) ? t3.abort() : typeof t3.destroy == "function" ? t3.destroy() : void o2(e4 || new a("pipe")); + }; + } + function f(t3) { + t3(); + } + function c(t3, e3) { + return t3.pipe(e3); + } + function h(t3) { + return t3.length ? typeof t3[t3.length - 1] != "function" ? s : t3.pop() : s; + } + t2.exports = function() { + for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) + e3[r3] = arguments[r3]; + var n2, i2 = h(e3); + if (Array.isArray(e3[0]) && (e3 = e3[0]), e3.length < 2) + throw new o("streams"); + var a2 = e3.map(function(t4, r4) { + var o2 = r4 < e3.length - 1; + return u(t4, o2, r4 > 0, function(t5) { + n2 || (n2 = t5), t5 && a2.forEach(f), o2 || (a2.forEach(f), i2(n2)); + }); + }); + return e3.reduce(c); + }; + }, 2457: (t2, e2, r2) => { + var n = r2(4281).q.ERR_INVALID_OPT_VALUE; + t2.exports = {getHighWaterMark: function(t3, e3, r3, i) { + var o = function(t4, e4, r4) { + return t4.highWaterMark != null ? t4.highWaterMark : e4 ? t4[r4] : null; + }(e3, i, r3); + if (o != null) { + if (!isFinite(o) || Math.floor(o) !== o || o < 0) + throw new n(i ? r3 : "highWaterMark", o); + return Math.floor(o); + } + return t3.objectMode ? 16 : 16384; + }}; + }, 2503: (t2, e2, r2) => { + t2.exports = r2(7187).EventEmitter; + }, 8473: (t2, e2, r2) => { + (e2 = t2.exports = r2(9481)).Stream = e2, e2.Readable = e2, e2.Writable = r2(4229), e2.Duplex = r2(6753), e2.Transform = r2(4605), e2.PassThrough = r2(2725), e2.finished = r2(8610), e2.pipeline = r2(9946); + }, 9785: (t2, e2, r2) => { + var n = r2(8764).Buffer, i = r2(5717), o = r2(3349), a = new Array(16), s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], u = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], f = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], c = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11], h = [0, 1518500249, 1859775393, 2400959708, 2840853838], l = [1352829926, 1548603684, 1836072691, 2053994217, 0]; + function d() { + o.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520; + } + function p(t3, e3) { + return t3 << e3 | t3 >>> 32 - e3; + } + function y(t3, e3, r3, n2, i2, o2, a2, s2) { + return p(t3 + (e3 ^ r3 ^ n2) + o2 + a2 | 0, s2) + i2 | 0; + } + function m(t3, e3, r3, n2, i2, o2, a2, s2) { + return p(t3 + (e3 & r3 | ~e3 & n2) + o2 + a2 | 0, s2) + i2 | 0; + } + function b(t3, e3, r3, n2, i2, o2, a2, s2) { + return p(t3 + ((e3 | ~r3) ^ n2) + o2 + a2 | 0, s2) + i2 | 0; + } + function g(t3, e3, r3, n2, i2, o2, a2, s2) { + return p(t3 + (e3 & n2 | r3 & ~n2) + o2 + a2 | 0, s2) + i2 | 0; + } + function v(t3, e3, r3, n2, i2, o2, a2, s2) { + return p(t3 + (e3 ^ (r3 | ~n2)) + o2 + a2 | 0, s2) + i2 | 0; + } + i(d, o), d.prototype._update = function() { + for (var t3 = a, e3 = 0; e3 < 16; ++e3) + t3[e3] = this._block.readInt32LE(4 * e3); + for (var r3 = 0 | this._a, n2 = 0 | this._b, i2 = 0 | this._c, o2 = 0 | this._d, d2 = 0 | this._e, w = 0 | this._a, _ = 0 | this._b, M = 0 | this._c, S = 0 | this._d, E = 0 | this._e, A = 0; A < 80; A += 1) { + var k, B; + A < 16 ? (k = y(r3, n2, i2, o2, d2, t3[s[A]], h[0], f[A]), B = v(w, _, M, S, E, t3[u[A]], l[0], c[A])) : A < 32 ? (k = m(r3, n2, i2, o2, d2, t3[s[A]], h[1], f[A]), B = g(w, _, M, S, E, t3[u[A]], l[1], c[A])) : A < 48 ? (k = b(r3, n2, i2, o2, d2, t3[s[A]], h[2], f[A]), B = b(w, _, M, S, E, t3[u[A]], l[2], c[A])) : A < 64 ? (k = g(r3, n2, i2, o2, d2, t3[s[A]], h[3], f[A]), B = m(w, _, M, S, E, t3[u[A]], l[3], c[A])) : (k = v(r3, n2, i2, o2, d2, t3[s[A]], h[4], f[A]), B = y(w, _, M, S, E, t3[u[A]], l[4], c[A])), r3 = d2, d2 = o2, o2 = p(i2, 10), i2 = n2, n2 = k, w = E, E = S, S = p(M, 10), M = _, _ = B; + } + var T = this._b + i2 + S | 0; + this._b = this._c + o2 + E | 0, this._c = this._d + d2 + w | 0, this._d = this._e + r3 + _ | 0, this._e = this._a + n2 + M | 0, this._a = T; + }, d.prototype._digest = function() { + this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); + var t3 = n.alloc ? n.alloc(20) : new n(20); + return t3.writeInt32LE(this._a, 0), t3.writeInt32LE(this._b, 4), t3.writeInt32LE(this._c, 8), t3.writeInt32LE(this._d, 12), t3.writeInt32LE(this._e, 16), t3; + }, t2.exports = d; + }, 9509: (t2, e2, r2) => { + var n = r2(8764), i = n.Buffer; + function o(t3, e3) { + for (var r3 in t3) + e3[r3] = t3[r3]; + } + function a(t3, e3, r3) { + return i(t3, e3, r3); + } + i.from && i.alloc && i.allocUnsafe && i.allocUnsafeSlow ? t2.exports = n : (o(n, e2), e2.Buffer = a), a.prototype = Object.create(i.prototype), o(i, a), a.from = function(t3, e3, r3) { + if (typeof t3 == "number") + throw new TypeError("Argument must not be a number"); + return i(t3, e3, r3); + }, a.alloc = function(t3, e3, r3) { + if (typeof t3 != "number") + throw new TypeError("Argument must be a number"); + var n2 = i(t3); + return e3 !== void 0 ? typeof r3 == "string" ? n2.fill(e3, r3) : n2.fill(e3) : n2.fill(0), n2; + }, a.allocUnsafe = function(t3) { + if (typeof t3 != "number") + throw new TypeError("Argument must be a number"); + return i(t3); + }, a.allocUnsafeSlow = function(t3) { + if (typeof t3 != "number") + throw new TypeError("Argument must be a number"); + return n.SlowBuffer(t3); + }; + }, 2399: (t2, e2, r2) => { + var n, i = r2(4155), o = r2(8764), a = o.Buffer, s = {}; + for (n in o) + o.hasOwnProperty(n) && n !== "SlowBuffer" && n !== "Buffer" && (s[n] = o[n]); + var u = s.Buffer = {}; + for (n in a) + a.hasOwnProperty(n) && n !== "allocUnsafe" && n !== "allocUnsafeSlow" && (u[n] = a[n]); + if (s.Buffer.prototype = a.prototype, u.from && u.from !== Uint8Array.from || (u.from = function(t3, e3, r3) { + if (typeof t3 == "number") + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof t3); + if (t3 && t3.length === void 0) + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); + return a(t3, e3, r3); + }), u.alloc || (u.alloc = function(t3, e3, r3) { + if (typeof t3 != "number") + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof t3); + if (t3 < 0 || t3 >= 2 * (1 << 30)) + throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); + var n2 = a(t3); + return e3 && e3.length !== 0 ? typeof r3 == "string" ? n2.fill(e3, r3) : n2.fill(e3) : n2.fill(0), n2; + }), !s.kStringMaxLength) + try { + s.kStringMaxLength = i.binding("buffer").kStringMaxLength; + } catch (t3) { + } + s.constants || (s.constants = {MAX_LENGTH: s.kMaxLength}, s.kStringMaxLength && (s.constants.MAX_STRING_LENGTH = s.kStringMaxLength)), t2.exports = s; + }, 7221: (t2, e2, r2) => { + t2.exports = r2(9119)(r2(8573)); + }, 8573: (t2, e2, r2) => { + const n = new (r2(6266)).ec("secp256k1"), i = n.curve, o = i.n.constructor; + function a(t3) { + const e3 = t3[0]; + switch (e3) { + case 2: + case 3: + return t3.length !== 33 ? null : function(t4, e4) { + let r3 = new o(e4); + if (r3.cmp(i.p) >= 0) + return null; + r3 = r3.toRed(i.red); + let a2 = r3.redSqr().redIMul(r3).redIAdd(i.b).redSqrt(); + return t4 === 3 !== a2.isOdd() && (a2 = a2.redNeg()), n.keyPair({pub: {x: r3, y: a2}}); + }(e3, t3.subarray(1, 33)); + case 4: + case 6: + case 7: + return t3.length !== 65 ? null : function(t4, e4, r3) { + let a2 = new o(e4), s2 = new o(r3); + if (a2.cmp(i.p) >= 0 || s2.cmp(i.p) >= 0) + return null; + if (a2 = a2.toRed(i.red), s2 = s2.toRed(i.red), (t4 === 6 || t4 === 7) && s2.isOdd() !== (t4 === 7)) + return null; + const u = a2.redSqr().redIMul(a2); + return s2.redSqr().redISub(u.redIAdd(i.b)).isZero() ? n.keyPair({pub: {x: a2, y: s2}}) : null; + }(e3, t3.subarray(1, 33), t3.subarray(33, 65)); + default: + return null; + } + } + function s(t3, e3) { + const r3 = e3.encode(null, t3.length === 33); + for (let e4 = 0; e4 < t3.length; ++e4) + t3[e4] = r3[e4]; + } + t2.exports = {contextRandomize: () => 0, privateKeyVerify(t3) { + const e3 = new o(t3); + return e3.cmp(i.n) < 0 && !e3.isZero() ? 0 : 1; + }, privateKeyNegate(t3) { + const e3 = new o(t3), r3 = i.n.sub(e3).umod(i.n).toArrayLike(Uint8Array, "be", 32); + return t3.set(r3), 0; + }, privateKeyTweakAdd(t3, e3) { + const r3 = new o(e3); + if (r3.cmp(i.n) >= 0) + return 1; + if (r3.iadd(new o(t3)), r3.cmp(i.n) >= 0 && r3.isub(i.n), r3.isZero()) + return 1; + const n2 = r3.toArrayLike(Uint8Array, "be", 32); + return t3.set(n2), 0; + }, privateKeyTweakMul(t3, e3) { + let r3 = new o(e3); + if (r3.cmp(i.n) >= 0 || r3.isZero()) + return 1; + r3.imul(new o(t3)), r3.cmp(i.n) >= 0 && (r3 = r3.umod(i.n)); + const n2 = r3.toArrayLike(Uint8Array, "be", 32); + return t3.set(n2), 0; + }, publicKeyVerify: (t3) => a(t3) === null ? 1 : 0, publicKeyCreate(t3, e3) { + const r3 = new o(e3); + return r3.cmp(i.n) >= 0 || r3.isZero() ? 1 : (s(t3, n.keyFromPrivate(e3).getPublic()), 0); + }, publicKeyConvert(t3, e3) { + const r3 = a(e3); + return r3 === null ? 1 : (s(t3, r3.getPublic()), 0); + }, publicKeyNegate(t3, e3) { + const r3 = a(e3); + if (r3 === null) + return 1; + const n2 = r3.getPublic(); + return n2.y = n2.y.redNeg(), s(t3, n2), 0; + }, publicKeyCombine(t3, e3) { + const r3 = new Array(e3.length); + for (let t4 = 0; t4 < e3.length; ++t4) + if (r3[t4] = a(e3[t4]), r3[t4] === null) + return 1; + let n2 = r3[0].getPublic(); + for (let t4 = 1; t4 < r3.length; ++t4) + n2 = n2.add(r3[t4].pub); + return n2.isInfinity() ? 2 : (s(t3, n2), 0); + }, publicKeyTweakAdd(t3, e3, r3) { + const n2 = a(e3); + if (n2 === null) + return 1; + if ((r3 = new o(r3)).cmp(i.n) >= 0) + return 2; + const u = n2.getPublic().add(i.g.mul(r3)); + return u.isInfinity() ? 2 : (s(t3, u), 0); + }, publicKeyTweakMul(t3, e3, r3) { + const n2 = a(e3); + return n2 === null ? 1 : (r3 = new o(r3)).cmp(i.n) >= 0 || r3.isZero() ? 2 : (s(t3, n2.getPublic().mul(r3)), 0); + }, signatureNormalize(t3) { + const e3 = new o(t3.subarray(0, 32)), r3 = new o(t3.subarray(32, 64)); + return e3.cmp(i.n) >= 0 || r3.cmp(i.n) >= 0 ? 1 : (r3.cmp(n.nh) === 1 && t3.set(i.n.sub(r3).toArrayLike(Uint8Array, "be", 32), 32), 0); + }, signatureExport(t3, e3) { + const r3 = e3.subarray(0, 32), n2 = e3.subarray(32, 64); + if (new o(r3).cmp(i.n) >= 0) + return 1; + if (new o(n2).cmp(i.n) >= 0) + return 1; + const {output: a2} = t3; + let s2 = a2.subarray(4, 37); + s2[0] = 0, s2.set(r3, 1); + let u = 33, f = 0; + for (; u > 1 && s2[f] === 0 && !(128 & s2[f + 1]); --u, ++f) + ; + if (s2 = s2.subarray(f), 128 & s2[0]) + return 1; + if (u > 1 && s2[0] === 0 && !(128 & s2[1])) + return 1; + let c = a2.subarray(39, 72); + c[0] = 0, c.set(n2, 1); + let h = 33, l = 0; + for (; h > 1 && c[l] === 0 && !(128 & c[l + 1]); --h, ++l) + ; + return c = c.subarray(l), 128 & c[0] || h > 1 && c[0] === 0 && !(128 & c[1]) ? 1 : (t3.outputlen = 6 + u + h, a2[0] = 48, a2[1] = t3.outputlen - 2, a2[2] = 2, a2[3] = s2.length, a2.set(s2, 4), a2[4 + u] = 2, a2[5 + u] = c.length, a2.set(c, 6 + u), 0); + }, signatureImport(t3, e3) { + if (e3.length < 8) + return 1; + if (e3.length > 72) + return 1; + if (e3[0] !== 48) + return 1; + if (e3[1] !== e3.length - 2) + return 1; + if (e3[2] !== 2) + return 1; + const r3 = e3[3]; + if (r3 === 0) + return 1; + if (5 + r3 >= e3.length) + return 1; + if (e3[4 + r3] !== 2) + return 1; + const n2 = e3[5 + r3]; + if (n2 === 0) + return 1; + if (6 + r3 + n2 !== e3.length) + return 1; + if (128 & e3[4]) + return 1; + if (r3 > 1 && e3[4] === 0 && !(128 & e3[5])) + return 1; + if (128 & e3[r3 + 6]) + return 1; + if (n2 > 1 && e3[r3 + 6] === 0 && !(128 & e3[r3 + 7])) + return 1; + let a2 = e3.subarray(4, 4 + r3); + if (a2.length === 33 && a2[0] === 0 && (a2 = a2.subarray(1)), a2.length > 32) + return 1; + let s2 = e3.subarray(6 + r3); + if (s2.length === 33 && s2[0] === 0 && (s2 = s2.slice(1)), s2.length > 32) + throw new Error("S length is too long"); + let u = new o(a2); + u.cmp(i.n) >= 0 && (u = new o(0)); + let f = new o(e3.subarray(6 + r3)); + return f.cmp(i.n) >= 0 && (f = new o(0)), t3.set(u.toArrayLike(Uint8Array, "be", 32), 0), t3.set(f.toArrayLike(Uint8Array, "be", 32), 32), 0; + }, ecdsaSign(t3, e3, r3, a2, s2) { + if (s2) { + const t4 = s2; + s2 = (n2) => { + const i2 = t4(e3, r3, null, a2, n2); + if (!(i2 instanceof Uint8Array && i2.length === 32)) + throw new Error("This is the way"); + return new o(i2); + }; + } + const u = new o(r3); + if (u.cmp(i.n) >= 0 || u.isZero()) + return 1; + let f; + try { + f = n.sign(e3, r3, {canonical: true, k: s2, pers: a2}); + } catch (t4) { + return 1; + } + return t3.signature.set(f.r.toArrayLike(Uint8Array, "be", 32), 0), t3.signature.set(f.s.toArrayLike(Uint8Array, "be", 32), 32), t3.recid = f.recoveryParam, 0; + }, ecdsaVerify(t3, e3, r3) { + const s2 = {r: t3.subarray(0, 32), s: t3.subarray(32, 64)}, u = new o(s2.r), f = new o(s2.s); + if (u.cmp(i.n) >= 0 || f.cmp(i.n) >= 0) + return 1; + if (f.cmp(n.nh) === 1 || u.isZero() || f.isZero()) + return 3; + const c = a(r3); + if (c === null) + return 2; + const h = c.getPublic(); + return n.verify(e3, s2, h) ? 0 : 3; + }, ecdsaRecover(t3, e3, r3, a2) { + const u = {r: e3.slice(0, 32), s: e3.slice(32, 64)}, f = new o(u.r), c = new o(u.s); + if (f.cmp(i.n) >= 0 || c.cmp(i.n) >= 0) + return 1; + if (f.isZero() || c.isZero()) + return 2; + let h; + try { + h = n.recoverPubKey(a2, u, r3); + } catch (t4) { + return 2; + } + return s(t3, h), 0; + }, ecdh(t3, e3, r3, s2, u, f, c) { + const h = a(e3); + if (h === null) + return 1; + const l = new o(r3); + if (l.cmp(i.n) >= 0 || l.isZero()) + return 2; + const d = h.getPublic().mul(l); + if (u === void 0) { + const e4 = d.encode(null, true), r4 = n.hash().update(e4).digest(); + for (let e5 = 0; e5 < 32; ++e5) + t3[e5] = r4[e5]; + } else { + f || (f = new Uint8Array(32)); + const e4 = d.getX().toArray("be", 32); + for (let t4 = 0; t4 < 32; ++t4) + f[t4] = e4[t4]; + c || (c = new Uint8Array(32)); + const r4 = d.getY().toArray("be", 32); + for (let t4 = 0; t4 < 32; ++t4) + c[t4] = r4[t4]; + const n2 = u(f, c, s2); + if (!(n2 instanceof Uint8Array && n2.length === t3.length)) + return 2; + t3.set(n2); + } + return 0; + }}; + }, 9119: (t2) => { + const e2 = "Impossible case. Please create issue.", r2 = "The tweak was out of range or the resulted private key is invalid", n = "The tweak was out of range or equal to zero", i = "Public Key could not be parsed", o = "Public Key serialization error", a = "Signature could not be parsed"; + function s(t3, e3) { + if (!t3) + throw new Error(e3); + } + function u(t3, e3, r3) { + if (s(e3 instanceof Uint8Array, `Expected ${t3} to be an Uint8Array`), r3 !== void 0) + if (Array.isArray(r3)) { + const n2 = `Expected ${t3} to be an Uint8Array with length [${r3.join(", ")}]`; + s(r3.includes(e3.length), n2); + } else { + const n2 = `Expected ${t3} to be an Uint8Array with length ${r3}`; + s(e3.length === r3, n2); + } + } + function f(t3) { + s(h(t3) === "Boolean", "Expected compressed to be a Boolean"); + } + function c(t3 = (t4) => new Uint8Array(t4), e3) { + return typeof t3 == "function" && (t3 = t3(e3)), u("output", t3, e3), t3; + } + function h(t3) { + return Object.prototype.toString.call(t3).slice(8, -1); + } + t2.exports = (t3) => ({contextRandomize(e3) { + switch (s(e3 === null || e3 instanceof Uint8Array, "Expected seed to be an Uint8Array or null"), e3 !== null && u("seed", e3, 32), t3.contextRandomize(e3)) { + case 1: + throw new Error("Unknow error on context randomization"); + } + }, privateKeyVerify: (e3) => (u("private key", e3, 32), t3.privateKeyVerify(e3) === 0), privateKeyNegate(r3) { + switch (u("private key", r3, 32), t3.privateKeyNegate(r3)) { + case 0: + return r3; + case 1: + throw new Error(e2); + } + }, privateKeyTweakAdd(e3, n2) { + switch (u("private key", e3, 32), u("tweak", n2, 32), t3.privateKeyTweakAdd(e3, n2)) { + case 0: + return e3; + case 1: + throw new Error(r2); + } + }, privateKeyTweakMul(e3, r3) { + switch (u("private key", e3, 32), u("tweak", r3, 32), t3.privateKeyTweakMul(e3, r3)) { + case 0: + return e3; + case 1: + throw new Error(n); + } + }, publicKeyVerify: (e3) => (u("public key", e3, [33, 65]), t3.publicKeyVerify(e3) === 0), publicKeyCreate(e3, r3 = true, n2) { + switch (u("private key", e3, 32), f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyCreate(n2, e3)) { + case 0: + return n2; + case 1: + throw new Error("Private Key is invalid"); + case 2: + throw new Error(o); + } + }, publicKeyConvert(e3, r3 = true, n2) { + switch (u("public key", e3, [33, 65]), f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyConvert(n2, e3)) { + case 0: + return n2; + case 1: + throw new Error(i); + case 2: + throw new Error(o); + } + }, publicKeyNegate(r3, n2 = true, a2) { + switch (u("public key", r3, [33, 65]), f(n2), a2 = c(a2, n2 ? 33 : 65), t3.publicKeyNegate(a2, r3)) { + case 0: + return a2; + case 1: + throw new Error(i); + case 2: + throw new Error(e2); + case 3: + throw new Error(o); + } + }, publicKeyCombine(e3, r3 = true, n2) { + s(Array.isArray(e3), "Expected public keys to be an Array"), s(e3.length > 0, "Expected public keys array will have more than zero items"); + for (const t4 of e3) + u("public key", t4, [33, 65]); + switch (f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyCombine(n2, e3)) { + case 0: + return n2; + case 1: + throw new Error(i); + case 2: + throw new Error("The sum of the public keys is not valid"); + case 3: + throw new Error(o); + } + }, publicKeyTweakAdd(e3, n2, o2 = true, a2) { + switch (u("public key", e3, [33, 65]), u("tweak", n2, 32), f(o2), a2 = c(a2, o2 ? 33 : 65), t3.publicKeyTweakAdd(a2, e3, n2)) { + case 0: + return a2; + case 1: + throw new Error(i); + case 2: + throw new Error(r2); + } + }, publicKeyTweakMul(e3, r3, o2 = true, a2) { + switch (u("public key", e3, [33, 65]), u("tweak", r3, 32), f(o2), a2 = c(a2, o2 ? 33 : 65), t3.publicKeyTweakMul(a2, e3, r3)) { + case 0: + return a2; + case 1: + throw new Error(i); + case 2: + throw new Error(n); + } + }, signatureNormalize(e3) { + switch (u("signature", e3, 64), t3.signatureNormalize(e3)) { + case 0: + return e3; + case 1: + throw new Error(a); + } + }, signatureExport(r3, n2) { + u("signature", r3, 64); + const i2 = {output: n2 = c(n2, 72), outputlen: 72}; + switch (t3.signatureExport(i2, r3)) { + case 0: + return n2.slice(0, i2.outputlen); + case 1: + throw new Error(a); + case 2: + throw new Error(e2); + } + }, signatureImport(r3, n2) { + switch (u("signature", r3), n2 = c(n2, 64), t3.signatureImport(n2, r3)) { + case 0: + return n2; + case 1: + throw new Error(a); + case 2: + throw new Error(e2); + } + }, ecdsaSign(r3, n2, i2 = {}, o2) { + u("message", r3, 32), u("private key", n2, 32), s(h(i2) === "Object", "Expected options to be an Object"), i2.data !== void 0 && u("options.data", i2.data), i2.noncefn !== void 0 && s(h(i2.noncefn) === "Function", "Expected options.noncefn to be a Function"); + const a2 = {signature: o2 = c(o2, 64), recid: null}; + switch (t3.ecdsaSign(a2, r3, n2, i2.data, i2.noncefn)) { + case 0: + return a2; + case 1: + throw new Error("The nonce generation function failed, or the private key was invalid"); + case 2: + throw new Error(e2); + } + }, ecdsaVerify(e3, r3, n2) { + switch (u("signature", e3, 64), u("message", r3, 32), u("public key", n2, [33, 65]), t3.ecdsaVerify(e3, r3, n2)) { + case 0: + return true; + case 3: + return false; + case 1: + throw new Error(a); + case 2: + throw new Error(i); + } + }, ecdsaRecover(r3, n2, i2, o2 = true, l) { + switch (u("signature", r3, 64), s(h(n2) === "Number" && n2 >= 0 && n2 <= 3, "Expected recovery id to be a Number within interval [0, 3]"), u("message", i2, 32), f(o2), l = c(l, o2 ? 33 : 65), t3.ecdsaRecover(l, r3, n2, i2)) { + case 0: + return l; + case 1: + throw new Error(a); + case 2: + throw new Error("Public key could not be recover"); + case 3: + throw new Error(e2); + } + }, ecdh(e3, r3, n2 = {}, o2) { + switch (u("public key", e3, [33, 65]), u("private key", r3, 32), s(h(n2) === "Object", "Expected options to be an Object"), n2.data !== void 0 && u("options.data", n2.data), n2.hashfn !== void 0 ? (s(h(n2.hashfn) === "Function", "Expected options.hashfn to be a Function"), n2.xbuf !== void 0 && u("options.xbuf", n2.xbuf, 32), n2.ybuf !== void 0 && u("options.ybuf", n2.ybuf, 32), u("output", o2)) : o2 = c(o2, 32), t3.ecdh(o2, e3, r3, n2.data, n2.hashfn, n2.xbuf, n2.ybuf)) { + case 0: + return o2; + case 1: + throw new Error(i); + case 2: + throw new Error("Scalar was invalid (zero or overflow)"); + } + }}); + }, 4189: (t2, e2, r2) => { + var n = r2(9509).Buffer; + function i(t3, e3) { + this._block = n.alloc(t3), this._finalSize = e3, this._blockSize = t3, this._len = 0; + } + i.prototype.update = function(t3, e3) { + typeof t3 == "string" && (e3 = e3 || "utf8", t3 = n.from(t3, e3)); + for (var r3 = this._block, i2 = this._blockSize, o = t3.length, a = this._len, s = 0; s < o; ) { + for (var u = a % i2, f = Math.min(o - s, i2 - u), c = 0; c < f; c++) + r3[u + c] = t3[s + c]; + s += f, (a += f) % i2 == 0 && this._update(r3); + } + return this._len += o, this; + }, i.prototype.digest = function(t3) { + var e3 = this._len % this._blockSize; + this._block[e3] = 128, this._block.fill(0, e3 + 1), e3 >= this._finalSize && (this._update(this._block), this._block.fill(0)); + var r3 = 8 * this._len; + if (r3 <= 4294967295) + this._block.writeUInt32BE(r3, this._blockSize - 4); + else { + var n2 = (4294967295 & r3) >>> 0, i2 = (r3 - n2) / 4294967296; + this._block.writeUInt32BE(i2, this._blockSize - 8), this._block.writeUInt32BE(n2, this._blockSize - 4); + } + this._update(this._block); + var o = this._hash(); + return t3 ? o.toString(t3) : o; + }, i.prototype._update = function() { + throw new Error("_update must be implemented by subclass"); + }, t2.exports = i; + }, 9072: (t2, e2, r2) => { + var n = t2.exports = function(t3) { + t3 = t3.toLowerCase(); + var e3 = n[t3]; + if (!e3) + throw new Error(t3 + " is not supported (we accept pull requests)"); + return new e3(); + }; + n.sha = r2(4448), n.sha1 = r2(8336), n.sha224 = r2(8432), n.sha256 = r2(7499), n.sha384 = r2(1686), n.sha512 = r2(7816); + }, 4448: (t2, e2, r2) => { + var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [1518500249, 1859775393, -1894007588, -899497514], s = new Array(80); + function u() { + this.init(), this._w = s, i.call(this, 64, 56); + } + function f(t3) { + return t3 << 30 | t3 >>> 2; + } + function c(t3, e3, r3, n2) { + return t3 === 0 ? e3 & r3 | ~e3 & n2 : t3 === 2 ? e3 & r3 | e3 & n2 | r3 & n2 : e3 ^ r3 ^ n2; + } + n(u, i), u.prototype.init = function() { + return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; + }, u.prototype._update = function(t3) { + for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, h = 0; h < 16; ++h) + r3[h] = t3.readInt32BE(4 * h); + for (; h < 80; ++h) + r3[h] = r3[h - 3] ^ r3[h - 8] ^ r3[h - 14] ^ r3[h - 16]; + for (var l = 0; l < 80; ++l) { + var d = ~~(l / 20), p = 0 | ((e3 = n2) << 5 | e3 >>> 27) + c(d, i2, o2, s2) + u2 + r3[l] + a[d]; + u2 = s2, s2 = o2, o2 = f(i2), i2 = n2, n2 = p; + } + this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0; + }, u.prototype._hash = function() { + var t3 = o.allocUnsafe(20); + return t3.writeInt32BE(0 | this._a, 0), t3.writeInt32BE(0 | this._b, 4), t3.writeInt32BE(0 | this._c, 8), t3.writeInt32BE(0 | this._d, 12), t3.writeInt32BE(0 | this._e, 16), t3; + }, t2.exports = u; + }, 8336: (t2, e2, r2) => { + var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [1518500249, 1859775393, -1894007588, -899497514], s = new Array(80); + function u() { + this.init(), this._w = s, i.call(this, 64, 56); + } + function f(t3) { + return t3 << 5 | t3 >>> 27; + } + function c(t3) { + return t3 << 30 | t3 >>> 2; + } + function h(t3, e3, r3, n2) { + return t3 === 0 ? e3 & r3 | ~e3 & n2 : t3 === 2 ? e3 & r3 | e3 & n2 | r3 & n2 : e3 ^ r3 ^ n2; + } + n(u, i), u.prototype.init = function() { + return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; + }, u.prototype._update = function(t3) { + for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, l = 0; l < 16; ++l) + r3[l] = t3.readInt32BE(4 * l); + for (; l < 80; ++l) + r3[l] = (e3 = r3[l - 3] ^ r3[l - 8] ^ r3[l - 14] ^ r3[l - 16]) << 1 | e3 >>> 31; + for (var d = 0; d < 80; ++d) { + var p = ~~(d / 20), y = f(n2) + h(p, i2, o2, s2) + u2 + r3[d] + a[p] | 0; + u2 = s2, s2 = o2, o2 = c(i2), i2 = n2, n2 = y; + } + this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0; + }, u.prototype._hash = function() { + var t3 = o.allocUnsafe(20); + return t3.writeInt32BE(0 | this._a, 0), t3.writeInt32BE(0 | this._b, 4), t3.writeInt32BE(0 | this._c, 8), t3.writeInt32BE(0 | this._d, 12), t3.writeInt32BE(0 | this._e, 16), t3; + }, t2.exports = u; + }, 8432: (t2, e2, r2) => { + var n = r2(5717), i = r2(7499), o = r2(4189), a = r2(9509).Buffer, s = new Array(64); + function u() { + this.init(), this._w = s, o.call(this, 64, 56); + } + n(u, i), u.prototype.init = function() { + return this._a = 3238371032, this._b = 914150663, this._c = 812702999, this._d = 4144912697, this._e = 4290775857, this._f = 1750603025, this._g = 1694076839, this._h = 3204075428, this; + }, u.prototype._hash = function() { + var t3 = a.allocUnsafe(28); + return t3.writeInt32BE(this._a, 0), t3.writeInt32BE(this._b, 4), t3.writeInt32BE(this._c, 8), t3.writeInt32BE(this._d, 12), t3.writeInt32BE(this._e, 16), t3.writeInt32BE(this._f, 20), t3.writeInt32BE(this._g, 24), t3; + }, t2.exports = u; + }, 7499: (t2, e2, r2) => { + var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [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], s = new Array(64); + function u() { + this.init(), this._w = s, i.call(this, 64, 56); + } + function f(t3, e3, r3) { + return r3 ^ t3 & (e3 ^ r3); + } + function c(t3, e3, r3) { + return t3 & e3 | r3 & (t3 | e3); + } + function h(t3) { + return (t3 >>> 2 | t3 << 30) ^ (t3 >>> 13 | t3 << 19) ^ (t3 >>> 22 | t3 << 10); + } + function l(t3) { + return (t3 >>> 6 | t3 << 26) ^ (t3 >>> 11 | t3 << 21) ^ (t3 >>> 25 | t3 << 7); + } + function d(t3) { + return (t3 >>> 7 | t3 << 25) ^ (t3 >>> 18 | t3 << 14) ^ t3 >>> 3; + } + n(u, i), u.prototype.init = function() { + return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, this._g = 528734635, this._h = 1541459225, this; + }, u.prototype._update = function(t3) { + for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, p = 0 | this._f, y = 0 | this._g, m = 0 | this._h, b = 0; b < 16; ++b) + r3[b] = t3.readInt32BE(4 * b); + for (; b < 64; ++b) + r3[b] = 0 | (((e3 = r3[b - 2]) >>> 17 | e3 << 15) ^ (e3 >>> 19 | e3 << 13) ^ e3 >>> 10) + r3[b - 7] + d(r3[b - 15]) + r3[b - 16]; + for (var g = 0; g < 64; ++g) { + var v = m + l(u2) + f(u2, p, y) + a[g] + r3[g] | 0, w = h(n2) + c(n2, i2, o2) | 0; + m = y, y = p, p = u2, u2 = s2 + v | 0, s2 = o2, o2 = i2, i2 = n2, n2 = v + w | 0; + } + this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0, this._f = p + this._f | 0, this._g = y + this._g | 0, this._h = m + this._h | 0; + }, u.prototype._hash = function() { + var t3 = o.allocUnsafe(32); + return t3.writeInt32BE(this._a, 0), t3.writeInt32BE(this._b, 4), t3.writeInt32BE(this._c, 8), t3.writeInt32BE(this._d, 12), t3.writeInt32BE(this._e, 16), t3.writeInt32BE(this._f, 20), t3.writeInt32BE(this._g, 24), t3.writeInt32BE(this._h, 28), t3; + }, t2.exports = u; + }, 1686: (t2, e2, r2) => { + var n = r2(5717), i = r2(7816), o = r2(4189), a = r2(9509).Buffer, s = new Array(160); + function u() { + this.init(), this._w = s, o.call(this, 128, 112); + } + n(u, i), u.prototype.init = function() { + return this._ah = 3418070365, this._bh = 1654270250, this._ch = 2438529370, this._dh = 355462360, this._eh = 1731405415, this._fh = 2394180231, this._gh = 3675008525, this._hh = 1203062813, this._al = 3238371032, this._bl = 914150663, this._cl = 812702999, this._dl = 4144912697, this._el = 4290775857, this._fl = 1750603025, this._gl = 1694076839, this._hl = 3204075428, this; + }, u.prototype._hash = function() { + var t3 = a.allocUnsafe(48); + function e3(e4, r3, n2) { + t3.writeInt32BE(e4, n2), t3.writeInt32BE(r3, n2 + 4); + } + return e3(this._ah, this._al, 0), e3(this._bh, this._bl, 8), e3(this._ch, this._cl, 16), e3(this._dh, this._dl, 24), e3(this._eh, this._el, 32), e3(this._fh, this._fl, 40), t3; + }, t2.exports = u; + }, 7816: (t2, e2, r2) => { + var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [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], s = new Array(160); + function u() { + this.init(), this._w = s, i.call(this, 128, 112); + } + function f(t3, e3, r3) { + return r3 ^ t3 & (e3 ^ r3); + } + function c(t3, e3, r3) { + return t3 & e3 | r3 & (t3 | e3); + } + function h(t3, e3) { + return (t3 >>> 28 | e3 << 4) ^ (e3 >>> 2 | t3 << 30) ^ (e3 >>> 7 | t3 << 25); + } + function l(t3, e3) { + return (t3 >>> 14 | e3 << 18) ^ (t3 >>> 18 | e3 << 14) ^ (e3 >>> 9 | t3 << 23); + } + function d(t3, e3) { + return (t3 >>> 1 | e3 << 31) ^ (t3 >>> 8 | e3 << 24) ^ t3 >>> 7; + } + function p(t3, e3) { + return (t3 >>> 1 | e3 << 31) ^ (t3 >>> 8 | e3 << 24) ^ (t3 >>> 7 | e3 << 25); + } + function y(t3, e3) { + return (t3 >>> 19 | e3 << 13) ^ (e3 >>> 29 | t3 << 3) ^ t3 >>> 6; + } + function m(t3, e3) { + return (t3 >>> 19 | e3 << 13) ^ (e3 >>> 29 | t3 << 3) ^ (t3 >>> 6 | e3 << 26); + } + function b(t3, e3) { + return t3 >>> 0 < e3 >>> 0 ? 1 : 0; + } + n(u, i), u.prototype.init = function() { + return this._ah = 1779033703, this._bh = 3144134277, this._ch = 1013904242, this._dh = 2773480762, this._eh = 1359893119, this._fh = 2600822924, this._gh = 528734635, this._hh = 1541459225, this._al = 4089235720, this._bl = 2227873595, this._cl = 4271175723, this._dl = 1595750129, this._el = 2917565137, this._fl = 725511199, this._gl = 4215389547, this._hl = 327033209, this; + }, u.prototype._update = function(t3) { + for (var e3 = this._w, r3 = 0 | this._ah, n2 = 0 | this._bh, i2 = 0 | this._ch, o2 = 0 | this._dh, s2 = 0 | this._eh, u2 = 0 | this._fh, g = 0 | this._gh, v = 0 | this._hh, w = 0 | this._al, _ = 0 | this._bl, M = 0 | this._cl, S = 0 | this._dl, E = 0 | this._el, A = 0 | this._fl, k = 0 | this._gl, B = 0 | this._hl, T = 0; T < 32; T += 2) + e3[T] = t3.readInt32BE(4 * T), e3[T + 1] = t3.readInt32BE(4 * T + 4); + for (; T < 160; T += 2) { + var x = e3[T - 30], O = e3[T - 30 + 1], R = d(x, O), P = p(O, x), I = y(x = e3[T - 4], O = e3[T - 4 + 1]), j = m(O, x), U = e3[T - 14], N = e3[T - 14 + 1], C = e3[T - 32], D = e3[T - 32 + 1], L = P + N | 0, K = R + U + b(L, P) | 0; + K = (K = K + I + b(L = L + j | 0, j) | 0) + C + b(L = L + D | 0, D) | 0, e3[T] = K, e3[T + 1] = L; + } + for (var z = 0; z < 160; z += 2) { + K = e3[z], L = e3[z + 1]; + var q = c(r3, n2, i2), H = c(w, _, M), F = h(r3, w), V = h(w, r3), W = l(s2, E), J = l(E, s2), $ = a[z], G = a[z + 1], Z = f(s2, u2, g), Y = f(E, A, k), X = B + J | 0, Q = v + W + b(X, B) | 0; + Q = (Q = (Q = Q + Z + b(X = X + Y | 0, Y) | 0) + $ + b(X = X + G | 0, G) | 0) + K + b(X = X + L | 0, L) | 0; + var tt = V + H | 0, et = F + q + b(tt, V) | 0; + v = g, B = k, g = u2, k = A, u2 = s2, A = E, s2 = o2 + Q + b(E = S + X | 0, S) | 0, o2 = i2, S = M, i2 = n2, M = _, n2 = r3, _ = w, r3 = Q + et + b(w = X + tt | 0, X) | 0; + } + this._al = this._al + w | 0, this._bl = this._bl + _ | 0, this._cl = this._cl + M | 0, this._dl = this._dl + S | 0, this._el = this._el + E | 0, this._fl = this._fl + A | 0, this._gl = this._gl + k | 0, this._hl = this._hl + B | 0, this._ah = this._ah + r3 + b(this._al, w) | 0, this._bh = this._bh + n2 + b(this._bl, _) | 0, this._ch = this._ch + i2 + b(this._cl, M) | 0, this._dh = this._dh + o2 + b(this._dl, S) | 0, this._eh = this._eh + s2 + b(this._el, E) | 0, this._fh = this._fh + u2 + b(this._fl, A) | 0, this._gh = this._gh + g + b(this._gl, k) | 0, this._hh = this._hh + v + b(this._hl, B) | 0; + }, u.prototype._hash = function() { + var t3 = o.allocUnsafe(64); + function e3(e4, r3, n2) { + t3.writeInt32BE(e4, n2), t3.writeInt32BE(r3, n2 + 4); + } + return e3(this._ah, this._al, 0), e3(this._bh, this._bl, 8), e3(this._ch, this._cl, 16), e3(this._dh, this._dl, 24), e3(this._eh, this._el, 32), e3(this._fh, this._fl, 40), e3(this._gh, this._gl, 48), e3(this._hh, this._hl, 56), t3; + }, t2.exports = u; + }, 2830: (t2, e2, r2) => { + t2.exports = i; + var n = r2(7187).EventEmitter; + function i() { + n.call(this); + } + r2(5717)(i, n), i.Readable = r2(9481), i.Writable = r2(4229), i.Duplex = r2(6753), i.Transform = r2(4605), i.PassThrough = r2(2725), i.finished = r2(8610), i.pipeline = r2(9946), i.Stream = i, i.prototype.pipe = function(t3, e3) { + var r3 = this; + function i2(e4) { + t3.writable && t3.write(e4) === false && r3.pause && r3.pause(); + } + function o() { + r3.readable && r3.resume && r3.resume(); + } + r3.on("data", i2), t3.on("drain", o), t3._isStdio || e3 && e3.end === false || (r3.on("end", s), r3.on("close", u)); + var a = false; + function s() { + a || (a = true, t3.end()); + } + function u() { + a || (a = true, typeof t3.destroy == "function" && t3.destroy()); + } + function f(t4) { + if (c(), n.listenerCount(this, "error") === 0) + throw t4; + } + function c() { + r3.removeListener("data", i2), t3.removeListener("drain", o), r3.removeListener("end", s), r3.removeListener("close", u), r3.removeListener("error", f), t3.removeListener("error", f), r3.removeListener("end", c), r3.removeListener("close", c), t3.removeListener("close", c); + } + return r3.on("error", f), t3.on("error", f), r3.on("end", c), r3.on("close", c), t3.on("close", c), t3.emit("pipe", r3), t3; + }; + }, 2553: (t2, e2, r2) => { + var n = r2(9509).Buffer, i = n.isEncoding || function(t3) { + switch ((t3 = "" + t3) && t3.toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + case "raw": + return true; + default: + return false; + } + }; + function o(t3) { + var e3; + switch (this.encoding = function(t4) { + var e4 = function(t5) { + if (!t5) + return "utf8"; + for (var e5; ; ) + switch (t5) { + case "utf8": + case "utf-8": + return "utf8"; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return "utf16le"; + case "latin1": + case "binary": + return "latin1"; + case "base64": + case "ascii": + case "hex": + return t5; + default: + if (e5) + return; + t5 = ("" + t5).toLowerCase(), e5 = true; + } + }(t4); + if (typeof e4 != "string" && (n.isEncoding === i || !i(t4))) + throw new Error("Unknown encoding: " + t4); + return e4 || t4; + }(t3), this.encoding) { + case "utf16le": + this.text = u, this.end = f, e3 = 4; + break; + case "utf8": + this.fillLast = s, e3 = 4; + break; + case "base64": + this.text = c, this.end = h, e3 = 3; + break; + default: + return this.write = l, void (this.end = d); + } + this.lastNeed = 0, this.lastTotal = 0, this.lastChar = n.allocUnsafe(e3); + } + function a(t3) { + return t3 <= 127 ? 0 : t3 >> 5 == 6 ? 2 : t3 >> 4 == 14 ? 3 : t3 >> 3 == 30 ? 4 : t3 >> 6 == 2 ? -1 : -2; + } + function s(t3) { + var e3 = this.lastTotal - this.lastNeed, r3 = function(t4, e4, r4) { + if ((192 & e4[0]) != 128) + return t4.lastNeed = 0, "\uFFFD"; + if (t4.lastNeed > 1 && e4.length > 1) { + if ((192 & e4[1]) != 128) + return t4.lastNeed = 1, "\uFFFD"; + if (t4.lastNeed > 2 && e4.length > 2 && (192 & e4[2]) != 128) + return t4.lastNeed = 2, "\uFFFD"; + } + }(this, t3); + return r3 !== void 0 ? r3 : this.lastNeed <= t3.length ? (t3.copy(this.lastChar, e3, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal)) : (t3.copy(this.lastChar, e3, 0, t3.length), void (this.lastNeed -= t3.length)); + } + function u(t3, e3) { + if ((t3.length - e3) % 2 == 0) { + var r3 = t3.toString("utf16le", e3); + if (r3) { + var n2 = r3.charCodeAt(r3.length - 1); + if (n2 >= 55296 && n2 <= 56319) + return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = t3[t3.length - 2], this.lastChar[1] = t3[t3.length - 1], r3.slice(0, -1); + } + return r3; + } + return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = t3[t3.length - 1], t3.toString("utf16le", e3, t3.length - 1); + } + function f(t3) { + var e3 = t3 && t3.length ? this.write(t3) : ""; + if (this.lastNeed) { + var r3 = this.lastTotal - this.lastNeed; + return e3 + this.lastChar.toString("utf16le", 0, r3); + } + return e3; + } + function c(t3, e3) { + var r3 = (t3.length - e3) % 3; + return r3 === 0 ? t3.toString("base64", e3) : (this.lastNeed = 3 - r3, this.lastTotal = 3, r3 === 1 ? this.lastChar[0] = t3[t3.length - 1] : (this.lastChar[0] = t3[t3.length - 2], this.lastChar[1] = t3[t3.length - 1]), t3.toString("base64", e3, t3.length - r3)); + } + function h(t3) { + var e3 = t3 && t3.length ? this.write(t3) : ""; + return this.lastNeed ? e3 + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : e3; + } + function l(t3) { + return t3.toString(this.encoding); + } + function d(t3) { + return t3 && t3.length ? this.write(t3) : ""; + } + e2.s = o, o.prototype.write = function(t3) { + if (t3.length === 0) + return ""; + var e3, r3; + if (this.lastNeed) { + if ((e3 = this.fillLast(t3)) === void 0) + return ""; + r3 = this.lastNeed, this.lastNeed = 0; + } else + r3 = 0; + return r3 < t3.length ? e3 ? e3 + this.text(t3, r3) : this.text(t3, r3) : e3 || ""; + }, o.prototype.end = function(t3) { + var e3 = t3 && t3.length ? this.write(t3) : ""; + return this.lastNeed ? e3 + "\uFFFD" : e3; + }, o.prototype.text = function(t3, e3) { + var r3 = function(t4, e4, r4) { + var n3 = e4.length - 1; + if (n3 < r4) + return 0; + var i2 = a(e4[n3]); + return i2 >= 0 ? (i2 > 0 && (t4.lastNeed = i2 - 1), i2) : --n3 < r4 || i2 === -2 ? 0 : (i2 = a(e4[n3])) >= 0 ? (i2 > 0 && (t4.lastNeed = i2 - 2), i2) : --n3 < r4 || i2 === -2 ? 0 : (i2 = a(e4[n3])) >= 0 ? (i2 > 0 && (i2 === 2 ? i2 = 0 : t4.lastNeed = i2 - 3), i2) : 0; + }(this, t3, e3); + if (!this.lastNeed) + return t3.toString("utf8", e3); + this.lastTotal = r3; + var n2 = t3.length - (r3 - this.lastNeed); + return t3.copy(this.lastChar, 0, n2), t3.toString("utf8", e3, n2); + }, o.prototype.fillLast = function(t3) { + if (this.lastNeed <= t3.length) + return t3.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal); + t3.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, t3.length), this.lastNeed -= t3.length; + }; + }, 3607: function(t2, e2, r2) { + var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { + return e3[r3]; + }}); + } : function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; + }), i = this && this.__exportStar || function(t3, e3) { + for (var r3 in t3) + r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), i(r2(1999), e2), i(r2(3915), e2); + var o = r2(1417); + Object.defineProperty(e2, "base64to16", {enumerable: true, get: function() { + return o.base64to16; + }}), Object.defineProperty(e2, "encodeBase16", {enumerable: true, get: function() { + return o.encodeBase16; + }}), Object.defineProperty(e2, "decodeBase16", {enumerable: true, get: function() { + return o.decodeBase16; + }}), Object.defineProperty(e2, "encodeBase64", {enumerable: true, get: function() { + return o.encodeBase64; + }}), Object.defineProperty(e2, "decodeBase64", {enumerable: true, get: function() { + return o.decodeBase64; + }}); + }, 5050: function(t2, e2, r2) { + var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), a = this && this.__decorate || function(t3, e3, r3, n2) { + var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") + a2 = Reflect.decorate(t3, e3, r3, n2); + else + for (var s2 = t3.length - 1; s2 >= 0; s2--) + (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); + return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; + }, s = this && this.__metadata || function(t3, e3) { + if (typeof Reflect == "object" && typeof Reflect.metadata == "function") + return Reflect.metadata(t3, e3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.URef = e2.AccessRights = e2.KeyValue = e2.AccountHash = e2.KeyVariant = e2.CLValue = e2.CLTypedAndToBytesHelper = e2.CLTypeHelper = e2.OptionType = e2.MapValue = e2.PublicKey = e2.Tuple3 = e2.Tuple2 = e2.Tuple1 = e2.List = e2.fromBytesByCLType = e2.StringValue = e2.Unit = e2.U512 = e2.U128 = e2.I64 = e2.U64 = e2.I32 = e2.U32 = e2.U8 = e2.Bool = e2.Result = e2.FromBytesError = e2.SimpleType = e2.staticImplements = e2.CLTypedAndToBytes = void 0; + var u, f, c, h = r2(3286), l = r2(3917), d = r2(2092), p = r2(1417), y = r2(5371), m = r2(3492), b = r2(2964), g = r2(4546), v = function() { + function t3() { + } + return t3.prototype.clTypeEncoded = function() { + return G.toBytesHelper(this.clType()); + }, t3; + }(); + e2.CLTypedAndToBytes = v, e2.staticImplements = function() { + return function(t3) { + }; + }, function(t3) { + t3[t3.Bool = 0] = "Bool", t3[t3.I32 = 1] = "I32", t3[t3.I64 = 2] = "I64", t3[t3.U8 = 3] = "U8", t3[t3.U32 = 4] = "U32", t3[t3.U64 = 5] = "U64", t3[t3.U128 = 6] = "U128", t3[t3.U256 = 7] = "U256", t3[t3.U512 = 8] = "U512", t3[t3.Unit = 9] = "Unit", t3[t3.String = 10] = "String", t3[t3.Key = 11] = "Key", t3[t3.URef = 12] = "URef", t3[t3.PublicKey = 22] = "PublicKey"; + }(u = e2.SimpleType || (e2.SimpleType = {})), function(t3) { + t3[t3.Option = 13] = "Option", t3[t3.List = 14] = "List", t3[t3.ByteArray = 15] = "ByteArray", t3[t3.Result = 16] = "Result", t3[t3.Map = 17] = "Map", t3[t3.Tuple1 = 18] = "Tuple1", t3[t3.Tuple2 = 19] = "Tuple2", t3[t3.Tuple3 = 20] = "Tuple3", t3[t3.Any = 21] = "Any"; + }(f || (f = {})), function(t3) { + t3[t3.Ok = 0] = "Ok", t3[t3.EarlyEndOfStream = 1] = "EarlyEndOfStream", t3[t3.FormattingError = 2] = "FormattingError"; + }(c = e2.FromBytesError || (e2.FromBytesError = {})); + var w = function() { + function t3(t4, e3, r3) { + this.val = t4, this.rem = e3, this.error = r3; + } + return t3.Err = function(e3) { + return new t3(null, null, e3); + }, t3.Ok = function(e3, r3) { + return new t3(e3, r3, c.Ok); + }, t3.prototype.remainder = function() { + if (this.rem === null) + throw new Error("Don't have remainder"); + return this.rem; + }, t3.prototype.value = function() { + if (!this.hasValue()) + throw new Error("Don't have value"); + return this.val; + }, t3.prototype.hasValue = function() { + return this.val !== null; + }, t3.prototype.hasError = function() { + return this.error !== c.Ok; + }, t3; + }(); + e2.Result = w; + var _ = function(t3) { + function e3(e4) { + var r4 = t3.call(this) || this; + return r4.val = e4, r4; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.toBytes = function() { + return new Uint8Array([this.val ? 1 : 0]); + }, e3.prototype.clType = function() { + return u.Bool; + }, e3.fromBytes = function(t4) { + return t4.length === 0 ? w.Err(c.EarlyEndOfStream) : t4[0] === 1 ? w.Ok(new r3(true), t4.subarray(1)) : t4[0] === 0 ? w.Ok(new r3(false), t4.subarray(1)) : w.Err(c.FormattingError); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Boolean])], e3); + }(v); + e2.Bool = _; + var M = function(t3) { + function e3(e4, r3, n2) { + var i2 = t3.call(this) || this; + return i2.toBytes = function() { + return l.toBytesNumber(i2.bitSize, i2.signed, i2.val); + }, i2.name = (r3 ? "i" : "u") + e4, i2.bitSize = e4, i2.signed = r3, i2.val = d.BigNumber.from(n2), i2; + } + return o(e3, t3), e3; + }(v), S = function(t3) { + function e3(e4) { + return t3.call(this, 8, false, e4) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.U8; + }, e3.fromBytes = function(t4) { + return t4.length === 0 ? w.Err(c.EarlyEndOfStream) : w.Ok(new r3(t4[0]), t4.subarray(1)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Number])], e3); + }(M); + e2.U8 = S; + var E = function(t3) { + function e3(e4) { + return t3.call(this, 32, false, e4) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.U32; + }, e3.fromBytes = function(t4) { + if (t4.length < 4) + return w.Err(c.EarlyEndOfStream); + var e4 = i.from(t4.subarray(0, 4)).readUInt32LE(0); + return w.Ok(new r3(e4), t4.subarray(4)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Number])], e3); + }(M); + e2.U32 = E; + var A = function(t3) { + function e3(e4) { + return t3.call(this, 32, true, e4) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.I32; + }, e3.fromBytes = function(t4) { + if (t4.length < 4) + return w.Err(c.EarlyEndOfStream); + var e4 = i.from(t4.subarray(0, 4)).readInt32LE(0); + return w.Ok(new r3(e4), t4.subarray(4)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Number])], e3); + }(M); + e2.I32 = A; + var k = function(t3) { + function e3(e4) { + return t3.call(this, 64, false, e4) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.U64; + }, e3.fromBytes = function(t4) { + var e4 = Uint8Array.from(t4); + if (t4.length < 8) + return w.Err(c.EarlyEndOfStream); + var n2 = e4.subarray(0, 8), i2 = e4.subarray(8); + return w.Ok(new r3(d.BigNumber.from(n2.reverse())), i2); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Object])], e3); + }(M); + e2.U64 = k; + var B = function(t3) { + function e3(e4) { + return t3.call(this, 64, true, e4) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.I64; + }, e3.fromBytes = function(t4) { + if (t4.length < 8) + return w.Err(c.EarlyEndOfStream); + var e4 = Uint8Array.from(t4), n2 = e4.subarray(0, 8), i2 = e4.subarray(8); + return w.Ok(new r3(d.BigNumber.from(n2.reverse()).fromTwos(64)), i2); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Object])], e3); + }(M); + e2.I64 = B; + var T = function(t3) { + function e3(e4) { + return t3.call(this, 128, false, e4) || this; + } + return o(e3, t3), e3.prototype.clType = function() { + return u.U128; + }, e3.fromBytes = function(t4) { + return z(t4, 128); + }, a([function(t4) { + }, s("design:paramtypes", [Object])], e3); + }(M); + e2.U128 = T; + var x = function(t3) { + function e3(e4) { + return t3.call(this, 256, false, e4) || this; + } + return o(e3, t3), e3.prototype.clType = function() { + return u.U256; + }, e3.fromBytes = function(t4) { + return z(t4, 256); + }, a([function(t4) { + }, s("design:paramtypes", [Object])], e3); + }(M), O = function(t3) { + function e3(e4) { + return t3.call(this, 512, false, e4) || this; + } + return o(e3, t3), e3.prototype.clType = function() { + return u.U512; + }, e3.fromBytes = function(t4) { + return z(t4, 512); + }, a([function(t4) { + }, s("design:paramtypes", [Object])], e3); + }(M); + e2.U512 = O; + var R = function(t3) { + function e3() { + return t3 !== null && t3.apply(this, arguments) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.Unit; + }, e3.prototype.toBytes = function() { + return Uint8Array.from([]); + }, e3.fromBytes = function(t4) { + return w.Ok(new r3(), t4); + }, r3 = a([function(t4) { + }], e3); + }(v); + e2.Unit = R; + var P = function(t3) { + function e3(e4) { + var r4 = t3.call(this) || this; + return r4.val = e4, r4.toBytes = function() { + return l.toBytesString(r4.val); + }, r4; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.String; + }, e3.fromBytes = function(t4) { + var e4 = E.fromBytes(t4); + if (e4.hasError()) + return w.Err(e4.error); + var n2 = e4.value().val.toNumber(), o2 = i.from(e4.remainder().subarray(0, n2)).toString("utf8"); + return w.Ok(new r3(o2), e4.remainder().subarray(n2)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [String])], e3); + }(v); + e2.StringValue = P, e2.fromBytesByCLType = function(t3, e3) { + return t3 instanceof H ? j.fromBytes(t3, e3) : t3 instanceof W ? U.fromBytes(t3, e3) : t3 instanceof J ? N.fromBytes(t3, e3) : t3 instanceof $ ? C.fromBytes(t3, e3) : t3 instanceof F ? K.fromBytes(e3) : t3 instanceof V ? L.fromBytes(t3, e3) : t3 instanceof q ? y.Option.fromBytes(t3, e3) : I(t3, e3); + }; + var I = function(t3, e3) { + var r3; + switch (t3) { + case u.Bool: + r3 = _.fromBytes(e3); + break; + case u.I32: + r3 = A.fromBytes(e3); + break; + case u.I64: + r3 = B.fromBytes(e3); + break; + case u.U8: + r3 = S.fromBytes(e3); + break; + case u.U32: + r3 = E.fromBytes(e3); + break; + case u.U64: + r3 = k.fromBytes(e3); + break; + case u.U128: + r3 = T.fromBytes(e3); + break; + case u.U256: + r3 = x.fromBytes(e3); + break; + case u.U512: + r3 = O.fromBytes(e3); + break; + case u.Unit: + r3 = R.fromBytes(e3); + break; + case u.String: + r3 = P.fromBytes(e3); + break; + case u.Key: + r3 = nt.fromBytes(e3); + break; + case u.URef: + r3 = at.fromBytes(e3); + break; + case u.PublicKey: + r3 = D.fromBytes(e3); + break; + default: + r3 = w.Err(c.FormattingError); + } + return r3.hasError() ? w.Err(r3.error) : w.Ok(r3.value(), r3.remainder()); + }, j = function(t3) { + function r3(e3) { + var r4 = t3.call(this) || this; + if (r4.vec = e3, e3.length === 0) + throw new Error("Can't create instance for empty list"); + return r4; + } + return o(r3, t3), r3.prototype.clType = function() { + return G.list(this.vec[0].clType()); + }, r3.prototype.toBytes = function() { + return l.toBytesVecT(this.vec); + }, r3.fromBytes = function(t4, n2) { + var i2 = E.fromBytes(n2); + if (i2.hasError()) + return w.Err(i2.error); + for (var o2 = i2.value().val.toNumber(), a2 = [], s2 = i2.remainder(), u2 = 0; u2 < o2; u2++) { + var f2 = e2.fromBytesByCLType(t4.innerType, s2); + if (f2.hasError()) + return w.Err(f2.error); + a2.push(f2.value()), s2 = f2.remainder(); + } + return w.Ok(new r3(a2), s2); + }, r3; + }(v); + e2.List = j; + var U = function(t3) { + function r3(e3) { + var r4 = t3.call(this) || this; + return r4.v0 = e3, r4; + } + return o(r3, t3), r3.prototype.toBytes = function() { + return this.v0.toBytes(); + }, r3.prototype.clType = function() { + return G.tuple1(this.v0.clType()); + }, r3.fromBytes = function(t4, n2) { + var i2 = e2.fromBytesByCLType(t4.t0, n2); + if (i2.hasError()) + return w.Err(i2.error); + var o2 = new r3(i2.value()); + return w.Ok(o2, i2.remainder()); + }, r3; + }(v); + e2.Tuple1 = U; + var N = function(t3) { + function r3(e3, r4) { + var n2 = t3.call(this) || this; + return n2.v0 = e3, n2.v1 = r4, n2; + } + return o(r3, t3), r3.prototype.toBytes = function() { + return h.concat([this.v0.toBytes(), this.v1.toBytes()]); + }, r3.prototype.clType = function() { + return G.tuple2(this.v0.clType(), this.v1.clType()); + }, r3.fromBytes = function(t4, n2) { + var i2 = e2.fromBytesByCLType(t4.t0, n2); + if (i2.hasError()) + return w.Err(i2.error); + var o2 = e2.fromBytesByCLType(t4.t1, i2.remainder()); + if (o2.hasError()) + return w.Err(o2.error); + var a2 = new r3(i2.value(), o2.value()); + return w.Ok(a2, o2.remainder()); + }, r3; + }(v); + e2.Tuple2 = N; + var C = function(t3) { + function r3(e3, r4, n2) { + var i2 = t3.call(this) || this; + return i2.v0 = e3, i2.v1 = r4, i2.v2 = n2, i2; + } + return o(r3, t3), r3.prototype.clType = function() { + return G.tuple3(this.v0.clType(), this.v1.clType(), this.v2.clType()); + }, r3.prototype.toBytes = function() { + return h.concat([this.v0.toBytes(), this.v1.toBytes(), this.v2.toBytes()]); + }, r3.fromBytes = function(t4, n2) { + var i2 = e2.fromBytesByCLType(t4.t0, n2); + if (i2.hasError()) + return w.Err(i2.error); + var o2 = e2.fromBytesByCLType(t4.t1, i2.remainder()); + if (o2.hasError()) + return w.Err(o2.error); + var a2 = e2.fromBytesByCLType(t4.t2, o2.remainder()); + if (a2.hasError()) + return w.Err(a2.error); + var s2 = new r3(i2.value(), o2.value(), a2.value()); + return w.Ok(s2, a2.remainder()); + }, r3; + }(v); + e2.Tuple3 = C; + var D = function(t3) { + function e3(e4, r4) { + var n2 = t3.call(this) || this; + return n2.rawPublicKey = e4, n2.tag = r4, n2; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return u.PublicKey; + }, e3.prototype.toBytes = function() { + return h.concat([Uint8Array.from([this.tag]), l.toBytesBytesArray(this.rawPublicKey)]); + }, e3.prototype.toAccountHex = function() { + var t4; + switch (this.tag) { + case 1: + t4 = "01" + p.encodeBase16(this.rawPublicKey); + break; + case 2: + t4 = "02" + p.encodeBase16(this.rawPublicKey); + break; + default: + throw new Error("Unsupported type of public key"); + } + return t4; + }, e3.prototype.isEd25519 = function() { + return this.tag === 1; + }, e3.prototype.isSecp256K1 = function() { + return this.tag === 2; + }, e3.prototype.toAccountHash = function() { + var t4 = this.signatureAlgorithm(), e4 = i.from([0]), r4 = i.concat([i.from(t4.toLowerCase()), e4]); + return this.rawPublicKey.length === 0 ? i.from([]) : m.byteHash(i.concat([r4, i.from(this.rawPublicKey)])); + }, e3.fromEd25519 = function(t4) { + return new r3(t4, 1); + }, e3.fromSecp256K1 = function(t4) { + return new r3(t4, 2); + }, e3.from = function(t4, e4) { + switch (e4) { + case b.SignatureAlgorithm.Ed25519: + return r3.fromEd25519(t4); + case b.SignatureAlgorithm.Secp256K1: + return r3.fromSecp256K1(t4); + default: + throw new Error("Unsupported type of public key"); + } + }, e3.fromHex = function(t4) { + if (t4.length < 2) + throw new Error("asymmetric key error: too short"); + var e4 = p.decodeBase16(t4); + switch (e4[0]) { + case 1: + return r3.fromEd25519(e4.subarray(1)); + case 2: + return r3.fromSecp256K1(e4.subarray(1)); + default: + throw new Error("Unsupported type of public key"); + } + }, e3.prototype.signatureAlgorithm = function() { + switch (this.tag) { + case 1: + return b.SignatureAlgorithm.Ed25519; + case 2: + return b.SignatureAlgorithm.Secp256K1; + default: + throw new Error("Unsupported type of public key"); + } + }, e3.fromBytes = function(t4) { + if (t4.length < 1) + return w.Err(c.EarlyEndOfStream); + var e4, n2 = t4[0], i2 = 1; + switch (n2) { + case 1: + e4 = 32; + break; + case 2: + e4 = 33; + break; + default: + return w.Err(c.FormattingError); + } + var o2 = t4.subarray(i2, i2 + e4); + i2 += e4; + var a2 = new r3(o2, n2); + return w.Ok(a2, t4.subarray(i2)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Uint8Array, Number])], e3); + }(v); + e2.PublicKey = D; + var L = function(t3) { + function r3(e3) { + var r4 = t3.call(this) || this; + return r4.v = e3, r4; + } + return o(r3, t3), r3.prototype.toBytes = function() { + var t4 = this.v.map(function(t5) { + return h.concat([t5.key.toBytes(), t5.value.toBytes()]); + }); + return t4.splice(0, 0, l.toBytesU32(this.v.length)), h.concat(t4); + }, r3.prototype.clType = function() { + return new V(this.v[0].key.clType(), this.v[0].value.clType()); + }, r3.fromBytes = function(t4, n2) { + var i2 = E.fromBytes(n2); + if (i2.hasError()) + return w.Err(i2.error); + for (var o2 = i2.value().val.toNumber(), a2 = [], s2 = i2.remainder(), u2 = 0; u2 < o2; u2++) { + var f2 = e2.fromBytesByCLType(t4.keyType, s2); + if (f2.hasError()) + return w.Err(f2.error); + s2 = f2.remainder(); + var c2 = e2.fromBytesByCLType(t4.valueType, s2); + if (c2.hasError()) + return w.Err(c2.error); + s2 = c2.remainder(), a2.push({key: f2.value(), value: c2.value()}); + } + return w.Ok(new r3(a2), s2); + }, r3; + }(v); + e2.MapValue = L; + var K = function(t3) { + function e3(e4) { + var r4 = t3.call(this) || this; + return r4.rawBytes = e4, r4; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.clType = function() { + return G.byteArray(this.rawBytes.length); + }, e3.prototype.toBytes = function() { + return l.toBytesBytesArray(this.rawBytes); + }, e3.fromBytes = function(t4) { + var e4 = new r3(t4.subarray(0, 32)); + return w.Ok(e4, t4.subarray(32)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Uint8Array])], e3); + }(v), z = function(t3, e3) { + var r3 = e3 / 8; + if (t3.length < 1) + return w.Err(c.EarlyEndOfStream); + var n2, i2 = Uint8Array.from(t3), o2 = i2[0]; + if (o2 > r3) + return w.Err(c.FormattingError); + if (o2 + 1 > t3.length) + return w.Err(c.EarlyEndOfStream); + n2 = o2 === 0 ? [0] : i2.subarray(1, 1 + o2); + var a2 = i2.subarray(1 + o2); + return e3 === 128 ? w.Ok(new T(d.BigNumber.from(n2.reverse())), a2) : e3 === 256 ? w.Ok(new x(d.BigNumber.from(n2.reverse())), a2) : e3 === 512 ? w.Ok(new O(d.BigNumber.from(n2.reverse())), a2) : w.Err(c.FormattingError); + }, q = function() { + function t3(t4) { + this.innerType = t4, this.tag = f.Option; + } + return t3.prototype.toJSON = function() { + var e3, r3 = Y(this.innerType); + return (e3 = {})[t3.TypeId] = r3, e3; + }, t3.TypeId = "Option", t3; + }(); + e2.OptionType = q; + var H = function() { + function t3(t4) { + this.tag = f.List, this.innerType = t4; + } + return t3.prototype.toJSON = function() { + var e3, r3 = Y(this.innerType); + return (e3 = {})[t3.TypeId] = r3, e3; + }, t3.TypeId = "List", t3; + }(), F = function() { + function t3(t4) { + this.size = t4, this.tag = f.ByteArray; + } + return t3.prototype.toJSON = function() { + var e3; + return (e3 = {})[t3.TypeId] = this.size, e3; + }, t3.TypeId = "ByteArray", t3; + }(), V = function() { + function t3(t4, e3) { + this.keyType = t4, this.valueType = e3, this.tag = f.Map; + } + return t3.prototype.toJSON = function() { + var e3; + return (e3 = {})[t3.TypeId] = {key: Y(this.keyType), value: Y(this.valueType)}, e3; + }, t3.TypeId = "Map", t3; + }(), W = function() { + function t3(t4) { + this.t0 = t4, this.tag = f.Tuple1; + } + return t3.prototype.toJSON = function() { + var e3, r3 = Y(this.t0); + return (e3 = {})[t3.TypeId] = r3, e3; + }, t3.TypeId = "Tuple1", t3; + }(), J = function() { + function t3(t4, e3) { + this.t0 = t4, this.t1 = e3, this.tag = f.Tuple2; + } + return t3.prototype.toJSON = function() { + var e3, r3 = Y(this.t0), n2 = Y(this.t1); + return (e3 = {})[t3.TypeId] = [r3, n2], e3; + }, t3.TypeId = "Tuple2", t3; + }(), $ = function() { + function t3(t4, e3, r3) { + this.t0 = t4, this.t1 = e3, this.t2 = r3, this.tag = f.Tuple3; + } + return t3.prototype.toJSON = function() { + var e3, r3 = Y(this.t0), n2 = Y(this.t1), i2 = Y(this.t2); + return (e3 = {})[t3.TypeId] = [r3, n2, i2], e3; + }, t3.TypeId = "Tuple3", t3; + }(), G = function() { + function t3() { + } + return t3.u8 = function() { + return u.U8; + }, t3.u32 = function() { + return u.U32; + }, t3.u64 = function() { + return u.U64; + }, t3.u128 = function() { + return u.U128; + }, t3.u256 = function() { + return u.U256; + }, t3.u512 = function() { + return u.U512; + }, t3.i32 = function() { + return u.I32; + }, t3.i64 = function() { + return u.I64; + }, t3.bool = function() { + return u.Bool; + }, t3.unit = function() { + return u.Unit; + }, t3.string = function() { + return u.String; + }, t3.key = function() { + return u.Key; + }, t3.publicKey = function() { + return u.PublicKey; + }, t3.uRef = function() { + return u.URef; + }, t3.option = function(t4) { + return new q(t4); + }, t3.list = function(t4) { + return new H(t4); + }, t3.byteArray = function(t4) { + return new F(t4); + }, t3.map = function(t4, e3) { + return new V(t4, e3); + }, t3.tuple1 = function(t4) { + return new W(t4); + }, t3.tuple2 = function(t4, e3) { + return new J(t4, e3); + }, t3.tuple3 = function(t4, e3, r3) { + return new $(t4, e3, r3); + }, t3.fromBytes = function(e3) { + if (e3.length < 1) + return w.Err(c.EarlyEndOfStream); + var r3 = e3[0], n2 = e3.subarray(1); + switch (r3) { + case u.Bool: + case u.I32: + case u.I64: + case u.U8: + case u.U32: + case u.U64: + case u.U256: + case u.U512: + case u.Unit: + case u.String: + case u.Key: + case u.URef: + case u.PublicKey: + return w.Ok(r3, n2); + case f.Option: + return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.option(s2.value()), s2.remainder()); + case f.List: + return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.list(s2.value()), s2.remainder()); + case f.ByteArray: + var i2 = E.fromBytes(n2); + return i2.hasError() ? w.Err(i2.error) : w.Ok(t3.byteArray(i2.value().val.toNumber()), i2.remainder()); + case f.Result: + throw new Error("Result type is unsupported now"); + case f.Map: + var o2 = t3.fromBytes(n2); + if (o2.hasError()) + return w.Err(o2.error); + var a2 = t3.fromBytes(o2.remainder()); + return a2.hasError() ? w.Err(a2.error) : w.Ok(t3.map(o2.value(), a2.value()), a2.remainder()); + case f.Tuple1: + var s2; + return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.tuple1(s2.value()), s2.remainder()); + case f.Tuple2: + return (h2 = t3.fromBytes(n2)).hasError() ? w.Err(h2.error) : (l2 = t3.fromBytes(h2.remainder())).hasError() ? w.Err(l2.error) : w.Ok(t3.tuple2(h2.value(), l2.value()), l2.remainder()); + case f.Tuple3: + var h2, l2; + if ((h2 = t3.fromBytes(n2)).hasError()) + return w.Err(h2.error); + if ((l2 = t3.fromBytes(h2.remainder())).hasError()) + return w.Err(l2.error); + var d2 = t3.fromBytes(h2.remainder()); + return d2.hasError() ? w.Err(d2.error) : w.Ok(t3.tuple3(h2.value(), l2.value(), d2.value()), d2.remainder()); + case f.Any: + throw new Error("Any type is unsupported now"); + default: + return w.Err(c.FormattingError); + } + }, t3.toBytesHelper = function(e3) { + if (e3 instanceof H) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.innerType)]); + if (e3 instanceof W) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0)]); + if (e3 instanceof J) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0), t3.toBytesHelper(e3.t1)]); + if (e3 instanceof $) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0), t3.toBytesHelper(e3.t1), t3.toBytesHelper(e3.t2)]); + if (e3 instanceof F) + return h.concat([Uint8Array.from([e3.tag]), l.toBytesU32(e3.size)]); + if (e3 instanceof V) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.keyType), t3.toBytesHelper(e3.valueType)]); + if (e3 instanceof q) + return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.innerType)]); + switch (e3) { + case u.Bool: + case u.I32: + case u.I64: + case u.U8: + case u.U32: + case u.U64: + case u.U128: + case u.U256: + case u.U512: + case u.Unit: + case u.String: + case u.Key: + case u.URef: + case u.PublicKey: + return Uint8Array.from([e3]); + default: + throw new Error("Wrong type"); + } + }, t3; + }(); + e2.CLTypeHelper = G; + var Z = function() { + function t3() { + } + return t3.list = function(t4) { + return new j(t4); + }, t3.tuple1 = function(t4) { + return new U(t4); + }, t3.tuple2 = function(t4, e3) { + return new N(t4, e3); + }, t3.tuple3 = function(t4, e3, r3) { + return new C(t4, e3, r3); + }, t3.option = function(t4, e3) { + return new y.Option(t4, e3); + }, t3.map = function(t4) { + return new L(t4); + }, t3.publicKey = function(t4) { + return D.fromEd25519(t4); + }, t3.bytes = function(t4) { + return new K(t4); + }, t3.bool = function(t4) { + return new _(t4); + }, t3.u8 = function(t4) { + return new S(t4); + }, t3.u32 = function(t4) { + return new E(t4); + }, t3.i32 = function(t4) { + return new A(t4); + }, t3.u64 = function(t4) { + return new k(t4); + }, t3.i64 = function(t4) { + return new B(t4); + }, t3.u128 = function(t4) { + return new T(t4); + }, t3.u256 = function(t4) { + return new x(t4); + }, t3.u512 = function(t4) { + return new O(t4); + }, t3.unit = function() { + return new R(); + }, t3.string = function(t4) { + return new P(t4); + }, t3; + }(); + e2.CLTypedAndToBytesHelper = Z; + var Y = function(t3) { + return t3 instanceof H || t3 instanceof W || t3 instanceof J || t3 instanceof $ || t3 instanceof F || t3 instanceof V || t3 instanceof q ? t3.toJSON() : function(t4) { + switch (t4) { + case u.Bool: + return "Bool"; + case u.I32: + return "I32"; + case u.I64: + return "I64"; + case u.U8: + return "U8"; + case u.U32: + return "U32"; + case u.U64: + return "U64"; + case u.U128: + return "U128"; + case u.U256: + return "U256"; + case u.U512: + return "U512"; + case u.Unit: + return "Unit"; + case u.String: + return "String"; + case u.Key: + return "Key"; + case u.URef: + return "URef"; + case u.PublicKey: + return "PublicKey"; + } + }(t3); + }, X = function(t3) { + if (typeof t3 == "string") + return function(t4) { + switch (t4) { + case "Bool": + return u.Bool; + case "I32": + return u.I32; + case "I64": + return u.I64; + case "U8": + return u.U8; + case "U32": + return u.U32; + case "U64": + return u.U64; + case "U128": + return u.U128; + case "U256": + return u.U256; + case "U512": + return u.U512; + case "Unit": + return u.Unit; + case "String": + return u.String; + case "Key": + return u.Key; + case "URef": + return u.URef; + case "PublicKey": + return u.PublicKey; + default: + throw new Error("The type " + t4 + " is not supported"); + } + }(t3); + if (typeof t3 == typeof {}) { + if (H.TypeId in t3) { + var e3 = X(t3[H.TypeId]); + return G.list(e3); + } + if (W.TypeId in t3) { + var r3 = X(t3[W.TypeId][0]); + return G.tuple1(r3); + } + if (J.TypeId in t3) { + var n2 = t3[J.TypeId], i2 = (r3 = X(n2[0]), X(n2[1])); + return G.tuple2(r3, i2); + } + if ($.TypeId in t3) { + n2 = t3[J.TypeId], r3 = X(n2[0]), i2 = X(n2[1]); + var o2 = X(n2[2]); + return G.tuple3(r3, i2, o2); + } + if (F.TypeId in t3) { + var a2 = t3[F.TypeId]; + return G.byteArray(a2); + } + if (q.TypeId in t3) + return e3 = X(t3[q.TypeId]), G.option(e3); + if (V.TypeId in t3) { + var s2 = X(t3[V.TypeId].key), f2 = X(t3[V.TypeId].value); + return G.map(s2, f2); + } + throw new Error("The type " + t3 + " is not supported"); + } + throw new Error("The type " + t3 + " is not supported"); + }; + function Q(t3, r3) { + var n2 = e2.fromBytesByCLType(t3.clType, p.decodeBase16(t3.bytes)); + return et.fromT(n2.value()); + } + var tt, et = function() { + function t3(t4, e3) { + this.value = t4, this.clType = e3, this.bytes = p.encodeBase16(this.value.toBytes()); + } + var r3; + return r3 = t3, t3.prototype.clValueBytes = function() { + return this.value.toBytes(); + }, t3.fromT = function(t4) { + return new r3(t4, t4.clType()); + }, t3.prototype.toBytes = function() { + return h.concat([l.toBytesArrayU8(this.clValueBytes()), G.toBytesHelper(this.clType)]); + }, t3.fromBytes = function(t4) { + var n2 = K.fromBytes(t4); + if (n2.hasError()) + return w.Err(n2.error); + var i2 = G.fromBytes(n2.remainder()); + if (i2.hasError()) + return w.Err(i2.error); + var o2 = e2.fromBytesByCLType(i2.value(), n2.value().rawBytes), a2 = new r3(o2.value(), i2.value()); + return w.Ok(a2, i2.remainder()); + }, t3.prototype.reconstruct = function() { + var t4 = e2.fromBytesByCLType(this.clType, p.decodeBase16(this.bytes)); + if (t4.hasError()) + throw new Error("Failed to deserialize CLValue"); + this.value = t4.value(); + }, t3.list = function(t4) { + return r3.fromT(new j(t4)); + }, t3.tuple1 = function(t4) { + return r3.fromT(new U(t4)); + }, t3.tuple2 = function(t4, e3) { + return r3.fromT(new N(t4, e3)); + }, t3.tuple3 = function(t4, e3, n2) { + return r3.fromT(new C(t4, e3, n2)); + }, t3.option = function(t4, e3) { + return r3.fromT(new y.Option(t4, e3)); + }, t3.map = function(t4) { + return r3.fromT(new L(t4)); + }, t3.publicKey = function(t4) { + return r3.fromT(t4); + }, t3.byteArray = function(t4) { + return r3.fromT(new K(t4)); + }, t3.prototype.isBigNumber = function() { + return this.clType === u.U8 || this.clType === u.I32 || this.clType === u.I64 || this.clType === u.U32 || this.clType === u.U64 || this.clType === u.U128 || this.clType === u.U256 || this.clType === u.U512; + }, t3.prototype.asBigNumber = function() { + if (this.isBigNumber()) { + var t4 = this.value; + return d.BigNumber.from(t4.val); + } + throw new Error("The CLValue is not an instance of BigNumber"); + }, t3.prototype.isBoolean = function() { + return this.clType === u.Bool; + }, t3.prototype.asBoolean = function() { + if (!this.isBoolean()) + throw new Error("The CLValue is not an instance of Boolean"); + return this.value.val; + }, t3.prototype.isString = function() { + return this.clType === u.String; + }, t3.prototype.asString = function() { + if (!this.isString()) + throw new Error("The CLValue is not an instance of String"); + return this.value.val; + }, t3.prototype.isPublicKey = function() { + return this.clType === u.PublicKey; + }, t3.prototype.asPublicKey = function() { + if (!this.isPublicKey()) + throw new Error("The CLValue is not an instance of PublicKey"); + return this.value; + }, t3.prototype.isKey = function() { + return this.clType === u.Key; + }, t3.prototype.asKey = function() { + if (!this.isKey()) + throw new Error("The CLValue is not an instance of Key"); + return this.value; + }, t3.prototype.isURef = function() { + return this.clType === u.URef; + }, t3.prototype.asURef = function() { + if (!this.isURef()) + throw new Error("The CLValue is not an instance of URef"); + return this.value; + }, t3.prototype.isBytesArray = function() { + return this.clType instanceof F; + }, t3.prototype.asBytesArray = function() { + if (!this.isBytesArray()) + throw new Error("The CLValue is not an instance of BytesArray"); + return this.value.toBytes(); + }, t3.prototype.isOption = function() { + return this.clType instanceof q; + }, t3.prototype.asOption = function() { + if (!this.isOption()) + throw new Error("The CLValue is not an instance of Option"); + return this.value; + }, t3.prototype.isList = function() { + return this.clType instanceof H; + }, t3.prototype.asList = function() { + if (!this.isList()) + throw new Error("The CLValue is not an instance of List"); + var t4 = this.clType, e3 = j.fromBytes(t4, this.clValueBytes()); + if (e3.hasError()) + throw new Error("The CLValue can not be parsed to list."); + return e3.value().vec.map(function(t5) { + return r3.fromT(t5); + }); + }, t3.bool = function(t4) { + return r3.fromT(new _(t4)); + }, t3.u8 = function(t4) { + return r3.fromT(new S(t4)); + }, t3.u32 = function(t4) { + return r3.fromT(new E(t4)); + }, t3.i32 = function(t4) { + return r3.fromT(new A(t4)); + }, t3.u64 = function(t4) { + return r3.fromT(new k(t4)); + }, t3.i64 = function(t4) { + return r3.fromT(new B(t4)); + }, t3.u128 = function(t4) { + return r3.fromT(new T(t4)); + }, t3.u256 = function(t4) { + return r3.fromT(new x(t4)); + }, t3.u512 = function(t4) { + return r3.fromT(new O(t4)); + }, t3.unit = function() { + return r3.fromT(new R()); + }, t3.string = function(t4) { + return r3.fromT(new P(t4)); + }, t3.key = function(t4) { + return r3.fromT(t4); + }, t3.uref = function(t4) { + return r3.fromT(t4); + }, t3.stringList = function(t4) { + var e3 = Z.list(t4.map(function(t5) { + return Z.string(t5); + })); + return new r3(e3, G.list(u.String)); + }, a([g.jsonMember({name: "cl_type", serializer: Y, deserializer: X}), s("design:type", Object)], t3.prototype, "clType", void 0), a([g.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "bytes", void 0), a([g.jsonMember({serializer: function(t4) { + return "null"; + }, deserializer: function(t4) { + return null; + }}), s("design:type", Object)], t3.prototype, "parsed", void 0), r3 = a([g.jsonObject({initializer: function(t4, e3) { + return Q(t4); + }}), s("design:paramtypes", [v, Object])], t3); + }(); + e2.CLValue = et, function(t3) { + t3[t3.ACCOUNT_ID = 0] = "ACCOUNT_ID", t3[t3.HASH_ID = 1] = "HASH_ID", t3[t3.UREF_ID = 2] = "UREF_ID"; + }(tt = e2.KeyVariant || (e2.KeyVariant = {})); + var rt = function(t3) { + function e3(e4) { + var r4 = t3.call(this) || this; + return r4.bytes = e4, r4; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.toBytes = function() { + return this.bytes; + }, e3.prototype.clType = function() { + return G.byteArray(32); + }, e3.fromBytes = function(t4) { + if (t4.length < 32) + return w.Err(c.EarlyEndOfStream); + var e4 = t4.subarray(0, 32), n2 = new r3(e4); + return w.Ok(n2, t4.subarray(32)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Uint8Array])], e3); + }(v); + e2.AccountHash = rt; + var nt = function(t3) { + function e3() { + return t3 !== null && t3.apply(this, arguments) || this; + } + var r3; + return o(e3, t3), r3 = e3, e3.prototype.isHash = function() { + return this.variant === tt.HASH_ID; + }, e3.prototype.isURef = function() { + return this.variant === tt.UREF_ID; + }, e3.prototype.isAccount = function() { + return this.variant === tt.ACCOUNT_ID; + }, e3.fromURef = function(t4) { + var e4 = new r3(); + return e4.variant = tt.UREF_ID, e4.uRef = t4, e4; + }, e3.fromHash = function(t4) { + var e4 = new r3(); + return e4.variant = tt.HASH_ID, e4.hash = t4, e4; + }, e3.fromAccount = function(t4) { + var e4 = new r3(); + return e4.variant = tt.ACCOUNT_ID, e4.account = t4, e4; + }, e3.prototype.clType = function() { + return u.Key; + }, e3.prototype.toBytes = function() { + if (this.variant === tt.ACCOUNT_ID) + return h.concat([Uint8Array.from([this.variant]), this.account.toBytes()]); + if (this.variant === tt.HASH_ID) + return h.concat([Uint8Array.from([this.variant]), this.hash]); + if (this.variant === tt.UREF_ID) + return h.concat([Uint8Array.from([this.variant]), this.uRef.toBytes()]); + throw new Error("Unknown variant"); + }, e3.fromBytes = function(t4) { + if (t4.length < 1) + return w.Err(c.EarlyEndOfStream); + var e4 = t4[0], n2 = 1; + if (e4 === tt.HASH_ID) { + var i2 = t4.subarray(n2, 32 + n2); + n2 += 32; + var o2 = r3.fromHash(i2); + return w.Ok(o2, t4.subarray(n2)); + } + if (e4 === tt.UREF_ID) { + var a2 = t4.subarray(1), s2 = at.fromBytes(a2); + return s2.hasError() ? w.Err(s2.error) : (o2 = r3.fromURef(s2.value()), w.Ok(o2, s2.remainder())); + } + if (e4 === tt.ACCOUNT_ID) { + var u2 = t4.subarray(1), f2 = rt.fromBytes(u2); + return f2.hasError() ? w.Err(f2.error) : (o2 = r3.fromAccount(f2.value()), w.Ok(o2, f2.remainder())); + } + return w.Err(c.FormattingError); + }, r3 = a([function(t4) { + }], e3); + }(v); + e2.KeyValue = nt; + var it, ot = "uref-"; + (it = e2.AccessRights || (e2.AccessRights = {}))[it.None = 0] = "None", it[it.READ = 1] = "READ", it[it.WRITE = 2] = "WRITE", it[it.ADD = 4] = "ADD", it[it.READ_WRITE = 3] = "READ_WRITE", it[it.READ_ADD = 5] = "READ_ADD", it[it.ADD_WRITE = 6] = "ADD_WRITE", it[it.READ_ADD_WRITE = 7] = "READ_ADD_WRITE"; + var at = function(t3) { + function e3(e4, r4) { + var n2 = t3.call(this) || this; + if (n2.uRefAddr = e4, n2.accessRights = r4, n2.uRefAddr.byteLength !== 32) + throw new Error("The length of URefAddr should be 32"); + return n2; + } + var r3; + return o(e3, t3), r3 = e3, e3.fromFormattedStr = function(t4) { + if (!t4.startsWith(ot)) + throw new Error("prefix is not 'uref-'"); + var e4 = t4.substring(ot.length).split("-", 2); + if (e4.length !== 2) + throw new Error("no access rights as suffix"); + var n2 = p.decodeBase16(e4[0]), i2 = parseInt(e4[1], 8); + return new r3(n2, i2); + }, e3.prototype.toFormattedStr = function() { + return [ot, p.encodeBase16(this.uRefAddr), this.accessRights.toString(8)].join("-"); + }, e3.prototype.toBytes = function() { + return h.concat([this.uRefAddr, Uint8Array.from([this.accessRights])]); + }, e3.prototype.clType = function() { + return G.uRef(); + }, e3.fromBytes = function(t4) { + if (t4.length < 33) + return w.Err(c.EarlyEndOfStream); + var e4 = t4.subarray(0, 32), n2 = t4[32], i2 = new r3(e4, n2); + return w.Ok(i2, t4.subarray(33)); + }, r3 = a([function(t4) { + }, s("design:paramtypes", [Uint8Array, Number])], e3); + }(v); + e2.URef = at; + }, 3368: function(t2, e2, r2) { + var n = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u2(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u2(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u2(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u2((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, i = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperClient = void 0; + var o = r2(1999), a = r2(3915), s = r2(1417), u = r2(2964), f = r2(3655), c = r2(2092), h = function() { + function t3(t4) { + this.nodeClient = new o.CasperServiceByJsonRPC(t4); + } + return t3.prototype.newKeyPair = function(t4) { + switch (t4) { + case u.SignatureAlgorithm.Ed25519: + return a.Keys.Ed25519.new(); + case u.SignatureAlgorithm.Secp256K1: + return a.Keys.Secp256K1.new(); + default: + throw new Error("Invalid signature algorithm"); + } + }, t3.prototype.loadPublicKeyFromFile = function(t4, e3) { + switch (e3) { + case u.SignatureAlgorithm.Ed25519: + return a.Keys.Ed25519.parsePublicKeyFile(t4); + case u.SignatureAlgorithm.Secp256K1: + return a.Keys.Secp256K1.parsePublicKeyFile(t4); + default: + throw new Error("Invalid signature algorithm"); + } + }, t3.prototype.loadPrivateKeyFromFile = function(t4, e3) { + switch (e3) { + case u.SignatureAlgorithm.Ed25519: + return a.Keys.Ed25519.parsePrivateKeyFile(t4); + case u.SignatureAlgorithm.Secp256K1: + return a.Keys.Secp256K1.parsePrivateKeyFile(t4); + default: + throw new Error("Invalid signature algorithm"); + } + }, t3.prototype.loadKeyPairFromPrivateFile = function(t4, e3) { + switch (e3) { + case u.SignatureAlgorithm.Ed25519: + return a.Keys.Ed25519.loadKeyPairFromPrivateFile(t4); + case u.SignatureAlgorithm.Secp256K1: + return a.Keys.Secp256K1.loadKeyPairFromPrivateFile(t4); + default: + throw new Error("Invalid signature algorithm"); + } + }, t3.prototype.newHdWallet = function(t4) { + return f.CasperHDKey.fromMasterSeed(t4); + }, t3.prototype.privateToPublicKey = function(t4, e3) { + switch (e3) { + case u.SignatureAlgorithm.Ed25519: + return a.Keys.Ed25519.privateToPublicKey(t4); + case u.SignatureAlgorithm.Secp256K1: + return a.Keys.Secp256K1.privateToPublicKey(t4); + default: + throw new Error("Invalid signature algorithm"); + } + }, t3.prototype.makeDeploy = function(t4, e3, r3) { + return a.DeployUtil.makeDeploy(t4, e3, r3); + }, t3.prototype.signDeploy = function(t4, e3) { + return a.DeployUtil.signDeploy(t4, e3); + }, t3.prototype.putDeploy = function(t4) { + return this.nodeClient.deploy(t4).then(function(t5) { + return t5.deploy_hash; + }); + }, t3.prototype.deployToJson = function(t4) { + return a.DeployUtil.deployToJson(t4); + }, t3.prototype.deployFromJson = function(t4) { + return a.DeployUtil.deployFromJson(t4); + }, t3.prototype.makeTransferDeploy = function(t4, e3, r3) { + if (!e3.isTransfer()) + throw new Error("The session is not a Transfer ExecutableDeployItem"); + return this.makeDeploy(t4, e3, r3); + }, t3.prototype.balanceOfByPublicKey = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + return [2, this.balanceOfByAccountHash(s.encodeBase16(t4.toAccountHash()))]; + }); + }); + }, t3.prototype.balanceOfByAccountHash = function(t4) { + return n(this, void 0, void 0, function() { + var e3, r3; + return i(this, function(n2) { + switch (n2.label) { + case 0: + return n2.trys.push([0, 4, , 5]), [4, this.nodeClient.getLatestBlockInfo().then(function(t5) { + var e4; + return (e4 = t5.block) === null || e4 === void 0 ? void 0 : e4.header.state_root_hash; + })]; + case 1: + return (e3 = n2.sent()) ? [4, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(e3, t4)] : [2, c.BigNumber.from(0)]; + case 2: + return (r3 = n2.sent()) ? [4, this.nodeClient.getAccountBalance(e3, r3)] : [2, c.BigNumber.from(0)]; + case 3: + return [2, n2.sent()]; + case 4: + return n2.sent(), [2, c.BigNumber.from(0)]; + case 5: + return [2]; + } + }); + }); + }, t3.prototype.getDeploy = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, this.nodeClient.getDeployInfo(t4).then(function(t5) { + return [a.DeployUtil.deployFromJson(t5), t5]; + })]; + case 1: + return [2, e3.sent()]; + } + }); + }); + }, t3.prototype.getAccountMainPurseUref = function(t4) { + return n(this, void 0, void 0, function() { + var e3; + return i(this, function(r3) { + switch (r3.label) { + case 0: + return [4, this.nodeClient.getLatestBlockInfo().then(function(t5) { + var e4; + return (e4 = t5.block) === null || e4 === void 0 ? void 0 : e4.header.state_root_hash; + })]; + case 1: + return (e3 = r3.sent()) ? [4, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(e3, s.encodeBase16(t4.toAccountHash()))] : [2, null]; + case 2: + return [2, r3.sent()]; + } + }); + }); + }, t3; + }(); + e2.CasperClient = h; + }, 3655: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperHDKey = void 0; + var i = r2(949), o = r2(4237), a = r2(2964), s = function() { + function t3(t4) { + this.hdKey = t4, this.bip44Index = 506; + } + return t3.prototype.bip44Path = function(t4) { + return ["m", "44'", this.bip44Index + "'", "0'", "0", "" + t4].join("/"); + }, t3.fromMasterSeed = function(e3) { + return new t3(i.HDKey.fromMasterSeed(n.from(e3))); + }, t3.prototype.publicKey = function() { + return this.hdKey.publicKey; + }, t3.prototype.privateKey = function() { + return this.hdKey.privateKey; + }, t3.prototype.privateExtendedKey = function() { + return this.hdKey.privateExtendedKey; + }, t3.prototype.publicExtendedKey = function() { + return this.hdKey.publicExtendedKey; + }, t3.prototype.derive = function(t4) { + var e3 = this.hdKey.derive(t4); + return new a.Secp256K1(new Uint8Array(e3.publicKey), new Uint8Array(e3.privateKey)); + }, t3.prototype.deriveIndex = function(t4) { + return this.derive(this.bip44Path(t4)); + }, t3.prototype.sign = function(t4) { + return this.hdKey.sign(o.sha256(n.from(t4))); + }, t3.prototype.verify = function(t4, e3) { + return this.hdKey.verify(o.sha256(n.from(e3)), n.from(t4)); + }, t3.prototype.toJSON = function() { + return this.hdKey.toJSON(); + }, t3; + }(); + e2.CasperHDKey = s; + }, 3492: function(t2, e2, r2) { + var n = r2(8764).Buffer, i = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { + return e3[r3]; + }}); + } : function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; + }), o = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { + Object.defineProperty(t3, "default", {enumerable: true, value: e3}); + } : function(t3, e3) { + t3.default = e3; + }), a = this && this.__importStar || function(t3) { + if (t3 && t3.__esModule) + return t3; + var e3 = {}; + if (t3 != null) + for (var r3 in t3) + r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && i(e3, t3, r3); + return o(e3, t3), e3; + }, s = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.Transfer = e2.Faucet = e2.BoundContract = e2.Contract = e2.byteHash = void 0; + var u = s(r2(1191)), f = a(r2(2349)), c = a(r2(4922)), h = r2(4922), l = r2(6349), d = r2(5050); + e2.byteHash = function(t3) { + return u.default.blake2b(t3, null, 32); + }; + var p = function() { + function t3(t4, e3) { + this.sessionWasm = f.readFileSync(t4), this.paymentWasm = e3 ? f.readFileSync(e3) : n.from(""); + } + return t3.prototype.deploy = function(t4, e3, r3, n2, i2) { + var o2 = h.ExecutableDeployItem.newModuleBytes(this.sessionWasm, t4), a2 = l.RuntimeArgs.fromMap({amount: d.CLValue.u512(e3.toString())}), s2 = h.ExecutableDeployItem.newModuleBytes(this.paymentWasm, a2), u2 = c.makeDeploy(new h.DeployParams(r3, i2), o2, s2); + return c.signDeploy(u2, n2); + }, t3; + }(); + e2.Contract = p; + var y = function() { + function t3(t4, e3) { + this.contract = t4, this.contractKeyPair = e3; + } + return t3.prototype.deploy = function(t4, e3, r3) { + return this.contract.deploy(t4, e3, this.contractKeyPair.publicKey, this.contractKeyPair, r3); + }, t3; + }(); + e2.BoundContract = y; + var m = function() { + function t3() { + } + return t3.args = function(t4) { + var e3 = d.KeyValue.fromAccount(new d.AccountHash(t4)); + return l.RuntimeArgs.fromMap({account: d.CLValue.key(e3)}); + }, t3; + }(); + e2.Faucet = m; + var b = function() { + function t3() { + } + return t3.args = function(t4, e3) { + var r3 = d.CLValue.key(d.KeyValue.fromAccount(new d.AccountHash(t4))); + return l.RuntimeArgs.fromMap({account: r3, amount: d.CLValue.u512(e3.toString())}); + }, t3; + }(); + e2.Transfer = b; + }, 1417: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}), e2.decodeBase16 = e2.encodeBase16 = e2.base64to16 = void 0; + var i = r2(6885), o = r2(6885); + function a(t3) { + return n.from(t3).toString("hex"); + } + Object.defineProperty(e2, "encodeBase64", {enumerable: true, get: function() { + return o.encodeBase64; + }}), Object.defineProperty(e2, "decodeBase64", {enumerable: true, get: function() { + return o.decodeBase64; + }}), e2.base64to16 = function(t3) { + return a(i.decodeBase64(t3)); + }, e2.encodeBase16 = a, e2.decodeBase16 = function(t3) { + return new Uint8Array(n.from(t3, "hex")); + }; + }, 4922: function(t2, e2, r2) { + var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), a = this && this.__decorate || function(t3, e3, r3, n2) { + var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") + a2 = Reflect.decorate(t3, e3, r3, n2); + else + for (var s2 = t3.length - 1; s2 >= 0; s2--) + (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); + return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; + }, s = this && this.__metadata || function(t3, e3) { + if (typeof Reflect == "object" && typeof Reflect.metadata == "function") + return Reflect.metadata(t3, e3); + }, u = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.deployToBytes = e2.validateDeploy = e2.deploySizeInBytes = e2.addArgToDeploy = e2.deployFromJson = e2.deployToJson = e2.standardPayment = e2.setSignature = e2.signDeploy = e2.makeDeploy = e2.DeployParams = e2.ContractType = e2.serializeApprovals = e2.serializeBody = e2.serializeHeader = e2.Deploy = e2.ExecutableDeployItem = e2.Transfer = e2.StoredVersionedContractByHash = e2.StoredVersionedContractByName = e2.StoredContractByName = e2.StoredContractByHash = e2.ModuleBytes = e2.Approval = e2.DeployHeader = e2.UniqAddress = e2.dehumanizerTTL = e2.humanizerTTL = void 0; + var f = r2(3286), c = u(r2(1191)), h = r2(5371), l = r2(1417), d = u(r2(9695)), p = r2(5050), y = r2(3917), m = r2(6349), b = r2(3915), g = r2(2964), v = r2(2092), w = r2(4546), _ = r2(6811), M = r2(2831), S = d.default.humanizer({spacer: "", serialComma: false, conjunction: " ", delimiter: " ", language: "shortEn", languages: {shortEn: {d: function() { + return "day"; + }, h: function() { + return "h"; + }, m: function() { + return "m"; + }, s: function() { + return "s"; + }, ms: function() { + return "ms"; + }}}}), E = function(t3) { + return l.encodeBase16(t3); + }, A = function(t3) { + return l.decodeBase16(t3); + }; + e2.humanizerTTL = function(t3) { + return S(t3); + }, e2.dehumanizerTTL = function(t3) { + return t3.split(" ").map(function(t4) { + if (t4.includes("ms")) + return Number(t4.replace("ms", "")); + if (t4.includes("s") && !t4.includes("m")) + return 1e3 * Number(t4.replace("s", "")); + if (t4.includes("m") && !t4.includes("s")) + return 60 * Number(t4.replace("m", "")) * 1e3; + if (t4.includes("h")) + return 60 * Number(t4.replace("h", "")) * 60 * 1e3; + if (t4.includes("day")) + return 24 * Number(t4.replace("day", "")) * 60 * 60 * 1e3; + throw Error("Unsuported TTL unit"); + }).reduce(function(t4, e3) { + return t4 + e3; + }); + }; + var k = function() { + function t3(t4, e3) { + if (!(t4 instanceof p.PublicKey)) + throw new Error("publicKey is not an instance of PublicKey"); + var r3 = v.BigNumber.from(e3); + if (r3.gt("18446744073709551615")) + throw new Error("transferId max value is U64"); + this.transferId = r3, this.publicKey = t4; + } + return t3.prototype.toString = function() { + return this.publicKey.toAccountHex() + "-" + this.transferId.toHexString(); + }, t3.fromString = function(e3) { + var r3 = e3.split("-"), n2 = r3[0], i2 = r3[1]; + return new t3(p.PublicKey.fromHex(n2), i2); + }, t3; + }(); + e2.UniqAddress = k; + var B = function() { + function t3(t4, e3, r3, n2, i2, o2, a2) { + this.account = t4, this.timestamp = e3, this.ttl = r3, this.gasPrice = n2, this.bodyHash = i2, this.dependencies = o2, this.chainName = a2; + } + return t3.prototype.toBytes = function() { + return f.concat([this.account.toBytes(), y.toBytesU64(this.timestamp), y.toBytesU64(this.ttl), y.toBytesU64(this.gasPrice), y.toBytesDeployHash(this.bodyHash), y.toBytesVecT(this.dependencies.map(function(t4) { + return new T(t4); + })), y.toBytesString(this.chainName)]); + }, a([w.jsonMember({serializer: function(t4) { + return t4.toAccountHex(); + }, deserializer: function(t4) { + return p.PublicKey.fromHex(t4); + }}), s("design:type", p.PublicKey)], t3.prototype, "account", void 0), a([w.jsonMember({serializer: function(t4) { + return new Date(t4).toISOString(); + }, deserializer: function(t4) { + return Date.parse(t4); + }}), s("design:type", Number)], t3.prototype, "timestamp", void 0), a([w.jsonMember({serializer: e2.humanizerTTL, deserializer: e2.dehumanizerTTL}), s("design:type", Number)], t3.prototype, "ttl", void 0), a([w.jsonMember({constructor: Number, name: "gas_price"}), s("design:type", Number)], t3.prototype, "gasPrice", void 0), a([w.jsonMember({name: "body_hash", serializer: E, deserializer: A}), s("design:type", Uint8Array)], t3.prototype, "bodyHash", void 0), a([w.jsonArrayMember(_.ByteArray, {serializer: function(t4) { + return t4.map(function(t5) { + return E(t5); + }); + }, deserializer: function(t4) { + return t4.map(function(t5) { + return A(t5); + }); + }}), s("design:type", Array)], t3.prototype, "dependencies", void 0), a([w.jsonMember({name: "chain_name", constructor: String}), s("design:type", String)], t3.prototype, "chainName", void 0), a([w.jsonObject, s("design:paramtypes", [p.PublicKey, Number, Number, Number, Uint8Array, Array, String])], t3); + }(); + e2.DeployHeader = B; + var T = function() { + function t3(t4) { + this.hash = t4; + } + return t3.prototype.toBytes = function() { + return y.toBytesDeployHash(this.hash); + }, t3; + }(), x = function() { + function t3() { + } + return a([w.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "signer", void 0), a([w.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "signature", void 0), a([w.jsonObject], t3); + }(); + e2.Approval = x; + var O = function() { + function t3() { + } + return t3.prototype.getArgByName = function(t4) { + return this.args.args.get(t4); + }, t3.prototype.setArg = function(t4, e3) { + this.args.args.set(t4, e3); + }, t3; + }(), R = function(t3) { + var e3 = {args: t3}; + return new w.TypedJSON(m.RuntimeArgs).parse(e3); + }, P = function(t3) { + var e3 = new w.TypedJSON(m.RuntimeArgs).toPlainJson(t3); + return Object.values(e3)[0]; + }, I = function(t3) { + function e3(e4, r3) { + var n2 = t3.call(this) || this; + return n2.tag = 0, n2.moduleBytes = e4, n2.args = r3, n2; + } + return o(e3, t3), e3.prototype.toBytes = function() { + return f.concat([Uint8Array.from([this.tag]), y.toBytesArrayU8(this.moduleBytes), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({name: "module_bytes", serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "moduleBytes", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, m.RuntimeArgs])], e3); + }(O); + e2.ModuleBytes = I; + var j = function(t3) { + function e3(e4, r3, n2) { + var i2 = t3.call(this) || this; + return i2.tag = 1, i2.entryPoint = r3, i2.args = n2, i2.hash = e4, i2; + } + return o(e3, t3), e3.prototype.toBytes = function() { + return f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.hash), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "hash", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, String, m.RuntimeArgs])], e3); + }(O); + e2.StoredContractByHash = j; + var U = function(t3) { + function e3(e4, r3, n2) { + var i2 = t3.call(this) || this; + return i2.tag = 2, i2.name = e4, i2.entryPoint = r3, i2.args = n2, i2; + } + return o(e3, t3), e3.prototype.toBytes = function() { + return f.concat([Uint8Array.from([this.tag]), y.toBytesString(this.name), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({constructor: String}), s("design:type", String)], e3.prototype, "name", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [String, String, m.RuntimeArgs])], e3); + }(O); + e2.StoredContractByName = U; + var N = function(t3) { + function e3(e4, r3, n2, i2) { + var o2 = t3.call(this) || this; + return o2.tag = 4, o2.name = e4, o2.version = r3, o2.entryPoint = n2, o2.args = i2, o2; + } + return o(e3, t3), e3.prototype.toBytes = function() { + var t4; + return t4 = this.version === null ? new h.Option(null, p.CLTypeHelper.u32()) : new h.Option(new p.U32(this.version)), f.concat([Uint8Array.from([this.tag]), y.toBytesString(this.name), t4.toBytes(), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({constructor: String}), s("design:type", String)], e3.prototype, "name", void 0), a([w.jsonMember({constructor: Number, preserveNull: true}), s("design:type", Object)], e3.prototype, "version", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [String, Object, String, m.RuntimeArgs])], e3); + }(O); + e2.StoredVersionedContractByName = N; + var C = function(t3) { + function e3(e4, r3, n2, i2) { + var o2 = t3.call(this) || this; + return o2.tag = 3, o2.hash = e4, o2.version = r3, o2.entryPoint = n2, o2.args = i2, o2; + } + return o(e3, t3), e3.prototype.toBytes = function() { + var t4; + return t4 = this.version === null ? new h.Option(null, p.CLTypeHelper.u32()) : new h.Option(new p.U32(this.version)), f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.hash), t4.toBytes(), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "hash", void 0), a([w.jsonMember({constructor: Number, preserveNull: true}), s("design:type", Object)], e3.prototype, "version", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, Object, String, m.RuntimeArgs])], e3); + }(O); + e2.StoredVersionedContractByHash = C; + var D = function(t3) { + function e3(e4) { + var r3 = t3.call(this) || this; + return r3.tag = 5, r3.args = e4, r3; + } + return o(e3, t3), e3.prototype.toBytes = function() { + return f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.args.toBytes())]); + }, a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [m.RuntimeArgs])], e3); + }(O); + e2.Transfer = D; + var L = function() { + function t3() { + } + var e3; + return e3 = t3, t3.prototype.toBytes = function() { + if (this.isModuleBytes()) + return this.moduleBytes.toBytes(); + if (this.isStoredContractByHash()) + return this.storedContractByHash.toBytes(); + if (this.isStoredContractByName()) + return this.storedContractByName.toBytes(); + if (this.isStoredVersionContractByHash()) + return this.storedVersionedContractByHash.toBytes(); + if (this.isStoredVersionContractByName()) + return this.storedVersionedContractByName.toBytes(); + if (this.isTransfer()) + return this.transfer.toBytes(); + throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); + }, t3.prototype.getArgByName = function(t4) { + if (this.isModuleBytes()) + return this.moduleBytes.getArgByName(t4); + if (this.isStoredContractByHash()) + return this.storedContractByHash.getArgByName(t4); + if (this.isStoredContractByName()) + return this.storedContractByName.getArgByName(t4); + if (this.isStoredVersionContractByHash()) + return this.storedVersionedContractByHash.getArgByName(t4); + if (this.isStoredVersionContractByName()) + return this.storedVersionedContractByName.getArgByName(t4); + if (this.isTransfer()) + return this.transfer.getArgByName(t4); + throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); + }, t3.prototype.setArg = function(t4, e4) { + if (this.isModuleBytes()) + return this.moduleBytes.setArg(t4, e4); + if (this.isStoredContractByHash()) + return this.storedContractByHash.setArg(t4, e4); + if (this.isStoredContractByName()) + return this.storedContractByName.setArg(t4, e4); + if (this.isStoredVersionContractByHash()) + return this.storedVersionedContractByHash.setArg(t4, e4); + if (this.isStoredVersionContractByName()) + return this.storedVersionedContractByName.setArg(t4, e4); + if (this.isTransfer()) + return this.transfer.setArg(t4, e4); + throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); + }, t3.fromExecutableDeployItemInternal = function(t4) { + var r3 = new e3(); + switch (t4.tag) { + case 0: + r3.moduleBytes = t4; + break; + case 1: + r3.storedContractByHash = t4; + break; + case 2: + r3.storedContractByName = t4; + break; + case 3: + r3.storedVersionedContractByHash = t4; + break; + case 4: + r3.storedVersionedContractByName = t4; + break; + case 5: + r3.transfer = t4; + } + return r3; + }, t3.newModuleBytes = function(t4, r3) { + return e3.fromExecutableDeployItemInternal(new I(t4, r3)); + }, t3.newStoredContractByHash = function(t4, r3, n2) { + return e3.fromExecutableDeployItemInternal(new j(t4, r3, n2)); + }, t3.newStoredContractByName = function(t4, r3, n2) { + return e3.fromExecutableDeployItemInternal(new U(t4, r3, n2)); + }, t3.newStoredVersionContractByHash = function(t4, r3, n2, i2) { + return e3.fromExecutableDeployItemInternal(new C(t4, r3, n2, i2)); + }, t3.newStoredVersionContractByName = function(t4, r3, n2, i2) { + return e3.fromExecutableDeployItemInternal(new N(t4, r3, n2, i2)); + }, t3.newTransfer = function(t4, r3, n2, i2) { + n2 === void 0 && (n2 = null); + var o2 = m.RuntimeArgs.fromMap({}); + if (o2.insert("amount", p.CLValue.u512(t4)), n2 && o2.insert("source", p.CLValue.uref(n2)), r3 instanceof b.URef) + o2.insert("target", p.CLValue.uref(r3)); + else { + if (!(r3 instanceof p.PublicKey)) + throw new Error("Please specify target"); + o2.insert("target", p.CLValue.byteArray(r3.toAccountHash())); + } + if (i2 === void 0) + throw new Error("transfer-id missing in new transfer."); + return o2.insert("id", p.CLValue.option(p.CLTypedAndToBytesHelper.u64(i2), p.CLTypeHelper.u64())), e3.fromExecutableDeployItemInternal(new D(o2)); + }, t3.newTransferWithOptionalTransferId = function(t4, r3, n2, i2) { + var o2 = m.RuntimeArgs.fromMap({}); + if (o2.insert("amount", p.CLValue.u512(t4)), n2 && o2.insert("source", p.CLValue.uref(n2)), r3 instanceof b.URef) + o2.insert("target", p.CLValue.uref(r3)); + else { + if (!(r3 instanceof p.PublicKey)) + throw new Error("Please specify target"); + o2.insert("target", p.CLValue.byteArray(r3.toAccountHash())); + } + return i2 != null ? o2.insert("id", p.CLValue.option(p.CLTypedAndToBytesHelper.u64(i2), p.CLTypeHelper.u64())) : o2.insert("id", p.CLValue.option(null, p.CLTypeHelper.u64())), e3.fromExecutableDeployItemInternal(new D(o2)); + }, t3.newTransferToUniqAddress = function(t4, e4, r3, n2, i2, o2, a2, s2) { + o2 === void 0 && (o2 = 1), a2 === void 0 && (a2 = 18e5); + var u2 = new b.DeployUtil.DeployParams(t4, i2, o2, a2), f2 = b.DeployUtil.standardPayment(n2), c2 = b.DeployUtil.ExecutableDeployItem.newTransfer(r3, e4.publicKey, s2, e4.transferId); + return b.DeployUtil.makeDeploy(u2, c2, f2); + }, t3.prototype.isModuleBytes = function() { + return !!this.moduleBytes; + }, t3.prototype.asModuleBytes = function() { + return this.moduleBytes; + }, t3.prototype.isStoredContractByHash = function() { + return !!this.storedContractByHash; + }, t3.prototype.asStoredContractByHash = function() { + return this.storedContractByHash; + }, t3.prototype.isStoredContractByName = function() { + return !!this.storedContractByName; + }, t3.prototype.asStoredContractByName = function() { + return this.storedContractByName; + }, t3.prototype.isStoredVersionContractByName = function() { + return !!this.storedVersionedContractByName; + }, t3.prototype.asStoredVersionContractByName = function() { + return this.storedVersionedContractByName; + }, t3.prototype.isStoredVersionContractByHash = function() { + return !!this.storedVersionedContractByHash; + }, t3.prototype.asStoredVersionContractByHash = function() { + return this.storedVersionedContractByHash; + }, t3.prototype.isTransfer = function() { + return !!this.transfer; + }, t3.prototype.asTransfer = function() { + return this.transfer; + }, a([w.jsonMember({name: "ModuleBytes", constructor: I}), s("design:type", I)], t3.prototype, "moduleBytes", void 0), a([w.jsonMember({name: "StoredContractByHash", constructor: j}), s("design:type", j)], t3.prototype, "storedContractByHash", void 0), a([w.jsonMember({name: "StoredContractByName", constructor: U}), s("design:type", U)], t3.prototype, "storedContractByName", void 0), a([w.jsonMember({name: "StoredVersionedContractByHash", constructor: C}), s("design:type", C)], t3.prototype, "storedVersionedContractByHash", void 0), a([w.jsonMember({name: "StoredVersionedContractByName", constructor: N}), s("design:type", N)], t3.prototype, "storedVersionedContractByName", void 0), a([w.jsonMember({name: "Transfer", constructor: D}), s("design:type", D)], t3.prototype, "transfer", void 0), e3 = a([w.jsonObject], t3); + }(); + e2.ExecutableDeployItem = L; + var K, z = function() { + function t3(t4, e3, r3, n2, i2) { + this.approvals = i2, this.session = n2, this.payment = r3, this.header = e3, this.hash = t4; + } + return t3.prototype.isTransfer = function() { + return this.session.isTransfer(); + }, t3.prototype.isStandardPayment = function() { + var t4; + return !!this.payment.isModuleBytes() && ((t4 = this.payment.asModuleBytes()) === null || t4 === void 0 ? void 0 : t4.moduleBytes.length) === 0; + }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], t3.prototype, "hash", void 0), a([w.jsonMember({constructor: B}), s("design:type", B)], t3.prototype, "header", void 0), a([w.jsonMember({constructor: L}), s("design:type", L)], t3.prototype, "payment", void 0), a([w.jsonMember({constructor: L}), s("design:type", L)], t3.prototype, "session", void 0), a([w.jsonArrayMember(x), s("design:type", Array)], t3.prototype, "approvals", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, B, L, L, Array])], t3); + }(); + e2.Deploy = z, e2.serializeHeader = function(t3) { + return t3.toBytes(); + }, e2.serializeBody = function(t3, e3) { + return f.concat([t3.toBytes(), e3.toBytes()]); + }, e2.serializeApprovals = function(t3) { + var e3 = y.toBytesU32(t3.length), r3 = f.concat(t3.map(function(t4) { + return f.concat([Uint8Array.from(i.from(t4.signer, "hex")), Uint8Array.from(i.from(t4.signature, "hex"))]); + })); + return f.concat([e3, r3]); + }, (K = e2.ContractType || (e2.ContractType = {})).WASM = "WASM", K.Hash = "Hash", K.Name = "Name"; + function q(t3, r3, n2) { + var i2 = e2.serializeBody(n2, r3), o2 = c.default.blake2b(i2, null, 32), a2 = new B(t3.accountPublicKey, t3.timestamp, t3.ttl, t3.gasPrice, o2, t3.dependencies, t3.chainName), s2 = e2.serializeHeader(a2), u2 = c.default.blake2b(s2, null, 32); + return new z(u2, a2, n2, r3, []); + } + e2.DeployParams = function(t3, e3, r3, n2, i2, o2) { + r3 === void 0 && (r3 = 1), n2 === void 0 && (n2 = 18e5), i2 === void 0 && (i2 = []), this.accountPublicKey = t3, this.chainName = e3, this.gasPrice = r3, this.ttl = n2, this.dependencies = i2, this.timestamp = o2, this.dependencies = i2.filter(function(t4) { + return i2.filter(function(e4) { + return l.encodeBase16(t4) === l.encodeBase16(e4); + }).length < 2; + }), o2 || (this.timestamp = Date.now()); + }, e2.makeDeploy = q, e2.signDeploy = function(t3, e3) { + var r3 = new x(), n2 = e3.sign(t3.hash); + switch (r3.signer = e3.accountHex(), e3.signatureAlgorithm) { + case g.SignatureAlgorithm.Ed25519: + r3.signature = b.Keys.Ed25519.accountHex(n2); + break; + case g.SignatureAlgorithm.Secp256K1: + r3.signature = b.Keys.Secp256K1.accountHex(n2); + } + return t3.approvals.push(r3), t3; + }, e2.setSignature = function(t3, e3, r3) { + var n2 = new x(); + switch (n2.signer = r3.toAccountHex(), r3.signatureAlgorithm()) { + case g.SignatureAlgorithm.Ed25519: + n2.signature = b.Keys.Ed25519.accountHex(e3); + break; + case g.SignatureAlgorithm.Secp256K1: + n2.signature = b.Keys.Secp256K1.accountHex(e3); + } + return t3.approvals.push(n2), t3; + }, e2.standardPayment = function(t3) { + var e3 = m.RuntimeArgs.fromMap({amount: p.CLValue.u512(t3.toString())}); + return L.newModuleBytes(Uint8Array.from([]), e3); + }, e2.deployToJson = function(t3) { + return {deploy: new w.TypedJSON(z).toPlainJson(t3)}; + }, e2.deployFromJson = function(t3) { + var r3 = new w.TypedJSON(z).parse(t3.deploy); + if (r3 !== void 0 && e2.validateDeploy(r3).ok) + return r3; + }, e2.addArgToDeploy = function(t3, e3, r3) { + if (t3.approvals.length !== 0) + throw Error("Can not add argument to already signed deploy."); + var n2 = new b.DeployUtil.DeployParams(t3.header.account, t3.header.chainName, t3.header.gasPrice, t3.header.ttl, t3.header.dependencies, t3.header.timestamp), i2 = t3.session; + return i2.setArg(e3, r3), q(n2, i2, t3.payment); + }, e2.deploySizeInBytes = function(t3) { + var r3 = t3.hash.length, n2 = e2.serializeBody(t3.payment, t3.session).length; + return r3 + e2.serializeHeader(t3.header).length + n2 + t3.approvals.map(function(t4) { + return (t4.signature.length + t4.signer.length) / 2; + }).reduce(function(t4, e3) { + return t4 + e3; + }, 0); + }, e2.validateDeploy = function(t3) { + var r3 = e2.serializeBody(t3.payment, t3.session), n2 = c.default.blake2b(r3, null, 32); + if (!H(t3.header.bodyHash, n2)) + return M.Err("Invalid deploy: bodyHash missmatch. Expected: " + n2 + ", \n got: " + t3.header.bodyHash + "."); + var i2 = e2.serializeHeader(t3.header), o2 = c.default.blake2b(i2, null, 32); + return H(t3.hash, o2) ? M.Ok(t3) : M.Err("Invalid deploy: hash missmatch. Expected: " + o2 + ", \n got: " + t3.hash + "."); + }; + var H = function(t3, e3) { + return t3.length === e3.length && t3.every(function(t4, r3) { + return t4 === e3[r3]; + }); + }; + e2.deployToBytes = function(t3) { + return f.concat([e2.serializeHeader(t3.header), t3.hash, e2.serializeBody(t3.payment, t3.session), e2.serializeApprovals(t3.approvals)]); + }; + }, 2964: function(t2, e2, r2) { + var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }), a = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { + return e3[r3]; + }}); + } : function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; + }), s = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { + Object.defineProperty(t3, "default", {enumerable: true, value: e3}); + } : function(t3, e3) { + t3.default = e3; + }), u = this && this.__importStar || function(t3) { + if (t3 && t3.__esModule) + return t3; + var e3 = {}; + if (t3 != null) + for (var r3 in t3) + r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && a(e3, t3, r3); + return s(e3, t3), e3; + }, f = this && this.__importDefault || function(t3) { + return t3 && t3.__esModule ? t3 : {default: t3}; + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.Secp256K1 = e2.Ed25519 = e2.AsymmetricKey = e2.readBase64WithPEM = e2.SignatureAlgorithm = void 0; + var c, h = u(r2(2349)), l = u(r2(6811)), d = r2(6885), p = r2(3607), y = r2(3915), m = r2(3492), b = f(r2(6215)), g = u(r2(5053)), v = f(r2(8917)), w = r2(4237), _ = new v.default("secp256k1"); + function M(t3, e3) { + var r3 = i.from([0]), n2 = i.concat([i.from(t3), r3]); + return e3.length === 0 ? i.from([]) : m.byteHash(i.concat([n2, i.from(e3)])); + } + function S(t3) { + var e3 = t3.split(/\r?\n/).filter(function(t4) { + return !t4.startsWith("---"); + }).join("").trim(); + return d.decodeBase64(e3); + } + !function(t3) { + t3.Ed25519 = "ed25519", t3.Secp256K1 = "secp256k1"; + }(c = e2.SignatureAlgorithm || (e2.SignatureAlgorithm = {})), e2.readBase64WithPEM = S; + var E = function() { + function t3(t4, e3, r3) { + this.publicKey = y.PublicKey.from(t4, r3), this.privateKey = e3, this.signatureAlgorithm = r3; + } + return t3.prototype.accountHash = function() { + return this.publicKey.toAccountHash(); + }, t3.prototype.accountHex = function() { + return this.publicKey.toAccountHex(); + }, t3.prototype.toPem = function(t4, e3) { + return "-----BEGIN " + t4 + "-----\n" + e3 + "\n-----END " + t4 + "-----\n"; + }, t3; + }(); + e2.AsymmetricKey = E; + var A = function(t3) { + function e3(e4) { + return t3.call(this, e4.publicKey, e4.secretKey, c.Ed25519) || this; + } + return o(e3, t3), e3.new = function() { + return new e3(l.sign_keyPair()); + }, e3.accountHex = function(t4) { + return "01" + p.encodeBase16(t4); + }, e3.parseKeyFiles = function(t4, r3) { + var n2 = e3.parsePublicKeyFile(t4), o2 = e3.parsePrivateKeyFile(r3); + return new e3({publicKey: n2, secretKey: i.concat([o2, n2])}); + }, e3.accountHash = function(t4) { + return M(c.Ed25519, t4); + }, e3.parseKeyPair = function(t4, r3) { + var n2 = e3.parsePublicKey(t4), i2 = e3.parsePrivateKey(r3), o2 = new Uint8Array(n2.length + i2.length); + return o2.set(i2), o2.set(n2, i2.length), new e3({publicKey: n2, secretKey: o2}); + }, e3.parsePrivateKeyFile = function(t4) { + return e3.parsePrivateKey(e3.readBase64File(t4)); + }, e3.parsePublicKeyFile = function(t4) { + return e3.parsePublicKey(e3.readBase64File(t4)); + }, e3.parsePrivateKey = function(t4) { + return e3.parseKey(t4, 0, 32); + }, e3.parsePublicKey = function(t4) { + return e3.parseKey(t4, 32, 64); + }, e3.readBase64WithPEM = function(t4) { + return S(t4); + }, e3.readBase64File = function(t4) { + var r3 = h.readFileSync(t4).toString(); + return e3.readBase64WithPEM(r3); + }, e3.parseKey = function(t4, e4, r3) { + var n2 = t4.length, o2 = n2 === 32 ? t4 : n2 === 64 ? i.from(t4).slice(e4, r3) : n2 > 32 && n2 < 64 ? i.from(t4).slice(n2 % 32) : null; + if (o2 == null || o2.length !== 32) + throw Error("Unexpected key length: " + n2); + return o2; + }, e3.prototype.exportPrivateKeyInPem = function() { + var t4 = i.from([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]), r3 = p.encodeBase64(i.concat([t4, i.from(e3.parsePrivateKey(this.privateKey))])); + return this.toPem("PRIVATE KEY", r3); + }, e3.prototype.exportPublicKeyInPem = function() { + var t4 = i.from([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]), e4 = p.encodeBase64(i.concat([t4, i.from(this.publicKey.rawPublicKey)])); + return this.toPem("PUBLIC KEY", e4); + }, e3.prototype.sign = function(t4) { + return l.sign_detached(t4, this.privateKey); + }, e3.prototype.verify = function(t4, e4) { + return l.sign_detached_verify(e4, t4, this.publicKey.rawPublicKey); + }, e3.privateToPublicKey = function(t4) { + return t4.length === 64 ? l.sign_keyPair_fromSecretKey(t4).publicKey : l.sign_keyPair_fromSeed(t4).publicKey; + }, e3.loadKeyPairFromPrivateFile = function(t4) { + var r3 = e3.parsePrivateKeyFile(t4), n2 = e3.privateToPublicKey(r3); + return e3.parseKeyPair(n2, r3); + }, e3; + }(E); + e2.Ed25519 = A; + var k = function(t3) { + function e3(e4, r3) { + return t3.call(this, e4, r3, c.Secp256K1) || this; + } + return o(e3, t3), e3.new = function() { + var t4 = b.default.generatePrivate(); + return new e3(Uint8Array.from(b.default.getPublicCompressed(t4)), t4); + }, e3.parseKeyFiles = function(t4, r3) { + var n2 = e3.parsePublicKeyFile(t4), i2 = e3.parsePrivateKeyFile(r3); + return new e3(n2, i2); + }, e3.accountHash = function(t4) { + return M(c.Secp256K1, t4); + }, e3.accountHex = function(t4) { + return "02" + p.encodeBase16(t4); + }, e3.parseKeyPair = function(t4, r3, n2) { + var i2 = e3.parsePublicKey(t4, n2), o2 = e3.parsePrivateKey(r3, n2); + return new e3(i2, o2); + }, e3.parsePrivateKeyFile = function(t4) { + return e3.parsePrivateKey(e3.readBase64File(t4)); + }, e3.parsePublicKeyFile = function(t4) { + return e3.parsePublicKey(e3.readBase64File(t4)); + }, e3.parsePrivateKey = function(t4, e4) { + var r3; + return e4 === void 0 && (e4 = "der"), r3 = e4 === "der" ? _.encodePrivate(i.from(t4), "der", "raw") : p.encodeBase16(t4), i.from(r3, "hex"); + }, e3.parsePublicKey = function(t4, e4) { + var r3; + return e4 === void 0 && (e4 = "der"), r3 = e4 === "der" ? _.encodePublic(i.from(t4), "der", "raw") : p.encodeBase16(t4), Uint8Array.from(i.from(r3, "hex")); + }, e3.readBase64WithPEM = function(t4) { + return S(t4); + }, e3.readBase64File = function(t4) { + var r3 = h.readFileSync(t4).toString(); + return e3.readBase64WithPEM(r3); + }, e3.prototype.exportPrivateKeyInPem = function() { + return _.encodePrivate(p.encodeBase16(this.privateKey), "raw", "pem"); + }, e3.prototype.exportPublicKeyInPem = function() { + return _.encodePublic(p.encodeBase16(this.publicKey.rawPublicKey), "raw", "pem"); + }, e3.prototype.sign = function(t4) { + return g.ecdsaSign(w.sha256(i.from(t4)), this.privateKey).signature; + }, e3.prototype.verify = function(t4, e4) { + return g.ecdsaVerify(t4, w.sha256(i.from(e4)), this.publicKey.rawPublicKey); + }, e3.privateToPublicKey = function(t4) { + return g.publicKeyCreate(t4, true); + }, e3.loadKeyPairFromPrivateFile = function(t4) { + var r3 = e3.parsePrivateKeyFile(t4), n2 = e3.privateToPublicKey(r3); + return e3.parseKeyPair(n2, r3, "raw"); + }, e3.deriveIndex = function(t4, e4) { + return t4.deriveIndex(e4); + }, e3; + }(E); + e2.Secp256K1 = k; + }, 6349: function(t2, e2, r2) { + var n = this && this.__decorate || function(t3, e3, r3, n2) { + var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") + a2 = Reflect.decorate(t3, e3, r3, n2); + else + for (var s2 = t3.length - 1; s2 >= 0; s2--) + (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); + return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; + }, i = this && this.__metadata || function(t3, e3) { + if (typeof Reflect == "object" && typeof Reflect.metadata == "function") + return Reflect.metadata(t3, e3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.RuntimeArgs = e2.NamedArg = void 0; + var o = r2(3917), a = r2(5050), s = r2(3286), u = r2(4546), f = function() { + function t3(t4, e3) { + this.name = t4, this.value = e3; + } + return t3.prototype.toBytes = function() { + var t4 = o.toBytesString(this.name), e3 = this.value.toBytes(); + return s.concat([t4, e3]); + }, t3.fromBytes = function(e3) { + var r3 = a.StringValue.fromBytes(e3); + if (r3.hasError()) + return a.Result.Err(r3.error); + var n2 = a.CLValue.fromBytes(r3.remainder()); + return n2.hasError() ? a.Result.Err(n2.error) : a.Result.Ok(new t3(r3.value().val, n2.value()), n2.remainder()); + }, t3; + }(); + e2.NamedArg = f; + var c = function(t3) { + var e3 = new u.TypedJSON(a.CLValue); + return new Map(Array.from(t3, function(t4) { + var r3 = t4[0], n2 = t4[1]; + return [r3, e3.parse(n2)]; + })); + }, h = function(t3) { + var e3 = new u.TypedJSON(a.CLValue); + return Array.from(t3, function(t4) { + var r3 = t4[0], n2 = t4[1]; + return [r3, e3.toPlainJson(n2)]; + }); + }, l = function() { + function t3(t4) { + this.args = t4; + } + var e3; + return e3 = t3, t3.fromMap = function(t4) { + var r3 = new Map(Object.keys(t4).map(function(e4) { + return [e4, t4[e4]]; + })); + return new e3(r3); + }, t3.fromNamedArgs = function(t4) { + var r3 = t4.reduce(function(t5, e4) { + return t5[e4.name] = e4.value, t5; + }, {}); + return e3.fromMap(r3); + }, t3.prototype.insert = function(t4, e4) { + this.args.set(t4, e4); + }, t3.prototype.toBytes = function() { + var t4 = Array.from(this.args.entries()).map(function(t5) { + return new f(t5[0], t5[1]); + }); + return o.toBytesVecT(t4); + }, t3.fromBytes = function(t4) { + var r3 = a.U32.fromBytes(t4); + if (r3.hasError()) + return a.Result.Err(r3.error); + for (var n2 = r3.value().val.toNumber(), i2 = r3.remainder(), o2 = [], s2 = 0; s2 < n2; s2++) { + var u2 = f.fromBytes(i2); + if (u2.hasError()) + return a.Result.Err(u2.error); + o2.push(u2.value()), i2 = u2.remainder(); + } + return a.Result.Ok(e3.fromNamedArgs(o2), i2); + }, n([u.jsonMember({serializer: h, deserializer: c}), i("design:type", Map)], t3.prototype, "args", void 0), e3 = n([u.jsonObject(), i("design:paramtypes", [Map])], t3); + }(); + e2.RuntimeArgs = l; + }, 165: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}), e2.Args = e2.UInt64Arg = e2.PublicKeyArg = e2.ByteSequenceArg = e2.ByteArrayArg = void 0; + var i = function(t3) { + var e3 = n.alloc(4); + return e3.writeInt32LE(t3, 0), e3; + }; + e2.ByteArrayArg = function(t3) { + return n.from(t3); + }, e2.ByteSequenceArg = function(t3) { + return n.concat([i(t3.length), t3].map(n.from)); + }, e2.PublicKeyArg = e2.ByteArrayArg, e2.UInt64Arg = function(t3) { + var e3 = n.alloc(8); + return e3.writeBigUInt64LE(t3, 0), e3; + }, e2.Args = function() { + for (var t3 = [], r3 = 0; r3 < arguments.length; r3++) + t3[r3] = arguments[r3]; + var o = [i(t3.length)].concat(t3.map(e2.ByteSequenceArg)); + return n.concat(o.map(n.from)); + }; + }, 2896: function(t2, e2) { + var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i, o) { + function a(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o(t5); + } + } + function s(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o(t5); + } + } + function u(t4) { + var e4; + t4.done ? i(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a, s); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, n = this && this.__generator || function(t3, e3) { + var r3, n2, i, o, a = {label: 0, sent: function() { + if (1 & i[0]) + throw i[1]; + return i[1]; + }, trys: [], ops: []}; + return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { + return this; + }), o; + function s(o2) { + return function(s2) { + return function(o3) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a; ) + try { + if (r3 = 1, n2 && (i = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i = n2.return) && i.call(n2), 0) : n2.next) && !(i = i.call(n2, o3[1])).done) + return i; + switch (n2 = 0, i && (o3 = [2 & o3[0], i.value]), o3[0]) { + case 0: + case 1: + i = o3; + break; + case 4: + return a.label++, {value: o3[1], done: false}; + case 5: + a.label++, n2 = o3[1], o3 = [0]; + continue; + case 7: + o3 = a.ops.pop(), a.trys.pop(); + continue; + default: + if (!((i = (i = a.trys).length > 0 && i[i.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { + a = 0; + continue; + } + if (o3[0] === 3 && (!i || o3[1] > i[0] && o3[1] < i[3])) { + a.label = o3[1]; + break; + } + if (o3[0] === 6 && a.label < i[1]) { + a.label = i[1], i = o3; + break; + } + if (i && a.label < i[2]) { + a.label = i[2], a.ops.push(o3); + break; + } + i[2] && a.ops.pop(), a.trys.pop(); + continue; + } + o3 = e3.call(t3, a); + } catch (t4) { + o3 = [6, t4], n2 = 0; + } finally { + r3 = i = 0; + } + if (5 & o3[0]) + throw o3[1]; + return {value: o3[0] ? o3[1] : void 0, done: true}; + }([o2, s2]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.signTestDeploy = e2.getToSignMessageID = e2.createTestAccount = e2.createNewVault = e2.resetExistingVault = e2.hasCreatedVault = e2.forceDisconnect = e2.forceConnection = e2.disconnectFromSite = e2.sign = e2.getActivePublicKey = e2.getSelectedPublicKeyBase64 = e2.sendConnectionRequest = e2.isConnected = e2.getVersion = void 0, e2.getVersion = function() { + return r2(void 0, void 0, void 0, function() { + return n(this, function(t3) { + switch (t3.label) { + case 0: + return t3.trys.push([0, 2, , 3]), [4, window.casperlabsHelper.getVersion()]; + case 1: + return [2, t3.sent()]; + case 2: + return t3.sent(), [2, "<1.0.0"]; + case 3: + return [2]; + } + }); + }); + }, e2.isConnected = function() { + return r2(void 0, void 0, void 0, function() { + return n(this, function(t3) { + switch (t3.label) { + case 0: + return [4, window.casperlabsHelper.isConnected()]; + case 1: + return [2, t3.sent()]; + } + }); + }); + }, e2.sendConnectionRequest = function() { + return window.casperlabsHelper.requestConnection(); + }, e2.getSelectedPublicKeyBase64 = function() { + return window.casperlabsHelper.getSelectedPublicKeyBase64(); + }, e2.getActivePublicKey = function() { + return window.casperlabsHelper.getActivePublicKey(); + }, e2.sign = function(t3, e3, r3) { + return window.casperlabsHelper.sign(t3, e3, r3); + }, e2.disconnectFromSite = function() { + return window.casperlabsHelper.disconnectFromSite(); + }, e2.forceConnection = function() { + return window.signerTestingHelper.forceConnection(); + }, e2.forceDisconnect = function() { + return window.signerTestingHelper.forceDisconnect(); + }, e2.hasCreatedVault = function() { + return window.signerTestingHelper.hasCreatedVault(); + }, e2.resetExistingVault = function() { + return window.signerTestingHelper.resetExistingVault(); + }, e2.createNewVault = function(t3) { + return window.signerTestingHelper.createNewVault(t3); + }, e2.createTestAccount = function(t3, e3) { + return window.signerTestingHelper.createTestAccount(t3, e3); + }, e2.getToSignMessageID = function() { + return window.signerTestingHelper.getToSignMessageID(); + }, e2.signTestDeploy = function(t3) { + return window.signerTestingHelper.signTestDeploy(t3); + }; + }, 5778: function(t2, e2, r2) { + var n = this && this.__decorate || function(t3, e3, r3, n2) { + var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") + a2 = Reflect.decorate(t3, e3, r3, n2); + else + for (var s2 = t3.length - 1; s2 >= 0; s2--) + (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); + return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; + }, i = this && this.__metadata || function(t3, e3) { + if (typeof Reflect == "object" && typeof Reflect.metadata == "function") + return Reflect.metadata(t3, e3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.StoredValue = e2.ContractMetadataJson = e2.EraInfoJson = e2.SeigniorageAllocation = e2.DeployInfoJson = e2.TransferJson = void 0; + var o = r2(4546), a = r2(5050), s = function() { + function t3() { + } + return n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "name", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "key", void 0), n([o.jsonObject], t3); + }(), u = function() { + function t3() { + } + return n([o.jsonMember({name: "account_hash", constructor: String}), i("design:type", String)], t3.prototype, "accountHash", void 0), n([o.jsonMember({constructor: Number}), i("design:type", Number)], t3.prototype, "weight", void 0), n([o.jsonObject], t3); + }(), f = function() { + function t3() { + } + return n([o.jsonMember({constructor: Number}), i("design:type", Number)], t3.prototype, "deployment", void 0), n([o.jsonMember({name: "key_management", constructor: Number}), i("design:type", Number)], t3.prototype, "keyManagement", void 0), n([o.jsonObject], t3); + }(), c = function() { + function t3() { + } + return t3.prototype.accountHash = function() { + return this._accountHash; + }, n([o.jsonMember({name: "account_hash", constructor: String}), i("design:type", String)], t3.prototype, "_accountHash", void 0), n([o.jsonArrayMember(s, {name: "named_keys"}), i("design:type", Array)], t3.prototype, "namedKeys", void 0), n([o.jsonMember({name: "main_purse", constructor: String}), i("design:type", String)], t3.prototype, "mainPurse", void 0), n([o.jsonArrayMember(u, {name: "associated_keys"}), i("design:type", Array)], t3.prototype, "associatedKeys", void 0), n([o.jsonMember({name: "action_thresholds", constructor: f}), i("design:type", f)], t3.prototype, "actionThresholds", void 0), n([o.jsonObject], t3); + }(), h = function() { + function t3() { + } + return n([o.jsonMember({name: "deploy_hash", constructor: String}), i("design:type", String)], t3.prototype, "deployHash", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "from", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "source", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "target", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "gas", void 0), n([o.jsonMember({constructor: String, preserveNull: true}), i("design:type", Object)], t3.prototype, "id", void 0), n([o.jsonObject], t3); + }(); + e2.TransferJson = h; + var l = function() { + function t3() { + } + return n([o.jsonMember({name: "deploy_hash", constructor: String}), i("design:type", String)], t3.prototype, "deployHash", void 0), n([o.jsonArrayMember(String), i("design:type", Array)], t3.prototype, "transfers", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "from", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "source", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "gas", void 0), n([o.jsonObject], t3); + }(); + e2.DeployInfoJson = l; + var d = function() { + function t3() { + } + return n([o.jsonMember({name: "validator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "validatorPublicKey", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonObject], t3); + }(), p = function() { + function t3() { + } + return n([o.jsonMember({name: "delegator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "delegatorPublicKey", void 0), n([o.jsonMember({name: "validator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "validatorPublicKey", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonObject], t3); + }(), y = function() { + function t3() { + } + return n([o.jsonMember({constructor: d}), i("design:type", d)], t3.prototype, "Validator", void 0), n([o.jsonMember({constructor: p}), i("design:type", p)], t3.prototype, "Delegator", void 0), n([o.jsonObject], t3); + }(); + e2.SeigniorageAllocation = y; + var m = function() { + function t3() { + } + return n([o.jsonArrayMember(y, {name: "seigniorage_allocations"}), i("design:type", Array)], t3.prototype, "seigniorageAllocations", void 0), n([o.jsonObject], t3); + }(); + e2.EraInfoJson = m; + var b = function() { + function t3() { + } + return n([o.jsonMember({name: "contract_package_hash", constructor: String}), i("design:type", String)], t3.prototype, "contractPackageHash", void 0), n([o.jsonMember({name: "contract_wasm_hash", constructor: String}), i("design:type", String)], t3.prototype, "contractWasmHash", void 0), n([o.jsonMember({name: "protocol_version", constructor: String}), i("design:type", String)], t3.prototype, "protocolVersion", void 0), n([o.jsonObject], t3); + }(); + e2.ContractMetadataJson = b; + var g = function() { + function t3() { + } + return n([o.jsonMember({constructor: a.CLValue}), i("design:type", a.CLValue)], t3.prototype, "CLValue", void 0), n([o.jsonMember({constructor: c}), i("design:type", c)], t3.prototype, "Account", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "ContractWASM", void 0), n([o.jsonMember({constructor: b}), i("design:type", b)], t3.prototype, "Contract", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "ContractPackage", void 0), n([o.jsonMember({constructor: h}), i("design:type", h)], t3.prototype, "Transfer", void 0), n([o.jsonMember({constructor: l}), i("design:type", l)], t3.prototype, "DeployInfo", void 0), n([o.jsonMember({constructor: m}), i("design:type", m)], t3.prototype, "EraInfo", void 0), n([o.jsonObject], t3); + }(); + e2.StoredValue = g; + }, 3917: (t2, e2, r2) => { + var n = r2(8764).Buffer; + Object.defineProperty(e2, "__esModule", {value: true}), e2.toBytesStringList = e2.toBytesVecT = e2.toBytesBytesArray = e2.toBytesArrayU8 = e2.toBytesString = e2.toBytesU512 = e2.toBytesDeployHash = e2.toBytesU256 = e2.toBytesU128 = e2.toBytesI64 = e2.toBytesU64 = e2.toBytesU32 = e2.toBytesI32 = e2.toBytesU8 = e2.toBytesNumber = void 0; + var i = r2(2092), o = r2(2279), a = r2(3286), s = r2(5050); + function u(t3) { + return e2.toBytesNumber(32, false, t3); + } + function f(t3) { + var e3 = t3.map(function(t4) { + return t4.toBytes(); + }); + return e3.splice(0, 0, u(t3.length)), a.concat(e3); + } + e2.toBytesNumber = function(t3, e3, r3) { + var n2 = i.BigNumber.from(r3), s2 = o.MaxUint256.mask(t3); + if (e3) { + var u2 = s2.mask(t3 - 1); + if (n2.gt(u2) || n2.lt(u2.add(o.One).mul(o.NegativeOne))) + throw new Error("value out-of-bounds, value: " + r3); + } else if (n2.lt(o.Zero) || n2.gt(s2.mask(t3))) + throw new Error("value out-of-bounds, value: " + r3); + n2 = n2.toTwos(t3).mask(t3); + var f2 = a.arrayify(n2); + if (n2.gte(0)) { + if (t3 > 64) + return a.concat([f2, Uint8Array.from([f2.length])]).reverse(); + var c = t3 / 8; + return a.concat([f2.reverse(), new Uint8Array(c - f2.length)]); + } + return f2.reverse(); + }, e2.toBytesU8 = function(t3) { + return e2.toBytesNumber(8, false, t3); + }, e2.toBytesI32 = function(t3) { + return e2.toBytesNumber(32, true, t3); + }, e2.toBytesU32 = u, e2.toBytesU64 = function(t3) { + return e2.toBytesNumber(64, false, t3); + }, e2.toBytesI64 = function(t3) { + return e2.toBytesNumber(64, true, t3); + }, e2.toBytesU128 = function(t3) { + return e2.toBytesNumber(128, false, t3); + }, e2.toBytesU256 = function(t3) { + return e2.toBytesNumber(256, false, t3); + }, e2.toBytesDeployHash = function(t3) { + return t3; + }, e2.toBytesU512 = function(t3) { + return e2.toBytesNumber(512, false, t3); + }, e2.toBytesString = function(t3) { + var e3 = Uint8Array.from(n.from(t3)); + return a.concat([u(e3.byteLength), e3]); + }, e2.toBytesArrayU8 = function(t3) { + return a.concat([u(t3.length), t3]); + }, e2.toBytesBytesArray = function(t3) { + return t3; + }, e2.toBytesVecT = f, e2.toBytesStringList = function(t3) { + return f(t3.map(function(t4) { + return s.CLValue.string(t4); + })); + }; + }, 3915: function(t2, e2, r2) { + var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { + return e3[r3]; + }}); + } : function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; + }), i = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { + Object.defineProperty(t3, "default", {enumerable: true, value: e3}); + } : function(t3, e3) { + t3.default = e3; + }), o = this && this.__importStar || function(t3) { + if (t3 && t3.__esModule) + return t3; + var e3 = {}; + if (t3 != null) + for (var r3 in t3) + r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && n(e3, t3, r3); + return i(e3, t3), e3; + }, a = this && this.__exportStar || function(t3, e3) { + for (var r3 in t3) + r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.Signer = e2.DeployUtil = e2.Serialization = e2.Keys = e2.Contracts = void 0; + var s = o(r2(3492)); + e2.Contracts = s; + var u = o(r2(4922)); + e2.DeployUtil = u; + var f = o(r2(2964)); + e2.Keys = f; + var c = o(r2(165)); + e2.Serialization = c; + var h = o(r2(2896)); + e2.Signer = h, a(r2(5050), e2), a(r2(6349), e2), a(r2(3368), e2), a(r2(5371), e2); + }, 5371: function(t2, e2, r2) { + var n, i = this && this.__extends || (n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }, function(t3, e3) { + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + }); + Object.defineProperty(e2, "__esModule", {value: true}), e2.Option = void 0; + var o = r2(5050), a = r2(3286), s = function(t3) { + function e3(e4, r3) { + var n2 = t3.call(this) || this; + if (n2.t = e4, e4 === null) { + if (!r3) + throw new Error("You had to assign innerType for None"); + n2.innerType = r3; + } else + n2.innerType = e4.clType(); + return n2; + } + return i(e3, t3), e3.prototype.isNone = function() { + return this.t === null; + }, e3.prototype.isSome = function() { + return this.t !== null; + }, e3.prototype.getSome = function() { + if (!this.isSome()) + throw new Error("Value is None"); + return o.CLValue.fromT(this.t); + }, e3.prototype.toBytes = function() { + return this.t === null ? Uint8Array.from([0]) : a.concat([Uint8Array.from([1]), this.t.toBytes()]); + }, e3.prototype.clType = function() { + return o.CLTypeHelper.option(this.innerType); + }, e3.fromBytes = function(t4, r3) { + var n2 = o.U8.fromBytes(r3); + if (n2.hasError()) + return o.Result.Err(n2.error); + var i2 = n2.value().val.toNumber(); + if (i2 === 0) + return o.Result.Ok(new e3(null, t4.innerType), n2.remainder()); + if (i2 === 1) { + var a2 = o.fromBytesByCLType(t4.innerType, n2.remainder()); + return a2.hasError() ? o.Result.Err(a2.error) : o.Result.Ok(new e3(a2.value(), t4.innerType), a2.remainder()); + } + return o.Result.Err(o.FromBytesError.FormattingError); + }, e3; + }(o.CLTypedAndToBytes); + e2.Option = s; + }, 8132: function(t2, e2) { + var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o) { + function a(t4) { + try { + u(n2.next(t4)); + } catch (t5) { + o(t5); + } + } + function s(t4) { + try { + u(n2.throw(t4)); + } catch (t5) { + o(t5); + } + } + function u(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a, s); + } + u((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, n = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o, a = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { + return this; + }), o; + function s(o2) { + return function(s2) { + return function(o3) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o3[1])).done) + return i2; + switch (n2 = 0, i2 && (o3 = [2 & o3[0], i2.value]), o3[0]) { + case 0: + case 1: + i2 = o3; + break; + case 4: + return a.label++, {value: o3[1], done: false}; + case 5: + a.label++, n2 = o3[1], o3 = [0]; + continue; + case 7: + o3 = a.ops.pop(), a.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a.trys).length > 0 && i2[i2.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { + a = 0; + continue; + } + if (o3[0] === 3 && (!i2 || o3[1] > i2[0] && o3[1] < i2[3])) { + a.label = o3[1]; + break; + } + if (o3[0] === 6 && a.label < i2[1]) { + a.label = i2[1], i2 = o3; + break; + } + if (i2 && a.label < i2[2]) { + a.label = i2[2], a.ops.push(o3); + break; + } + i2[2] && a.ops.pop(), a.trys.pop(); + continue; + } + o3 = e3.call(t3, a); + } catch (t4) { + o3 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o3[0]) + throw o3[1]; + return {value: o3[0] ? o3[1] : void 0, done: true}; + }([o2, s2]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.BalanceServiceByJsonRPC = void 0; + var i = function() { + function t3(t4) { + this.casperService = t4, this.balanceUrefs = new Map(); + } + return t3.prototype.getAccountBalance = function(t4, e3) { + return r2(this, void 0, void 0, function() { + var r3, i2; + return n(this, function(n2) { + switch (n2.label) { + case 0: + return n2.trys.push([0, 5, , 6]), [4, this.casperService.getStateRootHash(t4)]; + case 1: + return r3 = n2.sent(), (i2 = this.balanceUrefs.get(e3.toAccountHex())) ? [3, 3] : [4, this.casperService.getAccountBalanceUrefByPublicKey(r3, e3)]; + case 2: + (i2 = n2.sent()) && this.balanceUrefs.set(e3.toAccountHex(), i2), n2.label = 3; + case 3: + return i2 ? [4, this.casperService.getAccountBalance(r3, i2)] : [2, void 0]; + case 4: + return [2, n2.sent()]; + case 5: + return n2.sent(), [2, void 0]; + case 6: + return [2]; + } + }); + }); + }, t3; + }(); + e2.BalanceServiceByJsonRPC = i; + }, 9693: function(t2, e2, r2) { + var n = this && this.__awaiter || function(t3, e3, r3, n2) { + return new (r3 || (r3 = Promise))(function(i2, o2) { + function a2(t4) { + try { + u2(n2.next(t4)); + } catch (t5) { + o2(t5); + } + } + function s2(t4) { + try { + u2(n2.throw(t4)); + } catch (t5) { + o2(t5); + } + } + function u2(t4) { + var e4; + t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { + t5(e4); + })).then(a2, s2); + } + u2((n2 = n2.apply(t3, e3 || [])).next()); + }); + }, i = this && this.__generator || function(t3, e3) { + var r3, n2, i2, o2, a2 = {label: 0, sent: function() { + if (1 & i2[0]) + throw i2[1]; + return i2[1]; + }, trys: [], ops: []}; + return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { + return this; + }), o2; + function s2(o3) { + return function(s3) { + return function(o4) { + if (r3) + throw new TypeError("Generator is already executing."); + for (; a2; ) + try { + if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) + return i2; + switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { + case 0: + case 1: + i2 = o4; + break; + case 4: + return a2.label++, {value: o4[1], done: false}; + case 5: + a2.label++, n2 = o4[1], o4 = [0]; + continue; + case 7: + o4 = a2.ops.pop(), a2.trys.pop(); + continue; + default: + if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { + a2 = 0; + continue; + } + if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { + a2.label = o4[1]; + break; + } + if (o4[0] === 6 && a2.label < i2[1]) { + a2.label = i2[1], i2 = o4; + break; + } + if (i2 && a2.label < i2[2]) { + a2.label = i2[2], a2.ops.push(o4); + break; + } + i2[2] && a2.ops.pop(), a2.trys.pop(); + continue; + } + o4 = e3.call(t3, a2); + } catch (t4) { + o4 = [6, t4], n2 = 0; + } finally { + r3 = i2 = 0; + } + if (5 & o4[0]) + throw o4[1]; + return {value: o4[0] ? o4[1] : void 0, done: true}; + }([o3, s3]); + }; + } + }; + Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperServiceByJsonRPC = void 0; + var o = r2(4927), a = r2(3607), s = r2(4922), u = r2(4546), f = r2(5778), c = r2(2092), h = function() { + function t3(t4) { + var e3 = new o.HTTPTransport(t4), r3 = new o.RequestManager([e3]); + this.client = new o.Client(r3); + } + return t3.prototype.getDeployInfo = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, this.client.request({method: "info_get_deploy", params: {deploy_hash: t4}})]; + case 1: + return [2, e3.sent()]; + } + }); + }); + }, t3.prototype.getBlockInfo = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, this.client.request({method: "chain_get_block", params: {block_identifier: {Hash: t4}}}).then(function(e4) { + if (e4.block !== null && e4.block.hash !== t4) + throw new Error("Returned block does not have a matching hash."); + return e4; + })]; + case 1: + return [2, e3.sent()]; + } + }); + }); + }, t3.prototype.getBlockInfoByHeight = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, this.client.request({method: "chain_get_block", params: {block_identifier: {Height: t4}}}).then(function(e4) { + if (e4.block !== null && e4.block.header.height !== t4) + throw new Error("Returned block does not have a matching height."); + return e4; + })]; + case 1: + return [2, e3.sent()]; + } + }); + }); + }, t3.prototype.getLatestBlockInfo = function() { + return n(this, void 0, void 0, function() { + return i(this, function(t4) { + switch (t4.label) { + case 0: + return [4, this.client.request({method: "chain_get_block"})]; + case 1: + return [2, t4.sent()]; + } + }); + }); + }, t3.prototype.getPeers = function() { + return n(this, void 0, void 0, function() { + return i(this, function(t4) { + switch (t4.label) { + case 0: + return [4, this.client.request({method: "info_get_peers"})]; + case 1: + return [2, t4.sent()]; + } + }); + }); + }, t3.prototype.getStatus = function() { + return n(this, void 0, void 0, function() { + return i(this, function(t4) { + switch (t4.label) { + case 0: + return [4, this.client.request({method: "info_get_status"})]; + case 1: + return [2, t4.sent()]; + } + }); + }); + }, t3.prototype.getValidatorsInfo = function() { + return n(this, void 0, void 0, function() { + return i(this, function(t4) { + switch (t4.label) { + case 0: + return [4, this.client.request({method: "state_get_auction_info"})]; + case 1: + return [2, t4.sent()]; + } + }); + }); + }, t3.prototype.getAccountBalanceUrefByPublicKeyHash = function(t4, e3) { + return n(this, void 0, void 0, function() { + return i(this, function(r3) { + switch (r3.label) { + case 0: + return [4, this.getBlockState(t4, "account-hash-" + e3, []).then(function(t5) { + return t5.Account; + })]; + case 1: + return [2, r3.sent().mainPurse]; + } + }); + }); + }, t3.prototype.getAccountBalanceUrefByPublicKey = function(t4, e3) { + return n(this, void 0, void 0, function() { + return i(this, function(r3) { + return [2, this.getAccountBalanceUrefByPublicKeyHash(t4, a.encodeBase16(e3.toAccountHash()))]; + }); + }); + }, t3.prototype.getAccountBalance = function(t4, e3) { + return n(this, void 0, void 0, function() { + return i(this, function(r3) { + switch (r3.label) { + case 0: + return [4, this.client.request({method: "state_get_balance", params: {state_root_hash: t4, purse_uref: e3}}).then(function(t5) { + return c.BigNumber.from(t5.balance_value); + })]; + case 1: + return [2, r3.sent()]; + } + }); + }); + }, t3.prototype.getStateRootHash = function(t4) { + return n(this, void 0, void 0, function() { + return i(this, function(e3) { + switch (e3.label) { + case 0: + return [4, this.client.request({method: "chain_get_state_root_hash", params: {block_hash: t4}}).then(function(t5) { + return t5.state_root_hash; + })]; + case 1: + return [2, e3.sent()]; + } + }); + }); + }, t3.prototype.getBlockState = function(t4, e3, r3) { + return n(this, void 0, void 0, function() { + var n2, o2; + return i(this, function(i2) { + switch (i2.label) { + case 0: + return [4, this.client.request({method: "state_get_item", params: {state_root_hash: t4, key: e3, path: r3}})]; + case 1: + return (n2 = i2.sent()).error ? [2, n2] : (o2 = n2.stored_value, [2, new u.TypedJSON(f.StoredValue).parse(o2)]); + } + }); + }); + }, t3.prototype.deploy = function(t4) { + return n(this, void 0, void 0, function() { + var e3; + return i(this, function(r3) { + switch (r3.label) { + case 0: + if ((e3 = a.DeployUtil.deploySizeInBytes(t4)) > 1048576) + throw Error("Deploy can not be send, because it's too large: " + e3 + " bytes. Max size is 1 megabyte."); + return [4, this.client.request({method: "account_put_deploy", params: s.deployToJson(t4)})]; + case 1: + return [2, r3.sent()]; + } + }); + }); + }, t3; + }(); + e2.CasperServiceByJsonRPC = h; + }, 1999: function(t2, e2, r2) { + var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { + return e3[r3]; + }}); + } : function(t3, e3, r3, n2) { + n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; + }), i = this && this.__exportStar || function(t3, e3) { + for (var r3 in t3) + r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); + }; + Object.defineProperty(e2, "__esModule", {value: true}), i(r2(9693), e2), i(r2(8132), e2); + }, 2831: (t2, e2, r2) => { + function n(t3) { + var e3 = String(t3); + if (e3 === "[object Object]") + try { + e3 = JSON.stringify(t3); + } catch (t4) { + } + return e3; + } + r2.r(e2), r2.d(e2, {Err: () => a, ErrImpl: () => o, None: () => f, Ok: () => u, OkImpl: () => s, Option: () => c, Result: () => i, Some: () => h}); + var i, o = function() { + function t3(e3) { + if (!(this instanceof t3)) + return new t3(e3); + this.ok = false, this.err = true, this.val = e3; + } + return t3.prototype[Symbol.iterator] = function() { + return {next: function() { + return {done: true, value: void 0}; + }}; + }, t3.prototype.else = function(t4) { + return t4; + }, t3.prototype.unwrapOr = function(t4) { + return t4; + }, t3.prototype.expect = function(t4) { + throw new Error(t4 + " - Error: " + n(this.val)); + }, t3.prototype.unwrap = function() { + throw new Error("Tried to unwrap Error: " + n(this.val)); + }, t3.prototype.map = function(t4) { + return this; + }, t3.prototype.andThen = function(t4) { + return this; + }, t3.prototype.mapErr = function(t4) { + return new a(t4(this.val)); + }, t3.prototype.toString = function() { + return "Err(" + n(this.val) + ")"; + }, t3.EMPTY = new t3(void 0), t3; + }(), a = o, s = function() { + function t3(e3) { + if (!(this instanceof t3)) + return new t3(e3); + this.ok = true, this.err = false, this.val = e3; + } + return t3.prototype[Symbol.iterator] = function() { + var t4 = Object(this.val); + return Symbol.iterator in t4 ? t4[Symbol.iterator]() : {next: function() { + return {done: true, value: void 0}; + }}; + }, t3.prototype.else = function(t4) { + return this.val; + }, t3.prototype.unwrapOr = function(t4) { + return this.val; + }, t3.prototype.expect = function(t4) { + return this.val; + }, t3.prototype.unwrap = function() { + return this.val; + }, t3.prototype.map = function(t4) { + return new u(t4(this.val)); + }, t3.prototype.andThen = function(t4) { + return t4(this.val); + }, t3.prototype.mapErr = function(t4) { + return this; + }, t3.prototype.safeUnwrap = function() { + return this.val; + }, t3.prototype.toString = function() { + return "Ok(" + n(this.val) + ")"; + }, t3.EMPTY = new t3(void 0), t3; + }(), u = s; + !function(t3) { + t3.all = function() { + for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) + t4[e3] = arguments[e3]; + for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { + var o2 = i2[n2]; + if (!o2.ok) + return o2; + r3.push(o2.val); + } + return new u(r3); + }, t3.any = function() { + for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) + t4[e3] = arguments[e3]; + for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { + var o2 = i2[n2]; + if (o2.ok) + return o2; + r3.push(o2.val); + } + return new a(r3); + }, t3.wrap = function(t4) { + try { + return new u(t4()); + } catch (t5) { + return new a(t5); + } + }, t3.wrapAsync = function(t4) { + try { + return t4().then(function(t5) { + return new u(t5); + }).catch(function(t5) { + return new a(t5); + }); + } catch (t5) { + return Promise.resolve(new a(t5)); + } + }, t3.isResult = function(t4) { + return t4 instanceof a || t4 instanceof u; + }; + }(i || (i = {})); + var f = new (function() { + function t3() { + this.some = false, this.none = true; + } + return t3.prototype[Symbol.iterator] = function() { + return {next: function() { + return {done: true, value: void 0}; + }}; + }, t3.prototype.unwrapOr = function(t4) { + return t4; + }, t3.prototype.expect = function(t4) { + throw new Error("" + t4); + }, t3.prototype.unwrap = function() { + throw new Error("Tried to unwrap None"); + }, t3.prototype.map = function(t4) { + return this; + }, t3.prototype.andThen = function(t4) { + return this; + }, t3.prototype.toString = function() { + return "None"; + }, t3; + }())(); + Object.freeze(f); + var c, h = function() { + function t3(e3) { + if (!(this instanceof t3)) + return new t3(e3); + this.some = true, this.none = false, this.val = e3; + } + return t3.prototype[Symbol.iterator] = function() { + var t4 = Object(this.val); + return Symbol.iterator in t4 ? t4[Symbol.iterator]() : {next: function() { + return {done: true, value: void 0}; + }}; + }, t3.prototype.unwrapOr = function(t4) { + return this.val; + }, t3.prototype.expect = function(t4) { + return this.val; + }, t3.prototype.unwrap = function() { + return this.val; + }, t3.prototype.map = function(t4) { + return h(t4(this.val)); + }, t3.prototype.andThen = function(t4) { + return t4(this.val); + }, t3.prototype.safeUnwrap = function() { + return this.val; + }, t3.prototype.toString = function() { + return "Some(" + n(this.val) + ")"; + }, t3.EMPTY = new t3(void 0), t3; + }(); + !function(t3) { + t3.all = function() { + for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) + t4[e3] = arguments[e3]; + for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { + var o2 = i2[n2]; + if (!o2.some) + return o2; + r3.push(o2.val); + } + return h(r3); + }, t3.any = function() { + for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) + t4[e3] = arguments[e3]; + for (var r3 = 0, n2 = t4; r3 < n2.length; r3++) { + var i2 = n2[r3]; + return i2.some, i2; + } + return f; + }, t3.isOption = function(t4) { + return t4 instanceof h || t4 === f; + }; + }(c || (c = {})); + }, 6811: (t2, e2, r2) => { + function n(t3) { + return new Uint8Array(t3); + } + function i(t3) { + return new Uint16Array(t3); + } + function o(t3) { + return new Uint32Array(t3); + } + function a(t3) { + return new Int32Array(t3); + } + function s(t3) { + return new Float64Array(t3); + } + function u(t3) { + if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t3)) + throw new TypeError("invalid base64 string"); + } + function f(t3) { + if (!/^(?:[A-Fa-f0-9]{2})+$/.test(t3)) + throw new TypeError("invalid hex string"); + } + r2.r(e2), r2.d(e2, {ByteArray: () => n, HalfArray: () => i, IntArray: () => a, NumArray: () => s, WordArray: () => o, _hash: () => mt, _onetimeauth: () => st, _randomBytes: () => A, _scalarMult: () => X, _scalarMult_base: () => Q, _verify_16: () => M, _verify_32: () => S, auth: () => Ct, auth_full: () => Kt, blake2b: () => Qt, blake2b_final: () => re, blake2b_init: () => te, blake2b_update: () => ee, blake2s: () => zt, blake2s_final: () => Ft, blake2s_init: () => qt, blake2s_update: () => Ht, box: () => ut, box_after: () => ct, box_before: () => ft, box_keyPair: () => dt, box_keyPair_fromSecretKey: () => pt, box_open: () => ht, box_open_after: () => lt, decodeBase64: () => p, decodeHex: () => g, decodeUTF8: () => l, encodeBase64: () => d, encodeHex: () => m, encodeUTF8: () => h, hash: () => yt, randomBytes: () => k, scalarMult: () => Z, scalarMult_base: () => Y, scalarbase: () => xt, scalarmult: () => Ot, sealedbox: () => le, sealedbox_open: () => de, secretbox: () => ot, secretbox_open: () => at, sign: () => wt, sign_detached: () => Mt, sign_detached_verify: () => St, sign_keyPair: () => Et, sign_keyPair_fromSecretKey: () => At, sign_keyPair_fromSeed: () => kt, sign_open: () => _t, validateBase64: () => u, validateHex: () => f, verify: () => E}); + var c = String.fromCharCode; + function h(t3) { + return decodeURIComponent(escape(c.apply(void 0, t3))); + } + function l(t3) { + if (typeof t3 != "string") + throw new TypeError("expected string"); + for (var e3 = unescape(encodeURIComponent(t3)), r3 = n(e3.length), i2 = 0; i2 < e3.length; i2++) + r3[i2] = e3.charCodeAt(i2); + return r3; + } + function d(t3) { + return btoa(c.apply(void 0, t3)); + } + function p(t3) { + u(t3); + for (var e3 = atob(t3), r3 = n(e3.length), i2 = 0; i2 < e3.length; i2++) + r3[i2] = e3.charCodeAt(i2); + return r3; + } + function y(t3) { + return t3 + (t3 < 10 ? 48 : 87); + } + function m(t3) { + for (var e3 = n(t3.length << 1), r3 = 0, i2 = void 0; r3 < t3.length; r3++) + e3[i2 = r3 << 1] = y(t3[r3] >> 8), e3[i2 + 1] = y(15 & t3[r3]); + return c.apply(void 0, e3); + } + function b(t3, e3) { + var r3 = t3.charCodeAt(e3); + return r3 - (r3 < 58 ? 48 : r3 < 71 ? 55 : 87); + } + function g(t3) { + f(t3); + for (var e3 = n(t3.length >> 1), r3 = 0; r3 < e3.length; r3 += 2) + e3[r3] = b(t3, r3) << 8 | b(t3, r3 + 1); + return e3; + } + function v(t3, e3) { + if (t3.length != 32) + throw new Error("bad key size"); + if (e3.length != 24) + throw new Error("bad nonce size"); + } + function w() { + for (var t3 = [], e3 = 0; e3 < arguments.length; e3++) + t3[e3] = arguments[e3]; + for (var r3 = 0, n2 = t3; r3 < n2.length; r3++) { + var i2 = n2[r3]; + if (!(i2 instanceof Uint8Array)) + throw new TypeError("unexpected type, use ByteArray"); + } + } + function _(t3, e3, r3, n2, i2) { + var o2, a2 = 0; + for (o2 = 0; o2 < i2; o2++) + a2 |= t3[e3 + o2] ^ r3[n2 + o2]; + return (1 & a2 - 1 >>> 8) - 1; + } + function M(t3, e3, r3, n2) { + return _(t3, e3, r3, n2, 16); + } + function S(t3, e3, r3, n2) { + return _(t3, e3, r3, n2, 32); + } + function E(t3, e3) { + return w(t3, e3), t3.length > 0 && e3.length > 0 && t3.length == e3.length && _(t3, 0, e3, 0, t3.length) == 0; + } + function A(t3, e3) { + for (var r3 = 0; r3 < e3; r3 += 65536) + crypto.getRandomValues(t3.subarray(r3, r3 + Math.min(e3 - r3, 65536))); + } + function k(t3) { + var e3 = n(t3); + return A(e3, t3), e3; + } + function B(t3) { + var e3 = s(16); + if (t3) + for (var r3 = 0; r3 < t3.length; r3++) + e3[r3] = t3[r3]; + return e3; + } + var T = n(16), x = n(32); + x[0] = 9; + var O = B(), R = B([1]), P = B([56129, 1]), I = B([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), j = B([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), U = B([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), N = B([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), C = B([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]); + function D(t3, e3, r3) { + for (var n2 = 0; n2 < 16; n2++) + t3[n2] = e3[n2] + r3[n2]; + } + function L(t3, e3, r3) { + for (var n2 = 0; n2 < 16; n2++) + t3[n2] = e3[n2] - r3[n2]; + } + function K(t3, e3, r3) { + var n2, i2, o2 = 0, a2 = 0, s2 = 0, u2 = 0, f2 = 0, c2 = 0, h2 = 0, l2 = 0, d2 = 0, p2 = 0, y2 = 0, m2 = 0, b2 = 0, g2 = 0, v2 = 0, w2 = 0, _2 = 0, M2 = 0, S2 = 0, E2 = 0, A2 = 0, k2 = 0, B2 = 0, T2 = 0, x2 = 0, O2 = 0, R2 = 0, P2 = 0, I2 = 0, j2 = 0, U2 = 0, N2 = r3[0], C2 = r3[1], D2 = r3[2], L2 = r3[3], K2 = r3[4], z2 = r3[5], q2 = r3[6], H2 = r3[7], F2 = r3[8], V2 = r3[9], W2 = r3[10], J2 = r3[11], $2 = r3[12], G2 = r3[13], Z2 = r3[14], Y2 = r3[15]; + o2 += (n2 = e3[0]) * N2, a2 += n2 * C2, s2 += n2 * D2, u2 += n2 * L2, f2 += n2 * K2, c2 += n2 * z2, h2 += n2 * q2, l2 += n2 * H2, d2 += n2 * F2, p2 += n2 * V2, y2 += n2 * W2, m2 += n2 * J2, b2 += n2 * $2, g2 += n2 * G2, v2 += n2 * Z2, w2 += n2 * Y2, a2 += (n2 = e3[1]) * N2, s2 += n2 * C2, u2 += n2 * D2, f2 += n2 * L2, c2 += n2 * K2, h2 += n2 * z2, l2 += n2 * q2, d2 += n2 * H2, p2 += n2 * F2, y2 += n2 * V2, m2 += n2 * W2, b2 += n2 * J2, g2 += n2 * $2, v2 += n2 * G2, w2 += n2 * Z2, _2 += n2 * Y2, s2 += (n2 = e3[2]) * N2, u2 += n2 * C2, f2 += n2 * D2, c2 += n2 * L2, h2 += n2 * K2, l2 += n2 * z2, d2 += n2 * q2, p2 += n2 * H2, y2 += n2 * F2, m2 += n2 * V2, b2 += n2 * W2, g2 += n2 * J2, v2 += n2 * $2, w2 += n2 * G2, _2 += n2 * Z2, M2 += n2 * Y2, u2 += (n2 = e3[3]) * N2, f2 += n2 * C2, c2 += n2 * D2, h2 += n2 * L2, l2 += n2 * K2, d2 += n2 * z2, p2 += n2 * q2, y2 += n2 * H2, m2 += n2 * F2, b2 += n2 * V2, g2 += n2 * W2, v2 += n2 * J2, w2 += n2 * $2, _2 += n2 * G2, M2 += n2 * Z2, S2 += n2 * Y2, f2 += (n2 = e3[4]) * N2, c2 += n2 * C2, h2 += n2 * D2, l2 += n2 * L2, d2 += n2 * K2, p2 += n2 * z2, y2 += n2 * q2, m2 += n2 * H2, b2 += n2 * F2, g2 += n2 * V2, v2 += n2 * W2, w2 += n2 * J2, _2 += n2 * $2, M2 += n2 * G2, S2 += n2 * Z2, E2 += n2 * Y2, c2 += (n2 = e3[5]) * N2, h2 += n2 * C2, l2 += n2 * D2, d2 += n2 * L2, p2 += n2 * K2, y2 += n2 * z2, m2 += n2 * q2, b2 += n2 * H2, g2 += n2 * F2, v2 += n2 * V2, w2 += n2 * W2, _2 += n2 * J2, M2 += n2 * $2, S2 += n2 * G2, E2 += n2 * Z2, A2 += n2 * Y2, h2 += (n2 = e3[6]) * N2, l2 += n2 * C2, d2 += n2 * D2, p2 += n2 * L2, y2 += n2 * K2, m2 += n2 * z2, b2 += n2 * q2, g2 += n2 * H2, v2 += n2 * F2, w2 += n2 * V2, _2 += n2 * W2, M2 += n2 * J2, S2 += n2 * $2, E2 += n2 * G2, A2 += n2 * Z2, k2 += n2 * Y2, l2 += (n2 = e3[7]) * N2, d2 += n2 * C2, p2 += n2 * D2, y2 += n2 * L2, m2 += n2 * K2, b2 += n2 * z2, g2 += n2 * q2, v2 += n2 * H2, w2 += n2 * F2, _2 += n2 * V2, M2 += n2 * W2, S2 += n2 * J2, E2 += n2 * $2, A2 += n2 * G2, k2 += n2 * Z2, B2 += n2 * Y2, d2 += (n2 = e3[8]) * N2, p2 += n2 * C2, y2 += n2 * D2, m2 += n2 * L2, b2 += n2 * K2, g2 += n2 * z2, v2 += n2 * q2, w2 += n2 * H2, _2 += n2 * F2, M2 += n2 * V2, S2 += n2 * W2, E2 += n2 * J2, A2 += n2 * $2, k2 += n2 * G2, B2 += n2 * Z2, T2 += n2 * Y2, p2 += (n2 = e3[9]) * N2, y2 += n2 * C2, m2 += n2 * D2, b2 += n2 * L2, g2 += n2 * K2, v2 += n2 * z2, w2 += n2 * q2, _2 += n2 * H2, M2 += n2 * F2, S2 += n2 * V2, E2 += n2 * W2, A2 += n2 * J2, k2 += n2 * $2, B2 += n2 * G2, T2 += n2 * Z2, x2 += n2 * Y2, y2 += (n2 = e3[10]) * N2, m2 += n2 * C2, b2 += n2 * D2, g2 += n2 * L2, v2 += n2 * K2, w2 += n2 * z2, _2 += n2 * q2, M2 += n2 * H2, S2 += n2 * F2, E2 += n2 * V2, A2 += n2 * W2, k2 += n2 * J2, B2 += n2 * $2, T2 += n2 * G2, x2 += n2 * Z2, O2 += n2 * Y2, m2 += (n2 = e3[11]) * N2, b2 += n2 * C2, g2 += n2 * D2, v2 += n2 * L2, w2 += n2 * K2, _2 += n2 * z2, M2 += n2 * q2, S2 += n2 * H2, E2 += n2 * F2, A2 += n2 * V2, k2 += n2 * W2, B2 += n2 * J2, T2 += n2 * $2, x2 += n2 * G2, O2 += n2 * Z2, R2 += n2 * Y2, b2 += (n2 = e3[12]) * N2, g2 += n2 * C2, v2 += n2 * D2, w2 += n2 * L2, _2 += n2 * K2, M2 += n2 * z2, S2 += n2 * q2, E2 += n2 * H2, A2 += n2 * F2, k2 += n2 * V2, B2 += n2 * W2, T2 += n2 * J2, x2 += n2 * $2, O2 += n2 * G2, R2 += n2 * Z2, P2 += n2 * Y2, g2 += (n2 = e3[13]) * N2, v2 += n2 * C2, w2 += n2 * D2, _2 += n2 * L2, M2 += n2 * K2, S2 += n2 * z2, E2 += n2 * q2, A2 += n2 * H2, k2 += n2 * F2, B2 += n2 * V2, T2 += n2 * W2, x2 += n2 * J2, O2 += n2 * $2, R2 += n2 * G2, P2 += n2 * Z2, I2 += n2 * Y2, v2 += (n2 = e3[14]) * N2, w2 += n2 * C2, _2 += n2 * D2, M2 += n2 * L2, S2 += n2 * K2, E2 += n2 * z2, A2 += n2 * q2, k2 += n2 * H2, B2 += n2 * F2, T2 += n2 * V2, x2 += n2 * W2, O2 += n2 * J2, R2 += n2 * $2, P2 += n2 * G2, I2 += n2 * Z2, j2 += n2 * Y2, w2 += (n2 = e3[15]) * N2, a2 += 38 * (M2 += n2 * D2), s2 += 38 * (S2 += n2 * L2), u2 += 38 * (E2 += n2 * K2), f2 += 38 * (A2 += n2 * z2), c2 += 38 * (k2 += n2 * q2), h2 += 38 * (B2 += n2 * H2), l2 += 38 * (T2 += n2 * F2), d2 += 38 * (x2 += n2 * V2), p2 += 38 * (O2 += n2 * W2), y2 += 38 * (R2 += n2 * J2), m2 += 38 * (P2 += n2 * $2), b2 += 38 * (I2 += n2 * G2), g2 += 38 * (j2 += n2 * Z2), v2 += 38 * (U2 += n2 * Y2), o2 = (n2 = (o2 += 38 * (_2 += n2 * C2)) + (i2 = 1) + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), a2 = (n2 = a2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), s2 = (n2 = s2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), u2 = (n2 = u2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), f2 = (n2 = f2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), c2 = (n2 = c2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), h2 = (n2 = h2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), l2 = (n2 = l2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), d2 = (n2 = d2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), p2 = (n2 = p2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), y2 = (n2 = y2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), m2 = (n2 = m2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), b2 = (n2 = b2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), g2 = (n2 = g2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), v2 = (n2 = v2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), w2 = (n2 = w2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), o2 = (n2 = (o2 += i2 - 1 + 37 * (i2 - 1)) + (i2 = 1) + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), a2 = (n2 = a2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), s2 = (n2 = s2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), u2 = (n2 = u2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), f2 = (n2 = f2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), c2 = (n2 = c2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), h2 = (n2 = h2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), l2 = (n2 = l2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), d2 = (n2 = d2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), p2 = (n2 = p2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), y2 = (n2 = y2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), m2 = (n2 = m2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), b2 = (n2 = b2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), g2 = (n2 = g2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), v2 = (n2 = v2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), w2 = (n2 = w2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), o2 += i2 - 1 + 37 * (i2 - 1), t3[0] = o2, t3[1] = a2, t3[2] = s2, t3[3] = u2, t3[4] = f2, t3[5] = c2, t3[6] = h2, t3[7] = l2, t3[8] = d2, t3[9] = p2, t3[10] = y2, t3[11] = m2, t3[12] = b2, t3[13] = g2, t3[14] = v2, t3[15] = w2; + } + function z(t3, e3) { + K(t3, e3, e3); + } + function q(t3, e3) { + for (var r3 = 0; r3 < 16; r3++) + t3[r3] = 0 | e3[r3]; + } + function H(t3) { + var e3, r3, n2 = 1; + for (e3 = 0; e3 < 16; e3++) + r3 = t3[e3] + n2 + 65535, n2 = Math.floor(r3 / 65536), t3[e3] = r3 - 65536 * n2; + t3[0] += n2 - 1 + 37 * (n2 - 1); + } + function F(t3, e3, r3) { + for (var n2, i2 = ~(r3 - 1), o2 = 0; o2 < 16; o2++) + n2 = i2 & (t3[o2] ^ e3[o2]), t3[o2] ^= n2, e3[o2] ^= n2; + } + function V(t3, e3) { + var r3, n2, i2, o2 = B(), a2 = B(); + for (r3 = 0; r3 < 16; r3++) + a2[r3] = e3[r3]; + for (H(a2), H(a2), H(a2), n2 = 0; n2 < 2; n2++) { + for (o2[0] = a2[0] - 65517, r3 = 1; r3 < 15; r3++) + o2[r3] = a2[r3] - 65535 - (o2[r3 - 1] >> 16 & 1), o2[r3 - 1] &= 65535; + o2[15] = a2[15] - 32767 - (o2[14] >> 16 & 1), i2 = o2[15] >> 16 & 1, o2[14] &= 65535, F(a2, o2, 1 - i2); + } + for (r3 = 0; r3 < 16; r3++) + t3[2 * r3] = 255 & a2[r3], t3[2 * r3 + 1] = a2[r3] >> 8; + } + function W(t3, e3) { + var r3 = n(32), i2 = n(32); + return V(r3, t3), V(i2, e3), S(r3, 0, i2, 0); + } + function J(t3) { + var e3 = n(32); + return V(e3, t3), 1 & e3[0]; + } + function $(t3, e3) { + for (var r3 = 0; r3 < 16; r3++) + t3[r3] = e3[2 * r3] + (e3[2 * r3 + 1] << 8); + t3[15] &= 32767; + } + function G(t3, e3) { + var r3, n2 = B(); + for (r3 = 0; r3 < 16; r3++) + n2[r3] = e3[r3]; + for (r3 = 253; r3 >= 0; r3--) + z(n2, n2), r3 !== 2 && r3 !== 4 && K(n2, n2, e3); + for (r3 = 0; r3 < 16; r3++) + t3[r3] = n2[r3]; + } + function Z(t3, e3) { + if (w(t3, e3), t3.length !== 32) + throw new Error("bad n size"); + if (e3.length !== 32) + throw new Error("bad p size"); + var r3 = n(32); + return X(r3, t3, e3), r3; + } + function Y(t3) { + if (w(t3), t3.length !== 32) + throw new Error("bad n size"); + var e3 = n(32); + return Q(e3, t3), e3; + } + function X(t3, e3, r3) { + var i2, o2, a2 = n(32), u2 = s(80), f2 = B(), c2 = B(), h2 = B(), l2 = B(), d2 = B(), p2 = B(); + for (o2 = 0; o2 < 31; o2++) + a2[o2] = e3[o2]; + for (a2[31] = 127 & e3[31] | 64, a2[0] &= 248, $(u2, r3), o2 = 0; o2 < 16; o2++) + c2[o2] = u2[o2], l2[o2] = f2[o2] = h2[o2] = 0; + for (f2[0] = l2[0] = 1, o2 = 254; o2 >= 0; --o2) + F(f2, c2, i2 = a2[o2 >>> 3] >>> (7 & o2) & 1), F(h2, l2, i2), D(d2, f2, h2), L(f2, f2, h2), D(h2, c2, l2), L(c2, c2, l2), z(l2, d2), z(p2, f2), K(f2, h2, f2), K(h2, c2, d2), D(d2, f2, h2), L(f2, f2, h2), z(c2, f2), L(h2, l2, p2), K(f2, h2, P), D(f2, f2, l2), K(h2, h2, f2), K(f2, l2, p2), K(l2, c2, u2), z(c2, d2), F(f2, c2, i2), F(h2, l2, i2); + for (o2 = 0; o2 < 16; o2++) + u2[o2 + 16] = f2[o2], u2[o2 + 32] = h2[o2], u2[o2 + 48] = c2[o2], u2[o2 + 64] = l2[o2]; + var y2 = u2.subarray(32), m2 = u2.subarray(16); + return G(y2, y2), K(m2, m2, y2), V(t3, m2), 0; + } + function Q(t3, e3) { + return X(t3, e3, x); + } + function tt(t3, e3, r3, n2) { + for (var i2, o2 = 255 & n2[0] | (255 & n2[1]) << 8 | (255 & n2[2]) << 16 | (255 & n2[3]) << 24, a2 = 255 & r3[0] | (255 & r3[1]) << 8 | (255 & r3[2]) << 16 | (255 & r3[3]) << 24, s2 = 255 & r3[4] | (255 & r3[5]) << 8 | (255 & r3[6]) << 16 | (255 & r3[7]) << 24, u2 = 255 & r3[8] | (255 & r3[9]) << 8 | (255 & r3[10]) << 16 | (255 & r3[11]) << 24, f2 = 255 & r3[12] | (255 & r3[13]) << 8 | (255 & r3[14]) << 16 | (255 & r3[15]) << 24, c2 = 255 & n2[4] | (255 & n2[5]) << 8 | (255 & n2[6]) << 16 | (255 & n2[7]) << 24, h2 = 255 & e3[0] | (255 & e3[1]) << 8 | (255 & e3[2]) << 16 | (255 & e3[3]) << 24, l2 = 255 & e3[4] | (255 & e3[5]) << 8 | (255 & e3[6]) << 16 | (255 & e3[7]) << 24, d2 = 255 & e3[8] | (255 & e3[9]) << 8 | (255 & e3[10]) << 16 | (255 & e3[11]) << 24, p2 = 255 & e3[12] | (255 & e3[13]) << 8 | (255 & e3[14]) << 16 | (255 & e3[15]) << 24, y2 = 255 & n2[8] | (255 & n2[9]) << 8 | (255 & n2[10]) << 16 | (255 & n2[11]) << 24, m2 = 255 & r3[16] | (255 & r3[17]) << 8 | (255 & r3[18]) << 16 | (255 & r3[19]) << 24, b2 = 255 & r3[20] | (255 & r3[21]) << 8 | (255 & r3[22]) << 16 | (255 & r3[23]) << 24, g2 = 255 & r3[24] | (255 & r3[25]) << 8 | (255 & r3[26]) << 16 | (255 & r3[27]) << 24, v2 = 255 & r3[28] | (255 & r3[29]) << 8 | (255 & r3[30]) << 16 | (255 & r3[31]) << 24, w2 = 255 & n2[12] | (255 & n2[13]) << 8 | (255 & n2[14]) << 16 | (255 & n2[15]) << 24, _2 = o2, M2 = a2, S2 = s2, E2 = u2, A2 = f2, k2 = c2, B2 = h2, T2 = l2, x2 = d2, O2 = p2, R2 = y2, P2 = m2, I2 = b2, j2 = g2, U2 = v2, N2 = w2, C2 = 0; C2 < 20; C2 += 2) + _2 ^= (i2 = (I2 ^= (i2 = (x2 ^= (i2 = (A2 ^= (i2 = _2 + I2 | 0) << 7 | i2 >>> 25) + _2 | 0) << 9 | i2 >>> 23) + A2 | 0) << 13 | i2 >>> 19) + x2 | 0) << 18 | i2 >>> 14, k2 ^= (i2 = (M2 ^= (i2 = (j2 ^= (i2 = (O2 ^= (i2 = k2 + M2 | 0) << 7 | i2 >>> 25) + k2 | 0) << 9 | i2 >>> 23) + O2 | 0) << 13 | i2 >>> 19) + j2 | 0) << 18 | i2 >>> 14, R2 ^= (i2 = (B2 ^= (i2 = (S2 ^= (i2 = (U2 ^= (i2 = R2 + B2 | 0) << 7 | i2 >>> 25) + R2 | 0) << 9 | i2 >>> 23) + U2 | 0) << 13 | i2 >>> 19) + S2 | 0) << 18 | i2 >>> 14, N2 ^= (i2 = (P2 ^= (i2 = (T2 ^= (i2 = (E2 ^= (i2 = N2 + P2 | 0) << 7 | i2 >>> 25) + N2 | 0) << 9 | i2 >>> 23) + E2 | 0) << 13 | i2 >>> 19) + T2 | 0) << 18 | i2 >>> 14, _2 ^= (i2 = (E2 ^= (i2 = (S2 ^= (i2 = (M2 ^= (i2 = _2 + E2 | 0) << 7 | i2 >>> 25) + _2 | 0) << 9 | i2 >>> 23) + M2 | 0) << 13 | i2 >>> 19) + S2 | 0) << 18 | i2 >>> 14, k2 ^= (i2 = (A2 ^= (i2 = (T2 ^= (i2 = (B2 ^= (i2 = k2 + A2 | 0) << 7 | i2 >>> 25) + k2 | 0) << 9 | i2 >>> 23) + B2 | 0) << 13 | i2 >>> 19) + T2 | 0) << 18 | i2 >>> 14, R2 ^= (i2 = (O2 ^= (i2 = (x2 ^= (i2 = (P2 ^= (i2 = R2 + O2 | 0) << 7 | i2 >>> 25) + R2 | 0) << 9 | i2 >>> 23) + P2 | 0) << 13 | i2 >>> 19) + x2 | 0) << 18 | i2 >>> 14, N2 ^= (i2 = (U2 ^= (i2 = (j2 ^= (i2 = (I2 ^= (i2 = N2 + U2 | 0) << 7 | i2 >>> 25) + N2 | 0) << 9 | i2 >>> 23) + I2 | 0) << 13 | i2 >>> 19) + j2 | 0) << 18 | i2 >>> 14; + _2 = _2 + o2 | 0, M2 = M2 + a2 | 0, S2 = S2 + s2 | 0, E2 = E2 + u2 | 0, A2 = A2 + f2 | 0, k2 = k2 + c2 | 0, B2 = B2 + h2 | 0, T2 = T2 + l2 | 0, x2 = x2 + d2 | 0, O2 = O2 + p2 | 0, R2 = R2 + y2 | 0, P2 = P2 + m2 | 0, I2 = I2 + b2 | 0, j2 = j2 + g2 | 0, U2 = U2 + v2 | 0, N2 = N2 + w2 | 0, t3[0] = _2 >>> 0 & 255, t3[1] = _2 >>> 8 & 255, t3[2] = _2 >>> 16 & 255, t3[3] = _2 >>> 24 & 255, t3[4] = M2 >>> 0 & 255, t3[5] = M2 >>> 8 & 255, t3[6] = M2 >>> 16 & 255, t3[7] = M2 >>> 24 & 255, t3[8] = S2 >>> 0 & 255, t3[9] = S2 >>> 8 & 255, t3[10] = S2 >>> 16 & 255, t3[11] = S2 >>> 24 & 255, t3[12] = E2 >>> 0 & 255, t3[13] = E2 >>> 8 & 255, t3[14] = E2 >>> 16 & 255, t3[15] = E2 >>> 24 & 255, t3[16] = A2 >>> 0 & 255, t3[17] = A2 >>> 8 & 255, t3[18] = A2 >>> 16 & 255, t3[19] = A2 >>> 24 & 255, t3[20] = k2 >>> 0 & 255, t3[21] = k2 >>> 8 & 255, t3[22] = k2 >>> 16 & 255, t3[23] = k2 >>> 24 & 255, t3[24] = B2 >>> 0 & 255, t3[25] = B2 >>> 8 & 255, t3[26] = B2 >>> 16 & 255, t3[27] = B2 >>> 24 & 255, t3[28] = T2 >>> 0 & 255, t3[29] = T2 >>> 8 & 255, t3[30] = T2 >>> 16 & 255, t3[31] = T2 >>> 24 & 255, t3[32] = x2 >>> 0 & 255, t3[33] = x2 >>> 8 & 255, t3[34] = x2 >>> 16 & 255, t3[35] = x2 >>> 24 & 255, t3[36] = O2 >>> 0 & 255, t3[37] = O2 >>> 8 & 255, t3[38] = O2 >>> 16 & 255, t3[39] = O2 >>> 24 & 255, t3[40] = R2 >>> 0 & 255, t3[41] = R2 >>> 8 & 255, t3[42] = R2 >>> 16 & 255, t3[43] = R2 >>> 24 & 255, t3[44] = P2 >>> 0 & 255, t3[45] = P2 >>> 8 & 255, t3[46] = P2 >>> 16 & 255, t3[47] = P2 >>> 24 & 255, t3[48] = I2 >>> 0 & 255, t3[49] = I2 >>> 8 & 255, t3[50] = I2 >>> 16 & 255, t3[51] = I2 >>> 24 & 255, t3[52] = j2 >>> 0 & 255, t3[53] = j2 >>> 8 & 255, t3[54] = j2 >>> 16 & 255, t3[55] = j2 >>> 24 & 255, t3[56] = U2 >>> 0 & 255, t3[57] = U2 >>> 8 & 255, t3[58] = U2 >>> 16 & 255, t3[59] = U2 >>> 24 & 255, t3[60] = N2 >>> 0 & 255, t3[61] = N2 >>> 8 & 255, t3[62] = N2 >>> 16 & 255, t3[63] = N2 >>> 24 & 255; + } + function et(t3, e3, r3, n2) { + for (var i2, o2 = 255 & n2[0] | (255 & n2[1]) << 8 | (255 & n2[2]) << 16 | (255 & n2[3]) << 24, a2 = 255 & r3[0] | (255 & r3[1]) << 8 | (255 & r3[2]) << 16 | (255 & r3[3]) << 24, s2 = 255 & r3[4] | (255 & r3[5]) << 8 | (255 & r3[6]) << 16 | (255 & r3[7]) << 24, u2 = 255 & r3[8] | (255 & r3[9]) << 8 | (255 & r3[10]) << 16 | (255 & r3[11]) << 24, f2 = 255 & r3[12] | (255 & r3[13]) << 8 | (255 & r3[14]) << 16 | (255 & r3[15]) << 24, c2 = 255 & n2[4] | (255 & n2[5]) << 8 | (255 & n2[6]) << 16 | (255 & n2[7]) << 24, h2 = 255 & e3[0] | (255 & e3[1]) << 8 | (255 & e3[2]) << 16 | (255 & e3[3]) << 24, l2 = 255 & e3[4] | (255 & e3[5]) << 8 | (255 & e3[6]) << 16 | (255 & e3[7]) << 24, d2 = 255 & e3[8] | (255 & e3[9]) << 8 | (255 & e3[10]) << 16 | (255 & e3[11]) << 24, p2 = 255 & e3[12] | (255 & e3[13]) << 8 | (255 & e3[14]) << 16 | (255 & e3[15]) << 24, y2 = 255 & n2[8] | (255 & n2[9]) << 8 | (255 & n2[10]) << 16 | (255 & n2[11]) << 24, m2 = 255 & r3[16] | (255 & r3[17]) << 8 | (255 & r3[18]) << 16 | (255 & r3[19]) << 24, b2 = 255 & r3[20] | (255 & r3[21]) << 8 | (255 & r3[22]) << 16 | (255 & r3[23]) << 24, g2 = 255 & r3[24] | (255 & r3[25]) << 8 | (255 & r3[26]) << 16 | (255 & r3[27]) << 24, v2 = 255 & r3[28] | (255 & r3[29]) << 8 | (255 & r3[30]) << 16 | (255 & r3[31]) << 24, w2 = 255 & n2[12] | (255 & n2[13]) << 8 | (255 & n2[14]) << 16 | (255 & n2[15]) << 24, _2 = 0; _2 < 20; _2 += 2) + o2 ^= (i2 = (b2 ^= (i2 = (d2 ^= (i2 = (f2 ^= (i2 = o2 + b2 | 0) << 7 | i2 >>> 25) + o2 | 0) << 9 | i2 >>> 23) + f2 | 0) << 13 | i2 >>> 19) + d2 | 0) << 18 | i2 >>> 14, c2 ^= (i2 = (a2 ^= (i2 = (g2 ^= (i2 = (p2 ^= (i2 = c2 + a2 | 0) << 7 | i2 >>> 25) + c2 | 0) << 9 | i2 >>> 23) + p2 | 0) << 13 | i2 >>> 19) + g2 | 0) << 18 | i2 >>> 14, y2 ^= (i2 = (h2 ^= (i2 = (s2 ^= (i2 = (v2 ^= (i2 = y2 + h2 | 0) << 7 | i2 >>> 25) + y2 | 0) << 9 | i2 >>> 23) + v2 | 0) << 13 | i2 >>> 19) + s2 | 0) << 18 | i2 >>> 14, w2 ^= (i2 = (m2 ^= (i2 = (l2 ^= (i2 = (u2 ^= (i2 = w2 + m2 | 0) << 7 | i2 >>> 25) + w2 | 0) << 9 | i2 >>> 23) + u2 | 0) << 13 | i2 >>> 19) + l2 | 0) << 18 | i2 >>> 14, o2 ^= (i2 = (u2 ^= (i2 = (s2 ^= (i2 = (a2 ^= (i2 = o2 + u2 | 0) << 7 | i2 >>> 25) + o2 | 0) << 9 | i2 >>> 23) + a2 | 0) << 13 | i2 >>> 19) + s2 | 0) << 18 | i2 >>> 14, c2 ^= (i2 = (f2 ^= (i2 = (l2 ^= (i2 = (h2 ^= (i2 = c2 + f2 | 0) << 7 | i2 >>> 25) + c2 | 0) << 9 | i2 >>> 23) + h2 | 0) << 13 | i2 >>> 19) + l2 | 0) << 18 | i2 >>> 14, y2 ^= (i2 = (p2 ^= (i2 = (d2 ^= (i2 = (m2 ^= (i2 = y2 + p2 | 0) << 7 | i2 >>> 25) + y2 | 0) << 9 | i2 >>> 23) + m2 | 0) << 13 | i2 >>> 19) + d2 | 0) << 18 | i2 >>> 14, w2 ^= (i2 = (v2 ^= (i2 = (g2 ^= (i2 = (b2 ^= (i2 = w2 + v2 | 0) << 7 | i2 >>> 25) + w2 | 0) << 9 | i2 >>> 23) + b2 | 0) << 13 | i2 >>> 19) + g2 | 0) << 18 | i2 >>> 14; + t3[0] = o2 >>> 0 & 255, t3[1] = o2 >>> 8 & 255, t3[2] = o2 >>> 16 & 255, t3[3] = o2 >>> 24 & 255, t3[4] = c2 >>> 0 & 255, t3[5] = c2 >>> 8 & 255, t3[6] = c2 >>> 16 & 255, t3[7] = c2 >>> 24 & 255, t3[8] = y2 >>> 0 & 255, t3[9] = y2 >>> 8 & 255, t3[10] = y2 >>> 16 & 255, t3[11] = y2 >>> 24 & 255, t3[12] = w2 >>> 0 & 255, t3[13] = w2 >>> 8 & 255, t3[14] = w2 >>> 16 & 255, t3[15] = w2 >>> 24 & 255, t3[16] = h2 >>> 0 & 255, t3[17] = h2 >>> 8 & 255, t3[18] = h2 >>> 16 & 255, t3[19] = h2 >>> 24 & 255, t3[20] = l2 >>> 0 & 255, t3[21] = l2 >>> 8 & 255, t3[22] = l2 >>> 16 & 255, t3[23] = l2 >>> 24 & 255, t3[24] = d2 >>> 0 & 255, t3[25] = d2 >>> 8 & 255, t3[26] = d2 >>> 16 & 255, t3[27] = d2 >>> 24 & 255, t3[28] = p2 >>> 0 & 255, t3[29] = p2 >>> 8 & 255, t3[30] = p2 >>> 16 & 255, t3[31] = p2 >>> 24 & 255; + } + var rt = n([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); + function nt(t3, e3, r3, i2, o2, a2, s2) { + var u2 = n(32), f2 = n(8); + et(u2, a2, s2, rt); + for (var c2 = 0; c2 < 8; c2++) + f2[c2] = a2[c2 + 16]; + return function(t4, e4, r4, i3, o3, a3, s3) { + var u3, f3, c3 = n(16), h2 = n(64); + for (f3 = 0; f3 < 16; f3++) + c3[f3] = 0; + for (f3 = 0; f3 < 8; f3++) + c3[f3] = a3[f3]; + for (; o3 >= 64; ) { + for (tt(h2, c3, s3, rt), f3 = 0; f3 < 64; f3++) + t4[e4 + f3] = r4[i3 + f3] ^ h2[f3]; + for (u3 = 1, f3 = 8; f3 < 16; f3++) + u3 = u3 + (255 & c3[f3]) | 0, c3[f3] = 255 & u3, u3 >>>= 8; + o3 -= 64, e4 += 64, i3 += 64; + } + if (o3 > 0) + for (tt(h2, c3, s3, rt), f3 = 0; f3 < o3; f3++) + t4[e4 + f3] = r4[i3 + f3] ^ h2[f3]; + return 0; + }(t3, e3, r3, i2, o2, f2, u2); + } + function it(t3, e3, r3, n2) { + for (var i2, o2, a2, s2, u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2, w2, _2, M2, S2 = t3.fin ? 0 : 2048, E2 = t3.h, A2 = t3.r, k2 = E2[0], B2 = E2[1], T2 = E2[2], x2 = E2[3], O2 = E2[4], R2 = E2[5], P2 = E2[6], I2 = E2[7], j2 = E2[8], U2 = E2[9], N2 = A2[0], C2 = A2[1], D2 = A2[2], L2 = A2[3], K2 = A2[4], z2 = A2[5], q2 = A2[6], H2 = A2[7], F2 = A2[8], V2 = A2[9]; n2 >= 16; ) + d2 = l2 = 0, d2 += (k2 += 8191 & (i2 = 255 & e3[r3 + 0] | (255 & e3[r3 + 1]) << 8)) * N2, d2 += (B2 += 8191 & (i2 >>> 13 | (o2 = 255 & e3[r3 + 2] | (255 & e3[r3 + 3]) << 8) << 3)) * (5 * V2), d2 += (T2 += 8191 & (o2 >>> 10 | (a2 = 255 & e3[r3 + 4] | (255 & e3[r3 + 5]) << 8) << 6)) * (5 * F2), d2 += (x2 += 8191 & (a2 >>> 7 | (s2 = 255 & e3[r3 + 6] | (255 & e3[r3 + 7]) << 8) << 9)) * (5 * H2), l2 = (d2 += (O2 += 8191 & (s2 >>> 4 | (u2 = 255 & e3[r3 + 8] | (255 & e3[r3 + 9]) << 8) << 12)) * (5 * q2)) >>> 13, d2 &= 8191, d2 += (R2 += u2 >>> 1 & 8191) * (5 * z2), d2 += (P2 += 8191 & (u2 >>> 14 | (f2 = 255 & e3[r3 + 10] | (255 & e3[r3 + 11]) << 8) << 2)) * (5 * K2), d2 += (I2 += 8191 & (f2 >>> 11 | (c2 = 255 & e3[r3 + 12] | (255 & e3[r3 + 13]) << 8) << 5)) * (5 * L2), d2 += (j2 += 8191 & (c2 >>> 8 | (h2 = 255 & e3[r3 + 14] | (255 & e3[r3 + 15]) << 8) << 8)) * (5 * D2), p2 = l2 += (d2 += (U2 += h2 >>> 5 | S2) * (5 * C2)) >>> 13, p2 += k2 * C2, p2 += B2 * N2, p2 += T2 * (5 * V2), p2 += x2 * (5 * F2), l2 = (p2 += O2 * (5 * H2)) >>> 13, p2 &= 8191, p2 += R2 * (5 * q2), p2 += P2 * (5 * z2), p2 += I2 * (5 * K2), p2 += j2 * (5 * L2), l2 += (p2 += U2 * (5 * D2)) >>> 13, p2 &= 8191, y2 = l2, y2 += k2 * D2, y2 += B2 * C2, y2 += T2 * N2, y2 += x2 * (5 * V2), l2 = (y2 += O2 * (5 * F2)) >>> 13, y2 &= 8191, y2 += R2 * (5 * H2), y2 += P2 * (5 * q2), y2 += I2 * (5 * z2), y2 += j2 * (5 * K2), m2 = l2 += (y2 += U2 * (5 * L2)) >>> 13, m2 += k2 * L2, m2 += B2 * D2, m2 += T2 * C2, m2 += x2 * N2, l2 = (m2 += O2 * (5 * V2)) >>> 13, m2 &= 8191, m2 += R2 * (5 * F2), m2 += P2 * (5 * H2), m2 += I2 * (5 * q2), m2 += j2 * (5 * z2), b2 = l2 += (m2 += U2 * (5 * K2)) >>> 13, b2 += k2 * K2, b2 += B2 * L2, b2 += T2 * D2, b2 += x2 * C2, l2 = (b2 += O2 * N2) >>> 13, b2 &= 8191, b2 += R2 * (5 * V2), b2 += P2 * (5 * F2), b2 += I2 * (5 * H2), b2 += j2 * (5 * q2), g2 = l2 += (b2 += U2 * (5 * z2)) >>> 13, g2 += k2 * z2, g2 += B2 * K2, g2 += T2 * L2, g2 += x2 * D2, l2 = (g2 += O2 * C2) >>> 13, g2 &= 8191, g2 += R2 * N2, g2 += P2 * (5 * V2), g2 += I2 * (5 * F2), g2 += j2 * (5 * H2), v2 = l2 += (g2 += U2 * (5 * q2)) >>> 13, v2 += k2 * q2, v2 += B2 * z2, v2 += T2 * K2, v2 += x2 * L2, l2 = (v2 += O2 * D2) >>> 13, v2 &= 8191, v2 += R2 * C2, v2 += P2 * N2, v2 += I2 * (5 * V2), v2 += j2 * (5 * F2), w2 = l2 += (v2 += U2 * (5 * H2)) >>> 13, w2 += k2 * H2, w2 += B2 * q2, w2 += T2 * z2, w2 += x2 * K2, l2 = (w2 += O2 * L2) >>> 13, w2 &= 8191, w2 += R2 * D2, w2 += P2 * C2, w2 += I2 * N2, w2 += j2 * (5 * V2), _2 = l2 += (w2 += U2 * (5 * F2)) >>> 13, _2 += k2 * F2, _2 += B2 * H2, _2 += T2 * q2, _2 += x2 * z2, l2 = (_2 += O2 * K2) >>> 13, _2 &= 8191, _2 += R2 * L2, _2 += P2 * D2, _2 += I2 * C2, _2 += j2 * N2, M2 = l2 += (_2 += U2 * (5 * V2)) >>> 13, M2 += k2 * V2, M2 += B2 * F2, M2 += T2 * H2, M2 += x2 * q2, l2 = (M2 += O2 * z2) >>> 13, M2 &= 8191, M2 += R2 * K2, M2 += P2 * L2, M2 += I2 * D2, M2 += j2 * C2, k2 = d2 = 8191 & (l2 = (l2 = ((l2 += (M2 += U2 * N2) >>> 13) << 2) + l2 | 0) + (d2 &= 8191) | 0), B2 = p2 += l2 >>>= 13, T2 = y2 &= 8191, x2 = m2 &= 8191, O2 = b2 &= 8191, R2 = g2 &= 8191, P2 = v2 &= 8191, I2 = w2 &= 8191, j2 = _2 &= 8191, U2 = M2 &= 8191, r3 += 16, n2 -= 16; + E2[0] = k2, E2[1] = B2, E2[2] = T2, E2[3] = x2, E2[4] = O2, E2[5] = R2, E2[6] = P2, E2[7] = I2, E2[8] = j2, E2[9] = U2; + } + function ot(t3, e3, r3) { + w(t3, e3, r3), v(r3, e3); + for (var i2 = n(32 + t3.length), o2 = n(i2.length), a2 = 0; a2 < t3.length; a2++) + i2[a2 + 32] = t3[a2]; + return function(t4, e4, r4, n2, i3) { + if (r4 < 32) + return -1; + nt(t4, 0, e4, 0, r4, n2, i3), st(t4, 16, t4, 32, r4 - 32, t4); + for (var o3 = 0; o3 < 16; o3++) + t4[o3] = 0; + }(o2, i2, i2.length, e3, r3), o2.subarray(16); + } + function at(t3, e3, r3) { + w(t3, e3, r3), v(r3, e3); + for (var i2 = n(16 + t3.length), o2 = n(i2.length), a2 = 0; a2 < t3.length; a2++) + i2[a2 + 16] = t3[a2]; + if (!(i2.length < 32 || function(t4, e4, r4, i3, o3) { + var a3 = n(32); + if (r4 < 32) + return -1; + if (function(t5, e5, r5, i4, o4) { + var a4 = n(32), s3 = n(8); + et(a4, i4, o4, rt); + for (var u2 = 0; u2 < 8; u2++) + s3[u2] = i4[u2 + 16]; + (function(t6, e6, r6, i5, o5) { + var a5, s4, u3 = n(16), f2 = n(64); + for (s4 = 0; s4 < 16; s4++) + u3[s4] = 0; + for (s4 = 0; s4 < 8; s4++) + u3[s4] = i5[s4]; + for (; r6 >= 64; ) { + for (tt(f2, u3, o5, rt), s4 = 0; s4 < 64; s4++) + t6[e6 + s4] = f2[s4]; + for (a5 = 1, s4 = 8; s4 < 16; s4++) + a5 = a5 + (255 & u3[s4]) | 0, u3[s4] = 255 & a5, a5 >>>= 8; + r6 -= 64, e6 += 64; + } + if (r6 > 0) + for (tt(f2, u3, o5, rt), s4 = 0; s4 < r6; s4++) + t6[e6 + s4] = f2[s4]; + })(t5, e5, r5, s3, a4); + }(a3, 0, 32, i3, o3), function(t5, e5, r5, i4, o4, a4) { + var s3 = n(16); + return st(s3, 0, r5, 32, o4, a4), M(t5, 16, s3, 0); + }(e4, 0, e4, 0, r4 - 32, a3) !== 0) + return -1; + nt(t4, 0, e4, 0, r4, i3, o3); + for (var s2 = 0; s2 < 32; s2++) + t4[s2] = 0; + return 0; + }(o2, i2, i2.length, e3, r3) !== 0)) + return o2.subarray(32); + } + function st(t3, e3, r3, o2, a2, s2) { + var u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2 = (u2 = s2, b2 = i(10), g2 = i(8), f2 = 255 & u2[0] | (255 & u2[1]) << 8, b2[0] = 8191 & f2, c2 = 255 & u2[2] | (255 & u2[3]) << 8, b2[1] = 8191 & (f2 >>> 13 | c2 << 3), h2 = 255 & u2[4] | (255 & u2[5]) << 8, b2[2] = 7939 & (c2 >>> 10 | h2 << 6), l2 = 255 & u2[6] | (255 & u2[7]) << 8, b2[3] = 8191 & (h2 >>> 7 | l2 << 9), d2 = 255 & u2[8] | (255 & u2[9]) << 8, b2[4] = 255 & (l2 >>> 4 | d2 << 12), b2[5] = d2 >>> 1 & 8190, p2 = 255 & u2[10] | (255 & u2[11]) << 8, b2[6] = 8191 & (d2 >>> 14 | p2 << 2), y2 = 255 & u2[12] | (255 & u2[13]) << 8, b2[7] = 8065 & (p2 >>> 11 | y2 << 5), m2 = 255 & u2[14] | (255 & u2[15]) << 8, b2[8] = 8191 & (y2 >>> 8 | m2 << 8), b2[9] = m2 >>> 5 & 127, g2[0] = 255 & u2[16] | (255 & u2[17]) << 8, g2[1] = 255 & u2[18] | (255 & u2[19]) << 8, g2[2] = 255 & u2[20] | (255 & u2[21]) << 8, g2[3] = 255 & u2[22] | (255 & u2[23]) << 8, g2[4] = 255 & u2[24] | (255 & u2[25]) << 8, g2[5] = 255 & u2[26] | (255 & u2[27]) << 8, g2[6] = 255 & u2[28] | (255 & u2[29]) << 8, g2[7] = 255 & u2[30] | (255 & u2[31]) << 8, {buffer: n(16), r: b2, h: i(10), pad: g2, leftover: 0, fin: 0}); + return function(t4, e4, r4, n2) { + var i2, o3, a3 = t4.buffer; + if (t4.leftover) { + for ((o3 = 16 - t4.leftover) > n2 && (o3 = n2), i2 = 0; i2 < o3; i2++) + a3[t4.leftover + i2] = e4[r4 + i2]; + if (n2 -= o3, r4 += o3, t4.leftover += o3, t4.leftover < 16) + return; + it(t4, a3, 0, 16), t4.leftover = 0; + } + if (n2 >= 16 && (it(t4, e4, r4, o3 = n2 - n2 % 16), r4 += o3, n2 -= o3), n2) { + for (i2 = 0; i2 < n2; i2++) + a3[t4.leftover + i2] = e4[r4 + i2]; + t4.leftover += n2; + } + }(v2, r3, o2, a2), function(t4, e4, r4) { + var n2, o3, a3, s3, u3 = i(10), f3 = t4.buffer, c3 = t4.h, h3 = t4.pad, l3 = t4.leftover; + if (l3) { + for (s3 = l3, f3[s3++] = 1; s3 < 16; s3++) + f3[s3] = 0; + t4.fin = 1, it(t4, f3, 0, 16); + } + for (n2 = c3[1] >>> 13, c3[1] &= 8191, s3 = 2; s3 < 10; s3++) + c3[s3] += n2, n2 = c3[s3] >>> 13, c3[s3] &= 8191; + for (c3[0] += 5 * n2, n2 = c3[0] >>> 13, c3[0] &= 8191, c3[1] += n2, n2 = c3[1] >>> 13, c3[1] &= 8191, c3[2] += n2, u3[0] = c3[0] + 5, n2 = u3[0] >>> 13, u3[0] &= 8191, s3 = 1; s3 < 10; s3++) + u3[s3] = c3[s3] + n2, n2 = u3[s3] >>> 13, u3[s3] &= 8191; + for (u3[9] -= 8192, o3 = (1 ^ n2) - 1, s3 = 0; s3 < 10; s3++) + u3[s3] &= o3; + for (o3 = ~o3, s3 = 0; s3 < 10; s3++) + c3[s3] = c3[s3] & o3 | u3[s3]; + for (c3[0] = 65535 & (c3[0] | c3[1] << 13), c3[1] = 65535 & (c3[1] >>> 3 | c3[2] << 10), c3[2] = 65535 & (c3[2] >>> 6 | c3[3] << 7), c3[3] = 65535 & (c3[3] >>> 9 | c3[4] << 4), c3[4] = 65535 & (c3[4] >>> 12 | c3[5] << 1 | c3[6] << 14), c3[5] = 65535 & (c3[6] >>> 2 | c3[7] << 11), c3[6] = 65535 & (c3[7] >>> 5 | c3[8] << 8), c3[7] = 65535 & (c3[8] >>> 8 | c3[9] << 5), a3 = c3[0] + h3[0], c3[0] = 65535 & a3, s3 = 1; s3 < 8; s3++) + a3 = (c3[s3] + h3[s3] | 0) + (a3 >>> 16) | 0, c3[s3] = 65535 & a3; + e4[r4 + 0] = c3[0] >>> 0 & 255, e4[r4 + 1] = c3[0] >>> 8 & 255, e4[r4 + 2] = c3[1] >>> 0 & 255, e4[r4 + 3] = c3[1] >>> 8 & 255, e4[r4 + 4] = c3[2] >>> 0 & 255, e4[r4 + 5] = c3[2] >>> 8 & 255, e4[r4 + 6] = c3[3] >>> 0 & 255, e4[r4 + 7] = c3[3] >>> 8 & 255, e4[r4 + 8] = c3[4] >>> 0 & 255, e4[r4 + 9] = c3[4] >>> 8 & 255, e4[r4 + 10] = c3[5] >>> 0 & 255, e4[r4 + 11] = c3[5] >>> 8 & 255, e4[r4 + 12] = c3[6] >>> 0 & 255, e4[r4 + 13] = c3[6] >>> 8 & 255, e4[r4 + 14] = c3[7] >>> 0 & 255, e4[r4 + 15] = c3[7] >>> 8 & 255; + }(v2, t3, e3), 0; + } + function ut(t3, e3, r3, n2) { + return ot(t3, e3, ft(r3, n2)); + } + function ft(t3, e3) { + w(t3, e3), function(t4, e4) { + if (t4.length != 32) + throw new Error("bad public key size"); + if (e4.length != 32) + throw new Error("bad secret key size"); + }(t3, e3); + var r3 = n(32); + return function(t4, e4, r4) { + var i2 = n(32); + X(i2, r4, e4), et(t4, T, i2, rt); + }(r3, t3, e3), r3; + } + var ct = ot; + function ht(t3, e3, r3, n2) { + return at(t3, e3, ft(r3, n2)); + } + var lt = at; + function dt() { + var t3, e3, r3 = n(32), i2 = n(32); + return t3 = r3, A(e3 = i2, 32), Q(t3, e3), {publicKey: r3, secretKey: i2}; + } + function pt(t3) { + if (w(t3), t3.length !== 32) + throw new Error("bad secret key size"); + var e3 = n(32); + return Q(e3, t3), {publicKey: e3, secretKey: n(t3)}; + } + function yt(t3) { + w(t3); + var e3 = n(64); + return mt(e3, t3, t3.length), e3; + } + function mt(t3, e3, r3) { + var i2, o2 = a(8), s2 = a(8), u2 = n(256), f2 = r3; + for (o2[0] = 1779033703, o2[1] = 3144134277, o2[2] = 1013904242, o2[3] = 2773480762, o2[4] = 1359893119, o2[5] = 2600822924, o2[6] = 528734635, o2[7] = 1541459225, s2[0] = 4089235720, s2[1] = 2227873595, s2[2] = 4271175723, s2[3] = 1595750129, s2[4] = 2917565137, s2[5] = 725511199, s2[6] = 4215389547, s2[7] = 327033209, gt(o2, s2, e3, r3), r3 %= 128, i2 = 0; i2 < r3; i2++) + u2[i2] = e3[f2 - r3 + i2]; + for (u2[r3] = 128, u2[(r3 = 256 - 128 * (r3 < 112 ? 1 : 0)) - 9] = 0, vt(u2, r3 - 8, f2 / 536870912 | 0, f2 << 3), gt(o2, s2, u2, r3), i2 = 0; i2 < 8; i2++) + vt(t3, 8 * i2, o2[i2], s2[i2]); + return 0; + } + var bt = [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 gt(t3, e3, r3, n2) { + for (var i2, o2, s2, u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2, w2, _2, M2, S2, E2, A2, k2, B2, T2, x2, O2, R2 = a(16), P2 = a(16), I2 = t3[0], j2 = t3[1], U2 = t3[2], N2 = t3[3], C2 = t3[4], D2 = t3[5], L2 = t3[6], K2 = t3[7], z2 = e3[0], q2 = e3[1], H2 = e3[2], F2 = e3[3], V2 = e3[4], W2 = e3[5], J2 = e3[6], $2 = e3[7], G2 = 0; n2 >= 128; ) { + for (S2 = 0; S2 < 16; S2++) + E2 = 8 * S2 + G2, R2[S2] = r3[E2 + 0] << 24 | r3[E2 + 1] << 16 | r3[E2 + 2] << 8 | r3[E2 + 3], P2[S2] = r3[E2 + 4] << 24 | r3[E2 + 5] << 16 | r3[E2 + 6] << 8 | r3[E2 + 7]; + for (S2 = 0; S2 < 80; S2++) + if (i2 = I2, o2 = j2, s2 = U2, u2 = N2, f2 = C2, c2 = D2, h2 = L2, d2 = z2, p2 = q2, y2 = H2, m2 = F2, b2 = V2, g2 = W2, v2 = J2, B2 = 65535 & (k2 = $2), T2 = k2 >>> 16, x2 = 65535 & (A2 = K2), O2 = A2 >>> 16, B2 += 65535 & (k2 = (V2 >>> 14 | C2 << 18) ^ (V2 >>> 18 | C2 << 14) ^ (C2 >>> 9 | V2 << 23)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (C2 >>> 14 | V2 << 18) ^ (C2 >>> 18 | V2 << 14) ^ (V2 >>> 9 | C2 << 23)), O2 += A2 >>> 16, B2 += 65535 & (k2 = V2 & W2 ^ ~V2 & J2), T2 += k2 >>> 16, x2 += 65535 & (A2 = C2 & D2 ^ ~C2 & L2), O2 += A2 >>> 16, B2 += 65535 & (k2 = bt[2 * S2 + 1]), T2 += k2 >>> 16, x2 += 65535 & (A2 = bt[2 * S2]), O2 += A2 >>> 16, A2 = R2[S2 % 16], T2 += (k2 = P2[S2 % 16]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16, B2 = 65535 & (k2 = M2 = 65535 & B2 | T2 << 16), T2 = k2 >>> 16, x2 = 65535 & (A2 = _2 = 65535 & x2 | (O2 += x2 >>> 16) << 16), O2 = A2 >>> 16, B2 += 65535 & (k2 = (z2 >>> 28 | I2 << 4) ^ (I2 >>> 2 | z2 << 30) ^ (I2 >>> 7 | z2 << 25)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (I2 >>> 28 | z2 << 4) ^ (z2 >>> 2 | I2 << 30) ^ (z2 >>> 7 | I2 << 25)), O2 += A2 >>> 16, T2 += (k2 = z2 & q2 ^ z2 & H2 ^ q2 & H2) >>> 16, x2 += 65535 & (A2 = I2 & j2 ^ I2 & U2 ^ j2 & U2), O2 += A2 >>> 16, l2 = 65535 & (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) | (O2 += x2 >>> 16) << 16, w2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = m2), T2 = k2 >>> 16, x2 = 65535 & (A2 = u2), O2 = A2 >>> 16, T2 += (k2 = M2) >>> 16, x2 += 65535 & (A2 = _2), O2 += A2 >>> 16, j2 = i2, U2 = o2, N2 = s2, C2 = u2 = 65535 & (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) | (O2 += x2 >>> 16) << 16, D2 = f2, L2 = c2, K2 = h2, I2 = l2, q2 = d2, H2 = p2, F2 = y2, V2 = m2 = 65535 & B2 | T2 << 16, W2 = b2, J2 = g2, $2 = v2, z2 = w2, S2 % 16 == 15) + for (E2 = 0; E2 < 16; E2++) + A2 = R2[E2], B2 = 65535 & (k2 = P2[E2]), T2 = k2 >>> 16, x2 = 65535 & A2, O2 = A2 >>> 16, A2 = R2[(E2 + 9) % 16], B2 += 65535 & (k2 = P2[(E2 + 9) % 16]), T2 += k2 >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, _2 = R2[(E2 + 1) % 16], B2 += 65535 & (k2 = ((M2 = P2[(E2 + 1) % 16]) >>> 1 | _2 << 31) ^ (M2 >>> 8 | _2 << 24) ^ (M2 >>> 7 | _2 << 25)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (_2 >>> 1 | M2 << 31) ^ (_2 >>> 8 | M2 << 24) ^ _2 >>> 7), O2 += A2 >>> 16, _2 = R2[(E2 + 14) % 16], T2 += (k2 = ((M2 = P2[(E2 + 14) % 16]) >>> 19 | _2 << 13) ^ (_2 >>> 29 | M2 << 3) ^ (M2 >>> 6 | _2 << 26)) >>> 16, x2 += 65535 & (A2 = (_2 >>> 19 | M2 << 13) ^ (M2 >>> 29 | _2 << 3) ^ _2 >>> 6), O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, R2[E2] = 65535 & x2 | O2 << 16, P2[E2] = 65535 & B2 | T2 << 16; + B2 = 65535 & (k2 = z2), T2 = k2 >>> 16, x2 = 65535 & (A2 = I2), O2 = A2 >>> 16, A2 = t3[0], T2 += (k2 = e3[0]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[0] = I2 = 65535 & x2 | O2 << 16, e3[0] = z2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = q2), T2 = k2 >>> 16, x2 = 65535 & (A2 = j2), O2 = A2 >>> 16, A2 = t3[1], T2 += (k2 = e3[1]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[1] = j2 = 65535 & x2 | O2 << 16, e3[1] = q2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = H2), T2 = k2 >>> 16, x2 = 65535 & (A2 = U2), O2 = A2 >>> 16, A2 = t3[2], T2 += (k2 = e3[2]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[2] = U2 = 65535 & x2 | O2 << 16, e3[2] = H2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = F2), T2 = k2 >>> 16, x2 = 65535 & (A2 = N2), O2 = A2 >>> 16, A2 = t3[3], T2 += (k2 = e3[3]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[3] = N2 = 65535 & x2 | O2 << 16, e3[3] = F2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = V2), T2 = k2 >>> 16, x2 = 65535 & (A2 = C2), O2 = A2 >>> 16, A2 = t3[4], T2 += (k2 = e3[4]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[4] = C2 = 65535 & x2 | O2 << 16, e3[4] = V2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = W2), T2 = k2 >>> 16, x2 = 65535 & (A2 = D2), O2 = A2 >>> 16, A2 = t3[5], T2 += (k2 = e3[5]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[5] = D2 = 65535 & x2 | O2 << 16, e3[5] = W2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = J2), T2 = k2 >>> 16, x2 = 65535 & (A2 = L2), O2 = A2 >>> 16, A2 = t3[6], T2 += (k2 = e3[6]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[6] = L2 = 65535 & x2 | O2 << 16, e3[6] = J2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = $2), T2 = k2 >>> 16, x2 = 65535 & (A2 = K2), O2 = A2 >>> 16, A2 = t3[7], T2 += (k2 = e3[7]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[7] = K2 = 65535 & x2 | O2 << 16, e3[7] = $2 = 65535 & B2 | T2 << 16, G2 += 128, n2 -= 128; + } + return n2; + } + function vt(t3, e3, r3, n2) { + t3[e3] = r3 >> 24 & 255, t3[e3 + 1] = r3 >> 16 & 255, t3[e3 + 2] = r3 >> 8 & 255, t3[e3 + 3] = 255 & r3, t3[e3 + 4] = n2 >> 24 & 255, t3[e3 + 5] = n2 >> 16 & 255, t3[e3 + 6] = n2 >> 8 & 255, t3[e3 + 7] = 255 & n2; + } + function wt(t3, e3) { + if (w(t3, e3), e3.length !== 64) + throw new Error("bad secret key size"); + var r3 = n(64 + t3.length); + return function(t4, e4, r4, i2) { + var o2, a2, u2 = n(64), f2 = n(64), c2 = n(64), h2 = s(64), l2 = [B(), B(), B(), B()]; + mt(u2, i2, 32), u2[0] &= 248, u2[31] &= 127, u2[31] |= 64; + for (o2 = 0; o2 < r4; o2++) + t4[64 + o2] = e4[o2]; + for (o2 = 0; o2 < 32; o2++) + t4[32 + o2] = u2[32 + o2]; + for (mt(c2, t4.subarray(32), r4 + 32), Pt(c2), xt(l2, c2), Rt(t4, l2), o2 = 32; o2 < 64; o2++) + t4[o2] = i2[o2]; + for (mt(f2, t4, r4 + 64), Pt(f2), o2 = 0; o2 < 64; o2++) + h2[o2] = 0; + for (o2 = 0; o2 < 32; o2++) + h2[o2] = c2[o2]; + for (o2 = 0; o2 < 32; o2++) + for (a2 = 0; a2 < 32; a2++) + h2[o2 + a2] += f2[o2] * u2[a2]; + jt(t4.subarray(32), h2); + }(r3, t3, t3.length, e3), r3; + } + function _t(t3, e3) { + if (w(t3, e3), e3.length !== 32) + throw new Error("bad public key size"); + var r3 = n(t3.length), i2 = Tt(r3, t3, t3.length, e3); + if (!(i2 < 0)) { + for (var o2 = n(i2), a2 = 0; a2 < o2.length; a2++) + o2[a2] = r3[a2]; + return o2; + } + } + function Mt(t3, e3) { + for (var r3 = wt(t3, e3), i2 = n(64), o2 = 0; o2 < i2.length; o2++) + i2[o2] = r3[o2]; + return i2; + } + function St(t3, e3, r3) { + if (w(t3, e3, r3), e3.length !== 64) + throw new Error("bad signature size"); + if (r3.length !== 32) + throw new Error("bad public key size"); + var i2, o2 = n(64 + t3.length), a2 = n(64 + t3.length); + for (i2 = 0; i2 < 64; i2++) + o2[i2] = e3[i2]; + for (i2 = 0; i2 < t3.length; i2++) + o2[i2 + 64] = t3[i2]; + return Tt(a2, o2, o2.length, r3) >= 0; + } + function Et() { + var t3 = n(32), e3 = n(64); + return Bt(t3, e3, false), {publicKey: t3, secretKey: e3}; + } + function At(t3) { + if (w(t3), t3.length !== 64) + throw new Error("bad secret key size"); + for (var e3 = n(32), r3 = 0; r3 < e3.length; r3++) + e3[r3] = t3[32 + r3]; + return {publicKey: e3, secretKey: n(t3)}; + } + function kt(t3) { + if (w(t3), t3.length !== 32) + throw new Error("bad seed size"); + for (var e3 = n(32), r3 = n(64), i2 = 0; i2 < 32; i2++) + r3[i2] = t3[i2]; + return Bt(e3, r3, true), {publicKey: e3, secretKey: r3}; + } + function Bt(t3, e3, r3) { + var i2, o2 = n(64), a2 = [B(), B(), B(), B()]; + for (r3 || A(e3, 32), mt(o2, e3, 32), o2[0] &= 248, o2[31] &= 127, o2[31] |= 64, xt(a2, o2), Rt(t3, a2), i2 = 0; i2 < 32; i2++) + e3[i2 + 32] = t3[i2]; + return 0; + } + function Tt(t3, e3, r3, i2) { + var o2, a2 = n(32), s2 = n(64), u2 = [B(), B(), B(), B()], f2 = [B(), B(), B(), B()]; + if (r3 < 64 || function(t4, e4) { + var r4 = B(), n2 = B(), i3 = B(), o3 = B(), a3 = B(), s3 = B(), u3 = B(); + return q(t4[2], R), $(t4[1], e4), z(i3, t4[1]), K(o3, i3, I), L(i3, i3, t4[2]), D(o3, t4[2], o3), z(a3, o3), z(s3, a3), K(u3, s3, a3), K(r4, u3, i3), K(r4, r4, o3), function(t5, e5) { + var r5, n3 = B(); + for (r5 = 0; r5 < 16; r5++) + n3[r5] = e5[r5]; + for (r5 = 250; r5 >= 0; r5--) + z(n3, n3), r5 !== 1 && K(n3, n3, e5); + for (r5 = 0; r5 < 16; r5++) + t5[r5] = n3[r5]; + }(r4, r4), K(r4, r4, i3), K(r4, r4, o3), K(r4, r4, o3), K(t4[0], r4, o3), z(n2, t4[0]), K(n2, n2, o3), W(n2, i3) && K(t4[0], t4[0], C), z(n2, t4[0]), K(n2, n2, o3), W(n2, i3) ? -1 : (J(t4[0]) === e4[31] >> 7 && L(t4[0], O, t4[0]), K(t4[3], t4[0], t4[1]), 0); + }(f2, i2)) + return -1; + for (o2 = 0; o2 < r3; o2++) + t3[o2] = e3[o2]; + for (o2 = 0; o2 < 32; o2++) + t3[o2 + 32] = i2[o2]; + if (mt(s2, t3, r3), Pt(s2), Ot(u2, f2, s2), xt(f2, e3.subarray(32)), Ut(u2, f2), Rt(a2, u2), r3 -= 64, S(e3, 0, a2, 0)) { + for (o2 = 0; o2 < r3; o2++) + t3[o2] = 0; + return -1; + } + for (o2 = 0; o2 < r3; o2++) + t3[o2] = e3[o2 + 64]; + return r3; + } + function xt(t3, e3) { + var r3 = [B(), B(), B(), B()]; + q(r3[0], U), q(r3[1], N), q(r3[2], R), K(r3[3], U, N), Ot(t3, r3, e3); + } + function Ot(t3, e3, r3) { + var n2, i2; + for (q(t3[0], O), q(t3[1], R), q(t3[2], R), q(t3[3], O), i2 = 255; i2 >= 0; --i2) + Nt(t3, e3, n2 = r3[i2 / 8 | 0] >> (7 & i2) & 1), Ut(e3, t3), Ut(t3, t3), Nt(t3, e3, n2); + } + function Rt(t3, e3) { + var r3 = B(), n2 = B(), i2 = B(); + G(i2, e3[2]), K(r3, e3[0], i2), K(n2, e3[1], i2), V(t3, n2), t3[31] ^= J(r3) << 7; + } + function Pt(t3) { + var e3, r3 = s(64); + for (e3 = 0; e3 < 64; e3++) + r3[e3] = t3[e3]; + for (e3 = 0; e3 < 64; e3++) + t3[e3] = 0; + jt(t3, r3); + } + var It = s([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]); + function jt(t3, e3) { + var r3, n2, i2, o2; + for (n2 = 63; n2 >= 32; --n2) { + for (r3 = 0, i2 = n2 - 32, o2 = n2 - 12; i2 < o2; ++i2) + e3[i2] += r3 - 16 * e3[n2] * It[i2 - (n2 - 32)], r3 = e3[i2] + 128 >> 8, e3[i2] -= 256 * r3; + e3[i2] += r3, e3[n2] = 0; + } + for (r3 = 0, i2 = 0; i2 < 32; i2++) + e3[i2] += r3 - (e3[31] >> 4) * It[i2], r3 = e3[i2] >> 8, e3[i2] &= 255; + for (i2 = 0; i2 < 32; i2++) + e3[i2] -= r3 * It[i2]; + for (n2 = 0; n2 < 32; n2++) + e3[n2 + 1] += e3[n2] >> 8, t3[n2] = 255 & e3[n2]; + } + function Ut(t3, e3) { + var r3 = B(), n2 = B(), i2 = B(), o2 = B(), a2 = B(), s2 = B(), u2 = B(), f2 = B(), c2 = B(); + L(r3, t3[1], t3[0]), L(c2, e3[1], e3[0]), K(r3, r3, c2), D(n2, t3[0], t3[1]), D(c2, e3[0], e3[1]), K(n2, n2, c2), K(i2, t3[3], e3[3]), K(i2, i2, j), K(o2, t3[2], e3[2]), D(o2, o2, o2), L(a2, n2, r3), L(s2, o2, i2), D(u2, o2, i2), D(f2, n2, r3), K(t3[0], a2, s2), K(t3[1], f2, u2), K(t3[2], u2, s2), K(t3[3], a2, f2); + } + function Nt(t3, e3, r3) { + for (var n2 = 0; n2 < 4; n2++) + F(t3[n2], e3[n2], r3); + } + function Ct(t3, e3) { + var r3 = n(32); + return r3.set(Lt(t3, e3).subarray(0, 32)), r3; + } + var Dt = 128; + function Lt(t3, e3) { + var r3, i2, o2 = n(Dt + Math.max(64, t3.length)); + for (e3.length > Dt && (e3 = yt(e3)), r3 = 0; r3 < Dt; r3++) + o2[r3] = 54; + for (r3 = 0; r3 < e3.length; r3++) + o2[r3] ^= e3[r3]; + for (o2.set(t3, Dt), i2 = yt(o2.subarray(0, Dt + t3.length)), r3 = 0; r3 < Dt; r3++) + o2[r3] = 92; + for (r3 = 0; r3 < e3.length; r3++) + o2[r3] ^= e3[r3]; + return o2.set(i2, Dt), yt(o2.subarray(0, Dt + i2.length)); + } + var Kt = Lt; + function zt(t3, e3, r3) { + r3 === void 0 && (r3 = 32); + var n2 = qt(r3, e3); + return Ht(n2, t3), Ft(n2); + } + function qt(t3, e3) { + if (!(t3 > 0 && t3 <= 32)) + throw new Error("Incorrect output length, should be in [1, 32]"); + var r3 = e3 ? e3.length : 0; + if (e3 && !(r3 > 0 && r3 <= 32)) + throw new Error("Incorrect key length, should be in [1, 32]"); + var n2 = {h: o(Vt), b: o(64), c: 0, t: 0, outlen: t3}; + return n2.h[0] ^= 16842752 ^ r3 << 8 ^ t3, r3 && (Ht(n2, e3), n2.c = 64), n2; + } + function Ht(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) + t3.c === 64 && (t3.t += t3.c, Gt(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; + } + function Ft(t3) { + for (t3.t += t3.c; t3.c < 64; ) + t3.b[t3.c++] = 0; + Gt(t3, true); + for (var e3 = n(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) + e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3) & 255; + return e3; + } + var Vt = o([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), Wt = n([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]), Jt = o(16), $t = o(16); + function Gt(t3, e3) { + var r3 = 0; + for (r3 = 0; r3 < 8; r3++) + Jt[r3] = t3.h[r3], Jt[r3 + 8] = Vt[r3]; + for (Jt[12] ^= t3.t, Jt[13] ^= t3.t / 4294967296, e3 && (Jt[14] = ~Jt[14]), r3 = 0; r3 < 16; r3++) + $t[r3] = Zt(t3.b, 4 * r3); + for (r3 = 0; r3 < 10; r3++) + Yt(0, 4, 8, 12, $t[Wt[16 * r3 + 0]], $t[Wt[16 * r3 + 1]]), Yt(1, 5, 9, 13, $t[Wt[16 * r3 + 2]], $t[Wt[16 * r3 + 3]]), Yt(2, 6, 10, 14, $t[Wt[16 * r3 + 4]], $t[Wt[16 * r3 + 5]]), Yt(3, 7, 11, 15, $t[Wt[16 * r3 + 6]], $t[Wt[16 * r3 + 7]]), Yt(0, 5, 10, 15, $t[Wt[16 * r3 + 8]], $t[Wt[16 * r3 + 9]]), Yt(1, 6, 11, 12, $t[Wt[16 * r3 + 10]], $t[Wt[16 * r3 + 11]]), Yt(2, 7, 8, 13, $t[Wt[16 * r3 + 12]], $t[Wt[16 * r3 + 13]]), Yt(3, 4, 9, 14, $t[Wt[16 * r3 + 14]], $t[Wt[16 * r3 + 15]]); + for (r3 = 0; r3 < 8; r3++) + t3.h[r3] ^= Jt[r3] ^ Jt[r3 + 8]; + } + function Zt(t3, e3) { + return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; + } + function Yt(t3, e3, r3, n2, i2, o2) { + Jt[t3] = Jt[t3] + Jt[e3] + i2, Jt[n2] = Xt(Jt[n2] ^ Jt[t3], 16), Jt[r3] = Jt[r3] + Jt[n2], Jt[e3] = Xt(Jt[e3] ^ Jt[r3], 12), Jt[t3] = Jt[t3] + Jt[e3] + o2, Jt[n2] = Xt(Jt[n2] ^ Jt[t3], 8), Jt[r3] = Jt[r3] + Jt[n2], Jt[e3] = Xt(Jt[e3] ^ Jt[r3], 7); + } + function Xt(t3, e3) { + return t3 >>> e3 ^ t3 << 32 - e3; + } + function Qt(t3, e3, r3) { + r3 === void 0 && (r3 = 64); + var n2 = te(r3, e3); + return ee(n2, t3), re(n2); + } + function te(t3, e3) { + if (t3 === 0 || t3 > 64) + throw new Error("Illegal output length, expected 0 < length <= 64"); + if (e3 && e3.length > 64) + throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64"); + for (var r3 = o(16), i2 = 0; i2 < 16; i2++) + r3[i2] = ne[i2]; + var a2 = e3 ? e3.length : 0; + r3[0] ^= 16842752 ^ a2 << 8 ^ t3; + var s2 = {b: n(128), h: r3, t: 0, c: 0, outlen: t3}; + return e3 && (ee(s2, e3), s2.c = 128), s2; + } + function ee(t3, e3) { + for (var r3 = 0; r3 < e3.length; r3++) + t3.c === 128 && (t3.t += t3.c, se(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; + } + function re(t3) { + for (t3.t += t3.c; t3.c < 128; ) + t3.b[t3.c++] = 0; + se(t3, true); + for (var e3 = n(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) + e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3); + return e3; + } + var ne = o([4089235720, 1779033703, 2227873595, 3144134277, 4271175723, 1013904242, 1595750129, 2773480762, 2917565137, 1359893119, 725511199, 2600822924, 4215389547, 528734635, 327033209, 1541459225]), ie = n([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3].map(function(t3) { + return 2 * t3; + })), oe = o(32), ae = o(32); + function se(t3, e3) { + var r3; + for (r3 = 0; r3 < 16; r3++) + oe[r3] = t3.h[r3], oe[r3 + 16] = ne[r3]; + for (oe[24] = oe[24] ^ t3.t, oe[25] = oe[25] ^ t3.t / 4294967296, e3 && (oe[28] = ~oe[28], oe[29] = ~oe[29]), r3 = 0; r3 < 32; r3++) + ae[r3] = ce(t3.b, 4 * r3); + for (r3 = 0; r3 < 12; r3++) + he(0, 8, 16, 24, ie[16 * r3 + 0], ie[16 * r3 + 1]), he(2, 10, 18, 26, ie[16 * r3 + 2], ie[16 * r3 + 3]), he(4, 12, 20, 28, ie[16 * r3 + 4], ie[16 * r3 + 5]), he(6, 14, 22, 30, ie[16 * r3 + 6], ie[16 * r3 + 7]), he(0, 10, 20, 30, ie[16 * r3 + 8], ie[16 * r3 + 9]), he(2, 12, 22, 24, ie[16 * r3 + 10], ie[16 * r3 + 11]), he(4, 14, 16, 26, ie[16 * r3 + 12], ie[16 * r3 + 13]), he(6, 8, 18, 28, ie[16 * r3 + 14], ie[16 * r3 + 15]); + for (r3 = 0; r3 < 16; r3++) + t3.h[r3] = t3.h[r3] ^ oe[r3] ^ oe[r3 + 16]; + } + function ue(t3, e3, r3) { + var n2 = t3[e3] + t3[r3], i2 = t3[e3 + 1] + t3[r3 + 1]; + n2 >= 4294967296 && i2++, t3[e3] = n2, t3[e3 + 1] = i2; + } + function fe(t3, e3, r3, n2) { + var i2 = t3[e3] + r3; + r3 < 0 && (i2 += 4294967296); + var o2 = t3[e3 + 1] + n2; + i2 >= 4294967296 && o2++, t3[e3] = i2, t3[e3 + 1] = o2; + } + function ce(t3, e3) { + return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; + } + function he(t3, e3, r3, n2, i2, o2) { + var a2 = ae[i2], s2 = ae[i2 + 1], u2 = ae[o2], f2 = ae[o2 + 1]; + ue(oe, t3, e3), fe(oe, t3, a2, s2); + var c2 = oe[n2] ^ oe[t3], h2 = oe[n2 + 1] ^ oe[t3 + 1]; + oe[n2] = h2, oe[n2 + 1] = c2, ue(oe, r3, n2), c2 = oe[e3] ^ oe[r3], h2 = oe[e3 + 1] ^ oe[r3 + 1], oe[e3] = c2 >>> 24 ^ h2 << 8, oe[e3 + 1] = h2 >>> 24 ^ c2 << 8, ue(oe, t3, e3), fe(oe, t3, u2, f2), c2 = oe[n2] ^ oe[t3], h2 = oe[n2 + 1] ^ oe[t3 + 1], oe[n2] = c2 >>> 16 ^ h2 << 16, oe[n2 + 1] = h2 >>> 16 ^ c2 << 16, ue(oe, r3, n2), c2 = oe[e3] ^ oe[r3], h2 = oe[e3 + 1] ^ oe[r3 + 1], oe[e3] = h2 >>> 31 ^ c2 << 1, oe[e3 + 1] = c2 >>> 31 ^ h2 << 1; + } + function le(t3, e3) { + var r3 = n(48 + t3.length), i2 = dt(); + r3.set(i2.publicKey); + var o2 = ut(t3, pe(i2.publicKey, e3), e3, i2.secretKey); + r3.set(o2, i2.publicKey.length); + for (var a2 = 0; a2 < i2.secretKey.length; a2++) + i2.secretKey[a2] = 0; + return r3; + } + function de(t3, e3, r3) { + if (!(t3.length < 48)) { + var n2 = t3.subarray(0, 32), i2 = pe(n2, e3); + return ht(t3.subarray(32), i2, n2, r3); + } + } + function pe(t3, e3) { + var r3 = te(24); + return ee(r3, t3), ee(r3, e3), re(r3); + } + }, 6885: function(t2, e2, r2) { + var n = r2(8924).Buffer; + !function(e3, r3) { + t2.exports ? t2.exports = r3() : (e3.nacl || (e3.nacl = {}), e3.nacl.util = r3()); + }(this, function() { + var t3 = {}; + function e3(t4) { + if (!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t4)) + throw new TypeError("invalid encoding"); + } + return t3.decodeUTF8 = function(t4) { + if (typeof t4 != "string") + throw new TypeError("expected string"); + var e4, r3 = unescape(encodeURIComponent(t4)), n2 = new Uint8Array(r3.length); + for (e4 = 0; e4 < r3.length; e4++) + n2[e4] = r3.charCodeAt(e4); + return n2; + }, t3.encodeUTF8 = function(t4) { + var e4, r3 = []; + for (e4 = 0; e4 < t4.length; e4++) + r3.push(String.fromCharCode(t4[e4])); + return decodeURIComponent(escape(r3.join(""))); + }, typeof atob == "undefined" ? n.from !== void 0 ? (t3.encodeBase64 = function(t4) { + return n.from(t4).toString("base64"); + }, t3.decodeBase64 = function(t4) { + return e3(t4), new Uint8Array(Array.prototype.slice.call(n.from(t4, "base64"), 0)); + }) : (t3.encodeBase64 = function(t4) { + return new n(t4).toString("base64"); + }, t3.decodeBase64 = function(t4) { + return e3(t4), new Uint8Array(Array.prototype.slice.call(new n(t4, "base64"), 0)); + }) : (t3.encodeBase64 = function(t4) { + var e4, r3 = [], n2 = t4.length; + for (e4 = 0; e4 < n2; e4++) + r3.push(String.fromCharCode(t4[e4])); + return btoa(r3.join("")); + }, t3.decodeBase64 = function(t4) { + e3(t4); + var r3, n2 = atob(t4), i = new Uint8Array(n2.length); + for (r3 = 0; r3 < n2.length; r3++) + i[r3] = n2.charCodeAt(r3); + return i; + }), t3; + }); + }, 188: (t2, e2, r2) => { + r2.d(e2, {m: () => s, Z: () => u}); + var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); + function s(t3, e3) { + if (t3.__type != null) + return e3.get(t3.__type); + } + var u = function() { + function t3() { + this.typeResolver = s, this.errorHandler = n.H, this.deserializationStrategy = new Map([[a.IK.ctor, n.yR], [Number, l], [String, l], [Boolean, l], [Date, m], [ArrayBuffer, b], [DataView, g], [Array, d], [Set, p], [Map, y], [Float32Array, w], [Float64Array, w], [Uint8Array, _], [Uint8ClampedArray, _], [Uint16Array, _], [Uint32Array, _]]); + } + return t3.prototype.setDeserializationStrategy = function(t4, e3) { + this.deserializationStrategy.set(t4, e3); + }, t3.prototype.setNameResolver = function(t4) { + this.nameResolver = t4; + }, t3.prototype.setTypeResolver = function(t4) { + if (typeof t4 != "function") + throw new TypeError("'typeResolverCallback' is not a function."); + this.typeResolver = t4; + }, t3.prototype.getTypeResolver = function() { + return this.typeResolver; + }, t3.prototype.setErrorHandler = function(t4) { + if (typeof t4 != "function") + throw new TypeError("'errorHandlerCallback' is not a function."); + this.errorHandler = t4; + }, t3.prototype.getErrorHandler = function() { + return this.errorHandler; + }, t3.prototype.convertSingleValue = function(t4, e3, r3, s2, u2) { + if (s2 === void 0 && (s2 = "object"), this.retrievePreserveNull(u2) && t4 === null) + return null; + if ((0, n.Jf)(t4)) { + var f2 = this.deserializationStrategy.get(e3.ctor); + if (f2 !== void 0) + return f2(t4, e3, r3, s2, this, u2); + if (typeof t4 == "object") + return function(t5, e4, r4, s3, u3) { + if (typeof t5 == "object" && t5 !== null) { + var f3 = e4.ctor, c3 = i.WR.getFromConstructor(f3), h2 = r4, l2 = u3.getTypeResolver(); + c3 !== void 0 && (c3.processDeferredKnownTypes(), h2 = u3.mergeKnownTypes(h2, u3.createKnownTypesMap(c3.knownTypes)), c3.typeResolver != null && (l2 = c3.typeResolver)); + var d2 = l2(t5, h2); + if (d2 != null && (0, n.me)(d2, f3) && (f3 = d2, (c3 = i.WR.getFromConstructor(d2)) !== void 0 && (h2 = u3.mergeKnownTypes(h2, u3.createKnownTypesMap(c3.knownTypes)))), (c3 == null ? void 0 : c3.isExplicitlyMarked) === true) { + var p2 = c3, y2 = {}, m2 = (0, o.JH)(u3.options, p2.options); + p2.dataMembers.forEach(function(e5, r5) { + var i2, a2 = t5[r5], s4 = (0, n.$0)(p2.classType) + "." + r5, f4 = (0, o.JH)(m2, e5.options); + if (e5.deserializer != null) + i2 = e5.deserializer(a2); + else { + if (e5.type == null) + throw new TypeError("Cannot deserialize " + s4 + " there is no constructor nor deserialization function to use."); + i2 = u3.convertSingleValue(a2, e5.type(), h2, s4, f4); + } + (0, n.Jf)(i2) || u3.retrievePreserveNull(f4) && i2 === null ? y2[e5.key] = i2 : e5.isRequired === true && u3.getErrorHandler()(new TypeError("Missing required member '" + s4 + "'.")); + }); + var b2 = void 0; + if (typeof c3.initializerCallback == "function") + try { + if ((b2 = c3.initializerCallback(y2, t5)) == null) + throw new TypeError("Cannot deserialize " + s3 + ": 'initializer' function returned undefined/null, but '" + (0, n.$0)(c3.classType) + "' was expected."); + if (!(b2 instanceof c3.classType)) + throw new TypeError("Cannot deserialize " + s3 + ":'initializer' returned '" + (0, n.$0)(b2.constructor) + "', but '" + (0, n.$0)(c3.classType) + "' was expected, and '" + (0, n.$0)(b2.constructor) + "' is not a subtype of '" + (0, n.$0)(c3.classType) + "'"); + } catch (t6) { + return void u3.getErrorHandler()(t6); + } + else + b2 = u3.instantiateType(f3); + Object.assign(b2, y2); + var g2 = c3.onDeserializedMethodName; + return g2 != null && (typeof b2[g2] == "function" ? b2[g2]() : typeof b2.constructor[g2] == "function" ? b2.constructor[g2]() : u3.getErrorHandler()(new TypeError("onDeserialized callback'" + (0, n.$0)(c3.classType) + "." + g2 + "' is not a method."))), b2; + } + var v2 = {}; + return Object.keys(t5).forEach(function(e5) { + v2[e5] = u3.convertSingleValue(t5[e5], new a.h2(t5[e5].constructor), r4, e5); + }), v2; + } + u3.getErrorHandler()(new TypeError("Cannot deserialize " + s3 + ": 'sourceObject' must be a defined object.")); + }(t4, e3, r3, s2, this); + var c2 = "Could not deserialize '" + s2 + "'; don't know how to deserialize type"; + e3.hasFriendlyName() && (c2 += " '" + e3.ctor.name + "'"), this.errorHandler(new TypeError(c2 + ".")); + } + }, t3.prototype.instantiateType = function(t4) { + return new t4(); + }, t3.prototype.mergeKnownTypes = function() { + for (var t4 = this, e3 = [], r3 = 0; r3 < arguments.length; r3++) + e3[r3] = arguments[r3]; + var n2 = new Map(); + return e3.forEach(function(e4) { + e4.forEach(function(e5, r4) { + t4.nameResolver === void 0 ? n2.set(r4, e5) : n2.set(t4.nameResolver(e5), e5); + }); + }), n2; + }, t3.prototype.createKnownTypesMap = function(t4) { + var e3 = this, r3 = new Map(); + return t4.forEach(function(t5) { + if (e3.nameResolver === void 0) { + var n2 = i.WR.getFromConstructor(t5), o2 = (n2 == null ? void 0 : n2.isExplicitlyMarked) === true ? n2.name : null; + r3.set(o2 != null ? o2 : t5.name, t5); + } else + r3.set(e3.nameResolver(t5), t5); + }), r3; + }, t3.prototype.retrievePreserveNull = function(t4) { + return (0, o.l_)("preserveNull", (0, o.JH)(this.options, t4)); + }, t3; + }(); + function f(t3, e3, r3, n2) { + throw new TypeError("Could not deserialize " + n2 + " as " + t3 + ": expected " + e3 + ", got " + r3 + "."); + } + function c(t3, e3, r3) { + return "Could not deserialize " + r3 + ": expected '" + (typeof t3 == "function" ? (0, n.$0)(t3) : t3) + "', got '" + (typeof e3 == "function" ? (0, n.$0)(e3) : e3) + "'."; + } + function h(t3) { + return t3 == null ? "undefined" : (0, n.$0)(t3.constructor); + } + function l(t3, e3, r3, i2) { + if (t3.constructor !== e3.ctor) + throw new TypeError(c((0, n.$0)(e3.ctor), t3.constructor, i2)); + return t3; + } + function d(t3, e3, r3, n2, i2, o2) { + if (!(e3 instanceof a.GJ)) + throw new TypeError("Could not deserialize " + n2 + " as Array: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); + return Array.isArray(t3) ? e3.elementType == null ? (i2.getErrorHandler()(new TypeError("Could not deserialize " + n2 + " as Array: missing constructor reference of Array elements.")), []) : t3.map(function(t4, a2) { + try { + return i2.convertSingleValue(t4, e3.elementType, r3, n2 + "[" + a2 + "]", o2); + } catch (t5) { + return void i2.getErrorHandler()(t5); + } + }) : (i2.getErrorHandler()(new TypeError(c(Array, t3.constructor, n2))), []); + } + function p(t3, e3, r3, n2, i2, o2) { + if (!(e3 instanceof a.do)) + throw new TypeError("Could not deserialize " + n2 + " as Set: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); + if (!Array.isArray(t3)) + return i2.getErrorHandler()(new TypeError(c(Array, t3.constructor, n2))), new Set(); + if (e3.elementType == null) + return i2.getErrorHandler()(new TypeError("Could not deserialize " + n2 + " as Set: missing constructor reference of Set elements.")), new Set(); + var s2 = new Set(); + return t3.forEach(function(t4, a2) { + try { + s2.add(i2.convertSingleValue(t4, e3.elementType, r3, n2 + "[" + a2 + "]", o2)); + } catch (t5) { + i2.getErrorHandler()(t5); + } + }), s2; + } + function y(t3, e3, r3, i2, o2, s2) { + if (!(e3 instanceof a.br)) + throw new TypeError("Could not deserialize " + i2 + " as Map: incorrect TypeDescriptor detected,please use proper annotation or function for this type"); + var u2 = e3.getCompleteOptions().shape; + if (!function(t4, e4) { + return e4 === 0 && Array.isArray(t4) || e4 === 1 && typeof t4 == "object"; + }(t3, u2)) { + var f2 = u2 === 0 ? Array : Object; + return o2.getErrorHandler()(new TypeError(c(f2, t3.constructor, i2))), new Map(); + } + if (e3.keyType == null) + return o2.getErrorHandler()(new TypeError("Could not deserialize " + i2 + " as Map: missing key constructor.")), new Map(); + if (e3.valueType == null) + return o2.getErrorHandler()(new TypeError("Could not deserialize " + i2 + " as Map: missing value constructor.")), new Map(); + var h2 = i2 + "[].key", l2 = i2 + "[].value", d2 = new Map(); + return u2 === 1 ? Object.keys(t3).forEach(function(i3) { + try { + var a2 = o2.convertSingleValue(i3, e3.keyType, r3, h2, s2); + (0, n.Jf)(a2) && d2.set(a2, o2.convertSingleValue(t3[i3], e3.valueType, r3, l2, s2)); + } catch (t4) { + o2.getErrorHandler()(t4); + } + }) : t3.forEach(function(t4) { + try { + var i3 = o2.convertSingleValue(t4.key, e3.keyType, r3, h2, s2); + (0, n.Jf)(i3) && d2.set(i3, o2.convertSingleValue(t4.value, e3.valueType, r3, l2, s2)); + } catch (t5) { + o2.getErrorHandler()(t5); + } + }), d2; + } + function m(t3, e3, r3, n2) { + if (typeof t3 == "number") { + if (t3 % 1 != 0) + throw new TypeError("Could not deserialize " + n2 + " as Date: expected an integer, got a number with decimal places."); + return new Date(t3); + } + return typeof t3 == "string" ? new Date(t3) : t3 instanceof Date ? t3 : void f("Date", "an ISO-8601 string", h(t3), n2); + } + function b(t3, e3, r3, n2) { + return typeof t3 != "string" && f("ArrayBuffer", "a string source", h(t3), n2), v(t3); + } + function g(t3, e3, r3, n2) { + return typeof t3 != "string" && f("DataView", "a string source", h(t3), n2), new DataView(v(t3)); + } + function v(t3) { + for (var e3 = new ArrayBuffer(2 * t3.length), r3 = new Uint16Array(e3), n2 = 0, i2 = t3.length; n2 < i2; n2++) + r3[n2] = t3.charCodeAt(n2); + return e3; + } + function w(t3, e3, r3, n2) { + var i2 = e3.ctor; + return Array.isArray(t3) && t3.every(function(t4) { + return !isNaN(t4); + }) ? new i2(t3) : f(i2.name, "a numeric source array", h(t3), n2); + } + function _(t3, e3, r3, n2) { + var i2 = e3.ctor; + return Array.isArray(t3) && t3.every(function(t4) { + return !isNaN(t4); + }) ? new i2(t3.map(function(t4) { + return ~~t4; + })) : f(e3.ctor.name, "a numeric source array", h(t3), n2); + } + }, 5077: (t2, e2, r2) => { + r2.d(e2, {Vf: () => o, AZ: () => a, lW: () => s, by: () => u, W0: () => f, me: () => c, H: () => h, KE: () => l, Jf: () => d, V9: () => p, df: () => y, $0: () => m, yR: () => b}); + var n = r2(8145), i = r2(8665), o = "If the type is not yet defined, for example due to circular references, add '() => ' before it. E.g. @jsonMember(() => Foo)", a = 'Make sure that you have both "experimentalDecorators" and "emitDecoratorMetadata" enabled in your tsconfig.json'; + function s(t3) { + return [Date, Number, String, Boolean].indexOf(t3) !== -1; + } + function u(t3) { + return [Float32Array, Float64Array, Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array].indexOf(t3) !== -1; + } + function f(t3, e3) { + return typeof t3 != "string" || function(t4, e4) { + var r3 = e4 === String || e4 === ArrayBuffer || e4 === DataView, n2 = t4.length >= 2 && t4[0] === '"' && t4[t4.length - 1] === '"'; + if (e4 === Date) { + var i2 = !isNaN(Number(t4.trim())); + return !n2 && !i2; + } + return r3 && !n2; + }(t3, e3) ? t3 : JSON.parse(t3); + } + function c(t3, e3) { + return t3 === e3 || t3.prototype instanceof e3; + } + function h(t3) { + for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) + e3[r3 - 1] = arguments[r3]; + typeof console == "object" && typeof console.error == "function" ? console.error.apply(console, (0, n.pr)([t3], e3)) : typeof console == "object" && typeof console.log == "function" && console.log.apply(console, (0, n.pr)(["ERROR: " + t3], e3)); + } + function l(t3) { + for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) + e3[r3 - 1] = arguments[r3]; + typeof console == "object" && typeof console.warn == "function" ? console.warn.apply(console, (0, n.pr)([t3], e3)) : typeof console == "object" && typeof console.log == "function" && console.log.apply(console, (0, n.pr)(["WARNING: " + t3], e3)); + } + function d(t3) { + return !(t3 == null); + } + function p(t3, e3) { + return e3 === i.IK.ctor || (typeof t3 == "number" ? e3 === Number : typeof t3 == "string" ? e3 === String : typeof t3 == "boolean" ? e3 === Boolean : !!function(t4) { + return typeof t4 == "object"; + }(t3) && t3 instanceof e3); + } + var y = typeof Reflect == "object" && typeof Reflect.getMetadata == "function"; + function m(t3) { + return typeof t3.name == "string" ? t3.name : "undefined"; + } + function b(t3) { + return t3; + } + }, 4546: (t2, e2, r2) => { + r2.r(e2), r2.d(e2, {TypedJSON: () => n.r5, defaultTypeResolver: () => i.m, defaultTypeEmitter: () => o.C, JsonObjectMetadata: () => a.WR, jsonObject: () => s.O, jsonMember: () => u.R, jsonArrayMember: () => f.g, jsonSetMember: () => c.b, jsonMapMember: () => h.W, toJson: () => l.Q, ArrayT: () => d.AJ, AnyT: () => d.IK, SetT: () => d.zc, MapT: () => d.mY, SetTypeDescriptor: () => d.do, ArrayTypeDescriptor: () => d.GJ, MapTypeDescriptor: () => d.br}); + var n = r2(3380), i = r2(188), o = r2(6844), a = r2(4606), s = r2(4991), u = r2(255), f = r2(8991), c = r2(8120), h = r2(6558), l = r2(9225), d = r2(8665), p = r2(7759), y = {}; + for (const t3 in p) + ["default", "TypedJSON", "defaultTypeResolver", "defaultTypeEmitter", "JsonObjectMetadata", "jsonObject", "jsonMember", "jsonArrayMember", "jsonSetMember", "jsonMapMember", "toJson", "ArrayT", "AnyT", "SetT", "MapT", "SetTypeDescriptor", "ArrayTypeDescriptor", "MapTypeDescriptor"].indexOf(t3) < 0 && (y[t3] = () => p[t3]); + r2.d(e2, y); + }, 8991: (t2, e2, r2) => { + r2.d(e2, {g: () => s, r: () => u}); + var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); + function s(t3, e3) { + return e3 === void 0 && (e3 = {}), function(r3, s2) { + var f, c = "@jsonArrayMember on " + (0, n.$0)(r3.constructor) + "." + String(s2), h = (0, a.JD)(t3, c), l = e3.dimensions == null ? 1 : e3.dimensions; + if (!isNaN(l) && l < 1) + (0, n.H)(c + ": 'dimensions' option must be at least 1."); + else { + var d = n.df ? Reflect.getMetadata("design:type", r3, s2) : null; + d == null || d === Array || d === Object ? (0, i.d3)(r3, s2, {type: function() { + return u((0, a._k)(h()), l); + }, emitDefaultValue: e3.emitDefaultValue, isRequired: e3.isRequired, options: (0, o.M3)(e3), key: s2.toString(), name: (f = e3.name) !== null && f !== void 0 ? f : s2.toString(), deserializer: e3.deserializer, serializer: e3.serializer}) : (0, n.H)(c + ": property is not an Array. " + n.AZ); + } + }; + } + function u(t3, e3) { + for (var r3 = new a.GJ(t3), n2 = 1; n2 < e3; ++n2) + r3 = new a.GJ(r3); + return r3; + } + }, 6558: (t2, e2, r2) => { + r2.d(e2, {W: () => s}); + var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); + function s(t3, e3, r3) { + return r3 === void 0 && (r3 = {}), function(s2, u) { + var f, c = "@jsonMapMember on " + (0, n.$0)(s2.constructor) + "." + String(u), h = (0, a.JD)(t3, c), l = (0, a.JD)(e3, c), d = n.df ? Reflect.getMetadata("design:type", s2, u) : null; + d == null || d === Map || d === Object ? (0, i.d3)(s2, u, {type: function() { + return (0, a.mY)(h(), l(), {shape: r3.shape}); + }, emitDefaultValue: r3.emitDefaultValue, isRequired: r3.isRequired, options: (0, o.M3)(r3), key: u.toString(), name: (f = r3.name) !== null && f !== void 0 ? f : u.toString(), deserializer: r3.deserializer, serializer: r3.serializer}) : (0, n.H)(c + ": property is not a Map. " + n.AZ); + }; + } + }, 255: (t2, e2, r2) => { + r2.d(e2, {R: () => s}); + var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); + function s(t3, e3) { + var r3, s2; + if (typeof e3 != "string" && typeof e3 != "symbol") + return r3 = t3, s2 = e3, function(t4, e4) { + var u3, c2, h2 = "@jsonMember on " + (0, n.$0)(t4.constructor) + "." + String(e4); + if ((0, a.nW)(r3) || (0, a.p3)(r3) ? c2 = (0, a.JD)(r3, h2) : s2 = r3, s2 = s2 != null ? s2 : {}, Object.prototype.hasOwnProperty.call(s2, "constructor")) { + if (c2 !== void 0) + throw new Error("Cannot both define constructor option and type. Only one allowed."); + if (!(0, n.Jf)(s2.constructor)) + return void (0, n.H)(h2 + ": cannot resolve specified property constructor at runtime. " + n.Vf); + var l2 = (0, a._k)(s2.constructor); + c2 = function() { + return l2; + }, n.df && !(0, n.me)(l2.ctor, Reflect.getMetadata("design:type", t4, e4)) && (0, n.KE)(h2 + ": detected property type does not match 'constructor' option."); + } else if (c2 !== void 0) + ; + else if (n.df) { + var d2 = Reflect.getMetadata("design:type", t4, e4); + if (d2 == null) + return void (0, n.H)(h2 + ": cannot resolve detected property constructor at runtime. " + n.Vf); + c2 = function() { + return (0, a._k)(d2); + }; + } else if (s2.deserializer === void 0) + return void (0, n.H)(h2 + ": Cannot determine type"); + var p = c2 == null ? void 0 : c2(); + p !== void 0 && f(h2, p) || (0, i.d3)(t4, e4, {type: c2 === void 0 ? void 0 : function() { + return (0, a._k)(c2()); + }, emitDefaultValue: s2.emitDefaultValue, isRequired: s2.isRequired, options: (0, o.M3)(s2), key: e4.toString(), name: (u3 = s2.name) !== null && u3 !== void 0 ? u3 : e4.toString(), deserializer: s2.deserializer, serializer: s2.serializer}); + }; + var u2 = e3, c = t3, h = "@jsonMember on " + (0, n.$0)(c.constructor) + "." + String(u2); + if (n.df) { + var l = Reflect.getMetadata("design:type", c, u2); + if (l != null) { + var d = (0, a._k)(l); + f(h, d) || (0, i.d3)(c, u2, {type: function() { + return d; + }, key: e3.toString(), name: e3.toString()}); + } else + (0, n.H)(h + ": could not resolve detected property constructor at runtime. Potential solutions:\n - " + n.Vf + "\n - " + n.AZ); + } else + (0, n.H)(h + ": ReflectDecorators is required if the type is not explicitly provided with e.g. @jsonMember(Number)"); + } + function u(t3, e3) { + return t3 instanceof a.eh ? t3.ctor === e3 : t3 === e3; + } + function f(t3, e3) { + return e3 instanceof a.GJ || !u(e3, Array) ? e3 instanceof a.do || !u(e3, Set) ? !(e3 instanceof a.br || !u(e3, Map) || ((0, n.H)(t3 + ": property is a Map. Use the jsonMapMember decorator to serialize this property."), 0)) : ((0, n.H)(t3 + ": property is a Set. Use the jsonSetMember decorator to serialize this property."), true) : ((0, n.H)(t3 + ": property is an Array. Use the jsonArrayMember decorator to serialize this property."), true); + } + }, 4991: (t2, e2, r2) => { + r2.d(e2, {O: () => o}); + var n = r2(4606), i = r2(2651); + function o(t3) { + var e3; + function r3(t4) { + var r4 = n.WR.ensurePresentInPrototype(t4.prototype); + r4.isExplicitlyMarked = true, r4.onDeserializedMethodName = e3.onDeserialized, r4.beforeSerializationMethodName = e3.beforeSerialization, e3.typeResolver != null && (r4.typeResolver = e3.typeResolver), e3.typeHintEmitter != null && (r4.typeHintEmitter = e3.typeHintEmitter), r4.initializerCallback = e3.initializer, e3.name != null && (r4.name = e3.name); + var o2 = (0, i.M3)(e3); + o2 !== void 0 && (r4.options = o2), e3.knownTypes != null && e3.knownTypes.filter(function(t5) { + return Boolean(t5); + }).forEach(function(t5) { + return r4.knownTypes.add(t5); + }); + } + if (e3 = typeof t3 == "function" ? {} : t3 != null ? t3 : {}, typeof t3 != "function") + return r3; + r3(t3); + } + }, 8120: (t2, e2, r2) => { + r2.d(e2, {b: () => s}); + var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); + function s(t3, e3) { + return e3 === void 0 && (e3 = {}), function(r3, s2) { + var u, f = "@jsonSetMember on " + (0, n.$0)(r3.constructor) + "." + String(s2), c = (0, a.JD)(t3, f), h = n.df ? Reflect.getMetadata("design:type", r3, s2) : null; + h == null || h === Set || h === Object ? (0, i.d3)(r3, s2, {type: function() { + return (0, a.zc)(c()); + }, emitDefaultValue: e3.emitDefaultValue, isRequired: e3.isRequired, options: (0, o.M3)(e3), key: s2.toString(), name: (u = e3.name) !== null && u !== void 0 ? u : s2.toString(), deserializer: e3.deserializer, serializer: e3.serializer}) : (0, n.H)(f + ": property is not a Set. " + n.AZ); + }; + } + }, 4606: (t2, e2, r2) => { + r2.d(e2, {WR: () => o, d3: () => a}); + var n = r2(5077), i = "__typedJsonJsonObjectMetadataInformation__", o = function() { + function t3(t4) { + this.dataMembers = new Map(), this.knownTypes = new Set(), this.knownTypesDeferred = [], this.isExplicitlyMarked = false, this.isHandledWithoutAnnotation = false, this.classType = t4; + } + return t3.getJsonObjectName = function(e3) { + var r3 = t3.getFromConstructor(e3); + return r3 === void 0 ? (0, n.$0)(e3) : (0, n.$0)(r3.classType); + }, t3.getFromConstructor = function(e3) { + var r3 = e3.prototype; + if (r3 != null) { + var n2; + if (Object.prototype.hasOwnProperty.call(r3, i) && (n2 = r3[i]), (n2 == null ? void 0 : n2.isExplicitlyMarked) === true) + return n2; + if (t3.doesHandleWithoutAnnotation(e3)) { + var o2 = new t3(e3); + return o2.isExplicitlyMarked = true, o2; + } + } + }, t3.ensurePresentInPrototype = function(e3) { + if (Object.prototype.hasOwnProperty.call(e3, i)) + return e3[i]; + var r3 = new t3(e3.constructor), n2 = e3[i]; + return n2 !== void 0 && (n2.dataMembers.forEach(function(t4, e4) { + r3.dataMembers.set(e4, t4); + }), n2.knownTypes.forEach(function(t4) { + r3.knownTypes.add(t4); + }), r3.typeResolver = n2.typeResolver, r3.typeHintEmitter = n2.typeHintEmitter), Object.defineProperty(e3, i, {enumerable: false, configurable: false, writable: false, value: r3}), r3; + }, t3.getKnownTypeNameFromType = function(e3) { + var r3 = t3.getFromConstructor(e3); + return r3 === void 0 ? (0, n.$0)(e3) : (0, n.$0)(r3.classType); + }, t3.doesHandleWithoutAnnotation = function(t4) { + return (0, n.lW)(t4) || (0, n.by)(t4) || t4 === DataView || t4 === ArrayBuffer; + }, t3.prototype.processDeferredKnownTypes = function() { + var t4 = this; + this.knownTypesDeferred.forEach(function(e3) { + e3().getTypes().forEach(function(e4) { + return t4.knownTypes.add(e4); + }); + }), this.knownTypesDeferred = []; + }, t3; + }(); + function a(t3, e3, r3) { + var i2 = "@jsonMember on " + (0, n.$0)(t3.constructor) + "." + String(e3); + if (typeof t3 != "function") + if (typeof t3[e3] != "function") + if (r3 == null || r3.type === void 0 && r3.deserializer === void 0) + (0, n.H)(i2 + ": JsonMemberMetadata has unknown type."); + else { + var a2 = o.ensurePresentInPrototype(t3); + r3.deserializer === void 0 && a2.knownTypesDeferred.push(r3.type), Object.keys(r3).forEach(function(t4) { + return r3[t4] === void 0 && delete r3[t4]; + }), a2.dataMembers.set(r3.name, r3); + } + else + (0, n.H)(i2 + ": cannot use a method property."); + else + (0, n.H)(i2 + ": cannot use a static property."); + } + }, 2651: (t2, e2, r2) => { + r2.d(e2, {M3: () => o, l_: () => a, JH: () => s}); + var n = r2(8145), i = ["preserveNull"]; + function o(t3) { + var e3 = Object.keys(t3).filter(function(t4) { + return i.indexOf(t4) > -1; + }).reduce(function(e4, r3) { + return e4[r3] = t3[r3], e4; + }, {}); + return Object.keys(e3).length > 0 ? e3 : void 0; + } + function a(t3, e3) { + return e3 != null && e3[t3] != null ? e3[t3] : function(t4) { + switch (t4) { + case "preserveNull": + return false; + } + return null; + }(t3); + } + function s(t3, e3) { + return e3 == null ? t3 : (0, n.pi)((0, n.pi)({}, t3), e3); + } + }, 3380: (t2, e2, r2) => { + r2.d(e2, {r5: () => h}); + var n = r2(8145), i = r2(188), o = r2(5077), a = r2(8991), s = r2(4606), u = r2(2651), f = r2(6844), c = r2(8665), h = function() { + function t3(t4, e3) { + this.serializer = new f.e(), this.deserializer = new i.Z(), this.globalKnownTypes = [], this.indent = 0; + var r3 = s.WR.getFromConstructor(t4); + if (r3 === void 0 || !r3.isExplicitlyMarked && !r3.isHandledWithoutAnnotation) + throw new TypeError("The TypedJSON root data type must have the @jsonObject decorator used."); + this.nameResolver = function(t5) { + return (0, o.$0)(t5); + }, this.rootConstructor = t4, this.errorHandler = function(t5) { + return (0, o.H)(t5); + }, this.config(e3); + } + return t3.parse = function(e3, r3, n2) { + return new t3(r3, n2).parse(e3); + }, t3.parseAsArray = function(e3, r3, n2, i2) { + return new t3(r3, n2).parseAsArray(e3, i2); + }, t3.parseAsSet = function(e3, r3, n2) { + return new t3(r3, n2).parseAsSet(e3); + }, t3.parseAsMap = function(e3, r3, n2, i2) { + return new t3(n2, i2).parseAsMap(e3, r3); + }, t3.toPlainJson = function(e3, r3, n2) { + return new t3(r3, n2).toPlainJson(e3); + }, t3.toPlainArray = function(e3, r3, n2, i2) { + return new t3(r3, i2).toPlainArray(e3, n2); + }, t3.toPlainSet = function(e3, r3, n2) { + return new t3(r3, n2).toPlainSet(e3); + }, t3.toPlainMap = function(e3, r3, n2, i2) { + return new t3(n2, i2).toPlainMap(e3, r3); + }, t3.stringify = function(e3, r3, n2) { + return new t3(r3, n2).stringify(e3); + }, t3.stringifyAsArray = function(e3, r3, n2, i2) { + return new t3(r3, i2).stringifyAsArray(e3, n2); + }, t3.stringifyAsSet = function(e3, r3, n2) { + return new t3(r3, n2).stringifyAsSet(e3); + }, t3.stringifyAsMap = function(e3, r3, n2, i2) { + return new t3(n2, i2).stringifyAsMap(e3, r3); + }, t3.setGlobalConfig = function(t4) { + Object.assign(this._globalConfig, t4); + }, t3.mapType = function(t4, e3) { + this._globalConfig.mappedTypes == null && (this._globalConfig.mappedTypes = new Map()), this._globalConfig.mappedTypes.set(t4, e3); + }, t3.prototype.config = function(e3) { + var r3 = this; + (e3 = (0, n.pi)((0, n.pi)({}, t3._globalConfig), e3)).knownTypes != null && t3._globalConfig.knownTypes != null && (e3.knownTypes = Array.from(new Set(e3.knownTypes.concat(t3._globalConfig.knownTypes)))); + var i2 = (0, u.M3)(e3); + this.serializer.options = i2, this.deserializer.options = i2, e3.errorHandler != null && (this.errorHandler = e3.errorHandler, this.deserializer.setErrorHandler(e3.errorHandler), this.serializer.setErrorHandler(e3.errorHandler)), e3.replacer != null && (this.replacer = e3.replacer), e3.typeResolver != null && this.deserializer.setTypeResolver(e3.typeResolver), e3.typeHintEmitter != null && this.serializer.setTypeHintEmitter(e3.typeHintEmitter), e3.indent != null && (this.indent = e3.indent), e3.mappedTypes != null && e3.mappedTypes.forEach(function(t4, e4) { + r3.setSerializationStrategies(e4, t4); + }), e3.nameResolver != null && (this.nameResolver = e3.nameResolver, this.deserializer.setNameResolver(e3.nameResolver)), e3.knownTypes != null && (e3.knownTypes.forEach(function(t4, e4) { + t4 == null && (0, o.KE)("TypedJSON.config: 'knownTypes' contains an undefined/null value (element " + e4 + ")."); + }), this.globalKnownTypes = e3.knownTypes); + }, t3.prototype.mapType = function(t4, e3) { + this.setSerializationStrategies(t4, e3); + }, t3.prototype.parse = function(t4) { + var e3, r3 = this, n2 = (0, o.W0)(t4, this.rootConstructor), i2 = s.WR.getFromConstructor(this.rootConstructor), a2 = new Map(); + this.globalKnownTypes.filter(function(t5) { + return t5; + }).forEach(function(t5) { + a2.set(r3.nameResolver(t5), t5); + }), i2 !== void 0 && (i2.processDeferredKnownTypes(), i2.knownTypes.forEach(function(t5) { + a2.set(r3.nameResolver(t5), t5); + })); + try { + e3 = this.deserializer.convertSingleValue(n2, (0, c._k)(this.rootConstructor), a2); + } catch (t5) { + this.errorHandler(t5); + } + return e3; + }, t3.prototype.parseAsArray = function(t4, e3) { + e3 === void 0 && (e3 = 1); + var r3 = (0, o.W0)(t4, Array); + return this.deserializer.convertSingleValue(r3, (0, a.r)((0, c._k)(this.rootConstructor), e3), this._mapKnownTypes(this.globalKnownTypes)); + }, t3.prototype.parseAsSet = function(t4) { + var e3 = (0, o.W0)(t4, Set); + return this.deserializer.convertSingleValue(e3, (0, c.zc)(this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); + }, t3.prototype.parseAsMap = function(t4, e3) { + var r3 = (0, o.W0)(t4, Map); + return this.deserializer.convertSingleValue(r3, (0, c.mY)(e3, this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); + }, t3.prototype.toPlainJson = function(t4) { + try { + return this.serializer.convertSingleValue(t4, (0, c._k)(this.rootConstructor)); + } catch (t5) { + this.errorHandler(t5); + } + }, t3.prototype.toPlainArray = function(t4, e3) { + e3 === void 0 && (e3 = 1); + try { + return this.serializer.convertSingleValue(t4, (0, a.r)((0, c._k)(this.rootConstructor), e3)); + } catch (t5) { + this.errorHandler(t5); + } + }, t3.prototype.toPlainSet = function(t4) { + try { + return this.serializer.convertSingleValue(t4, (0, c.zc)(this.rootConstructor)); + } catch (t5) { + this.errorHandler(t5); + } + }, t3.prototype.toPlainMap = function(t4, e3) { + try { + return this.serializer.convertSingleValue(t4, (0, c.mY)(e3, this.rootConstructor)); + } catch (t5) { + this.errorHandler(t5); + } + }, t3.prototype.stringify = function(t4) { + var e3 = this.toPlainJson(t4); + return e3 === void 0 ? "" : JSON.stringify(e3, this.replacer, this.indent); + }, t3.prototype.stringifyAsArray = function(t4, e3) { + return JSON.stringify(this.toPlainArray(t4, e3), this.replacer, this.indent); + }, t3.prototype.stringifyAsSet = function(t4) { + return JSON.stringify(this.toPlainSet(t4), this.replacer, this.indent); + }, t3.prototype.stringifyAsMap = function(t4, e3) { + return JSON.stringify(this.toPlainMap(t4, e3), this.replacer, this.indent); + }, t3.prototype._mapKnownTypes = function(t4) { + var e3 = this, r3 = new Map(); + return t4.filter(function(t5) { + return t5; + }).forEach(function(t5) { + return r3.set(e3.nameResolver(t5), t5); + }), r3; + }, t3.prototype.setSerializationStrategies = function(t4, e3) { + e3.deserializer != null && this.deserializer.setDeserializationStrategy(t4, function(t5) { + return e3.deserializer(t5); + }), e3.serializer != null && this.serializer.setSerializationStrategy(t4, function(t5) { + return e3.serializer(t5); + }); + }, t3._globalConfig = {}, t3; + }(); + }, 6844: (t2, e2, r2) => { + r2.d(e2, {C: () => u, e: () => f}); + var n = r2(8145), i = r2(5077), o = r2(4606), a = r2(2651), s = r2(8665); + function u(t3, e3, r3, n2) { + var o2; + e3.constructor !== r3 && (t3.__type = (o2 = n2 == null ? void 0 : n2.name) !== null && o2 !== void 0 ? o2 : (0, i.$0)(e3.constructor)); + } + var f = function() { + function t3() { + this.typeHintEmitter = u, this.errorHandler = i.H, this.serializationStrategy = new Map([[s.IK.ctor, i.yR], [Date, i.yR], [Number, i.yR], [String, i.yR], [Boolean, i.yR], [ArrayBuffer, p], [DataView, y], [Array, c], [Set, h], [Map, l], [Float32Array, d], [Float64Array, d], [Int8Array, d], [Uint8Array, d], [Uint8ClampedArray, d], [Int16Array, d], [Uint16Array, d], [Int32Array, d], [Uint32Array, d]]); + } + return t3.prototype.setSerializationStrategy = function(t4, e3) { + this.serializationStrategy.set(t4, e3); + }, t3.prototype.setTypeHintEmitter = function(t4) { + if (typeof t4 != "function") + throw new TypeError("'typeEmitterCallback' is not a function."); + this.typeHintEmitter = t4; + }, t3.prototype.getTypeHintEmitter = function() { + return this.typeHintEmitter; + }, t3.prototype.setErrorHandler = function(t4) { + if (typeof t4 != "function") + throw new TypeError("'errorHandlerCallback' is not a function."); + this.errorHandler = t4; + }, t3.prototype.getErrorHandler = function() { + return this.errorHandler; + }, t3.prototype.retrievePreserveNull = function(t4) { + return (0, a.l_)("preserveNull", (0, a.JH)(this.options, t4)); + }, t3.prototype.convertSingleValue = function(t4, e3, r3, s2) { + if (r3 === void 0 && (r3 = "object"), this.retrievePreserveNull(s2) && t4 === null) + return null; + if ((0, i.Jf)(t4)) + if ((0, i.V9)(t4, e3.ctor)) { + var u2 = this.serializationStrategy.get(e3.ctor); + if (u2 !== void 0) + return u2(t4, e3, r3, this, s2); + if (typeof t4 == "object") + return function(t5, e4, r4, s3, u3) { + var f3, c3, h3 = s3.getTypeHintEmitter(); + if ((f3 = t5.constructor !== e4.ctor && t5 instanceof e4.ctor ? o.WR.getFromConstructor(t5.constructor) : o.WR.getFromConstructor(e4.ctor)) === void 0) + c3 = (0, n.pi)({}, t5); + else { + var l2 = f3.beforeSerializationMethodName; + l2 != null && (typeof t5[l2] == "function" ? t5[l2]() : typeof t5.constructor[l2] == "function" ? t5.constructor[l2]() : s3.getErrorHandler()(new TypeError("beforeSerialization callback '" + (0, i.$0)(f3.classType) + "." + l2 + "' is not a method."))); + var d2 = f3; + c3 = {}; + var p2 = (0, a.JH)(s3.options, d2.options); + d2.typeHintEmitter != null && (h3 = d2.typeHintEmitter), d2.dataMembers.forEach(function(e5) { + var r5, n2 = (0, a.JH)(p2, e5.options); + if (e5.serializer != null) + r5 = e5.serializer(t5[e5.key]); + else { + if (e5.type == null) + throw new TypeError("Could not serialize " + e5.name + ", there is no constructor nor serialization function to use."); + r5 = s3.convertSingleValue(t5[e5.key], e5.type(), (0, i.$0)(d2.classType) + "." + e5.key, n2); + } + (s3.retrievePreserveNull(n2) && r5 === null || (0, i.Jf)(r5)) && (c3[e5.name] = r5); + }); + } + return h3(c3, t5, e4.ctor, f3), c3; + }(t4, e3, 0, this); + var f2 = "Could not serialize '" + r3 + "'; don't know how to serialize type"; + e3.hasFriendlyName() && (f2 += " '" + e3.ctor.name + "'"), this.errorHandler(new TypeError(f2 + ".")); + } else { + var c2 = (0, i.$0)(e3.ctor), h2 = (0, i.$0)(t4.constructor); + this.errorHandler(new TypeError("Could not serialize '" + r3 + "': expected '" + c2 + "', got '" + h2 + "'.")); + } + }, t3; + }(); + function c(t3, e3, r3, n2, o2) { + if (!(e3 instanceof s.GJ)) + throw new TypeError("Could not serialize " + r3 + " as Array: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); + if (e3.elementType == null) + throw new TypeError("Could not serialize " + r3 + " as Array: missing element type definition."); + return t3.forEach(function(t4, a2) { + if (!(n2.retrievePreserveNull(o2) && t4 === null || (0, i.V9)(t4, e3.elementType.ctor))) { + var s2 = (0, i.$0)(e3.elementType.ctor), u2 = t4 && (0, i.$0)(t4.constructor); + throw new TypeError("Could not serialize " + r3 + "[" + a2 + "]: expected '" + s2 + "', got '" + u2 + "'."); + } + }), t3.map(function(t4, i2) { + return n2.convertSingleValue(t4, e3.elementType, r3 + "[" + i2 + "]", o2); + }); + } + function h(t3, e3, r3, n2, o2) { + if (!(e3 instanceof s.do)) + throw new TypeError("Could not serialize " + r3 + " as Set: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); + if (e3.elementType == null) + throw new TypeError("Could not serialize " + r3 + " as Set: missing element type definition."); + r3 += "[]"; + var a2 = []; + return t3.forEach(function(t4) { + var s2 = n2.convertSingleValue(t4, e3.elementType, r3, o2); + (0, i.Jf)(t4) && !(0, i.Jf)(s2) || a2.push(s2); + }), a2; + } + function l(t3, e3, r3, n2, o2) { + if (!(e3 instanceof s.br)) + throw new TypeError("Could not serialize " + r3 + " as Map: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); + if (e3.valueType == null) + throw new TypeError("Could not serialize " + r3 + " as Map: missing value type definition."); + if (e3.keyType == null) + throw new TypeError("Could not serialize " + r3 + " as Map: missing key type definition."); + var a2 = r3 + "[].key", u2 = r3 + "[].value", f2 = e3.getCompleteOptions().shape, c2 = f2 === 1 ? {} : [], h2 = n2.retrievePreserveNull(o2); + return t3.forEach(function(t4, r4) { + var s2 = {key: n2.convertSingleValue(r4, e3.keyType, a2, o2), value: n2.convertSingleValue(t4, e3.valueType, u2, o2)}, l2 = (0, i.Jf)(s2.key), d2 = s2.value === null && h2 || (0, i.Jf)(s2.value); + l2 && d2 && (f2 === 1 ? c2[s2.key] = s2.value : c2.push(s2)); + }), c2; + } + function d(t3) { + return Array.from(t3); + } + function p(t3) { + return Array.from(new Uint16Array(t3)).map(function(t4) { + return String.fromCharCode(t4); + }).join(""); + } + function y(t3) { + return p(t3.buffer); + } + }, 9225: (t2, e2, r2) => { + r2.d(e2, {Q: () => i}); + var n = r2(3380); + function i(t3) { + if (typeof t3 != "function") + return function(e3) { + o(e3, t3); + }; + o(t3, {}); + } + function o(t3, e3) { + if (e3.overwrite !== true && t3.prototype.toJSON !== void 0) + throw new Error(t3.name + " already has toJSON defined!"); + t3.prototype.toJSON = function() { + return n.r5.toPlainJson(this, Object.getPrototypeOf(this).constructor); + }; + } + }, 8665: (t2, e2, r2) => { + r2.d(e2, {eh: () => o, h2: () => a, GJ: () => u, AJ: () => f, do: () => c, zc: () => h, br: () => l, mY: () => d, IK: () => p, nW: () => y, p3: () => m, _k: () => b, JD: () => g}); + var n = r2(8145), i = r2(5077), o = function() { + function t3(t4) { + this.ctor = t4; + } + return t3.prototype.getTypes = function() { + return [this.ctor]; + }, t3.prototype.hasFriendlyName = function() { + return this.ctor.name !== "Object"; + }, t3; + }(), a = function(t3) { + function e3(e4) { + return t3.call(this, e4) || this; + } + return (0, n.ZT)(e3, t3), e3; + }(o), s = function(t3) { + function e3(e4) { + return t3.call(this, e4) || this; + } + return (0, n.ZT)(e3, t3), e3; + }(o), u = function(t3) { + function e3(e4) { + var r3 = t3.call(this, Array) || this; + return r3.elementType = e4, r3; + } + return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { + return t3.prototype.getTypes.call(this).concat(this.elementType.getTypes()); + }, e3; + }(s); + function f(t3) { + return new u(b(t3)); + } + var c = function(t3) { + function e3(e4) { + var r3 = t3.call(this, Set) || this; + return r3.elementType = e4, r3; + } + return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { + return t3.prototype.getTypes.call(this).concat(this.elementType.getTypes()); + }, e3; + }(s); + function h(t3) { + return new c(b(t3)); + } + var l = function(t3) { + function e3(e4, r3, n2) { + var i2 = t3.call(this, Map) || this; + return i2.keyType = e4, i2.valueType = r3, i2.options = n2, i2; + } + return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { + return t3.prototype.getTypes.call(this).concat(this.keyType.getTypes(), this.valueType.getTypes()); + }, e3.prototype.getCompleteOptions = function() { + var t4, e4; + return {shape: (e4 = (t4 = this.options) === null || t4 === void 0 ? void 0 : t4.shape) !== null && e4 !== void 0 ? e4 : 0}; + }, e3; + }(s); + function d(t3, e3, r3) { + return new l(b(t3), b(e3), r3); + } + var p = new a(function() { + }); + function y(t3) { + return t3 != null && (typeof t3 == "function" || t3 instanceof o); + } + function m(t3) { + return typeof t3 == "function" && t3.name === ""; + } + function b(t3) { + return t3 instanceof o ? t3 : new a(t3); + } + function g(t3, e3) { + if (t3 == null) + throw new Error("No type given on " + e3 + ". " + i.Vf); + return m(t3) ? t3 : function() { + return t3; + }; + } + }, 7759: () => { + }, 8145: (t2, e2, r2) => { + r2.d(e2, {ZT: () => i, pi: () => o, pr: () => a}); + var n = function(t3, e3) { + return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { + t4.__proto__ = e4; + } || function(t4, e4) { + for (var r3 in e4) + Object.prototype.hasOwnProperty.call(e4, r3) && (t4[r3] = e4[r3]); + })(t3, e3); + }; + function i(t3, e3) { + if (typeof e3 != "function" && e3 !== null) + throw new TypeError("Class extends value " + String(e3) + " is not a constructor or null"); + function r3() { + this.constructor = t3; + } + n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); + } + var o = function() { + return (o = Object.assign || function(t3) { + for (var e3, r3 = 1, n2 = arguments.length; r3 < n2; r3++) + for (var i2 in e3 = arguments[r3]) + Object.prototype.hasOwnProperty.call(e3, i2) && (t3[i2] = e3[i2]); + return t3; + }).apply(this, arguments); + }; + function a() { + for (var t3 = 0, e3 = 0, r3 = arguments.length; e3 < r3; e3++) + t3 += arguments[e3].length; + var n2 = Array(t3), i2 = 0; + for (e3 = 0; e3 < r3; e3++) + for (var o2 = arguments[e3], a2 = 0, s = o2.length; a2 < s; a2++, i2++) + n2[i2] = o2[a2]; + return n2; + } + }, 7781: (t2, e2, r2) => { + function n(t3) { + try { + if (!r2.g.localStorage) + return false; + } catch (t4) { + return false; + } + var e3 = r2.g.localStorage[t3]; + return e3 != null && String(e3).toLowerCase() === "true"; + } + t2.exports = function(t3, e3) { + if (n("noDeprecation")) + return t3; + var r3 = false; + return function() { + if (!r3) { + if (n("throwDeprecation")) + throw new Error(e3); + n("traceDeprecation") ? console.trace(e3) : console.warn(e3), r3 = true; + } + return t3.apply(this, arguments); + }; + }; + }, 384: (t2) => { + t2.exports = function(t3) { + return t3 && typeof t3 == "object" && typeof t3.copy == "function" && typeof t3.fill == "function" && typeof t3.readUInt8 == "function"; + }; + }, 5955: (t2, e2, r2) => { + var n = r2(2584), i = r2(8662), o = r2(6430), a = r2(5692); + function s(t3) { + return t3.call.bind(t3); + } + var u = typeof BigInt != "undefined", f = typeof Symbol != "undefined", c = s(Object.prototype.toString), h = s(Number.prototype.valueOf), l = s(String.prototype.valueOf), d = s(Boolean.prototype.valueOf); + if (u) + var p = s(BigInt.prototype.valueOf); + if (f) + var y = s(Symbol.prototype.valueOf); + function m(t3, e3) { + if (typeof t3 != "object") + return false; + try { + return e3(t3), true; + } catch (t4) { + return false; + } + } + function b(t3) { + return c(t3) === "[object Map]"; + } + function g(t3) { + return c(t3) === "[object Set]"; + } + function v(t3) { + return c(t3) === "[object WeakMap]"; + } + function w(t3) { + return c(t3) === "[object WeakSet]"; + } + function _(t3) { + return c(t3) === "[object ArrayBuffer]"; + } + function M(t3) { + return typeof ArrayBuffer != "undefined" && (_.working ? _(t3) : t3 instanceof ArrayBuffer); + } + function S(t3) { + return c(t3) === "[object DataView]"; + } + function E(t3) { + return typeof DataView != "undefined" && (S.working ? S(t3) : t3 instanceof DataView); + } + function A(t3) { + return c(t3) === "[object SharedArrayBuffer]"; + } + function k(t3) { + return typeof SharedArrayBuffer != "undefined" && (A.working ? A(t3) : t3 instanceof SharedArrayBuffer); + } + function B(t3) { + return m(t3, h); + } + function T(t3) { + return m(t3, l); + } + function x(t3) { + return m(t3, d); + } + function O(t3) { + return u && m(t3, p); + } + function R(t3) { + return f && m(t3, y); + } + e2.isArgumentsObject = n, e2.isGeneratorFunction = i, e2.isTypedArray = a, e2.isPromise = function(t3) { + return typeof Promise != "undefined" && t3 instanceof Promise || t3 !== null && typeof t3 == "object" && typeof t3.then == "function" && typeof t3.catch == "function"; + }, e2.isArrayBufferView = function(t3) { + return typeof ArrayBuffer != "undefined" && ArrayBuffer.isView ? ArrayBuffer.isView(t3) : a(t3) || E(t3); + }, e2.isUint8Array = function(t3) { + return o(t3) === "Uint8Array"; + }, e2.isUint8ClampedArray = function(t3) { + return o(t3) === "Uint8ClampedArray"; + }, e2.isUint16Array = function(t3) { + return o(t3) === "Uint16Array"; + }, e2.isUint32Array = function(t3) { + return o(t3) === "Uint32Array"; + }, e2.isInt8Array = function(t3) { + return o(t3) === "Int8Array"; + }, e2.isInt16Array = function(t3) { + return o(t3) === "Int16Array"; + }, e2.isInt32Array = function(t3) { + return o(t3) === "Int32Array"; + }, e2.isFloat32Array = function(t3) { + return o(t3) === "Float32Array"; + }, e2.isFloat64Array = function(t3) { + return o(t3) === "Float64Array"; + }, e2.isBigInt64Array = function(t3) { + return o(t3) === "BigInt64Array"; + }, e2.isBigUint64Array = function(t3) { + return o(t3) === "BigUint64Array"; + }, b.working = typeof Map != "undefined" && b(new Map()), e2.isMap = function(t3) { + return typeof Map != "undefined" && (b.working ? b(t3) : t3 instanceof Map); + }, g.working = typeof Set != "undefined" && g(new Set()), e2.isSet = function(t3) { + return typeof Set != "undefined" && (g.working ? g(t3) : t3 instanceof Set); + }, v.working = typeof WeakMap != "undefined" && v(new WeakMap()), e2.isWeakMap = function(t3) { + return typeof WeakMap != "undefined" && (v.working ? v(t3) : t3 instanceof WeakMap); + }, w.working = typeof WeakSet != "undefined" && w(new WeakSet()), e2.isWeakSet = function(t3) { + return w(t3); + }, _.working = typeof ArrayBuffer != "undefined" && _(new ArrayBuffer()), e2.isArrayBuffer = M, S.working = typeof ArrayBuffer != "undefined" && typeof DataView != "undefined" && S(new DataView(new ArrayBuffer(1), 0, 1)), e2.isDataView = E, A.working = typeof SharedArrayBuffer != "undefined" && A(new SharedArrayBuffer()), e2.isSharedArrayBuffer = k, e2.isAsyncFunction = function(t3) { + return c(t3) === "[object AsyncFunction]"; + }, e2.isMapIterator = function(t3) { + return c(t3) === "[object Map Iterator]"; + }, e2.isSetIterator = function(t3) { + return c(t3) === "[object Set Iterator]"; + }, e2.isGeneratorObject = function(t3) { + return c(t3) === "[object Generator]"; + }, e2.isWebAssemblyCompiledModule = function(t3) { + return c(t3) === "[object WebAssembly.Module]"; + }, e2.isNumberObject = B, e2.isStringObject = T, e2.isBooleanObject = x, e2.isBigIntObject = O, e2.isSymbolObject = R, e2.isBoxedPrimitive = function(t3) { + return B(t3) || T(t3) || x(t3) || O(t3) || R(t3); + }, e2.isAnyArrayBuffer = function(t3) { + return typeof Uint8Array != "undefined" && (M(t3) || k(t3)); + }, ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function(t3) { + Object.defineProperty(e2, t3, {enumerable: false, value: function() { + throw new Error(t3 + " is not supported in userland"); + }}); + }); + }, 9539: (t2, e2, r2) => { + var n = r2(4155), i = Object.getOwnPropertyDescriptors || function(t3) { + for (var e3 = Object.keys(t3), r3 = {}, n2 = 0; n2 < e3.length; n2++) + r3[e3[n2]] = Object.getOwnPropertyDescriptor(t3, e3[n2]); + return r3; + }, o = /%[sdj%]/g; + e2.format = function(t3) { + if (!v(t3)) { + for (var e3 = [], r3 = 0; r3 < arguments.length; r3++) + e3.push(f(arguments[r3])); + return e3.join(" "); + } + r3 = 1; + for (var n2 = arguments, i2 = n2.length, a2 = String(t3).replace(o, function(t4) { + if (t4 === "%%") + return "%"; + if (r3 >= i2) + return t4; + switch (t4) { + case "%s": + return String(n2[r3++]); + case "%d": + return Number(n2[r3++]); + case "%j": + try { + return JSON.stringify(n2[r3++]); + } catch (t5) { + return "[Circular]"; + } + default: + return t4; + } + }), s2 = n2[r3]; r3 < i2; s2 = n2[++r3]) + b(s2) || !M(s2) ? a2 += " " + s2 : a2 += " " + f(s2); + return a2; + }, e2.deprecate = function(t3, r3) { + if (n !== void 0 && n.noDeprecation === true) + return t3; + if (n === void 0) + return function() { + return e2.deprecate(t3, r3).apply(this, arguments); + }; + var i2 = false; + return function() { + if (!i2) { + if (n.throwDeprecation) + throw new Error(r3); + n.traceDeprecation ? console.trace(r3) : console.error(r3), i2 = true; + } + return t3.apply(this, arguments); + }; + }; + var a = {}, s = /^$/; + if (n.env.NODE_DEBUG) { + var u = n.env.NODE_DEBUG; + u = u.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase(), s = new RegExp("^" + u + "$", "i"); + } + function f(t3, r3) { + var n2 = {seen: [], stylize: h}; + return arguments.length >= 3 && (n2.depth = arguments[2]), arguments.length >= 4 && (n2.colors = arguments[3]), m(r3) ? n2.showHidden = r3 : r3 && e2._extend(n2, r3), w(n2.showHidden) && (n2.showHidden = false), w(n2.depth) && (n2.depth = 2), w(n2.colors) && (n2.colors = false), w(n2.customInspect) && (n2.customInspect = true), n2.colors && (n2.stylize = c), l(n2, t3, n2.depth); + } + function c(t3, e3) { + var r3 = f.styles[e3]; + return r3 ? "[" + f.colors[r3][0] + "m" + t3 + "[" + f.colors[r3][1] + "m" : t3; + } + function h(t3, e3) { + return t3; + } + function l(t3, r3, n2) { + if (t3.customInspect && r3 && A(r3.inspect) && r3.inspect !== e2.inspect && (!r3.constructor || r3.constructor.prototype !== r3)) { + var i2 = r3.inspect(n2, t3); + return v(i2) || (i2 = l(t3, i2, n2)), i2; + } + var o2 = function(t4, e3) { + if (w(e3)) + return t4.stylize("undefined", "undefined"); + if (v(e3)) { + var r4 = "'" + JSON.stringify(e3).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; + return t4.stylize(r4, "string"); + } + return g(e3) ? t4.stylize("" + e3, "number") : m(e3) ? t4.stylize("" + e3, "boolean") : b(e3) ? t4.stylize("null", "null") : void 0; + }(t3, r3); + if (o2) + return o2; + var a2 = Object.keys(r3), s2 = function(t4) { + var e3 = {}; + return t4.forEach(function(t5, r4) { + e3[t5] = true; + }), e3; + }(a2); + if (t3.showHidden && (a2 = Object.getOwnPropertyNames(r3)), E(r3) && (a2.indexOf("message") >= 0 || a2.indexOf("description") >= 0)) + return d(r3); + if (a2.length === 0) { + if (A(r3)) { + var u2 = r3.name ? ": " + r3.name : ""; + return t3.stylize("[Function" + u2 + "]", "special"); + } + if (_(r3)) + return t3.stylize(RegExp.prototype.toString.call(r3), "regexp"); + if (S(r3)) + return t3.stylize(Date.prototype.toString.call(r3), "date"); + if (E(r3)) + return d(r3); + } + var f2, c2 = "", h2 = false, M2 = ["{", "}"]; + return y(r3) && (h2 = true, M2 = ["[", "]"]), A(r3) && (c2 = " [Function" + (r3.name ? ": " + r3.name : "") + "]"), _(r3) && (c2 = " " + RegExp.prototype.toString.call(r3)), S(r3) && (c2 = " " + Date.prototype.toUTCString.call(r3)), E(r3) && (c2 = " " + d(r3)), a2.length !== 0 || h2 && r3.length != 0 ? n2 < 0 ? _(r3) ? t3.stylize(RegExp.prototype.toString.call(r3), "regexp") : t3.stylize("[Object]", "special") : (t3.seen.push(r3), f2 = h2 ? function(t4, e3, r4, n3, i3) { + for (var o3 = [], a3 = 0, s3 = e3.length; a3 < s3; ++a3) + O(e3, String(a3)) ? o3.push(p(t4, e3, r4, n3, String(a3), true)) : o3.push(""); + return i3.forEach(function(i4) { + i4.match(/^\d+$/) || o3.push(p(t4, e3, r4, n3, i4, true)); + }), o3; + }(t3, r3, n2, s2, a2) : a2.map(function(e3) { + return p(t3, r3, n2, s2, e3, h2); + }), t3.seen.pop(), function(t4, e3, r4) { + return t4.reduce(function(t5, e4) { + return e4.indexOf("\n"), t5 + e4.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60 ? r4[0] + (e3 === "" ? "" : e3 + "\n ") + " " + t4.join(",\n ") + " " + r4[1] : r4[0] + e3 + " " + t4.join(", ") + " " + r4[1]; + }(f2, c2, M2)) : M2[0] + c2 + M2[1]; + } + function d(t3) { + return "[" + Error.prototype.toString.call(t3) + "]"; + } + function p(t3, e3, r3, n2, i2, o2) { + var a2, s2, u2; + if ((u2 = Object.getOwnPropertyDescriptor(e3, i2) || {value: e3[i2]}).get ? s2 = u2.set ? t3.stylize("[Getter/Setter]", "special") : t3.stylize("[Getter]", "special") : u2.set && (s2 = t3.stylize("[Setter]", "special")), O(n2, i2) || (a2 = "[" + i2 + "]"), s2 || (t3.seen.indexOf(u2.value) < 0 ? (s2 = b(r3) ? l(t3, u2.value, null) : l(t3, u2.value, r3 - 1)).indexOf("\n") > -1 && (s2 = o2 ? s2.split("\n").map(function(t4) { + return " " + t4; + }).join("\n").substr(2) : "\n" + s2.split("\n").map(function(t4) { + return " " + t4; + }).join("\n")) : s2 = t3.stylize("[Circular]", "special")), w(a2)) { + if (o2 && i2.match(/^\d+$/)) + return s2; + (a2 = JSON.stringify("" + i2)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (a2 = a2.substr(1, a2.length - 2), a2 = t3.stylize(a2, "name")) : (a2 = a2.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), a2 = t3.stylize(a2, "string")); + } + return a2 + ": " + s2; + } + function y(t3) { + return Array.isArray(t3); + } + function m(t3) { + return typeof t3 == "boolean"; + } + function b(t3) { + return t3 === null; + } + function g(t3) { + return typeof t3 == "number"; + } + function v(t3) { + return typeof t3 == "string"; + } + function w(t3) { + return t3 === void 0; + } + function _(t3) { + return M(t3) && k(t3) === "[object RegExp]"; + } + function M(t3) { + return typeof t3 == "object" && t3 !== null; + } + function S(t3) { + return M(t3) && k(t3) === "[object Date]"; + } + function E(t3) { + return M(t3) && (k(t3) === "[object Error]" || t3 instanceof Error); + } + function A(t3) { + return typeof t3 == "function"; + } + function k(t3) { + return Object.prototype.toString.call(t3); + } + function B(t3) { + return t3 < 10 ? "0" + t3.toString(10) : t3.toString(10); + } + e2.debuglog = function(t3) { + if (t3 = t3.toUpperCase(), !a[t3]) + if (s.test(t3)) { + var r3 = n.pid; + a[t3] = function() { + var n2 = e2.format.apply(e2, arguments); + console.error("%s %d: %s", t3, r3, n2); + }; + } else + a[t3] = function() { + }; + return a[t3]; + }, e2.inspect = f, f.colors = {bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39]}, f.styles = {special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red"}, e2.types = r2(5955), e2.isArray = y, e2.isBoolean = m, e2.isNull = b, e2.isNullOrUndefined = function(t3) { + return t3 == null; + }, e2.isNumber = g, e2.isString = v, e2.isSymbol = function(t3) { + return typeof t3 == "symbol"; + }, e2.isUndefined = w, e2.isRegExp = _, e2.types.isRegExp = _, e2.isObject = M, e2.isDate = S, e2.types.isDate = S, e2.isError = E, e2.types.isNativeError = E, e2.isFunction = A, e2.isPrimitive = function(t3) { + return t3 === null || typeof t3 == "boolean" || typeof t3 == "number" || typeof t3 == "string" || typeof t3 == "symbol" || t3 === void 0; + }, e2.isBuffer = r2(384); + var T = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + function x() { + var t3 = new Date(), e3 = [B(t3.getHours()), B(t3.getMinutes()), B(t3.getSeconds())].join(":"); + return [t3.getDate(), T[t3.getMonth()], e3].join(" "); + } + function O(t3, e3) { + return Object.prototype.hasOwnProperty.call(t3, e3); + } + e2.log = function() { + console.log("%s - %s", x(), e2.format.apply(e2, arguments)); + }, e2.inherits = r2(5717), e2._extend = function(t3, e3) { + if (!e3 || !M(e3)) + return t3; + for (var r3 = Object.keys(e3), n2 = r3.length; n2--; ) + t3[r3[n2]] = e3[r3[n2]]; + return t3; + }; + var R = typeof Symbol != "undefined" ? Symbol("util.promisify.custom") : void 0; + function P(t3, e3) { + if (!t3) { + var r3 = new Error("Promise was rejected with a falsy value"); + r3.reason = t3, t3 = r3; + } + return e3(t3); + } + e2.promisify = function(t3) { + if (typeof t3 != "function") + throw new TypeError('The "original" argument must be of type Function'); + if (R && t3[R]) { + var e3; + if (typeof (e3 = t3[R]) != "function") + throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + return Object.defineProperty(e3, R, {value: e3, enumerable: false, writable: false, configurable: true}), e3; + } + function e3() { + for (var e4, r3, n2 = new Promise(function(t4, n3) { + e4 = t4, r3 = n3; + }), i2 = [], o2 = 0; o2 < arguments.length; o2++) + i2.push(arguments[o2]); + i2.push(function(t4, n3) { + t4 ? r3(t4) : e4(n3); + }); + try { + t3.apply(this, i2); + } catch (t4) { + r3(t4); + } + return n2; + } + return Object.setPrototypeOf(e3, Object.getPrototypeOf(t3)), R && Object.defineProperty(e3, R, {value: e3, enumerable: false, writable: false, configurable: true}), Object.defineProperties(e3, i(t3)); + }, e2.promisify.custom = R, e2.callbackify = function(t3) { + if (typeof t3 != "function") + throw new TypeError('The "original" argument must be of type Function'); + function e3() { + for (var e4 = [], r3 = 0; r3 < arguments.length; r3++) + e4.push(arguments[r3]); + var i2 = e4.pop(); + if (typeof i2 != "function") + throw new TypeError("The last argument must be of type Function"); + var o2 = this, a2 = function() { + return i2.apply(o2, arguments); + }; + t3.apply(this, e4).then(function(t4) { + n.nextTick(a2.bind(null, null, t4)); + }, function(t4) { + n.nextTick(P.bind(null, t4, a2)); + }); + } + return Object.setPrototypeOf(e3, Object.getPrototypeOf(t3)), Object.defineProperties(e3, i(t3)), e3; + }; + }, 7147: (t2, e2, r2) => { + r2.r(e2), r2.d(e2, {Headers: () => p, Request: () => _, Response: () => S, DOMException: () => A, fetch: () => k}); + var n = typeof globalThis != "undefined" && globalThis || typeof self != "undefined" && self || n !== void 0 && n, i = "URLSearchParams" in n, o = "Symbol" in n && "iterator" in Symbol, a = "FileReader" in n && "Blob" in n && function() { + try { + return new Blob(), true; + } catch (t3) { + return false; + } + }(), s = "FormData" in n, u = "ArrayBuffer" in n; + if (u) + var f = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], c = ArrayBuffer.isView || function(t3) { + return t3 && f.indexOf(Object.prototype.toString.call(t3)) > -1; + }; + function h(t3) { + if (typeof t3 != "string" && (t3 = String(t3)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t3) || t3 === "") + throw new TypeError('Invalid character in header field name: "' + t3 + '"'); + return t3.toLowerCase(); + } + function l(t3) { + return typeof t3 != "string" && (t3 = String(t3)), t3; + } + function d(t3) { + var e3 = {next: function() { + var e4 = t3.shift(); + return {done: e4 === void 0, value: e4}; + }}; + return o && (e3[Symbol.iterator] = function() { + return e3; + }), e3; + } + function p(t3) { + this.map = {}, t3 instanceof p ? t3.forEach(function(t4, e3) { + this.append(e3, t4); + }, this) : Array.isArray(t3) ? t3.forEach(function(t4) { + this.append(t4[0], t4[1]); + }, this) : t3 && Object.getOwnPropertyNames(t3).forEach(function(e3) { + this.append(e3, t3[e3]); + }, this); + } + function y(t3) { + if (t3.bodyUsed) + return Promise.reject(new TypeError("Already read")); + t3.bodyUsed = true; + } + function m(t3) { + return new Promise(function(e3, r3) { + t3.onload = function() { + e3(t3.result); + }, t3.onerror = function() { + r3(t3.error); + }; + }); + } + function b(t3) { + var e3 = new FileReader(), r3 = m(e3); + return e3.readAsArrayBuffer(t3), r3; + } + function g(t3) { + if (t3.slice) + return t3.slice(0); + var e3 = new Uint8Array(t3.byteLength); + return e3.set(new Uint8Array(t3)), e3.buffer; + } + function v() { + return this.bodyUsed = false, this._initBody = function(t3) { + var e3; + this.bodyUsed = this.bodyUsed, this._bodyInit = t3, t3 ? typeof t3 == "string" ? this._bodyText = t3 : a && Blob.prototype.isPrototypeOf(t3) ? this._bodyBlob = t3 : s && FormData.prototype.isPrototypeOf(t3) ? this._bodyFormData = t3 : i && URLSearchParams.prototype.isPrototypeOf(t3) ? this._bodyText = t3.toString() : u && a && (e3 = t3) && DataView.prototype.isPrototypeOf(e3) ? (this._bodyArrayBuffer = g(t3.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : u && (ArrayBuffer.prototype.isPrototypeOf(t3) || c(t3)) ? this._bodyArrayBuffer = g(t3) : this._bodyText = t3 = Object.prototype.toString.call(t3) : this._bodyText = "", this.headers.get("content-type") || (typeof t3 == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i && URLSearchParams.prototype.isPrototypeOf(t3) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")); + }, a && (this.blob = function() { + var t3 = y(this); + if (t3) + return t3; + if (this._bodyBlob) + return Promise.resolve(this._bodyBlob); + if (this._bodyArrayBuffer) + return Promise.resolve(new Blob([this._bodyArrayBuffer])); + if (this._bodyFormData) + throw new Error("could not read FormData body as blob"); + return Promise.resolve(new Blob([this._bodyText])); + }, this.arrayBuffer = function() { + return this._bodyArrayBuffer ? y(this) || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset, this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength)) : Promise.resolve(this._bodyArrayBuffer)) : this.blob().then(b); + }), this.text = function() { + var t3, e3, r3, n2 = y(this); + if (n2) + return n2; + if (this._bodyBlob) + return t3 = this._bodyBlob, r3 = m(e3 = new FileReader()), e3.readAsText(t3), r3; + if (this._bodyArrayBuffer) + return Promise.resolve(function(t4) { + for (var e4 = new Uint8Array(t4), r4 = new Array(e4.length), n3 = 0; n3 < e4.length; n3++) + r4[n3] = String.fromCharCode(e4[n3]); + return r4.join(""); + }(this._bodyArrayBuffer)); + if (this._bodyFormData) + throw new Error("could not read FormData body as text"); + return Promise.resolve(this._bodyText); + }, s && (this.formData = function() { + return this.text().then(M); + }), this.json = function() { + return this.text().then(JSON.parse); + }, this; + } + p.prototype.append = function(t3, e3) { + t3 = h(t3), e3 = l(e3); + var r3 = this.map[t3]; + this.map[t3] = r3 ? r3 + ", " + e3 : e3; + }, p.prototype.delete = function(t3) { + delete this.map[h(t3)]; + }, p.prototype.get = function(t3) { + return t3 = h(t3), this.has(t3) ? this.map[t3] : null; + }, p.prototype.has = function(t3) { + return this.map.hasOwnProperty(h(t3)); + }, p.prototype.set = function(t3, e3) { + this.map[h(t3)] = l(e3); + }, p.prototype.forEach = function(t3, e3) { + for (var r3 in this.map) + this.map.hasOwnProperty(r3) && t3.call(e3, this.map[r3], r3, this); + }, p.prototype.keys = function() { + var t3 = []; + return this.forEach(function(e3, r3) { + t3.push(r3); + }), d(t3); + }, p.prototype.values = function() { + var t3 = []; + return this.forEach(function(e3) { + t3.push(e3); + }), d(t3); + }, p.prototype.entries = function() { + var t3 = []; + return this.forEach(function(e3, r3) { + t3.push([r3, e3]); + }), d(t3); + }, o && (p.prototype[Symbol.iterator] = p.prototype.entries); + var w = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; + function _(t3, e3) { + if (!(this instanceof _)) + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); + var r3, n2, i2 = (e3 = e3 || {}).body; + if (t3 instanceof _) { + if (t3.bodyUsed) + throw new TypeError("Already read"); + this.url = t3.url, this.credentials = t3.credentials, e3.headers || (this.headers = new p(t3.headers)), this.method = t3.method, this.mode = t3.mode, this.signal = t3.signal, i2 || t3._bodyInit == null || (i2 = t3._bodyInit, t3.bodyUsed = true); + } else + this.url = String(t3); + if (this.credentials = e3.credentials || this.credentials || "same-origin", !e3.headers && this.headers || (this.headers = new p(e3.headers)), this.method = (n2 = (r3 = e3.method || this.method || "GET").toUpperCase(), w.indexOf(n2) > -1 ? n2 : r3), this.mode = e3.mode || this.mode || null, this.signal = e3.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && i2) + throw new TypeError("Body not allowed for GET or HEAD requests"); + if (this._initBody(i2), !(this.method !== "GET" && this.method !== "HEAD" || e3.cache !== "no-store" && e3.cache !== "no-cache")) { + var o2 = /([?&])_=[^&]*/; + o2.test(this.url) ? this.url = this.url.replace(o2, "$1_=" + new Date().getTime()) : this.url += (/\?/.test(this.url) ? "&" : "?") + "_=" + new Date().getTime(); + } + } + function M(t3) { + var e3 = new FormData(); + return t3.trim().split("&").forEach(function(t4) { + if (t4) { + var r3 = t4.split("="), n2 = r3.shift().replace(/\+/g, " "), i2 = r3.join("=").replace(/\+/g, " "); + e3.append(decodeURIComponent(n2), decodeURIComponent(i2)); + } + }), e3; + } + function S(t3, e3) { + if (!(this instanceof S)) + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); + e3 || (e3 = {}), this.type = "default", this.status = e3.status === void 0 ? 200 : e3.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = e3.statusText === void 0 ? "" : "" + e3.statusText, this.headers = new p(e3.headers), this.url = e3.url || "", this._initBody(t3); + } + _.prototype.clone = function() { + return new _(this, {body: this._bodyInit}); + }, v.call(_.prototype), v.call(S.prototype), S.prototype.clone = function() { + return new S(this._bodyInit, {status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url}); + }, S.error = function() { + var t3 = new S(null, {status: 0, statusText: ""}); + return t3.type = "error", t3; + }; + var E = [301, 302, 303, 307, 308]; + S.redirect = function(t3, e3) { + if (E.indexOf(e3) === -1) + throw new RangeError("Invalid status code"); + return new S(null, {status: e3, headers: {location: t3}}); + }; + var A = n.DOMException; + try { + new A(); + } catch (t3) { + (A = function(t4, e3) { + this.message = t4, this.name = e3; + var r3 = Error(t4); + this.stack = r3.stack; + }).prototype = Object.create(Error.prototype), A.prototype.constructor = A; + } + function k(t3, e3) { + return new Promise(function(r3, i2) { + var o2 = new _(t3, e3); + if (o2.signal && o2.signal.aborted) + return i2(new A("Aborted", "AbortError")); + var s2 = new XMLHttpRequest(); + function f2() { + s2.abort(); + } + s2.onload = function() { + var t4, e4, n2 = {status: s2.status, statusText: s2.statusText, headers: (t4 = s2.getAllResponseHeaders() || "", e4 = new p(), t4.replace(/\r?\n[\t ]+/g, " ").split("\r").map(function(t5) { + return t5.indexOf("\n") === 0 ? t5.substr(1, t5.length) : t5; + }).forEach(function(t5) { + var r4 = t5.split(":"), n3 = r4.shift().trim(); + if (n3) { + var i4 = r4.join(":").trim(); + e4.append(n3, i4); + } + }), e4)}; + n2.url = "responseURL" in s2 ? s2.responseURL : n2.headers.get("X-Request-URL"); + var i3 = "response" in s2 ? s2.response : s2.responseText; + setTimeout(function() { + r3(new S(i3, n2)); + }, 0); + }, s2.onerror = function() { + setTimeout(function() { + i2(new TypeError("Network request failed")); + }, 0); + }, s2.ontimeout = function() { + setTimeout(function() { + i2(new TypeError("Network request failed")); + }, 0); + }, s2.onabort = function() { + setTimeout(function() { + i2(new A("Aborted", "AbortError")); + }, 0); + }, s2.open(o2.method, function(t4) { + try { + return t4 === "" && n.location.href ? n.location.href : t4; + } catch (e4) { + return t4; + } + }(o2.url), true), o2.credentials === "include" ? s2.withCredentials = true : o2.credentials === "omit" && (s2.withCredentials = false), "responseType" in s2 && (a ? s2.responseType = "blob" : u && o2.headers.get("Content-Type") && o2.headers.get("Content-Type").indexOf("application/octet-stream") !== -1 && (s2.responseType = "arraybuffer")), !e3 || typeof e3.headers != "object" || e3.headers instanceof p ? o2.headers.forEach(function(t4, e4) { + s2.setRequestHeader(e4, t4); + }) : Object.getOwnPropertyNames(e3.headers).forEach(function(t4) { + s2.setRequestHeader(t4, l(e3.headers[t4])); + }), o2.signal && (o2.signal.addEventListener("abort", f2), s2.onreadystatechange = function() { + s2.readyState === 4 && o2.signal.removeEventListener("abort", f2); + }), s2.send(o2._bodyInit === void 0 ? null : o2._bodyInit); + }); + } + k.polyfill = true, n.fetch || (n.fetch = k, n.Headers = p, n.Request = _, n.Response = S); + }, 6430: (t2, e2, r2) => { + var n = r2(9804), i = r2(6314), o = r2(1924), a = o("Object.prototype.toString"), s = r2(1405)() && typeof Symbol.toStringTag == "symbol", u = i(), f = o("String.prototype.slice"), c = {}, h = r2(4079), l = Object.getPrototypeOf; + s && h && l && n(u, function(t3) { + if (typeof r2.g[t3] == "function") { + var e3 = new r2.g[t3](); + if (!(Symbol.toStringTag in e3)) + throw new EvalError("this engine has support for Symbol.toStringTag, but " + t3 + " does not have the property! Please report this."); + var n2 = l(e3), i2 = h(n2, Symbol.toStringTag); + if (!i2) { + var o2 = l(n2); + i2 = h(o2, Symbol.toStringTag); + } + c[t3] = i2.get; + } + }); + var d = r2(5692); + t2.exports = function(t3) { + return !!d(t3) && (s ? function(t4) { + var e3 = false; + return n(c, function(r3, n2) { + if (!e3) + try { + var i2 = r3.call(t4); + i2 === n2 && (e3 = i2); + } catch (t5) { + } + }), e3; + }(t3) : f(a(t3), 8, -1)); + }; + }, 6601: () => { + }, 9214: () => { + }, 1922: () => { + }, 2363: () => { + }, 2361: () => { + }, 4616: () => { + }, 8924: () => { + }, 2349: () => { + }}, e = {}; + function r(n) { + var i = e[n]; + if (i !== void 0) + return i.exports; + var o = e[n] = {id: n, loaded: false, exports: {}}; + return t[n].call(o.exports, o, o.exports, r), o.loaded = true, o.exports; + } + return r.n = (t2) => { + var e2 = t2 && t2.__esModule ? () => t2.default : () => t2; + return r.d(e2, {a: e2}), e2; + }, r.d = (t2, e2) => { + for (var n in e2) + r.o(e2, n) && !r.o(t2, n) && Object.defineProperty(t2, n, {enumerable: true, get: e2[n]}); + }, r.g = function() { + if (typeof globalThis == "object") + return globalThis; + try { + return this || new Function("return this")(); + } catch (t2) { + if (typeof window == "object") + return window; + } + }(), r.o = (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r.r = (t2) => { + typeof Symbol != "undefined" && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, {value: "Module"}), Object.defineProperty(t2, "__esModule", {value: true}); + }, r.nmd = (t2) => (t2.paths = [], t2.children || (t2.children = []), t2), r(3607); + })(); + }); + }); + var lib$1 = /* @__PURE__ */ getDefaultExportFromCjs(lib); + export default lib$1; \ No newline at end of file diff --git a/app/dashboard/templates/bounty/details2.html b/app/dashboard/templates/bounty/details2.html index 274636924cf..8d9be726e84 100644 --- a/app/dashboard/templates/bounty/details2.html +++ b/app/dashboard/templates/bounty/details2.html @@ -1157,6 +1157,10 @@

{{ noscript.keywords }}

+ {% elif web3_type == 'casper_ext' %} + + + {% elif web3_type == 'fiat' %} {% if PYPL_CLIENT_ID %} diff --git a/app/dashboard/templates/bounty/new_bounty.html b/app/dashboard/templates/bounty/new_bounty.html index fcbad620975..715ff8be3df 100644 --- a/app/dashboard/templates/bounty/new_bounty.html +++ b/app/dashboard/templates/bounty/new_bounty.html @@ -139,6 +139,10 @@

Fund Issue

Tezos + + diff --git a/app/dashboard/templates/dashboard/hackathon/new_bounty.html b/app/dashboard/templates/dashboard/hackathon/new_bounty.html index 6ab40b0b899..d961f80300b 100644 --- a/app/dashboard/templates/dashboard/hackathon/new_bounty.html +++ b/app/dashboard/templates/dashboard/hackathon/new_bounty.html @@ -203,6 +203,10 @@

Fund Prize

Tezos + + From 468027c589da6292d5eb7b621f1837d87167ea80 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Fri, 16 Jul 2021 13:28:43 +0100 Subject: [PATCH 07/22] fix casper chain id --- app/assets/v2/js/pages/hackathon_new_bounty.js | 2 +- app/assets/v2/js/pages/new_bounty.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/pages/hackathon_new_bounty.js b/app/assets/v2/js/pages/hackathon_new_bounty.js index 23404d6aef6..110f19a6aa0 100644 --- a/app/assets/v2/js/pages/hackathon_new_bounty.js +++ b/app/assets/v2/js/pages/hackathon_new_bounty.js @@ -186,7 +186,7 @@ Vue.mixin({ // tezos type = 'tezos_ext'; break; - case '82795': + case '270895': // casper type = 'casper_ext'; break; diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index a436f68dcca..5be0d117d73 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -255,7 +255,7 @@ Vue.mixin({ // tezos type = 'tezos_ext'; break; - case '82795': + case '270895': // casper type = 'casper_ext'; break; From f25181d9e0b5f0bbc9f09465df31f72d12569c0f Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Fri, 16 Jul 2021 14:20:35 +0100 Subject: [PATCH 08/22] start casper extension --- .../pages/bounty_detail/casper_extension.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/assets/v2/js/pages/bounty_detail/casper_extension.js diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js new file mode 100644 index 00000000000..392d1499abf --- /dev/null +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -0,0 +1,44 @@ +const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { + + const amount = vm.fulfillment_context.amount; + const token_name = vm.bounty.token_name; + + let selectedAddress; + + console.log(casper); + + function callback(error, from_address, txn) { + if (error) { + _alert({ message: gettext('Unable to payout bounty due to: ' + error) }, 'danger'); + console.log(error); + } else { + + const payload = { + payout_type: 'casper_ext', + tenant: 'CASPER', + amount: amount, + token_name: token_name, + funder_address: from_address, + payout_tx_id: txn + }; + + modal.closeModal(); + const apiUrlBounty = `/api/v1/bounty/payout/${fulfillment_id}`; + + fetchData(apiUrlBounty, 'POST', payload).then(response => { + if (200 <= response.status && response.status <= 204) { + vm.fetchBounty(); + _alert('Payment Successful', 'success'); + + } else { + _alert('Unable to make payout bounty. Please try again later', 'danger'); + console.error(`error: bounty payment failed with status: ${response.status} and message: ${response.message}`); + } + }).catch(function(error) { + _alert('Unable to make payout bounty. Please try again later', 'danger'); + console.log(error); + }); + } + } +}; + \ No newline at end of file From 53d7c4b979027302b088d5505b8ec7079f5237f7 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Sun, 18 Jul 2021 17:22:36 +0100 Subject: [PATCH 09/22] + usable casper js sdk --- app/assets/v2/js/lib/casper/casper-js-sdk.js | 19243 ------- app/assets/v2/js/lib/casper/casper_js_sdk.js | 45844 +++++++++++++++++ 2 files changed, 45844 insertions(+), 19243 deletions(-) delete mode 100644 app/assets/v2/js/lib/casper/casper-js-sdk.js create mode 100644 app/assets/v2/js/lib/casper/casper_js_sdk.js diff --git a/app/assets/v2/js/lib/casper/casper-js-sdk.js b/app/assets/v2/js/lib/casper/casper-js-sdk.js deleted file mode 100644 index fd27127c1d7..00000000000 --- a/app/assets/v2/js/lib/casper/casper-js-sdk.js +++ /dev/null @@ -1,19243 +0,0 @@ -function getDefaultExportFromCjs(x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; - } - function createCommonjsModule(fn, basedir, module) { - return module = { - path: basedir, - exports: {}, - require: function(path, base) { - return commonjsRequire(path, base === void 0 || base === null ? module.path : base); - } - }, fn(module, module.exports), module.exports; - } - function commonjsRequire() { - throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); - } - var lib = createCommonjsModule(function(module, exports) { - /*! For license information please see lib.js.LICENSE.txt */ - !function(t, e) { - module.exports = e(); - }(self, function() { - return (() => { - var t = {8794: (t2, e2, r2) => { - r2.d(e2, {i: () => n}); - const n = "bignumber/5.1.1"; - }, 2593: (t2, e2, r2) => { - r2.d(e2, {Zm: () => l, O$: () => p, g$: () => v, t2: () => w}); - var n = r2(3550), i = r2.n(n), o = r2(3286), a = r2(711), s = r2(8794), u = i().BN; - const f = new a.Yd(s.i), c = {}, h = 9007199254740991; - function l(t3) { - return t3 != null && (p.isBigNumber(t3) || typeof t3 == "number" && t3 % 1 == 0 || typeof t3 == "string" && !!t3.match(/^-?[0-9]+$/) || (0, o.isHexString)(t3) || typeof t3 == "bigint" || (0, o.isBytes)(t3)); - } - let d = false; - class p { - constructor(t3, e3) { - f.checkNew(new.target, p), t3 !== c && f.throwError("cannot call constructor directly; use BigNumber.from", a.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new (BigNumber)"}), this._hex = e3, this._isBigNumber = true, Object.freeze(this); - } - fromTwos(t3) { - return m(b(this).fromTwos(t3)); - } - toTwos(t3) { - return m(b(this).toTwos(t3)); - } - abs() { - return this._hex[0] === "-" ? p.from(this._hex.substring(1)) : this; - } - add(t3) { - return m(b(this).add(b(t3))); - } - sub(t3) { - return m(b(this).sub(b(t3))); - } - div(t3) { - return p.from(t3).isZero() && g("division by zero", "div"), m(b(this).div(b(t3))); - } - mul(t3) { - return m(b(this).mul(b(t3))); - } - mod(t3) { - const e3 = b(t3); - return e3.isNeg() && g("cannot modulo negative values", "mod"), m(b(this).umod(e3)); - } - pow(t3) { - const e3 = b(t3); - return e3.isNeg() && g("cannot raise to negative values", "pow"), m(b(this).pow(e3)); - } - and(t3) { - const e3 = b(t3); - return (this.isNegative() || e3.isNeg()) && g("cannot 'and' negative values", "and"), m(b(this).and(e3)); - } - or(t3) { - const e3 = b(t3); - return (this.isNegative() || e3.isNeg()) && g("cannot 'or' negative values", "or"), m(b(this).or(e3)); - } - xor(t3) { - const e3 = b(t3); - return (this.isNegative() || e3.isNeg()) && g("cannot 'xor' negative values", "xor"), m(b(this).xor(e3)); - } - mask(t3) { - return (this.isNegative() || t3 < 0) && g("cannot mask negative values", "mask"), m(b(this).maskn(t3)); - } - shl(t3) { - return (this.isNegative() || t3 < 0) && g("cannot shift negative values", "shl"), m(b(this).shln(t3)); - } - shr(t3) { - return (this.isNegative() || t3 < 0) && g("cannot shift negative values", "shr"), m(b(this).shrn(t3)); - } - eq(t3) { - return b(this).eq(b(t3)); - } - lt(t3) { - return b(this).lt(b(t3)); - } - lte(t3) { - return b(this).lte(b(t3)); - } - gt(t3) { - return b(this).gt(b(t3)); - } - gte(t3) { - return b(this).gte(b(t3)); - } - isNegative() { - return this._hex[0] === "-"; - } - isZero() { - return b(this).isZero(); - } - toNumber() { - try { - return b(this).toNumber(); - } catch (t3) { - g("overflow", "toNumber", this.toString()); - } - return null; - } - toBigInt() { - try { - return BigInt(this.toString()); - } catch (t3) { - } - return f.throwError("this platform does not support BigInt", a.Yd.errors.UNSUPPORTED_OPERATION, {value: this.toString()}); - } - toString() { - return arguments.length > 0 && (arguments[0] === 10 ? d || (d = true, f.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? f.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", a.Yd.errors.UNEXPECTED_ARGUMENT, {}) : f.throwError("BigNumber.toString does not accept parameters", a.Yd.errors.UNEXPECTED_ARGUMENT, {})), b(this).toString(10); - } - toHexString() { - return this._hex; - } - toJSON(t3) { - return {type: "BigNumber", hex: this.toHexString()}; - } - static from(t3) { - if (t3 instanceof p) - return t3; - if (typeof t3 == "string") - return t3.match(/^-?0x[0-9a-f]+$/i) ? new p(c, y(t3)) : t3.match(/^-?[0-9]+$/) ? new p(c, y(new u(t3))) : f.throwArgumentError("invalid BigNumber string", "value", t3); - if (typeof t3 == "number") - return t3 % 1 && g("underflow", "BigNumber.from", t3), (t3 >= h || t3 <= -h) && g("overflow", "BigNumber.from", t3), p.from(String(t3)); - const e3 = t3; - if (typeof e3 == "bigint") - return p.from(e3.toString()); - if ((0, o.isBytes)(e3)) - return p.from((0, o.hexlify)(e3)); - if (e3) - if (e3.toHexString) { - const t4 = e3.toHexString(); - if (typeof t4 == "string") - return p.from(t4); - } else { - let t4 = e3._hex; - if (t4 == null && e3.type === "BigNumber" && (t4 = e3.hex), typeof t4 == "string" && ((0, o.isHexString)(t4) || t4[0] === "-" && (0, o.isHexString)(t4.substring(1)))) - return p.from(t4); - } - return f.throwArgumentError("invalid BigNumber value", "value", t3); - } - static isBigNumber(t3) { - return !(!t3 || !t3._isBigNumber); - } - } - function y(t3) { - if (typeof t3 != "string") - return y(t3.toString(16)); - if (t3[0] === "-") - return (t3 = t3.substring(1))[0] === "-" && f.throwArgumentError("invalid hex", "value", t3), (t3 = y(t3)) === "0x00" ? t3 : "-" + t3; - if (t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), t3 === "0x") - return "0x00"; - for (t3.length % 2 && (t3 = "0x0" + t3.substring(2)); t3.length > 4 && t3.substring(0, 4) === "0x00"; ) - t3 = "0x" + t3.substring(4); - return t3; - } - function m(t3) { - return p.from(y(t3)); - } - function b(t3) { - const e3 = p.from(t3).toHexString(); - return e3[0] === "-" ? new u("-" + e3.substring(3), 16) : new u(e3.substring(2), 16); - } - function g(t3, e3, r3) { - const n2 = {fault: t3, operation: e3}; - return r3 != null && (n2.value = r3), f.throwError(t3, a.Yd.errors.NUMERIC_FAULT, n2); - } - function v(t3) { - return new u(t3, 36).toString(16); - } - function w(t3) { - return new u(t3, 16).toString(36); - } - }, 2092: (t2, e2, r2) => { - r2.r(e2), r2.d(e2, {BigNumber: () => n.O$, FixedFormat: () => m, FixedNumber: () => b, _base16To36: () => n.t2, _base36To16: () => n.g$, formatFixed: () => p, parseFixed: () => y}); - var n = r2(2593), i = r2(3286), o = r2(711), a = r2(8794); - const s = new o.Yd(a.i), u = {}, f = n.O$.from(0), c = n.O$.from(-1); - function h(t3, e3, r3, n2) { - const i2 = {fault: e3, operation: r3}; - return n2 !== void 0 && (i2.value = n2), s.throwError(t3, o.Yd.errors.NUMERIC_FAULT, i2); - } - let l = "0"; - for (; l.length < 256; ) - l += l; - function d(t3) { - if (typeof t3 != "number") - try { - t3 = n.O$.from(t3).toNumber(); - } catch (t4) { - } - return typeof t3 == "number" && t3 >= 0 && t3 <= 256 && !(t3 % 1) ? "1" + l.substring(0, t3) : s.throwArgumentError("invalid decimal size", "decimals", t3); - } - function p(t3, e3) { - e3 == null && (e3 = 0); - const r3 = d(e3), i2 = (t3 = n.O$.from(t3)).lt(f); - i2 && (t3 = t3.mul(c)); - let o2 = t3.mod(r3).toString(); - for (; o2.length < r3.length - 1; ) - o2 = "0" + o2; - o2 = o2.match(/^([0-9]*[1-9]|0)(0*)/)[1]; - const a2 = t3.div(r3).toString(); - return t3 = a2 + "." + o2, i2 && (t3 = "-" + t3), t3; - } - function y(t3, e3) { - e3 == null && (e3 = 0); - const r3 = d(e3); - if (typeof t3 == "string" && t3.match(/^-?[0-9.,]+$/) || s.throwArgumentError("invalid decimal value", "value", t3), r3.length - 1 == 0) - return n.O$.from(t3); - const i2 = t3.substring(0, 1) === "-"; - i2 && (t3 = t3.substring(1)), t3 === "." && s.throwArgumentError("missing value", "value", t3); - const o2 = t3.split("."); - o2.length > 2 && s.throwArgumentError("too many decimal points", "value", t3); - let a2 = o2[0], u2 = o2[1]; - for (a2 || (a2 = "0"), u2 || (u2 = "0"), u2.length > r3.length - 1 && h("fractional component exceeds decimals", "underflow", "parseFixed"); u2.length < r3.length - 1; ) - u2 += "0"; - const f2 = n.O$.from(a2), l2 = n.O$.from(u2); - let p2 = f2.mul(r3).add(l2); - return i2 && (p2 = p2.mul(c)), p2; - } - class m { - constructor(t3, e3, r3, n2) { - t3 !== u && s.throwError("cannot use FixedFormat constructor; use FixedFormat.from", o.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new FixedFormat"}), this.signed = e3, this.width = r3, this.decimals = n2, this.name = (e3 ? "" : "u") + "fixed" + String(r3) + "x" + String(n2), this._multiplier = d(n2), Object.freeze(this); - } - static from(t3) { - if (t3 instanceof m) - return t3; - let e3 = true, r3 = 128, n2 = 18; - if (typeof t3 == "string") { - if (t3 === "fixed") - ; - else if (t3 === "ufixed") - e3 = false; - else if (t3 != null) { - const i2 = t3.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); - i2 || s.throwArgumentError("invalid fixed format", "format", t3), e3 = i2[1] !== "u", r3 = parseInt(i2[2]), n2 = parseInt(i2[3]); - } - } else if (t3) { - const i2 = (e4, r4, n3) => t3[e4] == null ? n3 : (typeof t3[e4] !== r4 && s.throwArgumentError("invalid fixed format (" + e4 + " not " + r4 + ")", "format." + e4, t3[e4]), t3[e4]); - e3 = i2("signed", "boolean", e3), r3 = i2("width", "number", r3), n2 = i2("decimals", "number", n2); - } - return r3 % 8 && s.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", r3), n2 > 80 && s.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n2), new m(u, e3, r3, n2); - } - } - class b { - constructor(t3, e3, r3, n2) { - s.checkNew(new.target, b), t3 !== u && s.throwError("cannot use FixedNumber constructor; use FixedNumber.from", o.Yd.errors.UNSUPPORTED_OPERATION, {operation: "new FixedFormat"}), this.format = n2, this._hex = e3, this._value = r3, this._isFixedNumber = true, Object.freeze(this); - } - _checkFormat(t3) { - this.format.name !== t3.format.name && s.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t3); - } - addUnsafe(t3) { - this._checkFormat(t3); - const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); - return b.fromValue(e3.add(r3), this.format.decimals, this.format); - } - subUnsafe(t3) { - this._checkFormat(t3); - const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); - return b.fromValue(e3.sub(r3), this.format.decimals, this.format); - } - mulUnsafe(t3) { - this._checkFormat(t3); - const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); - return b.fromValue(e3.mul(r3).div(this.format._multiplier), this.format.decimals, this.format); - } - divUnsafe(t3) { - this._checkFormat(t3); - const e3 = y(this._value, this.format.decimals), r3 = y(t3._value, t3.format.decimals); - return b.fromValue(e3.mul(this.format._multiplier).div(r3), this.format.decimals, this.format); - } - floor() { - let t3 = this.toString().split("."), e3 = b.from(t3[0], this.format); - const r3 = !t3[1].match(/^(0*)$/); - return this.isNegative() && r3 && (e3 = e3.subUnsafe(g)), e3; - } - ceiling() { - let t3 = this.toString().split("."), e3 = b.from(t3[0], this.format); - const r3 = !t3[1].match(/^(0*)$/); - return !this.isNegative() && r3 && (e3 = e3.addUnsafe(g)), e3; - } - round(t3) { - t3 == null && (t3 = 0); - let e3 = this.toString().split("."); - if ((t3 < 0 || t3 > 80 || t3 % 1) && s.throwArgumentError("invalid decimal count", "decimals", t3), e3[1].length <= t3) - return this; - const r3 = b.from("1" + l.substring(0, t3)); - return this.mulUnsafe(r3).addUnsafe(v).floor().divUnsafe(r3); - } - isZero() { - return this._value === "0.0"; - } - isNegative() { - return this._value[0] === "-"; - } - toString() { - return this._value; - } - toHexString(t3) { - if (t3 == null) - return this._hex; - t3 % 8 && s.throwArgumentError("invalid byte width", "width", t3); - const e3 = n.O$.from(this._hex).fromTwos(this.format.width).toTwos(t3).toHexString(); - return (0, i.hexZeroPad)(e3, t3 / 8); - } - toUnsafeFloat() { - return parseFloat(this.toString()); - } - toFormat(t3) { - return b.fromString(this._value, t3); - } - static fromValue(t3, e3, r3) { - return r3 != null || e3 == null || (0, n.Zm)(e3) || (r3 = e3, e3 = null), e3 == null && (e3 = 0), r3 == null && (r3 = "fixed"), b.fromString(p(t3, e3), m.from(r3)); - } - static fromString(t3, e3) { - e3 == null && (e3 = "fixed"); - const r3 = m.from(e3), n2 = y(t3, r3.decimals); - !r3.signed && n2.lt(f) && h("unsigned value cannot be negative", "overflow", "value", t3); - let o2 = null; - r3.signed ? o2 = n2.toTwos(r3.width).toHexString() : (o2 = n2.toHexString(), o2 = (0, i.hexZeroPad)(o2, r3.width / 8)); - const a2 = p(n2, r3.decimals); - return new b(u, o2, a2, r3); - } - static fromBytes(t3, e3) { - e3 == null && (e3 = "fixed"); - const r3 = m.from(e3); - if ((0, i.arrayify)(t3).length > r3.width / 8) - throw new Error("overflow"); - let o2 = n.O$.from(t3); - r3.signed && (o2 = o2.fromTwos(r3.width)); - const a2 = o2.toTwos((r3.signed ? 0 : 1) + r3.width).toHexString(), s2 = p(o2, r3.decimals); - return new b(u, a2, s2, r3); - } - static from(t3, e3) { - if (typeof t3 == "string") - return b.fromString(t3, e3); - if ((0, i.isBytes)(t3)) - return b.fromBytes(t3, e3); - try { - return b.fromValue(t3, 0, e3); - } catch (t4) { - if (t4.code !== o.Yd.errors.INVALID_ARGUMENT) - throw t4; - } - return s.throwArgumentError("invalid FixedNumber value", "value", t3); - } - static isFixedNumber(t3) { - return !(!t3 || !t3._isFixedNumber); - } - } - const g = b.from(1), v = b.from("0.5"); - }, 3286: (t2, e2, r2) => { - r2.r(e2), r2.d(e2, {arrayify: () => u, concat: () => f, hexConcat: () => b, hexDataLength: () => y, hexDataSlice: () => m, hexStripZeros: () => v, hexValue: () => g, hexZeroPad: () => w, hexlify: () => p, isBytes: () => s, isBytesLike: () => a, isHexString: () => l, joinSignature: () => M, splitSignature: () => _, stripZeros: () => c, zeroPad: () => h}); - const n = new (r2(711)).Yd("bytes/5.1.0"); - function i(t3) { - return !!t3.toHexString; - } - function o(t3) { - return t3.slice || (t3.slice = function() { - const e3 = Array.prototype.slice.call(arguments); - return o(new Uint8Array(Array.prototype.slice.apply(t3, e3))); - }), t3; - } - function a(t3) { - return l(t3) && !(t3.length % 2) || s(t3); - } - function s(t3) { - if (t3 == null) - return false; - if (t3.constructor === Uint8Array) - return true; - if (typeof t3 == "string") - return false; - if (t3.length == null) - return false; - for (let e3 = 0; e3 < t3.length; e3++) { - const r3 = t3[e3]; - if (typeof r3 != "number" || r3 < 0 || r3 >= 256 || r3 % 1) - return false; - } - return true; - } - function u(t3, e3) { - if (e3 || (e3 = {}), typeof t3 == "number") { - n.checkSafeUint53(t3, "invalid arrayify value"); - const e4 = []; - for (; t3; ) - e4.unshift(255 & t3), t3 = parseInt(String(t3 / 256)); - return e4.length === 0 && e4.push(0), o(new Uint8Array(e4)); - } - if (e3.allowMissingPrefix && typeof t3 == "string" && t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), i(t3) && (t3 = t3.toHexString()), l(t3)) { - let r3 = t3.substring(2); - r3.length % 2 && (e3.hexPad === "left" ? r3 = "0x0" + r3.substring(2) : e3.hexPad === "right" ? r3 += "0" : n.throwArgumentError("hex data is odd-length", "value", t3)); - const i2 = []; - for (let t4 = 0; t4 < r3.length; t4 += 2) - i2.push(parseInt(r3.substring(t4, t4 + 2), 16)); - return o(new Uint8Array(i2)); - } - return s(t3) ? o(new Uint8Array(t3)) : n.throwArgumentError("invalid arrayify value", "value", t3); - } - function f(t3) { - const e3 = t3.map((t4) => u(t4)), r3 = e3.reduce((t4, e4) => t4 + e4.length, 0), n2 = new Uint8Array(r3); - return e3.reduce((t4, e4) => (n2.set(e4, t4), t4 + e4.length), 0), o(n2); - } - function c(t3) { - let e3 = u(t3); - if (e3.length === 0) - return e3; - let r3 = 0; - for (; r3 < e3.length && e3[r3] === 0; ) - r3++; - return r3 && (e3 = e3.slice(r3)), e3; - } - function h(t3, e3) { - (t3 = u(t3)).length > e3 && n.throwArgumentError("value out of range", "value", arguments[0]); - const r3 = new Uint8Array(e3); - return r3.set(t3, e3 - t3.length), o(r3); - } - function l(t3, e3) { - return !(typeof t3 != "string" || !t3.match(/^0x[0-9A-Fa-f]*$/) || e3 && t3.length !== 2 + 2 * e3); - } - const d = "0123456789abcdef"; - function p(t3, e3) { - if (e3 || (e3 = {}), typeof t3 == "number") { - n.checkSafeUint53(t3, "invalid hexlify value"); - let e4 = ""; - for (; t3; ) - e4 = d[15 & t3] + e4, t3 = Math.floor(t3 / 16); - return e4.length ? (e4.length % 2 && (e4 = "0" + e4), "0x" + e4) : "0x00"; - } - if (e3.allowMissingPrefix && typeof t3 == "string" && t3.substring(0, 2) !== "0x" && (t3 = "0x" + t3), i(t3)) - return t3.toHexString(); - if (l(t3)) - return t3.length % 2 && (e3.hexPad === "left" ? t3 = "0x0" + t3.substring(2) : e3.hexPad === "right" ? t3 += "0" : n.throwArgumentError("hex data is odd-length", "value", t3)), t3.toLowerCase(); - if (s(t3)) { - let e4 = "0x"; - for (let r3 = 0; r3 < t3.length; r3++) { - let n2 = t3[r3]; - e4 += d[(240 & n2) >> 4] + d[15 & n2]; - } - return e4; - } - return n.throwArgumentError("invalid hexlify value", "value", t3); - } - function y(t3) { - if (typeof t3 != "string") - t3 = p(t3); - else if (!l(t3) || t3.length % 2) - return null; - return (t3.length - 2) / 2; - } - function m(t3, e3, r3) { - return typeof t3 != "string" ? t3 = p(t3) : (!l(t3) || t3.length % 2) && n.throwArgumentError("invalid hexData", "value", t3), e3 = 2 + 2 * e3, r3 != null ? "0x" + t3.substring(e3, 2 + 2 * r3) : "0x" + t3.substring(e3); - } - function b(t3) { - let e3 = "0x"; - return t3.forEach((t4) => { - e3 += p(t4).substring(2); - }), e3; - } - function g(t3) { - const e3 = v(p(t3, {hexPad: "left"})); - return e3 === "0x" ? "0x0" : e3; - } - function v(t3) { - typeof t3 != "string" && (t3 = p(t3)), l(t3) || n.throwArgumentError("invalid hex string", "value", t3), t3 = t3.substring(2); - let e3 = 0; - for (; e3 < t3.length && t3[e3] === "0"; ) - e3++; - return "0x" + t3.substring(e3); - } - function w(t3, e3) { - for (typeof t3 != "string" ? t3 = p(t3) : l(t3) || n.throwArgumentError("invalid hex string", "value", t3), t3.length > 2 * e3 + 2 && n.throwArgumentError("value out of range", "value", arguments[1]); t3.length < 2 * e3 + 2; ) - t3 = "0x0" + t3.substring(2); - return t3; - } - function _(t3) { - const e3 = {r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0}; - if (a(t3)) { - const r3 = u(t3); - r3.length !== 65 && n.throwArgumentError("invalid signature string; must be 65 bytes", "signature", t3), e3.r = p(r3.slice(0, 32)), e3.s = p(r3.slice(32, 64)), e3.v = r3[64], e3.v < 27 && (e3.v === 0 || e3.v === 1 ? e3.v += 27 : n.throwArgumentError("signature invalid v byte", "signature", t3)), e3.recoveryParam = 1 - e3.v % 2, e3.recoveryParam && (r3[32] |= 128), e3._vs = p(r3.slice(32, 64)); - } else { - if (e3.r = t3.r, e3.s = t3.s, e3.v = t3.v, e3.recoveryParam = t3.recoveryParam, e3._vs = t3._vs, e3._vs != null) { - const r4 = h(u(e3._vs), 32); - e3._vs = p(r4); - const i3 = r4[0] >= 128 ? 1 : 0; - e3.recoveryParam == null ? e3.recoveryParam = i3 : e3.recoveryParam !== i3 && n.throwArgumentError("signature recoveryParam mismatch _vs", "signature", t3), r4[0] &= 127; - const o2 = p(r4); - e3.s == null ? e3.s = o2 : e3.s !== o2 && n.throwArgumentError("signature v mismatch _vs", "signature", t3); - } - e3.recoveryParam == null ? e3.v == null ? n.throwArgumentError("signature missing v and recoveryParam", "signature", t3) : e3.v === 0 || e3.v === 1 ? e3.recoveryParam = e3.v : e3.recoveryParam = 1 - e3.v % 2 : e3.v == null ? e3.v = 27 + e3.recoveryParam : e3.recoveryParam !== 1 - e3.v % 2 && n.throwArgumentError("signature recoveryParam mismatch v", "signature", t3), e3.r != null && l(e3.r) ? e3.r = w(e3.r, 32) : n.throwArgumentError("signature missing or invalid r", "signature", t3), e3.s != null && l(e3.s) ? e3.s = w(e3.s, 32) : n.throwArgumentError("signature missing or invalid s", "signature", t3); - const r3 = u(e3.s); - r3[0] >= 128 && n.throwArgumentError("signature s out of range", "signature", t3), e3.recoveryParam && (r3[0] |= 128); - const i2 = p(r3); - e3._vs && (l(e3._vs) || n.throwArgumentError("signature invalid _vs", "signature", t3), e3._vs = w(e3._vs, 32)), e3._vs == null ? e3._vs = i2 : e3._vs !== i2 && n.throwArgumentError("signature _vs mismatch v and s", "signature", t3); - } - return e3; - } - function M(t3) { - return p(f([(t3 = _(t3)).r, t3.s, t3.recoveryParam ? "0x1c" : "0x1b"])); - } - }, 2279: (t2, e2, r2) => { - r2.r(e2), r2.d(e2, {AddressZero: () => n, EtherSymbol: () => l, HashZero: () => h, MaxUint256: () => c, NegativeOne: () => o, One: () => s, Two: () => u, WeiPerEther: () => f, Zero: () => a}); - const n = "0x0000000000000000000000000000000000000000"; - var i = r2(2593); - const o = i.O$.from(-1), a = i.O$.from(0), s = i.O$.from(1), u = i.O$.from(2), f = i.O$.from("1000000000000000000"), c = i.O$.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), h = "0x0000000000000000000000000000000000000000000000000000000000000000", l = "\u039E"; - }, 711: (t2, e2, r2) => { - r2.d(e2, {Yd: () => h}); - let n = false, i = false; - const o = {debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5}; - let a = o.default, s = null; - const u = function() { - try { - const t3 = []; - if (["NFD", "NFC", "NFKD", "NFKC"].forEach((e3) => { - try { - if ("test".normalize(e3) !== "test") - throw new Error("bad normalize"); - } catch (r3) { - t3.push(e3); - } - }), t3.length) - throw new Error("missing " + t3.join(", ")); - if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) - throw new Error("broken implementation"); - } catch (t3) { - return t3.message; - } - return null; - }(); - var f, c; - !function(t3) { - t3.DEBUG = "DEBUG", t3.INFO = "INFO", t3.WARNING = "WARNING", t3.ERROR = "ERROR", t3.OFF = "OFF"; - }(f || (f = {})), function(t3) { - t3.UNKNOWN_ERROR = "UNKNOWN_ERROR", t3.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", t3.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", t3.NETWORK_ERROR = "NETWORK_ERROR", t3.SERVER_ERROR = "SERVER_ERROR", t3.TIMEOUT = "TIMEOUT", t3.BUFFER_OVERRUN = "BUFFER_OVERRUN", t3.NUMERIC_FAULT = "NUMERIC_FAULT", t3.MISSING_NEW = "MISSING_NEW", t3.INVALID_ARGUMENT = "INVALID_ARGUMENT", t3.MISSING_ARGUMENT = "MISSING_ARGUMENT", t3.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", t3.CALL_EXCEPTION = "CALL_EXCEPTION", t3.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", t3.NONCE_EXPIRED = "NONCE_EXPIRED", t3.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", t3.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; - }(c || (c = {})); - class h { - constructor(t3) { - Object.defineProperty(this, "version", {enumerable: true, value: t3, writable: false}); - } - _log(t3, e3) { - const r3 = t3.toLowerCase(); - o[r3] == null && this.throwArgumentError("invalid log level name", "logLevel", t3), a > o[r3] || console.log.apply(console, e3); - } - debug(...t3) { - this._log(h.levels.DEBUG, t3); - } - info(...t3) { - this._log(h.levels.INFO, t3); - } - warn(...t3) { - this._log(h.levels.WARNING, t3); - } - makeError(t3, e3, r3) { - if (i) - return this.makeError("censored error", e3, {}); - e3 || (e3 = h.errors.UNKNOWN_ERROR), r3 || (r3 = {}); - const n2 = []; - Object.keys(r3).forEach((t4) => { - try { - n2.push(t4 + "=" + JSON.stringify(r3[t4])); - } catch (e4) { - n2.push(t4 + "=" + JSON.stringify(r3[t4].toString())); - } - }), n2.push(`code=${e3}`), n2.push(`version=${this.version}`); - const o2 = t3; - n2.length && (t3 += " (" + n2.join(", ") + ")"); - const a2 = new Error(t3); - return a2.reason = o2, a2.code = e3, Object.keys(r3).forEach(function(t4) { - a2[t4] = r3[t4]; - }), a2; - } - throwError(t3, e3, r3) { - throw this.makeError(t3, e3, r3); - } - throwArgumentError(t3, e3, r3) { - return this.throwError(t3, h.errors.INVALID_ARGUMENT, {argument: e3, value: r3}); - } - assert(t3, e3, r3, n2) { - t3 || this.throwError(e3, r3, n2); - } - assertArgument(t3, e3, r3, n2) { - t3 || this.throwArgumentError(e3, r3, n2); - } - checkNormalize(t3) { - u && this.throwError("platform missing String.prototype.normalize", h.errors.UNSUPPORTED_OPERATION, {operation: "String.prototype.normalize", form: u}); - } - checkSafeUint53(t3, e3) { - typeof t3 == "number" && (e3 == null && (e3 = "value not safe"), (t3 < 0 || t3 >= 9007199254740991) && this.throwError(e3, h.errors.NUMERIC_FAULT, {operation: "checkSafeInteger", fault: "out-of-safe-range", value: t3}), t3 % 1 && this.throwError(e3, h.errors.NUMERIC_FAULT, {operation: "checkSafeInteger", fault: "non-integer", value: t3})); - } - checkArgumentCount(t3, e3, r3) { - r3 = r3 ? ": " + r3 : "", t3 < e3 && this.throwError("missing argument" + r3, h.errors.MISSING_ARGUMENT, {count: t3, expectedCount: e3}), t3 > e3 && this.throwError("too many arguments" + r3, h.errors.UNEXPECTED_ARGUMENT, {count: t3, expectedCount: e3}); - } - checkNew(t3, e3) { - t3 !== Object && t3 != null || this.throwError("missing new", h.errors.MISSING_NEW, {name: e3.name}); - } - checkAbstract(t3, e3) { - t3 === e3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(e3.name) + " directly; use a sub-class", h.errors.UNSUPPORTED_OPERATION, {name: t3.name, operation: "new"}) : t3 !== Object && t3 != null || this.throwError("missing new", h.errors.MISSING_NEW, {name: e3.name}); - } - static globalLogger() { - return s || (s = new h("logger/5.1.0")), s; - } - static setCensorship(t3, e3) { - if (!t3 && e3 && this.globalLogger().throwError("cannot permanently disable censorship", h.errors.UNSUPPORTED_OPERATION, {operation: "setCensorship"}), n) { - if (!t3) - return; - this.globalLogger().throwError("error censorship permanent", h.errors.UNSUPPORTED_OPERATION, {operation: "setCensorship"}); - } - i = !!t3, n = !!e3; - } - static setLogLevel(t3) { - const e3 = o[t3.toLowerCase()]; - e3 != null ? a = e3 : h.globalLogger().warn("invalid log level - " + t3); - } - static from(t3) { - return new h(t3); - } - } - h.errors = c, h.levels = f; - }, 2440: function(t2, e2) { - var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o) { - function a(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o(t5); - } - } - function s(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a, s); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, n = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o, a = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { - return this; - }), o; - function s(o2) { - return function(s2) { - return function(o3) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o3[1])).done) - return i2; - switch (n2 = 0, i2 && (o3 = [2 & o3[0], i2.value]), o3[0]) { - case 0: - case 1: - i2 = o3; - break; - case 4: - return a.label++, {value: o3[1], done: false}; - case 5: - a.label++, n2 = o3[1], o3 = [0]; - continue; - case 7: - o3 = a.ops.pop(), a.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a.trys).length > 0 && i2[i2.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { - a = 0; - continue; - } - if (o3[0] === 3 && (!i2 || o3[1] > i2[0] && o3[1] < i2[3])) { - a.label = o3[1]; - break; - } - if (o3[0] === 6 && a.label < i2[1]) { - a.label = i2[1], i2 = o3; - break; - } - if (i2 && a.label < i2[2]) { - a.label = i2[2], a.ops.push(o3); - break; - } - i2[2] && a.ops.pop(), a.trys.pop(); - continue; - } - o3 = e3.call(t3, a); - } catch (t4) { - o3 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o3[0]) - throw o3[1]; - return {value: o3[0] ? o3[1] : void 0, done: true}; - }([o2, s2]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var i = function() { - function t3(t4) { - this.requestManager = t4; - } - return t3.prototype.startBatch = function() { - return this.requestManager.startBatch(); - }, t3.prototype.stopBatch = function() { - return this.requestManager.stopBatch(); - }, t3.prototype.request = function(t4, e3) { - return r2(this, void 0, void 0, function() { - return n(this, function(r3) { - switch (r3.label) { - case 0: - return this.requestManager.connectPromise ? [4, this.requestManager.connectPromise] : [3, 2]; - case 1: - r3.sent(), r3.label = 2; - case 2: - return [2, this.requestManager.request(t4, false, e3)]; - } - }); - }); - }, t3.prototype.notify = function(t4) { - return r2(this, void 0, void 0, function() { - return n(this, function(e3) { - switch (e3.label) { - case 0: - return this.requestManager.connectPromise ? [4, this.requestManager.connectPromise] : [3, 2]; - case 1: - e3.sent(), e3.label = 2; - case 2: - return [2, this.requestManager.request(t4, true, null)]; - } - }); - }); - }, t3.prototype.onNotification = function(t4) { - this.requestManager.requestChannel.addListener("notification", t4); - }, t3.prototype.onError = function(t4) { - this.requestManager.requestChannel.addListener("error", t4); - }, t3.prototype.close = function() { - this.requestManager.close(); - }, t3; - }(); - e2.default = i; - }, 9931: function(t2, e2) { - var r2, n = this && this.__extends || (r2 = function(t3, e3) { - return (r2 = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function n2() { - this.constructor = t3; - } - r2(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (n2.prototype = e3.prototype, new n2()); - }); - Object.defineProperty(e2, "__esModule", {value: true}), e2.convertJSONToRPCError = e2.JSONRPCError = e2.ERR_UNKNOWN = e2.ERR_MISSIING_ID = e2.ERR_TIMEOUT = void 0, e2.ERR_TIMEOUT = 7777, e2.ERR_MISSIING_ID = 7878, e2.ERR_UNKNOWN = 7979; - var i = function(t3) { - function e3(e4, r3, n2) { - var i2 = this.constructor, o = t3.call(this, e4) || this; - return o.message = e4, o.code = r3, o.data = n2, Object.setPrototypeOf(o, i2.prototype), o; - } - return n(e3, t3), e3; - }(Error); - e2.JSONRPCError = i, e2.convertJSONToRPCError = function(t3) { - if (t3.error) { - var r3 = t3.error, n2 = r3.message, o = r3.code, a = r3.data; - return new i(n2, o, a); - } - return new i("Unknown error", e2.ERR_UNKNOWN, t3); - }; - }, 7182: (t2, e2) => { - Object.defineProperty(e2, "__esModule", {value: true}), e2.getNotifications = e2.getBatchRequests = e2.isNotification = void 0, e2.isNotification = function(t3) { - return t3.request.id === void 0 || t3.request.id === null; - }, e2.getBatchRequests = function(t3) { - return t3 instanceof Array ? t3.filter(function(t4) { - return t4.request.request.id != null; - }).map(function(t4) { - return t4.request; - }) : []; - }, e2.getNotifications = function(t3) { - return t3 instanceof Array ? t3.filter(function(t4) { - return e2.isNotification(t4.request); - }).map(function(t4) { - return t4.request; - }) : e2.isNotification(t3) ? [t3] : []; - }; - }, 2752: function(t2, e2, r2) { - var n = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, i = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s(o3) { - return function(s2) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s2]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var o = r2(7187), a = function() { - function t3(t4) { - this.batch = [], this.batchStarted = false, this.lastId = -1, this.transports = t4, this.requests = {}, this.connectPromise = this.connect(), this.requestChannel = new o.EventEmitter(); - } - return t3.prototype.connect = function() { - var t4 = this; - return Promise.all(this.transports.map(function(e3) { - return n(t4, void 0, void 0, function() { - return i(this, function(t5) { - switch (t5.label) { - case 0: - return e3.subscribe("error", this.handleError.bind(this)), e3.subscribe("notification", this.handleNotification.bind(this)), [4, e3.connect()]; - case 1: - return t5.sent(), [2]; - } - }); - }); - })); - }, t3.prototype.getPrimaryTransport = function() { - return this.transports[0]; - }, t3.prototype.request = function(t4, e3, r3) { - return e3 === void 0 && (e3 = false), n(this, void 0, void 0, function() { - var n2, o2, a2, s = this; - return i(this, function(i2) { - return n2 = (++this.lastId).toString(), o2 = e3 ? null : n2, a2 = {request: this.makeRequest(t4.method, t4.params || [], o2), internalID: n2}, this.batchStarted ? [2, new Promise(function(t5, e4) { - s.batch.push({resolve: t5, reject: e4, request: a2}); - })] : [2, this.getPrimaryTransport().sendData(a2, r3)]; - }); - }); - }, t3.prototype.close = function() { - this.requestChannel.removeAllListeners(), this.transports.forEach(function(t4) { - t4.unsubscribe(), t4.close(); - }); - }, t3.prototype.startBatch = function() { - this.batchStarted = true; - }, t3.prototype.stopBatch = function() { - if (this.batchStarted === false) - throw new Error("cannot end that which has never started"); - this.batch.length !== 0 ? (this.getPrimaryTransport().sendData(this.batch), this.batch = [], this.batchStarted = false) : this.batchStarted = false; - }, t3.prototype.makeRequest = function(t4, e3, r3) { - return r3 ? {jsonrpc: "2.0", id: r3, method: t4, params: e3} : {jsonrpc: "2.0", method: t4, params: e3}; - }, t3.prototype.handleError = function(t4) { - this.requestChannel.emit("error", t4); - }, t3.prototype.handleNotification = function(t4) { - this.requestChannel.emit("notification", t4); - }, t3; - }(); - e2.default = a; - }, 4927: function(t2, e2, r2) { - var n = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.PostMessageIframeTransport = e2.PostMessageWindowTransport = e2.JSONRPCError = e2.WebSocketTransport = e2.EventEmitterTransport = e2.HTTPTransport = e2.RequestManager = e2.Client = void 0; - var i = n(r2(2752)); - e2.RequestManager = i.default; - var o = n(r2(2300)); - e2.EventEmitterTransport = o.default; - var a = n(r2(2855)); - e2.HTTPTransport = a.default; - var s = n(r2(6628)); - e2.WebSocketTransport = s.default; - var u = n(r2(6514)); - e2.PostMessageWindowTransport = u.default; - var f = n(r2(5280)); - e2.PostMessageIframeTransport = f.default; - var c = r2(9931); - Object.defineProperty(e2, "JSONRPCError", {enumerable: true, get: function() { - return c.JSONRPCError; - }}); - var h = n(r2(2440)); - e2.Client = h.default, e2.default = h.default; - }, 2300: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }); - Object.defineProperty(e2, "__esModule", {value: true}); - var o = r2(3629), a = r2(7182), s = r2(9931), u = function(t3) { - function e3(e4, r3, n2) { - var i2 = t3.call(this) || this; - return i2.connection = e4, i2.reqUri = r3, i2.resUri = n2, i2; - } - return i(e3, t3), e3.prototype.connect = function() { - var t4 = this; - return this.connection.on(this.resUri, function(e4) { - t4.transportRequestManager.resolveResponse(e4); - }), Promise.resolve(); - }, e3.prototype.sendData = function(t4, e4) { - e4 === void 0 && (e4 = null); - var r3 = this.transportRequestManager.addRequest(t4, e4), n2 = a.getNotifications(t4), i2 = this.parseData(t4); - try { - return this.connection.emit(this.reqUri, i2), this.transportRequestManager.settlePendingRequest(n2), r3; - } catch (t5) { - var o2 = new s.JSONRPCError(t5.message, s.ERR_UNKNOWN, t5); - return this.transportRequestManager.settlePendingRequest(n2, o2), Promise.reject(o2); - } - }, e3.prototype.close = function() { - this.connection.removeAllListeners(); - }, e3; - }(o.Transport); - e2.default = u; - }, 2855: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), o = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u2(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u2(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u2(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u2((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, a = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }, s = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.HTTPTransport = void 0; - var u = s(r2(4301)), f = r2(3629), c = r2(7182), h = r2(9931), l = function(t3) { - function e3(r3, n2) { - var i2 = t3.call(this) || this; - return i2.onlyNotifications = function(t4) { - return t4 instanceof Array ? t4.every(function(t5) { - return t5.request.request.id === null || t5.request.request.id === void 0; - }) : t4.request.id === null || t4.request.id === void 0; - }, i2.uri = r3, i2.credentials = n2 && n2.credentials, i2.headers = e3.setupHeaders(n2 && n2.headers), i2; - } - return i(e3, t3), e3.prototype.connect = function() { - return Promise.resolve(); - }, e3.prototype.sendData = function(t4, e4) { - return e4 === void 0 && (e4 = null), o(this, void 0, void 0, function() { - var r3, n2, i2, o2, s2, f2, l2; - return a(this, function(a2) { - switch (a2.label) { - case 0: - r3 = this.transportRequestManager.addRequest(t4, e4), n2 = c.getNotifications(t4), i2 = c.getBatchRequests(t4), a2.label = 1; - case 1: - return a2.trys.push([1, 4, , 5]), [4, u.default(this.uri, {method: "POST", headers: this.headers, body: JSON.stringify(this.parseData(t4)), credentials: this.credentials})]; - case 2: - return o2 = a2.sent(), this.transportRequestManager.settlePendingRequest(n2), this.onlyNotifications(t4) ? [2, Promise.resolve()] : [4, o2.text()]; - case 3: - return s2 = a2.sent(), (l2 = this.transportRequestManager.resolveResponse(s2)) ? (this.transportRequestManager.settlePendingRequest(i2, l2), [2, Promise.reject(l2)]) : [3, 5]; - case 4: - return f2 = a2.sent(), l2 = new h.JSONRPCError(f2.message, h.ERR_UNKNOWN, f2), this.transportRequestManager.settlePendingRequest(n2, l2), this.transportRequestManager.settlePendingRequest(c.getBatchRequests(t4), l2), [2, Promise.reject(l2)]; - case 5: - return [2, r3]; - } - }); - }); - }, e3.prototype.close = function() { - }, e3.setupHeaders = function(t4) { - var e4 = new Headers(t4); - return e4.set("Content-Type", "application/json"), e4; - }, e3; - }(f.Transport); - e2.HTTPTransport = l, e2.default = l; - }, 5280: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), o = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, a = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var s = function(t3) { - function e3(e4) { - var r3 = t3.call(this) || this; - return r3.messageHandler = function(t4) { - r3.transportRequestManager.resolveResponse(JSON.stringify(t4.data)); - }, r3.uri = e4, r3.postMessageID = "post-message-transport-" + Math.random(), r3; - } - return i(e3, t3), e3.prototype.createWindow = function(t4) { - var e4 = this; - return new Promise(function(r3, n2) { - var i2, o2 = document.createElement("iframe"); - o2.setAttribute("id", e4.postMessageID), o2.setAttribute("width", "0px"), o2.setAttribute("height", "0px"), o2.setAttribute("style", "visiblity:hidden;border:none;outline:none;"), o2.addEventListener("load", function() { - r3(i2); - }), o2.setAttribute("src", t4), window.document.body.appendChild(o2), i2 = o2.contentWindow; - }); - }, e3.prototype.connect = function() { - var t4 = this, e4 = /^(http|https):\/\/.*$/; - return new Promise(function(r3, n2) { - return o(t4, void 0, void 0, function() { - var t5; - return a(this, function(i2) { - switch (i2.label) { - case 0: - return e4.test(this.uri) || n2(new Error("Bad URI")), t5 = this, [4, this.createWindow(this.uri)]; - case 1: - return t5.frame = i2.sent(), window.addEventListener("message", this.messageHandler), r3(), [2]; - } - }); - }); - }); - }, e3.prototype.sendData = function(t4, e4) { - return o(this, void 0, void 0, function() { - var e5; - return a(this, function(r3) { - return e5 = this.transportRequestManager.addRequest(t4, null), this.frame && this.frame.postMessage(t4.request, "*"), [2, e5]; - }); - }); - }, e3.prototype.close = function() { - var t4 = document.getElementById(this.postMessageID); - t4 == null || t4.remove(), window.removeEventListener("message", this.messageHandler); - }, e3; - }(r2(3629).Transport); - e2.default = s; - }, 6514: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), o = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, a = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var s = function(t3) { - function e3(e4) { - var r3 = t3.call(this) || this; - return r3.messageHandler = function(t4) { - r3.transportRequestManager.resolveResponse(JSON.stringify(t4.data)); - }, r3.uri = e4, r3.postMessageID = "post-message-transport-" + Math.random(), r3; - } - return i(e3, t3), e3.prototype.createWindow = function(t4) { - return new Promise(function(e4, r3) { - var n2, i2, o2; - i2 = t4, o2 = window.screen.height, n2 = window.open(i2, "inspector:popup", "left=0,top=0,width=400,height=" + o2 + ",resizable,scrollbars=yes,status=1"), setTimeout(function() { - e4(n2); - }, 3e3); - }); - }, e3.prototype.connect = function() { - var t4 = this, e4 = /^(http|https):\/\/.*$/; - return new Promise(function(r3, n2) { - return o(t4, void 0, void 0, function() { - var t5; - return a(this, function(i2) { - switch (i2.label) { - case 0: - return e4.test(this.uri) || n2(new Error("Bad URI")), t5 = this, [4, this.createWindow(this.uri)]; - case 1: - return t5.frame = i2.sent(), window.addEventListener("message", this.messageHandler), r3(), [2]; - } - }); - }); - }); - }, e3.prototype.sendData = function(t4, e4) { - return o(this, void 0, void 0, function() { - var e5; - return a(this, function(r3) { - return e5 = this.transportRequestManager.addRequest(t4, null), this.frame && this.frame.postMessage(t4.request, this.uri), [2, e5]; - }); - }); - }, e3.prototype.close = function() { - this.frame && (window.removeEventListener("message", this.messageHandler), this.frame.close()); - }, e3; - }(r2(3629).Transport); - e2.default = s; - }, 3629: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}), e2.Transport = void 0; - var n = r2(7016), i = function() { - function t3() { - this.transportRequestManager = new n.TransportRequestManager(), this.transportRequestManager.transportEventChannel.on("error", function() { - }); - } - return t3.prototype.subscribe = function(t4, e3) { - this.transportRequestManager.transportEventChannel.addListener(t4, e3); - }, t3.prototype.unsubscribe = function(t4, e3) { - if (!t4) - return this.transportRequestManager.transportEventChannel.removeAllListeners(); - t4 && e3 && this.transportRequestManager.transportEventChannel.removeListener(t4, e3); - }, t3.prototype.parseData = function(t4) { - return t4 instanceof Array ? t4.map(function(t5) { - return t5.request.request; - }) : t4.request; - }, t3; - }(); - e2.Transport = i; - }, 7016: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}), e2.TransportRequestManager = void 0; - var n = r2(7187), i = r2(9931), o = function() { - function t3() { - this.pendingRequest = {}, this.pendingBatchRequest = {}, this.transportEventChannel = new n.EventEmitter(); - } - return t3.prototype.addRequest = function(t4, e3) { - return this.transportEventChannel.emit("pending", t4), t4 instanceof Array ? (this.addBatchReq(t4, e3), Promise.resolve()) : this.addReq(t4.internalID, e3); - }, t3.prototype.settlePendingRequest = function(t4, e3) { - var r3 = this; - t4.forEach(function(t5) { - var n2 = r3.pendingRequest[t5.internalID]; - delete r3.pendingBatchRequest[t5.internalID], n2 !== void 0 && (e3 ? n2.reject(e3) : n2.resolve()); - }); - }, t3.prototype.resolveResponse = function(t4, e3) { - e3 === void 0 && (e3 = true); - var r3 = t4; - try { - if (r3 = JSON.parse(t4), this.checkJSONRPC(r3) === false) - return; - return r3 instanceof Array ? this.resolveBatch(r3, e3) : this.resolveRes(r3, e3); - } catch (r4) { - var n2 = new i.JSONRPCError("Bad response format", i.ERR_UNKNOWN, t4); - return e3 && this.transportEventChannel.emit("error", n2), n2; - } - }, t3.prototype.addBatchReq = function(t4, e3) { - var r3 = this; - return t4.forEach(function(t5) { - var e4 = t5.resolve, n2 = t5.reject, i2 = t5.request.internalID; - r3.pendingBatchRequest[i2] = true, r3.pendingRequest[i2] = {resolve: e4, reject: n2}; - }), Promise.resolve(); - }, t3.prototype.addReq = function(t4, e3) { - var r3 = this; - return new Promise(function(n2, i2) { - e3 !== null && e3 && r3.setRequestTimeout(t4, e3, i2), r3.pendingRequest[t4] = {resolve: n2, reject: i2}; - }); - }, t3.prototype.checkJSONRPC = function(t4) { - var e3 = [t4]; - return t4 instanceof Array && (e3 = t4), e3.every(function(t5) { - return t5.result !== void 0 || t5.error !== void 0 || t5.method !== void 0; - }); - }, t3.prototype.processResult = function(t4, e3) { - if (t4.error) { - var r3 = i.convertJSONToRPCError(t4); - e3.reject(r3); - } else - e3.resolve(t4.result); - }, t3.prototype.resolveBatch = function(t4, e3) { - var r3 = this, n2 = t4.map(function(t5) { - return r3.resolveRes(t5, e3); - }).filter(function(t5) { - return t5; - }); - if (n2.length > 0) - return n2[0]; - }, t3.prototype.resolveRes = function(t4, e3) { - var r3, n2 = t4.id, o2 = t4.error, a = this.pendingRequest[n2]; - return a ? (delete this.pendingRequest[n2], this.processResult(t4, a), void this.transportEventChannel.emit("response", t4)) : n2 !== void 0 || o2 !== void 0 ? (o2 && (r3 = i.convertJSONToRPCError(t4)), e3 && o2 && r3 && this.transportEventChannel.emit("error", r3), r3) : void this.transportEventChannel.emit("notification", t4); - }, t3.prototype.setRequestTimeout = function(t4, e3, r3) { - var n2 = this; - setTimeout(function() { - delete n2.pendingRequest[t4], r3(new i.JSONRPCError("Request timeout request took longer than " + e3 + " ms to resolve", i.ERR_TIMEOUT)); - }, e3); - }, t3; - }(); - e2.TransportRequestManager = o; - }, 6628: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), o = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u2(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u2(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u2(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u2((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, a = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }, s = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var u = s(r2(6792)), f = r2(3629), c = r2(7182), h = r2(9931), l = function(t3) { - function e3(e4) { - var r3 = t3.call(this) || this; - return r3.uri = e4, r3.connection = new u.default(e4), r3; - } - return i(e3, t3), e3.prototype.connect = function() { - var t4 = this; - return new Promise(function(e4, r3) { - var n2 = function() { - t4.connection.removeEventListener("open", n2), e4(); - }; - t4.connection.addEventListener("open", n2), t4.connection.addEventListener("message", function(e5) { - var r4 = e5.data; - t4.transportRequestManager.resolveResponse(r4); - }); - }); - }, e3.prototype.sendData = function(t4, e4) { - return e4 === void 0 && (e4 = 5e3), o(this, void 0, void 0, function() { - var r3, n2, i2 = this; - return a(this, function(o2) { - return r3 = this.transportRequestManager.addRequest(t4, e4), n2 = c.getNotifications(t4), this.connection.send(JSON.stringify(this.parseData(t4)), function(e5) { - if (e5) { - var o3 = new h.JSONRPCError(e5.message, h.ERR_UNKNOWN, e5); - i2.transportRequestManager.settlePendingRequest(n2, o3), i2.transportRequestManager.settlePendingRequest(c.getBatchRequests(t4), o3), r3 = Promise.reject(o3); - } - i2.transportRequestManager.settlePendingRequest(n2); - }), [2, r3]; - }); - }); - }, e3.prototype.close = function() { - this.connection.close(); - }, e3; - }(f.Transport); - e2.default = l; - }, 2190: (t2) => { - t2.exports = function(t3, r2, n) { - if (t3.filter) - return t3.filter(r2, n); - if (t3 == null) - throw new TypeError(); - if (typeof r2 != "function") - throw new TypeError(); - for (var i = [], o = 0; o < t3.length; o++) - if (e2.call(t3, o)) { - var a = t3[o]; - r2.call(n, a, o, t3) && i.push(a); - } - return i; - }; - var e2 = Object.prototype.hasOwnProperty; - }, 9809: (t2, e2, r2) => { - const n = e2; - n.bignum = r2(3550), n.define = r2(2500).define, n.base = r2(1979), n.constants = r2(6826), n.decoders = r2(8307), n.encoders = r2(6579); - }, 2500: (t2, e2, r2) => { - const n = r2(6579), i = r2(8307), o = r2(5717); - function a(t3, e3) { - this.name = t3, this.body = e3, this.decoders = {}, this.encoders = {}; - } - e2.define = function(t3, e3) { - return new a(t3, e3); - }, a.prototype._createNamed = function(t3) { - const e3 = this.name; - function r3(t4) { - this._initNamed(t4, e3); - } - return o(r3, t3), r3.prototype._initNamed = function(e4, r4) { - t3.call(this, e4, r4); - }, new r3(this); - }, a.prototype._getDecoder = function(t3) { - return t3 = t3 || "der", this.decoders.hasOwnProperty(t3) || (this.decoders[t3] = this._createNamed(i[t3])), this.decoders[t3]; - }, a.prototype.decode = function(t3, e3, r3) { - return this._getDecoder(e3).decode(t3, r3); - }, a.prototype._getEncoder = function(t3) { - return t3 = t3 || "der", this.encoders.hasOwnProperty(t3) || (this.encoders[t3] = this._createNamed(n[t3])), this.encoders[t3]; - }, a.prototype.encode = function(t3, e3, r3) { - return this._getEncoder(e3).encode(t3, r3); - }; - }, 6625: (t2, e2, r2) => { - const n = r2(5717), i = r2(8465).b, o = r2(2399).Buffer; - function a(t3, e3) { - i.call(this, e3), o.isBuffer(t3) ? (this.base = t3, this.offset = 0, this.length = t3.length) : this.error("Input not Buffer"); - } - function s(t3, e3) { - if (Array.isArray(t3)) - this.length = 0, this.value = t3.map(function(t4) { - return s.isEncoderBuffer(t4) || (t4 = new s(t4, e3)), this.length += t4.length, t4; - }, this); - else if (typeof t3 == "number") { - if (!(0 <= t3 && t3 <= 255)) - return e3.error("non-byte EncoderBuffer value"); - this.value = t3, this.length = 1; - } else if (typeof t3 == "string") - this.value = t3, this.length = o.byteLength(t3); - else { - if (!o.isBuffer(t3)) - return e3.error("Unsupported type: " + typeof t3); - this.value = t3, this.length = t3.length; - } - } - n(a, i), e2.C = a, a.isDecoderBuffer = function(t3) { - return t3 instanceof a || typeof t3 == "object" && o.isBuffer(t3.base) && t3.constructor.name === "DecoderBuffer" && typeof t3.offset == "number" && typeof t3.length == "number" && typeof t3.save == "function" && typeof t3.restore == "function" && typeof t3.isEmpty == "function" && typeof t3.readUInt8 == "function" && typeof t3.skip == "function" && typeof t3.raw == "function"; - }, a.prototype.save = function() { - return {offset: this.offset, reporter: i.prototype.save.call(this)}; - }, a.prototype.restore = function(t3) { - const e3 = new a(this.base); - return e3.offset = t3.offset, e3.length = this.offset, this.offset = t3.offset, i.prototype.restore.call(this, t3.reporter), e3; - }, a.prototype.isEmpty = function() { - return this.offset === this.length; - }, a.prototype.readUInt8 = function(t3) { - return this.offset + 1 <= this.length ? this.base.readUInt8(this.offset++, true) : this.error(t3 || "DecoderBuffer overrun"); - }, a.prototype.skip = function(t3, e3) { - if (!(this.offset + t3 <= this.length)) - return this.error(e3 || "DecoderBuffer overrun"); - const r3 = new a(this.base); - return r3._reporterState = this._reporterState, r3.offset = this.offset, r3.length = this.offset + t3, this.offset += t3, r3; - }, a.prototype.raw = function(t3) { - return this.base.slice(t3 ? t3.offset : this.offset, this.length); - }, e2.R = s, s.isEncoderBuffer = function(t3) { - return t3 instanceof s || typeof t3 == "object" && t3.constructor.name === "EncoderBuffer" && typeof t3.length == "number" && typeof t3.join == "function"; - }, s.prototype.join = function(t3, e3) { - return t3 || (t3 = o.alloc(this.length)), e3 || (e3 = 0), this.length === 0 || (Array.isArray(this.value) ? this.value.forEach(function(r3) { - r3.join(t3, e3), e3 += r3.length; - }) : (typeof this.value == "number" ? t3[e3] = this.value : typeof this.value == "string" ? t3.write(this.value, e3) : o.isBuffer(this.value) && this.value.copy(t3, e3), e3 += this.length)), t3; - }; - }, 1979: (t2, e2, r2) => { - const n = e2; - n.Reporter = r2(8465).b, n.DecoderBuffer = r2(6625).C, n.EncoderBuffer = r2(6625).R, n.Node = r2(1949); - }, 1949: (t2, e2, r2) => { - const n = r2(8465).b, i = r2(6625).R, o = r2(6625).C, a = r2(9746), s = ["seq", "seqof", "set", "setof", "objid", "bool", "gentime", "utctime", "null_", "enum", "int", "objDesc", "bitstr", "bmpstr", "charstr", "genstr", "graphstr", "ia5str", "iso646str", "numstr", "octstr", "printstr", "t61str", "unistr", "utf8str", "videostr"], u = ["key", "obj", "use", "optional", "explicit", "implicit", "def", "choice", "any", "contains"].concat(s); - function f(t3, e3, r3) { - const n2 = {}; - this._baseState = n2, n2.name = r3, n2.enc = t3, n2.parent = e3 || null, n2.children = null, n2.tag = null, n2.args = null, n2.reverseArgs = null, n2.choice = null, n2.optional = false, n2.any = false, n2.obj = false, n2.use = null, n2.useDecoder = null, n2.key = null, n2.default = null, n2.explicit = null, n2.implicit = null, n2.contains = null, n2.parent || (n2.children = [], this._wrap()); - } - t2.exports = f; - const c = ["enc", "parent", "children", "tag", "args", "reverseArgs", "choice", "optional", "any", "obj", "use", "alteredUse", "key", "default", "explicit", "implicit", "contains"]; - f.prototype.clone = function() { - const t3 = this._baseState, e3 = {}; - c.forEach(function(r4) { - e3[r4] = t3[r4]; - }); - const r3 = new this.constructor(e3.parent); - return r3._baseState = e3, r3; - }, f.prototype._wrap = function() { - const t3 = this._baseState; - u.forEach(function(e3) { - this[e3] = function() { - const r3 = new this.constructor(this); - return t3.children.push(r3), r3[e3].apply(r3, arguments); - }; - }, this); - }, f.prototype._init = function(t3) { - const e3 = this._baseState; - a(e3.parent === null), t3.call(this), e3.children = e3.children.filter(function(t4) { - return t4._baseState.parent === this; - }, this), a.equal(e3.children.length, 1, "Root node can have only one child"); - }, f.prototype._useArgs = function(t3) { - const e3 = this._baseState, r3 = t3.filter(function(t4) { - return t4 instanceof this.constructor; - }, this); - t3 = t3.filter(function(t4) { - return !(t4 instanceof this.constructor); - }, this), r3.length !== 0 && (a(e3.children === null), e3.children = r3, r3.forEach(function(t4) { - t4._baseState.parent = this; - }, this)), t3.length !== 0 && (a(e3.args === null), e3.args = t3, e3.reverseArgs = t3.map(function(t4) { - if (typeof t4 != "object" || t4.constructor !== Object) - return t4; - const e4 = {}; - return Object.keys(t4).forEach(function(r4) { - r4 == (0 | r4) && (r4 |= 0); - const n2 = t4[r4]; - e4[n2] = r4; - }), e4; - })); - }, ["_peekTag", "_decodeTag", "_use", "_decodeStr", "_decodeObjid", "_decodeTime", "_decodeNull", "_decodeInt", "_decodeBool", "_decodeList", "_encodeComposite", "_encodeStr", "_encodeObjid", "_encodeTime", "_encodeNull", "_encodeInt", "_encodeBool"].forEach(function(t3) { - f.prototype[t3] = function() { - const e3 = this._baseState; - throw new Error(t3 + " not implemented for encoding: " + e3.enc); - }; - }), s.forEach(function(t3) { - f.prototype[t3] = function() { - const e3 = this._baseState, r3 = Array.prototype.slice.call(arguments); - return a(e3.tag === null), e3.tag = t3, this._useArgs(r3), this; - }; - }), f.prototype.use = function(t3) { - a(t3); - const e3 = this._baseState; - return a(e3.use === null), e3.use = t3, this; - }, f.prototype.optional = function() { - return this._baseState.optional = true, this; - }, f.prototype.def = function(t3) { - const e3 = this._baseState; - return a(e3.default === null), e3.default = t3, e3.optional = true, this; - }, f.prototype.explicit = function(t3) { - const e3 = this._baseState; - return a(e3.explicit === null && e3.implicit === null), e3.explicit = t3, this; - }, f.prototype.implicit = function(t3) { - const e3 = this._baseState; - return a(e3.explicit === null && e3.implicit === null), e3.implicit = t3, this; - }, f.prototype.obj = function() { - const t3 = this._baseState, e3 = Array.prototype.slice.call(arguments); - return t3.obj = true, e3.length !== 0 && this._useArgs(e3), this; - }, f.prototype.key = function(t3) { - const e3 = this._baseState; - return a(e3.key === null), e3.key = t3, this; - }, f.prototype.any = function() { - return this._baseState.any = true, this; - }, f.prototype.choice = function(t3) { - const e3 = this._baseState; - return a(e3.choice === null), e3.choice = t3, this._useArgs(Object.keys(t3).map(function(e4) { - return t3[e4]; - })), this; - }, f.prototype.contains = function(t3) { - const e3 = this._baseState; - return a(e3.use === null), e3.contains = t3, this; - }, f.prototype._decode = function(t3, e3) { - const r3 = this._baseState; - if (r3.parent === null) - return t3.wrapResult(r3.children[0]._decode(t3, e3)); - let n2, i2 = r3.default, a2 = true, s2 = null; - if (r3.key !== null && (s2 = t3.enterKey(r3.key)), r3.optional) { - let n3 = null; - if (r3.explicit !== null ? n3 = r3.explicit : r3.implicit !== null ? n3 = r3.implicit : r3.tag !== null && (n3 = r3.tag), n3 !== null || r3.any) { - if (a2 = this._peekTag(t3, n3, r3.any), t3.isError(a2)) - return a2; - } else { - const n4 = t3.save(); - try { - r3.choice === null ? this._decodeGeneric(r3.tag, t3, e3) : this._decodeChoice(t3, e3), a2 = true; - } catch (t4) { - a2 = false; - } - t3.restore(n4); - } - } - if (r3.obj && a2 && (n2 = t3.enterObject()), a2) { - if (r3.explicit !== null) { - const e4 = this._decodeTag(t3, r3.explicit); - if (t3.isError(e4)) - return e4; - t3 = e4; - } - const n3 = t3.offset; - if (r3.use === null && r3.choice === null) { - let e4; - r3.any && (e4 = t3.save()); - const n4 = this._decodeTag(t3, r3.implicit !== null ? r3.implicit : r3.tag, r3.any); - if (t3.isError(n4)) - return n4; - r3.any ? i2 = t3.raw(e4) : t3 = n4; - } - if (e3 && e3.track && r3.tag !== null && e3.track(t3.path(), n3, t3.length, "tagged"), e3 && e3.track && r3.tag !== null && e3.track(t3.path(), t3.offset, t3.length, "content"), r3.any || (i2 = r3.choice === null ? this._decodeGeneric(r3.tag, t3, e3) : this._decodeChoice(t3, e3)), t3.isError(i2)) - return i2; - if (r3.any || r3.choice !== null || r3.children === null || r3.children.forEach(function(r4) { - r4._decode(t3, e3); - }), r3.contains && (r3.tag === "octstr" || r3.tag === "bitstr")) { - const n4 = new o(i2); - i2 = this._getUse(r3.contains, t3._reporterState.obj)._decode(n4, e3); - } - } - return r3.obj && a2 && (i2 = t3.leaveObject(n2)), r3.key === null || i2 === null && a2 !== true ? s2 !== null && t3.exitKey(s2) : t3.leaveKey(s2, r3.key, i2), i2; - }, f.prototype._decodeGeneric = function(t3, e3, r3) { - const n2 = this._baseState; - return t3 === "seq" || t3 === "set" ? null : t3 === "seqof" || t3 === "setof" ? this._decodeList(e3, t3, n2.args[0], r3) : /str$/.test(t3) ? this._decodeStr(e3, t3, r3) : t3 === "objid" && n2.args ? this._decodeObjid(e3, n2.args[0], n2.args[1], r3) : t3 === "objid" ? this._decodeObjid(e3, null, null, r3) : t3 === "gentime" || t3 === "utctime" ? this._decodeTime(e3, t3, r3) : t3 === "null_" ? this._decodeNull(e3, r3) : t3 === "bool" ? this._decodeBool(e3, r3) : t3 === "objDesc" ? this._decodeStr(e3, t3, r3) : t3 === "int" || t3 === "enum" ? this._decodeInt(e3, n2.args && n2.args[0], r3) : n2.use !== null ? this._getUse(n2.use, e3._reporterState.obj)._decode(e3, r3) : e3.error("unknown tag: " + t3); - }, f.prototype._getUse = function(t3, e3) { - const r3 = this._baseState; - return r3.useDecoder = this._use(t3, e3), a(r3.useDecoder._baseState.parent === null), r3.useDecoder = r3.useDecoder._baseState.children[0], r3.implicit !== r3.useDecoder._baseState.implicit && (r3.useDecoder = r3.useDecoder.clone(), r3.useDecoder._baseState.implicit = r3.implicit), r3.useDecoder; - }, f.prototype._decodeChoice = function(t3, e3) { - const r3 = this._baseState; - let n2 = null, i2 = false; - return Object.keys(r3.choice).some(function(o2) { - const a2 = t3.save(), s2 = r3.choice[o2]; - try { - const r4 = s2._decode(t3, e3); - if (t3.isError(r4)) - return false; - n2 = {type: o2, value: r4}, i2 = true; - } catch (e4) { - return t3.restore(a2), false; - } - return true; - }, this), i2 ? n2 : t3.error("Choice not matched"); - }, f.prototype._createEncoderBuffer = function(t3) { - return new i(t3, this.reporter); - }, f.prototype._encode = function(t3, e3, r3) { - const n2 = this._baseState; - if (n2.default !== null && n2.default === t3) - return; - const i2 = this._encodeValue(t3, e3, r3); - return i2 === void 0 || this._skipDefault(i2, e3, r3) ? void 0 : i2; - }, f.prototype._encodeValue = function(t3, e3, r3) { - const i2 = this._baseState; - if (i2.parent === null) - return i2.children[0]._encode(t3, e3 || new n()); - let o2 = null; - if (this.reporter = e3, i2.optional && t3 === void 0) { - if (i2.default === null) - return; - t3 = i2.default; - } - let a2 = null, s2 = false; - if (i2.any) - o2 = this._createEncoderBuffer(t3); - else if (i2.choice) - o2 = this._encodeChoice(t3, e3); - else if (i2.contains) - a2 = this._getUse(i2.contains, r3)._encode(t3, e3), s2 = true; - else if (i2.children) - a2 = i2.children.map(function(r4) { - if (r4._baseState.tag === "null_") - return r4._encode(null, e3, t3); - if (r4._baseState.key === null) - return e3.error("Child should have a key"); - const n2 = e3.enterKey(r4._baseState.key); - if (typeof t3 != "object") - return e3.error("Child expected, but input is not object"); - const i3 = r4._encode(t3[r4._baseState.key], e3, t3); - return e3.leaveKey(n2), i3; - }, this).filter(function(t4) { - return t4; - }), a2 = this._createEncoderBuffer(a2); - else if (i2.tag === "seqof" || i2.tag === "setof") { - if (!i2.args || i2.args.length !== 1) - return e3.error("Too many args for : " + i2.tag); - if (!Array.isArray(t3)) - return e3.error("seqof/setof, but data is not Array"); - const r4 = this.clone(); - r4._baseState.implicit = null, a2 = this._createEncoderBuffer(t3.map(function(r5) { - const n2 = this._baseState; - return this._getUse(n2.args[0], t3)._encode(r5, e3); - }, r4)); - } else - i2.use !== null ? o2 = this._getUse(i2.use, r3)._encode(t3, e3) : (a2 = this._encodePrimitive(i2.tag, t3), s2 = true); - if (!i2.any && i2.choice === null) { - const t4 = i2.implicit !== null ? i2.implicit : i2.tag, r4 = i2.implicit === null ? "universal" : "context"; - t4 === null ? i2.use === null && e3.error("Tag could be omitted only for .use()") : i2.use === null && (o2 = this._encodeComposite(t4, s2, r4, a2)); - } - return i2.explicit !== null && (o2 = this._encodeComposite(i2.explicit, false, "context", o2)), o2; - }, f.prototype._encodeChoice = function(t3, e3) { - const r3 = this._baseState, n2 = r3.choice[t3.type]; - return n2 || a(false, t3.type + " not found in " + JSON.stringify(Object.keys(r3.choice))), n2._encode(t3.value, e3); - }, f.prototype._encodePrimitive = function(t3, e3) { - const r3 = this._baseState; - if (/str$/.test(t3)) - return this._encodeStr(e3, t3); - if (t3 === "objid" && r3.args) - return this._encodeObjid(e3, r3.reverseArgs[0], r3.args[1]); - if (t3 === "objid") - return this._encodeObjid(e3, null, null); - if (t3 === "gentime" || t3 === "utctime") - return this._encodeTime(e3, t3); - if (t3 === "null_") - return this._encodeNull(); - if (t3 === "int" || t3 === "enum") - return this._encodeInt(e3, r3.args && r3.reverseArgs[0]); - if (t3 === "bool") - return this._encodeBool(e3); - if (t3 === "objDesc") - return this._encodeStr(e3, t3); - throw new Error("Unsupported tag: " + t3); - }, f.prototype._isNumstr = function(t3) { - return /^[0-9 ]*$/.test(t3); - }, f.prototype._isPrintstr = function(t3) { - return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(t3); - }; - }, 8465: (t2, e2, r2) => { - const n = r2(5717); - function i(t3) { - this._reporterState = {obj: null, path: [], options: t3 || {}, errors: []}; - } - function o(t3, e3) { - this.path = t3, this.rethrow(e3); - } - e2.b = i, i.prototype.isError = function(t3) { - return t3 instanceof o; - }, i.prototype.save = function() { - const t3 = this._reporterState; - return {obj: t3.obj, pathLen: t3.path.length}; - }, i.prototype.restore = function(t3) { - const e3 = this._reporterState; - e3.obj = t3.obj, e3.path = e3.path.slice(0, t3.pathLen); - }, i.prototype.enterKey = function(t3) { - return this._reporterState.path.push(t3); - }, i.prototype.exitKey = function(t3) { - const e3 = this._reporterState; - e3.path = e3.path.slice(0, t3 - 1); - }, i.prototype.leaveKey = function(t3, e3, r3) { - const n2 = this._reporterState; - this.exitKey(t3), n2.obj !== null && (n2.obj[e3] = r3); - }, i.prototype.path = function() { - return this._reporterState.path.join("/"); - }, i.prototype.enterObject = function() { - const t3 = this._reporterState, e3 = t3.obj; - return t3.obj = {}, e3; - }, i.prototype.leaveObject = function(t3) { - const e3 = this._reporterState, r3 = e3.obj; - return e3.obj = t3, r3; - }, i.prototype.error = function(t3) { - let e3; - const r3 = this._reporterState, n2 = t3 instanceof o; - if (e3 = n2 ? t3 : new o(r3.path.map(function(t4) { - return "[" + JSON.stringify(t4) + "]"; - }).join(""), t3.message || t3, t3.stack), !r3.options.partial) - throw e3; - return n2 || r3.errors.push(e3), e3; - }, i.prototype.wrapResult = function(t3) { - const e3 = this._reporterState; - return e3.options.partial ? {result: this.isError(t3) ? null : t3, errors: e3.errors} : t3; - }, n(o, Error), o.prototype.rethrow = function(t3) { - if (this.message = t3 + " at: " + (this.path || "(shallow)"), Error.captureStackTrace && Error.captureStackTrace(this, o), !this.stack) - try { - throw new Error(this.message); - } catch (t4) { - this.stack = t4.stack; - } - return this; - }; - }, 160: (t2, e2) => { - function r2(t3) { - const e3 = {}; - return Object.keys(t3).forEach(function(r3) { - (0 | r3) == r3 && (r3 |= 0); - const n = t3[r3]; - e3[n] = r3; - }), e3; - } - e2.tagClass = {0: "universal", 1: "application", 2: "context", 3: "private"}, e2.tagClassByName = r2(e2.tagClass), e2.tag = {0: "end", 1: "bool", 2: "int", 3: "bitstr", 4: "octstr", 5: "null_", 6: "objid", 7: "objDesc", 8: "external", 9: "real", 10: "enum", 11: "embed", 12: "utf8str", 13: "relativeOid", 16: "seq", 17: "set", 18: "numstr", 19: "printstr", 20: "t61str", 21: "videostr", 22: "ia5str", 23: "utctime", 24: "gentime", 25: "graphstr", 26: "iso646str", 27: "genstr", 28: "unistr", 29: "charstr", 30: "bmpstr"}, e2.tagByName = r2(e2.tag); - }, 6826: (t2, e2, r2) => { - const n = e2; - n._reverse = function(t3) { - const e3 = {}; - return Object.keys(t3).forEach(function(r3) { - (0 | r3) == r3 && (r3 |= 0); - const n2 = t3[r3]; - e3[n2] = r3; - }), e3; - }, n.der = r2(160); - }, 1671: (t2, e2, r2) => { - const n = r2(5717), i = r2(3550), o = r2(6625).C, a = r2(1949), s = r2(160); - function u(t3) { - this.enc = "der", this.name = t3.name, this.entity = t3, this.tree = new f(), this.tree._init(t3.body); - } - function f(t3) { - a.call(this, "der", t3); - } - function c(t3, e3) { - let r3 = t3.readUInt8(e3); - if (t3.isError(r3)) - return r3; - const n2 = s.tagClass[r3 >> 6], i2 = (32 & r3) == 0; - if ((31 & r3) == 31) { - let n3 = r3; - for (r3 = 0; (128 & n3) == 128; ) { - if (n3 = t3.readUInt8(e3), t3.isError(n3)) - return n3; - r3 <<= 7, r3 |= 127 & n3; - } - } else - r3 &= 31; - return {cls: n2, primitive: i2, tag: r3, tagStr: s.tag[r3]}; - } - function h(t3, e3, r3) { - let n2 = t3.readUInt8(r3); - if (t3.isError(n2)) - return n2; - if (!e3 && n2 === 128) - return null; - if ((128 & n2) == 0) - return n2; - const i2 = 127 & n2; - if (i2 > 4) - return t3.error("length octect is too long"); - n2 = 0; - for (let e4 = 0; e4 < i2; e4++) { - n2 <<= 8; - const e5 = t3.readUInt8(r3); - if (t3.isError(e5)) - return e5; - n2 |= e5; - } - return n2; - } - t2.exports = u, u.prototype.decode = function(t3, e3) { - return o.isDecoderBuffer(t3) || (t3 = new o(t3, e3)), this.tree._decode(t3, e3); - }, n(f, a), f.prototype._peekTag = function(t3, e3, r3) { - if (t3.isEmpty()) - return false; - const n2 = t3.save(), i2 = c(t3, 'Failed to peek tag: "' + e3 + '"'); - return t3.isError(i2) ? i2 : (t3.restore(n2), i2.tag === e3 || i2.tagStr === e3 || i2.tagStr + "of" === e3 || r3); - }, f.prototype._decodeTag = function(t3, e3, r3) { - const n2 = c(t3, 'Failed to decode tag of "' + e3 + '"'); - if (t3.isError(n2)) - return n2; - let i2 = h(t3, n2.primitive, 'Failed to get length of "' + e3 + '"'); - if (t3.isError(i2)) - return i2; - if (!r3 && n2.tag !== e3 && n2.tagStr !== e3 && n2.tagStr + "of" !== e3) - return t3.error('Failed to match tag: "' + e3 + '"'); - if (n2.primitive || i2 !== null) - return t3.skip(i2, 'Failed to match body of: "' + e3 + '"'); - const o2 = t3.save(), a2 = this._skipUntilEnd(t3, 'Failed to skip indefinite length body: "' + this.tag + '"'); - return t3.isError(a2) ? a2 : (i2 = t3.offset - o2.offset, t3.restore(o2), t3.skip(i2, 'Failed to match body of: "' + e3 + '"')); - }, f.prototype._skipUntilEnd = function(t3, e3) { - for (; ; ) { - const r3 = c(t3, e3); - if (t3.isError(r3)) - return r3; - const n2 = h(t3, r3.primitive, e3); - if (t3.isError(n2)) - return n2; - let i2; - if (i2 = r3.primitive || n2 !== null ? t3.skip(n2) : this._skipUntilEnd(t3, e3), t3.isError(i2)) - return i2; - if (r3.tagStr === "end") - break; - } - }, f.prototype._decodeList = function(t3, e3, r3, n2) { - const i2 = []; - for (; !t3.isEmpty(); ) { - const e4 = this._peekTag(t3, "end"); - if (t3.isError(e4)) - return e4; - const o2 = r3.decode(t3, "der", n2); - if (t3.isError(o2) && e4) - break; - i2.push(o2); - } - return i2; - }, f.prototype._decodeStr = function(t3, e3) { - if (e3 === "bitstr") { - const e4 = t3.readUInt8(); - return t3.isError(e4) ? e4 : {unused: e4, data: t3.raw()}; - } - if (e3 === "bmpstr") { - const e4 = t3.raw(); - if (e4.length % 2 == 1) - return t3.error("Decoding of string type: bmpstr length mismatch"); - let r3 = ""; - for (let t4 = 0; t4 < e4.length / 2; t4++) - r3 += String.fromCharCode(e4.readUInt16BE(2 * t4)); - return r3; - } - if (e3 === "numstr") { - const e4 = t3.raw().toString("ascii"); - return this._isNumstr(e4) ? e4 : t3.error("Decoding of string type: numstr unsupported characters"); - } - if (e3 === "octstr") - return t3.raw(); - if (e3 === "objDesc") - return t3.raw(); - if (e3 === "printstr") { - const e4 = t3.raw().toString("ascii"); - return this._isPrintstr(e4) ? e4 : t3.error("Decoding of string type: printstr unsupported characters"); - } - return /str$/.test(e3) ? t3.raw().toString() : t3.error("Decoding of string type: " + e3 + " unsupported"); - }, f.prototype._decodeObjid = function(t3, e3, r3) { - let n2; - const i2 = []; - let o2 = 0, a2 = 0; - for (; !t3.isEmpty(); ) - a2 = t3.readUInt8(), o2 <<= 7, o2 |= 127 & a2, (128 & a2) == 0 && (i2.push(o2), o2 = 0); - 128 & a2 && i2.push(o2); - const s2 = i2[0] / 40 | 0, u2 = i2[0] % 40; - if (n2 = r3 ? i2 : [s2, u2].concat(i2.slice(1)), e3) { - let t4 = e3[n2.join(" ")]; - t4 === void 0 && (t4 = e3[n2.join(".")]), t4 !== void 0 && (n2 = t4); - } - return n2; - }, f.prototype._decodeTime = function(t3, e3) { - const r3 = t3.raw().toString(); - let n2, i2, o2, a2, s2, u2; - if (e3 === "gentime") - n2 = 0 | r3.slice(0, 4), i2 = 0 | r3.slice(4, 6), o2 = 0 | r3.slice(6, 8), a2 = 0 | r3.slice(8, 10), s2 = 0 | r3.slice(10, 12), u2 = 0 | r3.slice(12, 14); - else { - if (e3 !== "utctime") - return t3.error("Decoding " + e3 + " time is not supported yet"); - n2 = 0 | r3.slice(0, 2), i2 = 0 | r3.slice(2, 4), o2 = 0 | r3.slice(4, 6), a2 = 0 | r3.slice(6, 8), s2 = 0 | r3.slice(8, 10), u2 = 0 | r3.slice(10, 12), n2 = n2 < 70 ? 2e3 + n2 : 1900 + n2; - } - return Date.UTC(n2, i2 - 1, o2, a2, s2, u2, 0); - }, f.prototype._decodeNull = function() { - return null; - }, f.prototype._decodeBool = function(t3) { - const e3 = t3.readUInt8(); - return t3.isError(e3) ? e3 : e3 !== 0; - }, f.prototype._decodeInt = function(t3, e3) { - const r3 = t3.raw(); - let n2 = new i(r3); - return e3 && (n2 = e3[n2.toString(10)] || n2), n2; - }, f.prototype._use = function(t3, e3) { - return typeof t3 == "function" && (t3 = t3(e3)), t3._getDecoder("der").tree; - }; - }, 8307: (t2, e2, r2) => { - const n = e2; - n.der = r2(1671), n.pem = r2(9631); - }, 9631: (t2, e2, r2) => { - const n = r2(5717), i = r2(2399).Buffer, o = r2(1671); - function a(t3) { - o.call(this, t3), this.enc = "pem"; - } - n(a, o), t2.exports = a, a.prototype.decode = function(t3, e3) { - const r3 = t3.toString().split(/[\r\n]+/g), n2 = e3.label.toUpperCase(), a2 = /^-----(BEGIN|END) ([^-]+)-----$/; - let s = -1, u = -1; - for (let t4 = 0; t4 < r3.length; t4++) { - const e4 = r3[t4].match(a2); - if (e4 !== null && e4[2] === n2) { - if (s !== -1) { - if (e4[1] !== "END") - break; - u = t4; - break; - } - if (e4[1] !== "BEGIN") - break; - s = t4; - } - } - if (s === -1 || u === -1) - throw new Error("PEM section not found for: " + n2); - const f = r3.slice(s + 1, u).join(""); - f.replace(/[^a-z0-9+/=]+/gi, ""); - const c = i.from(f, "base64"); - return o.prototype.decode.call(this, c, e3); - }; - }, 6984: (t2, e2, r2) => { - const n = r2(5717), i = r2(2399).Buffer, o = r2(1949), a = r2(160); - function s(t3) { - this.enc = "der", this.name = t3.name, this.entity = t3, this.tree = new u(), this.tree._init(t3.body); - } - function u(t3) { - o.call(this, "der", t3); - } - function f(t3) { - return t3 < 10 ? "0" + t3 : t3; - } - t2.exports = s, s.prototype.encode = function(t3, e3) { - return this.tree._encode(t3, e3).join(); - }, n(u, o), u.prototype._encodeComposite = function(t3, e3, r3, n2) { - const o2 = function(t4, e4, r4, n3) { - let i2; - if (t4 === "seqof" ? t4 = "seq" : t4 === "setof" && (t4 = "set"), a.tagByName.hasOwnProperty(t4)) - i2 = a.tagByName[t4]; - else { - if (typeof t4 != "number" || (0 | t4) !== t4) - return n3.error("Unknown tag: " + t4); - i2 = t4; - } - return i2 >= 31 ? n3.error("Multi-octet tag encoding unsupported") : (e4 || (i2 |= 32), i2 |= a.tagClassByName[r4 || "universal"] << 6, i2); - }(t3, e3, r3, this.reporter); - if (n2.length < 128) { - const t4 = i.alloc(2); - return t4[0] = o2, t4[1] = n2.length, this._createEncoderBuffer([t4, n2]); - } - let s2 = 1; - for (let t4 = n2.length; t4 >= 256; t4 >>= 8) - s2++; - const u2 = i.alloc(2 + s2); - u2[0] = o2, u2[1] = 128 | s2; - for (let t4 = 1 + s2, e4 = n2.length; e4 > 0; t4--, e4 >>= 8) - u2[t4] = 255 & e4; - return this._createEncoderBuffer([u2, n2]); - }, u.prototype._encodeStr = function(t3, e3) { - if (e3 === "bitstr") - return this._createEncoderBuffer([0 | t3.unused, t3.data]); - if (e3 === "bmpstr") { - const e4 = i.alloc(2 * t3.length); - for (let r3 = 0; r3 < t3.length; r3++) - e4.writeUInt16BE(t3.charCodeAt(r3), 2 * r3); - return this._createEncoderBuffer(e4); - } - return e3 === "numstr" ? this._isNumstr(t3) ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: numstr supports only digits and space") : e3 === "printstr" ? this._isPrintstr(t3) ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark") : /str$/.test(e3) || e3 === "objDesc" ? this._createEncoderBuffer(t3) : this.reporter.error("Encoding of string type: " + e3 + " unsupported"); - }, u.prototype._encodeObjid = function(t3, e3, r3) { - if (typeof t3 == "string") { - if (!e3) - return this.reporter.error("string objid given, but no values map found"); - if (!e3.hasOwnProperty(t3)) - return this.reporter.error("objid not found in values map"); - t3 = e3[t3].split(/[\s.]+/g); - for (let e4 = 0; e4 < t3.length; e4++) - t3[e4] |= 0; - } else if (Array.isArray(t3)) { - t3 = t3.slice(); - for (let e4 = 0; e4 < t3.length; e4++) - t3[e4] |= 0; - } - if (!Array.isArray(t3)) - return this.reporter.error("objid() should be either array or string, got: " + JSON.stringify(t3)); - if (!r3) { - if (t3[1] >= 40) - return this.reporter.error("Second objid identifier OOB"); - t3.splice(0, 2, 40 * t3[0] + t3[1]); - } - let n2 = 0; - for (let e4 = 0; e4 < t3.length; e4++) { - let r4 = t3[e4]; - for (n2++; r4 >= 128; r4 >>= 7) - n2++; - } - const o2 = i.alloc(n2); - let a2 = o2.length - 1; - for (let e4 = t3.length - 1; e4 >= 0; e4--) { - let r4 = t3[e4]; - for (o2[a2--] = 127 & r4; (r4 >>= 7) > 0; ) - o2[a2--] = 128 | 127 & r4; - } - return this._createEncoderBuffer(o2); - }, u.prototype._encodeTime = function(t3, e3) { - let r3; - const n2 = new Date(t3); - return e3 === "gentime" ? r3 = [f(n2.getUTCFullYear()), f(n2.getUTCMonth() + 1), f(n2.getUTCDate()), f(n2.getUTCHours()), f(n2.getUTCMinutes()), f(n2.getUTCSeconds()), "Z"].join("") : e3 === "utctime" ? r3 = [f(n2.getUTCFullYear() % 100), f(n2.getUTCMonth() + 1), f(n2.getUTCDate()), f(n2.getUTCHours()), f(n2.getUTCMinutes()), f(n2.getUTCSeconds()), "Z"].join("") : this.reporter.error("Encoding " + e3 + " time is not supported yet"), this._encodeStr(r3, "octstr"); - }, u.prototype._encodeNull = function() { - return this._createEncoderBuffer(""); - }, u.prototype._encodeInt = function(t3, e3) { - if (typeof t3 == "string") { - if (!e3) - return this.reporter.error("String int or enum given, but no values map"); - if (!e3.hasOwnProperty(t3)) - return this.reporter.error("Values map doesn't contain: " + JSON.stringify(t3)); - t3 = e3[t3]; - } - if (typeof t3 != "number" && !i.isBuffer(t3)) { - const e4 = t3.toArray(); - !t3.sign && 128 & e4[0] && e4.unshift(0), t3 = i.from(e4); - } - if (i.isBuffer(t3)) { - let e4 = t3.length; - t3.length === 0 && e4++; - const r4 = i.alloc(e4); - return t3.copy(r4), t3.length === 0 && (r4[0] = 0), this._createEncoderBuffer(r4); - } - if (t3 < 128) - return this._createEncoderBuffer(t3); - if (t3 < 256) - return this._createEncoderBuffer([0, t3]); - let r3 = 1; - for (let e4 = t3; e4 >= 256; e4 >>= 8) - r3++; - const n2 = new Array(r3); - for (let e4 = n2.length - 1; e4 >= 0; e4--) - n2[e4] = 255 & t3, t3 >>= 8; - return 128 & n2[0] && n2.unshift(0), this._createEncoderBuffer(i.from(n2)); - }, u.prototype._encodeBool = function(t3) { - return this._createEncoderBuffer(t3 ? 255 : 0); - }, u.prototype._use = function(t3, e3) { - return typeof t3 == "function" && (t3 = t3(e3)), t3._getEncoder("der").tree; - }, u.prototype._skipDefault = function(t3, e3, r3) { - const n2 = this._baseState; - let i2; - if (n2.default === null) - return false; - const o2 = t3.join(); - if (n2.defaultBuffer === void 0 && (n2.defaultBuffer = this._encodeValue(n2.default, e3, r3).join()), o2.length !== n2.defaultBuffer.length) - return false; - for (i2 = 0; i2 < o2.length; i2++) - if (o2[i2] !== n2.defaultBuffer[i2]) - return false; - return true; - }; - }, 6579: (t2, e2, r2) => { - const n = e2; - n.der = r2(6984), n.pem = r2(2883); - }, 2883: (t2, e2, r2) => { - const n = r2(5717), i = r2(6984); - function o(t3) { - i.call(this, t3), this.enc = "pem"; - } - n(o, i), t2.exports = o, o.prototype.encode = function(t3, e3) { - const r3 = i.prototype.encode.call(this, t3).toString("base64"), n2 = ["-----BEGIN " + e3.label + "-----"]; - for (let t4 = 0; t4 < r3.length; t4 += 64) - n2.push(r3.slice(t4, t4 + 64)); - return n2.push("-----END " + e3.label + "-----"), n2.join("\n"); - }; - }, 9282: (t2, e2, r2) => { - var n = r2(4155); - function i(t3) { - return (i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { - return typeof t4; - } : function(t4) { - return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; - })(t3); - } - var o, a, s = r2(2136).codes, u = s.ERR_AMBIGUOUS_ARGUMENT, f = s.ERR_INVALID_ARG_TYPE, c = s.ERR_INVALID_ARG_VALUE, h = s.ERR_INVALID_RETURN_VALUE, l = s.ERR_MISSING_ARGS, d = r2(5961), p = r2(9539).inspect, y = r2(9539).types, m = y.isPromise, b = y.isRegExp, g = Object.assign ? Object.assign : r2(8091).assign, v = Object.is ? Object.is : r2(609); - function w() { - var t3 = r2(9158); - o = t3.isDeepEqual, a = t3.isDeepStrictEqual; - } - var _ = false, M = t2.exports = k, S = {}; - function E(t3) { - if (t3.message instanceof Error) - throw t3.message; - throw new d(t3); - } - function A(t3, e3, r3, n2) { - if (!r3) { - var i2 = false; - if (e3 === 0) - i2 = true, n2 = "No value argument passed to `assert.ok()`"; - else if (n2 instanceof Error) - throw n2; - var o2 = new d({actual: r3, expected: true, message: n2, operator: "==", stackStartFn: t3}); - throw o2.generatedMessage = i2, o2; - } - } - function k() { - for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) - e3[r3] = arguments[r3]; - A.apply(void 0, [k, e3.length].concat(e3)); - } - M.fail = function t3(e3, r3, i2, o2, a2) { - var s2, u2 = arguments.length; - if (u2 === 0) - s2 = "Failed"; - else if (u2 === 1) - i2 = e3, e3 = void 0; - else { - if (_ === false) { - _ = true; - var f2 = n.emitWarning ? n.emitWarning : console.warn.bind(console); - f2("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.", "DeprecationWarning", "DEP0094"); - } - u2 === 2 && (o2 = "!="); - } - if (i2 instanceof Error) - throw i2; - var c2 = {actual: e3, expected: r3, operator: o2 === void 0 ? "fail" : o2, stackStartFn: a2 || t3}; - i2 !== void 0 && (c2.message = i2); - var h2 = new d(c2); - throw s2 && (h2.message = s2, h2.generatedMessage = true), h2; - }, M.AssertionError = d, M.ok = k, M.equal = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - e3 != r3 && E({actual: e3, expected: r3, message: n2, operator: "==", stackStartFn: t3}); - }, M.notEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - e3 == r3 && E({actual: e3, expected: r3, message: n2, operator: "!=", stackStartFn: t3}); - }, M.deepEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - o === void 0 && w(), o(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "deepEqual", stackStartFn: t3}); - }, M.notDeepEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - o === void 0 && w(), o(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notDeepEqual", stackStartFn: t3}); - }, M.deepStrictEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - o === void 0 && w(), a(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "deepStrictEqual", stackStartFn: t3}); - }, M.notDeepStrictEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - o === void 0 && w(), a(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notDeepStrictEqual", stackStartFn: t3}); - }, M.strictEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - v(e3, r3) || E({actual: e3, expected: r3, message: n2, operator: "strictEqual", stackStartFn: t3}); - }, M.notStrictEqual = function t3(e3, r3, n2) { - if (arguments.length < 2) - throw new l("actual", "expected"); - v(e3, r3) && E({actual: e3, expected: r3, message: n2, operator: "notStrictEqual", stackStartFn: t3}); - }; - var B = function t3(e3, r3, n2) { - var i2 = this; - !function(t4, e4) { - if (!(t4 instanceof e4)) - throw new TypeError("Cannot call a class as a function"); - }(this, t3), r3.forEach(function(t4) { - t4 in e3 && (n2 !== void 0 && typeof n2[t4] == "string" && b(e3[t4]) && e3[t4].test(n2[t4]) ? i2[t4] = n2[t4] : i2[t4] = e3[t4]); - }); - }; - function T(t3, e3, r3, n2, i2, o2) { - if (!(r3 in t3) || !a(t3[r3], e3[r3])) { - if (!n2) { - var s2 = new B(t3, i2), u2 = new B(e3, i2, t3), f2 = new d({actual: s2, expected: u2, operator: "deepStrictEqual", stackStartFn: o2}); - throw f2.actual = t3, f2.expected = e3, f2.operator = o2.name, f2; - } - E({actual: t3, expected: e3, message: n2, operator: o2.name, stackStartFn: o2}); - } - } - function x(t3, e3, r3, n2) { - if (typeof e3 != "function") { - if (b(e3)) - return e3.test(t3); - if (arguments.length === 2) - throw new f("expected", ["Function", "RegExp"], e3); - if (i(t3) !== "object" || t3 === null) { - var a2 = new d({actual: t3, expected: e3, message: r3, operator: "deepStrictEqual", stackStartFn: n2}); - throw a2.operator = n2.name, a2; - } - var s2 = Object.keys(e3); - if (e3 instanceof Error) - s2.push("name", "message"); - else if (s2.length === 0) - throw new c("error", e3, "may not be an empty object"); - return o === void 0 && w(), s2.forEach(function(i2) { - typeof t3[i2] == "string" && b(e3[i2]) && e3[i2].test(t3[i2]) || T(t3, e3, i2, r3, s2, n2); - }), true; - } - return e3.prototype !== void 0 && t3 instanceof e3 || !Error.isPrototypeOf(e3) && e3.call({}, t3) === true; - } - function O(t3) { - if (typeof t3 != "function") - throw new f("fn", "Function", t3); - try { - t3(); - } catch (t4) { - return t4; - } - return S; - } - function R(t3) { - return m(t3) || t3 !== null && i(t3) === "object" && typeof t3.then == "function" && typeof t3.catch == "function"; - } - function P(t3) { - return Promise.resolve().then(function() { - var e3; - if (typeof t3 == "function") { - if (!R(e3 = t3())) - throw new h("instance of Promise", "promiseFn", e3); - } else { - if (!R(t3)) - throw new f("promiseFn", ["Function", "Promise"], t3); - e3 = t3; - } - return Promise.resolve().then(function() { - return e3; - }).then(function() { - return S; - }).catch(function(t4) { - return t4; - }); - }); - } - function I(t3, e3, r3, n2) { - if (typeof r3 == "string") { - if (arguments.length === 4) - throw new f("error", ["Object", "Error", "Function", "RegExp"], r3); - if (i(e3) === "object" && e3 !== null) { - if (e3.message === r3) - throw new u("error/message", 'The error message "'.concat(e3.message, '" is identical to the message.')); - } else if (e3 === r3) - throw new u("error/message", 'The error "'.concat(e3, '" is identical to the message.')); - n2 = r3, r3 = void 0; - } else if (r3 != null && i(r3) !== "object" && typeof r3 != "function") - throw new f("error", ["Object", "Error", "Function", "RegExp"], r3); - if (e3 === S) { - var o2 = ""; - r3 && r3.name && (o2 += " (".concat(r3.name, ")")), o2 += n2 ? ": ".concat(n2) : "."; - var a2 = t3.name === "rejects" ? "rejection" : "exception"; - E({actual: void 0, expected: r3, operator: t3.name, message: "Missing expected ".concat(a2).concat(o2), stackStartFn: t3}); - } - if (r3 && !x(e3, r3, n2, t3)) - throw e3; - } - function j(t3, e3, r3, n2) { - if (e3 !== S) { - if (typeof r3 == "string" && (n2 = r3, r3 = void 0), !r3 || x(e3, r3)) { - var i2 = n2 ? ": ".concat(n2) : ".", o2 = t3.name === "doesNotReject" ? "rejection" : "exception"; - E({actual: e3, expected: r3, operator: t3.name, message: "Got unwanted ".concat(o2).concat(i2, "\n") + 'Actual message: "'.concat(e3 && e3.message, '"'), stackStartFn: t3}); - } - throw e3; - } - } - function U() { - for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) - e3[r3] = arguments[r3]; - A.apply(void 0, [U, e3.length].concat(e3)); - } - M.throws = function t3(e3) { - for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) - n2[i2 - 1] = arguments[i2]; - I.apply(void 0, [t3, O(e3)].concat(n2)); - }, M.rejects = function t3(e3) { - for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) - n2[i2 - 1] = arguments[i2]; - return P(e3).then(function(e4) { - return I.apply(void 0, [t3, e4].concat(n2)); - }); - }, M.doesNotThrow = function t3(e3) { - for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) - n2[i2 - 1] = arguments[i2]; - j.apply(void 0, [t3, O(e3)].concat(n2)); - }, M.doesNotReject = function t3(e3) { - for (var r3 = arguments.length, n2 = new Array(r3 > 1 ? r3 - 1 : 0), i2 = 1; i2 < r3; i2++) - n2[i2 - 1] = arguments[i2]; - return P(e3).then(function(e4) { - return j.apply(void 0, [t3, e4].concat(n2)); - }); - }, M.ifError = function t3(e3) { - if (e3 != null) { - var r3 = "ifError got unwanted exception: "; - i(e3) === "object" && typeof e3.message == "string" ? e3.message.length === 0 && e3.constructor ? r3 += e3.constructor.name : r3 += e3.message : r3 += p(e3); - var n2 = new d({actual: e3, expected: null, operator: "ifError", message: r3, stackStartFn: t3}), o2 = e3.stack; - if (typeof o2 == "string") { - var a2 = o2.split("\n"); - a2.shift(); - for (var s2 = n2.stack.split("\n"), u2 = 0; u2 < a2.length; u2++) { - var f2 = s2.indexOf(a2[u2]); - if (f2 !== -1) { - s2 = s2.slice(0, f2); - break; - } - } - n2.stack = "".concat(s2.join("\n"), "\n").concat(a2.join("\n")); - } - throw n2; - } - }, M.strict = g(U, M, {equal: M.strictEqual, deepEqual: M.deepStrictEqual, notEqual: M.notStrictEqual, notDeepEqual: M.notDeepStrictEqual}), M.strict.strict = M.strict; - }, 5961: (t2, e2, r2) => { - var n = r2(4155); - function i(t3, e3, r3) { - return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; - } - function o(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) { - var n2 = e3[r3]; - n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(t3, n2.key, n2); - } - } - function a(t3, e3) { - return !e3 || d(e3) !== "object" && typeof e3 != "function" ? s(t3) : e3; - } - function s(t3) { - if (t3 === void 0) - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - return t3; - } - function u(t3) { - var e3 = typeof Map == "function" ? new Map() : void 0; - return (u = function(t4) { - if (t4 === null || (r3 = t4, Function.toString.call(r3).indexOf("[native code]") === -1)) - return t4; - var r3; - if (typeof t4 != "function") - throw new TypeError("Super expression must either be null or a function"); - if (e3 !== void 0) { - if (e3.has(t4)) - return e3.get(t4); - e3.set(t4, n2); - } - function n2() { - return c(t4, arguments, l(this).constructor); - } - return n2.prototype = Object.create(t4.prototype, {constructor: {value: n2, enumerable: false, writable: true, configurable: true}}), h(n2, t4); - })(t3); - } - function f() { - if (typeof Reflect == "undefined" || !Reflect.construct) - return false; - if (Reflect.construct.sham) - return false; - if (typeof Proxy == "function") - return true; - try { - return Date.prototype.toString.call(Reflect.construct(Date, [], function() { - })), true; - } catch (t3) { - return false; - } - } - function c(t3, e3, r3) { - return (c = f() ? Reflect.construct : function(t4, e4, r4) { - var n2 = [null]; - n2.push.apply(n2, e4); - var i2 = new (Function.bind.apply(t4, n2))(); - return r4 && h(i2, r4.prototype), i2; - }).apply(null, arguments); - } - function h(t3, e3) { - return (h = Object.setPrototypeOf || function(t4, e4) { - return t4.__proto__ = e4, t4; - })(t3, e3); - } - function l(t3) { - return (l = Object.setPrototypeOf ? Object.getPrototypeOf : function(t4) { - return t4.__proto__ || Object.getPrototypeOf(t4); - })(t3); - } - function d(t3) { - return (d = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { - return typeof t4; - } : function(t4) { - return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; - })(t3); - } - var p = r2(9539).inspect, y = r2(2136).codes.ERR_INVALID_ARG_TYPE; - function m(t3, e3, r3) { - return (r3 === void 0 || r3 > t3.length) && (r3 = t3.length), t3.substring(r3 - e3.length, r3) === e3; - } - var b = "", g = "", v = "", w = "", _ = {deepStrictEqual: "Expected values to be strictly deep-equal:", strictEqual: "Expected values to be strictly equal:", strictEqualObject: 'Expected "actual" to be reference-equal to "expected":', deepEqual: "Expected values to be loosely deep-equal:", equal: "Expected values to be loosely equal:", notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:', notStrictEqual: 'Expected "actual" to be strictly unequal to:', notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', notEqual: 'Expected "actual" to be loosely unequal to:', notIdentical: "Values identical but not reference-equal:"}; - function M(t3) { - var e3 = Object.keys(t3), r3 = Object.create(Object.getPrototypeOf(t3)); - return e3.forEach(function(e4) { - r3[e4] = t3[e4]; - }), Object.defineProperty(r3, "message", {value: t3.message}), r3; - } - function S(t3) { - return p(t3, {compact: false, customInspect: false, depth: 1e3, maxArrayLength: 1 / 0, showHidden: false, breakLength: 1 / 0, showProxy: false, sorted: true, getters: true}); - } - var E = function(t3) { - function e3(t4) { - var r4; - if (function(t5, e4) { - if (!(t5 instanceof e4)) - throw new TypeError("Cannot call a class as a function"); - }(this, e3), d(t4) !== "object" || t4 === null) - throw new y("options", "Object", t4); - var i2 = t4.message, o2 = t4.operator, u3 = t4.stackStartFn, f2 = t4.actual, c2 = t4.expected, h2 = Error.stackTraceLimit; - if (Error.stackTraceLimit = 0, i2 != null) - r4 = a(this, l(e3).call(this, String(i2))); - else if (n.stderr && n.stderr.isTTY && (n.stderr && n.stderr.getColorDepth && n.stderr.getColorDepth() !== 1 ? (b = "", g = "", w = "", v = "") : (b = "", g = "", w = "", v = "")), d(f2) === "object" && f2 !== null && d(c2) === "object" && c2 !== null && "stack" in f2 && f2 instanceof Error && "stack" in c2 && c2 instanceof Error && (f2 = M(f2), c2 = M(c2)), o2 === "deepStrictEqual" || o2 === "strictEqual") - r4 = a(this, l(e3).call(this, function(t5, e4, r5) { - var i3 = "", o3 = "", a2 = 0, s2 = "", u4 = false, f3 = S(t5), c3 = f3.split("\n"), h3 = S(e4).split("\n"), l2 = 0, p3 = ""; - if (r5 === "strictEqual" && d(t5) === "object" && d(e4) === "object" && t5 !== null && e4 !== null && (r5 = "strictEqualObject"), c3.length === 1 && h3.length === 1 && c3[0] !== h3[0]) { - var y2 = c3[0].length + h3[0].length; - if (y2 <= 10) { - if (!(d(t5) === "object" && t5 !== null || d(e4) === "object" && e4 !== null || t5 === 0 && e4 === 0)) - return "".concat(_[r5], "\n\n") + "".concat(c3[0], " !== ").concat(h3[0], "\n"); - } else if (r5 !== "strictEqualObject" && y2 < (n.stderr && n.stderr.isTTY ? n.stderr.columns : 80)) { - for (; c3[0][l2] === h3[0][l2]; ) - l2++; - l2 > 2 && (p3 = "\n ".concat(function(t6, e5) { - if (e5 = Math.floor(e5), t6.length == 0 || e5 == 0) - return ""; - var r6 = t6.length * e5; - for (e5 = Math.floor(Math.log(e5) / Math.log(2)); e5; ) - t6 += t6, e5--; - return t6 + t6.substring(0, r6 - t6.length); - }(" ", l2), "^"), l2 = 0); - } - } - for (var M2 = c3[c3.length - 1], E3 = h3[h3.length - 1]; M2 === E3 && (l2++ < 2 ? s2 = "\n ".concat(M2).concat(s2) : i3 = M2, c3.pop(), h3.pop(), c3.length !== 0 && h3.length !== 0); ) - M2 = c3[c3.length - 1], E3 = h3[h3.length - 1]; - var A2 = Math.max(c3.length, h3.length); - if (A2 === 0) { - var k2 = f3.split("\n"); - if (k2.length > 30) - for (k2[26] = "".concat(b, "...").concat(w); k2.length > 27; ) - k2.pop(); - return "".concat(_.notIdentical, "\n\n").concat(k2.join("\n"), "\n"); - } - l2 > 3 && (s2 = "\n".concat(b, "...").concat(w).concat(s2), u4 = true), i3 !== "" && (s2 = "\n ".concat(i3).concat(s2), i3 = ""); - var B2 = 0, T = _[r5] + "\n".concat(g, "+ actual").concat(w, " ").concat(v, "- expected").concat(w), x = " ".concat(b, "...").concat(w, " Lines skipped"); - for (l2 = 0; l2 < A2; l2++) { - var O = l2 - a2; - if (c3.length < l2 + 1) - O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(h3[l2 - 2]), B2++), o3 += "\n ".concat(h3[l2 - 1]), B2++), a2 = l2, i3 += "\n".concat(v, "-").concat(w, " ").concat(h3[l2]), B2++; - else if (h3.length < l2 + 1) - O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(c3[l2 - 2]), B2++), o3 += "\n ".concat(c3[l2 - 1]), B2++), a2 = l2, o3 += "\n".concat(g, "+").concat(w, " ").concat(c3[l2]), B2++; - else { - var R = h3[l2], P = c3[l2], I = P !== R && (!m(P, ",") || P.slice(0, -1) !== R); - I && m(R, ",") && R.slice(0, -1) === P && (I = false, P += ","), I ? (O > 1 && l2 > 2 && (O > 4 ? (o3 += "\n".concat(b, "...").concat(w), u4 = true) : O > 3 && (o3 += "\n ".concat(c3[l2 - 2]), B2++), o3 += "\n ".concat(c3[l2 - 1]), B2++), a2 = l2, o3 += "\n".concat(g, "+").concat(w, " ").concat(P), i3 += "\n".concat(v, "-").concat(w, " ").concat(R), B2 += 2) : (o3 += i3, i3 = "", O !== 1 && l2 !== 0 || (o3 += "\n ".concat(P), B2++)); - } - if (B2 > 20 && l2 < A2 - 2) - return "".concat(T).concat(x, "\n").concat(o3, "\n").concat(b, "...").concat(w).concat(i3, "\n") + "".concat(b, "...").concat(w); - } - return "".concat(T).concat(u4 ? x : "", "\n").concat(o3).concat(i3).concat(s2).concat(p3); - }(f2, c2, o2))); - else if (o2 === "notDeepStrictEqual" || o2 === "notStrictEqual") { - var p2 = _[o2], E2 = S(f2).split("\n"); - if (o2 === "notStrictEqual" && d(f2) === "object" && f2 !== null && (p2 = _.notStrictEqualObject), E2.length > 30) - for (E2[26] = "".concat(b, "...").concat(w); E2.length > 27; ) - E2.pop(); - r4 = E2.length === 1 ? a(this, l(e3).call(this, "".concat(p2, " ").concat(E2[0]))) : a(this, l(e3).call(this, "".concat(p2, "\n\n").concat(E2.join("\n"), "\n"))); - } else { - var A = S(f2), k = "", B = _[o2]; - o2 === "notDeepEqual" || o2 === "notEqual" ? (A = "".concat(_[o2], "\n\n").concat(A)).length > 1024 && (A = "".concat(A.slice(0, 1021), "...")) : (k = "".concat(S(c2)), A.length > 512 && (A = "".concat(A.slice(0, 509), "...")), k.length > 512 && (k = "".concat(k.slice(0, 509), "...")), o2 === "deepEqual" || o2 === "equal" ? A = "".concat(B, "\n\n").concat(A, "\n\nshould equal\n\n") : k = " ".concat(o2, " ").concat(k)), r4 = a(this, l(e3).call(this, "".concat(A).concat(k))); - } - return Error.stackTraceLimit = h2, r4.generatedMessage = !i2, Object.defineProperty(s(r4), "name", {value: "AssertionError [ERR_ASSERTION]", enumerable: false, writable: true, configurable: true}), r4.code = "ERR_ASSERTION", r4.actual = f2, r4.expected = c2, r4.operator = o2, Error.captureStackTrace && Error.captureStackTrace(s(r4), u3), r4.stack, r4.name = "AssertionError", a(r4); - } - var r3, u2; - return function(t4, e4) { - if (typeof e4 != "function" && e4 !== null) - throw new TypeError("Super expression must either be null or a function"); - t4.prototype = Object.create(e4 && e4.prototype, {constructor: {value: t4, writable: true, configurable: true}}), e4 && h(t4, e4); - }(e3, t3), r3 = e3, (u2 = [{key: "toString", value: function() { - return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message); - }}, {key: p.custom, value: function(t4, e4) { - return p(this, function(t5) { - for (var e5 = 1; e5 < arguments.length; e5++) { - var r4 = arguments[e5] != null ? arguments[e5] : {}, n2 = Object.keys(r4); - typeof Object.getOwnPropertySymbols == "function" && (n2 = n2.concat(Object.getOwnPropertySymbols(r4).filter(function(t6) { - return Object.getOwnPropertyDescriptor(r4, t6).enumerable; - }))), n2.forEach(function(e6) { - i(t5, e6, r4[e6]); - }); - } - return t5; - }({}, e4, {customInspect: false, depth: 0})); - }}]) && o(r3.prototype, u2), e3; - }(u(Error)); - t2.exports = E; - }, 2136: (t2, e2, r2) => { - function n(t3) { - return (n = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { - return typeof t4; - } : function(t4) { - return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; - })(t3); - } - function i(t3) { - return (i = Object.setPrototypeOf ? Object.getPrototypeOf : function(t4) { - return t4.__proto__ || Object.getPrototypeOf(t4); - })(t3); - } - function o(t3, e3) { - return (o = Object.setPrototypeOf || function(t4, e4) { - return t4.__proto__ = e4, t4; - })(t3, e3); - } - var a, s, u = {}; - function f(t3, e3, r3) { - r3 || (r3 = Error); - var a2 = function(r4) { - function a3(r5, o2, s2) { - var u2; - return function(t4, e4) { - if (!(t4 instanceof e4)) - throw new TypeError("Cannot call a class as a function"); - }(this, a3), (u2 = function(t4, e4) { - return !e4 || n(e4) !== "object" && typeof e4 != "function" ? function(t5) { - if (t5 === void 0) - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - return t5; - }(t4) : e4; - }(this, i(a3).call(this, function(t4, r6, n2) { - return typeof e3 == "string" ? e3 : e3(t4, r6, n2); - }(r5, o2, s2)))).code = t3, u2; - } - return function(t4, e4) { - if (typeof e4 != "function" && e4 !== null) - throw new TypeError("Super expression must either be null or a function"); - t4.prototype = Object.create(e4 && e4.prototype, {constructor: {value: t4, writable: true, configurable: true}}), e4 && o(t4, e4); - }(a3, r4), a3; - }(r3); - u[t3] = a2; - } - function c(t3, e3) { - if (Array.isArray(t3)) { - var r3 = t3.length; - return t3 = t3.map(function(t4) { - return String(t4); - }), r3 > 2 ? "one of ".concat(e3, " ").concat(t3.slice(0, r3 - 1).join(", "), ", or ") + t3[r3 - 1] : r3 === 2 ? "one of ".concat(e3, " ").concat(t3[0], " or ").concat(t3[1]) : "of ".concat(e3, " ").concat(t3[0]); - } - return "of ".concat(e3, " ").concat(String(t3)); - } - f("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), f("ERR_INVALID_ARG_TYPE", function(t3, e3, i2) { - var o2, s2, u2, f2, h; - if (a === void 0 && (a = r2(9282)), a(typeof t3 == "string", "'name' must be a string"), typeof e3 == "string" && (s2 = "not ", e3.substr(0, s2.length) === s2) ? (o2 = "must not be", e3 = e3.replace(/^not /, "")) : o2 = "must be", function(t4, e4, r3) { - return (r3 === void 0 || r3 > t4.length) && (r3 = t4.length), t4.substring(r3 - e4.length, r3) === e4; - }(t3, " argument")) - u2 = "The ".concat(t3, " ").concat(o2, " ").concat(c(e3, "type")); - else { - var l = (typeof h != "number" && (h = 0), h + ".".length > (f2 = t3).length || f2.indexOf(".", h) === -1 ? "argument" : "property"); - u2 = 'The "'.concat(t3, '" ').concat(l, " ").concat(o2, " ").concat(c(e3, "type")); - } - return u2 + ". Received type ".concat(n(i2)); - }, TypeError), f("ERR_INVALID_ARG_VALUE", function(t3, e3) { - var n2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "is invalid"; - s === void 0 && (s = r2(9539)); - var i2 = s.inspect(e3); - return i2.length > 128 && (i2 = "".concat(i2.slice(0, 128), "...")), "The argument '".concat(t3, "' ").concat(n2, ". Received ").concat(i2); - }, TypeError), f("ERR_INVALID_RETURN_VALUE", function(t3, e3, r3) { - var i2; - return i2 = r3 && r3.constructor && r3.constructor.name ? "instance of ".concat(r3.constructor.name) : "type ".concat(n(r3)), "Expected ".concat(t3, ' to be returned from the "').concat(e3, '"') + " function but got ".concat(i2, "."); - }, TypeError), f("ERR_MISSING_ARGS", function() { - for (var t3 = arguments.length, e3 = new Array(t3), n2 = 0; n2 < t3; n2++) - e3[n2] = arguments[n2]; - a === void 0 && (a = r2(9282)), a(e3.length > 0, "At least one arg needs to be specified"); - var i2 = "The ", o2 = e3.length; - switch (e3 = e3.map(function(t4) { - return '"'.concat(t4, '"'); - }), o2) { - case 1: - i2 += "".concat(e3[0], " argument"); - break; - case 2: - i2 += "".concat(e3[0], " and ").concat(e3[1], " arguments"); - break; - default: - i2 += e3.slice(0, o2 - 1).join(", "), i2 += ", and ".concat(e3[o2 - 1], " arguments"); - } - return "".concat(i2, " must be specified"); - }, TypeError), t2.exports.codes = u; - }, 9158: (t2, e2, r2) => { - function n(t3, e3) { - return function(t4) { - if (Array.isArray(t4)) - return t4; - }(t3) || function(t4, e4) { - var r3 = [], n2 = true, i2 = false, o2 = void 0; - try { - for (var a2, s2 = t4[Symbol.iterator](); !(n2 = (a2 = s2.next()).done) && (r3.push(a2.value), !e4 || r3.length !== e4); n2 = true) - ; - } catch (t5) { - i2 = true, o2 = t5; - } finally { - try { - n2 || s2.return == null || s2.return(); - } finally { - if (i2) - throw o2; - } - } - return r3; - }(t3, e3) || function() { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - }(); - } - function i(t3) { - return (i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t4) { - return typeof t4; - } : function(t4) { - return t4 && typeof Symbol == "function" && t4.constructor === Symbol && t4 !== Symbol.prototype ? "symbol" : typeof t4; - })(t3); - } - var o = /a/g.flags !== void 0, a = function(t3) { - var e3 = []; - return t3.forEach(function(t4) { - return e3.push(t4); - }), e3; - }, s = function(t3) { - var e3 = []; - return t3.forEach(function(t4, r3) { - return e3.push([r3, t4]); - }), e3; - }, u = Object.is ? Object.is : r2(609), f = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function() { - return []; - }, c = Number.isNaN ? Number.isNaN : r2(360); - function h(t3) { - return t3.call.bind(t3); - } - var l = h(Object.prototype.hasOwnProperty), d = h(Object.prototype.propertyIsEnumerable), p = h(Object.prototype.toString), y = r2(9539).types, m = y.isAnyArrayBuffer, b = y.isArrayBufferView, g = y.isDate, v = y.isMap, w = y.isRegExp, _ = y.isSet, M = y.isNativeError, S = y.isBoxedPrimitive, E = y.isNumberObject, A = y.isStringObject, k = y.isBooleanObject, B = y.isBigIntObject, T = y.isSymbolObject, x = y.isFloat32Array, O = y.isFloat64Array; - function R(t3) { - if (t3.length === 0 || t3.length > 10) - return true; - for (var e3 = 0; e3 < t3.length; e3++) { - var r3 = t3.charCodeAt(e3); - if (r3 < 48 || r3 > 57) - return true; - } - return t3.length === 10 && t3 >= Math.pow(2, 32); - } - function P(t3) { - return Object.keys(t3).filter(R).concat(f(t3).filter(Object.prototype.propertyIsEnumerable.bind(t3))); - } - function I(t3, e3) { - if (t3 === e3) - return 0; - for (var r3 = t3.length, n2 = e3.length, i2 = 0, o2 = Math.min(r3, n2); i2 < o2; ++i2) - if (t3[i2] !== e3[i2]) { - r3 = t3[i2], n2 = e3[i2]; - break; - } - return r3 < n2 ? -1 : n2 < r3 ? 1 : 0; - } - function j(t3, e3, r3, n2) { - if (t3 === e3) - return t3 !== 0 || !r3 || u(t3, e3); - if (r3) { - if (i(t3) !== "object") - return typeof t3 == "number" && c(t3) && c(e3); - if (i(e3) !== "object" || t3 === null || e3 === null) - return false; - if (Object.getPrototypeOf(t3) !== Object.getPrototypeOf(e3)) - return false; - } else { - if (t3 === null || i(t3) !== "object") - return (e3 === null || i(e3) !== "object") && t3 == e3; - if (e3 === null || i(e3) !== "object") - return false; - } - var a2, s2, f2, h2, l2 = p(t3); - if (l2 !== p(e3)) - return false; - if (Array.isArray(t3)) { - if (t3.length !== e3.length) - return false; - var d2 = P(t3), y2 = P(e3); - return d2.length === y2.length && N(t3, e3, r3, n2, 1, d2); - } - if (l2 === "[object Object]" && (!v(t3) && v(e3) || !_(t3) && _(e3))) - return false; - if (g(t3)) { - if (!g(e3) || Date.prototype.getTime.call(t3) !== Date.prototype.getTime.call(e3)) - return false; - } else if (w(t3)) { - if (!w(e3) || (f2 = t3, h2 = e3, !(o ? f2.source === h2.source && f2.flags === h2.flags : RegExp.prototype.toString.call(f2) === RegExp.prototype.toString.call(h2)))) - return false; - } else if (M(t3) || t3 instanceof Error) { - if (t3.message !== e3.message || t3.name !== e3.name) - return false; - } else { - if (b(t3)) { - if (r3 || !x(t3) && !O(t3)) { - if (!function(t4, e4) { - return t4.byteLength === e4.byteLength && I(new Uint8Array(t4.buffer, t4.byteOffset, t4.byteLength), new Uint8Array(e4.buffer, e4.byteOffset, e4.byteLength)) === 0; - }(t3, e3)) - return false; - } else if (!function(t4, e4) { - if (t4.byteLength !== e4.byteLength) - return false; - for (var r4 = 0; r4 < t4.byteLength; r4++) - if (t4[r4] !== e4[r4]) - return false; - return true; - }(t3, e3)) - return false; - var R2 = P(t3), j2 = P(e3); - return R2.length === j2.length && N(t3, e3, r3, n2, 0, R2); - } - if (_(t3)) - return !(!_(e3) || t3.size !== e3.size) && N(t3, e3, r3, n2, 2); - if (v(t3)) - return !(!v(e3) || t3.size !== e3.size) && N(t3, e3, r3, n2, 3); - if (m(t3)) { - if (s2 = e3, (a2 = t3).byteLength !== s2.byteLength || I(new Uint8Array(a2), new Uint8Array(s2)) !== 0) - return false; - } else if (S(t3) && !function(t4, e4) { - return E(t4) ? E(e4) && u(Number.prototype.valueOf.call(t4), Number.prototype.valueOf.call(e4)) : A(t4) ? A(e4) && String.prototype.valueOf.call(t4) === String.prototype.valueOf.call(e4) : k(t4) ? k(e4) && Boolean.prototype.valueOf.call(t4) === Boolean.prototype.valueOf.call(e4) : B(t4) ? B(e4) && BigInt.prototype.valueOf.call(t4) === BigInt.prototype.valueOf.call(e4) : T(e4) && Symbol.prototype.valueOf.call(t4) === Symbol.prototype.valueOf.call(e4); - }(t3, e3)) - return false; - } - return N(t3, e3, r3, n2, 0); - } - function U(t3, e3) { - return e3.filter(function(e4) { - return d(t3, e4); - }); - } - function N(t3, e3, r3, n2, i2, o2) { - if (arguments.length === 5) { - o2 = Object.keys(t3); - var a2 = Object.keys(e3); - if (o2.length !== a2.length) - return false; - } - for (var s2 = 0; s2 < o2.length; s2++) - if (!l(e3, o2[s2])) - return false; - if (r3 && arguments.length === 5) { - var u2 = f(t3); - if (u2.length !== 0) { - var c2 = 0; - for (s2 = 0; s2 < u2.length; s2++) { - var h2 = u2[s2]; - if (d(t3, h2)) { - if (!d(e3, h2)) - return false; - o2.push(h2), c2++; - } else if (d(e3, h2)) - return false; - } - var p2 = f(e3); - if (u2.length !== p2.length && U(e3, p2).length !== c2) - return false; - } else { - var y2 = f(e3); - if (y2.length !== 0 && U(e3, y2).length !== 0) - return false; - } - } - if (o2.length === 0 && (i2 === 0 || i2 === 1 && t3.length === 0 || t3.size === 0)) - return true; - if (n2 === void 0) - n2 = {val1: new Map(), val2: new Map(), position: 0}; - else { - var m2 = n2.val1.get(t3); - if (m2 !== void 0) { - var b2 = n2.val2.get(e3); - if (b2 !== void 0) - return m2 === b2; - } - n2.position++; - } - n2.val1.set(t3, n2.position), n2.val2.set(e3, n2.position); - var g2 = q(t3, e3, r3, o2, n2, i2); - return n2.val1.delete(t3), n2.val2.delete(e3), g2; - } - function C(t3, e3, r3, n2) { - for (var i2 = a(t3), o2 = 0; o2 < i2.length; o2++) { - var s2 = i2[o2]; - if (j(e3, s2, r3, n2)) - return t3.delete(s2), true; - } - return false; - } - function D(t3) { - switch (i(t3)) { - case "undefined": - return null; - case "object": - return; - case "symbol": - return false; - case "string": - t3 = +t3; - case "number": - if (c(t3)) - return false; - } - return true; - } - function L(t3, e3, r3) { - var n2 = D(r3); - return n2 != null ? n2 : e3.has(n2) && !t3.has(n2); - } - function K(t3, e3, r3, n2, i2) { - var o2 = D(r3); - if (o2 != null) - return o2; - var a2 = e3.get(o2); - return !(a2 === void 0 && !e3.has(o2) || !j(n2, a2, false, i2)) && !t3.has(o2) && j(n2, a2, false, i2); - } - function z(t3, e3, r3, n2, i2, o2) { - for (var s2 = a(t3), u2 = 0; u2 < s2.length; u2++) { - var f2 = s2[u2]; - if (j(r3, f2, i2, o2) && j(n2, e3.get(f2), i2, o2)) - return t3.delete(f2), true; - } - return false; - } - function q(t3, e3, r3, o2, u2, f2) { - var c2 = 0; - if (f2 === 2) { - if (!function(t4, e4, r4, n2) { - for (var o3 = null, s2 = a(t4), u3 = 0; u3 < s2.length; u3++) { - var f3 = s2[u3]; - if (i(f3) === "object" && f3 !== null) - o3 === null && (o3 = new Set()), o3.add(f3); - else if (!e4.has(f3)) { - if (r4) - return false; - if (!L(t4, e4, f3)) - return false; - o3 === null && (o3 = new Set()), o3.add(f3); - } - } - if (o3 !== null) { - for (var c3 = a(e4), h3 = 0; h3 < c3.length; h3++) { - var l2 = c3[h3]; - if (i(l2) === "object" && l2 !== null) { - if (!C(o3, l2, r4, n2)) - return false; - } else if (!r4 && !t4.has(l2) && !C(o3, l2, r4, n2)) - return false; - } - return o3.size === 0; - } - return true; - }(t3, e3, r3, u2)) - return false; - } else if (f2 === 3) { - if (!function(t4, e4, r4, o3) { - for (var a2 = null, u3 = s(t4), f3 = 0; f3 < u3.length; f3++) { - var c3 = n(u3[f3], 2), h3 = c3[0], l2 = c3[1]; - if (i(h3) === "object" && h3 !== null) - a2 === null && (a2 = new Set()), a2.add(h3); - else { - var d3 = e4.get(h3); - if (d3 === void 0 && !e4.has(h3) || !j(l2, d3, r4, o3)) { - if (r4) - return false; - if (!K(t4, e4, h3, l2, o3)) - return false; - a2 === null && (a2 = new Set()), a2.add(h3); - } - } - } - if (a2 !== null) { - for (var p3 = s(e4), y2 = 0; y2 < p3.length; y2++) { - var m2 = n(p3[y2], 2), b2 = (h3 = m2[0], m2[1]); - if (i(h3) === "object" && h3 !== null) { - if (!z(a2, t4, h3, b2, r4, o3)) - return false; - } else if (!(r4 || t4.has(h3) && j(t4.get(h3), b2, false, o3) || z(a2, t4, h3, b2, false, o3))) - return false; - } - return a2.size === 0; - } - return true; - }(t3, e3, r3, u2)) - return false; - } else if (f2 === 1) - for (; c2 < t3.length; c2++) { - if (!l(t3, c2)) { - if (l(e3, c2)) - return false; - for (var h2 = Object.keys(t3); c2 < h2.length; c2++) { - var d2 = h2[c2]; - if (!l(e3, d2) || !j(t3[d2], e3[d2], r3, u2)) - return false; - } - return h2.length === Object.keys(e3).length; - } - if (!l(e3, c2) || !j(t3[c2], e3[c2], r3, u2)) - return false; - } - for (c2 = 0; c2 < o2.length; c2++) { - var p2 = o2[c2]; - if (!j(t3[p2], e3[p2], r3, u2)) - return false; - } - return true; - } - t2.exports = {isDeepEqual: function(t3, e3) { - return j(t3, e3, false); - }, isDeepStrictEqual: function(t3, e3) { - return j(t3, e3, true); - }}; - }, 6314: (t2, e2, r2) => { - var n = r2(2190); - t2.exports = function() { - return n(["BigInt64Array", "BigUint64Array", "Float32Array", "Float64Array", "Int16Array", "Int32Array", "Int8Array", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray"], function(t3) { - return typeof r2.g[t3] == "function"; - }); - }; - }, 8162: (t2, e2, r2) => { - var n = r2(9509).Buffer; - t2.exports = function(t3) { - if (t3.length >= 255) - throw new TypeError("Alphabet too long"); - for (var e3 = new Uint8Array(256), r3 = 0; r3 < e3.length; r3++) - e3[r3] = 255; - for (var i = 0; i < t3.length; i++) { - var o = t3.charAt(i), a = o.charCodeAt(0); - if (e3[a] !== 255) - throw new TypeError(o + " is ambiguous"); - e3[a] = i; - } - var s = t3.length, u = t3.charAt(0), f = Math.log(s) / Math.log(256), c = Math.log(256) / Math.log(s); - function h(t4) { - if (typeof t4 != "string") - throw new TypeError("Expected String"); - if (t4.length === 0) - return n.alloc(0); - var r4 = 0; - if (t4[r4] !== " ") { - for (var i2 = 0, o2 = 0; t4[r4] === u; ) - i2++, r4++; - for (var a2 = (t4.length - r4) * f + 1 >>> 0, c2 = new Uint8Array(a2); t4[r4]; ) { - var h2 = e3[t4.charCodeAt(r4)]; - if (h2 === 255) - return; - for (var l = 0, d = a2 - 1; (h2 !== 0 || l < o2) && d !== -1; d--, l++) - h2 += s * c2[d] >>> 0, c2[d] = h2 % 256 >>> 0, h2 = h2 / 256 >>> 0; - if (h2 !== 0) - throw new Error("Non-zero carry"); - o2 = l, r4++; - } - if (t4[r4] !== " ") { - for (var p = a2 - o2; p !== a2 && c2[p] === 0; ) - p++; - var y = n.allocUnsafe(i2 + (a2 - p)); - y.fill(0, 0, i2); - for (var m = i2; p !== a2; ) - y[m++] = c2[p++]; - return y; - } - } - } - return {encode: function(e4) { - if ((Array.isArray(e4) || e4 instanceof Uint8Array) && (e4 = n.from(e4)), !n.isBuffer(e4)) - throw new TypeError("Expected Buffer"); - if (e4.length === 0) - return ""; - for (var r4 = 0, i2 = 0, o2 = 0, a2 = e4.length; o2 !== a2 && e4[o2] === 0; ) - o2++, r4++; - for (var f2 = (a2 - o2) * c + 1 >>> 0, h2 = new Uint8Array(f2); o2 !== a2; ) { - for (var l = e4[o2], d = 0, p = f2 - 1; (l !== 0 || d < i2) && p !== -1; p--, d++) - l += 256 * h2[p] >>> 0, h2[p] = l % s >>> 0, l = l / s >>> 0; - if (l !== 0) - throw new Error("Non-zero carry"); - i2 = d, o2++; - } - for (var y = f2 - i2; y !== f2 && h2[y] === 0; ) - y++; - for (var m = u.repeat(r4); y < f2; ++y) - m += t3.charAt(h2[y]); - return m; - }, decodeUnsafe: h, decode: function(t4) { - var e4 = h(t4); - if (e4) - return e4; - throw new Error("Non-base" + s + " character"); - }}; - }; - }, 9742: (t2, e2) => { - e2.byteLength = function(t3) { - var e3 = u(t3), r3 = e3[0], n2 = e3[1]; - return 3 * (r3 + n2) / 4 - n2; - }, e2.toByteArray = function(t3) { - var e3, r3, o2 = u(t3), a2 = o2[0], s2 = o2[1], f2 = new i(function(t4, e4, r4) { - return 3 * (e4 + r4) / 4 - r4; - }(0, a2, s2)), c = 0, h = s2 > 0 ? a2 - 4 : a2; - for (r3 = 0; r3 < h; r3 += 4) - e3 = n[t3.charCodeAt(r3)] << 18 | n[t3.charCodeAt(r3 + 1)] << 12 | n[t3.charCodeAt(r3 + 2)] << 6 | n[t3.charCodeAt(r3 + 3)], f2[c++] = e3 >> 16 & 255, f2[c++] = e3 >> 8 & 255, f2[c++] = 255 & e3; - return s2 === 2 && (e3 = n[t3.charCodeAt(r3)] << 2 | n[t3.charCodeAt(r3 + 1)] >> 4, f2[c++] = 255 & e3), s2 === 1 && (e3 = n[t3.charCodeAt(r3)] << 10 | n[t3.charCodeAt(r3 + 1)] << 4 | n[t3.charCodeAt(r3 + 2)] >> 2, f2[c++] = e3 >> 8 & 255, f2[c++] = 255 & e3), f2; - }, e2.fromByteArray = function(t3) { - for (var e3, n2 = t3.length, i2 = n2 % 3, o2 = [], a2 = 16383, s2 = 0, u2 = n2 - i2; s2 < u2; s2 += a2) - o2.push(f(t3, s2, s2 + a2 > u2 ? u2 : s2 + a2)); - return i2 === 1 ? (e3 = t3[n2 - 1], o2.push(r2[e3 >> 2] + r2[e3 << 4 & 63] + "==")) : i2 === 2 && (e3 = (t3[n2 - 2] << 8) + t3[n2 - 1], o2.push(r2[e3 >> 10] + r2[e3 >> 4 & 63] + r2[e3 << 2 & 63] + "=")), o2.join(""); - }; - for (var r2 = [], n = [], i = typeof Uint8Array != "undefined" ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = 0, s = o.length; a < s; ++a) - r2[a] = o[a], n[o.charCodeAt(a)] = a; - function u(t3) { - var e3 = t3.length; - if (e3 % 4 > 0) - throw new Error("Invalid string. Length must be a multiple of 4"); - var r3 = t3.indexOf("="); - return r3 === -1 && (r3 = e3), [r3, r3 === e3 ? 0 : 4 - r3 % 4]; - } - function f(t3, e3, n2) { - for (var i2, o2, a2 = [], s2 = e3; s2 < n2; s2 += 3) - i2 = (t3[s2] << 16 & 16711680) + (t3[s2 + 1] << 8 & 65280) + (255 & t3[s2 + 2]), a2.push(r2[(o2 = i2) >> 18 & 63] + r2[o2 >> 12 & 63] + r2[o2 >> 6 & 63] + r2[63 & o2]); - return a2.join(""); - } - n["-".charCodeAt(0)] = 62, n["_".charCodeAt(0)] = 63; - }, 8442: (t2, e2, r2) => { - var n = r2(9488); - function i(t3, e3, r3) { - var n2 = t3[e3] + t3[r3], i2 = t3[e3 + 1] + t3[r3 + 1]; - n2 >= 4294967296 && i2++, t3[e3] = n2, t3[e3 + 1] = i2; - } - function o(t3, e3, r3, n2) { - var i2 = t3[e3] + r3; - r3 < 0 && (i2 += 4294967296); - var o2 = t3[e3 + 1] + n2; - i2 >= 4294967296 && o2++, t3[e3] = i2, t3[e3 + 1] = o2; - } - function a(t3, e3) { - return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; - } - function s(t3, e3, r3, n2, a2, s2) { - var u2 = h[a2], f2 = h[a2 + 1], l2 = h[s2], d2 = h[s2 + 1]; - i(c, t3, e3), o(c, t3, u2, f2); - var p2 = c[n2] ^ c[t3], y2 = c[n2 + 1] ^ c[t3 + 1]; - c[n2] = y2, c[n2 + 1] = p2, i(c, r3, n2), p2 = c[e3] ^ c[r3], y2 = c[e3 + 1] ^ c[r3 + 1], c[e3] = p2 >>> 24 ^ y2 << 8, c[e3 + 1] = y2 >>> 24 ^ p2 << 8, i(c, t3, e3), o(c, t3, l2, d2), p2 = c[n2] ^ c[t3], y2 = c[n2 + 1] ^ c[t3 + 1], c[n2] = p2 >>> 16 ^ y2 << 16, c[n2 + 1] = y2 >>> 16 ^ p2 << 16, i(c, r3, n2), p2 = c[e3] ^ c[r3], y2 = c[e3 + 1] ^ c[r3 + 1], c[e3] = y2 >>> 31 ^ p2 << 1, c[e3 + 1] = p2 >>> 31 ^ y2 << 1; - } - var u = new Uint32Array([4089235720, 1779033703, 2227873595, 3144134277, 4271175723, 1013904242, 1595750129, 2773480762, 2917565137, 1359893119, 725511199, 2600822924, 4215389547, 528734635, 327033209, 1541459225]), f = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3].map(function(t3) { - return 2 * t3; - })), c = new Uint32Array(32), h = new Uint32Array(32); - function l(t3, e3) { - var r3 = 0; - for (r3 = 0; r3 < 16; r3++) - c[r3] = t3.h[r3], c[r3 + 16] = u[r3]; - for (c[24] = c[24] ^ t3.t, c[25] = c[25] ^ t3.t / 4294967296, e3 && (c[28] = ~c[28], c[29] = ~c[29]), r3 = 0; r3 < 32; r3++) - h[r3] = a(t3.b, 4 * r3); - for (r3 = 0; r3 < 12; r3++) - s(0, 8, 16, 24, f[16 * r3 + 0], f[16 * r3 + 1]), s(2, 10, 18, 26, f[16 * r3 + 2], f[16 * r3 + 3]), s(4, 12, 20, 28, f[16 * r3 + 4], f[16 * r3 + 5]), s(6, 14, 22, 30, f[16 * r3 + 6], f[16 * r3 + 7]), s(0, 10, 20, 30, f[16 * r3 + 8], f[16 * r3 + 9]), s(2, 12, 22, 24, f[16 * r3 + 10], f[16 * r3 + 11]), s(4, 14, 16, 26, f[16 * r3 + 12], f[16 * r3 + 13]), s(6, 8, 18, 28, f[16 * r3 + 14], f[16 * r3 + 15]); - for (r3 = 0; r3 < 16; r3++) - t3.h[r3] = t3.h[r3] ^ c[r3] ^ c[r3 + 16]; - } - function d(t3, e3) { - if (t3 === 0 || t3 > 64) - throw new Error("Illegal output length, expected 0 < length <= 64"); - if (e3 && e3.length > 64) - throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64"); - for (var r3 = {b: new Uint8Array(128), h: new Uint32Array(16), t: 0, c: 0, outlen: t3}, n2 = 0; n2 < 16; n2++) - r3.h[n2] = u[n2]; - var i2 = e3 ? e3.length : 0; - return r3.h[0] ^= 16842752 ^ i2 << 8 ^ t3, e3 && (p(r3, e3), r3.c = 128), r3; - } - function p(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) - t3.c === 128 && (t3.t += t3.c, l(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; - } - function y(t3) { - for (t3.t += t3.c; t3.c < 128; ) - t3.b[t3.c++] = 0; - l(t3, true); - for (var e3 = new Uint8Array(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) - e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3); - return e3; - } - function m(t3, e3, r3) { - r3 = r3 || 64, t3 = n.normalizeInput(t3); - var i2 = d(r3, e3); - return p(i2, t3), y(i2); - } - t2.exports = {blake2b: m, blake2bHex: function(t3, e3, r3) { - var i2 = m(t3, e3, r3); - return n.toHex(i2); - }, blake2bInit: d, blake2bUpdate: p, blake2bFinal: y}; - }, 5297: (t2, e2, r2) => { - var n = r2(9488); - function i(t3, e3) { - return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; - } - function o(t3, e3, r3, n2, i2, o2) { - f[t3] = f[t3] + f[e3] + i2, f[n2] = a(f[n2] ^ f[t3], 16), f[r3] = f[r3] + f[n2], f[e3] = a(f[e3] ^ f[r3], 12), f[t3] = f[t3] + f[e3] + o2, f[n2] = a(f[n2] ^ f[t3], 8), f[r3] = f[r3] + f[n2], f[e3] = a(f[e3] ^ f[r3], 7); - } - function a(t3, e3) { - return t3 >>> e3 ^ t3 << 32 - e3; - } - var s = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), u = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]), f = new Uint32Array(16), c = new Uint32Array(16); - function h(t3, e3) { - var r3 = 0; - for (r3 = 0; r3 < 8; r3++) - f[r3] = t3.h[r3], f[r3 + 8] = s[r3]; - for (f[12] ^= t3.t, f[13] ^= t3.t / 4294967296, e3 && (f[14] = ~f[14]), r3 = 0; r3 < 16; r3++) - c[r3] = i(t3.b, 4 * r3); - for (r3 = 0; r3 < 10; r3++) - o(0, 4, 8, 12, c[u[16 * r3 + 0]], c[u[16 * r3 + 1]]), o(1, 5, 9, 13, c[u[16 * r3 + 2]], c[u[16 * r3 + 3]]), o(2, 6, 10, 14, c[u[16 * r3 + 4]], c[u[16 * r3 + 5]]), o(3, 7, 11, 15, c[u[16 * r3 + 6]], c[u[16 * r3 + 7]]), o(0, 5, 10, 15, c[u[16 * r3 + 8]], c[u[16 * r3 + 9]]), o(1, 6, 11, 12, c[u[16 * r3 + 10]], c[u[16 * r3 + 11]]), o(2, 7, 8, 13, c[u[16 * r3 + 12]], c[u[16 * r3 + 13]]), o(3, 4, 9, 14, c[u[16 * r3 + 14]], c[u[16 * r3 + 15]]); - for (r3 = 0; r3 < 8; r3++) - t3.h[r3] ^= f[r3] ^ f[r3 + 8]; - } - function l(t3, e3) { - if (!(t3 > 0 && t3 <= 32)) - throw new Error("Incorrect output length, should be in [1, 32]"); - var r3 = e3 ? e3.length : 0; - if (e3 && !(r3 > 0 && r3 <= 32)) - throw new Error("Incorrect key length, should be in [1, 32]"); - var n2 = {h: new Uint32Array(s), b: new Uint32Array(64), c: 0, t: 0, outlen: t3}; - return n2.h[0] ^= 16842752 ^ r3 << 8 ^ t3, r3 > 0 && (d(n2, e3), n2.c = 64), n2; - } - function d(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) - t3.c === 64 && (t3.t += t3.c, h(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; - } - function p(t3) { - for (t3.t += t3.c; t3.c < 64; ) - t3.b[t3.c++] = 0; - h(t3, true); - for (var e3 = new Uint8Array(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) - e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3) & 255; - return e3; - } - function y(t3, e3, r3) { - r3 = r3 || 32, t3 = n.normalizeInput(t3); - var i2 = l(r3, e3); - return d(i2, t3), p(i2); - } - t2.exports = {blake2s: y, blake2sHex: function(t3, e3, r3) { - var i2 = y(t3, e3, r3); - return n.toHex(i2); - }, blake2sInit: l, blake2sUpdate: d, blake2sFinal: p}; - }, 1191: (t2, e2, r2) => { - var n = r2(8442), i = r2(5297); - t2.exports = {blake2b: n.blake2b, blake2bHex: n.blake2bHex, blake2bInit: n.blake2bInit, blake2bUpdate: n.blake2bUpdate, blake2bFinal: n.blake2bFinal, blake2s: i.blake2s, blake2sHex: i.blake2sHex, blake2sInit: i.blake2sInit, blake2sUpdate: i.blake2sUpdate, blake2sFinal: i.blake2sFinal}; - }, 9488: (t2, e2, r2) => { - var n = r2(8764).Buffer; - function i(t3) { - return (4294967296 + t3).toString(16).substring(1); - } - t2.exports = {normalizeInput: function(t3) { - var e3; - if (t3 instanceof Uint8Array) - e3 = t3; - else if (t3 instanceof n) - e3 = new Uint8Array(t3); - else { - if (typeof t3 != "string") - throw new Error("Input must be an string, Buffer or Uint8Array"); - e3 = new Uint8Array(n.from(t3, "utf8")); - } - return e3; - }, toHex: function(t3) { - return Array.prototype.map.call(t3, function(t4) { - return (t4 < 16 ? "0" : "") + t4.toString(16); - }).join(""); - }, debugPrint: function(t3, e3, r3) { - for (var n2 = "\n" + t3 + " = ", o = 0; o < e3.length; o += 2) { - if (r3 === 32) - n2 += i(e3[o]).toUpperCase(), n2 += " ", n2 += i(e3[o + 1]).toUpperCase(); - else { - if (r3 !== 64) - throw new Error("Invalid size " + r3); - n2 += i(e3[o + 1]).toUpperCase(), n2 += i(e3[o]).toUpperCase(); - } - o % 6 == 4 ? n2 += "\n" + new Array(t3.length + 4).join(" ") : o < e3.length - 2 && (n2 += " "); - } - console.log(n2); - }, testSpeed: function(t3, e3, r3) { - for (var n2 = new Date().getTime(), i2 = new Uint8Array(e3), o = 0; o < e3; o++) - i2[o] = o % 256; - var a = new Date().getTime(); - for (console.log("Generated random input in " + (a - n2) + "ms"), n2 = a, o = 0; o < r3; o++) { - var s = t3(i2), u = new Date().getTime(), f = u - n2; - n2 = u, console.log("Hashed in " + f + "ms: " + s.substring(0, 20) + "..."), console.log(Math.round(e3 / (1 << 20) / (f / 1e3) * 100) / 100 + " MB PER SECOND"); - } - }}; - }, 3550: function(t2, e2, r2) { - !function(t3, e3) { - function n(t4, e4) { - if (!t4) - throw new Error(e4 || "Assertion failed"); - } - function i(t4, e4) { - t4.super_ = e4; - var r3 = function() { - }; - r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; - } - function o(t4, e4, r3) { - if (o.isBN(t4)) - return t4; - this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); - } - var a; - typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; - try { - a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(6601).Buffer; - } catch (t4) { - } - function s(t4, e4) { - var r3 = t4.charCodeAt(e4); - return r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : r3 - 48 & 15; - } - function u(t4, e4, r3) { - var n2 = s(t4, r3); - return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; - } - function f(t4, e4, r3, n2) { - for (var i2 = 0, o2 = Math.min(t4.length, r3), a2 = e4; a2 < o2; a2++) { - var s2 = t4.charCodeAt(a2) - 48; - i2 *= n2, i2 += s2 >= 49 ? s2 - 49 + 10 : s2 >= 17 ? s2 - 17 + 10 : s2; - } - return i2; - } - o.isBN = function(t4) { - return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); - }, o.max = function(t4, e4) { - return t4.cmp(e4) > 0 ? t4 : e4; - }, o.min = function(t4, e4) { - return t4.cmp(e4) < 0 ? t4 : e4; - }, o.prototype._init = function(t4, e4, r3) { - if (typeof t4 == "number") - return this._initNumber(t4, e4, r3); - if (typeof t4 == "object") - return this._initArray(t4, e4, r3); - e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); - var i2 = 0; - (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); - }, o.prototype._initNumber = function(t4, e4, r3) { - t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); - }, o.prototype._initArray = function(t4, e4, r3) { - if (n(typeof t4.length == "number"), t4.length <= 0) - return this.words = [0], this.length = 1, this; - this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); - for (var i2 = 0; i2 < this.length; i2++) - this.words[i2] = 0; - var o2, a2, s2 = 0; - if (r3 === "be") - for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) - a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - else if (r3 === "le") - for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) - a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - return this.strip(); - }, o.prototype._parseHex = function(t4, e4, r3) { - this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); - for (var n2 = 0; n2 < this.length; n2++) - this.words[n2] = 0; - var i2, o2 = 0, a2 = 0; - if (r3 === "be") - for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - else - for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - this.strip(); - }, o.prototype._parseBase = function(t4, e4, r3) { - this.words = [0], this.length = 1; - for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) - n2++; - n2--, i2 = i2 / e4 | 0; - for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) - u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - if (a2 !== 0) { - var h2 = 1; - for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) - h2 *= e4; - this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - } - this.strip(); - }, o.prototype.copy = function(t4) { - t4.words = new Array(this.length); - for (var e4 = 0; e4 < this.length; e4++) - t4.words[e4] = this.words[e4]; - t4.length = this.length, t4.negative = this.negative, t4.red = this.red; - }, o.prototype.clone = function() { - var t4 = new o(null); - return this.copy(t4), t4; - }, o.prototype._expand = function(t4) { - for (; this.length < t4; ) - this.words[this.length++] = 0; - return this; - }, o.prototype.strip = function() { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) - this.length--; - return this._normSign(); - }, o.prototype._normSign = function() { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }, o.prototype.inspect = function() { - return (this.red ? ""; - }; - var c = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], h = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], l = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; - function d(t4, e4, r3) { - r3.negative = e4.negative ^ t4.negative; - var n2 = t4.length + e4.length | 0; - r3.length = n2, n2 = n2 - 1 | 0; - var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; - r3.words[0] = s2; - for (var f2 = 1; f2 < n2; f2++) { - for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { - var p2 = f2 - d2 | 0; - c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; - } - r3.words[f2] = 0 | h2, u2 = 0 | c2; - } - return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3.strip(); - } - o.prototype.toString = function(t4, e4) { - var r3; - if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { - r3 = ""; - for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { - var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); - r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? c[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); - } - for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { - var f2 = h[t4], d2 = l[t4]; - r3 = ""; - var p2 = this.clone(); - for (p2.negative = 0; !p2.isZero(); ) { - var y2 = p2.modn(d2).toString(t4); - r3 = (p2 = p2.idivn(d2)).isZero() ? y2 + r3 : c[f2 - y2.length] + y2 + r3; - } - for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - n(false, "Base should be between 2 and 36"); - }, o.prototype.toNumber = function() { - var t4 = this.words[0]; - return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; - }, o.prototype.toJSON = function() { - return this.toString(16); - }, o.prototype.toBuffer = function(t4, e4) { - return n(a !== void 0), this.toArrayLike(a, t4, e4); - }, o.prototype.toArray = function(t4, e4) { - return this.toArrayLike(Array, t4, e4); - }, o.prototype.toArrayLike = function(t4, e4, r3) { - var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); - n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"), this.strip(); - var a2, s2, u2 = e4 === "le", f2 = new t4(o2), c2 = this.clone(); - if (u2) { - for (s2 = 0; !c2.isZero(); s2++) - a2 = c2.andln(255), c2.iushrn(8), f2[s2] = a2; - for (; s2 < o2; s2++) - f2[s2] = 0; - } else { - for (s2 = 0; s2 < o2 - i2; s2++) - f2[s2] = 0; - for (s2 = 0; !c2.isZero(); s2++) - a2 = c2.andln(255), c2.iushrn(8), f2[o2 - s2 - 1] = a2; - } - return f2; - }, Math.clz32 ? o.prototype._countBits = function(t4) { - return 32 - Math.clz32(t4); - } : o.prototype._countBits = function(t4) { - var e4 = t4, r3 = 0; - return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; - }, o.prototype._zeroBits = function(t4) { - if (t4 === 0) - return 26; - var e4 = t4, r3 = 0; - return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; - }, o.prototype.bitLength = function() { - var t4 = this.words[this.length - 1], e4 = this._countBits(t4); - return 26 * (this.length - 1) + e4; - }, o.prototype.zeroBits = function() { - if (this.isZero()) - return 0; - for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { - var r3 = this._zeroBits(this.words[e4]); - if (t4 += r3, r3 !== 26) - break; - } - return t4; - }, o.prototype.byteLength = function() { - return Math.ceil(this.bitLength() / 8); - }, o.prototype.toTwos = function(t4) { - return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); - }, o.prototype.fromTwos = function(t4) { - return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); - }, o.prototype.isNeg = function() { - return this.negative !== 0; - }, o.prototype.neg = function() { - return this.clone().ineg(); - }, o.prototype.ineg = function() { - return this.isZero() || (this.negative ^= 1), this; - }, o.prototype.iuor = function(t4) { - for (; this.length < t4.length; ) - this.words[this.length++] = 0; - for (var e4 = 0; e4 < t4.length; e4++) - this.words[e4] = this.words[e4] | t4.words[e4]; - return this.strip(); - }, o.prototype.ior = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuor(t4); - }, o.prototype.or = function(t4) { - return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); - }, o.prototype.uor = function(t4) { - return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); - }, o.prototype.iuand = function(t4) { - var e4; - e4 = this.length > t4.length ? t4 : this; - for (var r3 = 0; r3 < e4.length; r3++) - this.words[r3] = this.words[r3] & t4.words[r3]; - return this.length = e4.length, this.strip(); - }, o.prototype.iand = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuand(t4); - }, o.prototype.and = function(t4) { - return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); - }, o.prototype.uand = function(t4) { - return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); - }, o.prototype.iuxor = function(t4) { - var e4, r3; - this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); - for (var n2 = 0; n2 < r3.length; n2++) - this.words[n2] = e4.words[n2] ^ r3.words[n2]; - if (this !== e4) - for (; n2 < e4.length; n2++) - this.words[n2] = e4.words[n2]; - return this.length = e4.length, this.strip(); - }, o.prototype.ixor = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuxor(t4); - }, o.prototype.xor = function(t4) { - return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); - }, o.prototype.uxor = function(t4) { - return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); - }, o.prototype.inotn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; - this._expand(e4), r3 > 0 && e4--; - for (var i2 = 0; i2 < e4; i2++) - this.words[i2] = 67108863 & ~this.words[i2]; - return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this.strip(); - }, o.prototype.notn = function(t4) { - return this.clone().inotn(t4); - }, o.prototype.setn = function(t4, e4) { - n(typeof t4 == "number" && t4 >= 0); - var r3 = t4 / 26 | 0, i2 = t4 % 26; - return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this.strip(); - }, o.prototype.iadd = function(t4) { - var e4, r3, n2; - if (this.negative !== 0 && t4.negative === 0) - return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); - if (this.negative === 0 && t4.negative !== 0) - return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); - this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) - e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - for (; i2 !== 0 && o2 < r3.length; o2++) - e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - if (this.length = r3.length, i2 !== 0) - this.words[this.length] = i2, this.length++; - else if (r3 !== this) - for (; o2 < r3.length; o2++) - this.words[o2] = r3.words[o2]; - return this; - }, o.prototype.add = function(t4) { - var e4; - return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); - }, o.prototype.isub = function(t4) { - if (t4.negative !== 0) { - t4.negative = 0; - var e4 = this.iadd(t4); - return t4.negative = 1, e4._normSign(); - } - if (this.negative !== 0) - return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); - var r3, n2, i2 = this.cmp(t4); - if (i2 === 0) - return this.negative = 0, this.length = 1, this.words[0] = 0, this; - i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - for (; o2 !== 0 && a2 < r3.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - if (o2 === 0 && a2 < r3.length && r3 !== this) - for (; a2 < r3.length; a2++) - this.words[a2] = r3.words[a2]; - return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this.strip(); - }, o.prototype.sub = function(t4) { - return this.clone().isub(t4); - }; - var p = function(t4, e4, r3) { - var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v2 = 0 | a2[3], w2 = 8191 & v2, _2 = v2 >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A = 0 | a2[5], k = 8191 & A, B = A >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; - r3.negative = t4.negative ^ e4.negative, r3.length = 19; - var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; - f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); - var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; - var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; - var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; - var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k, z), i2 = (i2 = Math.imul(k, q)) + Math.imul(B, z) | 0, o2 = Math.imul(B, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; - var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k, F) | 0, i2 = (i2 = i2 + Math.imul(k, V) | 0) + Math.imul(B, F) | 0, o2 = o2 + Math.imul(B, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; - var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k, J) | 0, i2 = (i2 = i2 + Math.imul(k, $) | 0) + Math.imul(B, J) | 0, o2 = o2 + Math.imul(B, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; - var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k, Z) | 0, i2 = (i2 = i2 + Math.imul(k, Y) | 0) + Math.imul(B, Z) | 0, o2 = o2 + Math.imul(B, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; - var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k, Q) | 0, i2 = (i2 = i2 + Math.imul(k, tt) | 0) + Math.imul(B, Q) | 0, o2 = o2 + Math.imul(B, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; - var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k, rt) | 0, i2 = (i2 = i2 + Math.imul(k, nt) | 0) + Math.imul(B, rt) | 0, o2 = o2 + Math.imul(B, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; - var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k, ot) | 0, i2 = (i2 = i2 + Math.imul(k, at) | 0) + Math.imul(B, ot) | 0, o2 = o2 + Math.imul(B, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; - var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k, ut) | 0, i2 = (i2 = i2 + Math.imul(k, ft) | 0) + Math.imul(B, ut) | 0, o2 = o2 + Math.imul(B, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; - var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k, ht) | 0, i2 = (i2 = i2 + Math.imul(k, lt) | 0) + Math.imul(B, ht) | 0, o2 = o2 + Math.imul(B, lt) | 0; - var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; - var Ot = (f2 + (n2 = n2 + Math.imul(k, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k, yt) | 0) + Math.imul(B, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(B, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; - var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; - var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); - var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; - var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; - return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; - }; - function y(t4, e4, r3) { - return new m().mulp(t4, e4, r3); - } - function m(t4, e4) { - this.x = t4, this.y = e4; - } - Math.imul || (p = d), o.prototype.mulTo = function(t4, e4) { - var r3 = this.length + t4.length; - return this.length === 10 && t4.length === 10 ? p(this, t4, e4) : r3 < 63 ? d(this, t4, e4) : r3 < 1024 ? function(t5, e5, r4) { - r4.negative = e5.negative ^ t5.negative, r4.length = t5.length + e5.length; - for (var n2 = 0, i2 = 0, o2 = 0; o2 < r4.length - 1; o2++) { - var a2 = i2; - i2 = 0; - for (var s2 = 67108863 & n2, u2 = Math.min(o2, e5.length - 1), f2 = Math.max(0, o2 - t5.length + 1); f2 <= u2; f2++) { - var c2 = o2 - f2, h2 = (0 | t5.words[c2]) * (0 | e5.words[f2]), l2 = 67108863 & h2; - s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; - } - r4.words[o2] = s2, n2 = a2, a2 = i2; - } - return n2 !== 0 ? r4.words[o2] = n2 : r4.length--, r4.strip(); - }(this, t4, e4) : y(this, t4, e4); - }, m.prototype.makeRBT = function(t4) { - for (var e4 = new Array(t4), r3 = o.prototype._countBits(t4) - 1, n2 = 0; n2 < t4; n2++) - e4[n2] = this.revBin(n2, r3, t4); - return e4; - }, m.prototype.revBin = function(t4, e4, r3) { - if (t4 === 0 || t4 === r3 - 1) - return t4; - for (var n2 = 0, i2 = 0; i2 < e4; i2++) - n2 |= (1 & t4) << e4 - i2 - 1, t4 >>= 1; - return n2; - }, m.prototype.permute = function(t4, e4, r3, n2, i2, o2) { - for (var a2 = 0; a2 < o2; a2++) - n2[a2] = e4[t4[a2]], i2[a2] = r3[t4[a2]]; - }, m.prototype.transform = function(t4, e4, r3, n2, i2, o2) { - this.permute(o2, t4, e4, r3, n2, i2); - for (var a2 = 1; a2 < i2; a2 <<= 1) - for (var s2 = a2 << 1, u2 = Math.cos(2 * Math.PI / s2), f2 = Math.sin(2 * Math.PI / s2), c2 = 0; c2 < i2; c2 += s2) - for (var h2 = u2, l2 = f2, d2 = 0; d2 < a2; d2++) { - var p2 = r3[c2 + d2], y2 = n2[c2 + d2], m2 = r3[c2 + d2 + a2], b2 = n2[c2 + d2 + a2], g2 = h2 * m2 - l2 * b2; - b2 = h2 * b2 + l2 * m2, m2 = g2, r3[c2 + d2] = p2 + m2, n2[c2 + d2] = y2 + b2, r3[c2 + d2 + a2] = p2 - m2, n2[c2 + d2 + a2] = y2 - b2, d2 !== s2 && (g2 = u2 * h2 - f2 * l2, l2 = u2 * l2 + f2 * h2, h2 = g2); - } - }, m.prototype.guessLen13b = function(t4, e4) { - var r3 = 1 | Math.max(e4, t4), n2 = 1 & r3, i2 = 0; - for (r3 = r3 / 2 | 0; r3; r3 >>>= 1) - i2++; - return 1 << i2 + 1 + n2; - }, m.prototype.conjugate = function(t4, e4, r3) { - if (!(r3 <= 1)) - for (var n2 = 0; n2 < r3 / 2; n2++) { - var i2 = t4[n2]; - t4[n2] = t4[r3 - n2 - 1], t4[r3 - n2 - 1] = i2, i2 = e4[n2], e4[n2] = -e4[r3 - n2 - 1], e4[r3 - n2 - 1] = -i2; - } - }, m.prototype.normalize13b = function(t4, e4) { - for (var r3 = 0, n2 = 0; n2 < e4 / 2; n2++) { - var i2 = 8192 * Math.round(t4[2 * n2 + 1] / e4) + Math.round(t4[2 * n2] / e4) + r3; - t4[n2] = 67108863 & i2, r3 = i2 < 67108864 ? 0 : i2 / 67108864 | 0; - } - return t4; - }, m.prototype.convert13b = function(t4, e4, r3, i2) { - for (var o2 = 0, a2 = 0; a2 < e4; a2++) - o2 += 0 | t4[a2], r3[2 * a2] = 8191 & o2, o2 >>>= 13, r3[2 * a2 + 1] = 8191 & o2, o2 >>>= 13; - for (a2 = 2 * e4; a2 < i2; ++a2) - r3[a2] = 0; - n(o2 === 0), n((-8192 & o2) == 0); - }, m.prototype.stub = function(t4) { - for (var e4 = new Array(t4), r3 = 0; r3 < t4; r3++) - e4[r3] = 0; - return e4; - }, m.prototype.mulp = function(t4, e4, r3) { - var n2 = 2 * this.guessLen13b(t4.length, e4.length), i2 = this.makeRBT(n2), o2 = this.stub(n2), a2 = new Array(n2), s2 = new Array(n2), u2 = new Array(n2), f2 = new Array(n2), c2 = new Array(n2), h2 = new Array(n2), l2 = r3.words; - l2.length = n2, this.convert13b(t4.words, t4.length, a2, n2), this.convert13b(e4.words, e4.length, f2, n2), this.transform(a2, o2, s2, u2, n2, i2), this.transform(f2, o2, c2, h2, n2, i2); - for (var d2 = 0; d2 < n2; d2++) { - var p2 = s2[d2] * c2[d2] - u2[d2] * h2[d2]; - u2[d2] = s2[d2] * h2[d2] + u2[d2] * c2[d2], s2[d2] = p2; - } - return this.conjugate(s2, u2, n2), this.transform(s2, u2, l2, o2, n2, i2), this.conjugate(l2, o2, n2), this.normalize13b(l2, n2), r3.negative = t4.negative ^ e4.negative, r3.length = t4.length + e4.length, r3.strip(); - }, o.prototype.mul = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); - }, o.prototype.mulf = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), y(this, t4, e4); - }, o.prototype.imul = function(t4) { - return this.clone().mulTo(t4, this); - }, o.prototype.imuln = function(t4) { - n(typeof t4 == "number"), n(t4 < 67108864); - for (var e4 = 0, r3 = 0; r3 < this.length; r3++) { - var i2 = (0 | this.words[r3]) * t4, o2 = (67108863 & i2) + (67108863 & e4); - e4 >>= 26, e4 += i2 / 67108864 | 0, e4 += o2 >>> 26, this.words[r3] = 67108863 & o2; - } - return e4 !== 0 && (this.words[r3] = e4, this.length++), this; - }, o.prototype.muln = function(t4) { - return this.clone().imuln(t4); - }, o.prototype.sqr = function() { - return this.mul(this); - }, o.prototype.isqr = function() { - return this.imul(this.clone()); - }, o.prototype.pow = function(t4) { - var e4 = function(t5) { - for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { - var n3 = r4 / 26 | 0, i3 = r4 % 26; - e5[r4] = (t5.words[n3] & 1 << i3) >>> i3; - } - return e5; - }(t4); - if (e4.length === 0) - return new o(1); - for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) - ; - if (++n2 < e4.length) - for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) - e4[n2] !== 0 && (r3 = r3.mul(i2)); - return r3; - }, o.prototype.iushln = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; - if (r3 !== 0) { - var a2 = 0; - for (e4 = 0; e4 < this.length; e4++) { - var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; - this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; - } - a2 && (this.words[e4] = a2, this.length++); - } - if (i2 !== 0) { - for (e4 = this.length - 1; e4 >= 0; e4--) - this.words[e4 + i2] = this.words[e4]; - for (e4 = 0; e4 < i2; e4++) - this.words[e4] = 0; - this.length += i2; - } - return this.strip(); - }, o.prototype.ishln = function(t4) { - return n(this.negative === 0), this.iushln(t4); - }, o.prototype.iushrn = function(t4, e4, r3) { - var i2; - n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; - var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; - if (i2 -= a2, i2 = Math.max(0, i2), u2) { - for (var f2 = 0; f2 < a2; f2++) - u2.words[f2] = this.words[f2]; - u2.length = a2; - } - if (a2 === 0) - ; - else if (this.length > a2) - for (this.length -= a2, f2 = 0; f2 < this.length; f2++) - this.words[f2] = this.words[f2 + a2]; - else - this.words[0] = 0, this.length = 1; - var c2 = 0; - for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { - var h2 = 0 | this.words[f2]; - this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; - } - return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this.strip(); - }, o.prototype.ishrn = function(t4, e4, r3) { - return n(this.negative === 0), this.iushrn(t4, e4, r3); - }, o.prototype.shln = function(t4) { - return this.clone().ishln(t4); - }, o.prototype.ushln = function(t4) { - return this.clone().iushln(t4); - }, o.prototype.shrn = function(t4) { - return this.clone().ishrn(t4); - }, o.prototype.ushrn = function(t4) { - return this.clone().iushrn(t4); - }, o.prototype.testn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - return !(this.length <= r3 || !(this.words[r3] & i2)); - }, o.prototype.imaskn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26; - if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) - return this; - if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { - var i2 = 67108863 ^ 67108863 >>> e4 << e4; - this.words[this.length - 1] &= i2; - } - return this.strip(); - }, o.prototype.maskn = function(t4) { - return this.clone().imaskn(t4); - }, o.prototype.iaddn = function(t4) { - return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) < t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); - }, o.prototype._iaddn = function(t4) { - this.words[0] += t4; - for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) - this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; - return this.length = Math.max(this.length, e4 + 1), this; - }, o.prototype.isubn = function(t4) { - if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) - return this.iaddn(-t4); - if (this.negative !== 0) - return this.negative = 0, this.iaddn(t4), this.negative = 1, this; - if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) - this.words[0] = -this.words[0], this.negative = 1; - else - for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) - this.words[e4] += 67108864, this.words[e4 + 1] -= 1; - return this.strip(); - }, o.prototype.addn = function(t4) { - return this.clone().iaddn(t4); - }, o.prototype.subn = function(t4) { - return this.clone().isubn(t4); - }, o.prototype.iabs = function() { - return this.negative = 0, this; - }, o.prototype.abs = function() { - return this.clone().iabs(); - }, o.prototype._ishlnsubmul = function(t4, e4, r3) { - var i2, o2, a2 = t4.length + r3; - this._expand(a2); - var s2 = 0; - for (i2 = 0; i2 < t4.length; i2++) { - o2 = (0 | this.words[i2 + r3]) + s2; - var u2 = (0 | t4.words[i2]) * e4; - s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; - } - for (; i2 < this.length - r3; i2++) - s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; - if (s2 === 0) - return this.strip(); - for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) - s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; - return this.negative = 1, this.strip(); - }, o.prototype._wordDiv = function(t4, e4) { - var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; - (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); - var s2, u2 = n2.length - i2.length; - if (e4 !== "mod") { - (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); - for (var f2 = 0; f2 < s2.length; f2++) - s2.words[f2] = 0; - } - var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); - c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); - for (var h2 = u2 - 1; h2 >= 0; h2--) { - var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); - for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) - l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); - s2 && (s2.words[h2] = l2); - } - return s2 && s2.strip(), n2.strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; - }, o.prototype.divmod = function(t4, e4, r3) { - return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modn(t4.words[0]))} : this._wordDiv(t4, e4); - var i2, a2, s2; - }, o.prototype.div = function(t4) { - return this.divmod(t4, "div", false).div; - }, o.prototype.mod = function(t4) { - return this.divmod(t4, "mod", false).mod; - }, o.prototype.umod = function(t4) { - return this.divmod(t4, "mod", true).mod; - }, o.prototype.divRound = function(t4) { - var e4 = this.divmod(t4); - if (e4.mod.isZero()) - return e4.div; - var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); - return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); - }, o.prototype.modn = function(t4) { - n(t4 <= 67108863); - for (var e4 = (1 << 26) % t4, r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) - r3 = (e4 * r3 + (0 | this.words[i2])) % t4; - return r3; - }, o.prototype.idivn = function(t4) { - n(t4 <= 67108863); - for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { - var i2 = (0 | this.words[r3]) + 67108864 * e4; - this.words[r3] = i2 / t4 | 0, e4 = i2 % t4; - } - return this.strip(); - }, o.prototype.divn = function(t4) { - return this.clone().idivn(t4); - }, o.prototype.egcd = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) - e4.iushrn(1), r3.iushrn(1), ++f2; - for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { - for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) - ; - if (l2 > 0) - for (e4.iushrn(l2); l2-- > 0; ) - (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); - for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) - ; - if (p2 > 0) - for (r3.iushrn(p2); p2-- > 0; ) - (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); - } - return {a: s2, b: u2, gcd: r3.iushln(f2)}; - }, o.prototype._invmp = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { - for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) - ; - if (f2 > 0) - for (e4.iushrn(f2); f2-- > 0; ) - a2.isOdd() && a2.iadd(u2), a2.iushrn(1); - for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) - ; - if (h2 > 0) - for (r3.iushrn(h2); h2-- > 0; ) - s2.isOdd() && s2.iadd(u2), s2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); - } - return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; - }, o.prototype.gcd = function(t4) { - if (this.isZero()) - return t4.abs(); - if (t4.isZero()) - return this.abs(); - var e4 = this.clone(), r3 = t4.clone(); - e4.negative = 0, r3.negative = 0; - for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) - e4.iushrn(1), r3.iushrn(1); - for (; ; ) { - for (; e4.isEven(); ) - e4.iushrn(1); - for (; r3.isEven(); ) - r3.iushrn(1); - var i2 = e4.cmp(r3); - if (i2 < 0) { - var o2 = e4; - e4 = r3, r3 = o2; - } else if (i2 === 0 || r3.cmpn(1) === 0) - break; - e4.isub(r3); - } - return r3.iushln(n2); - }, o.prototype.invm = function(t4) { - return this.egcd(t4).a.umod(t4); - }, o.prototype.isEven = function() { - return (1 & this.words[0]) == 0; - }, o.prototype.isOdd = function() { - return (1 & this.words[0]) == 1; - }, o.prototype.andln = function(t4) { - return this.words[0] & t4; - }, o.prototype.bincn = function(t4) { - n(typeof t4 == "number"); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - if (this.length <= r3) - return this._expand(r3 + 1), this.words[r3] |= i2, this; - for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { - var s2 = 0 | this.words[a2]; - o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; - } - return o2 !== 0 && (this.words[a2] = o2, this.length++), this; - }, o.prototype.isZero = function() { - return this.length === 1 && this.words[0] === 0; - }, o.prototype.cmpn = function(t4) { - var e4, r3 = t4 < 0; - if (this.negative !== 0 && !r3) - return -1; - if (this.negative === 0 && r3) - return 1; - if (this.strip(), this.length > 1) - e4 = 1; - else { - r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); - var i2 = 0 | this.words[0]; - e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; - } - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.cmp = function(t4) { - if (this.negative !== 0 && t4.negative === 0) - return -1; - if (this.negative === 0 && t4.negative !== 0) - return 1; - var e4 = this.ucmp(t4); - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.ucmp = function(t4) { - if (this.length > t4.length) - return 1; - if (this.length < t4.length) - return -1; - for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { - var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; - if (n2 !== i2) { - n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); - break; - } - } - return e4; - }, o.prototype.gtn = function(t4) { - return this.cmpn(t4) === 1; - }, o.prototype.gt = function(t4) { - return this.cmp(t4) === 1; - }, o.prototype.gten = function(t4) { - return this.cmpn(t4) >= 0; - }, o.prototype.gte = function(t4) { - return this.cmp(t4) >= 0; - }, o.prototype.ltn = function(t4) { - return this.cmpn(t4) === -1; - }, o.prototype.lt = function(t4) { - return this.cmp(t4) === -1; - }, o.prototype.lten = function(t4) { - return this.cmpn(t4) <= 0; - }, o.prototype.lte = function(t4) { - return this.cmp(t4) <= 0; - }, o.prototype.eqn = function(t4) { - return this.cmpn(t4) === 0; - }, o.prototype.eq = function(t4) { - return this.cmp(t4) === 0; - }, o.red = function(t4) { - return new S(t4); - }, o.prototype.toRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); - }, o.prototype.fromRed = function() { - return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }, o.prototype._forceRed = function(t4) { - return this.red = t4, this; - }, o.prototype.forceRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); - }, o.prototype.redAdd = function(t4) { - return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); - }, o.prototype.redIAdd = function(t4) { - return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); - }, o.prototype.redSub = function(t4) { - return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); - }, o.prototype.redISub = function(t4) { - return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); - }, o.prototype.redShl = function(t4) { - return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); - }, o.prototype.redMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); - }, o.prototype.redIMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); - }, o.prototype.redSqr = function() { - return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }, o.prototype.redISqr = function() { - return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }, o.prototype.redSqrt = function() { - return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }, o.prototype.redInvm = function() { - return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }, o.prototype.redNeg = function() { - return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }, o.prototype.redPow = function(t4) { - return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); - }; - var b = {k256: null, p224: null, p192: null, p25519: null}; - function g(t4, e4) { - this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); - } - function v() { - g.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - function w() { - g.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - function _() { - g.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - function M() { - g.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - function S(t4) { - if (typeof t4 == "string") { - var e4 = o._prime(t4); - this.m = e4.p, this.prime = e4; - } else - n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; - } - function E(t4) { - S.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); - } - g.prototype._tmp = function() { - var t4 = new o(null); - return t4.words = new Array(Math.ceil(this.n / 13)), t4; - }, g.prototype.ireduce = function(t4) { - var e4, r3 = t4; - do { - this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); - } while (e4 > this.n); - var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); - return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; - }, g.prototype.split = function(t4, e4) { - t4.iushrn(this.n, 0, e4); - }, g.prototype.imulK = function(t4) { - return t4.imul(this.k); - }, i(v, g), v.prototype.split = function(t4, e4) { - for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) - e4.words[i2] = t4.words[i2]; - if (e4.length = n2, t4.length <= 9) - return t4.words[0] = 0, void (t4.length = 1); - var o2 = t4.words[9]; - for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { - var a2 = 0 | t4.words[i2]; - t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; - } - o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; - }, v.prototype.imulK = function(t4) { - t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 0 | t4.words[r3]; - e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); - } - return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; - }, i(w, g), i(_, g), i(M, g), M.prototype.imulK = function(t4) { - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; - n2 >>>= 26, t4.words[r3] = i2, e4 = n2; - } - return e4 !== 0 && (t4.words[t4.length++] = e4), t4; - }, o._prime = function(t4) { - if (b[t4]) - return b[t4]; - var e4; - if (t4 === "k256") - e4 = new v(); - else if (t4 === "p224") - e4 = new w(); - else if (t4 === "p192") - e4 = new _(); - else { - if (t4 !== "p25519") - throw new Error("Unknown prime " + t4); - e4 = new M(); - } - return b[t4] = e4, e4; - }, S.prototype._verify1 = function(t4) { - n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); - }, S.prototype._verify2 = function(t4, e4) { - n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); - }, S.prototype.imod = function(t4) { - return this.prime ? this.prime.ireduce(t4)._forceRed(this) : t4.umod(this.m)._forceRed(this); - }, S.prototype.neg = function(t4) { - return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); - }, S.prototype.add = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.add(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); - }, S.prototype.iadd = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.iadd(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; - }, S.prototype.sub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.sub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); - }, S.prototype.isub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.isub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; - }, S.prototype.shl = function(t4, e4) { - return this._verify1(t4), this.imod(t4.ushln(e4)); - }, S.prototype.imul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.imul(e4)); - }, S.prototype.mul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.mul(e4)); - }, S.prototype.isqr = function(t4) { - return this.imul(t4, t4.clone()); - }, S.prototype.sqr = function(t4) { - return this.mul(t4, t4); - }, S.prototype.sqrt = function(t4) { - if (t4.isZero()) - return t4.clone(); - var e4 = this.m.andln(3); - if (n(e4 % 2 == 1), e4 === 3) { - var r3 = this.m.add(new o(1)).iushrn(2); - return this.pow(t4, r3); - } - for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) - a2++, i2.iushrn(1); - n(!i2.isZero()); - var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); - for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) - c2.redIAdd(u2); - for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { - for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) - y2 = y2.redSqr(); - n(m2 < p2); - var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); - l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; - } - return l2; - }, S.prototype.invm = function(t4) { - var e4 = t4._invmp(this.m); - return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); - }, S.prototype.pow = function(t4, e4) { - if (e4.isZero()) - return new o(1).toRed(this); - if (e4.cmpn(1) === 0) - return t4.clone(); - var r3 = new Array(16); - r3[0] = new o(1).toRed(this), r3[1] = t4; - for (var n2 = 2; n2 < r3.length; n2++) - r3[n2] = this.mul(r3[n2 - 1], t4); - var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; - for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { - for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { - var h2 = f2 >> c2 & 1; - i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; - } - u2 = 26; - } - return i2; - }, S.prototype.convertTo = function(t4) { - var e4 = t4.umod(this.m); - return e4 === t4 ? e4.clone() : e4; - }, S.prototype.convertFrom = function(t4) { - var e4 = t4.clone(); - return e4.red = null, e4; - }, o.mont = function(t4) { - return new E(t4); - }, i(E, S), E.prototype.convertTo = function(t4) { - return this.imod(t4.ushln(this.shift)); - }, E.prototype.convertFrom = function(t4) { - var e4 = this.imod(t4.mul(this.rinv)); - return e4.red = null, e4; - }, E.prototype.imul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return t4.words[0] = 0, t4.length = 1, t4; - var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; - return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); - }, E.prototype.mul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return new o(0)._forceRed(this); - var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; - return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); - }, E.prototype.invm = function(t4) { - return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); - }; - }(t2 = r2.nmd(t2), this); - }, 7376: (t2, e2, r2) => { - var n; - function i(t3) { - this.rand = t3; - } - if (t2.exports = function(t3) { - return n || (n = new i(null)), n.generate(t3); - }, t2.exports.Rand = i, i.prototype.generate = function(t3) { - return this._rand(t3); - }, i.prototype._rand = function(t3) { - if (this.rand.getBytes) - return this.rand.getBytes(t3); - for (var e3 = new Uint8Array(t3), r3 = 0; r3 < e3.length; r3++) - e3[r3] = this.rand.getByte(); - return e3; - }, typeof self == "object") - self.crypto && self.crypto.getRandomValues ? i.prototype._rand = function(t3) { - var e3 = new Uint8Array(t3); - return self.crypto.getRandomValues(e3), e3; - } : self.msCrypto && self.msCrypto.getRandomValues ? i.prototype._rand = function(t3) { - var e3 = new Uint8Array(t3); - return self.msCrypto.getRandomValues(e3), e3; - } : typeof window == "object" && (i.prototype._rand = function() { - throw new Error("Not implemented yet"); - }); - else - try { - var o = r2(9214); - if (typeof o.randomBytes != "function") - throw new Error("Not supported"); - i.prototype._rand = function(t3) { - return o.randomBytes(t3); - }; - } catch (t3) { - } - }, 4497: (t2, e2, r2) => { - var n = r2(9509).Buffer; - function i(t3) { - n.isBuffer(t3) || (t3 = n.from(t3)); - for (var e3 = t3.length / 4 | 0, r3 = new Array(e3), i2 = 0; i2 < e3; i2++) - r3[i2] = t3.readUInt32BE(4 * i2); - return r3; - } - function o(t3) { - for (; 0 < t3.length; t3++) - t3[0] = 0; - } - function a(t3, e3, r3, n2, i2) { - for (var o2, a2, s2, u2, f2 = r3[0], c = r3[1], h = r3[2], l = r3[3], d = t3[0] ^ e3[0], p = t3[1] ^ e3[1], y = t3[2] ^ e3[2], m = t3[3] ^ e3[3], b = 4, g = 1; g < i2; g++) - o2 = f2[d >>> 24] ^ c[p >>> 16 & 255] ^ h[y >>> 8 & 255] ^ l[255 & m] ^ e3[b++], a2 = f2[p >>> 24] ^ c[y >>> 16 & 255] ^ h[m >>> 8 & 255] ^ l[255 & d] ^ e3[b++], s2 = f2[y >>> 24] ^ c[m >>> 16 & 255] ^ h[d >>> 8 & 255] ^ l[255 & p] ^ e3[b++], u2 = f2[m >>> 24] ^ c[d >>> 16 & 255] ^ h[p >>> 8 & 255] ^ l[255 & y] ^ e3[b++], d = o2, p = a2, y = s2, m = u2; - return o2 = (n2[d >>> 24] << 24 | n2[p >>> 16 & 255] << 16 | n2[y >>> 8 & 255] << 8 | n2[255 & m]) ^ e3[b++], a2 = (n2[p >>> 24] << 24 | n2[y >>> 16 & 255] << 16 | n2[m >>> 8 & 255] << 8 | n2[255 & d]) ^ e3[b++], s2 = (n2[y >>> 24] << 24 | n2[m >>> 16 & 255] << 16 | n2[d >>> 8 & 255] << 8 | n2[255 & p]) ^ e3[b++], u2 = (n2[m >>> 24] << 24 | n2[d >>> 16 & 255] << 16 | n2[p >>> 8 & 255] << 8 | n2[255 & y]) ^ e3[b++], [o2 >>>= 0, a2 >>>= 0, s2 >>>= 0, u2 >>>= 0]; - } - var s = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], u = function() { - for (var t3 = new Array(256), e3 = 0; e3 < 256; e3++) - t3[e3] = e3 < 128 ? e3 << 1 : e3 << 1 ^ 283; - for (var r3 = [], n2 = [], i2 = [[], [], [], []], o2 = [[], [], [], []], a2 = 0, s2 = 0, u2 = 0; u2 < 256; ++u2) { - var f2 = s2 ^ s2 << 1 ^ s2 << 2 ^ s2 << 3 ^ s2 << 4; - f2 = f2 >>> 8 ^ 255 & f2 ^ 99, r3[a2] = f2, n2[f2] = a2; - var c = t3[a2], h = t3[c], l = t3[h], d = 257 * t3[f2] ^ 16843008 * f2; - i2[0][a2] = d << 24 | d >>> 8, i2[1][a2] = d << 16 | d >>> 16, i2[2][a2] = d << 8 | d >>> 24, i2[3][a2] = d, d = 16843009 * l ^ 65537 * h ^ 257 * c ^ 16843008 * a2, o2[0][f2] = d << 24 | d >>> 8, o2[1][f2] = d << 16 | d >>> 16, o2[2][f2] = d << 8 | d >>> 24, o2[3][f2] = d, a2 === 0 ? a2 = s2 = 1 : (a2 = c ^ t3[t3[t3[l ^ c]]], s2 ^= t3[t3[s2]]); - } - return {SBOX: r3, INV_SBOX: n2, SUB_MIX: i2, INV_SUB_MIX: o2}; - }(); - function f(t3) { - this._key = i(t3), this._reset(); - } - f.blockSize = 16, f.keySize = 32, f.prototype.blockSize = f.blockSize, f.prototype.keySize = f.keySize, f.prototype._reset = function() { - for (var t3 = this._key, e3 = t3.length, r3 = e3 + 6, n2 = 4 * (r3 + 1), i2 = [], o2 = 0; o2 < e3; o2++) - i2[o2] = t3[o2]; - for (o2 = e3; o2 < n2; o2++) { - var a2 = i2[o2 - 1]; - o2 % e3 == 0 ? (a2 = a2 << 8 | a2 >>> 24, a2 = u.SBOX[a2 >>> 24] << 24 | u.SBOX[a2 >>> 16 & 255] << 16 | u.SBOX[a2 >>> 8 & 255] << 8 | u.SBOX[255 & a2], a2 ^= s[o2 / e3 | 0] << 24) : e3 > 6 && o2 % e3 == 4 && (a2 = u.SBOX[a2 >>> 24] << 24 | u.SBOX[a2 >>> 16 & 255] << 16 | u.SBOX[a2 >>> 8 & 255] << 8 | u.SBOX[255 & a2]), i2[o2] = i2[o2 - e3] ^ a2; - } - for (var f2 = [], c = 0; c < n2; c++) { - var h = n2 - c, l = i2[h - (c % 4 ? 0 : 4)]; - f2[c] = c < 4 || h <= 4 ? l : u.INV_SUB_MIX[0][u.SBOX[l >>> 24]] ^ u.INV_SUB_MIX[1][u.SBOX[l >>> 16 & 255]] ^ u.INV_SUB_MIX[2][u.SBOX[l >>> 8 & 255]] ^ u.INV_SUB_MIX[3][u.SBOX[255 & l]]; - } - this._nRounds = r3, this._keySchedule = i2, this._invKeySchedule = f2; - }, f.prototype.encryptBlockRaw = function(t3) { - return a(t3 = i(t3), this._keySchedule, u.SUB_MIX, u.SBOX, this._nRounds); - }, f.prototype.encryptBlock = function(t3) { - var e3 = this.encryptBlockRaw(t3), r3 = n.allocUnsafe(16); - return r3.writeUInt32BE(e3[0], 0), r3.writeUInt32BE(e3[1], 4), r3.writeUInt32BE(e3[2], 8), r3.writeUInt32BE(e3[3], 12), r3; - }, f.prototype.decryptBlock = function(t3) { - var e3 = (t3 = i(t3))[1]; - t3[1] = t3[3], t3[3] = e3; - var r3 = a(t3, this._invKeySchedule, u.INV_SUB_MIX, u.INV_SBOX, this._nRounds), o2 = n.allocUnsafe(16); - return o2.writeUInt32BE(r3[0], 0), o2.writeUInt32BE(r3[3], 4), o2.writeUInt32BE(r3[2], 8), o2.writeUInt32BE(r3[1], 12), o2; - }, f.prototype.scrub = function() { - o(this._keySchedule), o(this._invKeySchedule), o(this._key); - }, t2.exports.AES = f; - }, 2422: (t2, e2, r2) => { - var n = r2(4497), i = r2(9509).Buffer, o = r2(1027), a = r2(5717), s = r2(3288), u = r2(7295), f = r2(685); - function c(t3, e3, r3, a2) { - o.call(this); - var u2 = i.alloc(4, 0); - this._cipher = new n.AES(e3); - var c2 = this._cipher.encryptBlock(u2); - this._ghash = new s(c2), r3 = function(t4, e4, r4) { - if (e4.length === 12) - return t4._finID = i.concat([e4, i.from([0, 0, 0, 1])]), i.concat([e4, i.from([0, 0, 0, 2])]); - var n2 = new s(r4), o2 = e4.length, a3 = o2 % 16; - n2.update(e4), a3 && (a3 = 16 - a3, n2.update(i.alloc(a3, 0))), n2.update(i.alloc(8, 0)); - var u3 = 8 * o2, c3 = i.alloc(8); - c3.writeUIntBE(u3, 0, 8), n2.update(c3), t4._finID = n2.state; - var h = i.from(t4._finID); - return f(h), h; - }(this, r3, c2), this._prev = i.from(r3), this._cache = i.allocUnsafe(0), this._secCache = i.allocUnsafe(0), this._decrypt = a2, this._alen = 0, this._len = 0, this._mode = t3, this._authTag = null, this._called = false; - } - a(c, o), c.prototype._update = function(t3) { - if (!this._called && this._alen) { - var e3 = 16 - this._alen % 16; - e3 < 16 && (e3 = i.alloc(e3, 0), this._ghash.update(e3)); - } - this._called = true; - var r3 = this._mode.encrypt(this, t3); - return this._decrypt ? this._ghash.update(t3) : this._ghash.update(r3), this._len += t3.length, r3; - }, c.prototype._final = function() { - if (this._decrypt && !this._authTag) - throw new Error("Unsupported state or unable to authenticate data"); - var t3 = u(this._ghash.final(8 * this._alen, 8 * this._len), this._cipher.encryptBlock(this._finID)); - if (this._decrypt && function(t4, e3) { - var r3 = 0; - t4.length !== e3.length && r3++; - for (var n2 = Math.min(t4.length, e3.length), i2 = 0; i2 < n2; ++i2) - r3 += t4[i2] ^ e3[i2]; - return r3; - }(t3, this._authTag)) - throw new Error("Unsupported state or unable to authenticate data"); - this._authTag = t3, this._cipher.scrub(); - }, c.prototype.getAuthTag = function() { - if (this._decrypt || !i.isBuffer(this._authTag)) - throw new Error("Attempting to get auth tag in unsupported state"); - return this._authTag; - }, c.prototype.setAuthTag = function(t3) { - if (!this._decrypt) - throw new Error("Attempting to set auth tag in unsupported state"); - this._authTag = t3; - }, c.prototype.setAAD = function(t3) { - if (this._called) - throw new Error("Attempting to set AAD in unsupported state"); - this._ghash.update(t3), this._alen += t3.length; - }, t2.exports = c; - }, 4696: (t2, e2, r2) => { - var n = r2(1494), i = r2(6193), o = r2(5415); - e2.createCipher = e2.Cipher = n.createCipher, e2.createCipheriv = e2.Cipheriv = n.createCipheriv, e2.createDecipher = e2.Decipher = i.createDecipher, e2.createDecipheriv = e2.Decipheriv = i.createDecipheriv, e2.listCiphers = e2.getCiphers = function() { - return Object.keys(o); - }; - }, 6193: (t2, e2, r2) => { - var n = r2(2422), i = r2(9509).Buffer, o = r2(45), a = r2(5969), s = r2(1027), u = r2(4497), f = r2(3048); - function c(t3, e3, r3) { - s.call(this), this._cache = new h(), this._last = void 0, this._cipher = new u.AES(e3), this._prev = i.from(r3), this._mode = t3, this._autopadding = true; - } - function h() { - this.cache = i.allocUnsafe(0); - } - function l(t3, e3, r3) { - var s2 = o[t3.toLowerCase()]; - if (!s2) - throw new TypeError("invalid suite type"); - if (typeof r3 == "string" && (r3 = i.from(r3)), s2.mode !== "GCM" && r3.length !== s2.iv) - throw new TypeError("invalid iv length " + r3.length); - if (typeof e3 == "string" && (e3 = i.from(e3)), e3.length !== s2.key / 8) - throw new TypeError("invalid key length " + e3.length); - return s2.type === "stream" ? new a(s2.module, e3, r3, true) : s2.type === "auth" ? new n(s2.module, e3, r3, true) : new c(s2.module, e3, r3); - } - r2(5717)(c, s), c.prototype._update = function(t3) { - var e3, r3; - this._cache.add(t3); - for (var n2 = []; e3 = this._cache.get(this._autopadding); ) - r3 = this._mode.decrypt(this, e3), n2.push(r3); - return i.concat(n2); - }, c.prototype._final = function() { - var t3 = this._cache.flush(); - if (this._autopadding) - return function(t4) { - var e3 = t4[15]; - if (e3 < 1 || e3 > 16) - throw new Error("unable to decrypt data"); - for (var r3 = -1; ++r3 < e3; ) - if (t4[r3 + (16 - e3)] !== e3) - throw new Error("unable to decrypt data"); - if (e3 !== 16) - return t4.slice(0, 16 - e3); - }(this._mode.decrypt(this, t3)); - if (t3) - throw new Error("data not multiple of block length"); - }, c.prototype.setAutoPadding = function(t3) { - return this._autopadding = !!t3, this; - }, h.prototype.add = function(t3) { - this.cache = i.concat([this.cache, t3]); - }, h.prototype.get = function(t3) { - var e3; - if (t3) { - if (this.cache.length > 16) - return e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), e3; - } else if (this.cache.length >= 16) - return e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), e3; - return null; - }, h.prototype.flush = function() { - if (this.cache.length) - return this.cache; - }, e2.createDecipher = function(t3, e3) { - var r3 = o[t3.toLowerCase()]; - if (!r3) - throw new TypeError("invalid suite type"); - var n2 = f(e3, false, r3.key, r3.iv); - return l(t3, n2.key, n2.iv); - }, e2.createDecipheriv = l; - }, 1494: (t2, e2, r2) => { - var n = r2(45), i = r2(2422), o = r2(9509).Buffer, a = r2(5969), s = r2(1027), u = r2(4497), f = r2(3048); - function c(t3, e3, r3) { - s.call(this), this._cache = new l(), this._cipher = new u.AES(e3), this._prev = o.from(r3), this._mode = t3, this._autopadding = true; - } - r2(5717)(c, s), c.prototype._update = function(t3) { - var e3, r3; - this._cache.add(t3); - for (var n2 = []; e3 = this._cache.get(); ) - r3 = this._mode.encrypt(this, e3), n2.push(r3); - return o.concat(n2); - }; - var h = o.alloc(16, 16); - function l() { - this.cache = o.allocUnsafe(0); - } - function d(t3, e3, r3) { - var s2 = n[t3.toLowerCase()]; - if (!s2) - throw new TypeError("invalid suite type"); - if (typeof e3 == "string" && (e3 = o.from(e3)), e3.length !== s2.key / 8) - throw new TypeError("invalid key length " + e3.length); - if (typeof r3 == "string" && (r3 = o.from(r3)), s2.mode !== "GCM" && r3.length !== s2.iv) - throw new TypeError("invalid iv length " + r3.length); - return s2.type === "stream" ? new a(s2.module, e3, r3) : s2.type === "auth" ? new i(s2.module, e3, r3) : new c(s2.module, e3, r3); - } - c.prototype._final = function() { - var t3 = this._cache.flush(); - if (this._autopadding) - return t3 = this._mode.encrypt(this, t3), this._cipher.scrub(), t3; - if (!t3.equals(h)) - throw this._cipher.scrub(), new Error("data not multiple of block length"); - }, c.prototype.setAutoPadding = function(t3) { - return this._autopadding = !!t3, this; - }, l.prototype.add = function(t3) { - this.cache = o.concat([this.cache, t3]); - }, l.prototype.get = function() { - if (this.cache.length > 15) { - var t3 = this.cache.slice(0, 16); - return this.cache = this.cache.slice(16), t3; - } - return null; - }, l.prototype.flush = function() { - for (var t3 = 16 - this.cache.length, e3 = o.allocUnsafe(t3), r3 = -1; ++r3 < t3; ) - e3.writeUInt8(t3, r3); - return o.concat([this.cache, e3]); - }, e2.createCipheriv = d, e2.createCipher = function(t3, e3) { - var r3 = n[t3.toLowerCase()]; - if (!r3) - throw new TypeError("invalid suite type"); - var i2 = f(e3, false, r3.key, r3.iv); - return d(t3, i2.key, i2.iv); - }; - }, 3288: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = n.alloc(16, 0); - function o(t3) { - var e3 = n.allocUnsafe(16); - return e3.writeUInt32BE(t3[0] >>> 0, 0), e3.writeUInt32BE(t3[1] >>> 0, 4), e3.writeUInt32BE(t3[2] >>> 0, 8), e3.writeUInt32BE(t3[3] >>> 0, 12), e3; - } - function a(t3) { - this.h = t3, this.state = n.alloc(16, 0), this.cache = n.allocUnsafe(0); - } - a.prototype.ghash = function(t3) { - for (var e3 = -1; ++e3 < t3.length; ) - this.state[e3] ^= t3[e3]; - this._multiply(); - }, a.prototype._multiply = function() { - for (var t3, e3, r3, n2 = [(t3 = this.h).readUInt32BE(0), t3.readUInt32BE(4), t3.readUInt32BE(8), t3.readUInt32BE(12)], i2 = [0, 0, 0, 0], a2 = -1; ++a2 < 128; ) { - for ((this.state[~~(a2 / 8)] & 1 << 7 - a2 % 8) != 0 && (i2[0] ^= n2[0], i2[1] ^= n2[1], i2[2] ^= n2[2], i2[3] ^= n2[3]), r3 = (1 & n2[3]) != 0, e3 = 3; e3 > 0; e3--) - n2[e3] = n2[e3] >>> 1 | (1 & n2[e3 - 1]) << 31; - n2[0] = n2[0] >>> 1, r3 && (n2[0] = n2[0] ^ 225 << 24); - } - this.state = o(i2); - }, a.prototype.update = function(t3) { - var e3; - for (this.cache = n.concat([this.cache, t3]); this.cache.length >= 16; ) - e3 = this.cache.slice(0, 16), this.cache = this.cache.slice(16), this.ghash(e3); - }, a.prototype.final = function(t3, e3) { - return this.cache.length && this.ghash(n.concat([this.cache, i], 16)), this.ghash(o([0, t3, 0, e3])), this.state; - }, t2.exports = a; - }, 685: (t2) => { - t2.exports = function(t3) { - for (var e2, r2 = t3.length; r2--; ) { - if ((e2 = t3.readUInt8(r2)) !== 255) { - e2++, t3.writeUInt8(e2, r2); - break; - } - t3.writeUInt8(0, r2); - } - }; - }, 5292: (t2, e2, r2) => { - var n = r2(7295); - e2.encrypt = function(t3, e3) { - var r3 = n(e3, t3._prev); - return t3._prev = t3._cipher.encryptBlock(r3), t3._prev; - }, e2.decrypt = function(t3, e3) { - var r3 = t3._prev; - t3._prev = e3; - var i = t3._cipher.decryptBlock(e3); - return n(i, r3); - }; - }, 6311: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(7295); - function o(t3, e3, r3) { - var o2 = e3.length, a = i(e3, t3._cache); - return t3._cache = t3._cache.slice(o2), t3._prev = n.concat([t3._prev, r3 ? e3 : a]), a; - } - e2.encrypt = function(t3, e3, r3) { - for (var i2, a = n.allocUnsafe(0); e3.length; ) { - if (t3._cache.length === 0 && (t3._cache = t3._cipher.encryptBlock(t3._prev), t3._prev = n.allocUnsafe(0)), !(t3._cache.length <= e3.length)) { - a = n.concat([a, o(t3, e3, r3)]); - break; - } - i2 = t3._cache.length, a = n.concat([a, o(t3, e3.slice(0, i2), r3)]), e3 = e3.slice(i2); - } - return a; - }; - }, 1510: (t2, e2, r2) => { - var n = r2(9509).Buffer; - function i(t3, e3, r3) { - for (var n2, i2, a = -1, s = 0; ++a < 8; ) - n2 = e3 & 1 << 7 - a ? 128 : 0, s += (128 & (i2 = t3._cipher.encryptBlock(t3._prev)[0] ^ n2)) >> a % 8, t3._prev = o(t3._prev, r3 ? n2 : i2); - return s; - } - function o(t3, e3) { - var r3 = t3.length, i2 = -1, o2 = n.allocUnsafe(t3.length); - for (t3 = n.concat([t3, n.from([e3])]); ++i2 < r3; ) - o2[i2] = t3[i2] << 1 | t3[i2 + 1] >> 7; - return o2; - } - e2.encrypt = function(t3, e3, r3) { - for (var o2 = e3.length, a = n.allocUnsafe(o2), s = -1; ++s < o2; ) - a[s] = i(t3, e3[s], r3); - return a; - }; - }, 1964: (t2, e2, r2) => { - var n = r2(9509).Buffer; - function i(t3, e3, r3) { - var i2 = t3._cipher.encryptBlock(t3._prev)[0] ^ e3; - return t3._prev = n.concat([t3._prev.slice(1), n.from([r3 ? e3 : i2])]), i2; - } - e2.encrypt = function(t3, e3, r3) { - for (var o = e3.length, a = n.allocUnsafe(o), s = -1; ++s < o; ) - a[s] = i(t3, e3[s], r3); - return a; - }; - }, 6009: (t2, e2, r2) => { - var n = r2(7295), i = r2(9509).Buffer, o = r2(685); - function a(t3) { - var e3 = t3._cipher.encryptBlockRaw(t3._prev); - return o(t3._prev), e3; - } - e2.encrypt = function(t3, e3) { - var r3 = Math.ceil(e3.length / 16), o2 = t3._cache.length; - t3._cache = i.concat([t3._cache, i.allocUnsafe(16 * r3)]); - for (var s = 0; s < r3; s++) { - var u = a(t3), f = o2 + 16 * s; - t3._cache.writeUInt32BE(u[0], f + 0), t3._cache.writeUInt32BE(u[1], f + 4), t3._cache.writeUInt32BE(u[2], f + 8), t3._cache.writeUInt32BE(u[3], f + 12); - } - var c = t3._cache.slice(0, e3.length); - return t3._cache = t3._cache.slice(e3.length), n(e3, c); - }; - }, 1084: (t2, e2) => { - e2.encrypt = function(t3, e3) { - return t3._cipher.encryptBlock(e3); - }, e2.decrypt = function(t3, e3) { - return t3._cipher.decryptBlock(e3); - }; - }, 45: (t2, e2, r2) => { - var n = {ECB: r2(1084), CBC: r2(5292), CFB: r2(6311), CFB8: r2(1964), CFB1: r2(1510), OFB: r2(8861), CTR: r2(6009), GCM: r2(6009)}, i = r2(5415); - for (var o in i) - i[o].module = n[i[o].mode]; - t2.exports = i; - }, 5415: (t2) => { - t2.exports = JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}'); - }, 8861: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(7295); - function o(t3) { - return t3._prev = t3._cipher.encryptBlock(t3._prev), t3._prev; - } - e2.encrypt = function(t3, e3) { - for (; t3._cache.length < e3.length; ) - t3._cache = n.concat([t3._cache, o(t3)]); - var r3 = t3._cache.slice(0, e3.length); - return t3._cache = t3._cache.slice(e3.length), i(e3, r3); - }; - }, 5969: (t2, e2, r2) => { - var n = r2(4497), i = r2(9509).Buffer, o = r2(1027); - function a(t3, e3, r3, a2) { - o.call(this), this._cipher = new n.AES(e3), this._prev = i.from(r3), this._cache = i.allocUnsafe(0), this._secCache = i.allocUnsafe(0), this._decrypt = a2, this._mode = t3; - } - r2(5717)(a, o), a.prototype._update = function(t3) { - return this._mode.encrypt(this, t3, this._decrypt); - }, a.prototype._final = function() { - this._cipher.scrub(); - }, t2.exports = a; - }, 3614: (t2, e2, r2) => { - var n = r2(7667), i = r2(4696), o = r2(45), a = r2(9715), s = r2(3048); - function u(t3, e3, r3) { - if (t3 = t3.toLowerCase(), o[t3]) - return i.createCipheriv(t3, e3, r3); - if (a[t3]) - return new n({key: e3, iv: r3, mode: t3}); - throw new TypeError("invalid suite type"); - } - function f(t3, e3, r3) { - if (t3 = t3.toLowerCase(), o[t3]) - return i.createDecipheriv(t3, e3, r3); - if (a[t3]) - return new n({key: e3, iv: r3, mode: t3, decrypt: true}); - throw new TypeError("invalid suite type"); - } - e2.createCipher = e2.Cipher = function(t3, e3) { - var r3, n2; - if (t3 = t3.toLowerCase(), o[t3]) - r3 = o[t3].key, n2 = o[t3].iv; - else { - if (!a[t3]) - throw new TypeError("invalid suite type"); - r3 = 8 * a[t3].key, n2 = a[t3].iv; - } - var i2 = s(e3, false, r3, n2); - return u(t3, i2.key, i2.iv); - }, e2.createCipheriv = e2.Cipheriv = u, e2.createDecipher = e2.Decipher = function(t3, e3) { - var r3, n2; - if (t3 = t3.toLowerCase(), o[t3]) - r3 = o[t3].key, n2 = o[t3].iv; - else { - if (!a[t3]) - throw new TypeError("invalid suite type"); - r3 = 8 * a[t3].key, n2 = a[t3].iv; - } - var i2 = s(e3, false, r3, n2); - return f(t3, i2.key, i2.iv); - }, e2.createDecipheriv = e2.Decipheriv = f, e2.listCiphers = e2.getCiphers = function() { - return Object.keys(a).concat(i.getCiphers()); - }; - }, 7667: (t2, e2, r2) => { - var n = r2(1027), i = r2(5251), o = r2(5717), a = r2(9509).Buffer, s = {"des-ede3-cbc": i.CBC.instantiate(i.EDE), "des-ede3": i.EDE, "des-ede-cbc": i.CBC.instantiate(i.EDE), "des-ede": i.EDE, "des-cbc": i.CBC.instantiate(i.DES), "des-ecb": i.DES}; - function u(t3) { - n.call(this); - var e3, r3 = t3.mode.toLowerCase(), i2 = s[r3]; - e3 = t3.decrypt ? "decrypt" : "encrypt"; - var o2 = t3.key; - a.isBuffer(o2) || (o2 = a.from(o2)), r3 !== "des-ede" && r3 !== "des-ede-cbc" || (o2 = a.concat([o2, o2.slice(0, 8)])); - var u2 = t3.iv; - a.isBuffer(u2) || (u2 = a.from(u2)), this._des = i2.create({key: o2, iv: u2, type: e3}); - } - s.des = s["des-cbc"], s.des3 = s["des-ede3-cbc"], t2.exports = u, o(u, n), u.prototype._update = function(t3) { - return a.from(this._des.update(t3)); - }, u.prototype._final = function() { - return a.from(this._des.final()); - }; - }, 9715: (t2, e2) => { - e2["des-ecb"] = {key: 8, iv: 0}, e2["des-cbc"] = e2.des = {key: 8, iv: 8}, e2["des-ede3-cbc"] = e2.des3 = {key: 24, iv: 8}, e2["des-ede3"] = {key: 24, iv: 0}, e2["des-ede-cbc"] = {key: 16, iv: 8}, e2["des-ede"] = {key: 16, iv: 0}; - }, 3663: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(3982), o = r2(1798); - function a(t3) { - var e3, r3 = t3.modulus.byteLength(); - do { - e3 = new i(o(r3)); - } while (e3.cmp(t3.modulus) >= 0 || !e3.umod(t3.prime1) || !e3.umod(t3.prime2)); - return e3; - } - function s(t3, e3) { - var r3 = function(t4) { - var e4 = a(t4); - return {blinder: e4.toRed(i.mont(t4.modulus)).redPow(new i(t4.publicExponent)).fromRed(), unblinder: e4.invm(t4.modulus)}; - }(e3), o2 = e3.modulus.byteLength(), s2 = new i(t3).mul(r3.blinder).umod(e3.modulus), u = s2.toRed(i.mont(e3.prime1)), f = s2.toRed(i.mont(e3.prime2)), c = e3.coefficient, h = e3.prime1, l = e3.prime2, d = u.redPow(e3.exponent1).fromRed(), p = f.redPow(e3.exponent2).fromRed(), y = d.isub(p).imul(c).umod(h).imul(l); - return p.iadd(y).imul(r3.unblinder).umod(e3.modulus).toArrayLike(n, "be", o2); - } - s.getr = a, t2.exports = s; - }, 3982: function(t2, e2, r2) { - !function(t3, e3) { - function n(t4, e4) { - if (!t4) - throw new Error(e4 || "Assertion failed"); - } - function i(t4, e4) { - t4.super_ = e4; - var r3 = function() { - }; - r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; - } - function o(t4, e4, r3) { - if (o.isBN(t4)) - return t4; - this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); - } - var a; - typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; - try { - a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(1922).Buffer; - } catch (t4) { - } - function s(t4, e4) { - var r3 = t4.charCodeAt(e4); - return r3 >= 48 && r3 <= 57 ? r3 - 48 : r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : void n(false, "Invalid character in " + t4); - } - function u(t4, e4, r3) { - var n2 = s(t4, r3); - return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; - } - function f(t4, e4, r3, i2) { - for (var o2 = 0, a2 = 0, s2 = Math.min(t4.length, r3), u2 = e4; u2 < s2; u2++) { - var f2 = t4.charCodeAt(u2) - 48; - o2 *= i2, a2 = f2 >= 49 ? f2 - 49 + 10 : f2 >= 17 ? f2 - 17 + 10 : f2, n(f2 >= 0 && a2 < i2, "Invalid character"), o2 += a2; - } - return o2; - } - function c(t4, e4) { - t4.words = e4.words, t4.length = e4.length, t4.negative = e4.negative, t4.red = e4.red; - } - if (o.isBN = function(t4) { - return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); - }, o.max = function(t4, e4) { - return t4.cmp(e4) > 0 ? t4 : e4; - }, o.min = function(t4, e4) { - return t4.cmp(e4) < 0 ? t4 : e4; - }, o.prototype._init = function(t4, e4, r3) { - if (typeof t4 == "number") - return this._initNumber(t4, e4, r3); - if (typeof t4 == "object") - return this._initArray(t4, e4, r3); - e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); - var i2 = 0; - (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); - }, o.prototype._initNumber = function(t4, e4, r3) { - t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); - }, o.prototype._initArray = function(t4, e4, r3) { - if (n(typeof t4.length == "number"), t4.length <= 0) - return this.words = [0], this.length = 1, this; - this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); - for (var i2 = 0; i2 < this.length; i2++) - this.words[i2] = 0; - var o2, a2, s2 = 0; - if (r3 === "be") - for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) - a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - else if (r3 === "le") - for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) - a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - return this._strip(); - }, o.prototype._parseHex = function(t4, e4, r3) { - this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); - for (var n2 = 0; n2 < this.length; n2++) - this.words[n2] = 0; - var i2, o2 = 0, a2 = 0; - if (r3 === "be") - for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - else - for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - this._strip(); - }, o.prototype._parseBase = function(t4, e4, r3) { - this.words = [0], this.length = 1; - for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) - n2++; - n2--, i2 = i2 / e4 | 0; - for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) - u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - if (a2 !== 0) { - var h2 = 1; - for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) - h2 *= e4; - this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - } - this._strip(); - }, o.prototype.copy = function(t4) { - t4.words = new Array(this.length); - for (var e4 = 0; e4 < this.length; e4++) - t4.words[e4] = this.words[e4]; - t4.length = this.length, t4.negative = this.negative, t4.red = this.red; - }, o.prototype._move = function(t4) { - c(t4, this); - }, o.prototype.clone = function() { - var t4 = new o(null); - return this.copy(t4), t4; - }, o.prototype._expand = function(t4) { - for (; this.length < t4; ) - this.words[this.length++] = 0; - return this; - }, o.prototype._strip = function() { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) - this.length--; - return this._normSign(); - }, o.prototype._normSign = function() { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }, typeof Symbol != "undefined" && typeof Symbol.for == "function") - try { - o.prototype[Symbol.for("nodejs.util.inspect.custom")] = h; - } catch (t4) { - o.prototype.inspect = h; - } - else - o.prototype.inspect = h; - function h() { - return (this.red ? ""; - } - var l = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], d = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], p = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; - function y(t4, e4, r3) { - r3.negative = e4.negative ^ t4.negative; - var n2 = t4.length + e4.length | 0; - r3.length = n2, n2 = n2 - 1 | 0; - var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; - r3.words[0] = s2; - for (var f2 = 1; f2 < n2; f2++) { - for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { - var p2 = f2 - d2 | 0; - c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; - } - r3.words[f2] = 0 | h2, u2 = 0 | c2; - } - return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3._strip(); - } - o.prototype.toString = function(t4, e4) { - var r3; - if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { - r3 = ""; - for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { - var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); - r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? l[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); - } - for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { - var f2 = d[t4], c2 = p[t4]; - r3 = ""; - var h2 = this.clone(); - for (h2.negative = 0; !h2.isZero(); ) { - var y2 = h2.modrn(c2).toString(t4); - r3 = (h2 = h2.idivn(c2)).isZero() ? y2 + r3 : l[f2 - y2.length] + y2 + r3; - } - for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - n(false, "Base should be between 2 and 36"); - }, o.prototype.toNumber = function() { - var t4 = this.words[0]; - return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; - }, o.prototype.toJSON = function() { - return this.toString(16, 2); - }, a && (o.prototype.toBuffer = function(t4, e4) { - return this.toArrayLike(a, t4, e4); - }), o.prototype.toArray = function(t4, e4) { - return this.toArrayLike(Array, t4, e4); - }, o.prototype.toArrayLike = function(t4, e4, r3) { - this._strip(); - var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); - n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"); - var a2 = function(t5, e5) { - return t5.allocUnsafe ? t5.allocUnsafe(e5) : new t5(e5); - }(t4, o2); - return this["_toArrayLike" + (e4 === "le" ? "LE" : "BE")](a2, i2), a2; - }, o.prototype._toArrayLikeLE = function(t4, e4) { - for (var r3 = 0, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { - var a2 = this.words[i2] << o2 | n2; - t4[r3++] = 255 & a2, r3 < t4.length && (t4[r3++] = a2 >> 8 & 255), r3 < t4.length && (t4[r3++] = a2 >> 16 & 255), o2 === 6 ? (r3 < t4.length && (t4[r3++] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); - } - if (r3 < t4.length) - for (t4[r3++] = n2; r3 < t4.length; ) - t4[r3++] = 0; - }, o.prototype._toArrayLikeBE = function(t4, e4) { - for (var r3 = t4.length - 1, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { - var a2 = this.words[i2] << o2 | n2; - t4[r3--] = 255 & a2, r3 >= 0 && (t4[r3--] = a2 >> 8 & 255), r3 >= 0 && (t4[r3--] = a2 >> 16 & 255), o2 === 6 ? (r3 >= 0 && (t4[r3--] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); - } - if (r3 >= 0) - for (t4[r3--] = n2; r3 >= 0; ) - t4[r3--] = 0; - }, Math.clz32 ? o.prototype._countBits = function(t4) { - return 32 - Math.clz32(t4); - } : o.prototype._countBits = function(t4) { - var e4 = t4, r3 = 0; - return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; - }, o.prototype._zeroBits = function(t4) { - if (t4 === 0) - return 26; - var e4 = t4, r3 = 0; - return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; - }, o.prototype.bitLength = function() { - var t4 = this.words[this.length - 1], e4 = this._countBits(t4); - return 26 * (this.length - 1) + e4; - }, o.prototype.zeroBits = function() { - if (this.isZero()) - return 0; - for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { - var r3 = this._zeroBits(this.words[e4]); - if (t4 += r3, r3 !== 26) - break; - } - return t4; - }, o.prototype.byteLength = function() { - return Math.ceil(this.bitLength() / 8); - }, o.prototype.toTwos = function(t4) { - return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); - }, o.prototype.fromTwos = function(t4) { - return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); - }, o.prototype.isNeg = function() { - return this.negative !== 0; - }, o.prototype.neg = function() { - return this.clone().ineg(); - }, o.prototype.ineg = function() { - return this.isZero() || (this.negative ^= 1), this; - }, o.prototype.iuor = function(t4) { - for (; this.length < t4.length; ) - this.words[this.length++] = 0; - for (var e4 = 0; e4 < t4.length; e4++) - this.words[e4] = this.words[e4] | t4.words[e4]; - return this._strip(); - }, o.prototype.ior = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuor(t4); - }, o.prototype.or = function(t4) { - return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); - }, o.prototype.uor = function(t4) { - return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); - }, o.prototype.iuand = function(t4) { - var e4; - e4 = this.length > t4.length ? t4 : this; - for (var r3 = 0; r3 < e4.length; r3++) - this.words[r3] = this.words[r3] & t4.words[r3]; - return this.length = e4.length, this._strip(); - }, o.prototype.iand = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuand(t4); - }, o.prototype.and = function(t4) { - return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); - }, o.prototype.uand = function(t4) { - return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); - }, o.prototype.iuxor = function(t4) { - var e4, r3; - this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); - for (var n2 = 0; n2 < r3.length; n2++) - this.words[n2] = e4.words[n2] ^ r3.words[n2]; - if (this !== e4) - for (; n2 < e4.length; n2++) - this.words[n2] = e4.words[n2]; - return this.length = e4.length, this._strip(); - }, o.prototype.ixor = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuxor(t4); - }, o.prototype.xor = function(t4) { - return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); - }, o.prototype.uxor = function(t4) { - return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); - }, o.prototype.inotn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; - this._expand(e4), r3 > 0 && e4--; - for (var i2 = 0; i2 < e4; i2++) - this.words[i2] = 67108863 & ~this.words[i2]; - return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this._strip(); - }, o.prototype.notn = function(t4) { - return this.clone().inotn(t4); - }, o.prototype.setn = function(t4, e4) { - n(typeof t4 == "number" && t4 >= 0); - var r3 = t4 / 26 | 0, i2 = t4 % 26; - return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this._strip(); - }, o.prototype.iadd = function(t4) { - var e4, r3, n2; - if (this.negative !== 0 && t4.negative === 0) - return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); - if (this.negative === 0 && t4.negative !== 0) - return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); - this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) - e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - for (; i2 !== 0 && o2 < r3.length; o2++) - e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - if (this.length = r3.length, i2 !== 0) - this.words[this.length] = i2, this.length++; - else if (r3 !== this) - for (; o2 < r3.length; o2++) - this.words[o2] = r3.words[o2]; - return this; - }, o.prototype.add = function(t4) { - var e4; - return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); - }, o.prototype.isub = function(t4) { - if (t4.negative !== 0) { - t4.negative = 0; - var e4 = this.iadd(t4); - return t4.negative = 1, e4._normSign(); - } - if (this.negative !== 0) - return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); - var r3, n2, i2 = this.cmp(t4); - if (i2 === 0) - return this.negative = 0, this.length = 1, this.words[0] = 0, this; - i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - for (; o2 !== 0 && a2 < r3.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - if (o2 === 0 && a2 < r3.length && r3 !== this) - for (; a2 < r3.length; a2++) - this.words[a2] = r3.words[a2]; - return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this._strip(); - }, o.prototype.sub = function(t4) { - return this.clone().isub(t4); - }; - var m = function(t4, e4, r3) { - var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v = 0 | a2[3], w2 = 8191 & v, _2 = v >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A2 = 0 | a2[5], k2 = 8191 & A2, B2 = A2 >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; - r3.negative = t4.negative ^ e4.negative, r3.length = 19; - var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; - f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); - var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; - var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; - var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; - var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k2, z), i2 = (i2 = Math.imul(k2, q)) + Math.imul(B2, z) | 0, o2 = Math.imul(B2, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; - var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k2, F) | 0, i2 = (i2 = i2 + Math.imul(k2, V) | 0) + Math.imul(B2, F) | 0, o2 = o2 + Math.imul(B2, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; - var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k2, J) | 0, i2 = (i2 = i2 + Math.imul(k2, $) | 0) + Math.imul(B2, J) | 0, o2 = o2 + Math.imul(B2, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; - var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k2, Z) | 0, i2 = (i2 = i2 + Math.imul(k2, Y) | 0) + Math.imul(B2, Z) | 0, o2 = o2 + Math.imul(B2, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; - var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k2, Q) | 0, i2 = (i2 = i2 + Math.imul(k2, tt) | 0) + Math.imul(B2, Q) | 0, o2 = o2 + Math.imul(B2, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; - var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k2, rt) | 0, i2 = (i2 = i2 + Math.imul(k2, nt) | 0) + Math.imul(B2, rt) | 0, o2 = o2 + Math.imul(B2, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; - var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k2, ot) | 0, i2 = (i2 = i2 + Math.imul(k2, at) | 0) + Math.imul(B2, ot) | 0, o2 = o2 + Math.imul(B2, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; - var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k2, ut) | 0, i2 = (i2 = i2 + Math.imul(k2, ft) | 0) + Math.imul(B2, ut) | 0, o2 = o2 + Math.imul(B2, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; - var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k2, ht) | 0, i2 = (i2 = i2 + Math.imul(k2, lt) | 0) + Math.imul(B2, ht) | 0, o2 = o2 + Math.imul(B2, lt) | 0; - var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; - var Ot = (f2 + (n2 = n2 + Math.imul(k2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k2, yt) | 0) + Math.imul(B2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(B2, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; - var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; - var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); - var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; - var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; - return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; - }; - function b(t4, e4, r3) { - r3.negative = e4.negative ^ t4.negative, r3.length = t4.length + e4.length; - for (var n2 = 0, i2 = 0, o2 = 0; o2 < r3.length - 1; o2++) { - var a2 = i2; - i2 = 0; - for (var s2 = 67108863 & n2, u2 = Math.min(o2, e4.length - 1), f2 = Math.max(0, o2 - t4.length + 1); f2 <= u2; f2++) { - var c2 = o2 - f2, h2 = (0 | t4.words[c2]) * (0 | e4.words[f2]), l2 = 67108863 & h2; - s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; - } - r3.words[o2] = s2, n2 = a2, a2 = i2; - } - return n2 !== 0 ? r3.words[o2] = n2 : r3.length--, r3._strip(); - } - function g(t4, e4, r3) { - return b(t4, e4, r3); - } - Math.imul || (m = y), o.prototype.mulTo = function(t4, e4) { - var r3 = this.length + t4.length; - return this.length === 10 && t4.length === 10 ? m(this, t4, e4) : r3 < 63 ? y(this, t4, e4) : r3 < 1024 ? b(this, t4, e4) : g(this, t4, e4); - }, o.prototype.mul = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); - }, o.prototype.mulf = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), g(this, t4, e4); - }, o.prototype.imul = function(t4) { - return this.clone().mulTo(t4, this); - }, o.prototype.imuln = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(typeof t4 == "number"), n(t4 < 67108864); - for (var r3 = 0, i2 = 0; i2 < this.length; i2++) { - var o2 = (0 | this.words[i2]) * t4, a2 = (67108863 & o2) + (67108863 & r3); - r3 >>= 26, r3 += o2 / 67108864 | 0, r3 += a2 >>> 26, this.words[i2] = 67108863 & a2; - } - return r3 !== 0 && (this.words[i2] = r3, this.length++), e4 ? this.ineg() : this; - }, o.prototype.muln = function(t4) { - return this.clone().imuln(t4); - }, o.prototype.sqr = function() { - return this.mul(this); - }, o.prototype.isqr = function() { - return this.imul(this.clone()); - }, o.prototype.pow = function(t4) { - var e4 = function(t5) { - for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { - var n3 = r4 / 26 | 0, i3 = r4 % 26; - e5[r4] = t5.words[n3] >>> i3 & 1; - } - return e5; - }(t4); - if (e4.length === 0) - return new o(1); - for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) - ; - if (++n2 < e4.length) - for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) - e4[n2] !== 0 && (r3 = r3.mul(i2)); - return r3; - }, o.prototype.iushln = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; - if (r3 !== 0) { - var a2 = 0; - for (e4 = 0; e4 < this.length; e4++) { - var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; - this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; - } - a2 && (this.words[e4] = a2, this.length++); - } - if (i2 !== 0) { - for (e4 = this.length - 1; e4 >= 0; e4--) - this.words[e4 + i2] = this.words[e4]; - for (e4 = 0; e4 < i2; e4++) - this.words[e4] = 0; - this.length += i2; - } - return this._strip(); - }, o.prototype.ishln = function(t4) { - return n(this.negative === 0), this.iushln(t4); - }, o.prototype.iushrn = function(t4, e4, r3) { - var i2; - n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; - var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; - if (i2 -= a2, i2 = Math.max(0, i2), u2) { - for (var f2 = 0; f2 < a2; f2++) - u2.words[f2] = this.words[f2]; - u2.length = a2; - } - if (a2 === 0) - ; - else if (this.length > a2) - for (this.length -= a2, f2 = 0; f2 < this.length; f2++) - this.words[f2] = this.words[f2 + a2]; - else - this.words[0] = 0, this.length = 1; - var c2 = 0; - for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { - var h2 = 0 | this.words[f2]; - this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; - } - return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); - }, o.prototype.ishrn = function(t4, e4, r3) { - return n(this.negative === 0), this.iushrn(t4, e4, r3); - }, o.prototype.shln = function(t4) { - return this.clone().ishln(t4); - }, o.prototype.ushln = function(t4) { - return this.clone().iushln(t4); - }, o.prototype.shrn = function(t4) { - return this.clone().ishrn(t4); - }, o.prototype.ushrn = function(t4) { - return this.clone().iushrn(t4); - }, o.prototype.testn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - return !(this.length <= r3 || !(this.words[r3] & i2)); - }, o.prototype.imaskn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26; - if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) - return this; - if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { - var i2 = 67108863 ^ 67108863 >>> e4 << e4; - this.words[this.length - 1] &= i2; - } - return this._strip(); - }, o.prototype.maskn = function(t4) { - return this.clone().imaskn(t4); - }, o.prototype.iaddn = function(t4) { - return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) <= t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); - }, o.prototype._iaddn = function(t4) { - this.words[0] += t4; - for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) - this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; - return this.length = Math.max(this.length, e4 + 1), this; - }, o.prototype.isubn = function(t4) { - if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) - return this.iaddn(-t4); - if (this.negative !== 0) - return this.negative = 0, this.iaddn(t4), this.negative = 1, this; - if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) - this.words[0] = -this.words[0], this.negative = 1; - else - for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) - this.words[e4] += 67108864, this.words[e4 + 1] -= 1; - return this._strip(); - }, o.prototype.addn = function(t4) { - return this.clone().iaddn(t4); - }, o.prototype.subn = function(t4) { - return this.clone().isubn(t4); - }, o.prototype.iabs = function() { - return this.negative = 0, this; - }, o.prototype.abs = function() { - return this.clone().iabs(); - }, o.prototype._ishlnsubmul = function(t4, e4, r3) { - var i2, o2, a2 = t4.length + r3; - this._expand(a2); - var s2 = 0; - for (i2 = 0; i2 < t4.length; i2++) { - o2 = (0 | this.words[i2 + r3]) + s2; - var u2 = (0 | t4.words[i2]) * e4; - s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; - } - for (; i2 < this.length - r3; i2++) - s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; - if (s2 === 0) - return this._strip(); - for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) - s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; - return this.negative = 1, this._strip(); - }, o.prototype._wordDiv = function(t4, e4) { - var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; - (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); - var s2, u2 = n2.length - i2.length; - if (e4 !== "mod") { - (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); - for (var f2 = 0; f2 < s2.length; f2++) - s2.words[f2] = 0; - } - var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); - c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); - for (var h2 = u2 - 1; h2 >= 0; h2--) { - var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); - for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) - l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); - s2 && (s2.words[h2] = l2); - } - return s2 && s2._strip(), n2._strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; - }, o.prototype.divmod = function(t4, e4, r3) { - return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modrn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modrn(t4.words[0]))} : this._wordDiv(t4, e4); - var i2, a2, s2; - }, o.prototype.div = function(t4) { - return this.divmod(t4, "div", false).div; - }, o.prototype.mod = function(t4) { - return this.divmod(t4, "mod", false).mod; - }, o.prototype.umod = function(t4) { - return this.divmod(t4, "mod", true).mod; - }, o.prototype.divRound = function(t4) { - var e4 = this.divmod(t4); - if (e4.mod.isZero()) - return e4.div; - var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); - return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); - }, o.prototype.modrn = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(t4 <= 67108863); - for (var r3 = (1 << 26) % t4, i2 = 0, o2 = this.length - 1; o2 >= 0; o2--) - i2 = (r3 * i2 + (0 | this.words[o2])) % t4; - return e4 ? -i2 : i2; - }, o.prototype.modn = function(t4) { - return this.modrn(t4); - }, o.prototype.idivn = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(t4 <= 67108863); - for (var r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) { - var o2 = (0 | this.words[i2]) + 67108864 * r3; - this.words[i2] = o2 / t4 | 0, r3 = o2 % t4; - } - return this._strip(), e4 ? this.ineg() : this; - }, o.prototype.divn = function(t4) { - return this.clone().idivn(t4); - }, o.prototype.egcd = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) - e4.iushrn(1), r3.iushrn(1), ++f2; - for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { - for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) - ; - if (l2 > 0) - for (e4.iushrn(l2); l2-- > 0; ) - (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); - for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) - ; - if (p2 > 0) - for (r3.iushrn(p2); p2-- > 0; ) - (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); - } - return {a: s2, b: u2, gcd: r3.iushln(f2)}; - }, o.prototype._invmp = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { - for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) - ; - if (f2 > 0) - for (e4.iushrn(f2); f2-- > 0; ) - a2.isOdd() && a2.iadd(u2), a2.iushrn(1); - for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) - ; - if (h2 > 0) - for (r3.iushrn(h2); h2-- > 0; ) - s2.isOdd() && s2.iadd(u2), s2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); - } - return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; - }, o.prototype.gcd = function(t4) { - if (this.isZero()) - return t4.abs(); - if (t4.isZero()) - return this.abs(); - var e4 = this.clone(), r3 = t4.clone(); - e4.negative = 0, r3.negative = 0; - for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) - e4.iushrn(1), r3.iushrn(1); - for (; ; ) { - for (; e4.isEven(); ) - e4.iushrn(1); - for (; r3.isEven(); ) - r3.iushrn(1); - var i2 = e4.cmp(r3); - if (i2 < 0) { - var o2 = e4; - e4 = r3, r3 = o2; - } else if (i2 === 0 || r3.cmpn(1) === 0) - break; - e4.isub(r3); - } - return r3.iushln(n2); - }, o.prototype.invm = function(t4) { - return this.egcd(t4).a.umod(t4); - }, o.prototype.isEven = function() { - return (1 & this.words[0]) == 0; - }, o.prototype.isOdd = function() { - return (1 & this.words[0]) == 1; - }, o.prototype.andln = function(t4) { - return this.words[0] & t4; - }, o.prototype.bincn = function(t4) { - n(typeof t4 == "number"); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - if (this.length <= r3) - return this._expand(r3 + 1), this.words[r3] |= i2, this; - for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { - var s2 = 0 | this.words[a2]; - o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; - } - return o2 !== 0 && (this.words[a2] = o2, this.length++), this; - }, o.prototype.isZero = function() { - return this.length === 1 && this.words[0] === 0; - }, o.prototype.cmpn = function(t4) { - var e4, r3 = t4 < 0; - if (this.negative !== 0 && !r3) - return -1; - if (this.negative === 0 && r3) - return 1; - if (this._strip(), this.length > 1) - e4 = 1; - else { - r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); - var i2 = 0 | this.words[0]; - e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; - } - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.cmp = function(t4) { - if (this.negative !== 0 && t4.negative === 0) - return -1; - if (this.negative === 0 && t4.negative !== 0) - return 1; - var e4 = this.ucmp(t4); - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.ucmp = function(t4) { - if (this.length > t4.length) - return 1; - if (this.length < t4.length) - return -1; - for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { - var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; - if (n2 !== i2) { - n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); - break; - } - } - return e4; - }, o.prototype.gtn = function(t4) { - return this.cmpn(t4) === 1; - }, o.prototype.gt = function(t4) { - return this.cmp(t4) === 1; - }, o.prototype.gten = function(t4) { - return this.cmpn(t4) >= 0; - }, o.prototype.gte = function(t4) { - return this.cmp(t4) >= 0; - }, o.prototype.ltn = function(t4) { - return this.cmpn(t4) === -1; - }, o.prototype.lt = function(t4) { - return this.cmp(t4) === -1; - }, o.prototype.lten = function(t4) { - return this.cmpn(t4) <= 0; - }, o.prototype.lte = function(t4) { - return this.cmp(t4) <= 0; - }, o.prototype.eqn = function(t4) { - return this.cmpn(t4) === 0; - }, o.prototype.eq = function(t4) { - return this.cmp(t4) === 0; - }, o.red = function(t4) { - return new k(t4); - }, o.prototype.toRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); - }, o.prototype.fromRed = function() { - return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }, o.prototype._forceRed = function(t4) { - return this.red = t4, this; - }, o.prototype.forceRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); - }, o.prototype.redAdd = function(t4) { - return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); - }, o.prototype.redIAdd = function(t4) { - return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); - }, o.prototype.redSub = function(t4) { - return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); - }, o.prototype.redISub = function(t4) { - return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); - }, o.prototype.redShl = function(t4) { - return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); - }, o.prototype.redMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); - }, o.prototype.redIMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); - }, o.prototype.redSqr = function() { - return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }, o.prototype.redISqr = function() { - return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }, o.prototype.redSqrt = function() { - return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }, o.prototype.redInvm = function() { - return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }, o.prototype.redNeg = function() { - return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }, o.prototype.redPow = function(t4) { - return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); - }; - var w = {k256: null, p224: null, p192: null, p25519: null}; - function _(t4, e4) { - this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); - } - function M() { - _.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - function S() { - _.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - function E() { - _.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - function A() { - _.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - function k(t4) { - if (typeof t4 == "string") { - var e4 = o._prime(t4); - this.m = e4.p, this.prime = e4; - } else - n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; - } - function B(t4) { - k.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); - } - _.prototype._tmp = function() { - var t4 = new o(null); - return t4.words = new Array(Math.ceil(this.n / 13)), t4; - }, _.prototype.ireduce = function(t4) { - var e4, r3 = t4; - do { - this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); - } while (e4 > this.n); - var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); - return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; - }, _.prototype.split = function(t4, e4) { - t4.iushrn(this.n, 0, e4); - }, _.prototype.imulK = function(t4) { - return t4.imul(this.k); - }, i(M, _), M.prototype.split = function(t4, e4) { - for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) - e4.words[i2] = t4.words[i2]; - if (e4.length = n2, t4.length <= 9) - return t4.words[0] = 0, void (t4.length = 1); - var o2 = t4.words[9]; - for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { - var a2 = 0 | t4.words[i2]; - t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; - } - o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; - }, M.prototype.imulK = function(t4) { - t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 0 | t4.words[r3]; - e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); - } - return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; - }, i(S, _), i(E, _), i(A, _), A.prototype.imulK = function(t4) { - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; - n2 >>>= 26, t4.words[r3] = i2, e4 = n2; - } - return e4 !== 0 && (t4.words[t4.length++] = e4), t4; - }, o._prime = function(t4) { - if (w[t4]) - return w[t4]; - var e4; - if (t4 === "k256") - e4 = new M(); - else if (t4 === "p224") - e4 = new S(); - else if (t4 === "p192") - e4 = new E(); - else { - if (t4 !== "p25519") - throw new Error("Unknown prime " + t4); - e4 = new A(); - } - return w[t4] = e4, e4; - }, k.prototype._verify1 = function(t4) { - n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); - }, k.prototype._verify2 = function(t4, e4) { - n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); - }, k.prototype.imod = function(t4) { - return this.prime ? this.prime.ireduce(t4)._forceRed(this) : (c(t4, t4.umod(this.m)._forceRed(this)), t4); - }, k.prototype.neg = function(t4) { - return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); - }, k.prototype.add = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.add(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); - }, k.prototype.iadd = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.iadd(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; - }, k.prototype.sub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.sub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); - }, k.prototype.isub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.isub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; - }, k.prototype.shl = function(t4, e4) { - return this._verify1(t4), this.imod(t4.ushln(e4)); - }, k.prototype.imul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.imul(e4)); - }, k.prototype.mul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.mul(e4)); - }, k.prototype.isqr = function(t4) { - return this.imul(t4, t4.clone()); - }, k.prototype.sqr = function(t4) { - return this.mul(t4, t4); - }, k.prototype.sqrt = function(t4) { - if (t4.isZero()) - return t4.clone(); - var e4 = this.m.andln(3); - if (n(e4 % 2 == 1), e4 === 3) { - var r3 = this.m.add(new o(1)).iushrn(2); - return this.pow(t4, r3); - } - for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) - a2++, i2.iushrn(1); - n(!i2.isZero()); - var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); - for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) - c2.redIAdd(u2); - for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { - for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) - y2 = y2.redSqr(); - n(m2 < p2); - var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); - l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; - } - return l2; - }, k.prototype.invm = function(t4) { - var e4 = t4._invmp(this.m); - return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); - }, k.prototype.pow = function(t4, e4) { - if (e4.isZero()) - return new o(1).toRed(this); - if (e4.cmpn(1) === 0) - return t4.clone(); - var r3 = new Array(16); - r3[0] = new o(1).toRed(this), r3[1] = t4; - for (var n2 = 2; n2 < r3.length; n2++) - r3[n2] = this.mul(r3[n2 - 1], t4); - var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; - for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { - for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { - var h2 = f2 >> c2 & 1; - i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; - } - u2 = 26; - } - return i2; - }, k.prototype.convertTo = function(t4) { - var e4 = t4.umod(this.m); - return e4 === t4 ? e4.clone() : e4; - }, k.prototype.convertFrom = function(t4) { - var e4 = t4.clone(); - return e4.red = null, e4; - }, o.mont = function(t4) { - return new B(t4); - }, i(B, k), B.prototype.convertTo = function(t4) { - return this.imod(t4.ushln(this.shift)); - }, B.prototype.convertFrom = function(t4) { - var e4 = this.imod(t4.mul(this.rinv)); - return e4.red = null, e4; - }, B.prototype.imul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return t4.words[0] = 0, t4.length = 1, t4; - var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; - return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); - }, B.prototype.mul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return new o(0)._forceRed(this); - var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; - return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); - }, B.prototype.invm = function(t4) { - return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); - }; - }(t2 = r2.nmd(t2), this); - }, 6042: (t2, e2, r2) => { - t2.exports = r2(2063); - }, 2063: (t2) => { - t2.exports = JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}'); - }, 2236: (t2) => { - t2.exports = JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}'); - }, 4743: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(3482), o = r2(8473), a = r2(5717), s = r2(2957), u = r2(7753), f = r2(2063); - function c(t3) { - o.Writable.call(this); - var e3 = f[t3]; - if (!e3) - throw new Error("Unknown message digest"); - this._hashType = e3.hash, this._hash = i(e3.hash), this._tag = e3.id, this._signType = e3.sign; - } - function h(t3) { - o.Writable.call(this); - var e3 = f[t3]; - if (!e3) - throw new Error("Unknown message digest"); - this._hash = i(e3.hash), this._tag = e3.id, this._signType = e3.sign; - } - function l(t3) { - return new c(t3); - } - function d(t3) { - return new h(t3); - } - Object.keys(f).forEach(function(t3) { - f[t3].id = n.from(f[t3].id, "hex"), f[t3.toLowerCase()] = f[t3]; - }), a(c, o.Writable), c.prototype._write = function(t3, e3, r3) { - this._hash.update(t3), r3(); - }, c.prototype.update = function(t3, e3) { - return typeof t3 == "string" && (t3 = n.from(t3, e3)), this._hash.update(t3), this; - }, c.prototype.sign = function(t3, e3) { - this.end(); - var r3 = this._hash.digest(), n2 = s(r3, t3, this._hashType, this._signType, this._tag); - return e3 ? n2.toString(e3) : n2; - }, a(h, o.Writable), h.prototype._write = function(t3, e3, r3) { - this._hash.update(t3), r3(); - }, h.prototype.update = function(t3, e3) { - return typeof t3 == "string" && (t3 = n.from(t3, e3)), this._hash.update(t3), this; - }, h.prototype.verify = function(t3, e3, r3) { - typeof e3 == "string" && (e3 = n.from(e3, r3)), this.end(); - var i2 = this._hash.digest(); - return u(e3, i2, t3, this._signType, this._tag); - }, t2.exports = {Sign: l, Verify: d, createSign: l, createVerify: d}; - }, 2957: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(8355), o = r2(3663), a = r2(6266).ec, s = r2(8815), u = r2(980), f = r2(2236); - function c(t3, e3, r3, o2) { - if ((t3 = n.from(t3.toArray())).length < e3.byteLength()) { - var a2 = n.alloc(e3.byteLength() - t3.length); - t3 = n.concat([a2, t3]); - } - var s2 = r3.length, u2 = function(t4, e4) { - t4 = (t4 = h(t4, e4)).mod(e4); - var r4 = n.from(t4.toArray()); - if (r4.length < e4.byteLength()) { - var i2 = n.alloc(e4.byteLength() - r4.length); - r4 = n.concat([i2, r4]); - } - return r4; - }(r3, e3), f2 = n.alloc(s2); - f2.fill(1); - var c2 = n.alloc(s2); - return c2 = i(o2, c2).update(f2).update(n.from([0])).update(t3).update(u2).digest(), f2 = i(o2, c2).update(f2).digest(), {k: c2 = i(o2, c2).update(f2).update(n.from([1])).update(t3).update(u2).digest(), v: f2 = i(o2, c2).update(f2).digest()}; - } - function h(t3, e3) { - var r3 = new s(t3), n2 = (t3.length << 3) - e3.bitLength(); - return n2 > 0 && r3.ishrn(n2), r3; - } - function l(t3, e3, r3) { - var o2, a2; - do { - for (o2 = n.alloc(0); 8 * o2.length < t3.bitLength(); ) - e3.v = i(r3, e3.k).update(e3.v).digest(), o2 = n.concat([o2, e3.v]); - a2 = h(o2, t3), e3.k = i(r3, e3.k).update(e3.v).update(n.from([0])).digest(), e3.v = i(r3, e3.k).update(e3.v).digest(); - } while (a2.cmp(t3) !== -1); - return a2; - } - function d(t3, e3, r3, n2) { - return t3.toRed(s.mont(r3)).redPow(e3).fromRed().mod(n2); - } - t2.exports = function(t3, e3, r3, i2, p) { - var y = u(e3); - if (y.curve) { - if (i2 !== "ecdsa" && i2 !== "ecdsa/rsa") - throw new Error("wrong private key type"); - return function(t4, e4) { - var r4 = f[e4.curve.join(".")]; - if (!r4) - throw new Error("unknown curve " + e4.curve.join(".")); - var i3 = new a(r4).keyFromPrivate(e4.privateKey).sign(t4); - return n.from(i3.toDER()); - }(t3, y); - } - if (y.type === "dsa") { - if (i2 !== "dsa") - throw new Error("wrong private key type"); - return function(t4, e4, r4) { - for (var i3, o2 = e4.params.priv_key, a2 = e4.params.p, u2 = e4.params.q, f2 = e4.params.g, p2 = new s(0), y2 = h(t4, u2).mod(u2), m2 = false, b2 = c(o2, u2, t4, r4); m2 === false; ) - p2 = d(f2, i3 = l(u2, b2, r4), a2, u2), (m2 = i3.invm(u2).imul(y2.add(o2.mul(p2))).mod(u2)).cmpn(0) === 0 && (m2 = false, p2 = new s(0)); - return function(t5, e5) { - t5 = t5.toArray(), e5 = e5.toArray(), 128 & t5[0] && (t5 = [0].concat(t5)), 128 & e5[0] && (e5 = [0].concat(e5)); - var r5 = [48, t5.length + e5.length + 4, 2, t5.length]; - return r5 = r5.concat(t5, [2, e5.length], e5), n.from(r5); - }(p2, m2); - }(t3, y, r3); - } - if (i2 !== "rsa" && i2 !== "ecdsa/rsa") - throw new Error("wrong private key type"); - t3 = n.concat([p, t3]); - for (var m = y.modulus.byteLength(), b = [0, 1]; t3.length + b.length + 1 < m; ) - b.push(255); - b.push(0); - for (var g = -1; ++g < t3.length; ) - b.push(t3[g]); - return o(b, y); - }, t2.exports.getKey = c, t2.exports.makeKey = l; - }, 7753: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(8815), o = r2(6266).ec, a = r2(980), s = r2(2236); - function u(t3, e3) { - if (t3.cmpn(0) <= 0) - throw new Error("invalid sig"); - if (t3.cmp(e3) >= e3) - throw new Error("invalid sig"); - } - t2.exports = function(t3, e3, r3, f, c) { - var h = a(r3); - if (h.type === "ec") { - if (f !== "ecdsa" && f !== "ecdsa/rsa") - throw new Error("wrong public key type"); - return function(t4, e4, r4) { - var n2 = s[r4.data.algorithm.curve.join(".")]; - if (!n2) - throw new Error("unknown curve " + r4.data.algorithm.curve.join(".")); - var i2 = new o(n2), a2 = r4.data.subjectPrivateKey.data; - return i2.verify(e4, t4, a2); - }(t3, e3, h); - } - if (h.type === "dsa") { - if (f !== "dsa") - throw new Error("wrong public key type"); - return function(t4, e4, r4) { - var n2 = r4.data.p, o2 = r4.data.q, s2 = r4.data.g, f2 = r4.data.pub_key, c2 = a.signature.decode(t4, "der"), h2 = c2.s, l2 = c2.r; - u(h2, o2), u(l2, o2); - var d2 = i.mont(n2), p2 = h2.invm(o2); - return s2.toRed(d2).redPow(new i(e4).mul(p2).mod(o2)).fromRed().mul(f2.toRed(d2).redPow(l2.mul(p2).mod(o2)).fromRed()).mod(n2).mod(o2).cmp(l2) === 0; - }(t3, e3, h); - } - if (f !== "rsa" && f !== "ecdsa/rsa") - throw new Error("wrong public key type"); - e3 = n.concat([c, e3]); - for (var l = h.modulus.byteLength(), d = [1], p = 0; e3.length + d.length + 2 < l; ) - d.push(255), p++; - d.push(0); - for (var y = -1; ++y < e3.length; ) - d.push(e3[y]); - d = n.from(d); - var m = i.mont(h.modulus); - t3 = (t3 = new i(t3).toRed(m)).redPow(new i(h.publicExponent)), t3 = n.from(t3.fromRed().toArray()); - var b = p < 8 ? 1 : 0; - for (l = Math.min(t3.length, d.length), t3.length !== d.length && (b = 1), y = -1; ++y < l; ) - b |= t3[y] ^ d[y]; - return b === 0; - }; - }, 8815: function(t2, e2, r2) { - !function(t3, e3) { - function n(t4, e4) { - if (!t4) - throw new Error(e4 || "Assertion failed"); - } - function i(t4, e4) { - t4.super_ = e4; - var r3 = function() { - }; - r3.prototype = e4.prototype, t4.prototype = new r3(), t4.prototype.constructor = t4; - } - function o(t4, e4, r3) { - if (o.isBN(t4)) - return t4; - this.negative = 0, this.words = null, this.length = 0, this.red = null, t4 !== null && (e4 !== "le" && e4 !== "be" || (r3 = e4, e4 = 10), this._init(t4 || 0, e4 || 10, r3 || "be")); - } - var a; - typeof t3 == "object" ? t3.exports = o : e3.BN = o, o.BN = o, o.wordSize = 26; - try { - a = typeof window != "undefined" && window.Buffer !== void 0 ? window.Buffer : r2(2363).Buffer; - } catch (t4) { - } - function s(t4, e4) { - var r3 = t4.charCodeAt(e4); - return r3 >= 48 && r3 <= 57 ? r3 - 48 : r3 >= 65 && r3 <= 70 ? r3 - 55 : r3 >= 97 && r3 <= 102 ? r3 - 87 : void n(false, "Invalid character in " + t4); - } - function u(t4, e4, r3) { - var n2 = s(t4, r3); - return r3 - 1 >= e4 && (n2 |= s(t4, r3 - 1) << 4), n2; - } - function f(t4, e4, r3, i2) { - for (var o2 = 0, a2 = 0, s2 = Math.min(t4.length, r3), u2 = e4; u2 < s2; u2++) { - var f2 = t4.charCodeAt(u2) - 48; - o2 *= i2, a2 = f2 >= 49 ? f2 - 49 + 10 : f2 >= 17 ? f2 - 17 + 10 : f2, n(f2 >= 0 && a2 < i2, "Invalid character"), o2 += a2; - } - return o2; - } - function c(t4, e4) { - t4.words = e4.words, t4.length = e4.length, t4.negative = e4.negative, t4.red = e4.red; - } - if (o.isBN = function(t4) { - return t4 instanceof o || t4 !== null && typeof t4 == "object" && t4.constructor.wordSize === o.wordSize && Array.isArray(t4.words); - }, o.max = function(t4, e4) { - return t4.cmp(e4) > 0 ? t4 : e4; - }, o.min = function(t4, e4) { - return t4.cmp(e4) < 0 ? t4 : e4; - }, o.prototype._init = function(t4, e4, r3) { - if (typeof t4 == "number") - return this._initNumber(t4, e4, r3); - if (typeof t4 == "object") - return this._initArray(t4, e4, r3); - e4 === "hex" && (e4 = 16), n(e4 === (0 | e4) && e4 >= 2 && e4 <= 36); - var i2 = 0; - (t4 = t4.toString().replace(/\s+/g, ""))[0] === "-" && (i2++, this.negative = 1), i2 < t4.length && (e4 === 16 ? this._parseHex(t4, i2, r3) : (this._parseBase(t4, e4, i2), r3 === "le" && this._initArray(this.toArray(), e4, r3))); - }, o.prototype._initNumber = function(t4, e4, r3) { - t4 < 0 && (this.negative = 1, t4 = -t4), t4 < 67108864 ? (this.words = [67108863 & t4], this.length = 1) : t4 < 4503599627370496 ? (this.words = [67108863 & t4, t4 / 67108864 & 67108863], this.length = 2) : (n(t4 < 9007199254740992), this.words = [67108863 & t4, t4 / 67108864 & 67108863, 1], this.length = 3), r3 === "le" && this._initArray(this.toArray(), e4, r3); - }, o.prototype._initArray = function(t4, e4, r3) { - if (n(typeof t4.length == "number"), t4.length <= 0) - return this.words = [0], this.length = 1, this; - this.length = Math.ceil(t4.length / 3), this.words = new Array(this.length); - for (var i2 = 0; i2 < this.length; i2++) - this.words[i2] = 0; - var o2, a2, s2 = 0; - if (r3 === "be") - for (i2 = t4.length - 1, o2 = 0; i2 >= 0; i2 -= 3) - a2 = t4[i2] | t4[i2 - 1] << 8 | t4[i2 - 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - else if (r3 === "le") - for (i2 = 0, o2 = 0; i2 < t4.length; i2 += 3) - a2 = t4[i2] | t4[i2 + 1] << 8 | t4[i2 + 2] << 16, this.words[o2] |= a2 << s2 & 67108863, this.words[o2 + 1] = a2 >>> 26 - s2 & 67108863, (s2 += 24) >= 26 && (s2 -= 26, o2++); - return this._strip(); - }, o.prototype._parseHex = function(t4, e4, r3) { - this.length = Math.ceil((t4.length - e4) / 6), this.words = new Array(this.length); - for (var n2 = 0; n2 < this.length; n2++) - this.words[n2] = 0; - var i2, o2 = 0, a2 = 0; - if (r3 === "be") - for (n2 = t4.length - 1; n2 >= e4; n2 -= 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - else - for (n2 = (t4.length - e4) % 2 == 0 ? e4 + 1 : e4; n2 < t4.length; n2 += 2) - i2 = u(t4, e4, n2) << o2, this.words[a2] |= 67108863 & i2, o2 >= 18 ? (o2 -= 18, a2 += 1, this.words[a2] |= i2 >>> 26) : o2 += 8; - this._strip(); - }, o.prototype._parseBase = function(t4, e4, r3) { - this.words = [0], this.length = 1; - for (var n2 = 0, i2 = 1; i2 <= 67108863; i2 *= e4) - n2++; - n2--, i2 = i2 / e4 | 0; - for (var o2 = t4.length - r3, a2 = o2 % n2, s2 = Math.min(o2, o2 - a2) + r3, u2 = 0, c2 = r3; c2 < s2; c2 += n2) - u2 = f(t4, c2, c2 + n2, e4), this.imuln(i2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - if (a2 !== 0) { - var h2 = 1; - for (u2 = f(t4, c2, t4.length, e4), c2 = 0; c2 < a2; c2++) - h2 *= e4; - this.imuln(h2), this.words[0] + u2 < 67108864 ? this.words[0] += u2 : this._iaddn(u2); - } - this._strip(); - }, o.prototype.copy = function(t4) { - t4.words = new Array(this.length); - for (var e4 = 0; e4 < this.length; e4++) - t4.words[e4] = this.words[e4]; - t4.length = this.length, t4.negative = this.negative, t4.red = this.red; - }, o.prototype._move = function(t4) { - c(t4, this); - }, o.prototype.clone = function() { - var t4 = new o(null); - return this.copy(t4), t4; - }, o.prototype._expand = function(t4) { - for (; this.length < t4; ) - this.words[this.length++] = 0; - return this; - }, o.prototype._strip = function() { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) - this.length--; - return this._normSign(); - }, o.prototype._normSign = function() { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }, typeof Symbol != "undefined" && typeof Symbol.for == "function") - try { - o.prototype[Symbol.for("nodejs.util.inspect.custom")] = h; - } catch (t4) { - o.prototype.inspect = h; - } - else - o.prototype.inspect = h; - function h() { - return (this.red ? ""; - } - var l = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], d = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], p = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; - function y(t4, e4, r3) { - r3.negative = e4.negative ^ t4.negative; - var n2 = t4.length + e4.length | 0; - r3.length = n2, n2 = n2 - 1 | 0; - var i2 = 0 | t4.words[0], o2 = 0 | e4.words[0], a2 = i2 * o2, s2 = 67108863 & a2, u2 = a2 / 67108864 | 0; - r3.words[0] = s2; - for (var f2 = 1; f2 < n2; f2++) { - for (var c2 = u2 >>> 26, h2 = 67108863 & u2, l2 = Math.min(f2, e4.length - 1), d2 = Math.max(0, f2 - t4.length + 1); d2 <= l2; d2++) { - var p2 = f2 - d2 | 0; - c2 += (a2 = (i2 = 0 | t4.words[p2]) * (o2 = 0 | e4.words[d2]) + h2) / 67108864 | 0, h2 = 67108863 & a2; - } - r3.words[f2] = 0 | h2, u2 = 0 | c2; - } - return u2 !== 0 ? r3.words[f2] = 0 | u2 : r3.length--, r3._strip(); - } - o.prototype.toString = function(t4, e4) { - var r3; - if (e4 = 0 | e4 || 1, (t4 = t4 || 10) === 16 || t4 === "hex") { - r3 = ""; - for (var i2 = 0, o2 = 0, a2 = 0; a2 < this.length; a2++) { - var s2 = this.words[a2], u2 = (16777215 & (s2 << i2 | o2)).toString(16); - r3 = (o2 = s2 >>> 24 - i2 & 16777215) != 0 || a2 !== this.length - 1 ? l[6 - u2.length] + u2 + r3 : u2 + r3, (i2 += 2) >= 26 && (i2 -= 26, a2--); - } - for (o2 !== 0 && (r3 = o2.toString(16) + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - if (t4 === (0 | t4) && t4 >= 2 && t4 <= 36) { - var f2 = d[t4], c2 = p[t4]; - r3 = ""; - var h2 = this.clone(); - for (h2.negative = 0; !h2.isZero(); ) { - var y2 = h2.modrn(c2).toString(t4); - r3 = (h2 = h2.idivn(c2)).isZero() ? y2 + r3 : l[f2 - y2.length] + y2 + r3; - } - for (this.isZero() && (r3 = "0" + r3); r3.length % e4 != 0; ) - r3 = "0" + r3; - return this.negative !== 0 && (r3 = "-" + r3), r3; - } - n(false, "Base should be between 2 and 36"); - }, o.prototype.toNumber = function() { - var t4 = this.words[0]; - return this.length === 2 ? t4 += 67108864 * this.words[1] : this.length === 3 && this.words[2] === 1 ? t4 += 4503599627370496 + 67108864 * this.words[1] : this.length > 2 && n(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -t4 : t4; - }, o.prototype.toJSON = function() { - return this.toString(16, 2); - }, a && (o.prototype.toBuffer = function(t4, e4) { - return this.toArrayLike(a, t4, e4); - }), o.prototype.toArray = function(t4, e4) { - return this.toArrayLike(Array, t4, e4); - }, o.prototype.toArrayLike = function(t4, e4, r3) { - this._strip(); - var i2 = this.byteLength(), o2 = r3 || Math.max(1, i2); - n(i2 <= o2, "byte array longer than desired length"), n(o2 > 0, "Requested array length <= 0"); - var a2 = function(t5, e5) { - return t5.allocUnsafe ? t5.allocUnsafe(e5) : new t5(e5); - }(t4, o2); - return this["_toArrayLike" + (e4 === "le" ? "LE" : "BE")](a2, i2), a2; - }, o.prototype._toArrayLikeLE = function(t4, e4) { - for (var r3 = 0, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { - var a2 = this.words[i2] << o2 | n2; - t4[r3++] = 255 & a2, r3 < t4.length && (t4[r3++] = a2 >> 8 & 255), r3 < t4.length && (t4[r3++] = a2 >> 16 & 255), o2 === 6 ? (r3 < t4.length && (t4[r3++] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); - } - if (r3 < t4.length) - for (t4[r3++] = n2; r3 < t4.length; ) - t4[r3++] = 0; - }, o.prototype._toArrayLikeBE = function(t4, e4) { - for (var r3 = t4.length - 1, n2 = 0, i2 = 0, o2 = 0; i2 < this.length; i2++) { - var a2 = this.words[i2] << o2 | n2; - t4[r3--] = 255 & a2, r3 >= 0 && (t4[r3--] = a2 >> 8 & 255), r3 >= 0 && (t4[r3--] = a2 >> 16 & 255), o2 === 6 ? (r3 >= 0 && (t4[r3--] = a2 >> 24 & 255), n2 = 0, o2 = 0) : (n2 = a2 >>> 24, o2 += 2); - } - if (r3 >= 0) - for (t4[r3--] = n2; r3 >= 0; ) - t4[r3--] = 0; - }, Math.clz32 ? o.prototype._countBits = function(t4) { - return 32 - Math.clz32(t4); - } : o.prototype._countBits = function(t4) { - var e4 = t4, r3 = 0; - return e4 >= 4096 && (r3 += 13, e4 >>>= 13), e4 >= 64 && (r3 += 7, e4 >>>= 7), e4 >= 8 && (r3 += 4, e4 >>>= 4), e4 >= 2 && (r3 += 2, e4 >>>= 2), r3 + e4; - }, o.prototype._zeroBits = function(t4) { - if (t4 === 0) - return 26; - var e4 = t4, r3 = 0; - return (8191 & e4) == 0 && (r3 += 13, e4 >>>= 13), (127 & e4) == 0 && (r3 += 7, e4 >>>= 7), (15 & e4) == 0 && (r3 += 4, e4 >>>= 4), (3 & e4) == 0 && (r3 += 2, e4 >>>= 2), (1 & e4) == 0 && r3++, r3; - }, o.prototype.bitLength = function() { - var t4 = this.words[this.length - 1], e4 = this._countBits(t4); - return 26 * (this.length - 1) + e4; - }, o.prototype.zeroBits = function() { - if (this.isZero()) - return 0; - for (var t4 = 0, e4 = 0; e4 < this.length; e4++) { - var r3 = this._zeroBits(this.words[e4]); - if (t4 += r3, r3 !== 26) - break; - } - return t4; - }, o.prototype.byteLength = function() { - return Math.ceil(this.bitLength() / 8); - }, o.prototype.toTwos = function(t4) { - return this.negative !== 0 ? this.abs().inotn(t4).iaddn(1) : this.clone(); - }, o.prototype.fromTwos = function(t4) { - return this.testn(t4 - 1) ? this.notn(t4).iaddn(1).ineg() : this.clone(); - }, o.prototype.isNeg = function() { - return this.negative !== 0; - }, o.prototype.neg = function() { - return this.clone().ineg(); - }, o.prototype.ineg = function() { - return this.isZero() || (this.negative ^= 1), this; - }, o.prototype.iuor = function(t4) { - for (; this.length < t4.length; ) - this.words[this.length++] = 0; - for (var e4 = 0; e4 < t4.length; e4++) - this.words[e4] = this.words[e4] | t4.words[e4]; - return this._strip(); - }, o.prototype.ior = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuor(t4); - }, o.prototype.or = function(t4) { - return this.length > t4.length ? this.clone().ior(t4) : t4.clone().ior(this); - }, o.prototype.uor = function(t4) { - return this.length > t4.length ? this.clone().iuor(t4) : t4.clone().iuor(this); - }, o.prototype.iuand = function(t4) { - var e4; - e4 = this.length > t4.length ? t4 : this; - for (var r3 = 0; r3 < e4.length; r3++) - this.words[r3] = this.words[r3] & t4.words[r3]; - return this.length = e4.length, this._strip(); - }, o.prototype.iand = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuand(t4); - }, o.prototype.and = function(t4) { - return this.length > t4.length ? this.clone().iand(t4) : t4.clone().iand(this); - }, o.prototype.uand = function(t4) { - return this.length > t4.length ? this.clone().iuand(t4) : t4.clone().iuand(this); - }, o.prototype.iuxor = function(t4) { - var e4, r3; - this.length > t4.length ? (e4 = this, r3 = t4) : (e4 = t4, r3 = this); - for (var n2 = 0; n2 < r3.length; n2++) - this.words[n2] = e4.words[n2] ^ r3.words[n2]; - if (this !== e4) - for (; n2 < e4.length; n2++) - this.words[n2] = e4.words[n2]; - return this.length = e4.length, this._strip(); - }, o.prototype.ixor = function(t4) { - return n((this.negative | t4.negative) == 0), this.iuxor(t4); - }, o.prototype.xor = function(t4) { - return this.length > t4.length ? this.clone().ixor(t4) : t4.clone().ixor(this); - }, o.prototype.uxor = function(t4) { - return this.length > t4.length ? this.clone().iuxor(t4) : t4.clone().iuxor(this); - }, o.prototype.inotn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = 0 | Math.ceil(t4 / 26), r3 = t4 % 26; - this._expand(e4), r3 > 0 && e4--; - for (var i2 = 0; i2 < e4; i2++) - this.words[i2] = 67108863 & ~this.words[i2]; - return r3 > 0 && (this.words[i2] = ~this.words[i2] & 67108863 >> 26 - r3), this._strip(); - }, o.prototype.notn = function(t4) { - return this.clone().inotn(t4); - }, o.prototype.setn = function(t4, e4) { - n(typeof t4 == "number" && t4 >= 0); - var r3 = t4 / 26 | 0, i2 = t4 % 26; - return this._expand(r3 + 1), this.words[r3] = e4 ? this.words[r3] | 1 << i2 : this.words[r3] & ~(1 << i2), this._strip(); - }, o.prototype.iadd = function(t4) { - var e4, r3, n2; - if (this.negative !== 0 && t4.negative === 0) - return this.negative = 0, e4 = this.isub(t4), this.negative ^= 1, this._normSign(); - if (this.negative === 0 && t4.negative !== 0) - return t4.negative = 0, e4 = this.isub(t4), t4.negative = 1, e4._normSign(); - this.length > t4.length ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var i2 = 0, o2 = 0; o2 < n2.length; o2++) - e4 = (0 | r3.words[o2]) + (0 | n2.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - for (; i2 !== 0 && o2 < r3.length; o2++) - e4 = (0 | r3.words[o2]) + i2, this.words[o2] = 67108863 & e4, i2 = e4 >>> 26; - if (this.length = r3.length, i2 !== 0) - this.words[this.length] = i2, this.length++; - else if (r3 !== this) - for (; o2 < r3.length; o2++) - this.words[o2] = r3.words[o2]; - return this; - }, o.prototype.add = function(t4) { - var e4; - return t4.negative !== 0 && this.negative === 0 ? (t4.negative = 0, e4 = this.sub(t4), t4.negative ^= 1, e4) : t4.negative === 0 && this.negative !== 0 ? (this.negative = 0, e4 = t4.sub(this), this.negative = 1, e4) : this.length > t4.length ? this.clone().iadd(t4) : t4.clone().iadd(this); - }, o.prototype.isub = function(t4) { - if (t4.negative !== 0) { - t4.negative = 0; - var e4 = this.iadd(t4); - return t4.negative = 1, e4._normSign(); - } - if (this.negative !== 0) - return this.negative = 0, this.iadd(t4), this.negative = 1, this._normSign(); - var r3, n2, i2 = this.cmp(t4); - if (i2 === 0) - return this.negative = 0, this.length = 1, this.words[0] = 0, this; - i2 > 0 ? (r3 = this, n2 = t4) : (r3 = t4, n2 = this); - for (var o2 = 0, a2 = 0; a2 < n2.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) - (0 | n2.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - for (; o2 !== 0 && a2 < r3.length; a2++) - o2 = (e4 = (0 | r3.words[a2]) + o2) >> 26, this.words[a2] = 67108863 & e4; - if (o2 === 0 && a2 < r3.length && r3 !== this) - for (; a2 < r3.length; a2++) - this.words[a2] = r3.words[a2]; - return this.length = Math.max(this.length, a2), r3 !== this && (this.negative = 1), this._strip(); - }, o.prototype.sub = function(t4) { - return this.clone().isub(t4); - }; - var m = function(t4, e4, r3) { - var n2, i2, o2, a2 = t4.words, s2 = e4.words, u2 = r3.words, f2 = 0, c2 = 0 | a2[0], h2 = 8191 & c2, l2 = c2 >>> 13, d2 = 0 | a2[1], p2 = 8191 & d2, y2 = d2 >>> 13, m2 = 0 | a2[2], b2 = 8191 & m2, g2 = m2 >>> 13, v = 0 | a2[3], w2 = 8191 & v, _2 = v >>> 13, M2 = 0 | a2[4], S2 = 8191 & M2, E2 = M2 >>> 13, A2 = 0 | a2[5], k2 = 8191 & A2, B2 = A2 >>> 13, T = 0 | a2[6], x = 8191 & T, O = T >>> 13, R = 0 | a2[7], P = 8191 & R, I = R >>> 13, j = 0 | a2[8], U = 8191 & j, N = j >>> 13, C = 0 | a2[9], D = 8191 & C, L = C >>> 13, K = 0 | s2[0], z = 8191 & K, q = K >>> 13, H = 0 | s2[1], F = 8191 & H, V = H >>> 13, W = 0 | s2[2], J = 8191 & W, $ = W >>> 13, G = 0 | s2[3], Z = 8191 & G, Y = G >>> 13, X = 0 | s2[4], Q = 8191 & X, tt = X >>> 13, et = 0 | s2[5], rt = 8191 & et, nt = et >>> 13, it = 0 | s2[6], ot = 8191 & it, at = it >>> 13, st = 0 | s2[7], ut = 8191 & st, ft = st >>> 13, ct = 0 | s2[8], ht = 8191 & ct, lt = ct >>> 13, dt = 0 | s2[9], pt = 8191 & dt, yt = dt >>> 13; - r3.negative = t4.negative ^ e4.negative, r3.length = 19; - var mt = (f2 + (n2 = Math.imul(h2, z)) | 0) + ((8191 & (i2 = (i2 = Math.imul(h2, q)) + Math.imul(l2, z) | 0)) << 13) | 0; - f2 = ((o2 = Math.imul(l2, q)) + (i2 >>> 13) | 0) + (mt >>> 26) | 0, mt &= 67108863, n2 = Math.imul(p2, z), i2 = (i2 = Math.imul(p2, q)) + Math.imul(y2, z) | 0, o2 = Math.imul(y2, q); - var bt = (f2 + (n2 = n2 + Math.imul(h2, F) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, V) | 0) + Math.imul(l2, F) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, V) | 0) + (i2 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, n2 = Math.imul(b2, z), i2 = (i2 = Math.imul(b2, q)) + Math.imul(g2, z) | 0, o2 = Math.imul(g2, q), n2 = n2 + Math.imul(p2, F) | 0, i2 = (i2 = i2 + Math.imul(p2, V) | 0) + Math.imul(y2, F) | 0, o2 = o2 + Math.imul(y2, V) | 0; - var gt = (f2 + (n2 = n2 + Math.imul(h2, J) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, $) | 0) + Math.imul(l2, J) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, $) | 0) + (i2 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, n2 = Math.imul(w2, z), i2 = (i2 = Math.imul(w2, q)) + Math.imul(_2, z) | 0, o2 = Math.imul(_2, q), n2 = n2 + Math.imul(b2, F) | 0, i2 = (i2 = i2 + Math.imul(b2, V) | 0) + Math.imul(g2, F) | 0, o2 = o2 + Math.imul(g2, V) | 0, n2 = n2 + Math.imul(p2, J) | 0, i2 = (i2 = i2 + Math.imul(p2, $) | 0) + Math.imul(y2, J) | 0, o2 = o2 + Math.imul(y2, $) | 0; - var vt = (f2 + (n2 = n2 + Math.imul(h2, Z) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, Y) | 0) + Math.imul(l2, Z) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, Y) | 0) + (i2 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, n2 = Math.imul(S2, z), i2 = (i2 = Math.imul(S2, q)) + Math.imul(E2, z) | 0, o2 = Math.imul(E2, q), n2 = n2 + Math.imul(w2, F) | 0, i2 = (i2 = i2 + Math.imul(w2, V) | 0) + Math.imul(_2, F) | 0, o2 = o2 + Math.imul(_2, V) | 0, n2 = n2 + Math.imul(b2, J) | 0, i2 = (i2 = i2 + Math.imul(b2, $) | 0) + Math.imul(g2, J) | 0, o2 = o2 + Math.imul(g2, $) | 0, n2 = n2 + Math.imul(p2, Z) | 0, i2 = (i2 = i2 + Math.imul(p2, Y) | 0) + Math.imul(y2, Z) | 0, o2 = o2 + Math.imul(y2, Y) | 0; - var wt = (f2 + (n2 = n2 + Math.imul(h2, Q) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, tt) | 0) + Math.imul(l2, Q) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, tt) | 0) + (i2 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, n2 = Math.imul(k2, z), i2 = (i2 = Math.imul(k2, q)) + Math.imul(B2, z) | 0, o2 = Math.imul(B2, q), n2 = n2 + Math.imul(S2, F) | 0, i2 = (i2 = i2 + Math.imul(S2, V) | 0) + Math.imul(E2, F) | 0, o2 = o2 + Math.imul(E2, V) | 0, n2 = n2 + Math.imul(w2, J) | 0, i2 = (i2 = i2 + Math.imul(w2, $) | 0) + Math.imul(_2, J) | 0, o2 = o2 + Math.imul(_2, $) | 0, n2 = n2 + Math.imul(b2, Z) | 0, i2 = (i2 = i2 + Math.imul(b2, Y) | 0) + Math.imul(g2, Z) | 0, o2 = o2 + Math.imul(g2, Y) | 0, n2 = n2 + Math.imul(p2, Q) | 0, i2 = (i2 = i2 + Math.imul(p2, tt) | 0) + Math.imul(y2, Q) | 0, o2 = o2 + Math.imul(y2, tt) | 0; - var _t = (f2 + (n2 = n2 + Math.imul(h2, rt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, nt) | 0) + Math.imul(l2, rt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, nt) | 0) + (i2 >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, n2 = Math.imul(x, z), i2 = (i2 = Math.imul(x, q)) + Math.imul(O, z) | 0, o2 = Math.imul(O, q), n2 = n2 + Math.imul(k2, F) | 0, i2 = (i2 = i2 + Math.imul(k2, V) | 0) + Math.imul(B2, F) | 0, o2 = o2 + Math.imul(B2, V) | 0, n2 = n2 + Math.imul(S2, J) | 0, i2 = (i2 = i2 + Math.imul(S2, $) | 0) + Math.imul(E2, J) | 0, o2 = o2 + Math.imul(E2, $) | 0, n2 = n2 + Math.imul(w2, Z) | 0, i2 = (i2 = i2 + Math.imul(w2, Y) | 0) + Math.imul(_2, Z) | 0, o2 = o2 + Math.imul(_2, Y) | 0, n2 = n2 + Math.imul(b2, Q) | 0, i2 = (i2 = i2 + Math.imul(b2, tt) | 0) + Math.imul(g2, Q) | 0, o2 = o2 + Math.imul(g2, tt) | 0, n2 = n2 + Math.imul(p2, rt) | 0, i2 = (i2 = i2 + Math.imul(p2, nt) | 0) + Math.imul(y2, rt) | 0, o2 = o2 + Math.imul(y2, nt) | 0; - var Mt = (f2 + (n2 = n2 + Math.imul(h2, ot) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, at) | 0) + Math.imul(l2, ot) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, at) | 0) + (i2 >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, n2 = Math.imul(P, z), i2 = (i2 = Math.imul(P, q)) + Math.imul(I, z) | 0, o2 = Math.imul(I, q), n2 = n2 + Math.imul(x, F) | 0, i2 = (i2 = i2 + Math.imul(x, V) | 0) + Math.imul(O, F) | 0, o2 = o2 + Math.imul(O, V) | 0, n2 = n2 + Math.imul(k2, J) | 0, i2 = (i2 = i2 + Math.imul(k2, $) | 0) + Math.imul(B2, J) | 0, o2 = o2 + Math.imul(B2, $) | 0, n2 = n2 + Math.imul(S2, Z) | 0, i2 = (i2 = i2 + Math.imul(S2, Y) | 0) + Math.imul(E2, Z) | 0, o2 = o2 + Math.imul(E2, Y) | 0, n2 = n2 + Math.imul(w2, Q) | 0, i2 = (i2 = i2 + Math.imul(w2, tt) | 0) + Math.imul(_2, Q) | 0, o2 = o2 + Math.imul(_2, tt) | 0, n2 = n2 + Math.imul(b2, rt) | 0, i2 = (i2 = i2 + Math.imul(b2, nt) | 0) + Math.imul(g2, rt) | 0, o2 = o2 + Math.imul(g2, nt) | 0, n2 = n2 + Math.imul(p2, ot) | 0, i2 = (i2 = i2 + Math.imul(p2, at) | 0) + Math.imul(y2, ot) | 0, o2 = o2 + Math.imul(y2, at) | 0; - var St = (f2 + (n2 = n2 + Math.imul(h2, ut) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, ft) | 0) + Math.imul(l2, ut) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, ft) | 0) + (i2 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, n2 = Math.imul(U, z), i2 = (i2 = Math.imul(U, q)) + Math.imul(N, z) | 0, o2 = Math.imul(N, q), n2 = n2 + Math.imul(P, F) | 0, i2 = (i2 = i2 + Math.imul(P, V) | 0) + Math.imul(I, F) | 0, o2 = o2 + Math.imul(I, V) | 0, n2 = n2 + Math.imul(x, J) | 0, i2 = (i2 = i2 + Math.imul(x, $) | 0) + Math.imul(O, J) | 0, o2 = o2 + Math.imul(O, $) | 0, n2 = n2 + Math.imul(k2, Z) | 0, i2 = (i2 = i2 + Math.imul(k2, Y) | 0) + Math.imul(B2, Z) | 0, o2 = o2 + Math.imul(B2, Y) | 0, n2 = n2 + Math.imul(S2, Q) | 0, i2 = (i2 = i2 + Math.imul(S2, tt) | 0) + Math.imul(E2, Q) | 0, o2 = o2 + Math.imul(E2, tt) | 0, n2 = n2 + Math.imul(w2, rt) | 0, i2 = (i2 = i2 + Math.imul(w2, nt) | 0) + Math.imul(_2, rt) | 0, o2 = o2 + Math.imul(_2, nt) | 0, n2 = n2 + Math.imul(b2, ot) | 0, i2 = (i2 = i2 + Math.imul(b2, at) | 0) + Math.imul(g2, ot) | 0, o2 = o2 + Math.imul(g2, at) | 0, n2 = n2 + Math.imul(p2, ut) | 0, i2 = (i2 = i2 + Math.imul(p2, ft) | 0) + Math.imul(y2, ut) | 0, o2 = o2 + Math.imul(y2, ft) | 0; - var Et = (f2 + (n2 = n2 + Math.imul(h2, ht) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, lt) | 0) + Math.imul(l2, ht) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, lt) | 0) + (i2 >>> 13) | 0) + (Et >>> 26) | 0, Et &= 67108863, n2 = Math.imul(D, z), i2 = (i2 = Math.imul(D, q)) + Math.imul(L, z) | 0, o2 = Math.imul(L, q), n2 = n2 + Math.imul(U, F) | 0, i2 = (i2 = i2 + Math.imul(U, V) | 0) + Math.imul(N, F) | 0, o2 = o2 + Math.imul(N, V) | 0, n2 = n2 + Math.imul(P, J) | 0, i2 = (i2 = i2 + Math.imul(P, $) | 0) + Math.imul(I, J) | 0, o2 = o2 + Math.imul(I, $) | 0, n2 = n2 + Math.imul(x, Z) | 0, i2 = (i2 = i2 + Math.imul(x, Y) | 0) + Math.imul(O, Z) | 0, o2 = o2 + Math.imul(O, Y) | 0, n2 = n2 + Math.imul(k2, Q) | 0, i2 = (i2 = i2 + Math.imul(k2, tt) | 0) + Math.imul(B2, Q) | 0, o2 = o2 + Math.imul(B2, tt) | 0, n2 = n2 + Math.imul(S2, rt) | 0, i2 = (i2 = i2 + Math.imul(S2, nt) | 0) + Math.imul(E2, rt) | 0, o2 = o2 + Math.imul(E2, nt) | 0, n2 = n2 + Math.imul(w2, ot) | 0, i2 = (i2 = i2 + Math.imul(w2, at) | 0) + Math.imul(_2, ot) | 0, o2 = o2 + Math.imul(_2, at) | 0, n2 = n2 + Math.imul(b2, ut) | 0, i2 = (i2 = i2 + Math.imul(b2, ft) | 0) + Math.imul(g2, ut) | 0, o2 = o2 + Math.imul(g2, ft) | 0, n2 = n2 + Math.imul(p2, ht) | 0, i2 = (i2 = i2 + Math.imul(p2, lt) | 0) + Math.imul(y2, ht) | 0, o2 = o2 + Math.imul(y2, lt) | 0; - var At = (f2 + (n2 = n2 + Math.imul(h2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(h2, yt) | 0) + Math.imul(l2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(l2, yt) | 0) + (i2 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, n2 = Math.imul(D, F), i2 = (i2 = Math.imul(D, V)) + Math.imul(L, F) | 0, o2 = Math.imul(L, V), n2 = n2 + Math.imul(U, J) | 0, i2 = (i2 = i2 + Math.imul(U, $) | 0) + Math.imul(N, J) | 0, o2 = o2 + Math.imul(N, $) | 0, n2 = n2 + Math.imul(P, Z) | 0, i2 = (i2 = i2 + Math.imul(P, Y) | 0) + Math.imul(I, Z) | 0, o2 = o2 + Math.imul(I, Y) | 0, n2 = n2 + Math.imul(x, Q) | 0, i2 = (i2 = i2 + Math.imul(x, tt) | 0) + Math.imul(O, Q) | 0, o2 = o2 + Math.imul(O, tt) | 0, n2 = n2 + Math.imul(k2, rt) | 0, i2 = (i2 = i2 + Math.imul(k2, nt) | 0) + Math.imul(B2, rt) | 0, o2 = o2 + Math.imul(B2, nt) | 0, n2 = n2 + Math.imul(S2, ot) | 0, i2 = (i2 = i2 + Math.imul(S2, at) | 0) + Math.imul(E2, ot) | 0, o2 = o2 + Math.imul(E2, at) | 0, n2 = n2 + Math.imul(w2, ut) | 0, i2 = (i2 = i2 + Math.imul(w2, ft) | 0) + Math.imul(_2, ut) | 0, o2 = o2 + Math.imul(_2, ft) | 0, n2 = n2 + Math.imul(b2, ht) | 0, i2 = (i2 = i2 + Math.imul(b2, lt) | 0) + Math.imul(g2, ht) | 0, o2 = o2 + Math.imul(g2, lt) | 0; - var kt = (f2 + (n2 = n2 + Math.imul(p2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(p2, yt) | 0) + Math.imul(y2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(y2, yt) | 0) + (i2 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, n2 = Math.imul(D, J), i2 = (i2 = Math.imul(D, $)) + Math.imul(L, J) | 0, o2 = Math.imul(L, $), n2 = n2 + Math.imul(U, Z) | 0, i2 = (i2 = i2 + Math.imul(U, Y) | 0) + Math.imul(N, Z) | 0, o2 = o2 + Math.imul(N, Y) | 0, n2 = n2 + Math.imul(P, Q) | 0, i2 = (i2 = i2 + Math.imul(P, tt) | 0) + Math.imul(I, Q) | 0, o2 = o2 + Math.imul(I, tt) | 0, n2 = n2 + Math.imul(x, rt) | 0, i2 = (i2 = i2 + Math.imul(x, nt) | 0) + Math.imul(O, rt) | 0, o2 = o2 + Math.imul(O, nt) | 0, n2 = n2 + Math.imul(k2, ot) | 0, i2 = (i2 = i2 + Math.imul(k2, at) | 0) + Math.imul(B2, ot) | 0, o2 = o2 + Math.imul(B2, at) | 0, n2 = n2 + Math.imul(S2, ut) | 0, i2 = (i2 = i2 + Math.imul(S2, ft) | 0) + Math.imul(E2, ut) | 0, o2 = o2 + Math.imul(E2, ft) | 0, n2 = n2 + Math.imul(w2, ht) | 0, i2 = (i2 = i2 + Math.imul(w2, lt) | 0) + Math.imul(_2, ht) | 0, o2 = o2 + Math.imul(_2, lt) | 0; - var Bt = (f2 + (n2 = n2 + Math.imul(b2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(b2, yt) | 0) + Math.imul(g2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(g2, yt) | 0) + (i2 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, n2 = Math.imul(D, Z), i2 = (i2 = Math.imul(D, Y)) + Math.imul(L, Z) | 0, o2 = Math.imul(L, Y), n2 = n2 + Math.imul(U, Q) | 0, i2 = (i2 = i2 + Math.imul(U, tt) | 0) + Math.imul(N, Q) | 0, o2 = o2 + Math.imul(N, tt) | 0, n2 = n2 + Math.imul(P, rt) | 0, i2 = (i2 = i2 + Math.imul(P, nt) | 0) + Math.imul(I, rt) | 0, o2 = o2 + Math.imul(I, nt) | 0, n2 = n2 + Math.imul(x, ot) | 0, i2 = (i2 = i2 + Math.imul(x, at) | 0) + Math.imul(O, ot) | 0, o2 = o2 + Math.imul(O, at) | 0, n2 = n2 + Math.imul(k2, ut) | 0, i2 = (i2 = i2 + Math.imul(k2, ft) | 0) + Math.imul(B2, ut) | 0, o2 = o2 + Math.imul(B2, ft) | 0, n2 = n2 + Math.imul(S2, ht) | 0, i2 = (i2 = i2 + Math.imul(S2, lt) | 0) + Math.imul(E2, ht) | 0, o2 = o2 + Math.imul(E2, lt) | 0; - var Tt = (f2 + (n2 = n2 + Math.imul(w2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(w2, yt) | 0) + Math.imul(_2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(_2, yt) | 0) + (i2 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, n2 = Math.imul(D, Q), i2 = (i2 = Math.imul(D, tt)) + Math.imul(L, Q) | 0, o2 = Math.imul(L, tt), n2 = n2 + Math.imul(U, rt) | 0, i2 = (i2 = i2 + Math.imul(U, nt) | 0) + Math.imul(N, rt) | 0, o2 = o2 + Math.imul(N, nt) | 0, n2 = n2 + Math.imul(P, ot) | 0, i2 = (i2 = i2 + Math.imul(P, at) | 0) + Math.imul(I, ot) | 0, o2 = o2 + Math.imul(I, at) | 0, n2 = n2 + Math.imul(x, ut) | 0, i2 = (i2 = i2 + Math.imul(x, ft) | 0) + Math.imul(O, ut) | 0, o2 = o2 + Math.imul(O, ft) | 0, n2 = n2 + Math.imul(k2, ht) | 0, i2 = (i2 = i2 + Math.imul(k2, lt) | 0) + Math.imul(B2, ht) | 0, o2 = o2 + Math.imul(B2, lt) | 0; - var xt = (f2 + (n2 = n2 + Math.imul(S2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(S2, yt) | 0) + Math.imul(E2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(E2, yt) | 0) + (i2 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, n2 = Math.imul(D, rt), i2 = (i2 = Math.imul(D, nt)) + Math.imul(L, rt) | 0, o2 = Math.imul(L, nt), n2 = n2 + Math.imul(U, ot) | 0, i2 = (i2 = i2 + Math.imul(U, at) | 0) + Math.imul(N, ot) | 0, o2 = o2 + Math.imul(N, at) | 0, n2 = n2 + Math.imul(P, ut) | 0, i2 = (i2 = i2 + Math.imul(P, ft) | 0) + Math.imul(I, ut) | 0, o2 = o2 + Math.imul(I, ft) | 0, n2 = n2 + Math.imul(x, ht) | 0, i2 = (i2 = i2 + Math.imul(x, lt) | 0) + Math.imul(O, ht) | 0, o2 = o2 + Math.imul(O, lt) | 0; - var Ot = (f2 + (n2 = n2 + Math.imul(k2, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(k2, yt) | 0) + Math.imul(B2, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(B2, yt) | 0) + (i2 >>> 13) | 0) + (Ot >>> 26) | 0, Ot &= 67108863, n2 = Math.imul(D, ot), i2 = (i2 = Math.imul(D, at)) + Math.imul(L, ot) | 0, o2 = Math.imul(L, at), n2 = n2 + Math.imul(U, ut) | 0, i2 = (i2 = i2 + Math.imul(U, ft) | 0) + Math.imul(N, ut) | 0, o2 = o2 + Math.imul(N, ft) | 0, n2 = n2 + Math.imul(P, ht) | 0, i2 = (i2 = i2 + Math.imul(P, lt) | 0) + Math.imul(I, ht) | 0, o2 = o2 + Math.imul(I, lt) | 0; - var Rt = (f2 + (n2 = n2 + Math.imul(x, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(x, yt) | 0) + Math.imul(O, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(O, yt) | 0) + (i2 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, n2 = Math.imul(D, ut), i2 = (i2 = Math.imul(D, ft)) + Math.imul(L, ut) | 0, o2 = Math.imul(L, ft), n2 = n2 + Math.imul(U, ht) | 0, i2 = (i2 = i2 + Math.imul(U, lt) | 0) + Math.imul(N, ht) | 0, o2 = o2 + Math.imul(N, lt) | 0; - var Pt = (f2 + (n2 = n2 + Math.imul(P, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(P, yt) | 0) + Math.imul(I, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(I, yt) | 0) + (i2 >>> 13) | 0) + (Pt >>> 26) | 0, Pt &= 67108863, n2 = Math.imul(D, ht), i2 = (i2 = Math.imul(D, lt)) + Math.imul(L, ht) | 0, o2 = Math.imul(L, lt); - var It = (f2 + (n2 = n2 + Math.imul(U, pt) | 0) | 0) + ((8191 & (i2 = (i2 = i2 + Math.imul(U, yt) | 0) + Math.imul(N, pt) | 0)) << 13) | 0; - f2 = ((o2 = o2 + Math.imul(N, yt) | 0) + (i2 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; - var jt = (f2 + (n2 = Math.imul(D, pt)) | 0) + ((8191 & (i2 = (i2 = Math.imul(D, yt)) + Math.imul(L, pt) | 0)) << 13) | 0; - return f2 = ((o2 = Math.imul(L, yt)) + (i2 >>> 13) | 0) + (jt >>> 26) | 0, jt &= 67108863, u2[0] = mt, u2[1] = bt, u2[2] = gt, u2[3] = vt, u2[4] = wt, u2[5] = _t, u2[6] = Mt, u2[7] = St, u2[8] = Et, u2[9] = At, u2[10] = kt, u2[11] = Bt, u2[12] = Tt, u2[13] = xt, u2[14] = Ot, u2[15] = Rt, u2[16] = Pt, u2[17] = It, u2[18] = jt, f2 !== 0 && (u2[19] = f2, r3.length++), r3; - }; - function b(t4, e4, r3) { - r3.negative = e4.negative ^ t4.negative, r3.length = t4.length + e4.length; - for (var n2 = 0, i2 = 0, o2 = 0; o2 < r3.length - 1; o2++) { - var a2 = i2; - i2 = 0; - for (var s2 = 67108863 & n2, u2 = Math.min(o2, e4.length - 1), f2 = Math.max(0, o2 - t4.length + 1); f2 <= u2; f2++) { - var c2 = o2 - f2, h2 = (0 | t4.words[c2]) * (0 | e4.words[f2]), l2 = 67108863 & h2; - s2 = 67108863 & (l2 = l2 + s2 | 0), i2 += (a2 = (a2 = a2 + (h2 / 67108864 | 0) | 0) + (l2 >>> 26) | 0) >>> 26, a2 &= 67108863; - } - r3.words[o2] = s2, n2 = a2, a2 = i2; - } - return n2 !== 0 ? r3.words[o2] = n2 : r3.length--, r3._strip(); - } - function g(t4, e4, r3) { - return b(t4, e4, r3); - } - Math.imul || (m = y), o.prototype.mulTo = function(t4, e4) { - var r3 = this.length + t4.length; - return this.length === 10 && t4.length === 10 ? m(this, t4, e4) : r3 < 63 ? y(this, t4, e4) : r3 < 1024 ? b(this, t4, e4) : g(this, t4, e4); - }, o.prototype.mul = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), this.mulTo(t4, e4); - }, o.prototype.mulf = function(t4) { - var e4 = new o(null); - return e4.words = new Array(this.length + t4.length), g(this, t4, e4); - }, o.prototype.imul = function(t4) { - return this.clone().mulTo(t4, this); - }, o.prototype.imuln = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(typeof t4 == "number"), n(t4 < 67108864); - for (var r3 = 0, i2 = 0; i2 < this.length; i2++) { - var o2 = (0 | this.words[i2]) * t4, a2 = (67108863 & o2) + (67108863 & r3); - r3 >>= 26, r3 += o2 / 67108864 | 0, r3 += a2 >>> 26, this.words[i2] = 67108863 & a2; - } - return r3 !== 0 && (this.words[i2] = r3, this.length++), e4 ? this.ineg() : this; - }, o.prototype.muln = function(t4) { - return this.clone().imuln(t4); - }, o.prototype.sqr = function() { - return this.mul(this); - }, o.prototype.isqr = function() { - return this.imul(this.clone()); - }, o.prototype.pow = function(t4) { - var e4 = function(t5) { - for (var e5 = new Array(t5.bitLength()), r4 = 0; r4 < e5.length; r4++) { - var n3 = r4 / 26 | 0, i3 = r4 % 26; - e5[r4] = t5.words[n3] >>> i3 & 1; - } - return e5; - }(t4); - if (e4.length === 0) - return new o(1); - for (var r3 = this, n2 = 0; n2 < e4.length && e4[n2] === 0; n2++, r3 = r3.sqr()) - ; - if (++n2 < e4.length) - for (var i2 = r3.sqr(); n2 < e4.length; n2++, i2 = i2.sqr()) - e4[n2] !== 0 && (r3 = r3.mul(i2)); - return r3; - }, o.prototype.iushln = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4, r3 = t4 % 26, i2 = (t4 - r3) / 26, o2 = 67108863 >>> 26 - r3 << 26 - r3; - if (r3 !== 0) { - var a2 = 0; - for (e4 = 0; e4 < this.length; e4++) { - var s2 = this.words[e4] & o2, u2 = (0 | this.words[e4]) - s2 << r3; - this.words[e4] = u2 | a2, a2 = s2 >>> 26 - r3; - } - a2 && (this.words[e4] = a2, this.length++); - } - if (i2 !== 0) { - for (e4 = this.length - 1; e4 >= 0; e4--) - this.words[e4 + i2] = this.words[e4]; - for (e4 = 0; e4 < i2; e4++) - this.words[e4] = 0; - this.length += i2; - } - return this._strip(); - }, o.prototype.ishln = function(t4) { - return n(this.negative === 0), this.iushln(t4); - }, o.prototype.iushrn = function(t4, e4, r3) { - var i2; - n(typeof t4 == "number" && t4 >= 0), i2 = e4 ? (e4 - e4 % 26) / 26 : 0; - var o2 = t4 % 26, a2 = Math.min((t4 - o2) / 26, this.length), s2 = 67108863 ^ 67108863 >>> o2 << o2, u2 = r3; - if (i2 -= a2, i2 = Math.max(0, i2), u2) { - for (var f2 = 0; f2 < a2; f2++) - u2.words[f2] = this.words[f2]; - u2.length = a2; - } - if (a2 === 0) - ; - else if (this.length > a2) - for (this.length -= a2, f2 = 0; f2 < this.length; f2++) - this.words[f2] = this.words[f2 + a2]; - else - this.words[0] = 0, this.length = 1; - var c2 = 0; - for (f2 = this.length - 1; f2 >= 0 && (c2 !== 0 || f2 >= i2); f2--) { - var h2 = 0 | this.words[f2]; - this.words[f2] = c2 << 26 - o2 | h2 >>> o2, c2 = h2 & s2; - } - return u2 && c2 !== 0 && (u2.words[u2.length++] = c2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); - }, o.prototype.ishrn = function(t4, e4, r3) { - return n(this.negative === 0), this.iushrn(t4, e4, r3); - }, o.prototype.shln = function(t4) { - return this.clone().ishln(t4); - }, o.prototype.ushln = function(t4) { - return this.clone().iushln(t4); - }, o.prototype.shrn = function(t4) { - return this.clone().ishrn(t4); - }, o.prototype.ushrn = function(t4) { - return this.clone().iushrn(t4); - }, o.prototype.testn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - return !(this.length <= r3 || !(this.words[r3] & i2)); - }, o.prototype.imaskn = function(t4) { - n(typeof t4 == "number" && t4 >= 0); - var e4 = t4 % 26, r3 = (t4 - e4) / 26; - if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= r3) - return this; - if (e4 !== 0 && r3++, this.length = Math.min(r3, this.length), e4 !== 0) { - var i2 = 67108863 ^ 67108863 >>> e4 << e4; - this.words[this.length - 1] &= i2; - } - return this._strip(); - }, o.prototype.maskn = function(t4) { - return this.clone().imaskn(t4); - }, o.prototype.iaddn = function(t4) { - return n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0 ? this.isubn(-t4) : this.negative !== 0 ? this.length === 1 && (0 | this.words[0]) <= t4 ? (this.words[0] = t4 - (0 | this.words[0]), this.negative = 0, this) : (this.negative = 0, this.isubn(t4), this.negative = 1, this) : this._iaddn(t4); - }, o.prototype._iaddn = function(t4) { - this.words[0] += t4; - for (var e4 = 0; e4 < this.length && this.words[e4] >= 67108864; e4++) - this.words[e4] -= 67108864, e4 === this.length - 1 ? this.words[e4 + 1] = 1 : this.words[e4 + 1]++; - return this.length = Math.max(this.length, e4 + 1), this; - }, o.prototype.isubn = function(t4) { - if (n(typeof t4 == "number"), n(t4 < 67108864), t4 < 0) - return this.iaddn(-t4); - if (this.negative !== 0) - return this.negative = 0, this.iaddn(t4), this.negative = 1, this; - if (this.words[0] -= t4, this.length === 1 && this.words[0] < 0) - this.words[0] = -this.words[0], this.negative = 1; - else - for (var e4 = 0; e4 < this.length && this.words[e4] < 0; e4++) - this.words[e4] += 67108864, this.words[e4 + 1] -= 1; - return this._strip(); - }, o.prototype.addn = function(t4) { - return this.clone().iaddn(t4); - }, o.prototype.subn = function(t4) { - return this.clone().isubn(t4); - }, o.prototype.iabs = function() { - return this.negative = 0, this; - }, o.prototype.abs = function() { - return this.clone().iabs(); - }, o.prototype._ishlnsubmul = function(t4, e4, r3) { - var i2, o2, a2 = t4.length + r3; - this._expand(a2); - var s2 = 0; - for (i2 = 0; i2 < t4.length; i2++) { - o2 = (0 | this.words[i2 + r3]) + s2; - var u2 = (0 | t4.words[i2]) * e4; - s2 = ((o2 -= 67108863 & u2) >> 26) - (u2 / 67108864 | 0), this.words[i2 + r3] = 67108863 & o2; - } - for (; i2 < this.length - r3; i2++) - s2 = (o2 = (0 | this.words[i2 + r3]) + s2) >> 26, this.words[i2 + r3] = 67108863 & o2; - if (s2 === 0) - return this._strip(); - for (n(s2 === -1), s2 = 0, i2 = 0; i2 < this.length; i2++) - s2 = (o2 = -(0 | this.words[i2]) + s2) >> 26, this.words[i2] = 67108863 & o2; - return this.negative = 1, this._strip(); - }, o.prototype._wordDiv = function(t4, e4) { - var r3 = (this.length, t4.length), n2 = this.clone(), i2 = t4, a2 = 0 | i2.words[i2.length - 1]; - (r3 = 26 - this._countBits(a2)) != 0 && (i2 = i2.ushln(r3), n2.iushln(r3), a2 = 0 | i2.words[i2.length - 1]); - var s2, u2 = n2.length - i2.length; - if (e4 !== "mod") { - (s2 = new o(null)).length = u2 + 1, s2.words = new Array(s2.length); - for (var f2 = 0; f2 < s2.length; f2++) - s2.words[f2] = 0; - } - var c2 = n2.clone()._ishlnsubmul(i2, 1, u2); - c2.negative === 0 && (n2 = c2, s2 && (s2.words[u2] = 1)); - for (var h2 = u2 - 1; h2 >= 0; h2--) { - var l2 = 67108864 * (0 | n2.words[i2.length + h2]) + (0 | n2.words[i2.length + h2 - 1]); - for (l2 = Math.min(l2 / a2 | 0, 67108863), n2._ishlnsubmul(i2, l2, h2); n2.negative !== 0; ) - l2--, n2.negative = 0, n2._ishlnsubmul(i2, 1, h2), n2.isZero() || (n2.negative ^= 1); - s2 && (s2.words[h2] = l2); - } - return s2 && s2._strip(), n2._strip(), e4 !== "div" && r3 !== 0 && n2.iushrn(r3), {div: s2 || null, mod: n2}; - }, o.prototype.divmod = function(t4, e4, r3) { - return n(!t4.isZero()), this.isZero() ? {div: new o(0), mod: new o(0)} : this.negative !== 0 && t4.negative === 0 ? (s2 = this.neg().divmod(t4, e4), e4 !== "mod" && (i2 = s2.div.neg()), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.iadd(t4)), {div: i2, mod: a2}) : this.negative === 0 && t4.negative !== 0 ? (s2 = this.divmod(t4.neg(), e4), e4 !== "mod" && (i2 = s2.div.neg()), {div: i2, mod: s2.mod}) : (this.negative & t4.negative) != 0 ? (s2 = this.neg().divmod(t4.neg(), e4), e4 !== "div" && (a2 = s2.mod.neg(), r3 && a2.negative !== 0 && a2.isub(t4)), {div: s2.div, mod: a2}) : t4.length > this.length || this.cmp(t4) < 0 ? {div: new o(0), mod: this} : t4.length === 1 ? e4 === "div" ? {div: this.divn(t4.words[0]), mod: null} : e4 === "mod" ? {div: null, mod: new o(this.modrn(t4.words[0]))} : {div: this.divn(t4.words[0]), mod: new o(this.modrn(t4.words[0]))} : this._wordDiv(t4, e4); - var i2, a2, s2; - }, o.prototype.div = function(t4) { - return this.divmod(t4, "div", false).div; - }, o.prototype.mod = function(t4) { - return this.divmod(t4, "mod", false).mod; - }, o.prototype.umod = function(t4) { - return this.divmod(t4, "mod", true).mod; - }, o.prototype.divRound = function(t4) { - var e4 = this.divmod(t4); - if (e4.mod.isZero()) - return e4.div; - var r3 = e4.div.negative !== 0 ? e4.mod.isub(t4) : e4.mod, n2 = t4.ushrn(1), i2 = t4.andln(1), o2 = r3.cmp(n2); - return o2 < 0 || i2 === 1 && o2 === 0 ? e4.div : e4.div.negative !== 0 ? e4.div.isubn(1) : e4.div.iaddn(1); - }, o.prototype.modrn = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(t4 <= 67108863); - for (var r3 = (1 << 26) % t4, i2 = 0, o2 = this.length - 1; o2 >= 0; o2--) - i2 = (r3 * i2 + (0 | this.words[o2])) % t4; - return e4 ? -i2 : i2; - }, o.prototype.modn = function(t4) { - return this.modrn(t4); - }, o.prototype.idivn = function(t4) { - var e4 = t4 < 0; - e4 && (t4 = -t4), n(t4 <= 67108863); - for (var r3 = 0, i2 = this.length - 1; i2 >= 0; i2--) { - var o2 = (0 | this.words[i2]) + 67108864 * r3; - this.words[i2] = o2 / t4 | 0, r3 = o2 % t4; - } - return this._strip(), e4 ? this.ineg() : this; - }, o.prototype.divn = function(t4) { - return this.clone().idivn(t4); - }, o.prototype.egcd = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2 = new o(1), a2 = new o(0), s2 = new o(0), u2 = new o(1), f2 = 0; e4.isEven() && r3.isEven(); ) - e4.iushrn(1), r3.iushrn(1), ++f2; - for (var c2 = r3.clone(), h2 = e4.clone(); !e4.isZero(); ) { - for (var l2 = 0, d2 = 1; (e4.words[0] & d2) == 0 && l2 < 26; ++l2, d2 <<= 1) - ; - if (l2 > 0) - for (e4.iushrn(l2); l2-- > 0; ) - (i2.isOdd() || a2.isOdd()) && (i2.iadd(c2), a2.isub(h2)), i2.iushrn(1), a2.iushrn(1); - for (var p2 = 0, y2 = 1; (r3.words[0] & y2) == 0 && p2 < 26; ++p2, y2 <<= 1) - ; - if (p2 > 0) - for (r3.iushrn(p2); p2-- > 0; ) - (s2.isOdd() || u2.isOdd()) && (s2.iadd(c2), u2.isub(h2)), s2.iushrn(1), u2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), i2.isub(s2), a2.isub(u2)) : (r3.isub(e4), s2.isub(i2), u2.isub(a2)); - } - return {a: s2, b: u2, gcd: r3.iushln(f2)}; - }, o.prototype._invmp = function(t4) { - n(t4.negative === 0), n(!t4.isZero()); - var e4 = this, r3 = t4.clone(); - e4 = e4.negative !== 0 ? e4.umod(t4) : e4.clone(); - for (var i2, a2 = new o(1), s2 = new o(0), u2 = r3.clone(); e4.cmpn(1) > 0 && r3.cmpn(1) > 0; ) { - for (var f2 = 0, c2 = 1; (e4.words[0] & c2) == 0 && f2 < 26; ++f2, c2 <<= 1) - ; - if (f2 > 0) - for (e4.iushrn(f2); f2-- > 0; ) - a2.isOdd() && a2.iadd(u2), a2.iushrn(1); - for (var h2 = 0, l2 = 1; (r3.words[0] & l2) == 0 && h2 < 26; ++h2, l2 <<= 1) - ; - if (h2 > 0) - for (r3.iushrn(h2); h2-- > 0; ) - s2.isOdd() && s2.iadd(u2), s2.iushrn(1); - e4.cmp(r3) >= 0 ? (e4.isub(r3), a2.isub(s2)) : (r3.isub(e4), s2.isub(a2)); - } - return (i2 = e4.cmpn(1) === 0 ? a2 : s2).cmpn(0) < 0 && i2.iadd(t4), i2; - }, o.prototype.gcd = function(t4) { - if (this.isZero()) - return t4.abs(); - if (t4.isZero()) - return this.abs(); - var e4 = this.clone(), r3 = t4.clone(); - e4.negative = 0, r3.negative = 0; - for (var n2 = 0; e4.isEven() && r3.isEven(); n2++) - e4.iushrn(1), r3.iushrn(1); - for (; ; ) { - for (; e4.isEven(); ) - e4.iushrn(1); - for (; r3.isEven(); ) - r3.iushrn(1); - var i2 = e4.cmp(r3); - if (i2 < 0) { - var o2 = e4; - e4 = r3, r3 = o2; - } else if (i2 === 0 || r3.cmpn(1) === 0) - break; - e4.isub(r3); - } - return r3.iushln(n2); - }, o.prototype.invm = function(t4) { - return this.egcd(t4).a.umod(t4); - }, o.prototype.isEven = function() { - return (1 & this.words[0]) == 0; - }, o.prototype.isOdd = function() { - return (1 & this.words[0]) == 1; - }, o.prototype.andln = function(t4) { - return this.words[0] & t4; - }, o.prototype.bincn = function(t4) { - n(typeof t4 == "number"); - var e4 = t4 % 26, r3 = (t4 - e4) / 26, i2 = 1 << e4; - if (this.length <= r3) - return this._expand(r3 + 1), this.words[r3] |= i2, this; - for (var o2 = i2, a2 = r3; o2 !== 0 && a2 < this.length; a2++) { - var s2 = 0 | this.words[a2]; - o2 = (s2 += o2) >>> 26, s2 &= 67108863, this.words[a2] = s2; - } - return o2 !== 0 && (this.words[a2] = o2, this.length++), this; - }, o.prototype.isZero = function() { - return this.length === 1 && this.words[0] === 0; - }, o.prototype.cmpn = function(t4) { - var e4, r3 = t4 < 0; - if (this.negative !== 0 && !r3) - return -1; - if (this.negative === 0 && r3) - return 1; - if (this._strip(), this.length > 1) - e4 = 1; - else { - r3 && (t4 = -t4), n(t4 <= 67108863, "Number is too big"); - var i2 = 0 | this.words[0]; - e4 = i2 === t4 ? 0 : i2 < t4 ? -1 : 1; - } - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.cmp = function(t4) { - if (this.negative !== 0 && t4.negative === 0) - return -1; - if (this.negative === 0 && t4.negative !== 0) - return 1; - var e4 = this.ucmp(t4); - return this.negative !== 0 ? 0 | -e4 : e4; - }, o.prototype.ucmp = function(t4) { - if (this.length > t4.length) - return 1; - if (this.length < t4.length) - return -1; - for (var e4 = 0, r3 = this.length - 1; r3 >= 0; r3--) { - var n2 = 0 | this.words[r3], i2 = 0 | t4.words[r3]; - if (n2 !== i2) { - n2 < i2 ? e4 = -1 : n2 > i2 && (e4 = 1); - break; - } - } - return e4; - }, o.prototype.gtn = function(t4) { - return this.cmpn(t4) === 1; - }, o.prototype.gt = function(t4) { - return this.cmp(t4) === 1; - }, o.prototype.gten = function(t4) { - return this.cmpn(t4) >= 0; - }, o.prototype.gte = function(t4) { - return this.cmp(t4) >= 0; - }, o.prototype.ltn = function(t4) { - return this.cmpn(t4) === -1; - }, o.prototype.lt = function(t4) { - return this.cmp(t4) === -1; - }, o.prototype.lten = function(t4) { - return this.cmpn(t4) <= 0; - }, o.prototype.lte = function(t4) { - return this.cmp(t4) <= 0; - }, o.prototype.eqn = function(t4) { - return this.cmpn(t4) === 0; - }, o.prototype.eq = function(t4) { - return this.cmp(t4) === 0; - }, o.red = function(t4) { - return new k(t4); - }, o.prototype.toRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), t4.convertTo(this)._forceRed(t4); - }, o.prototype.fromRed = function() { - return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }, o.prototype._forceRed = function(t4) { - return this.red = t4, this; - }, o.prototype.forceRed = function(t4) { - return n(!this.red, "Already a number in reduction context"), this._forceRed(t4); - }, o.prototype.redAdd = function(t4) { - return n(this.red, "redAdd works only with red numbers"), this.red.add(this, t4); - }, o.prototype.redIAdd = function(t4) { - return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, t4); - }, o.prototype.redSub = function(t4) { - return n(this.red, "redSub works only with red numbers"), this.red.sub(this, t4); - }, o.prototype.redISub = function(t4) { - return n(this.red, "redISub works only with red numbers"), this.red.isub(this, t4); - }, o.prototype.redShl = function(t4) { - return n(this.red, "redShl works only with red numbers"), this.red.shl(this, t4); - }, o.prototype.redMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.mul(this, t4); - }, o.prototype.redIMul = function(t4) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, t4), this.red.imul(this, t4); - }, o.prototype.redSqr = function() { - return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }, o.prototype.redISqr = function() { - return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }, o.prototype.redSqrt = function() { - return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }, o.prototype.redInvm = function() { - return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }, o.prototype.redNeg = function() { - return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }, o.prototype.redPow = function(t4) { - return n(this.red && !t4.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, t4); - }; - var w = {k256: null, p224: null, p192: null, p25519: null}; - function _(t4, e4) { - this.name = t4, this.p = new o(e4, 16), this.n = this.p.bitLength(), this.k = new o(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); - } - function M() { - _.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - function S() { - _.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - function E() { - _.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - function A() { - _.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - function k(t4) { - if (typeof t4 == "string") { - var e4 = o._prime(t4); - this.m = e4.p, this.prime = e4; - } else - n(t4.gtn(1), "modulus must be greater than 1"), this.m = t4, this.prime = null; - } - function B(t4) { - k.call(this, t4), this.shift = this.m.bitLength(), this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26), this.r = new o(1).iushln(this.shift), this.r2 = this.imod(this.r.sqr()), this.rinv = this.r._invmp(this.m), this.minv = this.rinv.mul(this.r).isubn(1).div(this.m), this.minv = this.minv.umod(this.r), this.minv = this.r.sub(this.minv); - } - _.prototype._tmp = function() { - var t4 = new o(null); - return t4.words = new Array(Math.ceil(this.n / 13)), t4; - }, _.prototype.ireduce = function(t4) { - var e4, r3 = t4; - do { - this.split(r3, this.tmp), e4 = (r3 = (r3 = this.imulK(r3)).iadd(this.tmp)).bitLength(); - } while (e4 > this.n); - var n2 = e4 < this.n ? -1 : r3.ucmp(this.p); - return n2 === 0 ? (r3.words[0] = 0, r3.length = 1) : n2 > 0 ? r3.isub(this.p) : r3.strip !== void 0 ? r3.strip() : r3._strip(), r3; - }, _.prototype.split = function(t4, e4) { - t4.iushrn(this.n, 0, e4); - }, _.prototype.imulK = function(t4) { - return t4.imul(this.k); - }, i(M, _), M.prototype.split = function(t4, e4) { - for (var r3 = 4194303, n2 = Math.min(t4.length, 9), i2 = 0; i2 < n2; i2++) - e4.words[i2] = t4.words[i2]; - if (e4.length = n2, t4.length <= 9) - return t4.words[0] = 0, void (t4.length = 1); - var o2 = t4.words[9]; - for (e4.words[e4.length++] = o2 & r3, i2 = 10; i2 < t4.length; i2++) { - var a2 = 0 | t4.words[i2]; - t4.words[i2 - 10] = (a2 & r3) << 4 | o2 >>> 22, o2 = a2; - } - o2 >>>= 22, t4.words[i2 - 10] = o2, o2 === 0 && t4.length > 10 ? t4.length -= 10 : t4.length -= 9; - }, M.prototype.imulK = function(t4) { - t4.words[t4.length] = 0, t4.words[t4.length + 1] = 0, t4.length += 2; - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 0 | t4.words[r3]; - e4 += 977 * n2, t4.words[r3] = 67108863 & e4, e4 = 64 * n2 + (e4 / 67108864 | 0); - } - return t4.words[t4.length - 1] === 0 && (t4.length--, t4.words[t4.length - 1] === 0 && t4.length--), t4; - }, i(S, _), i(E, _), i(A, _), A.prototype.imulK = function(t4) { - for (var e4 = 0, r3 = 0; r3 < t4.length; r3++) { - var n2 = 19 * (0 | t4.words[r3]) + e4, i2 = 67108863 & n2; - n2 >>>= 26, t4.words[r3] = i2, e4 = n2; - } - return e4 !== 0 && (t4.words[t4.length++] = e4), t4; - }, o._prime = function(t4) { - if (w[t4]) - return w[t4]; - var e4; - if (t4 === "k256") - e4 = new M(); - else if (t4 === "p224") - e4 = new S(); - else if (t4 === "p192") - e4 = new E(); - else { - if (t4 !== "p25519") - throw new Error("Unknown prime " + t4); - e4 = new A(); - } - return w[t4] = e4, e4; - }, k.prototype._verify1 = function(t4) { - n(t4.negative === 0, "red works only with positives"), n(t4.red, "red works only with red numbers"); - }, k.prototype._verify2 = function(t4, e4) { - n((t4.negative | e4.negative) == 0, "red works only with positives"), n(t4.red && t4.red === e4.red, "red works only with red numbers"); - }, k.prototype.imod = function(t4) { - return this.prime ? this.prime.ireduce(t4)._forceRed(this) : (c(t4, t4.umod(this.m)._forceRed(this)), t4); - }, k.prototype.neg = function(t4) { - return t4.isZero() ? t4.clone() : this.m.sub(t4)._forceRed(this); - }, k.prototype.add = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.add(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3._forceRed(this); - }, k.prototype.iadd = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.iadd(e4); - return r3.cmp(this.m) >= 0 && r3.isub(this.m), r3; - }, k.prototype.sub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.sub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3._forceRed(this); - }, k.prototype.isub = function(t4, e4) { - this._verify2(t4, e4); - var r3 = t4.isub(e4); - return r3.cmpn(0) < 0 && r3.iadd(this.m), r3; - }, k.prototype.shl = function(t4, e4) { - return this._verify1(t4), this.imod(t4.ushln(e4)); - }, k.prototype.imul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.imul(e4)); - }, k.prototype.mul = function(t4, e4) { - return this._verify2(t4, e4), this.imod(t4.mul(e4)); - }, k.prototype.isqr = function(t4) { - return this.imul(t4, t4.clone()); - }, k.prototype.sqr = function(t4) { - return this.mul(t4, t4); - }, k.prototype.sqrt = function(t4) { - if (t4.isZero()) - return t4.clone(); - var e4 = this.m.andln(3); - if (n(e4 % 2 == 1), e4 === 3) { - var r3 = this.m.add(new o(1)).iushrn(2); - return this.pow(t4, r3); - } - for (var i2 = this.m.subn(1), a2 = 0; !i2.isZero() && i2.andln(1) === 0; ) - a2++, i2.iushrn(1); - n(!i2.isZero()); - var s2 = new o(1).toRed(this), u2 = s2.redNeg(), f2 = this.m.subn(1).iushrn(1), c2 = this.m.bitLength(); - for (c2 = new o(2 * c2 * c2).toRed(this); this.pow(c2, f2).cmp(u2) !== 0; ) - c2.redIAdd(u2); - for (var h2 = this.pow(c2, i2), l2 = this.pow(t4, i2.addn(1).iushrn(1)), d2 = this.pow(t4, i2), p2 = a2; d2.cmp(s2) !== 0; ) { - for (var y2 = d2, m2 = 0; y2.cmp(s2) !== 0; m2++) - y2 = y2.redSqr(); - n(m2 < p2); - var b2 = this.pow(h2, new o(1).iushln(p2 - m2 - 1)); - l2 = l2.redMul(b2), h2 = b2.redSqr(), d2 = d2.redMul(h2), p2 = m2; - } - return l2; - }, k.prototype.invm = function(t4) { - var e4 = t4._invmp(this.m); - return e4.negative !== 0 ? (e4.negative = 0, this.imod(e4).redNeg()) : this.imod(e4); - }, k.prototype.pow = function(t4, e4) { - if (e4.isZero()) - return new o(1).toRed(this); - if (e4.cmpn(1) === 0) - return t4.clone(); - var r3 = new Array(16); - r3[0] = new o(1).toRed(this), r3[1] = t4; - for (var n2 = 2; n2 < r3.length; n2++) - r3[n2] = this.mul(r3[n2 - 1], t4); - var i2 = r3[0], a2 = 0, s2 = 0, u2 = e4.bitLength() % 26; - for (u2 === 0 && (u2 = 26), n2 = e4.length - 1; n2 >= 0; n2--) { - for (var f2 = e4.words[n2], c2 = u2 - 1; c2 >= 0; c2--) { - var h2 = f2 >> c2 & 1; - i2 !== r3[0] && (i2 = this.sqr(i2)), h2 !== 0 || a2 !== 0 ? (a2 <<= 1, a2 |= h2, (++s2 == 4 || n2 === 0 && c2 === 0) && (i2 = this.mul(i2, r3[a2]), s2 = 0, a2 = 0)) : s2 = 0; - } - u2 = 26; - } - return i2; - }, k.prototype.convertTo = function(t4) { - var e4 = t4.umod(this.m); - return e4 === t4 ? e4.clone() : e4; - }, k.prototype.convertFrom = function(t4) { - var e4 = t4.clone(); - return e4.red = null, e4; - }, o.mont = function(t4) { - return new B(t4); - }, i(B, k), B.prototype.convertTo = function(t4) { - return this.imod(t4.ushln(this.shift)); - }, B.prototype.convertFrom = function(t4) { - var e4 = this.imod(t4.mul(this.rinv)); - return e4.red = null, e4; - }, B.prototype.imul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return t4.words[0] = 0, t4.length = 1, t4; - var r3 = t4.imul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), o2 = i2; - return i2.cmp(this.m) >= 0 ? o2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (o2 = i2.iadd(this.m)), o2._forceRed(this); - }, B.prototype.mul = function(t4, e4) { - if (t4.isZero() || e4.isZero()) - return new o(0)._forceRed(this); - var r3 = t4.mul(e4), n2 = r3.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), i2 = r3.isub(n2).iushrn(this.shift), a2 = i2; - return i2.cmp(this.m) >= 0 ? a2 = i2.isub(this.m) : i2.cmpn(0) < 0 && (a2 = i2.iadd(this.m)), a2._forceRed(this); - }, B.prototype.invm = function(t4) { - return this.imod(t4._invmp(this.m).mul(this.r2))._forceRed(this); - }; - }(t2 = r2.nmd(t2), this); - }, 7191: (t2, e2, r2) => { - var n = r2(8162); - t2.exports = n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); - }, 3310: (t2, e2, r2) => { - var n = r2(7191), i = r2(9509).Buffer; - t2.exports = function(t3) { - function e3(e4) { - var r3 = e4.slice(0, -4), n2 = e4.slice(-4), i2 = t3(r3); - if (!(n2[0] ^ i2[0] | n2[1] ^ i2[1] | n2[2] ^ i2[2] | n2[3] ^ i2[3])) - return r3; - } - return {encode: function(e4) { - var r3 = t3(e4); - return n.encode(i.concat([e4, r3], e4.length + 4)); - }, decode: function(t4) { - var r3 = e3(n.decode(t4)); - if (!r3) - throw new Error("Invalid checksum"); - return r3; - }, decodeUnsafe: function(t4) { - var r3 = n.decodeUnsafe(t4); - if (r3) - return e3(r3); - }}; - }; - }, 8334: (t2, e2, r2) => { - var n = r2(3482), i = r2(3310); - t2.exports = i(function(t3) { - var e3 = n("sha256").update(t3).digest(); - return n("sha256").update(e3).digest(); - }); - }, 7295: (t2, e2, r2) => { - var n = r2(8764).Buffer; - t2.exports = function(t3, e3) { - for (var r3 = Math.min(t3.length, e3.length), i = new n(r3), o = 0; o < r3; ++o) - i[o] = t3[o] ^ e3[o]; - return i; - }; - }, 8764: (t2, e2, r2) => { - const n = r2(9742), i = r2(645), o = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null; - e2.Buffer = u, e2.SlowBuffer = function(t3) { - return +t3 != t3 && (t3 = 0), u.alloc(+t3); - }, e2.INSPECT_MAX_BYTES = 50; - const a = 2147483647; - function s(t3) { - if (t3 > a) - throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); - const e3 = new Uint8Array(t3); - return Object.setPrototypeOf(e3, u.prototype), e3; - } - function u(t3, e3, r3) { - if (typeof t3 == "number") { - if (typeof e3 == "string") - throw new TypeError('The "string" argument must be of type string. Received type number'); - return h(t3); - } - return f(t3, e3, r3); - } - function f(t3, e3, r3) { - if (typeof t3 == "string") - return function(t4, e4) { - if (typeof e4 == "string" && e4 !== "" || (e4 = "utf8"), !u.isEncoding(e4)) - throw new TypeError("Unknown encoding: " + e4); - const r4 = 0 | y(t4, e4); - let n3 = s(r4); - const i3 = n3.write(t4, e4); - return i3 !== r4 && (n3 = n3.slice(0, i3)), n3; - }(t3, e3); - if (ArrayBuffer.isView(t3)) - return function(t4) { - if (G(t4, Uint8Array)) { - const e4 = new Uint8Array(t4); - return d(e4.buffer, e4.byteOffset, e4.byteLength); - } - return l(t4); - }(t3); - if (t3 == null) - throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); - if (G(t3, ArrayBuffer) || t3 && G(t3.buffer, ArrayBuffer)) - return d(t3, e3, r3); - if (typeof SharedArrayBuffer != "undefined" && (G(t3, SharedArrayBuffer) || t3 && G(t3.buffer, SharedArrayBuffer))) - return d(t3, e3, r3); - if (typeof t3 == "number") - throw new TypeError('The "value" argument must not be of type number. Received type number'); - const n2 = t3.valueOf && t3.valueOf(); - if (n2 != null && n2 !== t3) - return u.from(n2, e3, r3); - const i2 = function(t4) { - if (u.isBuffer(t4)) { - const e4 = 0 | p(t4.length), r4 = s(e4); - return r4.length === 0 || t4.copy(r4, 0, 0, e4), r4; - } - return t4.length !== void 0 ? typeof t4.length != "number" || Z(t4.length) ? s(0) : l(t4) : t4.type === "Buffer" && Array.isArray(t4.data) ? l(t4.data) : void 0; - }(t3); - if (i2) - return i2; - if (typeof Symbol != "undefined" && Symbol.toPrimitive != null && typeof t3[Symbol.toPrimitive] == "function") - return u.from(t3[Symbol.toPrimitive]("string"), e3, r3); - throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); - } - function c(t3) { - if (typeof t3 != "number") - throw new TypeError('"size" argument must be of type number'); - if (t3 < 0) - throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); - } - function h(t3) { - return c(t3), s(t3 < 0 ? 0 : 0 | p(t3)); - } - function l(t3) { - const e3 = t3.length < 0 ? 0 : 0 | p(t3.length), r3 = s(e3); - for (let n2 = 0; n2 < e3; n2 += 1) - r3[n2] = 255 & t3[n2]; - return r3; - } - function d(t3, e3, r3) { - if (e3 < 0 || t3.byteLength < e3) - throw new RangeError('"offset" is outside of buffer bounds'); - if (t3.byteLength < e3 + (r3 || 0)) - throw new RangeError('"length" is outside of buffer bounds'); - let n2; - return n2 = e3 === void 0 && r3 === void 0 ? new Uint8Array(t3) : r3 === void 0 ? new Uint8Array(t3, e3) : new Uint8Array(t3, e3, r3), Object.setPrototypeOf(n2, u.prototype), n2; - } - function p(t3) { - if (t3 >= a) - throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a.toString(16) + " bytes"); - return 0 | t3; - } - function y(t3, e3) { - if (u.isBuffer(t3)) - return t3.length; - if (ArrayBuffer.isView(t3) || G(t3, ArrayBuffer)) - return t3.byteLength; - if (typeof t3 != "string") - throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof t3); - const r3 = t3.length, n2 = arguments.length > 2 && arguments[2] === true; - if (!n2 && r3 === 0) - return 0; - let i2 = false; - for (; ; ) - switch (e3) { - case "ascii": - case "latin1": - case "binary": - return r3; - case "utf8": - case "utf-8": - return W(t3).length; - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return 2 * r3; - case "hex": - return r3 >>> 1; - case "base64": - return J(t3).length; - default: - if (i2) - return n2 ? -1 : W(t3).length; - e3 = ("" + e3).toLowerCase(), i2 = true; - } - } - function m(t3, e3, r3) { - let n2 = false; - if ((e3 === void 0 || e3 < 0) && (e3 = 0), e3 > this.length) - return ""; - if ((r3 === void 0 || r3 > this.length) && (r3 = this.length), r3 <= 0) - return ""; - if ((r3 >>>= 0) <= (e3 >>>= 0)) - return ""; - for (t3 || (t3 = "utf8"); ; ) - switch (t3) { - case "hex": - return O(this, e3, r3); - case "utf8": - case "utf-8": - return k(this, e3, r3); - case "ascii": - return T(this, e3, r3); - case "latin1": - case "binary": - return x(this, e3, r3); - case "base64": - return A(this, e3, r3); - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return R(this, e3, r3); - default: - if (n2) - throw new TypeError("Unknown encoding: " + t3); - t3 = (t3 + "").toLowerCase(), n2 = true; - } - } - function b(t3, e3, r3) { - const n2 = t3[e3]; - t3[e3] = t3[r3], t3[r3] = n2; - } - function g(t3, e3, r3, n2, i2) { - if (t3.length === 0) - return -1; - if (typeof r3 == "string" ? (n2 = r3, r3 = 0) : r3 > 2147483647 ? r3 = 2147483647 : r3 < -2147483648 && (r3 = -2147483648), Z(r3 = +r3) && (r3 = i2 ? 0 : t3.length - 1), r3 < 0 && (r3 = t3.length + r3), r3 >= t3.length) { - if (i2) - return -1; - r3 = t3.length - 1; - } else if (r3 < 0) { - if (!i2) - return -1; - r3 = 0; - } - if (typeof e3 == "string" && (e3 = u.from(e3, n2)), u.isBuffer(e3)) - return e3.length === 0 ? -1 : v(t3, e3, r3, n2, i2); - if (typeof e3 == "number") - return e3 &= 255, typeof Uint8Array.prototype.indexOf == "function" ? i2 ? Uint8Array.prototype.indexOf.call(t3, e3, r3) : Uint8Array.prototype.lastIndexOf.call(t3, e3, r3) : v(t3, [e3], r3, n2, i2); - throw new TypeError("val must be string, number or Buffer"); - } - function v(t3, e3, r3, n2, i2) { - let o2, a2 = 1, s2 = t3.length, u2 = e3.length; - if (n2 !== void 0 && ((n2 = String(n2).toLowerCase()) === "ucs2" || n2 === "ucs-2" || n2 === "utf16le" || n2 === "utf-16le")) { - if (t3.length < 2 || e3.length < 2) - return -1; - a2 = 2, s2 /= 2, u2 /= 2, r3 /= 2; - } - function f2(t4, e4) { - return a2 === 1 ? t4[e4] : t4.readUInt16BE(e4 * a2); - } - if (i2) { - let n3 = -1; - for (o2 = r3; o2 < s2; o2++) - if (f2(t3, o2) === f2(e3, n3 === -1 ? 0 : o2 - n3)) { - if (n3 === -1 && (n3 = o2), o2 - n3 + 1 === u2) - return n3 * a2; - } else - n3 !== -1 && (o2 -= o2 - n3), n3 = -1; - } else - for (r3 + u2 > s2 && (r3 = s2 - u2), o2 = r3; o2 >= 0; o2--) { - let r4 = true; - for (let n3 = 0; n3 < u2; n3++) - if (f2(t3, o2 + n3) !== f2(e3, n3)) { - r4 = false; - break; - } - if (r4) - return o2; - } - return -1; - } - function w(t3, e3, r3, n2) { - r3 = Number(r3) || 0; - const i2 = t3.length - r3; - n2 ? (n2 = Number(n2)) > i2 && (n2 = i2) : n2 = i2; - const o2 = e3.length; - let a2; - for (n2 > o2 / 2 && (n2 = o2 / 2), a2 = 0; a2 < n2; ++a2) { - const n3 = parseInt(e3.substr(2 * a2, 2), 16); - if (Z(n3)) - return a2; - t3[r3 + a2] = n3; - } - return a2; - } - function _(t3, e3, r3, n2) { - return $(W(e3, t3.length - r3), t3, r3, n2); - } - function M(t3, e3, r3, n2) { - return $(function(t4) { - const e4 = []; - for (let r4 = 0; r4 < t4.length; ++r4) - e4.push(255 & t4.charCodeAt(r4)); - return e4; - }(e3), t3, r3, n2); - } - function S(t3, e3, r3, n2) { - return $(J(e3), t3, r3, n2); - } - function E(t3, e3, r3, n2) { - return $(function(t4, e4) { - let r4, n3, i2; - const o2 = []; - for (let a2 = 0; a2 < t4.length && !((e4 -= 2) < 0); ++a2) - r4 = t4.charCodeAt(a2), n3 = r4 >> 8, i2 = r4 % 256, o2.push(i2), o2.push(n3); - return o2; - }(e3, t3.length - r3), t3, r3, n2); - } - function A(t3, e3, r3) { - return e3 === 0 && r3 === t3.length ? n.fromByteArray(t3) : n.fromByteArray(t3.slice(e3, r3)); - } - function k(t3, e3, r3) { - r3 = Math.min(t3.length, r3); - const n2 = []; - let i2 = e3; - for (; i2 < r3; ) { - const e4 = t3[i2]; - let o2 = null, a2 = e4 > 239 ? 4 : e4 > 223 ? 3 : e4 > 191 ? 2 : 1; - if (i2 + a2 <= r3) { - let r4, n3, s2, u2; - switch (a2) { - case 1: - e4 < 128 && (o2 = e4); - break; - case 2: - r4 = t3[i2 + 1], (192 & r4) == 128 && (u2 = (31 & e4) << 6 | 63 & r4, u2 > 127 && (o2 = u2)); - break; - case 3: - r4 = t3[i2 + 1], n3 = t3[i2 + 2], (192 & r4) == 128 && (192 & n3) == 128 && (u2 = (15 & e4) << 12 | (63 & r4) << 6 | 63 & n3, u2 > 2047 && (u2 < 55296 || u2 > 57343) && (o2 = u2)); - break; - case 4: - r4 = t3[i2 + 1], n3 = t3[i2 + 2], s2 = t3[i2 + 3], (192 & r4) == 128 && (192 & n3) == 128 && (192 & s2) == 128 && (u2 = (15 & e4) << 18 | (63 & r4) << 12 | (63 & n3) << 6 | 63 & s2, u2 > 65535 && u2 < 1114112 && (o2 = u2)); - } - } - o2 === null ? (o2 = 65533, a2 = 1) : o2 > 65535 && (o2 -= 65536, n2.push(o2 >>> 10 & 1023 | 55296), o2 = 56320 | 1023 & o2), n2.push(o2), i2 += a2; - } - return function(t4) { - const e4 = t4.length; - if (e4 <= B) - return String.fromCharCode.apply(String, t4); - let r4 = "", n3 = 0; - for (; n3 < e4; ) - r4 += String.fromCharCode.apply(String, t4.slice(n3, n3 += B)); - return r4; - }(n2); - } - e2.kMaxLength = a, u.TYPED_ARRAY_SUPPORT = function() { - try { - const t3 = new Uint8Array(1), e3 = {foo: function() { - return 42; - }}; - return Object.setPrototypeOf(e3, Uint8Array.prototype), Object.setPrototypeOf(t3, e3), t3.foo() === 42; - } catch (t3) { - return false; - } - }(), u.TYPED_ARRAY_SUPPORT || typeof console == "undefined" || typeof console.error != "function" || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(u.prototype, "parent", {enumerable: true, get: function() { - if (u.isBuffer(this)) - return this.buffer; - }}), Object.defineProperty(u.prototype, "offset", {enumerable: true, get: function() { - if (u.isBuffer(this)) - return this.byteOffset; - }}), u.poolSize = 8192, u.from = function(t3, e3, r3) { - return f(t3, e3, r3); - }, Object.setPrototypeOf(u.prototype, Uint8Array.prototype), Object.setPrototypeOf(u, Uint8Array), u.alloc = function(t3, e3, r3) { - return function(t4, e4, r4) { - return c(t4), t4 <= 0 ? s(t4) : e4 !== void 0 ? typeof r4 == "string" ? s(t4).fill(e4, r4) : s(t4).fill(e4) : s(t4); - }(t3, e3, r3); - }, u.allocUnsafe = function(t3) { - return h(t3); - }, u.allocUnsafeSlow = function(t3) { - return h(t3); - }, u.isBuffer = function(t3) { - return t3 != null && t3._isBuffer === true && t3 !== u.prototype; - }, u.compare = function(t3, e3) { - if (G(t3, Uint8Array) && (t3 = u.from(t3, t3.offset, t3.byteLength)), G(e3, Uint8Array) && (e3 = u.from(e3, e3.offset, e3.byteLength)), !u.isBuffer(t3) || !u.isBuffer(e3)) - throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); - if (t3 === e3) - return 0; - let r3 = t3.length, n2 = e3.length; - for (let i2 = 0, o2 = Math.min(r3, n2); i2 < o2; ++i2) - if (t3[i2] !== e3[i2]) { - r3 = t3[i2], n2 = e3[i2]; - break; - } - return r3 < n2 ? -1 : n2 < r3 ? 1 : 0; - }, u.isEncoding = function(t3) { - switch (String(t3).toLowerCase()) { - case "hex": - case "utf8": - case "utf-8": - case "ascii": - case "latin1": - case "binary": - case "base64": - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return true; - default: - return false; - } - }, u.concat = function(t3, e3) { - if (!Array.isArray(t3)) - throw new TypeError('"list" argument must be an Array of Buffers'); - if (t3.length === 0) - return u.alloc(0); - let r3; - if (e3 === void 0) - for (e3 = 0, r3 = 0; r3 < t3.length; ++r3) - e3 += t3[r3].length; - const n2 = u.allocUnsafe(e3); - let i2 = 0; - for (r3 = 0; r3 < t3.length; ++r3) { - let e4 = t3[r3]; - if (G(e4, Uint8Array)) - i2 + e4.length > n2.length ? (u.isBuffer(e4) || (e4 = u.from(e4)), e4.copy(n2, i2)) : Uint8Array.prototype.set.call(n2, e4, i2); - else { - if (!u.isBuffer(e4)) - throw new TypeError('"list" argument must be an Array of Buffers'); - e4.copy(n2, i2); - } - i2 += e4.length; - } - return n2; - }, u.byteLength = y, u.prototype._isBuffer = true, u.prototype.swap16 = function() { - const t3 = this.length; - if (t3 % 2 != 0) - throw new RangeError("Buffer size must be a multiple of 16-bits"); - for (let e3 = 0; e3 < t3; e3 += 2) - b(this, e3, e3 + 1); - return this; - }, u.prototype.swap32 = function() { - const t3 = this.length; - if (t3 % 4 != 0) - throw new RangeError("Buffer size must be a multiple of 32-bits"); - for (let e3 = 0; e3 < t3; e3 += 4) - b(this, e3, e3 + 3), b(this, e3 + 1, e3 + 2); - return this; - }, u.prototype.swap64 = function() { - const t3 = this.length; - if (t3 % 8 != 0) - throw new RangeError("Buffer size must be a multiple of 64-bits"); - for (let e3 = 0; e3 < t3; e3 += 8) - b(this, e3, e3 + 7), b(this, e3 + 1, e3 + 6), b(this, e3 + 2, e3 + 5), b(this, e3 + 3, e3 + 4); - return this; - }, u.prototype.toString = function() { - const t3 = this.length; - return t3 === 0 ? "" : arguments.length === 0 ? k(this, 0, t3) : m.apply(this, arguments); - }, u.prototype.toLocaleString = u.prototype.toString, u.prototype.equals = function(t3) { - if (!u.isBuffer(t3)) - throw new TypeError("Argument must be a Buffer"); - return this === t3 || u.compare(this, t3) === 0; - }, u.prototype.inspect = function() { - let t3 = ""; - const r3 = e2.INSPECT_MAX_BYTES; - return t3 = this.toString("hex", 0, r3).replace(/(.{2})/g, "$1 ").trim(), this.length > r3 && (t3 += " ... "), ""; - }, o && (u.prototype[o] = u.prototype.inspect), u.prototype.compare = function(t3, e3, r3, n2, i2) { - if (G(t3, Uint8Array) && (t3 = u.from(t3, t3.offset, t3.byteLength)), !u.isBuffer(t3)) - throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t3); - if (e3 === void 0 && (e3 = 0), r3 === void 0 && (r3 = t3 ? t3.length : 0), n2 === void 0 && (n2 = 0), i2 === void 0 && (i2 = this.length), e3 < 0 || r3 > t3.length || n2 < 0 || i2 > this.length) - throw new RangeError("out of range index"); - if (n2 >= i2 && e3 >= r3) - return 0; - if (n2 >= i2) - return -1; - if (e3 >= r3) - return 1; - if (this === t3) - return 0; - let o2 = (i2 >>>= 0) - (n2 >>>= 0), a2 = (r3 >>>= 0) - (e3 >>>= 0); - const s2 = Math.min(o2, a2), f2 = this.slice(n2, i2), c2 = t3.slice(e3, r3); - for (let t4 = 0; t4 < s2; ++t4) - if (f2[t4] !== c2[t4]) { - o2 = f2[t4], a2 = c2[t4]; - break; - } - return o2 < a2 ? -1 : a2 < o2 ? 1 : 0; - }, u.prototype.includes = function(t3, e3, r3) { - return this.indexOf(t3, e3, r3) !== -1; - }, u.prototype.indexOf = function(t3, e3, r3) { - return g(this, t3, e3, r3, true); - }, u.prototype.lastIndexOf = function(t3, e3, r3) { - return g(this, t3, e3, r3, false); - }, u.prototype.write = function(t3, e3, r3, n2) { - if (e3 === void 0) - n2 = "utf8", r3 = this.length, e3 = 0; - else if (r3 === void 0 && typeof e3 == "string") - n2 = e3, r3 = this.length, e3 = 0; - else { - if (!isFinite(e3)) - throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); - e3 >>>= 0, isFinite(r3) ? (r3 >>>= 0, n2 === void 0 && (n2 = "utf8")) : (n2 = r3, r3 = void 0); - } - const i2 = this.length - e3; - if ((r3 === void 0 || r3 > i2) && (r3 = i2), t3.length > 0 && (r3 < 0 || e3 < 0) || e3 > this.length) - throw new RangeError("Attempt to write outside buffer bounds"); - n2 || (n2 = "utf8"); - let o2 = false; - for (; ; ) - switch (n2) { - case "hex": - return w(this, t3, e3, r3); - case "utf8": - case "utf-8": - return _(this, t3, e3, r3); - case "ascii": - case "latin1": - case "binary": - return M(this, t3, e3, r3); - case "base64": - return S(this, t3, e3, r3); - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return E(this, t3, e3, r3); - default: - if (o2) - throw new TypeError("Unknown encoding: " + n2); - n2 = ("" + n2).toLowerCase(), o2 = true; - } - }, u.prototype.toJSON = function() { - return {type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0)}; - }; - const B = 4096; - function T(t3, e3, r3) { - let n2 = ""; - r3 = Math.min(t3.length, r3); - for (let i2 = e3; i2 < r3; ++i2) - n2 += String.fromCharCode(127 & t3[i2]); - return n2; - } - function x(t3, e3, r3) { - let n2 = ""; - r3 = Math.min(t3.length, r3); - for (let i2 = e3; i2 < r3; ++i2) - n2 += String.fromCharCode(t3[i2]); - return n2; - } - function O(t3, e3, r3) { - const n2 = t3.length; - (!e3 || e3 < 0) && (e3 = 0), (!r3 || r3 < 0 || r3 > n2) && (r3 = n2); - let i2 = ""; - for (let n3 = e3; n3 < r3; ++n3) - i2 += Y[t3[n3]]; - return i2; - } - function R(t3, e3, r3) { - const n2 = t3.slice(e3, r3); - let i2 = ""; - for (let t4 = 0; t4 < n2.length - 1; t4 += 2) - i2 += String.fromCharCode(n2[t4] + 256 * n2[t4 + 1]); - return i2; - } - function P(t3, e3, r3) { - if (t3 % 1 != 0 || t3 < 0) - throw new RangeError("offset is not uint"); - if (t3 + e3 > r3) - throw new RangeError("Trying to access beyond buffer length"); - } - function I(t3, e3, r3, n2, i2, o2) { - if (!u.isBuffer(t3)) - throw new TypeError('"buffer" argument must be a Buffer instance'); - if (e3 > i2 || e3 < o2) - throw new RangeError('"value" argument is out of bounds'); - if (r3 + n2 > t3.length) - throw new RangeError("Index out of range"); - } - function j(t3, e3, r3, n2, i2) { - q(e3, n2, i2, t3, r3, 7); - let o2 = Number(e3 & BigInt(4294967295)); - t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2, o2 >>= 8, t3[r3++] = o2; - let a2 = Number(e3 >> BigInt(32) & BigInt(4294967295)); - return t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, a2 >>= 8, t3[r3++] = a2, r3; - } - function U(t3, e3, r3, n2, i2) { - q(e3, n2, i2, t3, r3, 7); - let o2 = Number(e3 & BigInt(4294967295)); - t3[r3 + 7] = o2, o2 >>= 8, t3[r3 + 6] = o2, o2 >>= 8, t3[r3 + 5] = o2, o2 >>= 8, t3[r3 + 4] = o2; - let a2 = Number(e3 >> BigInt(32) & BigInt(4294967295)); - return t3[r3 + 3] = a2, a2 >>= 8, t3[r3 + 2] = a2, a2 >>= 8, t3[r3 + 1] = a2, a2 >>= 8, t3[r3] = a2, r3 + 8; - } - function N(t3, e3, r3, n2, i2, o2) { - if (r3 + n2 > t3.length) - throw new RangeError("Index out of range"); - if (r3 < 0) - throw new RangeError("Index out of range"); - } - function C(t3, e3, r3, n2, o2) { - return e3 = +e3, r3 >>>= 0, o2 || N(t3, 0, r3, 4), i.write(t3, e3, r3, n2, 23, 4), r3 + 4; - } - function D(t3, e3, r3, n2, o2) { - return e3 = +e3, r3 >>>= 0, o2 || N(t3, 0, r3, 8), i.write(t3, e3, r3, n2, 52, 8), r3 + 8; - } - u.prototype.slice = function(t3, e3) { - const r3 = this.length; - (t3 = ~~t3) < 0 ? (t3 += r3) < 0 && (t3 = 0) : t3 > r3 && (t3 = r3), (e3 = e3 === void 0 ? r3 : ~~e3) < 0 ? (e3 += r3) < 0 && (e3 = 0) : e3 > r3 && (e3 = r3), e3 < t3 && (e3 = t3); - const n2 = this.subarray(t3, e3); - return Object.setPrototypeOf(n2, u.prototype), n2; - }, u.prototype.readUintLE = u.prototype.readUIntLE = function(t3, e3, r3) { - t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); - let n2 = this[t3], i2 = 1, o2 = 0; - for (; ++o2 < e3 && (i2 *= 256); ) - n2 += this[t3 + o2] * i2; - return n2; - }, u.prototype.readUintBE = u.prototype.readUIntBE = function(t3, e3, r3) { - t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); - let n2 = this[t3 + --e3], i2 = 1; - for (; e3 > 0 && (i2 *= 256); ) - n2 += this[t3 + --e3] * i2; - return n2; - }, u.prototype.readUint8 = u.prototype.readUInt8 = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 1, this.length), this[t3]; - }, u.prototype.readUint16LE = u.prototype.readUInt16LE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 2, this.length), this[t3] | this[t3 + 1] << 8; - }, u.prototype.readUint16BE = u.prototype.readUInt16BE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 2, this.length), this[t3] << 8 | this[t3 + 1]; - }, u.prototype.readUint32LE = u.prototype.readUInt32LE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), (this[t3] | this[t3 + 1] << 8 | this[t3 + 2] << 16) + 16777216 * this[t3 + 3]; - }, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), 16777216 * this[t3] + (this[t3 + 1] << 16 | this[t3 + 2] << 8 | this[t3 + 3]); - }, u.prototype.readBigUInt64LE = X(function(t3) { - H(t3 >>>= 0, "offset"); - const e3 = this[t3], r3 = this[t3 + 7]; - e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); - const n2 = e3 + 256 * this[++t3] + 65536 * this[++t3] + this[++t3] * 2 ** 24, i2 = this[++t3] + 256 * this[++t3] + 65536 * this[++t3] + r3 * 2 ** 24; - return BigInt(n2) + (BigInt(i2) << BigInt(32)); - }), u.prototype.readBigUInt64BE = X(function(t3) { - H(t3 >>>= 0, "offset"); - const e3 = this[t3], r3 = this[t3 + 7]; - e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); - const n2 = e3 * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + this[++t3], i2 = this[++t3] * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + r3; - return (BigInt(n2) << BigInt(32)) + BigInt(i2); - }), u.prototype.readIntLE = function(t3, e3, r3) { - t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); - let n2 = this[t3], i2 = 1, o2 = 0; - for (; ++o2 < e3 && (i2 *= 256); ) - n2 += this[t3 + o2] * i2; - return i2 *= 128, n2 >= i2 && (n2 -= Math.pow(2, 8 * e3)), n2; - }, u.prototype.readIntBE = function(t3, e3, r3) { - t3 >>>= 0, e3 >>>= 0, r3 || P(t3, e3, this.length); - let n2 = e3, i2 = 1, o2 = this[t3 + --n2]; - for (; n2 > 0 && (i2 *= 256); ) - o2 += this[t3 + --n2] * i2; - return i2 *= 128, o2 >= i2 && (o2 -= Math.pow(2, 8 * e3)), o2; - }, u.prototype.readInt8 = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 1, this.length), 128 & this[t3] ? -1 * (255 - this[t3] + 1) : this[t3]; - }, u.prototype.readInt16LE = function(t3, e3) { - t3 >>>= 0, e3 || P(t3, 2, this.length); - const r3 = this[t3] | this[t3 + 1] << 8; - return 32768 & r3 ? 4294901760 | r3 : r3; - }, u.prototype.readInt16BE = function(t3, e3) { - t3 >>>= 0, e3 || P(t3, 2, this.length); - const r3 = this[t3 + 1] | this[t3] << 8; - return 32768 & r3 ? 4294901760 | r3 : r3; - }, u.prototype.readInt32LE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), this[t3] | this[t3 + 1] << 8 | this[t3 + 2] << 16 | this[t3 + 3] << 24; - }, u.prototype.readInt32BE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), this[t3] << 24 | this[t3 + 1] << 16 | this[t3 + 2] << 8 | this[t3 + 3]; - }, u.prototype.readBigInt64LE = X(function(t3) { - H(t3 >>>= 0, "offset"); - const e3 = this[t3], r3 = this[t3 + 7]; - e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); - const n2 = this[t3 + 4] + 256 * this[t3 + 5] + 65536 * this[t3 + 6] + (r3 << 24); - return (BigInt(n2) << BigInt(32)) + BigInt(e3 + 256 * this[++t3] + 65536 * this[++t3] + this[++t3] * 2 ** 24); - }), u.prototype.readBigInt64BE = X(function(t3) { - H(t3 >>>= 0, "offset"); - const e3 = this[t3], r3 = this[t3 + 7]; - e3 !== void 0 && r3 !== void 0 || F(t3, this.length - 8); - const n2 = (e3 << 24) + 65536 * this[++t3] + 256 * this[++t3] + this[++t3]; - return (BigInt(n2) << BigInt(32)) + BigInt(this[++t3] * 2 ** 24 + 65536 * this[++t3] + 256 * this[++t3] + r3); - }), u.prototype.readFloatLE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), i.read(this, t3, true, 23, 4); - }, u.prototype.readFloatBE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 4, this.length), i.read(this, t3, false, 23, 4); - }, u.prototype.readDoubleLE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 8, this.length), i.read(this, t3, true, 52, 8); - }, u.prototype.readDoubleBE = function(t3, e3) { - return t3 >>>= 0, e3 || P(t3, 8, this.length), i.read(this, t3, false, 52, 8); - }, u.prototype.writeUintLE = u.prototype.writeUIntLE = function(t3, e3, r3, n2) { - t3 = +t3, e3 >>>= 0, r3 >>>= 0, n2 || I(this, t3, e3, r3, Math.pow(2, 8 * r3) - 1, 0); - let i2 = 1, o2 = 0; - for (this[e3] = 255 & t3; ++o2 < r3 && (i2 *= 256); ) - this[e3 + o2] = t3 / i2 & 255; - return e3 + r3; - }, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(t3, e3, r3, n2) { - t3 = +t3, e3 >>>= 0, r3 >>>= 0, n2 || I(this, t3, e3, r3, Math.pow(2, 8 * r3) - 1, 0); - let i2 = r3 - 1, o2 = 1; - for (this[e3 + i2] = 255 & t3; --i2 >= 0 && (o2 *= 256); ) - this[e3 + i2] = t3 / o2 & 255; - return e3 + r3; - }, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 1, 255, 0), this[e3] = 255 & t3, e3 + 1; - }, u.prototype.writeUint16LE = u.prototype.writeUInt16LE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 65535, 0), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, e3 + 2; - }, u.prototype.writeUint16BE = u.prototype.writeUInt16BE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 65535, 0), this[e3] = t3 >>> 8, this[e3 + 1] = 255 & t3, e3 + 2; - }, u.prototype.writeUint32LE = u.prototype.writeUInt32LE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 4294967295, 0), this[e3 + 3] = t3 >>> 24, this[e3 + 2] = t3 >>> 16, this[e3 + 1] = t3 >>> 8, this[e3] = 255 & t3, e3 + 4; - }, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 4294967295, 0), this[e3] = t3 >>> 24, this[e3 + 1] = t3 >>> 16, this[e3 + 2] = t3 >>> 8, this[e3 + 3] = 255 & t3, e3 + 4; - }, u.prototype.writeBigUInt64LE = X(function(t3, e3 = 0) { - return j(this, t3, e3, BigInt(0), BigInt("0xffffffffffffffff")); - }), u.prototype.writeBigUInt64BE = X(function(t3, e3 = 0) { - return U(this, t3, e3, BigInt(0), BigInt("0xffffffffffffffff")); - }), u.prototype.writeIntLE = function(t3, e3, r3, n2) { - if (t3 = +t3, e3 >>>= 0, !n2) { - const n3 = Math.pow(2, 8 * r3 - 1); - I(this, t3, e3, r3, n3 - 1, -n3); - } - let i2 = 0, o2 = 1, a2 = 0; - for (this[e3] = 255 & t3; ++i2 < r3 && (o2 *= 256); ) - t3 < 0 && a2 === 0 && this[e3 + i2 - 1] !== 0 && (a2 = 1), this[e3 + i2] = (t3 / o2 >> 0) - a2 & 255; - return e3 + r3; - }, u.prototype.writeIntBE = function(t3, e3, r3, n2) { - if (t3 = +t3, e3 >>>= 0, !n2) { - const n3 = Math.pow(2, 8 * r3 - 1); - I(this, t3, e3, r3, n3 - 1, -n3); - } - let i2 = r3 - 1, o2 = 1, a2 = 0; - for (this[e3 + i2] = 255 & t3; --i2 >= 0 && (o2 *= 256); ) - t3 < 0 && a2 === 0 && this[e3 + i2 + 1] !== 0 && (a2 = 1), this[e3 + i2] = (t3 / o2 >> 0) - a2 & 255; - return e3 + r3; - }, u.prototype.writeInt8 = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 1, 127, -128), t3 < 0 && (t3 = 255 + t3 + 1), this[e3] = 255 & t3, e3 + 1; - }, u.prototype.writeInt16LE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 32767, -32768), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, e3 + 2; - }, u.prototype.writeInt16BE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 2, 32767, -32768), this[e3] = t3 >>> 8, this[e3 + 1] = 255 & t3, e3 + 2; - }, u.prototype.writeInt32LE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 2147483647, -2147483648), this[e3] = 255 & t3, this[e3 + 1] = t3 >>> 8, this[e3 + 2] = t3 >>> 16, this[e3 + 3] = t3 >>> 24, e3 + 4; - }, u.prototype.writeInt32BE = function(t3, e3, r3) { - return t3 = +t3, e3 >>>= 0, r3 || I(this, t3, e3, 4, 2147483647, -2147483648), t3 < 0 && (t3 = 4294967295 + t3 + 1), this[e3] = t3 >>> 24, this[e3 + 1] = t3 >>> 16, this[e3 + 2] = t3 >>> 8, this[e3 + 3] = 255 & t3, e3 + 4; - }, u.prototype.writeBigInt64LE = X(function(t3, e3 = 0) { - return j(this, t3, e3, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); - }), u.prototype.writeBigInt64BE = X(function(t3, e3 = 0) { - return U(this, t3, e3, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); - }), u.prototype.writeFloatLE = function(t3, e3, r3) { - return C(this, t3, e3, true, r3); - }, u.prototype.writeFloatBE = function(t3, e3, r3) { - return C(this, t3, e3, false, r3); - }, u.prototype.writeDoubleLE = function(t3, e3, r3) { - return D(this, t3, e3, true, r3); - }, u.prototype.writeDoubleBE = function(t3, e3, r3) { - return D(this, t3, e3, false, r3); - }, u.prototype.copy = function(t3, e3, r3, n2) { - if (!u.isBuffer(t3)) - throw new TypeError("argument should be a Buffer"); - if (r3 || (r3 = 0), n2 || n2 === 0 || (n2 = this.length), e3 >= t3.length && (e3 = t3.length), e3 || (e3 = 0), n2 > 0 && n2 < r3 && (n2 = r3), n2 === r3) - return 0; - if (t3.length === 0 || this.length === 0) - return 0; - if (e3 < 0) - throw new RangeError("targetStart out of bounds"); - if (r3 < 0 || r3 >= this.length) - throw new RangeError("Index out of range"); - if (n2 < 0) - throw new RangeError("sourceEnd out of bounds"); - n2 > this.length && (n2 = this.length), t3.length - e3 < n2 - r3 && (n2 = t3.length - e3 + r3); - const i2 = n2 - r3; - return this === t3 && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(e3, r3, n2) : Uint8Array.prototype.set.call(t3, this.subarray(r3, n2), e3), i2; - }, u.prototype.fill = function(t3, e3, r3, n2) { - if (typeof t3 == "string") { - if (typeof e3 == "string" ? (n2 = e3, e3 = 0, r3 = this.length) : typeof r3 == "string" && (n2 = r3, r3 = this.length), n2 !== void 0 && typeof n2 != "string") - throw new TypeError("encoding must be a string"); - if (typeof n2 == "string" && !u.isEncoding(n2)) - throw new TypeError("Unknown encoding: " + n2); - if (t3.length === 1) { - const e4 = t3.charCodeAt(0); - (n2 === "utf8" && e4 < 128 || n2 === "latin1") && (t3 = e4); - } - } else - typeof t3 == "number" ? t3 &= 255 : typeof t3 == "boolean" && (t3 = Number(t3)); - if (e3 < 0 || this.length < e3 || this.length < r3) - throw new RangeError("Out of range index"); - if (r3 <= e3) - return this; - let i2; - if (e3 >>>= 0, r3 = r3 === void 0 ? this.length : r3 >>> 0, t3 || (t3 = 0), typeof t3 == "number") - for (i2 = e3; i2 < r3; ++i2) - this[i2] = t3; - else { - const o2 = u.isBuffer(t3) ? t3 : u.from(t3, n2), a2 = o2.length; - if (a2 === 0) - throw new TypeError('The value "' + t3 + '" is invalid for argument "value"'); - for (i2 = 0; i2 < r3 - e3; ++i2) - this[i2 + e3] = o2[i2 % a2]; - } - return this; - }; - const L = {}; - function K(t3, e3, r3) { - L[t3] = class extends r3 { - constructor() { - super(), Object.defineProperty(this, "message", {value: e3.apply(this, arguments), writable: true, configurable: true}), this.name = `${this.name} [${t3}]`, this.stack, delete this.name; - } - get code() { - return t3; - } - set code(t4) { - Object.defineProperty(this, "code", {configurable: true, enumerable: true, value: t4, writable: true}); - } - toString() { - return `${this.name} [${t3}]: ${this.message}`; - } - }; - } - function z(t3) { - let e3 = "", r3 = t3.length; - const n2 = t3[0] === "-" ? 1 : 0; - for (; r3 >= n2 + 4; r3 -= 3) - e3 = `_${t3.slice(r3 - 3, r3)}${e3}`; - return `${t3.slice(0, r3)}${e3}`; - } - function q(t3, e3, r3, n2, i2, o2) { - if (t3 > r3 || t3 < e3) { - const n3 = typeof e3 == "bigint" ? "n" : ""; - let i3; - throw i3 = o2 > 3 ? e3 === 0 || e3 === BigInt(0) ? `>= 0${n3} and < 2${n3} ** ${8 * (o2 + 1)}${n3}` : `>= -(2${n3} ** ${8 * (o2 + 1) - 1}${n3}) and < 2 ** ${8 * (o2 + 1) - 1}${n3}` : `>= ${e3}${n3} and <= ${r3}${n3}`, new L.ERR_OUT_OF_RANGE("value", i3, t3); - } - !function(t4, e4, r4) { - H(e4, "offset"), t4[e4] !== void 0 && t4[e4 + r4] !== void 0 || F(e4, t4.length - (r4 + 1)); - }(n2, i2, o2); - } - function H(t3, e3) { - if (typeof t3 != "number") - throw new L.ERR_INVALID_ARG_TYPE(e3, "number", t3); - } - function F(t3, e3, r3) { - if (Math.floor(t3) !== t3) - throw H(t3, r3), new L.ERR_OUT_OF_RANGE(r3 || "offset", "an integer", t3); - if (e3 < 0) - throw new L.ERR_BUFFER_OUT_OF_BOUNDS(); - throw new L.ERR_OUT_OF_RANGE(r3 || "offset", `>= ${r3 ? 1 : 0} and <= ${e3}`, t3); - } - K("ERR_BUFFER_OUT_OF_BOUNDS", function(t3) { - return t3 ? `${t3} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds"; - }, RangeError), K("ERR_INVALID_ARG_TYPE", function(t3, e3) { - return `The "${t3}" argument must be of type number. Received type ${typeof e3}`; - }, TypeError), K("ERR_OUT_OF_RANGE", function(t3, e3, r3) { - let n2 = `The value of "${t3}" is out of range.`, i2 = r3; - return Number.isInteger(r3) && Math.abs(r3) > 2 ** 32 ? i2 = z(String(r3)) : typeof r3 == "bigint" && (i2 = String(r3), (r3 > BigInt(2) ** BigInt(32) || r3 < -(BigInt(2) ** BigInt(32))) && (i2 = z(i2)), i2 += "n"), n2 += ` It must be ${e3}. Received ${i2}`, n2; - }, RangeError); - const V = /[^+/0-9A-Za-z-_]/g; - function W(t3, e3) { - let r3; - e3 = e3 || 1 / 0; - const n2 = t3.length; - let i2 = null; - const o2 = []; - for (let a2 = 0; a2 < n2; ++a2) { - if (r3 = t3.charCodeAt(a2), r3 > 55295 && r3 < 57344) { - if (!i2) { - if (r3 > 56319) { - (e3 -= 3) > -1 && o2.push(239, 191, 189); - continue; - } - if (a2 + 1 === n2) { - (e3 -= 3) > -1 && o2.push(239, 191, 189); - continue; - } - i2 = r3; - continue; - } - if (r3 < 56320) { - (e3 -= 3) > -1 && o2.push(239, 191, 189), i2 = r3; - continue; - } - r3 = 65536 + (i2 - 55296 << 10 | r3 - 56320); - } else - i2 && (e3 -= 3) > -1 && o2.push(239, 191, 189); - if (i2 = null, r3 < 128) { - if ((e3 -= 1) < 0) - break; - o2.push(r3); - } else if (r3 < 2048) { - if ((e3 -= 2) < 0) - break; - o2.push(r3 >> 6 | 192, 63 & r3 | 128); - } else if (r3 < 65536) { - if ((e3 -= 3) < 0) - break; - o2.push(r3 >> 12 | 224, r3 >> 6 & 63 | 128, 63 & r3 | 128); - } else { - if (!(r3 < 1114112)) - throw new Error("Invalid code point"); - if ((e3 -= 4) < 0) - break; - o2.push(r3 >> 18 | 240, r3 >> 12 & 63 | 128, r3 >> 6 & 63 | 128, 63 & r3 | 128); - } - } - return o2; - } - function J(t3) { - return n.toByteArray(function(t4) { - if ((t4 = (t4 = t4.split("=")[0]).trim().replace(V, "")).length < 2) - return ""; - for (; t4.length % 4 != 0; ) - t4 += "="; - return t4; - }(t3)); - } - function $(t3, e3, r3, n2) { - let i2; - for (i2 = 0; i2 < n2 && !(i2 + r3 >= e3.length || i2 >= t3.length); ++i2) - e3[i2 + r3] = t3[i2]; - return i2; - } - function G(t3, e3) { - return t3 instanceof e3 || t3 != null && t3.constructor != null && t3.constructor.name != null && t3.constructor.name === e3.name; - } - function Z(t3) { - return t3 != t3; - } - const Y = function() { - const t3 = "0123456789abcdef", e3 = new Array(256); - for (let r3 = 0; r3 < 16; ++r3) { - const n2 = 16 * r3; - for (let i2 = 0; i2 < 16; ++i2) - e3[n2 + i2] = t3[r3] + t3[i2]; - } - return e3; - }(); - function X(t3) { - return typeof BigInt == "undefined" ? Q : t3; - } - function Q() { - throw new Error("BigInt not supported"); - } - }, 1924: (t2, e2, r2) => { - var n = r2(210), i = r2(5559), o = i(n("String.prototype.indexOf")); - t2.exports = function(t3, e3) { - var r3 = n(t3, !!e3); - return typeof r3 == "function" && o(t3, ".prototype.") > -1 ? i(r3) : r3; - }; - }, 5559: (t2, e2, r2) => { - var n = r2(8612), i = r2(210), o = i("%Function.prototype.apply%"), a = i("%Function.prototype.call%"), s = i("%Reflect.apply%", true) || n.call(a, o), u = i("%Object.getOwnPropertyDescriptor%", true), f = i("%Object.defineProperty%", true), c = i("%Math.max%"); - if (f) - try { - f({}, "a", {value: 1}); - } catch (t3) { - f = null; - } - t2.exports = function(t3) { - var e3 = s(n, a, arguments); - if (u && f) { - var r3 = u(e3, "length"); - r3.configurable && f(e3, "length", {value: 1 + c(0, t3.length - (arguments.length - 1))}); - } - return e3; - }; - var h = function() { - return s(n, o, arguments); - }; - f ? f(t2.exports, "apply", {value: h}) : t2.exports.apply = h; - }, 1027: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(2830).Transform, o = r2(2553).s; - function a(t3) { - i.call(this), this.hashMode = typeof t3 == "string", this.hashMode ? this[t3] = this._finalOrDigest : this.final = this._finalOrDigest, this._final && (this.__final = this._final, this._final = null), this._decoder = null, this._encoding = null; - } - r2(5717)(a, i), a.prototype.update = function(t3, e3, r3) { - typeof t3 == "string" && (t3 = n.from(t3, e3)); - var i2 = this._update(t3); - return this.hashMode ? this : (r3 && (i2 = this._toString(i2, r3)), i2); - }, a.prototype.setAutoPadding = function() { - }, a.prototype.getAuthTag = function() { - throw new Error("trying to get auth tag in unsupported state"); - }, a.prototype.setAuthTag = function() { - throw new Error("trying to set auth tag in unsupported state"); - }, a.prototype.setAAD = function() { - throw new Error("trying to set aad in unsupported state"); - }, a.prototype._transform = function(t3, e3, r3) { - var n2; - try { - this.hashMode ? this._update(t3) : this.push(this._update(t3)); - } catch (t4) { - n2 = t4; - } finally { - r3(n2); - } - }, a.prototype._flush = function(t3) { - var e3; - try { - this.push(this.__final()); - } catch (t4) { - e3 = t4; - } - t3(e3); - }, a.prototype._finalOrDigest = function(t3) { - var e3 = this.__final() || n.alloc(0); - return t3 && (e3 = this._toString(e3, t3, true)), e3; - }, a.prototype._toString = function(t3, e3, r3) { - if (this._decoder || (this._decoder = new o(e3), this._encoding = e3), this._encoding !== e3) - throw new Error("can't switch encodings"); - var n2 = this._decoder.write(t3); - return r3 && (n2 += this._decoder.end()), n2; - }, t2.exports = a; - }, 6393: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(6266), o = r2(3550); - t2.exports = function(t3) { - return new s(t3); - }; - var a = {secp256k1: {name: "secp256k1", byteLength: 32}, secp224r1: {name: "p224", byteLength: 28}, prime256v1: {name: "p256", byteLength: 32}, prime192v1: {name: "p192", byteLength: 24}, ed25519: {name: "ed25519", byteLength: 32}, secp384r1: {name: "p384", byteLength: 48}, secp521r1: {name: "p521", byteLength: 66}}; - function s(t3) { - this.curveType = a[t3], this.curveType || (this.curveType = {name: t3}), this.curve = new i.ec(this.curveType.name), this.keys = void 0; - } - function u(t3, e3, r3) { - Array.isArray(t3) || (t3 = t3.toArray()); - var i2 = new n(t3); - if (r3 && i2.length < r3) { - var o2 = new n(r3 - i2.length); - o2.fill(0), i2 = n.concat([o2, i2]); - } - return e3 ? i2.toString(e3) : i2; - } - a.p224 = a.secp224r1, a.p256 = a.secp256r1 = a.prime256v1, a.p192 = a.secp192r1 = a.prime192v1, a.p384 = a.secp384r1, a.p521 = a.secp521r1, s.prototype.generateKeys = function(t3, e3) { - return this.keys = this.curve.genKeyPair(), this.getPublicKey(t3, e3); - }, s.prototype.computeSecret = function(t3, e3, r3) { - return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), u(this.curve.keyFromPublic(t3).getPublic().mul(this.keys.getPrivate()).getX(), r3, this.curveType.byteLength); - }, s.prototype.getPublicKey = function(t3, e3) { - var r3 = this.keys.getPublic(e3 === "compressed", true); - return e3 === "hybrid" && (r3[r3.length - 1] % 2 ? r3[0] = 7 : r3[0] = 6), u(r3, t3); - }, s.prototype.getPrivateKey = function(t3) { - return u(this.keys.getPrivate(), t3); - }, s.prototype.setPublicKey = function(t3, e3) { - return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this.keys._importPublic(t3), this; - }, s.prototype.setPrivateKey = function(t3, e3) { - e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)); - var r3 = new o(t3); - return r3 = r3.toString(16), this.keys = this.curve.genKeyPair(), this.keys._importPrivate(r3), this; - }; - }, 3482: (t2, e2, r2) => { - var n = r2(5717), i = r2(2318), o = r2(9785), a = r2(9072), s = r2(1027); - function u(t3) { - s.call(this, "digest"), this._hash = t3; - } - n(u, s), u.prototype._update = function(t3) { - this._hash.update(t3); - }, u.prototype._final = function() { - return this._hash.digest(); - }, t2.exports = function(t3) { - return (t3 = t3.toLowerCase()) === "md5" ? new i() : t3 === "rmd160" || t3 === "ripemd160" ? new o() : new u(a(t3)); - }; - }, 8028: (t2, e2, r2) => { - var n = r2(2318); - t2.exports = function(t3) { - return new n().update(t3).digest(); - }; - }, 8355: (t2, e2, r2) => { - var n = r2(5717), i = r2(1031), o = r2(1027), a = r2(9509).Buffer, s = r2(8028), u = r2(9785), f = r2(9072), c = a.alloc(128); - function h(t3, e3) { - o.call(this, "digest"), typeof e3 == "string" && (e3 = a.from(e3)); - var r3 = t3 === "sha512" || t3 === "sha384" ? 128 : 64; - this._alg = t3, this._key = e3, e3.length > r3 ? e3 = (t3 === "rmd160" ? new u() : f(t3)).update(e3).digest() : e3.length < r3 && (e3 = a.concat([e3, c], r3)); - for (var n2 = this._ipad = a.allocUnsafe(r3), i2 = this._opad = a.allocUnsafe(r3), s2 = 0; s2 < r3; s2++) - n2[s2] = 54 ^ e3[s2], i2[s2] = 92 ^ e3[s2]; - this._hash = t3 === "rmd160" ? new u() : f(t3), this._hash.update(n2); - } - n(h, o), h.prototype._update = function(t3) { - this._hash.update(t3); - }, h.prototype._final = function() { - var t3 = this._hash.digest(); - return (this._alg === "rmd160" ? new u() : f(this._alg)).update(this._opad).update(t3).digest(); - }, t2.exports = function(t3, e3) { - return (t3 = t3.toLowerCase()) === "rmd160" || t3 === "ripemd160" ? new h("rmd160", e3) : t3 === "md5" ? new i(s, e3) : new h(t3, e3); - }; - }, 1031: (t2, e2, r2) => { - var n = r2(5717), i = r2(9509).Buffer, o = r2(1027), a = i.alloc(128), s = 64; - function u(t3, e3) { - o.call(this, "digest"), typeof e3 == "string" && (e3 = i.from(e3)), this._alg = t3, this._key = e3, e3.length > s ? e3 = t3(e3) : e3.length < s && (e3 = i.concat([e3, a], s)); - for (var r3 = this._ipad = i.allocUnsafe(s), n2 = this._opad = i.allocUnsafe(s), u2 = 0; u2 < s; u2++) - r3[u2] = 54 ^ e3[u2], n2[u2] = 92 ^ e3[u2]; - this._hash = [r3]; - } - n(u, o), u.prototype._update = function(t3) { - this._hash.push(t3); - }, u.prototype._final = function() { - var t3 = this._alg(i.concat(this._hash)); - return this._alg(i.concat([this._opad, t3])); - }, t2.exports = u; - }, 5835: (t2, e2, r2) => { - e2.randomBytes = e2.rng = e2.pseudoRandomBytes = e2.prng = r2(1798), e2.createHash = e2.Hash = r2(3482), e2.createHmac = e2.Hmac = r2(8355); - var n = r2(6042), i = Object.keys(n), o = ["sha1", "sha224", "sha256", "sha384", "sha512", "md5", "rmd160"].concat(i); - e2.getHashes = function() { - return o; - }; - var a = r2(5632); - e2.pbkdf2 = a.pbkdf2, e2.pbkdf2Sync = a.pbkdf2Sync; - var s = r2(3614); - e2.Cipher = s.Cipher, e2.createCipher = s.createCipher, e2.Cipheriv = s.Cipheriv, e2.createCipheriv = s.createCipheriv, e2.Decipher = s.Decipher, e2.createDecipher = s.createDecipher, e2.Decipheriv = s.Decipheriv, e2.createDecipheriv = s.createDecipheriv, e2.getCiphers = s.getCiphers, e2.listCiphers = s.listCiphers; - var u = r2(2607); - e2.DiffieHellmanGroup = u.DiffieHellmanGroup, e2.createDiffieHellmanGroup = u.createDiffieHellmanGroup, e2.getDiffieHellman = u.getDiffieHellman, e2.createDiffieHellman = u.createDiffieHellman, e2.DiffieHellman = u.DiffieHellman; - var f = r2(4743); - e2.createSign = f.createSign, e2.Sign = f.Sign, e2.createVerify = f.createVerify, e2.Verify = f.Verify, e2.createECDH = r2(6393); - var c = r2(7900); - e2.publicEncrypt = c.publicEncrypt, e2.privateEncrypt = c.privateEncrypt, e2.publicDecrypt = c.publicDecrypt, e2.privateDecrypt = c.privateDecrypt; - var h = r2(7963); - e2.randomFill = h.randomFill, e2.randomFillSync = h.randomFillSync, e2.createCredentials = function() { - throw new Error(["sorry, createCredentials is not implemented yet", "we accept pull requests", "https://github.com/crypto-browserify/crypto-browserify"].join("\n")); - }, e2.constants = {DH_CHECK_P_NOT_SAFE_PRIME: 2, DH_CHECK_P_NOT_PRIME: 1, DH_UNABLE_TO_CHECK_GENERATOR: 4, DH_NOT_SUITABLE_GENERATOR: 8, NPN_ENABLED: 1, ALPN_ENABLED: 1, RSA_PKCS1_PADDING: 1, RSA_SSLV23_PADDING: 2, RSA_NO_PADDING: 3, RSA_PKCS1_OAEP_PADDING: 4, RSA_X931_PADDING: 5, RSA_PKCS1_PSS_PADDING: 6, POINT_CONVERSION_COMPRESSED: 2, POINT_CONVERSION_UNCOMPRESSED: 4, POINT_CONVERSION_HYBRID: 6}; - }, 4289: (t2, e2, r2) => { - var n = r2(2215), i = typeof Symbol == "function" && typeof Symbol("foo") == "symbol", o = Object.prototype.toString, a = Array.prototype.concat, s = Object.defineProperty, u = s && function() { - var t3 = {}; - try { - for (var e3 in s(t3, "x", {enumerable: false, value: t3}), t3) - return false; - return t3.x === t3; - } catch (t4) { - return false; - } - }(), f = function(t3, e3, r3, n2) { - var i2; - (!(e3 in t3) || typeof (i2 = n2) == "function" && o.call(i2) === "[object Function]" && n2()) && (u ? s(t3, e3, {configurable: true, enumerable: false, value: r3, writable: true}) : t3[e3] = r3); - }, c = function(t3, e3) { - var r3 = arguments.length > 2 ? arguments[2] : {}, o2 = n(e3); - i && (o2 = a.call(o2, Object.getOwnPropertySymbols(e3))); - for (var s2 = 0; s2 < o2.length; s2 += 1) - f(t3, o2[s2], e3[o2[s2]], r3[o2[s2]]); - }; - c.supportsDescriptors = !!u, t2.exports = c; - }, 5251: (t2, e2, r2) => { - e2.utils = r2(1278), e2.Cipher = r2(5756), e2.DES = r2(778), e2.CBC = r2(9051), e2.EDE = r2(651); - }, 9051: (t2, e2, r2) => { - var n = r2(9746), i = r2(5717), o = {}; - function a(t3) { - n.equal(t3.length, 8, "Invalid IV length"), this.iv = new Array(8); - for (var e3 = 0; e3 < this.iv.length; e3++) - this.iv[e3] = t3[e3]; - } - e2.instantiate = function(t3) { - function e3(e4) { - t3.call(this, e4), this._cbcInit(); - } - i(e3, t3); - for (var r3 = Object.keys(o), n2 = 0; n2 < r3.length; n2++) { - var a2 = r3[n2]; - e3.prototype[a2] = o[a2]; - } - return e3.create = function(t4) { - return new e3(t4); - }, e3; - }, o._cbcInit = function() { - var t3 = new a(this.options.iv); - this._cbcState = t3; - }, o._update = function(t3, e3, r3, n2) { - var i2 = this._cbcState, o2 = this.constructor.super_.prototype, a2 = i2.iv; - if (this.type === "encrypt") { - for (var s = 0; s < this.blockSize; s++) - a2[s] ^= t3[e3 + s]; - for (o2._update.call(this, a2, 0, r3, n2), s = 0; s < this.blockSize; s++) - a2[s] = r3[n2 + s]; - } else { - for (o2._update.call(this, t3, e3, r3, n2), s = 0; s < this.blockSize; s++) - r3[n2 + s] ^= a2[s]; - for (s = 0; s < this.blockSize; s++) - a2[s] = t3[e3 + s]; - } - }; - }, 5756: (t2, e2, r2) => { - var n = r2(9746); - function i(t3) { - this.options = t3, this.type = this.options.type, this.blockSize = 8, this._init(), this.buffer = new Array(this.blockSize), this.bufferOff = 0; - } - t2.exports = i, i.prototype._init = function() { - }, i.prototype.update = function(t3) { - return t3.length === 0 ? [] : this.type === "decrypt" ? this._updateDecrypt(t3) : this._updateEncrypt(t3); - }, i.prototype._buffer = function(t3, e3) { - for (var r3 = Math.min(this.buffer.length - this.bufferOff, t3.length - e3), n2 = 0; n2 < r3; n2++) - this.buffer[this.bufferOff + n2] = t3[e3 + n2]; - return this.bufferOff += r3, r3; - }, i.prototype._flushBuffer = function(t3, e3) { - return this._update(this.buffer, 0, t3, e3), this.bufferOff = 0, this.blockSize; - }, i.prototype._updateEncrypt = function(t3) { - var e3 = 0, r3 = 0, n2 = (this.bufferOff + t3.length) / this.blockSize | 0, i2 = new Array(n2 * this.blockSize); - this.bufferOff !== 0 && (e3 += this._buffer(t3, e3), this.bufferOff === this.buffer.length && (r3 += this._flushBuffer(i2, r3))); - for (var o = t3.length - (t3.length - e3) % this.blockSize; e3 < o; e3 += this.blockSize) - this._update(t3, e3, i2, r3), r3 += this.blockSize; - for (; e3 < t3.length; e3++, this.bufferOff++) - this.buffer[this.bufferOff] = t3[e3]; - return i2; - }, i.prototype._updateDecrypt = function(t3) { - for (var e3 = 0, r3 = 0, n2 = Math.ceil((this.bufferOff + t3.length) / this.blockSize) - 1, i2 = new Array(n2 * this.blockSize); n2 > 0; n2--) - e3 += this._buffer(t3, e3), r3 += this._flushBuffer(i2, r3); - return e3 += this._buffer(t3, e3), i2; - }, i.prototype.final = function(t3) { - var e3, r3; - return t3 && (e3 = this.update(t3)), r3 = this.type === "encrypt" ? this._finalEncrypt() : this._finalDecrypt(), e3 ? e3.concat(r3) : r3; - }, i.prototype._pad = function(t3, e3) { - if (e3 === 0) - return false; - for (; e3 < t3.length; ) - t3[e3++] = 0; - return true; - }, i.prototype._finalEncrypt = function() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; - var t3 = new Array(this.blockSize); - return this._update(this.buffer, 0, t3, 0), t3; - }, i.prototype._unpad = function(t3) { - return t3; - }, i.prototype._finalDecrypt = function() { - n.equal(this.bufferOff, this.blockSize, "Not enough data to decrypt"); - var t3 = new Array(this.blockSize); - return this._flushBuffer(t3, 0), this._unpad(t3); - }; - }, 778: (t2, e2, r2) => { - var n = r2(9746), i = r2(5717), o = r2(1278), a = r2(5756); - function s() { - this.tmp = new Array(2), this.keys = null; - } - function u(t3) { - a.call(this, t3); - var e3 = new s(); - this._desState = e3, this.deriveKeys(e3, t3.key); - } - i(u, a), t2.exports = u, u.create = function(t3) { - return new u(t3); - }; - var f = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]; - u.prototype.deriveKeys = function(t3, e3) { - t3.keys = new Array(32), n.equal(e3.length, this.blockSize, "Invalid key length"); - var r3 = o.readUInt32BE(e3, 0), i2 = o.readUInt32BE(e3, 4); - o.pc1(r3, i2, t3.tmp, 0), r3 = t3.tmp[0], i2 = t3.tmp[1]; - for (var a2 = 0; a2 < t3.keys.length; a2 += 2) { - var s2 = f[a2 >>> 1]; - r3 = o.r28shl(r3, s2), i2 = o.r28shl(i2, s2), o.pc2(r3, i2, t3.keys, a2); - } - }, u.prototype._update = function(t3, e3, r3, n2) { - var i2 = this._desState, a2 = o.readUInt32BE(t3, e3), s2 = o.readUInt32BE(t3, e3 + 4); - o.ip(a2, s2, i2.tmp, 0), a2 = i2.tmp[0], s2 = i2.tmp[1], this.type === "encrypt" ? this._encrypt(i2, a2, s2, i2.tmp, 0) : this._decrypt(i2, a2, s2, i2.tmp, 0), a2 = i2.tmp[0], s2 = i2.tmp[1], o.writeUInt32BE(r3, a2, n2), o.writeUInt32BE(r3, s2, n2 + 4); - }, u.prototype._pad = function(t3, e3) { - for (var r3 = t3.length - e3, n2 = e3; n2 < t3.length; n2++) - t3[n2] = r3; - return true; - }, u.prototype._unpad = function(t3) { - for (var e3 = t3[t3.length - 1], r3 = t3.length - e3; r3 < t3.length; r3++) - n.equal(t3[r3], e3); - return t3.slice(0, t3.length - e3); - }, u.prototype._encrypt = function(t3, e3, r3, n2, i2) { - for (var a2 = e3, s2 = r3, u2 = 0; u2 < t3.keys.length; u2 += 2) { - var f2 = t3.keys[u2], c = t3.keys[u2 + 1]; - o.expand(s2, t3.tmp, 0), f2 ^= t3.tmp[0], c ^= t3.tmp[1]; - var h = o.substitute(f2, c), l = s2; - s2 = (a2 ^ o.permute(h)) >>> 0, a2 = l; - } - o.rip(s2, a2, n2, i2); - }, u.prototype._decrypt = function(t3, e3, r3, n2, i2) { - for (var a2 = r3, s2 = e3, u2 = t3.keys.length - 2; u2 >= 0; u2 -= 2) { - var f2 = t3.keys[u2], c = t3.keys[u2 + 1]; - o.expand(a2, t3.tmp, 0), f2 ^= t3.tmp[0], c ^= t3.tmp[1]; - var h = o.substitute(f2, c), l = a2; - a2 = (s2 ^ o.permute(h)) >>> 0, s2 = l; - } - o.rip(a2, s2, n2, i2); - }; - }, 651: (t2, e2, r2) => { - var n = r2(9746), i = r2(5717), o = r2(5756), a = r2(778); - function s(t3, e3) { - n.equal(e3.length, 24, "Invalid key length"); - var r3 = e3.slice(0, 8), i2 = e3.slice(8, 16), o2 = e3.slice(16, 24); - this.ciphers = t3 === "encrypt" ? [a.create({type: "encrypt", key: r3}), a.create({type: "decrypt", key: i2}), a.create({type: "encrypt", key: o2})] : [a.create({type: "decrypt", key: o2}), a.create({type: "encrypt", key: i2}), a.create({type: "decrypt", key: r3})]; - } - function u(t3) { - o.call(this, t3); - var e3 = new s(this.type, this.options.key); - this._edeState = e3; - } - i(u, o), t2.exports = u, u.create = function(t3) { - return new u(t3); - }, u.prototype._update = function(t3, e3, r3, n2) { - var i2 = this._edeState; - i2.ciphers[0]._update(t3, e3, r3, n2), i2.ciphers[1]._update(r3, n2, r3, n2), i2.ciphers[2]._update(r3, n2, r3, n2); - }, u.prototype._pad = a.prototype._pad, u.prototype._unpad = a.prototype._unpad; - }, 1278: (t2, e2) => { - e2.readUInt32BE = function(t3, e3) { - return (t3[0 + e3] << 24 | t3[1 + e3] << 16 | t3[2 + e3] << 8 | t3[3 + e3]) >>> 0; - }, e2.writeUInt32BE = function(t3, e3, r3) { - t3[0 + r3] = e3 >>> 24, t3[1 + r3] = e3 >>> 16 & 255, t3[2 + r3] = e3 >>> 8 & 255, t3[3 + r3] = 255 & e3; - }, e2.ip = function(t3, e3, r3, n2) { - for (var i2 = 0, o = 0, a = 6; a >= 0; a -= 2) { - for (var s = 0; s <= 24; s += 8) - i2 <<= 1, i2 |= e3 >>> s + a & 1; - for (s = 0; s <= 24; s += 8) - i2 <<= 1, i2 |= t3 >>> s + a & 1; - } - for (a = 6; a >= 0; a -= 2) { - for (s = 1; s <= 25; s += 8) - o <<= 1, o |= e3 >>> s + a & 1; - for (s = 1; s <= 25; s += 8) - o <<= 1, o |= t3 >>> s + a & 1; - } - r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; - }, e2.rip = function(t3, e3, r3, n2) { - for (var i2 = 0, o = 0, a = 0; a < 4; a++) - for (var s = 24; s >= 0; s -= 8) - i2 <<= 1, i2 |= e3 >>> s + a & 1, i2 <<= 1, i2 |= t3 >>> s + a & 1; - for (a = 4; a < 8; a++) - for (s = 24; s >= 0; s -= 8) - o <<= 1, o |= e3 >>> s + a & 1, o <<= 1, o |= t3 >>> s + a & 1; - r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; - }, e2.pc1 = function(t3, e3, r3, n2) { - for (var i2 = 0, o = 0, a = 7; a >= 5; a--) { - for (var s = 0; s <= 24; s += 8) - i2 <<= 1, i2 |= e3 >> s + a & 1; - for (s = 0; s <= 24; s += 8) - i2 <<= 1, i2 |= t3 >> s + a & 1; - } - for (s = 0; s <= 24; s += 8) - i2 <<= 1, i2 |= e3 >> s + a & 1; - for (a = 1; a <= 3; a++) { - for (s = 0; s <= 24; s += 8) - o <<= 1, o |= e3 >> s + a & 1; - for (s = 0; s <= 24; s += 8) - o <<= 1, o |= t3 >> s + a & 1; - } - for (s = 0; s <= 24; s += 8) - o <<= 1, o |= t3 >> s + a & 1; - r3[n2 + 0] = i2 >>> 0, r3[n2 + 1] = o >>> 0; - }, e2.r28shl = function(t3, e3) { - return t3 << e3 & 268435455 | t3 >>> 28 - e3; - }; - var r2 = [14, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, 15, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24]; - e2.pc2 = function(t3, e3, n2, i2) { - for (var o = 0, a = 0, s = r2.length >>> 1, u = 0; u < s; u++) - o <<= 1, o |= t3 >>> r2[u] & 1; - for (u = s; u < r2.length; u++) - a <<= 1, a |= e3 >>> r2[u] & 1; - n2[i2 + 0] = o >>> 0, n2[i2 + 1] = a >>> 0; - }, e2.expand = function(t3, e3, r3) { - var n2 = 0, i2 = 0; - n2 = (1 & t3) << 5 | t3 >>> 27; - for (var o = 23; o >= 15; o -= 4) - n2 <<= 6, n2 |= t3 >>> o & 63; - for (o = 11; o >= 3; o -= 4) - i2 |= t3 >>> o & 63, i2 <<= 6; - i2 |= (31 & t3) << 1 | t3 >>> 31, e3[r3 + 0] = n2 >>> 0, e3[r3 + 1] = i2 >>> 0; - }; - var n = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11]; - e2.substitute = function(t3, e3) { - for (var r3 = 0, i2 = 0; i2 < 4; i2++) - r3 <<= 4, r3 |= n[64 * i2 + (t3 >>> 18 - 6 * i2 & 63)]; - for (i2 = 0; i2 < 4; i2++) - r3 <<= 4, r3 |= n[256 + 64 * i2 + (e3 >>> 18 - 6 * i2 & 63)]; - return r3 >>> 0; - }; - var i = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7]; - e2.permute = function(t3) { - for (var e3 = 0, r3 = 0; r3 < i.length; r3++) - e3 <<= 1, e3 |= t3 >>> i[r3] & 1; - return e3 >>> 0; - }, e2.padSplit = function(t3, e3, r3) { - for (var n2 = t3.toString(2); n2.length < e3; ) - n2 = "0" + n2; - for (var i2 = [], o = 0; o < e3; o += r3) - i2.push(n2.slice(o, o + r3)); - return i2.join(" "); - }; - }, 2607: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(3590), o = r2(1930), a = r2(7426), s = {binary: true, hex: true, base64: true}; - e2.DiffieHellmanGroup = e2.createDiffieHellmanGroup = e2.getDiffieHellman = function(t3) { - var e3 = new n(o[t3].prime, "hex"), r3 = new n(o[t3].gen, "hex"); - return new a(e3, r3); - }, e2.createDiffieHellman = e2.DiffieHellman = function t3(e3, r3, o2, u) { - return n.isBuffer(r3) || s[r3] === void 0 ? t3(e3, "binary", r3, o2) : (r3 = r3 || "binary", u = u || "binary", o2 = o2 || new n([2]), n.isBuffer(o2) || (o2 = new n(o2, u)), typeof e3 == "number" ? new a(i(e3, o2), o2, true) : (n.isBuffer(e3) || (e3 = new n(e3, r3)), new a(e3, o2, true))); - }; - }, 7426: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(3550), o = new (r2(3047))(), a = new i(24), s = new i(11), u = new i(10), f = new i(3), c = new i(7), h = r2(3590), l = r2(1798); - function d(t3, e3) { - return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this._pub = new i(t3), this; - } - function p(t3, e3) { - return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this._priv = new i(t3), this; - } - t2.exports = m; - var y = {}; - function m(t3, e3, r3) { - this.setGenerator(e3), this.__prime = new i(t3), this._prime = i.mont(this.__prime), this._primeLen = t3.length, this._pub = void 0, this._priv = void 0, this._primeCode = void 0, r3 ? (this.setPublicKey = d, this.setPrivateKey = p) : this._primeCode = 8; - } - function b(t3, e3) { - var r3 = new n(t3.toArray()); - return e3 ? r3.toString(e3) : r3; - } - Object.defineProperty(m.prototype, "verifyError", {enumerable: true, get: function() { - return typeof this._primeCode != "number" && (this._primeCode = function(t3, e3) { - var r3 = e3.toString("hex"), n2 = [r3, t3.toString(16)].join("_"); - if (n2 in y) - return y[n2]; - var i2, l2 = 0; - if (t3.isEven() || !h.simpleSieve || !h.fermatTest(t3) || !o.test(t3)) - return l2 += 1, l2 += r3 === "02" || r3 === "05" ? 8 : 4, y[n2] = l2, l2; - switch (o.test(t3.shrn(1)) || (l2 += 2), r3) { - case "02": - t3.mod(a).cmp(s) && (l2 += 8); - break; - case "05": - (i2 = t3.mod(u)).cmp(f) && i2.cmp(c) && (l2 += 8); - break; - default: - l2 += 4; - } - return y[n2] = l2, l2; - }(this.__prime, this.__gen)), this._primeCode; - }}), m.prototype.generateKeys = function() { - return this._priv || (this._priv = new i(l(this._primeLen))), this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(), this.getPublicKey(); - }, m.prototype.computeSecret = function(t3) { - var e3 = (t3 = (t3 = new i(t3)).toRed(this._prime)).redPow(this._priv).fromRed(), r3 = new n(e3.toArray()), o2 = this.getPrime(); - if (r3.length < o2.length) { - var a2 = new n(o2.length - r3.length); - a2.fill(0), r3 = n.concat([a2, r3]); - } - return r3; - }, m.prototype.getPublicKey = function(t3) { - return b(this._pub, t3); - }, m.prototype.getPrivateKey = function(t3) { - return b(this._priv, t3); - }, m.prototype.getPrime = function(t3) { - return b(this.__prime, t3); - }, m.prototype.getGenerator = function(t3) { - return b(this._gen, t3); - }, m.prototype.setGenerator = function(t3, e3) { - return e3 = e3 || "utf8", n.isBuffer(t3) || (t3 = new n(t3, e3)), this.__gen = t3, this._gen = new i(t3), this; - }; - }, 3590: (t2, e2, r2) => { - var n = r2(1798); - t2.exports = g, g.simpleSieve = m, g.fermatTest = b; - var i = r2(3550), o = new i(24), a = new (r2(3047))(), s = new i(1), u = new i(2), f = new i(5), c = (new i(16), new i(8), new i(10)), h = new i(3), l = (new i(7), new i(11)), d = new i(4), p = (new i(12), null); - function y() { - if (p !== null) - return p; - var t3 = []; - t3[0] = 2; - for (var e3 = 1, r3 = 3; r3 < 1048576; r3 += 2) { - for (var n2 = Math.ceil(Math.sqrt(r3)), i2 = 0; i2 < e3 && t3[i2] <= n2 && r3 % t3[i2] != 0; i2++) - ; - e3 !== i2 && t3[i2] <= n2 || (t3[e3++] = r3); - } - return p = t3, t3; - } - function m(t3) { - for (var e3 = y(), r3 = 0; r3 < e3.length; r3++) - if (t3.modn(e3[r3]) === 0) - return t3.cmpn(e3[r3]) === 0; - return true; - } - function b(t3) { - var e3 = i.mont(t3); - return u.toRed(e3).redPow(t3.subn(1)).fromRed().cmpn(1) === 0; - } - function g(t3, e3) { - if (t3 < 16) - return new i(e3 === 2 || e3 === 5 ? [140, 123] : [140, 39]); - var r3, p2; - for (e3 = new i(e3); ; ) { - for (r3 = new i(n(Math.ceil(t3 / 8))); r3.bitLength() > t3; ) - r3.ishrn(1); - if (r3.isEven() && r3.iadd(s), r3.testn(1) || r3.iadd(u), e3.cmp(u)) { - if (!e3.cmp(f)) - for (; r3.mod(c).cmp(h); ) - r3.iadd(d); - } else - for (; r3.mod(o).cmp(l); ) - r3.iadd(d); - if (m(p2 = r3.shrn(1)) && m(r3) && b(p2) && b(r3) && a.test(p2) && a.test(r3)) - return r3; - } - } - }, 1930: (t2) => { - t2.exports = JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}'); - }, 6215: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = new (r2(6266)).ec("secp256k1"), o = r2.g.crypto || r2.g.msCrypto || {}, a = o.subtle || o.webkitSubtle, s = r2(5835); - const u = n.from("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", "hex"), f = n.alloc(32, 0); - function c(t3, e3) { - if (!t3) - throw new Error(e3 || "Assertion failed"); - } - function h(t3) { - return e3 = t3, !(!n.isBuffer(e3) || e3.length !== 32) && t3.compare(f) > 0 && t3.compare(u) < 0; - var e3; - } - function l(t3) { - var e3 = new Uint8Array(t3); - return o.getRandomValues === void 0 ? n.from(s.randomBytes(t3)) : (o.getRandomValues(e3), n.from(e3)); - } - function d(t3) { - return new Promise(function(e3) { - var r3 = s.createHash("sha512").update(t3).digest(); - e3(new Uint8Array(r3)); - }); - } - function p(t3) { - return function(e3, r3, i2) { - return new Promise(function(o2) { - if (a) - return a.importKey("raw", r3, {name: "AES-CBC"}, false, [t3]).then(function(r4) { - var n2 = {name: "AES-CBC", iv: e3}; - return a[t3](n2, r4, i2); - }).then(function(t4) { - o2(n.from(new Uint8Array(t4))); - }); - if (t3 === "encrypt") { - var u2 = s.createCipheriv("aes-256-cbc", r3, e3); - let t4 = u2.update(i2), a2 = u2.final(); - o2(n.concat([t4, a2])); - } else if (t3 === "decrypt") { - var f2 = s.createDecipheriv("aes-256-cbc", r3, e3); - let t4 = f2.update(i2), a2 = f2.final(); - o2(n.concat([t4, a2])); - } - }); - }; - } - var y = p("encrypt"), m = p("decrypt"); - e2.generatePrivate = function() { - for (var t3 = l(32); !h(t3); ) - t3 = l(32); - return t3; - }; - var b = e2.getPublic = function(t3) { - return c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), n.from(i.keyFromPrivate(t3).getPublic("arr")); - }; - e2.getPublicCompressed = function(t3) { - return c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), n.from(i.keyFromPrivate(t3).getPublic(true, "arr")); - }, e2.sign = function(t3, e3) { - return new Promise(function(r3) { - c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), c(e3.length > 0, "Message should not be empty"), c(e3.length <= 32, "Message is too long"), r3(n.from(i.sign(e3, t3, {canonical: true}).toDER())); - }); - }, e2.verify = function(t3, e3, r3) { - return new Promise(function(n2, o2) { - c(t3.length === 65 || t3.length === 33, "Bad public key"), t3.length === 65 && c(t3[0] === 4, "Bad public key"), t3.length === 33 && c(t3[0] === 2 || t3[0] === 3, "Bad public key"), c(e3.length > 0, "Message should not be empty"), c(e3.length <= 32, "Message is too long"), i.verify(e3, r3, t3) ? n2(null) : o2(new Error("Bad signature")); - }); - }; - var g = e2.derive = function(t3, e3) { - return new Promise(function(r3) { - c(n.isBuffer(t3), "Bad private key"), c(n.isBuffer(e3), "Bad public key"), c(t3.length === 32, "Bad private key"), c(h(t3), "Bad private key"), c(e3.length === 65 || e3.length === 33, "Bad public key"), e3.length === 65 && c(e3[0] === 4, "Bad public key"), e3.length === 33 && c(e3[0] === 2 || e3[0] === 3, "Bad public key"); - var o2 = i.keyFromPrivate(t3), a2 = i.keyFromPublic(e3), s2 = o2.derive(a2.getPublic()); - r3(n.from(s2.toArray())); - }); - }; - e2.encrypt = function(t3, e3, r3) { - var i2, o2, a2, u2; - return r3 = r3 || {}, new Promise(function(e4) { - for (var n2 = r3.ephemPrivateKey || l(32); !h(n2); ) - n2 = r3.ephemPrivateKey || l(32); - o2 = b(n2), e4(g(n2, t3)); - }).then(function(t4) { - return d(t4); - }).then(function(t4) { - i2 = r3.iv || l(16); - var n2 = t4.slice(0, 32); - return u2 = t4.slice(32), y(i2, n2, e3); - }).then(function(t4) { - a2 = t4; - var e4 = n.concat([i2, o2, a2]); - return function(t5, e5) { - return new Promise(function(r4) { - var i3 = s.createHmac("sha256", n.from(t5)); - i3.update(e5), r4(i3.digest()); - }); - }(u2, e4); - }).then(function(t4) { - return {iv: i2, ephemPublicKey: o2, ciphertext: a2, mac: t4}; - }); - }, e2.decrypt = function(t3, e3) { - var r3; - return g(t3, e3.ephemPublicKey).then(function(t4) { - return d(t4); - }).then(function(t4) { - r3 = t4.slice(0, 32); - var i2, o2, a2, u2 = t4.slice(32), f2 = n.concat([e3.iv, e3.ephemPublicKey, e3.ciphertext]); - return i2 = u2, o2 = f2, a2 = e3.mac, new Promise(function(t5) { - var e4 = s.createHmac("sha256", n.from(i2)); - e4.update(o2), t5(function(t6, e5) { - if (t6.length !== e5.length) - return false; - for (var r4 = 0, n2 = 0; n2 < t6.length; n2++) - r4 |= t6[n2] ^ e5[n2]; - return r4 === 0; - }(e4.digest(), a2)); - }); - }).then(function(t4) { - return c(t4, "Bad MAC"), m(e3.iv, r3, e3.ciphertext); - }).then(function(t4) { - return n.from(new Uint8Array(t4)); - }); - }; - }, 6266: (t2, e2, r2) => { - var n = e2; - n.version = r2(7519).i8, n.utils = r2(953), n.rand = r2(7376), n.curve = r2(8254), n.curves = r2(5427), n.ec = r2(7954), n.eddsa = r2(5980); - }, 4918: (t2, e2, r2) => { - var n = r2(3550), i = r2(953), o = i.getNAF, a = i.getJSF, s = i.assert; - function u(t3, e3) { - this.type = t3, this.p = new n(e3.p, 16), this.red = e3.prime ? n.red(e3.prime) : n.mont(this.p), this.zero = new n(0).toRed(this.red), this.one = new n(1).toRed(this.red), this.two = new n(2).toRed(this.red), this.n = e3.n && new n(e3.n, 16), this.g = e3.g && this.pointFromJSON(e3.g, e3.gRed), this._wnafT1 = new Array(4), this._wnafT2 = new Array(4), this._wnafT3 = new Array(4), this._wnafT4 = new Array(4), this._bitLength = this.n ? this.n.bitLength() : 0; - var r3 = this.n && this.p.div(this.n); - !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); - } - function f(t3, e3) { - this.curve = t3, this.type = e3, this.precomputed = null; - } - t2.exports = u, u.prototype.point = function() { - throw new Error("Not implemented"); - }, u.prototype.validate = function() { - throw new Error("Not implemented"); - }, u.prototype._fixedNafMul = function(t3, e3) { - s(t3.precomputed); - var r3 = t3._getDoubles(), n2 = o(e3, 1, this._bitLength), i2 = (1 << r3.step + 1) - (r3.step % 2 == 0 ? 2 : 1); - i2 /= 3; - var a2, u2, f2 = []; - for (a2 = 0; a2 < n2.length; a2 += r3.step) { - u2 = 0; - for (var c = a2 + r3.step - 1; c >= a2; c--) - u2 = (u2 << 1) + n2[c]; - f2.push(u2); - } - for (var h = this.jpoint(null, null, null), l = this.jpoint(null, null, null), d = i2; d > 0; d--) { - for (a2 = 0; a2 < f2.length; a2++) - (u2 = f2[a2]) === d ? l = l.mixedAdd(r3.points[a2]) : u2 === -d && (l = l.mixedAdd(r3.points[a2].neg())); - h = h.add(l); - } - return h.toP(); - }, u.prototype._wnafMul = function(t3, e3) { - var r3 = 4, n2 = t3._getNAFPoints(r3); - r3 = n2.wnd; - for (var i2 = n2.points, a2 = o(e3, r3, this._bitLength), u2 = this.jpoint(null, null, null), f2 = a2.length - 1; f2 >= 0; f2--) { - for (var c = 0; f2 >= 0 && a2[f2] === 0; f2--) - c++; - if (f2 >= 0 && c++, u2 = u2.dblp(c), f2 < 0) - break; - var h = a2[f2]; - s(h !== 0), u2 = t3.type === "affine" ? h > 0 ? u2.mixedAdd(i2[h - 1 >> 1]) : u2.mixedAdd(i2[-h - 1 >> 1].neg()) : h > 0 ? u2.add(i2[h - 1 >> 1]) : u2.add(i2[-h - 1 >> 1].neg()); - } - return t3.type === "affine" ? u2.toP() : u2; - }, u.prototype._wnafMulAdd = function(t3, e3, r3, n2, i2) { - var s2, u2, f2, c = this._wnafT1, h = this._wnafT2, l = this._wnafT3, d = 0; - for (s2 = 0; s2 < n2; s2++) { - var p = (f2 = e3[s2])._getNAFPoints(t3); - c[s2] = p.wnd, h[s2] = p.points; - } - for (s2 = n2 - 1; s2 >= 1; s2 -= 2) { - var y = s2 - 1, m = s2; - if (c[y] === 1 && c[m] === 1) { - var b = [e3[y], null, null, e3[m]]; - e3[y].y.cmp(e3[m].y) === 0 ? (b[1] = e3[y].add(e3[m]), b[2] = e3[y].toJ().mixedAdd(e3[m].neg())) : e3[y].y.cmp(e3[m].y.redNeg()) === 0 ? (b[1] = e3[y].toJ().mixedAdd(e3[m]), b[2] = e3[y].add(e3[m].neg())) : (b[1] = e3[y].toJ().mixedAdd(e3[m]), b[2] = e3[y].toJ().mixedAdd(e3[m].neg())); - var g = [-3, -1, -5, -7, 0, 7, 5, 1, 3], v = a(r3[y], r3[m]); - for (d = Math.max(v[0].length, d), l[y] = new Array(d), l[m] = new Array(d), u2 = 0; u2 < d; u2++) { - var w = 0 | v[0][u2], _ = 0 | v[1][u2]; - l[y][u2] = g[3 * (w + 1) + (_ + 1)], l[m][u2] = 0, h[y] = b; - } - } else - l[y] = o(r3[y], c[y], this._bitLength), l[m] = o(r3[m], c[m], this._bitLength), d = Math.max(l[y].length, d), d = Math.max(l[m].length, d); - } - var M = this.jpoint(null, null, null), S = this._wnafT4; - for (s2 = d; s2 >= 0; s2--) { - for (var E = 0; s2 >= 0; ) { - var A = true; - for (u2 = 0; u2 < n2; u2++) - S[u2] = 0 | l[u2][s2], S[u2] !== 0 && (A = false); - if (!A) - break; - E++, s2--; - } - if (s2 >= 0 && E++, M = M.dblp(E), s2 < 0) - break; - for (u2 = 0; u2 < n2; u2++) { - var k = S[u2]; - k !== 0 && (k > 0 ? f2 = h[u2][k - 1 >> 1] : k < 0 && (f2 = h[u2][-k - 1 >> 1].neg()), M = f2.type === "affine" ? M.mixedAdd(f2) : M.add(f2)); - } - } - for (s2 = 0; s2 < n2; s2++) - h[s2] = null; - return i2 ? M : M.toP(); - }, u.BasePoint = f, f.prototype.eq = function() { - throw new Error("Not implemented"); - }, f.prototype.validate = function() { - return this.curve.validate(this); - }, u.prototype.decodePoint = function(t3, e3) { - t3 = i.toArray(t3, e3); - var r3 = this.p.byteLength(); - if ((t3[0] === 4 || t3[0] === 6 || t3[0] === 7) && t3.length - 1 == 2 * r3) - return t3[0] === 6 ? s(t3[t3.length - 1] % 2 == 0) : t3[0] === 7 && s(t3[t3.length - 1] % 2 == 1), this.point(t3.slice(1, 1 + r3), t3.slice(1 + r3, 1 + 2 * r3)); - if ((t3[0] === 2 || t3[0] === 3) && t3.length - 1 === r3) - return this.pointFromX(t3.slice(1, 1 + r3), t3[0] === 3); - throw new Error("Unknown point format"); - }, f.prototype.encodeCompressed = function(t3) { - return this.encode(t3, true); - }, f.prototype._encode = function(t3) { - var e3 = this.curve.p.byteLength(), r3 = this.getX().toArray("be", e3); - return t3 ? [this.getY().isEven() ? 2 : 3].concat(r3) : [4].concat(r3, this.getY().toArray("be", e3)); - }, f.prototype.encode = function(t3, e3) { - return i.encode(this._encode(e3), t3); - }, f.prototype.precompute = function(t3) { - if (this.precomputed) - return this; - var e3 = {doubles: null, naf: null, beta: null}; - return e3.naf = this._getNAFPoints(8), e3.doubles = this._getDoubles(4, t3), e3.beta = this._getBeta(), this.precomputed = e3, this; - }, f.prototype._hasDoubles = function(t3) { - if (!this.precomputed) - return false; - var e3 = this.precomputed.doubles; - return !!e3 && e3.points.length >= Math.ceil((t3.bitLength() + 1) / e3.step); - }, f.prototype._getDoubles = function(t3, e3) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - for (var r3 = [this], n2 = this, i2 = 0; i2 < e3; i2 += t3) { - for (var o2 = 0; o2 < t3; o2++) - n2 = n2.dbl(); - r3.push(n2); - } - return {step: t3, points: r3}; - }, f.prototype._getNAFPoints = function(t3) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - for (var e3 = [this], r3 = (1 << t3) - 1, n2 = r3 === 1 ? null : this.dbl(), i2 = 1; i2 < r3; i2++) - e3[i2] = e3[i2 - 1].add(n2); - return {wnd: t3, points: e3}; - }, f.prototype._getBeta = function() { - return null; - }, f.prototype.dblp = function(t3) { - for (var e3 = this, r3 = 0; r3 < t3; r3++) - e3 = e3.dbl(); - return e3; - }; - }, 1138: (t2, e2, r2) => { - var n = r2(953), i = r2(3550), o = r2(5717), a = r2(4918), s = n.assert; - function u(t3) { - this.twisted = (0 | t3.a) != 1, this.mOneA = this.twisted && (0 | t3.a) == -1, this.extended = this.mOneA, a.call(this, "edwards", t3), this.a = new i(t3.a, 16).umod(this.red.m), this.a = this.a.toRed(this.red), this.c = new i(t3.c, 16).toRed(this.red), this.c2 = this.c.redSqr(), this.d = new i(t3.d, 16).toRed(this.red), this.dd = this.d.redAdd(this.d), s(!this.twisted || this.c.fromRed().cmpn(1) === 0), this.oneC = (0 | t3.c) == 1; - } - function f(t3, e3, r3, n2, o2) { - a.BasePoint.call(this, t3, "projective"), e3 === null && r3 === null && n2 === null ? (this.x = this.curve.zero, this.y = this.curve.one, this.z = this.curve.one, this.t = this.curve.zero, this.zOne = true) : (this.x = new i(e3, 16), this.y = new i(r3, 16), this.z = n2 ? new i(n2, 16) : this.curve.one, this.t = o2 && new i(o2, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.t && !this.t.red && (this.t = this.t.toRed(this.curve.red)), this.zOne = this.z === this.curve.one, this.curve.extended && !this.t && (this.t = this.x.redMul(this.y), this.zOne || (this.t = this.t.redMul(this.z.redInvm())))); - } - o(u, a), t2.exports = u, u.prototype._mulA = function(t3) { - return this.mOneA ? t3.redNeg() : this.a.redMul(t3); - }, u.prototype._mulC = function(t3) { - return this.oneC ? t3 : this.c.redMul(t3); - }, u.prototype.jpoint = function(t3, e3, r3, n2) { - return this.point(t3, e3, r3, n2); - }, u.prototype.pointFromX = function(t3, e3) { - (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); - var r3 = t3.redSqr(), n2 = this.c2.redSub(this.a.redMul(r3)), o2 = this.one.redSub(this.c2.redMul(this.d).redMul(r3)), a2 = n2.redMul(o2.redInvm()), s2 = a2.redSqrt(); - if (s2.redSqr().redSub(a2).cmp(this.zero) !== 0) - throw new Error("invalid point"); - var u2 = s2.fromRed().isOdd(); - return (e3 && !u2 || !e3 && u2) && (s2 = s2.redNeg()), this.point(t3, s2); - }, u.prototype.pointFromY = function(t3, e3) { - (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); - var r3 = t3.redSqr(), n2 = r3.redSub(this.c2), o2 = r3.redMul(this.d).redMul(this.c2).redSub(this.a), a2 = n2.redMul(o2.redInvm()); - if (a2.cmp(this.zero) === 0) { - if (e3) - throw new Error("invalid point"); - return this.point(this.zero, t3); - } - var s2 = a2.redSqrt(); - if (s2.redSqr().redSub(a2).cmp(this.zero) !== 0) - throw new Error("invalid point"); - return s2.fromRed().isOdd() !== e3 && (s2 = s2.redNeg()), this.point(s2, t3); - }, u.prototype.validate = function(t3) { - if (t3.isInfinity()) - return true; - t3.normalize(); - var e3 = t3.x.redSqr(), r3 = t3.y.redSqr(), n2 = e3.redMul(this.a).redAdd(r3), i2 = this.c2.redMul(this.one.redAdd(this.d.redMul(e3).redMul(r3))); - return n2.cmp(i2) === 0; - }, o(f, a.BasePoint), u.prototype.pointFromJSON = function(t3) { - return f.fromJSON(this, t3); - }, u.prototype.point = function(t3, e3, r3, n2) { - return new f(this, t3, e3, r3, n2); - }, f.fromJSON = function(t3, e3) { - return new f(t3, e3[0], e3[1], e3[2]); - }, f.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; - }, f.prototype.isInfinity = function() { - return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); - }, f.prototype._extDbl = function() { - var t3 = this.x.redSqr(), e3 = this.y.redSqr(), r3 = this.z.redSqr(); - r3 = r3.redIAdd(r3); - var n2 = this.curve._mulA(t3), i2 = this.x.redAdd(this.y).redSqr().redISub(t3).redISub(e3), o2 = n2.redAdd(e3), a2 = o2.redSub(r3), s2 = n2.redSub(e3), u2 = i2.redMul(a2), f2 = o2.redMul(s2), c = i2.redMul(s2), h = a2.redMul(o2); - return this.curve.point(u2, f2, h, c); - }, f.prototype._projDbl = function() { - var t3, e3, r3, n2, i2, o2, a2 = this.x.redAdd(this.y).redSqr(), s2 = this.x.redSqr(), u2 = this.y.redSqr(); - if (this.curve.twisted) { - var f2 = (n2 = this.curve._mulA(s2)).redAdd(u2); - this.zOne ? (t3 = a2.redSub(s2).redSub(u2).redMul(f2.redSub(this.curve.two)), e3 = f2.redMul(n2.redSub(u2)), r3 = f2.redSqr().redSub(f2).redSub(f2)) : (i2 = this.z.redSqr(), o2 = f2.redSub(i2).redISub(i2), t3 = a2.redSub(s2).redISub(u2).redMul(o2), e3 = f2.redMul(n2.redSub(u2)), r3 = f2.redMul(o2)); - } else - n2 = s2.redAdd(u2), i2 = this.curve._mulC(this.z).redSqr(), o2 = n2.redSub(i2).redSub(i2), t3 = this.curve._mulC(a2.redISub(n2)).redMul(o2), e3 = this.curve._mulC(n2).redMul(s2.redISub(u2)), r3 = n2.redMul(o2); - return this.curve.point(t3, e3, r3); - }, f.prototype.dbl = function() { - return this.isInfinity() ? this : this.curve.extended ? this._extDbl() : this._projDbl(); - }, f.prototype._extAdd = function(t3) { - var e3 = this.y.redSub(this.x).redMul(t3.y.redSub(t3.x)), r3 = this.y.redAdd(this.x).redMul(t3.y.redAdd(t3.x)), n2 = this.t.redMul(this.curve.dd).redMul(t3.t), i2 = this.z.redMul(t3.z.redAdd(t3.z)), o2 = r3.redSub(e3), a2 = i2.redSub(n2), s2 = i2.redAdd(n2), u2 = r3.redAdd(e3), f2 = o2.redMul(a2), c = s2.redMul(u2), h = o2.redMul(u2), l = a2.redMul(s2); - return this.curve.point(f2, c, l, h); - }, f.prototype._projAdd = function(t3) { - var e3, r3, n2 = this.z.redMul(t3.z), i2 = n2.redSqr(), o2 = this.x.redMul(t3.x), a2 = this.y.redMul(t3.y), s2 = this.curve.d.redMul(o2).redMul(a2), u2 = i2.redSub(s2), f2 = i2.redAdd(s2), c = this.x.redAdd(this.y).redMul(t3.x.redAdd(t3.y)).redISub(o2).redISub(a2), h = n2.redMul(u2).redMul(c); - return this.curve.twisted ? (e3 = n2.redMul(f2).redMul(a2.redSub(this.curve._mulA(o2))), r3 = u2.redMul(f2)) : (e3 = n2.redMul(f2).redMul(a2.redSub(o2)), r3 = this.curve._mulC(u2).redMul(f2)), this.curve.point(h, e3, r3); - }, f.prototype.add = function(t3) { - return this.isInfinity() ? t3 : t3.isInfinity() ? this : this.curve.extended ? this._extAdd(t3) : this._projAdd(t3); - }, f.prototype.mul = function(t3) { - return this._hasDoubles(t3) ? this.curve._fixedNafMul(this, t3) : this.curve._wnafMul(this, t3); - }, f.prototype.mulAdd = function(t3, e3, r3) { - return this.curve._wnafMulAdd(1, [this, e3], [t3, r3], 2, false); - }, f.prototype.jmulAdd = function(t3, e3, r3) { - return this.curve._wnafMulAdd(1, [this, e3], [t3, r3], 2, true); - }, f.prototype.normalize = function() { - if (this.zOne) - return this; - var t3 = this.z.redInvm(); - return this.x = this.x.redMul(t3), this.y = this.y.redMul(t3), this.t && (this.t = this.t.redMul(t3)), this.z = this.curve.one, this.zOne = true, this; - }, f.prototype.neg = function() { - return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); - }, f.prototype.getX = function() { - return this.normalize(), this.x.fromRed(); - }, f.prototype.getY = function() { - return this.normalize(), this.y.fromRed(); - }, f.prototype.eq = function(t3) { - return this === t3 || this.getX().cmp(t3.getX()) === 0 && this.getY().cmp(t3.getY()) === 0; - }, f.prototype.eqXToP = function(t3) { - var e3 = t3.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(e3) === 0) - return true; - for (var r3 = t3.clone(), n2 = this.curve.redN.redMul(this.z); ; ) { - if (r3.iadd(this.curve.n), r3.cmp(this.curve.p) >= 0) - return false; - if (e3.redIAdd(n2), this.x.cmp(e3) === 0) - return true; - } - }, f.prototype.toP = f.prototype.normalize, f.prototype.mixedAdd = f.prototype.add; - }, 8254: (t2, e2, r2) => { - var n = e2; - n.base = r2(4918), n.short = r2(6673), n.mont = r2(2881), n.edwards = r2(1138); - }, 2881: (t2, e2, r2) => { - var n = r2(3550), i = r2(5717), o = r2(4918), a = r2(953); - function s(t3) { - o.call(this, "mont", t3), this.a = new n(t3.a, 16).toRed(this.red), this.b = new n(t3.b, 16).toRed(this.red), this.i4 = new n(4).toRed(this.red).redInvm(), this.two = new n(2).toRed(this.red), this.a24 = this.i4.redMul(this.a.redAdd(this.two)); - } - function u(t3, e3, r3) { - o.BasePoint.call(this, t3, "projective"), e3 === null && r3 === null ? (this.x = this.curve.one, this.z = this.curve.zero) : (this.x = new n(e3, 16), this.z = new n(r3, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red))); - } - i(s, o), t2.exports = s, s.prototype.validate = function(t3) { - var e3 = t3.normalize().x, r3 = e3.redSqr(), n2 = r3.redMul(e3).redAdd(r3.redMul(this.a)).redAdd(e3); - return n2.redSqrt().redSqr().cmp(n2) === 0; - }, i(u, o.BasePoint), s.prototype.decodePoint = function(t3, e3) { - return this.point(a.toArray(t3, e3), 1); - }, s.prototype.point = function(t3, e3) { - return new u(this, t3, e3); - }, s.prototype.pointFromJSON = function(t3) { - return u.fromJSON(this, t3); - }, u.prototype.precompute = function() { - }, u.prototype._encode = function() { - return this.getX().toArray("be", this.curve.p.byteLength()); - }, u.fromJSON = function(t3, e3) { - return new u(t3, e3[0], e3[1] || t3.one); - }, u.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; - }, u.prototype.isInfinity = function() { - return this.z.cmpn(0) === 0; - }, u.prototype.dbl = function() { - var t3 = this.x.redAdd(this.z).redSqr(), e3 = this.x.redSub(this.z).redSqr(), r3 = t3.redSub(e3), n2 = t3.redMul(e3), i2 = r3.redMul(e3.redAdd(this.curve.a24.redMul(r3))); - return this.curve.point(n2, i2); - }, u.prototype.add = function() { - throw new Error("Not supported on Montgomery curve"); - }, u.prototype.diffAdd = function(t3, e3) { - var r3 = this.x.redAdd(this.z), n2 = this.x.redSub(this.z), i2 = t3.x.redAdd(t3.z), o2 = t3.x.redSub(t3.z).redMul(r3), a2 = i2.redMul(n2), s2 = e3.z.redMul(o2.redAdd(a2).redSqr()), u2 = e3.x.redMul(o2.redISub(a2).redSqr()); - return this.curve.point(s2, u2); - }, u.prototype.mul = function(t3) { - for (var e3 = t3.clone(), r3 = this, n2 = this.curve.point(null, null), i2 = []; e3.cmpn(0) !== 0; e3.iushrn(1)) - i2.push(e3.andln(1)); - for (var o2 = i2.length - 1; o2 >= 0; o2--) - i2[o2] === 0 ? (r3 = r3.diffAdd(n2, this), n2 = n2.dbl()) : (n2 = r3.diffAdd(n2, this), r3 = r3.dbl()); - return n2; - }, u.prototype.mulAdd = function() { - throw new Error("Not supported on Montgomery curve"); - }, u.prototype.jumlAdd = function() { - throw new Error("Not supported on Montgomery curve"); - }, u.prototype.eq = function(t3) { - return this.getX().cmp(t3.getX()) === 0; - }, u.prototype.normalize = function() { - return this.x = this.x.redMul(this.z.redInvm()), this.z = this.curve.one, this; - }, u.prototype.getX = function() { - return this.normalize(), this.x.fromRed(); - }; - }, 6673: (t2, e2, r2) => { - var n = r2(953), i = r2(3550), o = r2(5717), a = r2(4918), s = n.assert; - function u(t3) { - a.call(this, "short", t3), this.a = new i(t3.a, 16).toRed(this.red), this.b = new i(t3.b, 16).toRed(this.red), this.tinv = this.two.redInvm(), this.zeroA = this.a.fromRed().cmpn(0) === 0, this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0, this.endo = this._getEndomorphism(t3), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); - } - function f(t3, e3, r3, n2) { - a.BasePoint.call(this, t3, "affine"), e3 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new i(e3, 16), this.y = new i(r3, 16), n2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); - } - function c(t3, e3, r3, n2) { - a.BasePoint.call(this, t3, "jacobian"), e3 === null && r3 === null && n2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new i(0)) : (this.x = new i(e3, 16), this.y = new i(r3, 16), this.z = new i(n2, 16)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.zOne = this.z === this.curve.one; - } - o(u, a), t2.exports = u, u.prototype._getEndomorphism = function(t3) { - if (this.zeroA && this.g && this.n && this.p.modn(3) === 1) { - var e3, r3; - if (t3.beta) - e3 = new i(t3.beta, 16).toRed(this.red); - else { - var n2 = this._getEndoRoots(this.p); - e3 = (e3 = n2[0].cmp(n2[1]) < 0 ? n2[0] : n2[1]).toRed(this.red); - } - if (t3.lambda) - r3 = new i(t3.lambda, 16); - else { - var o2 = this._getEndoRoots(this.n); - this.g.mul(o2[0]).x.cmp(this.g.x.redMul(e3)) === 0 ? r3 = o2[0] : (r3 = o2[1], s(this.g.mul(r3).x.cmp(this.g.x.redMul(e3)) === 0)); - } - return {beta: e3, lambda: r3, basis: t3.basis ? t3.basis.map(function(t4) { - return {a: new i(t4.a, 16), b: new i(t4.b, 16)}; - }) : this._getEndoBasis(r3)}; - } - }, u.prototype._getEndoRoots = function(t3) { - var e3 = t3 === this.p ? this.red : i.mont(t3), r3 = new i(2).toRed(e3).redInvm(), n2 = r3.redNeg(), o2 = new i(3).toRed(e3).redNeg().redSqrt().redMul(r3); - return [n2.redAdd(o2).fromRed(), n2.redSub(o2).fromRed()]; - }, u.prototype._getEndoBasis = function(t3) { - for (var e3, r3, n2, o2, a2, s2, u2, f2, c2, h = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), l = t3, d = this.n.clone(), p = new i(1), y = new i(0), m = new i(0), b = new i(1), g = 0; l.cmpn(0) !== 0; ) { - var v = d.div(l); - f2 = d.sub(v.mul(l)), c2 = m.sub(v.mul(p)); - var w = b.sub(v.mul(y)); - if (!n2 && f2.cmp(h) < 0) - e3 = u2.neg(), r3 = p, n2 = f2.neg(), o2 = c2; - else if (n2 && ++g == 2) - break; - u2 = f2, d = l, l = f2, m = p, p = c2, b = y, y = w; - } - a2 = f2.neg(), s2 = c2; - var _ = n2.sqr().add(o2.sqr()); - return a2.sqr().add(s2.sqr()).cmp(_) >= 0 && (a2 = e3, s2 = r3), n2.negative && (n2 = n2.neg(), o2 = o2.neg()), a2.negative && (a2 = a2.neg(), s2 = s2.neg()), [{a: n2, b: o2}, {a: a2, b: s2}]; - }, u.prototype._endoSplit = function(t3) { - var e3 = this.endo.basis, r3 = e3[0], n2 = e3[1], i2 = n2.b.mul(t3).divRound(this.n), o2 = r3.b.neg().mul(t3).divRound(this.n), a2 = i2.mul(r3.a), s2 = o2.mul(n2.a), u2 = i2.mul(r3.b), f2 = o2.mul(n2.b); - return {k1: t3.sub(a2).sub(s2), k2: u2.add(f2).neg()}; - }, u.prototype.pointFromX = function(t3, e3) { - (t3 = new i(t3, 16)).red || (t3 = t3.toRed(this.red)); - var r3 = t3.redSqr().redMul(t3).redIAdd(t3.redMul(this.a)).redIAdd(this.b), n2 = r3.redSqrt(); - if (n2.redSqr().redSub(r3).cmp(this.zero) !== 0) - throw new Error("invalid point"); - var o2 = n2.fromRed().isOdd(); - return (e3 && !o2 || !e3 && o2) && (n2 = n2.redNeg()), this.point(t3, n2); - }, u.prototype.validate = function(t3) { - if (t3.inf) - return true; - var e3 = t3.x, r3 = t3.y, n2 = this.a.redMul(e3), i2 = e3.redSqr().redMul(e3).redIAdd(n2).redIAdd(this.b); - return r3.redSqr().redISub(i2).cmpn(0) === 0; - }, u.prototype._endoWnafMulAdd = function(t3, e3, r3) { - for (var n2 = this._endoWnafT1, i2 = this._endoWnafT2, o2 = 0; o2 < t3.length; o2++) { - var a2 = this._endoSplit(e3[o2]), s2 = t3[o2], u2 = s2._getBeta(); - a2.k1.negative && (a2.k1.ineg(), s2 = s2.neg(true)), a2.k2.negative && (a2.k2.ineg(), u2 = u2.neg(true)), n2[2 * o2] = s2, n2[2 * o2 + 1] = u2, i2[2 * o2] = a2.k1, i2[2 * o2 + 1] = a2.k2; - } - for (var f2 = this._wnafMulAdd(1, n2, i2, 2 * o2, r3), c2 = 0; c2 < 2 * o2; c2++) - n2[c2] = null, i2[c2] = null; - return f2; - }, o(f, a.BasePoint), u.prototype.point = function(t3, e3, r3) { - return new f(this, t3, e3, r3); - }, u.prototype.pointFromJSON = function(t3, e3) { - return f.fromJSON(this, t3, e3); - }, f.prototype._getBeta = function() { - if (this.curve.endo) { - var t3 = this.precomputed; - if (t3 && t3.beta) - return t3.beta; - var e3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (t3) { - var r3 = this.curve, n2 = function(t4) { - return r3.point(t4.x.redMul(r3.endo.beta), t4.y); - }; - t3.beta = e3, e3.precomputed = {beta: null, naf: t3.naf && {wnd: t3.naf.wnd, points: t3.naf.points.map(n2)}, doubles: t3.doubles && {step: t3.doubles.step, points: t3.doubles.points.map(n2)}}; - } - return e3; - } - }, f.prototype.toJSON = function() { - return this.precomputed ? [this.x, this.y, this.precomputed && {doubles: this.precomputed.doubles && {step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1)}, naf: this.precomputed.naf && {wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1)}}] : [this.x, this.y]; - }, f.fromJSON = function(t3, e3, r3) { - typeof e3 == "string" && (e3 = JSON.parse(e3)); - var n2 = t3.point(e3[0], e3[1], r3); - if (!e3[2]) - return n2; - function i2(e4) { - return t3.point(e4[0], e4[1], r3); - } - var o2 = e3[2]; - return n2.precomputed = {beta: null, doubles: o2.doubles && {step: o2.doubles.step, points: [n2].concat(o2.doubles.points.map(i2))}, naf: o2.naf && {wnd: o2.naf.wnd, points: [n2].concat(o2.naf.points.map(i2))}}, n2; - }, f.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; - }, f.prototype.isInfinity = function() { - return this.inf; - }, f.prototype.add = function(t3) { - if (this.inf) - return t3; - if (t3.inf) - return this; - if (this.eq(t3)) - return this.dbl(); - if (this.neg().eq(t3)) - return this.curve.point(null, null); - if (this.x.cmp(t3.x) === 0) - return this.curve.point(null, null); - var e3 = this.y.redSub(t3.y); - e3.cmpn(0) !== 0 && (e3 = e3.redMul(this.x.redSub(t3.x).redInvm())); - var r3 = e3.redSqr().redISub(this.x).redISub(t3.x), n2 = e3.redMul(this.x.redSub(r3)).redISub(this.y); - return this.curve.point(r3, n2); - }, f.prototype.dbl = function() { - if (this.inf) - return this; - var t3 = this.y.redAdd(this.y); - if (t3.cmpn(0) === 0) - return this.curve.point(null, null); - var e3 = this.curve.a, r3 = this.x.redSqr(), n2 = t3.redInvm(), i2 = r3.redAdd(r3).redIAdd(r3).redIAdd(e3).redMul(n2), o2 = i2.redSqr().redISub(this.x.redAdd(this.x)), a2 = i2.redMul(this.x.redSub(o2)).redISub(this.y); - return this.curve.point(o2, a2); - }, f.prototype.getX = function() { - return this.x.fromRed(); - }, f.prototype.getY = function() { - return this.y.fromRed(); - }, f.prototype.mul = function(t3) { - return t3 = new i(t3, 16), this.isInfinity() ? this : this._hasDoubles(t3) ? this.curve._fixedNafMul(this, t3) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t3]) : this.curve._wnafMul(this, t3); - }, f.prototype.mulAdd = function(t3, e3, r3) { - var n2 = [this, e3], i2 = [t3, r3]; - return this.curve.endo ? this.curve._endoWnafMulAdd(n2, i2) : this.curve._wnafMulAdd(1, n2, i2, 2); - }, f.prototype.jmulAdd = function(t3, e3, r3) { - var n2 = [this, e3], i2 = [t3, r3]; - return this.curve.endo ? this.curve._endoWnafMulAdd(n2, i2, true) : this.curve._wnafMulAdd(1, n2, i2, 2, true); - }, f.prototype.eq = function(t3) { - return this === t3 || this.inf === t3.inf && (this.inf || this.x.cmp(t3.x) === 0 && this.y.cmp(t3.y) === 0); - }, f.prototype.neg = function(t3) { - if (this.inf) - return this; - var e3 = this.curve.point(this.x, this.y.redNeg()); - if (t3 && this.precomputed) { - var r3 = this.precomputed, n2 = function(t4) { - return t4.neg(); - }; - e3.precomputed = {naf: r3.naf && {wnd: r3.naf.wnd, points: r3.naf.points.map(n2)}, doubles: r3.doubles && {step: r3.doubles.step, points: r3.doubles.points.map(n2)}}; - } - return e3; - }, f.prototype.toJ = function() { - return this.inf ? this.curve.jpoint(null, null, null) : this.curve.jpoint(this.x, this.y, this.curve.one); - }, o(c, a.BasePoint), u.prototype.jpoint = function(t3, e3, r3) { - return new c(this, t3, e3, r3); - }, c.prototype.toP = function() { - if (this.isInfinity()) - return this.curve.point(null, null); - var t3 = this.z.redInvm(), e3 = t3.redSqr(), r3 = this.x.redMul(e3), n2 = this.y.redMul(e3).redMul(t3); - return this.curve.point(r3, n2); - }, c.prototype.neg = function() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); - }, c.prototype.add = function(t3) { - if (this.isInfinity()) - return t3; - if (t3.isInfinity()) - return this; - var e3 = t3.z.redSqr(), r3 = this.z.redSqr(), n2 = this.x.redMul(e3), i2 = t3.x.redMul(r3), o2 = this.y.redMul(e3.redMul(t3.z)), a2 = t3.y.redMul(r3.redMul(this.z)), s2 = n2.redSub(i2), u2 = o2.redSub(a2); - if (s2.cmpn(0) === 0) - return u2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var f2 = s2.redSqr(), c2 = f2.redMul(s2), h = n2.redMul(f2), l = u2.redSqr().redIAdd(c2).redISub(h).redISub(h), d = u2.redMul(h.redISub(l)).redISub(o2.redMul(c2)), p = this.z.redMul(t3.z).redMul(s2); - return this.curve.jpoint(l, d, p); - }, c.prototype.mixedAdd = function(t3) { - if (this.isInfinity()) - return t3.toJ(); - if (t3.isInfinity()) - return this; - var e3 = this.z.redSqr(), r3 = this.x, n2 = t3.x.redMul(e3), i2 = this.y, o2 = t3.y.redMul(e3).redMul(this.z), a2 = r3.redSub(n2), s2 = i2.redSub(o2); - if (a2.cmpn(0) === 0) - return s2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var u2 = a2.redSqr(), f2 = u2.redMul(a2), c2 = r3.redMul(u2), h = s2.redSqr().redIAdd(f2).redISub(c2).redISub(c2), l = s2.redMul(c2.redISub(h)).redISub(i2.redMul(f2)), d = this.z.redMul(a2); - return this.curve.jpoint(h, l, d); - }, c.prototype.dblp = function(t3) { - if (t3 === 0) - return this; - if (this.isInfinity()) - return this; - if (!t3) - return this.dbl(); - var e3; - if (this.curve.zeroA || this.curve.threeA) { - var r3 = this; - for (e3 = 0; e3 < t3; e3++) - r3 = r3.dbl(); - return r3; - } - var n2 = this.curve.a, i2 = this.curve.tinv, o2 = this.x, a2 = this.y, s2 = this.z, u2 = s2.redSqr().redSqr(), f2 = a2.redAdd(a2); - for (e3 = 0; e3 < t3; e3++) { - var c2 = o2.redSqr(), h = f2.redSqr(), l = h.redSqr(), d = c2.redAdd(c2).redIAdd(c2).redIAdd(n2.redMul(u2)), p = o2.redMul(h), y = d.redSqr().redISub(p.redAdd(p)), m = p.redISub(y), b = d.redMul(m); - b = b.redIAdd(b).redISub(l); - var g = f2.redMul(s2); - e3 + 1 < t3 && (u2 = u2.redMul(l)), o2 = y, s2 = g, f2 = b; - } - return this.curve.jpoint(o2, f2.redMul(i2), s2); - }, c.prototype.dbl = function() { - return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); - }, c.prototype._zeroDbl = function() { - var t3, e3, r3; - if (this.zOne) { - var n2 = this.x.redSqr(), i2 = this.y.redSqr(), o2 = i2.redSqr(), a2 = this.x.redAdd(i2).redSqr().redISub(n2).redISub(o2); - a2 = a2.redIAdd(a2); - var s2 = n2.redAdd(n2).redIAdd(n2), u2 = s2.redSqr().redISub(a2).redISub(a2), f2 = o2.redIAdd(o2); - f2 = (f2 = f2.redIAdd(f2)).redIAdd(f2), t3 = u2, e3 = s2.redMul(a2.redISub(u2)).redISub(f2), r3 = this.y.redAdd(this.y); - } else { - var c2 = this.x.redSqr(), h = this.y.redSqr(), l = h.redSqr(), d = this.x.redAdd(h).redSqr().redISub(c2).redISub(l); - d = d.redIAdd(d); - var p = c2.redAdd(c2).redIAdd(c2), y = p.redSqr(), m = l.redIAdd(l); - m = (m = m.redIAdd(m)).redIAdd(m), t3 = y.redISub(d).redISub(d), e3 = p.redMul(d.redISub(t3)).redISub(m), r3 = (r3 = this.y.redMul(this.z)).redIAdd(r3); - } - return this.curve.jpoint(t3, e3, r3); - }, c.prototype._threeDbl = function() { - var t3, e3, r3; - if (this.zOne) { - var n2 = this.x.redSqr(), i2 = this.y.redSqr(), o2 = i2.redSqr(), a2 = this.x.redAdd(i2).redSqr().redISub(n2).redISub(o2); - a2 = a2.redIAdd(a2); - var s2 = n2.redAdd(n2).redIAdd(n2).redIAdd(this.curve.a), u2 = s2.redSqr().redISub(a2).redISub(a2); - t3 = u2; - var f2 = o2.redIAdd(o2); - f2 = (f2 = f2.redIAdd(f2)).redIAdd(f2), e3 = s2.redMul(a2.redISub(u2)).redISub(f2), r3 = this.y.redAdd(this.y); - } else { - var c2 = this.z.redSqr(), h = this.y.redSqr(), l = this.x.redMul(h), d = this.x.redSub(c2).redMul(this.x.redAdd(c2)); - d = d.redAdd(d).redIAdd(d); - var p = l.redIAdd(l), y = (p = p.redIAdd(p)).redAdd(p); - t3 = d.redSqr().redISub(y), r3 = this.y.redAdd(this.z).redSqr().redISub(h).redISub(c2); - var m = h.redSqr(); - m = (m = (m = m.redIAdd(m)).redIAdd(m)).redIAdd(m), e3 = d.redMul(p.redISub(t3)).redISub(m); - } - return this.curve.jpoint(t3, e3, r3); - }, c.prototype._dbl = function() { - var t3 = this.curve.a, e3 = this.x, r3 = this.y, n2 = this.z, i2 = n2.redSqr().redSqr(), o2 = e3.redSqr(), a2 = r3.redSqr(), s2 = o2.redAdd(o2).redIAdd(o2).redIAdd(t3.redMul(i2)), u2 = e3.redAdd(e3), f2 = (u2 = u2.redIAdd(u2)).redMul(a2), c2 = s2.redSqr().redISub(f2.redAdd(f2)), h = f2.redISub(c2), l = a2.redSqr(); - l = (l = (l = l.redIAdd(l)).redIAdd(l)).redIAdd(l); - var d = s2.redMul(h).redISub(l), p = r3.redAdd(r3).redMul(n2); - return this.curve.jpoint(c2, d, p); - }, c.prototype.trpl = function() { - if (!this.curve.zeroA) - return this.dbl().add(this); - var t3 = this.x.redSqr(), e3 = this.y.redSqr(), r3 = this.z.redSqr(), n2 = e3.redSqr(), i2 = t3.redAdd(t3).redIAdd(t3), o2 = i2.redSqr(), a2 = this.x.redAdd(e3).redSqr().redISub(t3).redISub(n2), s2 = (a2 = (a2 = (a2 = a2.redIAdd(a2)).redAdd(a2).redIAdd(a2)).redISub(o2)).redSqr(), u2 = n2.redIAdd(n2); - u2 = (u2 = (u2 = u2.redIAdd(u2)).redIAdd(u2)).redIAdd(u2); - var f2 = i2.redIAdd(a2).redSqr().redISub(o2).redISub(s2).redISub(u2), c2 = e3.redMul(f2); - c2 = (c2 = c2.redIAdd(c2)).redIAdd(c2); - var h = this.x.redMul(s2).redISub(c2); - h = (h = h.redIAdd(h)).redIAdd(h); - var l = this.y.redMul(f2.redMul(u2.redISub(f2)).redISub(a2.redMul(s2))); - l = (l = (l = l.redIAdd(l)).redIAdd(l)).redIAdd(l); - var d = this.z.redAdd(a2).redSqr().redISub(r3).redISub(s2); - return this.curve.jpoint(h, l, d); - }, c.prototype.mul = function(t3, e3) { - return t3 = new i(t3, e3), this.curve._wnafMul(this, t3); - }, c.prototype.eq = function(t3) { - if (t3.type === "affine") - return this.eq(t3.toJ()); - if (this === t3) - return true; - var e3 = this.z.redSqr(), r3 = t3.z.redSqr(); - if (this.x.redMul(r3).redISub(t3.x.redMul(e3)).cmpn(0) !== 0) - return false; - var n2 = e3.redMul(this.z), i2 = r3.redMul(t3.z); - return this.y.redMul(i2).redISub(t3.y.redMul(n2)).cmpn(0) === 0; - }, c.prototype.eqXToP = function(t3) { - var e3 = this.z.redSqr(), r3 = t3.toRed(this.curve.red).redMul(e3); - if (this.x.cmp(r3) === 0) - return true; - for (var n2 = t3.clone(), i2 = this.curve.redN.redMul(e3); ; ) { - if (n2.iadd(this.curve.n), n2.cmp(this.curve.p) >= 0) - return false; - if (r3.redIAdd(i2), this.x.cmp(r3) === 0) - return true; - } - }, c.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; - }, c.prototype.isInfinity = function() { - return this.z.cmpn(0) === 0; - }; - }, 5427: (t2, e2, r2) => { - var n, i = e2, o = r2(3715), a = r2(8254), s = r2(953).assert; - function u(t3) { - t3.type === "short" ? this.curve = new a.short(t3) : t3.type === "edwards" ? this.curve = new a.edwards(t3) : this.curve = new a.mont(t3), this.g = this.curve.g, this.n = this.curve.n, this.hash = t3.hash, s(this.g.validate(), "Invalid curve"), s(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); - } - function f(t3, e3) { - Object.defineProperty(i, t3, {configurable: true, enumerable: true, get: function() { - var r3 = new u(e3); - return Object.defineProperty(i, t3, {configurable: true, enumerable: true, value: r3}), r3; - }}); - } - i.PresetCurve = u, f("p192", {type: "short", prime: "p192", p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", hash: o.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}), f("p224", {type: "short", prime: "p224", p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", hash: o.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}), f("p256", {type: "short", prime: null, p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", hash: o.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}), f("p384", {type: "short", prime: null, p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", hash: o.sha384, gRed: false, g: ["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}), f("p521", {type: "short", prime: null, p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", hash: o.sha512, gRed: false, g: ["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}), f("curve25519", {type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: o.sha256, gRed: false, g: ["9"]}), f("ed25519", {type: "edwards", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "-1", c: "1", d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: o.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"]}); - try { - n = r2(1037); - } catch (t3) { - n = void 0; - } - f("secp256k1", {type: "short", prime: "k256", p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", a: "0", b: "7", n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", h: "1", hash: o.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3"}, {a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15"}], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", n]}); - }, 7954: (t2, e2, r2) => { - var n = r2(3550), i = r2(2156), o = r2(953), a = r2(5427), s = r2(7376), u = o.assert, f = r2(1251), c = r2(611); - function h(t3) { - if (!(this instanceof h)) - return new h(t3); - typeof t3 == "string" && (u(Object.prototype.hasOwnProperty.call(a, t3), "Unknown curve " + t3), t3 = a[t3]), t3 instanceof a.PresetCurve && (t3 = {curve: t3}), this.curve = t3.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = t3.curve.g, this.g.precompute(t3.curve.n.bitLength() + 1), this.hash = t3.hash || t3.curve.hash; - } - t2.exports = h, h.prototype.keyPair = function(t3) { - return new f(this, t3); - }, h.prototype.keyFromPrivate = function(t3, e3) { - return f.fromPrivate(this, t3, e3); - }, h.prototype.keyFromPublic = function(t3, e3) { - return f.fromPublic(this, t3, e3); - }, h.prototype.genKeyPair = function(t3) { - t3 || (t3 = {}); - for (var e3 = new i({hash: this.hash, pers: t3.pers, persEnc: t3.persEnc || "utf8", entropy: t3.entropy || s(this.hash.hmacStrength), entropyEnc: t3.entropy && t3.entropyEnc || "utf8", nonce: this.n.toArray()}), r3 = this.n.byteLength(), o2 = this.n.sub(new n(2)); ; ) { - var a2 = new n(e3.generate(r3)); - if (!(a2.cmp(o2) > 0)) - return a2.iaddn(1), this.keyFromPrivate(a2); - } - }, h.prototype._truncateToN = function(t3, e3) { - var r3 = 8 * t3.byteLength() - this.n.bitLength(); - return r3 > 0 && (t3 = t3.ushrn(r3)), !e3 && t3.cmp(this.n) >= 0 ? t3.sub(this.n) : t3; - }, h.prototype.sign = function(t3, e3, r3, o2) { - typeof r3 == "object" && (o2 = r3, r3 = null), o2 || (o2 = {}), e3 = this.keyFromPrivate(e3, r3), t3 = this._truncateToN(new n(t3, 16)); - for (var a2 = this.n.byteLength(), s2 = e3.getPrivate().toArray("be", a2), u2 = t3.toArray("be", a2), f2 = new i({hash: this.hash, entropy: s2, nonce: u2, pers: o2.pers, persEnc: o2.persEnc || "utf8"}), h2 = this.n.sub(new n(1)), l = 0; ; l++) { - var d = o2.k ? o2.k(l) : new n(f2.generate(this.n.byteLength())); - if (!((d = this._truncateToN(d, true)).cmpn(1) <= 0 || d.cmp(h2) >= 0)) { - var p = this.g.mul(d); - if (!p.isInfinity()) { - var y = p.getX(), m = y.umod(this.n); - if (m.cmpn(0) !== 0) { - var b = d.invm(this.n).mul(m.mul(e3.getPrivate()).iadd(t3)); - if ((b = b.umod(this.n)).cmpn(0) !== 0) { - var g = (p.getY().isOdd() ? 1 : 0) | (y.cmp(m) !== 0 ? 2 : 0); - return o2.canonical && b.cmp(this.nh) > 0 && (b = this.n.sub(b), g ^= 1), new c({r: m, s: b, recoveryParam: g}); - } - } - } - } - } - }, h.prototype.verify = function(t3, e3, r3, i2) { - t3 = this._truncateToN(new n(t3, 16)), r3 = this.keyFromPublic(r3, i2); - var o2 = (e3 = new c(e3, "hex")).r, a2 = e3.s; - if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0) - return false; - if (a2.cmpn(1) < 0 || a2.cmp(this.n) >= 0) - return false; - var s2, u2 = a2.invm(this.n), f2 = u2.mul(t3).umod(this.n), h2 = u2.mul(o2).umod(this.n); - return this.curve._maxwellTrick ? !(s2 = this.g.jmulAdd(f2, r3.getPublic(), h2)).isInfinity() && s2.eqXToP(o2) : !(s2 = this.g.mulAdd(f2, r3.getPublic(), h2)).isInfinity() && s2.getX().umod(this.n).cmp(o2) === 0; - }, h.prototype.recoverPubKey = function(t3, e3, r3, i2) { - u((3 & r3) === r3, "The recovery param is more than two bits"), e3 = new c(e3, i2); - var o2 = this.n, a2 = new n(t3), s2 = e3.r, f2 = e3.s, h2 = 1 & r3, l = r3 >> 1; - if (s2.cmp(this.curve.p.umod(this.curve.n)) >= 0 && l) - throw new Error("Unable to find sencond key candinate"); - s2 = l ? this.curve.pointFromX(s2.add(this.curve.n), h2) : this.curve.pointFromX(s2, h2); - var d = e3.r.invm(o2), p = o2.sub(a2).mul(d).umod(o2), y = f2.mul(d).umod(o2); - return this.g.mulAdd(p, s2, y); - }, h.prototype.getKeyRecoveryParam = function(t3, e3, r3, n2) { - if ((e3 = new c(e3, n2)).recoveryParam !== null) - return e3.recoveryParam; - for (var i2 = 0; i2 < 4; i2++) { - var o2; - try { - o2 = this.recoverPubKey(t3, e3, i2); - } catch (t4) { - continue; - } - if (o2.eq(r3)) - return i2; - } - throw new Error("Unable to find valid recovery factor"); - }; - }, 1251: (t2, e2, r2) => { - var n = r2(3550), i = r2(953).assert; - function o(t3, e3) { - this.ec = t3, this.priv = null, this.pub = null, e3.priv && this._importPrivate(e3.priv, e3.privEnc), e3.pub && this._importPublic(e3.pub, e3.pubEnc); - } - t2.exports = o, o.fromPublic = function(t3, e3, r3) { - return e3 instanceof o ? e3 : new o(t3, {pub: e3, pubEnc: r3}); - }, o.fromPrivate = function(t3, e3, r3) { - return e3 instanceof o ? e3 : new o(t3, {priv: e3, privEnc: r3}); - }, o.prototype.validate = function() { - var t3 = this.getPublic(); - return t3.isInfinity() ? {result: false, reason: "Invalid public key"} : t3.validate() ? t3.mul(this.ec.curve.n).isInfinity() ? {result: true, reason: null} : {result: false, reason: "Public key * N != O"} : {result: false, reason: "Public key is not a point"}; - }, o.prototype.getPublic = function(t3, e3) { - return typeof t3 == "string" && (e3 = t3, t3 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), e3 ? this.pub.encode(e3, t3) : this.pub; - }, o.prototype.getPrivate = function(t3) { - return t3 === "hex" ? this.priv.toString(16, 2) : this.priv; - }, o.prototype._importPrivate = function(t3, e3) { - this.priv = new n(t3, e3 || 16), this.priv = this.priv.umod(this.ec.curve.n); - }, o.prototype._importPublic = function(t3, e3) { - if (t3.x || t3.y) - return this.ec.curve.type === "mont" ? i(t3.x, "Need x coordinate") : this.ec.curve.type !== "short" && this.ec.curve.type !== "edwards" || i(t3.x && t3.y, "Need both x and y coordinate"), void (this.pub = this.ec.curve.point(t3.x, t3.y)); - this.pub = this.ec.curve.decodePoint(t3, e3); - }, o.prototype.derive = function(t3) { - return t3.validate() || i(t3.validate(), "public point not validated"), t3.mul(this.priv).getX(); - }, o.prototype.sign = function(t3, e3, r3) { - return this.ec.sign(t3, this, e3, r3); - }, o.prototype.verify = function(t3, e3) { - return this.ec.verify(t3, e3, this); - }, o.prototype.inspect = function() { - return ""; - }; - }, 611: (t2, e2, r2) => { - var n = r2(3550), i = r2(953), o = i.assert; - function a(t3, e3) { - if (t3 instanceof a) - return t3; - this._importDER(t3, e3) || (o(t3.r && t3.s, "Signature without r or s"), this.r = new n(t3.r, 16), this.s = new n(t3.s, 16), t3.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = t3.recoveryParam); - } - function s() { - this.place = 0; - } - function u(t3, e3) { - var r3 = t3[e3.place++]; - if (!(128 & r3)) - return r3; - var n2 = 15 & r3; - if (n2 === 0 || n2 > 4) - return false; - for (var i2 = 0, o2 = 0, a2 = e3.place; o2 < n2; o2++, a2++) - i2 <<= 8, i2 |= t3[a2], i2 >>>= 0; - return !(i2 <= 127) && (e3.place = a2, i2); - } - function f(t3) { - for (var e3 = 0, r3 = t3.length - 1; !t3[e3] && !(128 & t3[e3 + 1]) && e3 < r3; ) - e3++; - return e3 === 0 ? t3 : t3.slice(e3); - } - function c(t3, e3) { - if (e3 < 128) - t3.push(e3); - else { - var r3 = 1 + (Math.log(e3) / Math.LN2 >>> 3); - for (t3.push(128 | r3); --r3; ) - t3.push(e3 >>> (r3 << 3) & 255); - t3.push(e3); - } - } - t2.exports = a, a.prototype._importDER = function(t3, e3) { - t3 = i.toArray(t3, e3); - var r3 = new s(); - if (t3[r3.place++] !== 48) - return false; - var o2 = u(t3, r3); - if (o2 === false) - return false; - if (o2 + r3.place !== t3.length) - return false; - if (t3[r3.place++] !== 2) - return false; - var a2 = u(t3, r3); - if (a2 === false) - return false; - var f2 = t3.slice(r3.place, a2 + r3.place); - if (r3.place += a2, t3[r3.place++] !== 2) - return false; - var c2 = u(t3, r3); - if (c2 === false) - return false; - if (t3.length !== c2 + r3.place) - return false; - var h = t3.slice(r3.place, c2 + r3.place); - if (f2[0] === 0) { - if (!(128 & f2[1])) - return false; - f2 = f2.slice(1); - } - if (h[0] === 0) { - if (!(128 & h[1])) - return false; - h = h.slice(1); - } - return this.r = new n(f2), this.s = new n(h), this.recoveryParam = null, true; - }, a.prototype.toDER = function(t3) { - var e3 = this.r.toArray(), r3 = this.s.toArray(); - for (128 & e3[0] && (e3 = [0].concat(e3)), 128 & r3[0] && (r3 = [0].concat(r3)), e3 = f(e3), r3 = f(r3); !(r3[0] || 128 & r3[1]); ) - r3 = r3.slice(1); - var n2 = [2]; - c(n2, e3.length), (n2 = n2.concat(e3)).push(2), c(n2, r3.length); - var o2 = n2.concat(r3), a2 = [48]; - return c(a2, o2.length), a2 = a2.concat(o2), i.encode(a2, t3); - }; - }, 5980: (t2, e2, r2) => { - var n = r2(3715), i = r2(5427), o = r2(953), a = o.assert, s = o.parseBytes, u = r2(9087), f = r2(3622); - function c(t3) { - if (a(t3 === "ed25519", "only tested with ed25519 so far"), !(this instanceof c)) - return new c(t3); - t3 = i[t3].curve, this.curve = t3, this.g = t3.g, this.g.precompute(t3.n.bitLength() + 1), this.pointClass = t3.point().constructor, this.encodingLength = Math.ceil(t3.n.bitLength() / 8), this.hash = n.sha512; - } - t2.exports = c, c.prototype.sign = function(t3, e3) { - t3 = s(t3); - var r3 = this.keyFromSecret(e3), n2 = this.hashInt(r3.messagePrefix(), t3), i2 = this.g.mul(n2), o2 = this.encodePoint(i2), a2 = this.hashInt(o2, r3.pubBytes(), t3).mul(r3.priv()), u2 = n2.add(a2).umod(this.curve.n); - return this.makeSignature({R: i2, S: u2, Rencoded: o2}); - }, c.prototype.verify = function(t3, e3, r3) { - t3 = s(t3), e3 = this.makeSignature(e3); - var n2 = this.keyFromPublic(r3), i2 = this.hashInt(e3.Rencoded(), n2.pubBytes(), t3), o2 = this.g.mul(e3.S()); - return e3.R().add(n2.pub().mul(i2)).eq(o2); - }, c.prototype.hashInt = function() { - for (var t3 = this.hash(), e3 = 0; e3 < arguments.length; e3++) - t3.update(arguments[e3]); - return o.intFromLE(t3.digest()).umod(this.curve.n); - }, c.prototype.keyFromPublic = function(t3) { - return u.fromPublic(this, t3); - }, c.prototype.keyFromSecret = function(t3) { - return u.fromSecret(this, t3); - }, c.prototype.makeSignature = function(t3) { - return t3 instanceof f ? t3 : new f(this, t3); - }, c.prototype.encodePoint = function(t3) { - var e3 = t3.getY().toArray("le", this.encodingLength); - return e3[this.encodingLength - 1] |= t3.getX().isOdd() ? 128 : 0, e3; - }, c.prototype.decodePoint = function(t3) { - var e3 = (t3 = o.parseBytes(t3)).length - 1, r3 = t3.slice(0, e3).concat(-129 & t3[e3]), n2 = (128 & t3[e3]) != 0, i2 = o.intFromLE(r3); - return this.curve.pointFromY(i2, n2); - }, c.prototype.encodeInt = function(t3) { - return t3.toArray("le", this.encodingLength); - }, c.prototype.decodeInt = function(t3) { - return o.intFromLE(t3); - }, c.prototype.isPoint = function(t3) { - return t3 instanceof this.pointClass; - }; - }, 9087: (t2, e2, r2) => { - var n = r2(953), i = n.assert, o = n.parseBytes, a = n.cachedProperty; - function s(t3, e3) { - this.eddsa = t3, this._secret = o(e3.secret), t3.isPoint(e3.pub) ? this._pub = e3.pub : this._pubBytes = o(e3.pub); - } - s.fromPublic = function(t3, e3) { - return e3 instanceof s ? e3 : new s(t3, {pub: e3}); - }, s.fromSecret = function(t3, e3) { - return e3 instanceof s ? e3 : new s(t3, {secret: e3}); - }, s.prototype.secret = function() { - return this._secret; - }, a(s, "pubBytes", function() { - return this.eddsa.encodePoint(this.pub()); - }), a(s, "pub", function() { - return this._pubBytes ? this.eddsa.decodePoint(this._pubBytes) : this.eddsa.g.mul(this.priv()); - }), a(s, "privBytes", function() { - var t3 = this.eddsa, e3 = this.hash(), r3 = t3.encodingLength - 1, n2 = e3.slice(0, t3.encodingLength); - return n2[0] &= 248, n2[r3] &= 127, n2[r3] |= 64, n2; - }), a(s, "priv", function() { - return this.eddsa.decodeInt(this.privBytes()); - }), a(s, "hash", function() { - return this.eddsa.hash().update(this.secret()).digest(); - }), a(s, "messagePrefix", function() { - return this.hash().slice(this.eddsa.encodingLength); - }), s.prototype.sign = function(t3) { - return i(this._secret, "KeyPair can only verify"), this.eddsa.sign(t3, this); - }, s.prototype.verify = function(t3, e3) { - return this.eddsa.verify(t3, e3, this); - }, s.prototype.getSecret = function(t3) { - return i(this._secret, "KeyPair is public only"), n.encode(this.secret(), t3); - }, s.prototype.getPublic = function(t3) { - return n.encode(this.pubBytes(), t3); - }, t2.exports = s; - }, 3622: (t2, e2, r2) => { - var n = r2(3550), i = r2(953), o = i.assert, a = i.cachedProperty, s = i.parseBytes; - function u(t3, e3) { - this.eddsa = t3, typeof e3 != "object" && (e3 = s(e3)), Array.isArray(e3) && (e3 = {R: e3.slice(0, t3.encodingLength), S: e3.slice(t3.encodingLength)}), o(e3.R && e3.S, "Signature without R or S"), t3.isPoint(e3.R) && (this._R = e3.R), e3.S instanceof n && (this._S = e3.S), this._Rencoded = Array.isArray(e3.R) ? e3.R : e3.Rencoded, this._Sencoded = Array.isArray(e3.S) ? e3.S : e3.Sencoded; - } - a(u, "S", function() { - return this.eddsa.decodeInt(this.Sencoded()); - }), a(u, "R", function() { - return this.eddsa.decodePoint(this.Rencoded()); - }), a(u, "Rencoded", function() { - return this.eddsa.encodePoint(this.R()); - }), a(u, "Sencoded", function() { - return this.eddsa.encodeInt(this.S()); - }), u.prototype.toBytes = function() { - return this.Rencoded().concat(this.Sencoded()); - }, u.prototype.toHex = function() { - return i.encode(this.toBytes(), "hex").toUpperCase(); - }, t2.exports = u; - }, 1037: (t2) => { - t2.exports = {doubles: {step: 4, points: [["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a", "f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"], ["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508", "11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"], ["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739", "d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"], ["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640", "4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"], ["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c", "4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"], ["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda", "96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"], ["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa", "5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"], ["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0", "cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"], ["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d", "9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"], ["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d", "e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"], ["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1", "9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"], ["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0", "5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"], ["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047", "10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"], ["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862", "283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"], ["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7", "7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"], ["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd", "56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"], ["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83", "7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"], ["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a", "53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"], ["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8", "bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"], ["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d", "4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"], ["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725", "7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"], ["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754", "4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"], ["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c", "17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"], ["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6", "6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"], ["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39", "c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"], ["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891", "893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"], ["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b", "febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"], ["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03", "2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"], ["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d", "eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"], ["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070", "7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"], ["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4", "e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"], ["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da", "662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"], ["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11", "1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"], ["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e", "efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"], ["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41", "2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"], ["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef", "67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"], ["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8", "db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"], ["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d", "648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"], ["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96", "35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"], ["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd", "ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"], ["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5", "9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"], ["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266", "40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"], ["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71", "34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"], ["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac", "c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"], ["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751", "1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"], ["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e", "493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"], ["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241", "c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"], ["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3", "be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"], ["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f", "4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"], ["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19", "aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"], ["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be", "b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"], ["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9", "6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"], ["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2", "8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"], ["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13", "7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"], ["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c", "ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"], ["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba", "2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"], ["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151", "e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"], ["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073", "d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"], ["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458", "38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"], ["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b", "69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"], ["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366", "d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"], ["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa", "40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"], ["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0", "620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"], ["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787", "7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"], ["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e", "ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]}, naf: {wnd: 7, points: [["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9", "388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"], ["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4", "d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"], ["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc", "6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"], ["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe", "cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"], ["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb", "d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"], ["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8", "ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"], ["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"], ["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34", "4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"], ["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c", "85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"], ["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5", "321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"], ["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f", "2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"], ["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714", "73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"], ["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729", "a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"], ["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db", "2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"], ["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4", "e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"], ["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5", "b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"], ["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479", "2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"], ["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d", "80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"], ["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f", "1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"], ["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb", "d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"], ["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9", "eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"], ["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963", "758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"], ["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74", "958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"], ["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530", "e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"], ["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b", "5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"], ["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247", "cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"], ["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1", "cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"], ["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120", "4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"], ["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435", "91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"], ["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18", "673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"], ["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8", "59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"], ["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb", "3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"], ["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f", "55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"], ["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143", "efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"], ["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba", "e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"], ["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45", "f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"], ["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a", "744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"], ["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e", "c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"], ["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8", "e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"], ["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c", "30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"], ["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519", "e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"], ["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab", "100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"], ["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca", "ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"], ["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf", "8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"], ["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610", "68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"], ["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4", "f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"], ["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c", "d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"], ["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940", "edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"], ["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980", "a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"], ["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3", "66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"], ["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf", "9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"], ["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63", "4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"], ["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448", "fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"], ["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf", "5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"], ["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5", "8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"], ["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6", "8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"], ["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5", "5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"], ["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99", "f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"], ["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51", "f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"], ["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5", "42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"], ["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5", "204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"], ["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997", "4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"], ["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881", "73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"], ["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5", "39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"], ["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66", "d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"], ["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726", "ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"], ["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede", "6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"], ["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94", "60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"], ["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31", "3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"], ["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51", "b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"], ["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252", "ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"], ["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5", "cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"], ["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b", "6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"], ["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4", "322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"], ["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f", "6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"], ["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889", "2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"], ["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246", "b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"], ["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984", "998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"], ["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a", "b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"], ["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030", "bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"], ["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197", "6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"], ["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593", "c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"], ["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef", "21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"], ["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38", "60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"], ["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a", "49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"], ["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111", "5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"], ["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502", "7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"], ["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea", "be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"], ["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26", "8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"], ["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986", "39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"], ["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e", "62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"], ["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4", "25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"], ["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda", "ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"], ["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859", "cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"], ["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f", "f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"], ["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c", "6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"], ["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942", "fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"], ["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a", "1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"], ["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80", "5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"], ["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d", "438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"], ["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1", "cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"], ["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63", "c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"], ["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352", "6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"], ["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193", "ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"], ["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00", "9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"], ["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58", "ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"], ["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7", "d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"], ["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8", "c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"], ["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e", "67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"], ["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d", "cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"], ["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b", "299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"], ["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f", "f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"], ["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6", "462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"], ["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297", "62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"], ["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a", "7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"], ["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c", "ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"], ["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52", "4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"], ["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb", "bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"], ["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065", "bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"], ["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917", "603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"], ["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9", "cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"], ["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3", "553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"], ["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57", "712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"], ["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66", "ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"], ["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8", "9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"], ["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721", "9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"], ["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180", "4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}; - }, 953: (t2, e2, r2) => { - var n = e2, i = r2(3550), o = r2(9746), a = r2(4504); - n.assert = o, n.toArray = a.toArray, n.zero2 = a.zero2, n.toHex = a.toHex, n.encode = a.encode, n.getNAF = function(t3, e3, r3) { - var n2 = new Array(Math.max(t3.bitLength(), r3) + 1); - n2.fill(0); - for (var i2 = 1 << e3 + 1, o2 = t3.clone(), a2 = 0; a2 < n2.length; a2++) { - var s, u = o2.andln(i2 - 1); - o2.isOdd() ? (s = u > (i2 >> 1) - 1 ? (i2 >> 1) - u : u, o2.isubn(s)) : s = 0, n2[a2] = s, o2.iushrn(1); - } - return n2; - }, n.getJSF = function(t3, e3) { - var r3 = [[], []]; - t3 = t3.clone(), e3 = e3.clone(); - for (var n2, i2 = 0, o2 = 0; t3.cmpn(-i2) > 0 || e3.cmpn(-o2) > 0; ) { - var a2, s, u = t3.andln(3) + i2 & 3, f = e3.andln(3) + o2 & 3; - u === 3 && (u = -1), f === 3 && (f = -1), a2 = (1 & u) == 0 ? 0 : (n2 = t3.andln(7) + i2 & 7) != 3 && n2 !== 5 || f !== 2 ? u : -u, r3[0].push(a2), s = (1 & f) == 0 ? 0 : (n2 = e3.andln(7) + o2 & 7) != 3 && n2 !== 5 || u !== 2 ? f : -f, r3[1].push(s), 2 * i2 === a2 + 1 && (i2 = 1 - i2), 2 * o2 === s + 1 && (o2 = 1 - o2), t3.iushrn(1), e3.iushrn(1); - } - return r3; - }, n.cachedProperty = function(t3, e3, r3) { - var n2 = "_" + e3; - t3.prototype[e3] = function() { - return this[n2] !== void 0 ? this[n2] : this[n2] = r3.call(this); - }; - }, n.parseBytes = function(t3) { - return typeof t3 == "string" ? n.toArray(t3, "hex") : t3; - }, n.intFromLE = function(t3) { - return new i(t3, "hex", "le"); - }; - }, 7519: (t2) => { - t2.exports = {i8: "6.5.4"}; - }, 4079: (t2, e2, r2) => { - var n = r2(210)("%Object.getOwnPropertyDescriptor%"); - if (n) - try { - n([], "length"); - } catch (t3) { - n = null; - } - t2.exports = n; - }, 8091: (t2) => { - function e2(t3, e3) { - if (t3 == null) - throw new TypeError("Cannot convert first argument to object"); - for (var r2 = Object(t3), n = 1; n < arguments.length; n++) { - var i = arguments[n]; - if (i != null) - for (var o = Object.keys(Object(i)), a = 0, s = o.length; a < s; a++) { - var u = o[a], f = Object.getOwnPropertyDescriptor(i, u); - f !== void 0 && f.enumerable && (r2[u] = i[u]); - } - } - return r2; - } - t2.exports = {assign: e2, polyfill: function() { - Object.assign || Object.defineProperty(Object, "assign", {enumerable: false, configurable: true, writable: true, value: e2}); - }}; - }, 5443: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}), e2.createHashFunction = function(t3) { - return function(e3) { - var r3 = t3(); - return r3.update(e3), n.from(r3.digest()); - }; - }; - }, 949: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}); - var n = r2(6167); - e2.HDKey = n; - }, 682: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}); - var n = r2(2949).ripemd160, i = r2(5443); - e2.ripemd160 = i.createHashFunction(function() { - return new n(); - }); - }, 4237: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}); - var n = r2(9344), i = r2(5443); - e2.sha256 = i.createHashFunction(function() { - return new n(); - }); - }, 2326: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}); - var i = r2(682), o = r2(4237); - e2.createHmac = r2(8355), e2.randomBytes = r2(1798); - var a = function() { - function t3(t4) { - this.hashFunction = t4, this.buffers = []; - } - return t3.prototype.update = function(t4) { - if (!n.isBuffer(t4)) - throw new Error("hdkey-crypto shim is outdated"); - return this.buffers.push(t4), this; - }, t3.prototype.digest = function(t4) { - if (t4) - throw new Error("hdkey-crypto shim is outdated"); - return this.hashFunction(n.concat(this.buffers)); - }, t3; - }(); - e2.createHash = function(t3) { - if (t3 === "ripemd160") - return new a(i.ripemd160); - if (t3 === "sha256") - return new a(o.sha256); - throw new Error("hdkey-crypto shim is outdated"); - }; - }, 4863: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}), function(t3) { - for (var r3 in t3) - e2.hasOwnProperty(r3) || (e2[r3] = t3[r3]); - }(r2(6454)); - }, 6167: (t2, e2, r2) => { - function n(t3) { - return t3 && typeof t3 == "object" && "default" in t3 ? t3.default : t3; - } - var i = n(r2(9282)), o = n(r2(9509)), a = n(r2(8334)), s = r2(2326), u = r2(4863), f = o.Buffer, c = f.from("Bitcoin seed", "utf8"), h = 2147483648, l = {private: 76066276, public: 76067358}; - function d(t3) { - this.versions = t3 || l, this.depth = 0, this.index = 0, this._privateKey = null, this._publicKey = null, this.chainCode = null, this._fingerprint = 0, this.parentFingerprint = 0; - } - function p(t3, e3, r3) { - var n2 = f.allocUnsafe(78); - n2.writeUInt32BE(e3, 0), n2.writeUInt8(t3.depth, 4); - var i2 = t3.depth ? t3.parentFingerprint : 0; - return n2.writeUInt32BE(i2, 5), n2.writeUInt32BE(t3.index, 9), t3.chainCode.copy(n2, 13), r3.copy(n2, 45), n2; - } - function y(t3) { - var e3 = s.createHash("sha256").update(t3).digest(); - return s.createHash("ripemd160").update(e3).digest(); - } - Object.defineProperty(d.prototype, "fingerprint", {get: function() { - return this._fingerprint; - }}), Object.defineProperty(d.prototype, "identifier", {get: function() { - return this._identifier; - }}), Object.defineProperty(d.prototype, "pubKeyHash", {get: function() { - return this.identifier; - }}), Object.defineProperty(d.prototype, "privateKey", {get: function() { - return this._privateKey; - }, set: function(t3) { - i.equal(t3.length, 32, "Private key must be 32 bytes."), i(u.privateKeyVerify(t3) === true, "Invalid private key"), this._privateKey = t3, this._publicKey = u.publicKeyCreate(t3, true), this._identifier = y(this.publicKey), this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); - }}), Object.defineProperty(d.prototype, "publicKey", {get: function() { - return this._publicKey; - }, set: function(t3) { - i(t3.length === 33 || t3.length === 65, "Public key must be 33 or 65 bytes."), i(u.publicKeyVerify(t3) === true, "Invalid public key"), this._publicKey = u.publicKeyConvert(t3, true), this._identifier = y(this.publicKey), this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0), this._privateKey = null; - }}), Object.defineProperty(d.prototype, "privateExtendedKey", {get: function() { - return this._privateKey ? a.encode(p(this, this.versions.private, f.concat([f.alloc(1, 0), this.privateKey]))) : null; - }}), Object.defineProperty(d.prototype, "publicExtendedKey", {get: function() { - return a.encode(p(this, this.versions.public, this.publicKey)); - }}), d.prototype.derive = function(t3) { - if (t3 === "m" || t3 === "M" || t3 === "m'" || t3 === "M'") - return this; - var e3 = t3.split("/"), r3 = this; - return e3.forEach(function(t4, e4) { - if (e4 !== 0) { - var n2 = t4.length > 1 && t4[t4.length - 1] === "'", o2 = parseInt(t4, 10); - i(o2 < h, "Invalid index"), n2 && (o2 += h), r3 = r3.deriveChild(o2); - } else - i(/^[mM]{1}/.test(t4), 'Path must start with "m" or "M"'); - }), r3; - }, d.prototype.deriveChild = function(t3) { - var e3, r3 = t3 >= h, n2 = f.allocUnsafe(4); - if (n2.writeUInt32BE(t3, 0), r3) { - i(this.privateKey, "Could not derive hardened child key"); - var o2 = this.privateKey, a2 = f.alloc(1, 0); - o2 = f.concat([a2, o2]), e3 = f.concat([o2, n2]); - } else - e3 = f.concat([this.publicKey, n2]); - var c2 = s.createHmac("sha512", this.chainCode).update(e3).digest(), l2 = c2.slice(0, 32), p2 = c2.slice(32), y2 = new d(this.versions); - if (this.privateKey) - try { - y2.privateKey = u.privateKeyTweakAdd(this.privateKey, l2); - } catch (e4) { - return this.deriveChild(t3 + 1); - } - else - try { - y2.publicKey = u.publicKeyTweakAdd(this.publicKey, l2, true); - } catch (e4) { - return this.deriveChild(t3 + 1); - } - return y2.chainCode = p2, y2.depth = this.depth + 1, y2.parentFingerprint = this.fingerprint, y2.index = t3, y2; - }, d.prototype.sign = function(t3) { - return u.sign(t3, this.privateKey).signature; - }, d.prototype.verify = function(t3, e3) { - return u.verify(t3, e3, this.publicKey); - }, d.prototype.wipePrivateData = function() { - return this._privateKey && s.randomBytes(this._privateKey.length).copy(this._privateKey), this._privateKey = null, this; - }, d.prototype.toJSON = function() { - return {xpriv: this.privateExtendedKey, xpub: this.publicExtendedKey}; - }, d.fromMasterSeed = function(t3, e3) { - var r3 = s.createHmac("sha512", c).update(t3).digest(), n2 = r3.slice(0, 32), i2 = r3.slice(32), o2 = new d(e3); - return o2.chainCode = i2, o2.privateKey = n2, o2; - }, d.fromExtendedKey = function(t3, e3) { - var r3 = new d(e3 = e3 || l), n2 = a.decode(t3), o2 = n2.readUInt32BE(0); - i(o2 === e3.private || o2 === e3.public, "Version mismatch: does not match private or public"), r3.depth = n2.readUInt8(4), r3.parentFingerprint = n2.readUInt32BE(5), r3.index = n2.readUInt32BE(9), r3.chainCode = n2.slice(13, 45); - var s2 = n2.slice(45); - return s2.readUInt8(0) === 0 ? (i(o2 === e3.private, "Version mismatch: version does not match private"), r3.privateKey = s2.slice(1)) : (i(o2 === e3.public, "Version mismatch: version does not match public"), r3.publicKey = s2), r3; - }, d.fromJSON = function(t3) { - return d.fromExtendedKey(t3.xpriv); - }, d.HARDENED_OFFSET = h; - var m = d; - t2.exports = m; - }, 472: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}); - var n = r2(1798); - e2.getRandomBytes = function(t3) { - return new Promise(function(e3, r3) { - n(t3, function(t4, n2) { - t4 ? r3(t4) : e3(n2); - }); - }); - }, e2.getRandomBytesSync = function(t3) { - return n(t3); - }; - }, 5053: function(t2, e2, r2) { - var n = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, i = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s(o3) { - return function(s2) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s2]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var o = r2(7221), a = r2(472); - e2.createPrivateKey = function() { - return n(this, void 0, void 0, function() { - var t3; - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, a.getRandomBytes(32)]; - case 1: - return t3 = e3.sent(), o.privateKeyVerify(t3) ? [2, t3] : [3, 0]; - case 2: - return [2]; - } - }); - }); - }, e2.createPrivateKeySync = function() { - for (; ; ) { - var t3 = a.getRandomBytesSync(32); - if (o.privateKeyVerify(t3)) - return t3; - } - }, function(t3) { - for (var r3 in t3) - e2.hasOwnProperty(r3) || (e2[r3] = t3[r3]); - }(r2(7221)); - }, 6454: function(t2, e2, r2) { - var n = r2(8764).Buffer, i = this && this.__importStar || function(t3) { - if (t3 && t3.__esModule) - return t3; - var e3 = {}; - if (t3 != null) - for (var r3 in t3) - Object.hasOwnProperty.call(t3, r3) && (e3[r3] = t3[r3]); - return e3.default = t3, e3; - }; - Object.defineProperty(e2, "__esModule", {value: true}); - var o = i(r2(7221)); - e2.privateKeyVerify = function(t3) { - return o.privateKeyVerify(t3); - }, e2.publicKeyCreate = function(t3, e3) { - return e3 === void 0 && (e3 = true), n.from(o.publicKeyCreate(t3, e3)); - }, e2.publicKeyVerify = function(t3) { - return o.publicKeyVerify(t3); - }, e2.publicKeyConvert = function(t3, e3) { - return e3 === void 0 && (e3 = true), n.from(o.publicKeyConvert(t3, e3)); - }, e2.privateKeyTweakAdd = function(t3, e3) { - return n.from(o.privateKeyTweakAdd(n.from(t3), e3)); - }, e2.publicKeyTweakAdd = function(t3, e3, r3) { - return r3 === void 0 && (r3 = true), n.from(o.publicKeyTweakAdd(n.from(t3), e3, r3)); - }, e2.sign = function(t3, e3) { - var r3 = o.ecdsaSign(t3, e3); - return {signature: n.from(r3.signature), recovery: r3.recid}; - }, e2.verify = function(t3, e3, r3) { - return o.ecdsaVerify(e3, t3, r3); - }; - }, 7187: (t2) => { - var e2, r2 = typeof Reflect == "object" ? Reflect : null, n = r2 && typeof r2.apply == "function" ? r2.apply : function(t3, e3, r3) { - return Function.prototype.apply.call(t3, e3, r3); - }; - e2 = r2 && typeof r2.ownKeys == "function" ? r2.ownKeys : Object.getOwnPropertySymbols ? function(t3) { - return Object.getOwnPropertyNames(t3).concat(Object.getOwnPropertySymbols(t3)); - } : function(t3) { - return Object.getOwnPropertyNames(t3); - }; - var i = Number.isNaN || function(t3) { - return t3 != t3; - }; - function o() { - o.init.call(this); - } - t2.exports = o, t2.exports.once = function(t3, e3) { - return new Promise(function(r3, n2) { - function i2(r4) { - t3.removeListener(e3, o2), n2(r4); - } - function o2() { - typeof t3.removeListener == "function" && t3.removeListener("error", i2), r3([].slice.call(arguments)); - } - y(t3, e3, o2, {once: true}), e3 !== "error" && function(t4, e4, r4) { - typeof t4.on == "function" && y(t4, "error", e4, {once: true}); - }(t3, i2); - }); - }, o.EventEmitter = o, o.prototype._events = void 0, o.prototype._eventsCount = 0, o.prototype._maxListeners = void 0; - var a = 10; - function s(t3) { - if (typeof t3 != "function") - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t3); - } - function u(t3) { - return t3._maxListeners === void 0 ? o.defaultMaxListeners : t3._maxListeners; - } - function f(t3, e3, r3, n2) { - var i2, o2, a2, f2; - if (s(r3), (o2 = t3._events) === void 0 ? (o2 = t3._events = Object.create(null), t3._eventsCount = 0) : (o2.newListener !== void 0 && (t3.emit("newListener", e3, r3.listener ? r3.listener : r3), o2 = t3._events), a2 = o2[e3]), a2 === void 0) - a2 = o2[e3] = r3, ++t3._eventsCount; - else if (typeof a2 == "function" ? a2 = o2[e3] = n2 ? [r3, a2] : [a2, r3] : n2 ? a2.unshift(r3) : a2.push(r3), (i2 = u(t3)) > 0 && a2.length > i2 && !a2.warned) { - a2.warned = true; - var c2 = new Error("Possible EventEmitter memory leak detected. " + a2.length + " " + String(e3) + " listeners added. Use emitter.setMaxListeners() to increase limit"); - c2.name = "MaxListenersExceededWarning", c2.emitter = t3, c2.type = e3, c2.count = a2.length, f2 = c2, console && console.warn && console.warn(f2); - } - return t3; - } - function c() { - if (!this.fired) - return this.target.removeListener(this.type, this.wrapFn), this.fired = true, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); - } - function h(t3, e3, r3) { - var n2 = {fired: false, wrapFn: void 0, target: t3, type: e3, listener: r3}, i2 = c.bind(n2); - return i2.listener = r3, n2.wrapFn = i2, i2; - } - function l(t3, e3, r3) { - var n2 = t3._events; - if (n2 === void 0) - return []; - var i2 = n2[e3]; - return i2 === void 0 ? [] : typeof i2 == "function" ? r3 ? [i2.listener || i2] : [i2] : r3 ? function(t4) { - for (var e4 = new Array(t4.length), r4 = 0; r4 < e4.length; ++r4) - e4[r4] = t4[r4].listener || t4[r4]; - return e4; - }(i2) : p(i2, i2.length); - } - function d(t3) { - var e3 = this._events; - if (e3 !== void 0) { - var r3 = e3[t3]; - if (typeof r3 == "function") - return 1; - if (r3 !== void 0) - return r3.length; - } - return 0; - } - function p(t3, e3) { - for (var r3 = new Array(e3), n2 = 0; n2 < e3; ++n2) - r3[n2] = t3[n2]; - return r3; - } - function y(t3, e3, r3, n2) { - if (typeof t3.on == "function") - n2.once ? t3.once(e3, r3) : t3.on(e3, r3); - else { - if (typeof t3.addEventListener != "function") - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t3); - t3.addEventListener(e3, function i2(o2) { - n2.once && t3.removeEventListener(e3, i2), r3(o2); - }); - } - } - Object.defineProperty(o, "defaultMaxListeners", {enumerable: true, get: function() { - return a; - }, set: function(t3) { - if (typeof t3 != "number" || t3 < 0 || i(t3)) - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t3 + "."); - a = t3; - }}), o.init = function() { - this._events !== void 0 && this._events !== Object.getPrototypeOf(this)._events || (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; - }, o.prototype.setMaxListeners = function(t3) { - if (typeof t3 != "number" || t3 < 0 || i(t3)) - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + t3 + "."); - return this._maxListeners = t3, this; - }, o.prototype.getMaxListeners = function() { - return u(this); - }, o.prototype.emit = function(t3) { - for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) - e3.push(arguments[r3]); - var i2 = t3 === "error", o2 = this._events; - if (o2 !== void 0) - i2 = i2 && o2.error === void 0; - else if (!i2) - return false; - if (i2) { - var a2; - if (e3.length > 0 && (a2 = e3[0]), a2 instanceof Error) - throw a2; - var s2 = new Error("Unhandled error." + (a2 ? " (" + a2.message + ")" : "")); - throw s2.context = a2, s2; - } - var u2 = o2[t3]; - if (u2 === void 0) - return false; - if (typeof u2 == "function") - n(u2, this, e3); - else { - var f2 = u2.length, c2 = p(u2, f2); - for (r3 = 0; r3 < f2; ++r3) - n(c2[r3], this, e3); - } - return true; - }, o.prototype.addListener = function(t3, e3) { - return f(this, t3, e3, false); - }, o.prototype.on = o.prototype.addListener, o.prototype.prependListener = function(t3, e3) { - return f(this, t3, e3, true); - }, o.prototype.once = function(t3, e3) { - return s(e3), this.on(t3, h(this, t3, e3)), this; - }, o.prototype.prependOnceListener = function(t3, e3) { - return s(e3), this.prependListener(t3, h(this, t3, e3)), this; - }, o.prototype.removeListener = function(t3, e3) { - var r3, n2, i2, o2, a2; - if (s(e3), (n2 = this._events) === void 0) - return this; - if ((r3 = n2[t3]) === void 0) - return this; - if (r3 === e3 || r3.listener === e3) - --this._eventsCount == 0 ? this._events = Object.create(null) : (delete n2[t3], n2.removeListener && this.emit("removeListener", t3, r3.listener || e3)); - else if (typeof r3 != "function") { - for (i2 = -1, o2 = r3.length - 1; o2 >= 0; o2--) - if (r3[o2] === e3 || r3[o2].listener === e3) { - a2 = r3[o2].listener, i2 = o2; - break; - } - if (i2 < 0) - return this; - i2 === 0 ? r3.shift() : function(t4, e4) { - for (; e4 + 1 < t4.length; e4++) - t4[e4] = t4[e4 + 1]; - t4.pop(); - }(r3, i2), r3.length === 1 && (n2[t3] = r3[0]), n2.removeListener !== void 0 && this.emit("removeListener", t3, a2 || e3); - } - return this; - }, o.prototype.off = o.prototype.removeListener, o.prototype.removeAllListeners = function(t3) { - var e3, r3, n2; - if ((r3 = this._events) === void 0) - return this; - if (r3.removeListener === void 0) - return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : r3[t3] !== void 0 && (--this._eventsCount == 0 ? this._events = Object.create(null) : delete r3[t3]), this; - if (arguments.length === 0) { - var i2, o2 = Object.keys(r3); - for (n2 = 0; n2 < o2.length; ++n2) - (i2 = o2[n2]) !== "removeListener" && this.removeAllListeners(i2); - return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this; - } - if (typeof (e3 = r3[t3]) == "function") - this.removeListener(t3, e3); - else if (e3 !== void 0) - for (n2 = e3.length - 1; n2 >= 0; n2--) - this.removeListener(t3, e3[n2]); - return this; - }, o.prototype.listeners = function(t3) { - return l(this, t3, true); - }, o.prototype.rawListeners = function(t3) { - return l(this, t3, false); - }, o.listenerCount = function(t3, e3) { - return typeof t3.listenerCount == "function" ? t3.listenerCount(e3) : d.call(t3, e3); - }, o.prototype.listenerCount = d, o.prototype.eventNames = function() { - return this._eventsCount > 0 ? e2(this._events) : []; - }; - }, 3048: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(2318); - t2.exports = function(t3, e3, r3, o) { - if (n.isBuffer(t3) || (t3 = n.from(t3, "binary")), e3 && (n.isBuffer(e3) || (e3 = n.from(e3, "binary")), e3.length !== 8)) - throw new RangeError("salt should be Buffer with 8 byte length"); - for (var a = r3 / 8, s = n.alloc(a), u = n.alloc(o || 0), f = n.alloc(0); a > 0 || o > 0; ) { - var c = new i(); - c.update(f), c.update(t3), e3 && c.update(e3), f = c.digest(); - var h = 0; - if (a > 0) { - var l = s.length - a; - h = Math.min(a, f.length), f.copy(s, l, 0, h), a -= h; - } - if (h < f.length && o > 0) { - var d = u.length - o, p = Math.min(o, f.length - h); - f.copy(u, d, h, h + p), o -= p; - } - } - return f.fill(0), {key: s, iv: u}; - }; - }, 9804: (t2) => { - var e2 = Object.prototype.hasOwnProperty, r2 = Object.prototype.toString; - t2.exports = function(t3, n, i) { - if (r2.call(n) !== "[object Function]") - throw new TypeError("iterator must be a function"); - var o = t3.length; - if (o === +o) - for (var a = 0; a < o; a++) - n.call(i, t3[a], a, t3); - else - for (var s in t3) - e2.call(t3, s) && n.call(i, t3[s], s, t3); - }; - }, 7648: (t2) => { - var e2 = "Function.prototype.bind called on incompatible ", r2 = Array.prototype.slice, n = Object.prototype.toString, i = "[object Function]"; - t2.exports = function(t3) { - var o = this; - if (typeof o != "function" || n.call(o) !== i) - throw new TypeError(e2 + o); - for (var a, s = r2.call(arguments, 1), u = function() { - if (this instanceof a) { - var e3 = o.apply(this, s.concat(r2.call(arguments))); - return Object(e3) === e3 ? e3 : this; - } - return o.apply(t3, s.concat(r2.call(arguments))); - }, f = Math.max(0, o.length - s.length), c = [], h = 0; h < f; h++) - c.push("$" + h); - if (a = Function("binder", "return function (" + c.join(",") + "){ return binder.apply(this,arguments); }")(u), o.prototype) { - var l = function() { - }; - l.prototype = o.prototype, a.prototype = new l(), l.prototype = null; - } - return a; - }; - }, 8612: (t2, e2, r2) => { - var n = r2(7648); - t2.exports = Function.prototype.bind || n; - }, 210: (t2, e2, r2) => { - var n, i = SyntaxError, o = Function, a = TypeError, s = function(t3) { - try { - return o('"use strict"; return (' + t3 + ").constructor;")(); - } catch (t4) { - } - }, u = Object.getOwnPropertyDescriptor; - if (u) - try { - u({}, ""); - } catch (t3) { - u = null; - } - var f = function() { - throw new a(); - }, c = u ? function() { - try { - return f; - } catch (t3) { - try { - return u(arguments, "callee").get; - } catch (t4) { - return f; - } - } - }() : f, h = r2(1405)(), l = Object.getPrototypeOf || function(t3) { - return t3.__proto__; - }, d = {}, p = typeof Uint8Array == "undefined" ? n : l(Uint8Array), y = {"%AggregateError%": typeof AggregateError == "undefined" ? n : AggregateError, "%Array%": Array, "%ArrayBuffer%": typeof ArrayBuffer == "undefined" ? n : ArrayBuffer, "%ArrayIteratorPrototype%": h ? l([][Symbol.iterator]()) : n, "%AsyncFromSyncIteratorPrototype%": n, "%AsyncFunction%": d, "%AsyncGenerator%": d, "%AsyncGeneratorFunction%": d, "%AsyncIteratorPrototype%": d, "%Atomics%": typeof Atomics == "undefined" ? n : Atomics, "%BigInt%": typeof BigInt == "undefined" ? n : BigInt, "%Boolean%": Boolean, "%DataView%": typeof DataView == "undefined" ? n : DataView, "%Date%": Date, "%decodeURI%": decodeURI, "%decodeURIComponent%": decodeURIComponent, "%encodeURI%": encodeURI, "%encodeURIComponent%": encodeURIComponent, "%Error%": Error, "%eval%": eval, "%EvalError%": EvalError, "%Float32Array%": typeof Float32Array == "undefined" ? n : Float32Array, "%Float64Array%": typeof Float64Array == "undefined" ? n : Float64Array, "%FinalizationRegistry%": typeof FinalizationRegistry == "undefined" ? n : FinalizationRegistry, "%Function%": o, "%GeneratorFunction%": d, "%Int8Array%": typeof Int8Array == "undefined" ? n : Int8Array, "%Int16Array%": typeof Int16Array == "undefined" ? n : Int16Array, "%Int32Array%": typeof Int32Array == "undefined" ? n : Int32Array, "%isFinite%": isFinite, "%isNaN%": isNaN, "%IteratorPrototype%": h ? l(l([][Symbol.iterator]())) : n, "%JSON%": typeof JSON == "object" ? JSON : n, "%Map%": typeof Map == "undefined" ? n : Map, "%MapIteratorPrototype%": typeof Map != "undefined" && h ? l(new Map()[Symbol.iterator]()) : n, "%Math%": Math, "%Number%": Number, "%Object%": Object, "%parseFloat%": parseFloat, "%parseInt%": parseInt, "%Promise%": typeof Promise == "undefined" ? n : Promise, "%Proxy%": typeof Proxy == "undefined" ? n : Proxy, "%RangeError%": RangeError, "%ReferenceError%": ReferenceError, "%Reflect%": typeof Reflect == "undefined" ? n : Reflect, "%RegExp%": RegExp, "%Set%": typeof Set == "undefined" ? n : Set, "%SetIteratorPrototype%": typeof Set != "undefined" && h ? l(new Set()[Symbol.iterator]()) : n, "%SharedArrayBuffer%": typeof SharedArrayBuffer == "undefined" ? n : SharedArrayBuffer, "%String%": String, "%StringIteratorPrototype%": h ? l(""[Symbol.iterator]()) : n, "%Symbol%": h ? Symbol : n, "%SyntaxError%": i, "%ThrowTypeError%": c, "%TypedArray%": p, "%TypeError%": a, "%Uint8Array%": typeof Uint8Array == "undefined" ? n : Uint8Array, "%Uint8ClampedArray%": typeof Uint8ClampedArray == "undefined" ? n : Uint8ClampedArray, "%Uint16Array%": typeof Uint16Array == "undefined" ? n : Uint16Array, "%Uint32Array%": typeof Uint32Array == "undefined" ? n : Uint32Array, "%URIError%": URIError, "%WeakMap%": typeof WeakMap == "undefined" ? n : WeakMap, "%WeakRef%": typeof WeakRef == "undefined" ? n : WeakRef, "%WeakSet%": typeof WeakSet == "undefined" ? n : WeakSet}, m = function t3(e3) { - var r3; - if (e3 === "%AsyncFunction%") - r3 = s("async function () {}"); - else if (e3 === "%GeneratorFunction%") - r3 = s("function* () {}"); - else if (e3 === "%AsyncGeneratorFunction%") - r3 = s("async function* () {}"); - else if (e3 === "%AsyncGenerator%") { - var n2 = t3("%AsyncGeneratorFunction%"); - n2 && (r3 = n2.prototype); - } else if (e3 === "%AsyncIteratorPrototype%") { - var i2 = t3("%AsyncGenerator%"); - i2 && (r3 = l(i2.prototype)); - } - return y[e3] = r3, r3; - }, b = {"%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"], "%ArrayPrototype%": ["Array", "prototype"], "%ArrayProto_entries%": ["Array", "prototype", "entries"], "%ArrayProto_forEach%": ["Array", "prototype", "forEach"], "%ArrayProto_keys%": ["Array", "prototype", "keys"], "%ArrayProto_values%": ["Array", "prototype", "values"], "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"], "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"], "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"], "%BooleanPrototype%": ["Boolean", "prototype"], "%DataViewPrototype%": ["DataView", "prototype"], "%DatePrototype%": ["Date", "prototype"], "%ErrorPrototype%": ["Error", "prototype"], "%EvalErrorPrototype%": ["EvalError", "prototype"], "%Float32ArrayPrototype%": ["Float32Array", "prototype"], "%Float64ArrayPrototype%": ["Float64Array", "prototype"], "%FunctionPrototype%": ["Function", "prototype"], "%Generator%": ["GeneratorFunction", "prototype"], "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"], "%Int8ArrayPrototype%": ["Int8Array", "prototype"], "%Int16ArrayPrototype%": ["Int16Array", "prototype"], "%Int32ArrayPrototype%": ["Int32Array", "prototype"], "%JSONParse%": ["JSON", "parse"], "%JSONStringify%": ["JSON", "stringify"], "%MapPrototype%": ["Map", "prototype"], "%NumberPrototype%": ["Number", "prototype"], "%ObjectPrototype%": ["Object", "prototype"], "%ObjProto_toString%": ["Object", "prototype", "toString"], "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"], "%PromisePrototype%": ["Promise", "prototype"], "%PromiseProto_then%": ["Promise", "prototype", "then"], "%Promise_all%": ["Promise", "all"], "%Promise_reject%": ["Promise", "reject"], "%Promise_resolve%": ["Promise", "resolve"], "%RangeErrorPrototype%": ["RangeError", "prototype"], "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"], "%RegExpPrototype%": ["RegExp", "prototype"], "%SetPrototype%": ["Set", "prototype"], "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"], "%StringPrototype%": ["String", "prototype"], "%SymbolPrototype%": ["Symbol", "prototype"], "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"], "%TypedArrayPrototype%": ["TypedArray", "prototype"], "%TypeErrorPrototype%": ["TypeError", "prototype"], "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"], "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"], "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"], "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"], "%URIErrorPrototype%": ["URIError", "prototype"], "%WeakMapPrototype%": ["WeakMap", "prototype"], "%WeakSetPrototype%": ["WeakSet", "prototype"]}, g = r2(8612), v = r2(7642), w = g.call(Function.call, Array.prototype.concat), _ = g.call(Function.apply, Array.prototype.splice), M = g.call(Function.call, String.prototype.replace), S = g.call(Function.call, String.prototype.slice), E = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, A = /\\(\\)?/g, k = function(t3) { - var e3 = S(t3, 0, 1), r3 = S(t3, -1); - if (e3 === "%" && r3 !== "%") - throw new i("invalid intrinsic syntax, expected closing `%`"); - if (r3 === "%" && e3 !== "%") - throw new i("invalid intrinsic syntax, expected opening `%`"); - var n2 = []; - return M(t3, E, function(t4, e4, r4, i2) { - n2[n2.length] = r4 ? M(i2, A, "$1") : e4 || t4; - }), n2; - }, B = function(t3, e3) { - var r3, n2 = t3; - if (v(b, n2) && (n2 = "%" + (r3 = b[n2])[0] + "%"), v(y, n2)) { - var o2 = y[n2]; - if (o2 === d && (o2 = m(n2)), o2 === void 0 && !e3) - throw new a("intrinsic " + t3 + " exists, but is not available. Please file an issue!"); - return {alias: r3, name: n2, value: o2}; - } - throw new i("intrinsic " + t3 + " does not exist!"); - }; - t2.exports = function(t3, e3) { - if (typeof t3 != "string" || t3.length === 0) - throw new a("intrinsic name must be a non-empty string"); - if (arguments.length > 1 && typeof e3 != "boolean") - throw new a('"allowMissing" argument must be a boolean'); - var r3 = k(t3), n2 = r3.length > 0 ? r3[0] : "", o2 = B("%" + n2 + "%", e3), s2 = o2.name, f2 = o2.value, c2 = false, h2 = o2.alias; - h2 && (n2 = h2[0], _(r3, w([0, 1], h2))); - for (var l2 = 1, d2 = true; l2 < r3.length; l2 += 1) { - var p2 = r3[l2], m2 = S(p2, 0, 1), b2 = S(p2, -1); - if ((m2 === '"' || m2 === "'" || m2 === "`" || b2 === '"' || b2 === "'" || b2 === "`") && m2 !== b2) - throw new i("property names with quotes must have matching quotes"); - if (p2 !== "constructor" && d2 || (c2 = true), v(y, s2 = "%" + (n2 += "." + p2) + "%")) - f2 = y[s2]; - else if (f2 != null) { - if (!(p2 in f2)) { - if (!e3) - throw new a("base intrinsic for " + t3 + " exists, but the property is not available."); - return; - } - if (u && l2 + 1 >= r3.length) { - var g2 = u(f2, p2); - f2 = (d2 = !!g2) && "get" in g2 && !("originalValue" in g2.get) ? g2.get : f2[p2]; - } else - d2 = v(f2, p2), f2 = f2[p2]; - d2 && !c2 && (y[s2] = f2); - } - } - return f2; - }; - }, 1405: (t2, e2, r2) => { - var n = typeof Symbol != "undefined" && Symbol, i = r2(5419); - t2.exports = function() { - return typeof n == "function" && typeof Symbol == "function" && typeof n("foo") == "symbol" && typeof Symbol("bar") == "symbol" && i(); - }; - }, 5419: (t2) => { - t2.exports = function() { - if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function") - return false; - if (typeof Symbol.iterator == "symbol") - return true; - var t3 = {}, e2 = Symbol("test"), r2 = Object(e2); - if (typeof e2 == "string") - return false; - if (Object.prototype.toString.call(e2) !== "[object Symbol]") - return false; - if (Object.prototype.toString.call(r2) !== "[object Symbol]") - return false; - for (e2 in t3[e2] = 42, t3) - return false; - if (typeof Object.keys == "function" && Object.keys(t3).length !== 0) - return false; - if (typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(t3).length !== 0) - return false; - var n = Object.getOwnPropertySymbols(t3); - if (n.length !== 1 || n[0] !== e2) - return false; - if (!Object.prototype.propertyIsEnumerable.call(t3, e2)) - return false; - if (typeof Object.getOwnPropertyDescriptor == "function") { - var i = Object.getOwnPropertyDescriptor(t3, e2); - if (i.value !== 42 || i.enumerable !== true) - return false; - } - return true; - }; - }, 7642: (t2, e2, r2) => { - var n = r2(8612); - t2.exports = n.call(Function.call, Object.prototype.hasOwnProperty); - }, 3349: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = r2(8473).Transform; - function o(t3) { - i.call(this), this._block = n.allocUnsafe(t3), this._blockSize = t3, this._blockOffset = 0, this._length = [0, 0, 0, 0], this._finalized = false; - } - r2(5717)(o, i), o.prototype._transform = function(t3, e3, r3) { - var n2 = null; - try { - this.update(t3, e3); - } catch (t4) { - n2 = t4; - } - r3(n2); - }, o.prototype._flush = function(t3) { - var e3 = null; - try { - this.push(this.digest()); - } catch (t4) { - e3 = t4; - } - t3(e3); - }, o.prototype.update = function(t3, e3) { - if (function(t4, e4) { - if (!n.isBuffer(t4) && typeof t4 != "string") - throw new TypeError("Data must be a string or a buffer"); - }(t3), this._finalized) - throw new Error("Digest already called"); - n.isBuffer(t3) || (t3 = n.from(t3, e3)); - for (var r3 = this._block, i2 = 0; this._blockOffset + t3.length - i2 >= this._blockSize; ) { - for (var o2 = this._blockOffset; o2 < this._blockSize; ) - r3[o2++] = t3[i2++]; - this._update(), this._blockOffset = 0; - } - for (; i2 < t3.length; ) - r3[this._blockOffset++] = t3[i2++]; - for (var a = 0, s = 8 * t3.length; s > 0; ++a) - this._length[a] += s, (s = this._length[a] / 4294967296 | 0) > 0 && (this._length[a] -= 4294967296 * s); - return this; - }, o.prototype._update = function() { - throw new Error("_update is not implemented"); - }, o.prototype.digest = function(t3) { - if (this._finalized) - throw new Error("Digest already called"); - this._finalized = true; - var e3 = this._digest(); - t3 !== void 0 && (e3 = e3.toString(t3)), this._block.fill(0), this._blockOffset = 0; - for (var r3 = 0; r3 < 4; ++r3) - this._length[r3] = 0; - return e3; - }, o.prototype._digest = function() { - throw new Error("_digest is not implemented"); - }, t2.exports = o; - }, 3715: (t2, e2, r2) => { - var n = e2; - n.utils = r2(6436), n.common = r2(5772), n.sha = r2(9041), n.ripemd = r2(2949), n.hmac = r2(2344), n.sha1 = n.sha.sha1, n.sha256 = n.sha.sha256, n.sha224 = n.sha.sha224, n.sha384 = n.sha.sha384, n.sha512 = n.sha.sha512, n.ripemd160 = n.ripemd.ripemd160; - }, 5772: (t2, e2, r2) => { - var n = r2(6436), i = r2(9746); - function o() { - 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; - } - e2.BlockHash = o, o.prototype.update = function(t3, e3) { - if (t3 = n.toArray(t3, e3), this.pending ? this.pending = this.pending.concat(t3) : this.pending = t3, this.pendingTotal += t3.length, this.pending.length >= this._delta8) { - var r3 = (t3 = this.pending).length % this._delta8; - this.pending = t3.slice(t3.length - r3, t3.length), this.pending.length === 0 && (this.pending = null), t3 = n.join32(t3, 0, t3.length - r3, this.endian); - for (var i2 = 0; i2 < t3.length; i2 += this._delta32) - this._update(t3, i2, i2 + this._delta32); - } - return this; - }, o.prototype.digest = function(t3) { - return this.update(this._pad()), i(this.pending === null), this._digest(t3); - }, o.prototype._pad = function() { - var t3 = this.pendingTotal, e3 = this._delta8, r3 = e3 - (t3 + this.padLength) % e3, n2 = new Array(r3 + this.padLength); - n2[0] = 128; - for (var i2 = 1; i2 < r3; i2++) - n2[i2] = 0; - if (t3 <<= 3, this.endian === "big") { - for (var o2 = 8; o2 < this.padLength; o2++) - n2[i2++] = 0; - n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = t3 >>> 24 & 255, n2[i2++] = t3 >>> 16 & 255, n2[i2++] = t3 >>> 8 & 255, n2[i2++] = 255 & t3; - } else - for (n2[i2++] = 255 & t3, n2[i2++] = t3 >>> 8 & 255, n2[i2++] = t3 >>> 16 & 255, n2[i2++] = t3 >>> 24 & 255, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, n2[i2++] = 0, o2 = 8; o2 < this.padLength; o2++) - n2[i2++] = 0; - return n2; - }; - }, 2344: (t2, e2, r2) => { - var n = r2(6436), i = r2(9746); - function o(t3, e3, r3) { - if (!(this instanceof o)) - return new o(t3, e3, r3); - this.Hash = t3, this.blockSize = t3.blockSize / 8, this.outSize = t3.outSize / 8, this.inner = null, this.outer = null, this._init(n.toArray(e3, r3)); - } - t2.exports = o, o.prototype._init = function(t3) { - t3.length > this.blockSize && (t3 = new this.Hash().update(t3).digest()), i(t3.length <= this.blockSize); - for (var e3 = t3.length; e3 < this.blockSize; e3++) - t3.push(0); - for (e3 = 0; e3 < t3.length; e3++) - t3[e3] ^= 54; - for (this.inner = new this.Hash().update(t3), e3 = 0; e3 < t3.length; e3++) - t3[e3] ^= 106; - this.outer = new this.Hash().update(t3); - }, o.prototype.update = function(t3, e3) { - return this.inner.update(t3, e3), this; - }, o.prototype.digest = function(t3) { - return this.outer.update(this.inner.digest()), this.outer.digest(t3); - }; - }, 2949: (t2, e2, r2) => { - var n = r2(6436), i = r2(5772), o = n.rotl32, a = n.sum32, s = n.sum32_3, u = n.sum32_4, f = i.BlockHash; - function c() { - if (!(this instanceof c)) - return new c(); - f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; - } - function h(t3, e3, r3, n2) { - return t3 <= 15 ? e3 ^ r3 ^ n2 : t3 <= 31 ? e3 & r3 | ~e3 & n2 : t3 <= 47 ? (e3 | ~r3) ^ n2 : t3 <= 63 ? e3 & n2 | r3 & ~n2 : e3 ^ (r3 | ~n2); - } - function l(t3) { - return t3 <= 15 ? 0 : t3 <= 31 ? 1518500249 : t3 <= 47 ? 1859775393 : t3 <= 63 ? 2400959708 : 2840853838; - } - function d(t3) { - return t3 <= 15 ? 1352829926 : t3 <= 31 ? 1548603684 : t3 <= 47 ? 1836072691 : t3 <= 63 ? 2053994217 : 0; - } - n.inherits(c, f), e2.ripemd160 = c, c.blockSize = 512, c.outSize = 160, c.hmacStrength = 192, c.padLength = 64, c.prototype._update = function(t3, e3) { - for (var r3 = this.h[0], n2 = this.h[1], i2 = this.h[2], f2 = this.h[3], c2 = this.h[4], g = r3, v = n2, w = i2, _ = f2, M = c2, S = 0; S < 80; S++) { - var E = a(o(u(r3, h(S, n2, i2, f2), t3[p[S] + e3], l(S)), m[S]), c2); - r3 = c2, c2 = f2, f2 = o(i2, 10), i2 = n2, n2 = E, E = a(o(u(g, h(79 - S, v, w, _), t3[y[S] + e3], d(S)), b[S]), M), g = M, M = _, _ = o(w, 10), w = v, v = E; - } - E = s(this.h[1], i2, _), this.h[1] = s(this.h[2], f2, M), this.h[2] = s(this.h[3], c2, g), this.h[3] = s(this.h[4], r3, v), this.h[4] = s(this.h[0], n2, w), this.h[0] = E; - }, c.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h, "little") : n.split32(this.h, "little"); - }; - var p = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], y = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], m = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], b = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; - }, 9041: (t2, e2, r2) => { - e2.sha1 = r2(4761), e2.sha224 = r2(799), e2.sha256 = r2(9344), e2.sha384 = r2(772), e2.sha512 = r2(5900); - }, 4761: (t2, e2, r2) => { - var n = r2(6436), i = r2(5772), o = r2(7038), a = n.rotl32, s = n.sum32, u = n.sum32_5, f = o.ft_1, c = i.BlockHash, h = [1518500249, 1859775393, 2400959708, 3395469782]; - function l() { - if (!(this instanceof l)) - return new l(); - c.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); - } - n.inherits(l, c), t2.exports = l, l.blockSize = 512, l.outSize = 160, l.hmacStrength = 80, l.padLength = 64, l.prototype._update = function(t3, e3) { - for (var r3 = this.W, n2 = 0; n2 < 16; n2++) - r3[n2] = t3[e3 + n2]; - for (; n2 < r3.length; n2++) - r3[n2] = a(r3[n2 - 3] ^ r3[n2 - 8] ^ r3[n2 - 14] ^ r3[n2 - 16], 1); - var i2 = this.h[0], o2 = this.h[1], c2 = this.h[2], l2 = this.h[3], d = this.h[4]; - for (n2 = 0; n2 < r3.length; n2++) { - var p = ~~(n2 / 20), y = u(a(i2, 5), f(p, o2, c2, l2), d, r3[n2], h[p]); - d = l2, l2 = c2, c2 = a(o2, 30), o2 = i2, i2 = y; - } - this.h[0] = s(this.h[0], i2), this.h[1] = s(this.h[1], o2), this.h[2] = s(this.h[2], c2), this.h[3] = s(this.h[3], l2), this.h[4] = s(this.h[4], d); - }, l.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); - }; - }, 799: (t2, e2, r2) => { - var n = r2(6436), i = r2(9344); - function o() { - if (!(this instanceof o)) - return new o(); - i.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; - } - n.inherits(o, i), t2.exports = o, o.blockSize = 512, o.outSize = 224, o.hmacStrength = 192, o.padLength = 64, o.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h.slice(0, 7), "big") : n.split32(this.h.slice(0, 7), "big"); - }; - }, 9344: (t2, e2, r2) => { - var n = r2(6436), i = r2(5772), o = r2(7038), a = r2(9746), s = n.sum32, u = n.sum32_4, f = n.sum32_5, c = o.ch32, h = o.maj32, l = o.s0_256, d = o.s1_256, p = o.g0_256, y = o.g1_256, m = i.BlockHash, b = [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 g() { - if (!(this instanceof g)) - return new g(); - m.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = b, this.W = new Array(64); - } - n.inherits(g, m), t2.exports = g, g.blockSize = 512, g.outSize = 256, g.hmacStrength = 192, g.padLength = 64, g.prototype._update = function(t3, e3) { - for (var r3 = this.W, n2 = 0; n2 < 16; n2++) - r3[n2] = t3[e3 + n2]; - for (; n2 < r3.length; n2++) - r3[n2] = u(y(r3[n2 - 2]), r3[n2 - 7], p(r3[n2 - 15]), r3[n2 - 16]); - var i2 = this.h[0], o2 = this.h[1], m2 = this.h[2], b2 = this.h[3], g2 = this.h[4], v = this.h[5], w = this.h[6], _ = this.h[7]; - for (a(this.k.length === r3.length), n2 = 0; n2 < r3.length; n2++) { - var M = f(_, d(g2), c(g2, v, w), this.k[n2], r3[n2]), S = s(l(i2), h(i2, o2, m2)); - _ = w, w = v, v = g2, g2 = s(b2, M), b2 = m2, m2 = o2, o2 = i2, i2 = s(M, S); - } - this.h[0] = s(this.h[0], i2), this.h[1] = s(this.h[1], o2), this.h[2] = s(this.h[2], m2), this.h[3] = s(this.h[3], b2), this.h[4] = s(this.h[4], g2), this.h[5] = s(this.h[5], v), this.h[6] = s(this.h[6], w), this.h[7] = s(this.h[7], _); - }, g.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); - }; - }, 772: (t2, e2, r2) => { - var n = r2(6436), i = r2(5900); - function o() { - if (!(this instanceof o)) - return new o(); - i.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; - } - n.inherits(o, i), t2.exports = o, o.blockSize = 1024, o.outSize = 384, o.hmacStrength = 192, o.padLength = 128, o.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h.slice(0, 12), "big") : n.split32(this.h.slice(0, 12), "big"); - }; - }, 5900: (t2, e2, r2) => { - var n = r2(6436), i = r2(5772), o = r2(9746), a = n.rotr64_hi, s = n.rotr64_lo, u = n.shr64_hi, f = n.shr64_lo, c = n.sum64, h = n.sum64_hi, l = n.sum64_lo, d = n.sum64_4_hi, p = n.sum64_4_lo, y = n.sum64_5_hi, m = n.sum64_5_lo, b = i.BlockHash, g = [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 v() { - if (!(this instanceof v)) - return new v(); - b.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = g, this.W = new Array(160); - } - function w(t3, e3, r3, n2, i2) { - var o2 = t3 & r3 ^ ~t3 & i2; - return o2 < 0 && (o2 += 4294967296), o2; - } - function _(t3, e3, r3, n2, i2, o2) { - var a2 = e3 & n2 ^ ~e3 & o2; - return a2 < 0 && (a2 += 4294967296), a2; - } - function M(t3, e3, r3, n2, i2) { - var o2 = t3 & r3 ^ t3 & i2 ^ r3 & i2; - return o2 < 0 && (o2 += 4294967296), o2; - } - function S(t3, e3, r3, n2, i2, o2) { - var a2 = e3 & n2 ^ e3 & o2 ^ n2 & o2; - return a2 < 0 && (a2 += 4294967296), a2; - } - function E(t3, e3) { - var r3 = a(t3, e3, 28) ^ a(e3, t3, 2) ^ a(e3, t3, 7); - return r3 < 0 && (r3 += 4294967296), r3; - } - function A(t3, e3) { - var r3 = s(t3, e3, 28) ^ s(e3, t3, 2) ^ s(e3, t3, 7); - return r3 < 0 && (r3 += 4294967296), r3; - } - function k(t3, e3) { - var r3 = s(t3, e3, 14) ^ s(t3, e3, 18) ^ s(e3, t3, 9); - return r3 < 0 && (r3 += 4294967296), r3; - } - function B(t3, e3) { - var r3 = a(t3, e3, 1) ^ a(t3, e3, 8) ^ u(t3, e3, 7); - return r3 < 0 && (r3 += 4294967296), r3; - } - function T(t3, e3) { - var r3 = s(t3, e3, 1) ^ s(t3, e3, 8) ^ f(t3, e3, 7); - return r3 < 0 && (r3 += 4294967296), r3; - } - function x(t3, e3) { - var r3 = s(t3, e3, 19) ^ s(e3, t3, 29) ^ f(t3, e3, 6); - return r3 < 0 && (r3 += 4294967296), r3; - } - n.inherits(v, b), t2.exports = v, v.blockSize = 1024, v.outSize = 512, v.hmacStrength = 192, v.padLength = 128, v.prototype._prepareBlock = function(t3, e3) { - for (var r3 = this.W, n2 = 0; n2 < 32; n2++) - r3[n2] = t3[e3 + n2]; - for (; n2 < r3.length; n2 += 2) { - var i2 = (m2 = r3[n2 - 4], b2 = r3[n2 - 3], g2 = void 0, (g2 = a(m2, b2, 19) ^ a(b2, m2, 29) ^ u(m2, b2, 6)) < 0 && (g2 += 4294967296), g2), o2 = x(r3[n2 - 4], r3[n2 - 3]), s2 = r3[n2 - 14], f2 = r3[n2 - 13], c2 = B(r3[n2 - 30], r3[n2 - 29]), h2 = T(r3[n2 - 30], r3[n2 - 29]), l2 = r3[n2 - 32], y2 = r3[n2 - 31]; - r3[n2] = d(i2, o2, s2, f2, c2, h2, l2, y2), r3[n2 + 1] = p(i2, o2, s2, f2, c2, h2, l2, y2); - } - var m2, b2, g2; - }, v.prototype._update = function(t3, e3) { - this._prepareBlock(t3, e3); - var r3, n2, i2, s2 = this.W, u2 = this.h[0], f2 = this.h[1], d2 = this.h[2], p2 = this.h[3], b2 = this.h[4], g2 = this.h[5], v2 = this.h[6], B2 = this.h[7], T2 = this.h[8], x2 = this.h[9], O = this.h[10], R = this.h[11], P = this.h[12], I = this.h[13], j = this.h[14], U = this.h[15]; - o(this.k.length === s2.length); - for (var N = 0; N < s2.length; N += 2) { - var C = j, D = U, L = (i2 = void 0, (i2 = a(r3 = T2, n2 = x2, 14) ^ a(r3, n2, 18) ^ a(n2, r3, 9)) < 0 && (i2 += 4294967296), i2), K = k(T2, x2), z = w(T2, 0, O, 0, P), q = _(0, x2, 0, R, 0, I), H = this.k[N], F = this.k[N + 1], V = s2[N], W = s2[N + 1], J = y(C, D, L, K, z, q, H, F, V, W), $ = m(C, D, L, K, z, q, H, F, V, W); - C = E(u2, f2), D = A(u2, f2), L = M(u2, 0, d2, 0, b2), K = S(0, f2, 0, p2, 0, g2); - var G = h(C, D, L, K), Z = l(C, D, L, K); - j = P, U = I, P = O, I = R, O = T2, R = x2, T2 = h(v2, B2, J, $), x2 = l(B2, B2, J, $), v2 = b2, B2 = g2, b2 = d2, g2 = p2, d2 = u2, p2 = f2, u2 = h(J, $, G, Z), f2 = l(J, $, G, Z); - } - c(this.h, 0, u2, f2), c(this.h, 2, d2, p2), c(this.h, 4, b2, g2), c(this.h, 6, v2, B2), c(this.h, 8, T2, x2), c(this.h, 10, O, R), c(this.h, 12, P, I), c(this.h, 14, j, U); - }, v.prototype._digest = function(t3) { - return t3 === "hex" ? n.toHex32(this.h, "big") : n.split32(this.h, "big"); - }; - }, 7038: (t2, e2, r2) => { - var n = r2(6436).rotr32; - function i(t3, e3, r3) { - return t3 & e3 ^ ~t3 & r3; - } - function o(t3, e3, r3) { - return t3 & e3 ^ t3 & r3 ^ e3 & r3; - } - function a(t3, e3, r3) { - return t3 ^ e3 ^ r3; - } - e2.ft_1 = function(t3, e3, r3, n2) { - return t3 === 0 ? i(e3, r3, n2) : t3 === 1 || t3 === 3 ? a(e3, r3, n2) : t3 === 2 ? o(e3, r3, n2) : void 0; - }, e2.ch32 = i, e2.maj32 = o, e2.p32 = a, e2.s0_256 = function(t3) { - return n(t3, 2) ^ n(t3, 13) ^ n(t3, 22); - }, e2.s1_256 = function(t3) { - return n(t3, 6) ^ n(t3, 11) ^ n(t3, 25); - }, e2.g0_256 = function(t3) { - return n(t3, 7) ^ n(t3, 18) ^ t3 >>> 3; - }, e2.g1_256 = function(t3) { - return n(t3, 17) ^ n(t3, 19) ^ t3 >>> 10; - }; - }, 6436: (t2, e2, r2) => { - var n = r2(9746), i = r2(5717); - function o(t3, e3) { - return (64512 & t3.charCodeAt(e3)) == 55296 && !(e3 < 0 || e3 + 1 >= t3.length) && (64512 & t3.charCodeAt(e3 + 1)) == 56320; - } - function a(t3) { - return (t3 >>> 24 | t3 >>> 8 & 65280 | t3 << 8 & 16711680 | (255 & t3) << 24) >>> 0; - } - function s(t3) { - return t3.length === 1 ? "0" + t3 : t3; - } - function u(t3) { - return t3.length === 7 ? "0" + t3 : t3.length === 6 ? "00" + t3 : t3.length === 5 ? "000" + t3 : t3.length === 4 ? "0000" + t3 : t3.length === 3 ? "00000" + t3 : t3.length === 2 ? "000000" + t3 : t3.length === 1 ? "0000000" + t3 : t3; - } - e2.inherits = i, e2.toArray = function(t3, e3) { - if (Array.isArray(t3)) - return t3.slice(); - if (!t3) - return []; - var r3 = []; - if (typeof t3 == "string") - if (e3) { - if (e3 === "hex") - for ((t3 = t3.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (t3 = "0" + t3), i2 = 0; i2 < t3.length; i2 += 2) - r3.push(parseInt(t3[i2] + t3[i2 + 1], 16)); - } else - for (var n2 = 0, i2 = 0; i2 < t3.length; i2++) { - var a2 = t3.charCodeAt(i2); - a2 < 128 ? r3[n2++] = a2 : a2 < 2048 ? (r3[n2++] = a2 >> 6 | 192, r3[n2++] = 63 & a2 | 128) : o(t3, i2) ? (a2 = 65536 + ((1023 & a2) << 10) + (1023 & t3.charCodeAt(++i2)), r3[n2++] = a2 >> 18 | 240, r3[n2++] = a2 >> 12 & 63 | 128, r3[n2++] = a2 >> 6 & 63 | 128, r3[n2++] = 63 & a2 | 128) : (r3[n2++] = a2 >> 12 | 224, r3[n2++] = a2 >> 6 & 63 | 128, r3[n2++] = 63 & a2 | 128); - } - else - for (i2 = 0; i2 < t3.length; i2++) - r3[i2] = 0 | t3[i2]; - return r3; - }, e2.toHex = function(t3) { - for (var e3 = "", r3 = 0; r3 < t3.length; r3++) - e3 += s(t3[r3].toString(16)); - return e3; - }, e2.htonl = a, e2.toHex32 = function(t3, e3) { - for (var r3 = "", n2 = 0; n2 < t3.length; n2++) { - var i2 = t3[n2]; - e3 === "little" && (i2 = a(i2)), r3 += u(i2.toString(16)); - } - return r3; - }, e2.zero2 = s, e2.zero8 = u, e2.join32 = function(t3, e3, r3, i2) { - var o2 = r3 - e3; - n(o2 % 4 == 0); - for (var a2 = new Array(o2 / 4), s2 = 0, u2 = e3; s2 < a2.length; s2++, u2 += 4) { - var f; - f = i2 === "big" ? t3[u2] << 24 | t3[u2 + 1] << 16 | t3[u2 + 2] << 8 | t3[u2 + 3] : t3[u2 + 3] << 24 | t3[u2 + 2] << 16 | t3[u2 + 1] << 8 | t3[u2], a2[s2] = f >>> 0; - } - return a2; - }, e2.split32 = function(t3, e3) { - for (var r3 = new Array(4 * t3.length), n2 = 0, i2 = 0; n2 < t3.length; n2++, i2 += 4) { - var o2 = t3[n2]; - e3 === "big" ? (r3[i2] = o2 >>> 24, r3[i2 + 1] = o2 >>> 16 & 255, r3[i2 + 2] = o2 >>> 8 & 255, r3[i2 + 3] = 255 & o2) : (r3[i2 + 3] = o2 >>> 24, r3[i2 + 2] = o2 >>> 16 & 255, r3[i2 + 1] = o2 >>> 8 & 255, r3[i2] = 255 & o2); - } - return r3; - }, e2.rotr32 = function(t3, e3) { - return t3 >>> e3 | t3 << 32 - e3; - }, e2.rotl32 = function(t3, e3) { - return t3 << e3 | t3 >>> 32 - e3; - }, e2.sum32 = function(t3, e3) { - return t3 + e3 >>> 0; - }, e2.sum32_3 = function(t3, e3, r3) { - return t3 + e3 + r3 >>> 0; - }, e2.sum32_4 = function(t3, e3, r3, n2) { - return t3 + e3 + r3 + n2 >>> 0; - }, e2.sum32_5 = function(t3, e3, r3, n2, i2) { - return t3 + e3 + r3 + n2 + i2 >>> 0; - }, e2.sum64 = function(t3, e3, r3, n2) { - var i2 = t3[e3], o2 = n2 + t3[e3 + 1] >>> 0, a2 = (o2 < n2 ? 1 : 0) + r3 + i2; - t3[e3] = a2 >>> 0, t3[e3 + 1] = o2; - }, e2.sum64_hi = function(t3, e3, r3, n2) { - return (e3 + n2 >>> 0 < e3 ? 1 : 0) + t3 + r3 >>> 0; - }, e2.sum64_lo = function(t3, e3, r3, n2) { - return e3 + n2 >>> 0; - }, e2.sum64_4_hi = function(t3, e3, r3, n2, i2, o2, a2, s2) { - var u2 = 0, f = e3; - return u2 += (f = f + n2 >>> 0) < e3 ? 1 : 0, u2 += (f = f + o2 >>> 0) < o2 ? 1 : 0, t3 + r3 + i2 + a2 + (u2 += (f = f + s2 >>> 0) < s2 ? 1 : 0) >>> 0; - }, e2.sum64_4_lo = function(t3, e3, r3, n2, i2, o2, a2, s2) { - return e3 + n2 + o2 + s2 >>> 0; - }, e2.sum64_5_hi = function(t3, e3, r3, n2, i2, o2, a2, s2, u2, f) { - var c = 0, h = e3; - return c += (h = h + n2 >>> 0) < e3 ? 1 : 0, c += (h = h + o2 >>> 0) < o2 ? 1 : 0, c += (h = h + s2 >>> 0) < s2 ? 1 : 0, t3 + r3 + i2 + a2 + u2 + (c += (h = h + f >>> 0) < f ? 1 : 0) >>> 0; - }, e2.sum64_5_lo = function(t3, e3, r3, n2, i2, o2, a2, s2, u2, f) { - return e3 + n2 + o2 + s2 + f >>> 0; - }, e2.rotr64_hi = function(t3, e3, r3) { - return (e3 << 32 - r3 | t3 >>> r3) >>> 0; - }, e2.rotr64_lo = function(t3, e3, r3) { - return (t3 << 32 - r3 | e3 >>> r3) >>> 0; - }, e2.shr64_hi = function(t3, e3, r3) { - return t3 >>> r3; - }, e2.shr64_lo = function(t3, e3, r3) { - return (t3 << 32 - r3 | e3 >>> r3) >>> 0; - }; - }, 2156: (t2, e2, r2) => { - var n = r2(3715), i = r2(4504), o = r2(9746); - function a(t3) { - if (!(this instanceof a)) - return new a(t3); - this.hash = t3.hash, this.predResist = !!t3.predResist, this.outLen = this.hash.outSize, this.minEntropy = t3.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; - var e3 = i.toArray(t3.entropy, t3.entropyEnc || "hex"), r3 = i.toArray(t3.nonce, t3.nonceEnc || "hex"), n2 = i.toArray(t3.pers, t3.persEnc || "hex"); - o(e3.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(e3, r3, n2); - } - t2.exports = a, a.prototype._init = function(t3, e3, r3) { - var n2 = t3.concat(e3).concat(r3); - this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); - for (var i2 = 0; i2 < this.V.length; i2++) - this.K[i2] = 0, this.V[i2] = 1; - this._update(n2), this._reseed = 1, this.reseedInterval = 281474976710656; - }, a.prototype._hmac = function() { - return new n.hmac(this.hash, this.K); - }, a.prototype._update = function(t3) { - var e3 = this._hmac().update(this.V).update([0]); - t3 && (e3 = e3.update(t3)), this.K = e3.digest(), this.V = this._hmac().update(this.V).digest(), t3 && (this.K = this._hmac().update(this.V).update([1]).update(t3).digest(), this.V = this._hmac().update(this.V).digest()); - }, a.prototype.reseed = function(t3, e3, r3, n2) { - typeof e3 != "string" && (n2 = r3, r3 = e3, e3 = null), t3 = i.toArray(t3, e3), r3 = i.toArray(r3, n2), o(t3.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t3.concat(r3 || [])), this._reseed = 1; - }, a.prototype.generate = function(t3, e3, r3, n2) { - if (this._reseed > this.reseedInterval) - throw new Error("Reseed is required"); - typeof e3 != "string" && (n2 = r3, r3 = e3, e3 = null), r3 && (r3 = i.toArray(r3, n2 || "hex"), this._update(r3)); - for (var o2 = []; o2.length < t3; ) - this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); - var a2 = o2.slice(0, t3); - return this._update(r3), this._reseed++, i.encode(a2, e3); - }; - }, 9695: (t2, e2, r2) => { - var n; - !function() { - var i = {y: function(t3) { - return t3 === 1 ? "\u03C7\u03C1\u03CC\u03BD\u03BF\u03C2" : "\u03C7\u03C1\u03CC\u03BD\u03B9\u03B1"; - }, mo: function(t3) { - return t3 === 1 ? "\u03BC\u03AE\u03BD\u03B1\u03C2" : "\u03BC\u03AE\u03BD\u03B5\u03C2"; - }, w: function(t3) { - return t3 === 1 ? "\u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1" : "\u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2"; - }, d: function(t3) { - return t3 === 1 ? "\u03BC\u03AD\u03C1\u03B1" : "\u03BC\u03AD\u03C1\u03B5\u03C2"; - }, h: function(t3) { - return t3 === 1 ? "\u03CE\u03C1\u03B1" : "\u03CE\u03C1\u03B5\u03C2"; - }, m: function(t3) { - return t3 === 1 ? "\u03BB\u03B5\u03C0\u03C4\u03CC" : "\u03BB\u03B5\u03C0\u03C4\u03AC"; - }, s: function(t3) { - return t3 === 1 ? "\u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF" : "\u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1"; - }, ms: function(t3) { - return t3 === 1 ? "\u03C7\u03B9\u03BB\u03B9\u03BF\u03C3\u03C4\u03CC \u03C4\u03BF\u03C5 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03BF\u03BB\u03AD\u03C0\u03C4\u03BF\u03C5" : "\u03C7\u03B9\u03BB\u03B9\u03BF\u03C3\u03C4\u03AC \u03C4\u03BF\u03C5 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03BF\u03BB\u03AD\u03C0\u03C4\u03BF\u03C5"; - }, decimal: ","}, o = {ar: {y: function(t3) { - return t3 === 1 ? "\u0633\u0646\u0629" : "\u0633\u0646\u0648\u0627\u062A"; - }, mo: function(t3) { - return t3 === 1 ? "\u0634\u0647\u0631" : "\u0623\u0634\u0647\u0631"; - }, w: function(t3) { - return t3 === 1 ? "\u0623\u0633\u0628\u0648\u0639" : "\u0623\u0633\u0627\u0628\u064A\u0639"; - }, d: function(t3) { - return t3 === 1 ? "\u064A\u0648\u0645" : "\u0623\u064A\u0627\u0645"; - }, h: function(t3) { - return t3 === 1 ? "\u0633\u0627\u0639\u0629" : "\u0633\u0627\u0639\u0627\u062A"; - }, m: function(t3) { - return t3 > 2 && t3 < 11 ? "\u062F\u0642\u0627\u0626\u0642" : "\u062F\u0642\u064A\u0642\u0629"; - }, s: function(t3) { - return t3 === 1 ? "\u062B\u0627\u0646\u064A\u0629" : "\u062B\u0648\u0627\u0646\u064A"; - }, ms: function(t3) { - return t3 === 1 ? "\u062C\u0632\u0621 \u0645\u0646 \u0627\u0644\u062B\u0627\u0646\u064A\u0629" : "\u0623\u062C\u0632\u0627\u0621 \u0645\u0646 \u0627\u0644\u062B\u0627\u0646\u064A\u0629"; - }, decimal: ","}, bg: {y: function(t3) { - return ["\u0433\u043E\u0434\u0438\u043D\u0438", "\u0433\u043E\u0434\u0438\u043D\u0430", "\u0433\u043E\u0434\u0438\u043D\u0438"][h(t3)]; - }, mo: function(t3) { - return ["\u043C\u0435\u0441\u0435\u0446\u0430", "\u043C\u0435\u0441\u0435\u0446", "\u043C\u0435\u0441\u0435\u0446\u0430"][h(t3)]; - }, w: function(t3) { - return ["\u0441\u0435\u0434\u043C\u0438\u0446\u0438", "\u0441\u0435\u0434\u043C\u0438\u0446\u0430", "\u0441\u0435\u0434\u043C\u0438\u0446\u0438"][h(t3)]; - }, d: function(t3) { - return ["\u0434\u043D\u0438", "\u0434\u0435\u043D", "\u0434\u043D\u0438"][h(t3)]; - }, h: function(t3) { - return ["\u0447\u0430\u0441\u0430", "\u0447\u0430\u0441", "\u0447\u0430\u0441\u0430"][h(t3)]; - }, m: function(t3) { - return ["\u043C\u0438\u043D\u0443\u0442\u0438", "\u043C\u0438\u043D\u0443\u0442\u0430", "\u043C\u0438\u043D\u0443\u0442\u0438"][h(t3)]; - }, s: function(t3) { - return ["\u0441\u0435\u043A\u0443\u043D\u0434\u0438", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; - }, ms: function(t3) { - return ["\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0438", "\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0438\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; - }, decimal: ","}, ca: {y: function(t3) { - return "any" + (t3 === 1 ? "" : "s"); - }, mo: function(t3) { - return "mes" + (t3 === 1 ? "" : "os"); - }, w: function(t3) { - return "setman" + (t3 === 1 ? "a" : "es"); - }, d: function(t3) { - return "di" + (t3 === 1 ? "a" : "es"); - }, h: function(t3) { - return "hor" + (t3 === 1 ? "a" : "es"); - }, m: function(t3) { - return "minut" + (t3 === 1 ? "" : "s"); - }, s: function(t3) { - return "segon" + (t3 === 1 ? "" : "s"); - }, ms: function(t3) { - return "milisegon" + (t3 === 1 ? "" : "s"); - }, decimal: ","}, cs: {y: function(t3) { - return ["rok", "roku", "roky", "let"][l(t3)]; - }, mo: function(t3) { - return ["m\u011Bs\xEDc", "m\u011Bs\xEDce", "m\u011Bs\xEDce", "m\u011Bs\xEDc\u016F"][l(t3)]; - }, w: function(t3) { - return ["t\xFDden", "t\xFDdne", "t\xFDdny", "t\xFDdn\u016F"][l(t3)]; - }, d: function(t3) { - return ["den", "dne", "dny", "dn\xED"][l(t3)]; - }, h: function(t3) { - return ["hodina", "hodiny", "hodiny", "hodin"][l(t3)]; - }, m: function(t3) { - return ["minuta", "minuty", "minuty", "minut"][l(t3)]; - }, s: function(t3) { - return ["sekunda", "sekundy", "sekundy", "sekund"][l(t3)]; - }, ms: function(t3) { - return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][l(t3)]; - }, decimal: ","}, da: {y: "\xE5r", mo: function(t3) { - return "m\xE5ned" + (t3 === 1 ? "" : "er"); - }, w: function(t3) { - return "uge" + (t3 === 1 ? "" : "r"); - }, d: function(t3) { - return "dag" + (t3 === 1 ? "" : "e"); - }, h: function(t3) { - return "time" + (t3 === 1 ? "" : "r"); - }, m: function(t3) { - return "minut" + (t3 === 1 ? "" : "ter"); - }, s: function(t3) { - return "sekund" + (t3 === 1 ? "" : "er"); - }, ms: function(t3) { - return "millisekund" + (t3 === 1 ? "" : "er"); - }, decimal: ","}, de: {y: function(t3) { - return "Jahr" + (t3 === 1 ? "" : "e"); - }, mo: function(t3) { - return "Monat" + (t3 === 1 ? "" : "e"); - }, w: function(t3) { - return "Woche" + (t3 === 1 ? "" : "n"); - }, d: function(t3) { - return "Tag" + (t3 === 1 ? "" : "e"); - }, h: function(t3) { - return "Stunde" + (t3 === 1 ? "" : "n"); - }, m: function(t3) { - return "Minute" + (t3 === 1 ? "" : "n"); - }, s: function(t3) { - return "Sekunde" + (t3 === 1 ? "" : "n"); - }, ms: function(t3) { - return "Millisekunde" + (t3 === 1 ? "" : "n"); - }, decimal: ","}, el: i, en: {y: function(t3) { - return "year" + (t3 === 1 ? "" : "s"); - }, mo: function(t3) { - return "month" + (t3 === 1 ? "" : "s"); - }, w: function(t3) { - return "week" + (t3 === 1 ? "" : "s"); - }, d: function(t3) { - return "day" + (t3 === 1 ? "" : "s"); - }, h: function(t3) { - return "hour" + (t3 === 1 ? "" : "s"); - }, m: function(t3) { - return "minute" + (t3 === 1 ? "" : "s"); - }, s: function(t3) { - return "second" + (t3 === 1 ? "" : "s"); - }, ms: function(t3) { - return "millisecond" + (t3 === 1 ? "" : "s"); - }, decimal: "."}, es: {y: function(t3) { - return "a\xF1o" + (t3 === 1 ? "" : "s"); - }, mo: function(t3) { - return "mes" + (t3 === 1 ? "" : "es"); - }, w: function(t3) { - return "semana" + (t3 === 1 ? "" : "s"); - }, d: function(t3) { - return "d\xEDa" + (t3 === 1 ? "" : "s"); - }, h: function(t3) { - return "hora" + (t3 === 1 ? "" : "s"); - }, m: function(t3) { - return "minuto" + (t3 === 1 ? "" : "s"); - }, s: function(t3) { - return "segundo" + (t3 === 1 ? "" : "s"); - }, ms: function(t3) { - return "milisegundo" + (t3 === 1 ? "" : "s"); - }, decimal: ","}, et: {y: function(t3) { - return "aasta" + (t3 === 1 ? "" : "t"); - }, mo: function(t3) { - return "kuu" + (t3 === 1 ? "" : "d"); - }, w: function(t3) { - return "n\xE4dal" + (t3 === 1 ? "" : "at"); - }, d: function(t3) { - return "p\xE4ev" + (t3 === 1 ? "" : "a"); - }, h: function(t3) { - return "tund" + (t3 === 1 ? "" : "i"); - }, m: function(t3) { - return "minut" + (t3 === 1 ? "" : "it"); - }, s: function(t3) { - return "sekund" + (t3 === 1 ? "" : "it"); - }, ms: function(t3) { - return "millisekund" + (t3 === 1 ? "" : "it"); - }, decimal: ","}, fa: {y: "\u0633\u0627\u0644", mo: "\u0645\u0627\u0647", w: "\u0647\u0641\u062A\u0647", d: "\u0631\u0648\u0632", h: "\u0633\u0627\u0639\u062A", m: "\u062F\u0642\u06CC\u0642\u0647", s: "\u062B\u0627\u0646\u06CC\u0647", ms: "\u0645\u06CC\u0644\u06CC \u062B\u0627\u0646\u06CC\u0647", decimal: "."}, fi: {y: function(t3) { - return t3 === 1 ? "vuosi" : "vuotta"; - }, mo: function(t3) { - return t3 === 1 ? "kuukausi" : "kuukautta"; - }, w: function(t3) { - return "viikko" + (t3 === 1 ? "" : "a"); - }, d: function(t3) { - return "p\xE4iv\xE4" + (t3 === 1 ? "" : "\xE4"); - }, h: function(t3) { - return "tunti" + (t3 === 1 ? "" : "a"); - }, m: function(t3) { - return "minuutti" + (t3 === 1 ? "" : "a"); - }, s: function(t3) { - return "sekunti" + (t3 === 1 ? "" : "a"); - }, ms: function(t3) { - return "millisekunti" + (t3 === 1 ? "" : "a"); - }, decimal: ","}, fo: {y: "\xE1r", mo: function(t3) { - return t3 === 1 ? "m\xE1na\xF0ur" : "m\xE1na\xF0ir"; - }, w: function(t3) { - return t3 === 1 ? "vika" : "vikur"; - }, d: function(t3) { - return t3 === 1 ? "dagur" : "dagar"; - }, h: function(t3) { - return t3 === 1 ? "t\xEDmi" : "t\xEDmar"; - }, m: function(t3) { - return t3 === 1 ? "minuttur" : "minuttir"; - }, s: "sekund", ms: "millisekund", decimal: ","}, fr: {y: function(t3) { - return "an" + (t3 >= 2 ? "s" : ""); - }, mo: "mois", w: function(t3) { - return "semaine" + (t3 >= 2 ? "s" : ""); - }, d: function(t3) { - return "jour" + (t3 >= 2 ? "s" : ""); - }, h: function(t3) { - return "heure" + (t3 >= 2 ? "s" : ""); - }, m: function(t3) { - return "minute" + (t3 >= 2 ? "s" : ""); - }, s: function(t3) { - return "seconde" + (t3 >= 2 ? "s" : ""); - }, ms: function(t3) { - return "milliseconde" + (t3 >= 2 ? "s" : ""); - }, decimal: ","}, gr: i, he: {y: function(t3) { - return t3 === 1 ? "\u05E9\u05E0\u05D4" : "\u05E9\u05E0\u05D9\u05DD"; - }, mo: function(t3) { - return t3 === 1 ? "\u05D7\u05D5\u05D3\u05E9" : "\u05D7\u05D5\u05D3\u05E9\u05D9\u05DD"; - }, w: function(t3) { - return t3 === 1 ? "\u05E9\u05D1\u05D5\u05E2" : "\u05E9\u05D1\u05D5\u05E2\u05D5\u05EA"; - }, d: function(t3) { - return t3 === 1 ? "\u05D9\u05D5\u05DD" : "\u05D9\u05DE\u05D9\u05DD"; - }, h: function(t3) { - return t3 === 1 ? "\u05E9\u05E2\u05D4" : "\u05E9\u05E2\u05D5\u05EA"; - }, m: function(t3) { - return t3 === 1 ? "\u05D3\u05E7\u05D4" : "\u05D3\u05E7\u05D5\u05EA"; - }, s: function(t3) { - return t3 === 1 ? "\u05E9\u05E0\u05D9\u05D4" : "\u05E9\u05E0\u05D9\u05D5\u05EA"; - }, ms: function(t3) { - return t3 === 1 ? "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D9\u05D4" : "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D5\u05EA"; - }, decimal: "."}, hr: {y: function(t3) { - return t3 % 10 == 2 || t3 % 10 == 3 || t3 % 10 == 4 ? "godine" : "godina"; - }, mo: function(t3) { - return t3 === 1 ? "mjesec" : t3 === 2 || t3 === 3 || t3 === 4 ? "mjeseca" : "mjeseci"; - }, w: function(t3) { - return t3 % 10 == 1 && t3 !== 11 ? "tjedan" : "tjedna"; - }, d: function(t3) { - return t3 === 1 ? "dan" : "dana"; - }, h: function(t3) { - return t3 === 1 ? "sat" : t3 === 2 || t3 === 3 || t3 === 4 ? "sata" : "sati"; - }, m: function(t3) { - var e3 = t3 % 10; - return e3 !== 2 && e3 !== 3 && e3 !== 4 || !(t3 < 10 || t3 > 14) ? "minuta" : "minute"; - }, s: function(t3) { - var e3 = t3 % 10; - return e3 === 5 || Math.floor(t3) === t3 && t3 >= 10 && t3 <= 19 ? "sekundi" : e3 === 1 ? "sekunda" : e3 === 2 || e3 === 3 || e3 === 4 ? "sekunde" : "sekundi"; - }, ms: function(t3) { - return t3 === 1 ? "milisekunda" : t3 % 10 == 2 || t3 % 10 == 3 || t3 % 10 == 4 ? "milisekunde" : "milisekundi"; - }, decimal: ","}, hi: {y: "\u0938\u093E\u0932", mo: function(t3) { - return t3 === 1 ? "\u092E\u0939\u0940\u0928\u093E" : "\u092E\u0939\u0940\u0928\u0947"; - }, w: function(t3) { - return t3 === 1 ? "\u0939\u095E\u094D\u0924\u093E" : "\u0939\u092B\u094D\u0924\u0947"; - }, d: "\u0926\u093F\u0928", h: function(t3) { - return t3 === 1 ? "\u0918\u0902\u091F\u093E" : "\u0918\u0902\u091F\u0947"; - }, m: "\u092E\u093F\u0928\u091F", s: "\u0938\u0947\u0915\u0902\u0921", ms: "\u092E\u093F\u0932\u0940\u0938\u0947\u0915\u0902\u0921", decimal: "."}, hu: {y: "\xE9v", mo: "h\xF3nap", w: "h\xE9t", d: "nap", h: "\xF3ra", m: "perc", s: "m\xE1sodperc", ms: "ezredm\xE1sodperc", decimal: ","}, id: {y: "tahun", mo: "bulan", w: "minggu", d: "hari", h: "jam", m: "menit", s: "detik", ms: "milidetik", decimal: "."}, is: {y: "\xE1r", mo: function(t3) { - return "m\xE1nu\xF0" + (t3 === 1 ? "ur" : "ir"); - }, w: function(t3) { - return "vik" + (t3 === 1 ? "a" : "ur"); - }, d: function(t3) { - return "dag" + (t3 === 1 ? "ur" : "ar"); - }, h: function(t3) { - return "klukkut\xEDm" + (t3 === 1 ? "i" : "ar"); - }, m: function(t3) { - return "m\xEDn\xFAt" + (t3 === 1 ? "a" : "ur"); - }, s: function(t3) { - return "sek\xFAnd" + (t3 === 1 ? "a" : "ur"); - }, ms: function(t3) { - return "millisek\xFAnd" + (t3 === 1 ? "a" : "ur"); - }, decimal: "."}, it: {y: function(t3) { - return "ann" + (t3 === 1 ? "o" : "i"); - }, mo: function(t3) { - return "mes" + (t3 === 1 ? "e" : "i"); - }, w: function(t3) { - return "settiman" + (t3 === 1 ? "a" : "e"); - }, d: function(t3) { - return "giorn" + (t3 === 1 ? "o" : "i"); - }, h: function(t3) { - return "or" + (t3 === 1 ? "a" : "e"); - }, m: function(t3) { - return "minut" + (t3 === 1 ? "o" : "i"); - }, s: function(t3) { - return "second" + (t3 === 1 ? "o" : "i"); - }, ms: function(t3) { - return "millisecond" + (t3 === 1 ? "o" : "i"); - }, decimal: ","}, ja: {y: "\u5E74", mo: "\u6708", w: "\u9031", d: "\u65E5", h: "\u6642\u9593", m: "\u5206", s: "\u79D2", ms: "\u30DF\u30EA\u79D2", decimal: "."}, ko: {y: "\uB144", mo: "\uAC1C\uC6D4", w: "\uC8FC\uC77C", d: "\uC77C", h: "\uC2DC\uAC04", m: "\uBD84", s: "\uCD08", ms: "\uBC00\uB9AC \uCD08", decimal: "."}, lo: {y: "\u0E9B\u0EB5", mo: "\u0EC0\u0E94\u0EB7\u0EAD\u0E99", w: "\u0EAD\u0EB2\u0E97\u0EB4\u0E94", d: "\u0EA1\u0EB7\u0EC9", h: "\u0E8A\u0EBB\u0EC8\u0EA7\u0EC2\u0EA1\u0E87", m: "\u0E99\u0EB2\u0E97\u0EB5", s: "\u0EA7\u0EB4\u0E99\u0EB2\u0E97\u0EB5", ms: "\u0EA1\u0EB4\u0E99\u0EA5\u0EB4\u0EA7\u0EB4\u0E99\u0EB2\u0E97\u0EB5", decimal: ","}, lt: {y: function(t3) { - return t3 % 10 == 0 || t3 % 100 >= 10 && t3 % 100 <= 20 ? "met\u0173" : "metai"; - }, mo: function(t3) { - return ["m\u0117nuo", "m\u0117nesiai", "m\u0117nesi\u0173"][d(t3)]; - }, w: function(t3) { - return ["savait\u0117", "savait\u0117s", "savai\u010Di\u0173"][d(t3)]; - }, d: function(t3) { - return ["diena", "dienos", "dien\u0173"][d(t3)]; - }, h: function(t3) { - return ["valanda", "valandos", "valand\u0173"][d(t3)]; - }, m: function(t3) { - return ["minut\u0117", "minut\u0117s", "minu\u010Di\u0173"][d(t3)]; - }, s: function(t3) { - return ["sekund\u0117", "sekund\u0117s", "sekund\u017Ei\u0173"][d(t3)]; - }, ms: function(t3) { - return ["milisekund\u0117", "milisekund\u0117s", "milisekund\u017Ei\u0173"][d(t3)]; - }, decimal: ","}, lv: {y: function(t3) { - return p(t3) ? "gads" : "gadi"; - }, mo: function(t3) { - return p(t3) ? "m\u0113nesis" : "m\u0113ne\u0161i"; - }, w: function(t3) { - return p(t3) ? "ned\u0113\u013Ca" : "ned\u0113\u013Cas"; - }, d: function(t3) { - return p(t3) ? "diena" : "dienas"; - }, h: function(t3) { - return p(t3) ? "stunda" : "stundas"; - }, m: function(t3) { - return p(t3) ? "min\u016Bte" : "min\u016Btes"; - }, s: function(t3) { - return p(t3) ? "sekunde" : "sekundes"; - }, ms: function(t3) { - return p(t3) ? "milisekunde" : "milisekundes"; - }, decimal: ","}, ms: {y: "tahun", mo: "bulan", w: "minggu", d: "hari", h: "jam", m: "minit", s: "saat", ms: "milisaat", decimal: "."}, nl: {y: "jaar", mo: function(t3) { - return t3 === 1 ? "maand" : "maanden"; - }, w: function(t3) { - return t3 === 1 ? "week" : "weken"; - }, d: function(t3) { - return t3 === 1 ? "dag" : "dagen"; - }, h: "uur", m: function(t3) { - return t3 === 1 ? "minuut" : "minuten"; - }, s: function(t3) { - return t3 === 1 ? "seconde" : "seconden"; - }, ms: function(t3) { - return t3 === 1 ? "milliseconde" : "milliseconden"; - }, decimal: ","}, no: {y: "\xE5r", mo: function(t3) { - return "m\xE5ned" + (t3 === 1 ? "" : "er"); - }, w: function(t3) { - return "uke" + (t3 === 1 ? "" : "r"); - }, d: function(t3) { - return "dag" + (t3 === 1 ? "" : "er"); - }, h: function(t3) { - return "time" + (t3 === 1 ? "" : "r"); - }, m: function(t3) { - return "minutt" + (t3 === 1 ? "" : "er"); - }, s: function(t3) { - return "sekund" + (t3 === 1 ? "" : "er"); - }, ms: function(t3) { - return "millisekund" + (t3 === 1 ? "" : "er"); - }, decimal: ","}, pl: {y: function(t3) { - return ["rok", "roku", "lata", "lat"][c(t3)]; - }, mo: function(t3) { - return ["miesi\u0105c", "miesi\u0105ca", "miesi\u0105ce", "miesi\u0119cy"][c(t3)]; - }, w: function(t3) { - return ["tydzie\u0144", "tygodnia", "tygodnie", "tygodni"][c(t3)]; - }, d: function(t3) { - return ["dzie\u0144", "dnia", "dni", "dni"][c(t3)]; - }, h: function(t3) { - return ["godzina", "godziny", "godziny", "godzin"][c(t3)]; - }, m: function(t3) { - return ["minuta", "minuty", "minuty", "minut"][c(t3)]; - }, s: function(t3) { - return ["sekunda", "sekundy", "sekundy", "sekund"][c(t3)]; - }, ms: function(t3) { - return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][c(t3)]; - }, decimal: ","}, pt: {y: function(t3) { - return "ano" + (t3 === 1 ? "" : "s"); - }, mo: function(t3) { - return t3 === 1 ? "m\xEAs" : "meses"; - }, w: function(t3) { - return "semana" + (t3 === 1 ? "" : "s"); - }, d: function(t3) { - return "dia" + (t3 === 1 ? "" : "s"); - }, h: function(t3) { - return "hora" + (t3 === 1 ? "" : "s"); - }, m: function(t3) { - return "minuto" + (t3 === 1 ? "" : "s"); - }, s: function(t3) { - return "segundo" + (t3 === 1 ? "" : "s"); - }, ms: function(t3) { - return "milissegundo" + (t3 === 1 ? "" : "s"); - }, decimal: ","}, ro: {y: function(t3) { - return t3 === 1 ? "an" : "ani"; - }, mo: function(t3) { - return t3 === 1 ? "lun\u0103" : "luni"; - }, w: function(t3) { - return t3 === 1 ? "s\u0103pt\u0103m\xE2n\u0103" : "s\u0103pt\u0103m\xE2ni"; - }, d: function(t3) { - return t3 === 1 ? "zi" : "zile"; - }, h: function(t3) { - return t3 === 1 ? "or\u0103" : "ore"; - }, m: function(t3) { - return t3 === 1 ? "minut" : "minute"; - }, s: function(t3) { - return t3 === 1 ? "secund\u0103" : "secunde"; - }, ms: function(t3) { - return t3 === 1 ? "milisecund\u0103" : "milisecunde"; - }, decimal: ","}, ru: {y: function(t3) { - return ["\u043B\u0435\u0442", "\u0433\u043E\u0434", "\u0433\u043E\u0434\u0430"][h(t3)]; - }, mo: function(t3) { - return ["\u043C\u0435\u0441\u044F\u0446\u0435\u0432", "\u043C\u0435\u0441\u044F\u0446", "\u043C\u0435\u0441\u044F\u0446\u0430"][h(t3)]; - }, w: function(t3) { - return ["\u043D\u0435\u0434\u0435\u043B\u044C", "\u043D\u0435\u0434\u0435\u043B\u044F", "\u043D\u0435\u0434\u0435\u043B\u0438"][h(t3)]; - }, d: function(t3) { - return ["\u0434\u043D\u0435\u0439", "\u0434\u0435\u043D\u044C", "\u0434\u043D\u044F"][h(t3)]; - }, h: function(t3) { - return ["\u0447\u0430\u0441\u043E\u0432", "\u0447\u0430\u0441", "\u0447\u0430\u0441\u0430"][h(t3)]; - }, m: function(t3) { - return ["\u043C\u0438\u043D\u0443\u0442", "\u043C\u0438\u043D\u0443\u0442\u0430", "\u043C\u0438\u043D\u0443\u0442\u044B"][h(t3)]; - }, s: function(t3) { - return ["\u0441\u0435\u043A\u0443\u043D\u0434", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u044B"][h(t3)]; - }, ms: function(t3) { - return ["\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434", "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u044B"][h(t3)]; - }, decimal: ","}, uk: {y: function(t3) { - return ["\u0440\u043E\u043A\u0456\u0432", "\u0440\u0456\u043A", "\u0440\u043E\u043A\u0438"][h(t3)]; - }, mo: function(t3) { - return ["\u043C\u0456\u0441\u044F\u0446\u0456\u0432", "\u043C\u0456\u0441\u044F\u0446\u044C", "\u043C\u0456\u0441\u044F\u0446\u0456"][h(t3)]; - }, w: function(t3) { - return ["\u0442\u0438\u0436\u043D\u0456\u0432", "\u0442\u0438\u0436\u0434\u0435\u043D\u044C", "\u0442\u0438\u0436\u043D\u0456"][h(t3)]; - }, d: function(t3) { - return ["\u0434\u043D\u0456\u0432", "\u0434\u0435\u043D\u044C", "\u0434\u043D\u0456"][h(t3)]; - }, h: function(t3) { - return ["\u0433\u043E\u0434\u0438\u043D", "\u0433\u043E\u0434\u0438\u043D\u0430", "\u0433\u043E\u0434\u0438\u043D\u0438"][h(t3)]; - }, m: function(t3) { - return ["\u0445\u0432\u0438\u043B\u0438\u043D", "\u0445\u0432\u0438\u043B\u0438\u043D\u0430", "\u0445\u0432\u0438\u043B\u0438\u043D\u0438"][h(t3)]; - }, s: function(t3) { - return ["\u0441\u0435\u043A\u0443\u043D\u0434", "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; - }, ms: function(t3) { - return ["\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434", "\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0430", "\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0438"][h(t3)]; - }, decimal: ","}, ur: {y: "\u0633\u0627\u0644", mo: function(t3) { - return t3 === 1 ? "\u0645\u06C1\u06CC\u0646\u06C1" : "\u0645\u06C1\u06CC\u0646\u06D2"; - }, w: function(t3) { - return t3 === 1 ? "\u06C1\u0641\u062A\u06C1" : "\u06C1\u0641\u062A\u06D2"; - }, d: "\u062F\u0646", h: function(t3) { - return t3 === 1 ? "\u06AF\u06BE\u0646\u0679\u06C1" : "\u06AF\u06BE\u0646\u0679\u06D2"; - }, m: "\u0645\u0646\u0679", s: "\u0633\u06CC\u06A9\u0646\u0688", ms: "\u0645\u0644\u06CC \u0633\u06CC\u06A9\u0646\u0688", decimal: "."}, sk: {y: function(t3) { - return ["rok", "roky", "roky", "rokov"][l(t3)]; - }, mo: function(t3) { - return ["mesiac", "mesiace", "mesiace", "mesiacov"][l(t3)]; - }, w: function(t3) { - return ["t\xFD\u017Ede\u0148", "t\xFD\u017Edne", "t\xFD\u017Edne", "t\xFD\u017Ed\u0148ov"][l(t3)]; - }, d: function(t3) { - return ["de\u0148", "dni", "dni", "dn\xED"][l(t3)]; - }, h: function(t3) { - return ["hodina", "hodiny", "hodiny", "hod\xEDn"][l(t3)]; - }, m: function(t3) { - return ["min\xFAta", "min\xFAty", "min\xFAty", "min\xFAt"][l(t3)]; - }, s: function(t3) { - return ["sekunda", "sekundy", "sekundy", "sek\xFAnd"][l(t3)]; - }, ms: function(t3) { - return ["milisekunda", "milisekundy", "milisekundy", "milisek\xFAnd"][l(t3)]; - }, decimal: ","}, sl: {y: function(t3) { - return t3 % 10 == 1 ? "leto" : t3 % 100 == 2 ? "leti" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 && t3 % 100 <= 5 ? "leta" : "let"; - }, mo: function(t3) { - return t3 % 10 == 1 ? "mesec" : t3 % 100 == 2 || Math.floor(t3) !== t3 && t3 % 100 <= 5 ? "meseca" : t3 % 10 == 3 || t3 % 10 == 4 ? "mesece" : "mesecev"; - }, w: function(t3) { - return t3 % 10 == 1 ? "teden" : t3 % 10 == 2 || Math.floor(t3) !== t3 && t3 % 100 <= 4 ? "tedna" : t3 % 10 == 3 || t3 % 10 == 4 ? "tedne" : "tednov"; - }, d: function(t3) { - return t3 % 100 == 1 ? "dan" : "dni"; - }, h: function(t3) { - return t3 % 10 == 1 ? "ura" : t3 % 100 == 2 ? "uri" : t3 % 10 == 3 || t3 % 10 == 4 || Math.floor(t3) !== t3 ? "ure" : "ur"; - }, m: function(t3) { - return t3 % 10 == 1 ? "minuta" : t3 % 10 == 2 ? "minuti" : t3 % 10 == 3 || t3 % 10 == 4 || Math.floor(t3) !== t3 && t3 % 100 <= 4 ? "minute" : "minut"; - }, s: function(t3) { - return t3 % 10 == 1 ? "sekunda" : t3 % 100 == 2 ? "sekundi" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 ? "sekunde" : "sekund"; - }, ms: function(t3) { - return t3 % 10 == 1 ? "milisekunda" : t3 % 100 == 2 ? "milisekundi" : t3 % 100 == 3 || t3 % 100 == 4 || Math.floor(t3) !== t3 ? "milisekunde" : "milisekund"; - }, decimal: ","}, sv: {y: "\xE5r", mo: function(t3) { - return "m\xE5nad" + (t3 === 1 ? "" : "er"); - }, w: function(t3) { - return "veck" + (t3 === 1 ? "a" : "or"); - }, d: function(t3) { - return "dag" + (t3 === 1 ? "" : "ar"); - }, h: function(t3) { - return "timm" + (t3 === 1 ? "e" : "ar"); - }, m: function(t3) { - return "minut" + (t3 === 1 ? "" : "er"); - }, s: function(t3) { - return "sekund" + (t3 === 1 ? "" : "er"); - }, ms: function(t3) { - return "millisekund" + (t3 === 1 ? "" : "er"); - }, decimal: ","}, sw: {y: function(t3) { - return t3 === 1 ? "mwaka" : "miaka"; - }, mo: function(t3) { - return t3 === 1 ? "mwezi" : "miezi"; - }, w: "wiki", d: function(t3) { - return t3 === 1 ? "siku" : "masiku"; - }, h: function(t3) { - return t3 === 1 ? "saa" : "masaa"; - }, m: "dakika", s: "sekunde", ms: "milisekunde", decimal: "."}, tr: {y: "y\u0131l", mo: "ay", w: "hafta", d: "g\xFCn", h: "saat", m: "dakika", s: "saniye", ms: "milisaniye", decimal: ","}, th: {y: "\u0E1B\u0E35", mo: "\u0E40\u0E14\u0E37\u0E2D\u0E19", w: "\u0E2A\u0E31\u0E1B\u0E14\u0E32\u0E2B\u0E4C", d: "\u0E27\u0E31\u0E19", h: "\u0E0A\u0E31\u0E48\u0E27\u0E42\u0E21\u0E07", m: "\u0E19\u0E32\u0E17\u0E35", s: "\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", ms: "\u0E21\u0E34\u0E25\u0E25\u0E34\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", decimal: "."}, vi: {y: "n\u0103m", mo: "th\xE1ng", w: "tu\u1EA7n", d: "ng\xE0y", h: "gi\u1EDD", m: "ph\xFAt", s: "gi\xE2y", ms: "mili gi\xE2y", decimal: ","}, zh_CN: {y: "\u5E74", mo: "\u4E2A\u6708", w: "\u5468", d: "\u5929", h: "\u5C0F\u65F6", m: "\u5206\u949F", s: "\u79D2", ms: "\u6BEB\u79D2", decimal: "."}, zh_TW: {y: "\u5E74", mo: "\u500B\u6708", w: "\u5468", d: "\u5929", h: "\u5C0F\u6642", m: "\u5206\u9418", s: "\u79D2", ms: "\u6BEB\u79D2", decimal: "."}}; - function a(t3) { - var e3 = function(t4, r3) { - return function(t5, e4) { - var r4, n2, i2; - t5 = Math.abs(t5); - var a2, s2, f2, c2 = function(t6) { - var e5 = [t6.language]; - if (m(t6, "fallbacks")) { - if (!y(t6.fallbacks) || !t6.fallbacks.length) - throw new Error("fallbacks must be an array with at least one element"); - e5 = e5.concat(t6.fallbacks); - } - for (var r5 = 0; r5 < e5.length; r5++) { - var n3 = e5[r5]; - if (m(t6.languages, n3)) - return t6.languages[n3]; - if (m(o, n3)) - return o[n3]; - } - throw new Error("No language found."); - }(e4), h2 = []; - for (r4 = 0, n2 = e4.units.length; r4 < n2; r4++) { - if (a2 = e4.units[r4], s2 = e4.unitMeasures[a2], r4 + 1 === n2) - if (m(e4, "maxDecimalPoints")) { - var l2 = Math.pow(10, e4.maxDecimalPoints), d2 = t5 / s2; - f2 = parseFloat((Math.floor(l2 * d2) / l2).toFixed(e4.maxDecimalPoints)); - } else - f2 = t5 / s2; - else - f2 = Math.floor(t5 / s2); - h2.push({unitCount: f2, unitName: a2}), t5 -= f2 * s2; - } - var p2, b, g = 0; - for (r4 = 0; r4 < h2.length; r4++) - if (h2[r4].unitCount) { - g = r4; - break; - } - if (e4.round) - for (r4 = h2.length - 1; r4 >= 0 && ((i2 = h2[r4]).unitCount = Math.round(i2.unitCount), r4 !== 0); r4--) - b = h2[r4 - 1], p2 = e4.unitMeasures[b.unitName] / e4.unitMeasures[i2.unitName], (i2.unitCount % p2 == 0 || e4.largest && e4.largest - 1 < r4 - g) && (b.unitCount += i2.unitCount / p2, i2.unitCount = 0); - var v = []; - for (r4 = 0, h2.length; r4 < n2 && ((i2 = h2[r4]).unitCount && v.push(u(i2.unitCount, i2.unitName, c2, e4)), v.length !== e4.largest); r4++) - ; - return v.length ? e4.conjunction && v.length !== 1 ? v.length === 2 ? v.join(e4.conjunction) : v.length > 2 ? v.slice(0, -1).join(e4.delimiter) + (e4.serialComma ? "," : "") + e4.conjunction + v.slice(-1) : void 0 : v.join(e4.delimiter) : u(0, e4.units[e4.units.length - 1], c2, e4); - }(t4, f({}, e3, r3 || {})); - }; - return f(e3, {language: "en", delimiter: ", ", spacer: " ", conjunction: "", serialComma: true, units: ["y", "mo", "w", "d", "h", "m", "s"], languages: {}, round: false, unitMeasures: {y: 315576e5, mo: 26298e5, w: 6048e5, d: 864e5, h: 36e5, m: 6e4, s: 1e3, ms: 1}}, t3); - } - var s = a({}); - function u(t3, e3, r3, n2) { - var i2; - i2 = m(n2, "decimal") ? n2.decimal : m(r3, "decimal") ? r3.decimal : "."; - var o2, a2 = t3.toString().replace(".", i2), s2 = r3[e3]; - return o2 = typeof s2 == "function" ? s2(t3) : s2, a2 + n2.spacer + o2; - } - function f(t3) { - for (var e3, r3 = 1; r3 < arguments.length; r3++) - for (var n2 in e3 = arguments[r3]) - m(e3, n2) && (t3[n2] = e3[n2]); - return t3; - } - function c(t3) { - return t3 === 1 ? 0 : Math.floor(t3) !== t3 ? 1 : t3 % 10 >= 2 && t3 % 10 <= 4 && !(t3 % 100 > 10 && t3 % 100 < 20) ? 2 : 3; - } - function h(t3) { - return Math.floor(t3) !== t3 ? 2 : t3 % 100 >= 5 && t3 % 100 <= 20 || t3 % 10 >= 5 && t3 % 10 <= 9 || t3 % 10 == 0 ? 0 : t3 % 10 == 1 ? 1 : t3 > 1 ? 2 : 0; - } - function l(t3) { - return t3 === 1 ? 0 : Math.floor(t3) !== t3 ? 1 : t3 % 10 >= 2 && t3 % 10 <= 4 && t3 % 100 < 10 ? 2 : 3; - } - function d(t3) { - return t3 === 1 || t3 % 10 == 1 && t3 % 100 > 20 ? 0 : Math.floor(t3) !== t3 || t3 % 10 >= 2 && t3 % 100 > 20 || t3 % 10 >= 2 && t3 % 100 < 10 ? 1 : 2; - } - function p(t3) { - return t3 % 10 == 1 && t3 % 100 != 11; - } - var y = Array.isArray || function(t3) { - return Object.prototype.toString.call(t3) === "[object Array]"; - }; - function m(t3, e3) { - return Object.prototype.hasOwnProperty.call(t3, e3); - } - s.getSupportedLanguages = function() { - var t3 = []; - for (var e3 in o) - m(o, e3) && e3 !== "gr" && t3.push(e3); - return t3; - }, s.humanizer = a, (n = function() { - return s; - }.call(e2, r2, e2, t2)) === void 0 || (t2.exports = n); - }(); - }, 645: (t2, e2) => { - e2.read = function(t3, e3, r2, n, i) { - var o, a, s = 8 * i - n - 1, u = (1 << s) - 1, f = u >> 1, c = -7, h = r2 ? i - 1 : 0, l = r2 ? -1 : 1, d = t3[e3 + h]; - for (h += l, o = d & (1 << -c) - 1, d >>= -c, c += s; c > 0; o = 256 * o + t3[e3 + h], h += l, c -= 8) - ; - for (a = o & (1 << -c) - 1, o >>= -c, c += n; c > 0; a = 256 * a + t3[e3 + h], h += l, c -= 8) - ; - if (o === 0) - o = 1 - f; - else { - if (o === u) - return a ? NaN : 1 / 0 * (d ? -1 : 1); - a += Math.pow(2, n), o -= f; - } - return (d ? -1 : 1) * a * Math.pow(2, o - n); - }, e2.write = function(t3, e3, r2, n, i, o) { - var a, s, u, f = 8 * o - i - 1, c = (1 << f) - 1, h = c >> 1, l = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = n ? 0 : o - 1, p = n ? 1 : -1, y = e3 < 0 || e3 === 0 && 1 / e3 < 0 ? 1 : 0; - for (e3 = Math.abs(e3), isNaN(e3) || e3 === 1 / 0 ? (s = isNaN(e3) ? 1 : 0, a = c) : (a = Math.floor(Math.log(e3) / Math.LN2), e3 * (u = Math.pow(2, -a)) < 1 && (a--, u *= 2), (e3 += a + h >= 1 ? l / u : l * Math.pow(2, 1 - h)) * u >= 2 && (a++, u /= 2), a + h >= c ? (s = 0, a = c) : a + h >= 1 ? (s = (e3 * u - 1) * Math.pow(2, i), a += h) : (s = e3 * Math.pow(2, h - 1) * Math.pow(2, i), a = 0)); i >= 8; t3[r2 + d] = 255 & s, d += p, s /= 256, i -= 8) - ; - for (a = a << i | s, f += i; f > 0; t3[r2 + d] = 255 & a, d += p, a /= 256, f -= 8) - ; - t3[r2 + d - p] |= 128 * y; - }; - }, 5717: (t2) => { - typeof Object.create == "function" ? t2.exports = function(t3, e2) { - e2 && (t3.super_ = e2, t3.prototype = Object.create(e2.prototype, {constructor: {value: t3, enumerable: false, writable: true, configurable: true}})); - } : t2.exports = function(t3, e2) { - if (e2) { - t3.super_ = e2; - var r2 = function() { - }; - r2.prototype = e2.prototype, t3.prototype = new r2(), t3.prototype.constructor = t3; - } - }; - }, 2584: (t2, e2, r2) => { - var n = typeof Symbol == "function" && typeof Symbol.toStringTag == "symbol", i = r2(1924)("Object.prototype.toString"), o = function(t3) { - return !(n && t3 && typeof t3 == "object" && Symbol.toStringTag in t3) && i(t3) === "[object Arguments]"; - }, a = function(t3) { - return !!o(t3) || t3 !== null && typeof t3 == "object" && typeof t3.length == "number" && t3.length >= 0 && i(t3) !== "[object Array]" && i(t3.callee) === "[object Function]"; - }, s = function() { - return o(arguments); - }(); - o.isLegacyArguments = a, t2.exports = s ? o : a; - }, 8662: (t2) => { - var e2 = Object.prototype.toString, r2 = Function.prototype.toString, n = /^\s*(?:function)?\*/, i = typeof Symbol == "function" && typeof Symbol.toStringTag == "symbol", o = Object.getPrototypeOf, a = function() { - if (!i) - return false; - try { - return Function("return function*() {}")(); - } catch (t3) { - } - }(), s = !(!o || !a) && o(a); - t2.exports = function(t3) { - return typeof t3 == "function" && (!!n.test(r2.call(t3)) || (i ? o && o(t3) === s : e2.call(t3) === "[object GeneratorFunction]")); - }; - }, 8611: (t2) => { - t2.exports = function(t3) { - return t3 != t3; - }; - }, 360: (t2, e2, r2) => { - var n = r2(5559), i = r2(4289), o = r2(8611), a = r2(9415), s = r2(3194), u = n(a(), Number); - i(u, {getPolyfill: a, implementation: o, shim: s}), t2.exports = u; - }, 9415: (t2, e2, r2) => { - var n = r2(8611); - t2.exports = function() { - return Number.isNaN && Number.isNaN(NaN) && !Number.isNaN("a") ? Number.isNaN : n; - }; - }, 3194: (t2, e2, r2) => { - var n = r2(4289), i = r2(9415); - t2.exports = function() { - var t3 = i(); - return n(Number, {isNaN: t3}, {isNaN: function() { - return Number.isNaN !== t3; - }}), t3; - }; - }, 5692: (t2, e2, r2) => { - var n = r2(9804), i = r2(6314), o = r2(1924), a = o("Object.prototype.toString"), s = r2(1405)() && typeof Symbol.toStringTag == "symbol", u = i(), f = o("Array.prototype.indexOf", true) || function(t3, e3) { - for (var r3 = 0; r3 < t3.length; r3 += 1) - if (t3[r3] === e3) - return r3; - return -1; - }, c = o("String.prototype.slice"), h = {}, l = r2(4079), d = Object.getPrototypeOf; - s && l && d && n(u, function(t3) { - var e3 = new r2.g[t3](); - if (!(Symbol.toStringTag in e3)) - throw new EvalError("this engine has support for Symbol.toStringTag, but " + t3 + " does not have the property! Please report this."); - var n2 = d(e3), i2 = l(n2, Symbol.toStringTag); - if (!i2) { - var o2 = d(n2); - i2 = l(o2, Symbol.toStringTag); - } - h[t3] = i2.get; - }), t2.exports = function(t3) { - if (!t3 || typeof t3 != "object") - return false; - if (!s) { - var e3 = c(a(t3), 8, -1); - return f(u, e3) > -1; - } - return !!l && function(t4) { - var e4 = false; - return n(h, function(r3, n2) { - if (!e4) - try { - e4 = r3.call(t4) === n2; - } catch (t5) { - } - }), e4; - }(t3); - }; - }, 4301: (t2, e2, r2) => { - r2(7147), t2.exports = self.fetch.bind(self); - }, 6792: (t2, e2, r2) => { - var n = null; - typeof WebSocket != "undefined" ? n = WebSocket : typeof MozWebSocket != "undefined" ? n = MozWebSocket : r2.g !== void 0 ? n = r2.g.WebSocket || r2.g.MozWebSocket : typeof window != "undefined" ? n = window.WebSocket || window.MozWebSocket : typeof self != "undefined" && (n = self.WebSocket || self.MozWebSocket), t2.exports = n; - }, 8917: (t2, e2, r2) => { - Object.defineProperty(e2, "__esModule", {value: true}); - const n = r2(2491); - e2.default = n.default; - }, 2491: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}); - const i = r2(6266), o = r2(9809), a = r2(3550), s = o.define("ECPrivateKey", function() { - const t3 = this; - t3.seq().obj(t3.key("version").int(), t3.key("privateKey").octstr(), t3.key("parameters").explicit(0).objid().optional(), t3.key("publicKey").explicit(1).bitstr().optional()); - }), u = o.define("SubjectPublicKeyInfo", function() { - const t3 = this; - t3.seq().obj(t3.key("algorithm").seq().obj(t3.key("id").objid(), t3.key("curve").objid()), t3.key("pub").bitstr()); - }), f = {secp256k1: {curveParameters: [1, 3, 132, 0, 10], privatePEMOptions: {label: "EC PRIVATE KEY"}, publicPEMOptions: {label: "PUBLIC KEY"}, curve: new i.ec("secp256k1")}}; - class c { - constructor(t3) { - if (typeof t3 == "string") { - if (t3 !== "secp256k1") - throw new Error("Unknown curve " + t3); - t3 = f[t3]; - } - this.options = t3, this.algorithmID = [1, 2, 840, 10045, 2, 1]; - } - privateKeyObject(t3, e3) { - const r3 = {version: new a(1), privateKey: n.from(t3, "hex"), parameters: this.options.curveParameters}; - return e3 && (r3.publicKey = {unused: 0, data: n.from(e3, "hex")}), r3; - } - publicKeyObject(t3) { - return {algorithm: {id: this.algorithmID, curve: this.options.curveParameters}, pub: {unused: 0, data: n.from(t3, "hex")}}; - } - encodePrivate(t3, e3, r3) { - let i2; - if (e3 === "raw") { - if (typeof t3 != "string") - throw "private key must be a string"; - let e4 = this.options.curve.keyFromPrivate(t3, "hex").getPublic("hex"); - i2 = this.privateKeyObject(t3, e4); - } else if (e3 === "der") { - if (typeof t3 != "string") - ; - else { - if (typeof t3 != "string") - throw "private key must be a buffer or a string"; - t3 = n.from(t3, "hex"); - } - i2 = s.decode(t3, "der"); - } else { - if (e3 !== "pem") - throw "invalid private key format"; - if (typeof t3 != "string") - throw "private key must be a string"; - i2 = s.decode(t3, "pem", this.options.privatePEMOptions); - } - if (r3 === "raw") - return i2.privateKey.toString("hex"); - if (r3 === "der") - return s.encode(i2, "der").toString("hex"); - if (r3 === "pem") - return s.encode(i2, "pem", this.options.privatePEMOptions); - throw "invalid destination format for private key"; - } - encodePublic(t3, e3, r3) { - let i2; - if (e3 === "raw") { - if (typeof t3 != "string") - throw "public key must be a string"; - i2 = this.publicKeyObject(t3); - } else if (e3 === "der") { - if (typeof t3 != "string") - ; - else { - if (typeof t3 != "string") - throw "public key must be a buffer or a string"; - t3 = n.from(t3, "hex"); - } - i2 = u.decode(t3, "der"); - } else { - if (e3 !== "pem") - throw "invalid public key format"; - if (typeof t3 != "string") - throw "public key must be a string"; - i2 = u.decode(t3, "pem", this.options.publicPEMOptions); - } - if (r3 === "raw") - return i2.pub.data.toString("hex"); - if (r3 === "der") - return u.encode(i2, "der").toString("hex"); - if (r3 === "pem") - return u.encode(i2, "pem", this.options.publicPEMOptions); - throw "invalid destination format for public key"; - } - } - e2.default = c, c.ECPrivateKeyASN = s, c.SubjectPublicKeyInfoASN = u; - }, 2318: (t2, e2, r2) => { - var n = r2(5717), i = r2(3349), o = r2(9509).Buffer, a = new Array(16); - function s() { - i.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878; - } - function u(t3, e3) { - return t3 << e3 | t3 >>> 32 - e3; - } - function f(t3, e3, r3, n2, i2, o2, a2) { - return u(t3 + (e3 & r3 | ~e3 & n2) + i2 + o2 | 0, a2) + e3 | 0; - } - function c(t3, e3, r3, n2, i2, o2, a2) { - return u(t3 + (e3 & n2 | r3 & ~n2) + i2 + o2 | 0, a2) + e3 | 0; - } - function h(t3, e3, r3, n2, i2, o2, a2) { - return u(t3 + (e3 ^ r3 ^ n2) + i2 + o2 | 0, a2) + e3 | 0; - } - function l(t3, e3, r3, n2, i2, o2, a2) { - return u(t3 + (r3 ^ (e3 | ~n2)) + i2 + o2 | 0, a2) + e3 | 0; - } - n(s, i), s.prototype._update = function() { - for (var t3 = a, e3 = 0; e3 < 16; ++e3) - t3[e3] = this._block.readInt32LE(4 * e3); - var r3 = this._a, n2 = this._b, i2 = this._c, o2 = this._d; - r3 = f(r3, n2, i2, o2, t3[0], 3614090360, 7), o2 = f(o2, r3, n2, i2, t3[1], 3905402710, 12), i2 = f(i2, o2, r3, n2, t3[2], 606105819, 17), n2 = f(n2, i2, o2, r3, t3[3], 3250441966, 22), r3 = f(r3, n2, i2, o2, t3[4], 4118548399, 7), o2 = f(o2, r3, n2, i2, t3[5], 1200080426, 12), i2 = f(i2, o2, r3, n2, t3[6], 2821735955, 17), n2 = f(n2, i2, o2, r3, t3[7], 4249261313, 22), r3 = f(r3, n2, i2, o2, t3[8], 1770035416, 7), o2 = f(o2, r3, n2, i2, t3[9], 2336552879, 12), i2 = f(i2, o2, r3, n2, t3[10], 4294925233, 17), n2 = f(n2, i2, o2, r3, t3[11], 2304563134, 22), r3 = f(r3, n2, i2, o2, t3[12], 1804603682, 7), o2 = f(o2, r3, n2, i2, t3[13], 4254626195, 12), i2 = f(i2, o2, r3, n2, t3[14], 2792965006, 17), r3 = c(r3, n2 = f(n2, i2, o2, r3, t3[15], 1236535329, 22), i2, o2, t3[1], 4129170786, 5), o2 = c(o2, r3, n2, i2, t3[6], 3225465664, 9), i2 = c(i2, o2, r3, n2, t3[11], 643717713, 14), n2 = c(n2, i2, o2, r3, t3[0], 3921069994, 20), r3 = c(r3, n2, i2, o2, t3[5], 3593408605, 5), o2 = c(o2, r3, n2, i2, t3[10], 38016083, 9), i2 = c(i2, o2, r3, n2, t3[15], 3634488961, 14), n2 = c(n2, i2, o2, r3, t3[4], 3889429448, 20), r3 = c(r3, n2, i2, o2, t3[9], 568446438, 5), o2 = c(o2, r3, n2, i2, t3[14], 3275163606, 9), i2 = c(i2, o2, r3, n2, t3[3], 4107603335, 14), n2 = c(n2, i2, o2, r3, t3[8], 1163531501, 20), r3 = c(r3, n2, i2, o2, t3[13], 2850285829, 5), o2 = c(o2, r3, n2, i2, t3[2], 4243563512, 9), i2 = c(i2, o2, r3, n2, t3[7], 1735328473, 14), r3 = h(r3, n2 = c(n2, i2, o2, r3, t3[12], 2368359562, 20), i2, o2, t3[5], 4294588738, 4), o2 = h(o2, r3, n2, i2, t3[8], 2272392833, 11), i2 = h(i2, o2, r3, n2, t3[11], 1839030562, 16), n2 = h(n2, i2, o2, r3, t3[14], 4259657740, 23), r3 = h(r3, n2, i2, o2, t3[1], 2763975236, 4), o2 = h(o2, r3, n2, i2, t3[4], 1272893353, 11), i2 = h(i2, o2, r3, n2, t3[7], 4139469664, 16), n2 = h(n2, i2, o2, r3, t3[10], 3200236656, 23), r3 = h(r3, n2, i2, o2, t3[13], 681279174, 4), o2 = h(o2, r3, n2, i2, t3[0], 3936430074, 11), i2 = h(i2, o2, r3, n2, t3[3], 3572445317, 16), n2 = h(n2, i2, o2, r3, t3[6], 76029189, 23), r3 = h(r3, n2, i2, o2, t3[9], 3654602809, 4), o2 = h(o2, r3, n2, i2, t3[12], 3873151461, 11), i2 = h(i2, o2, r3, n2, t3[15], 530742520, 16), r3 = l(r3, n2 = h(n2, i2, o2, r3, t3[2], 3299628645, 23), i2, o2, t3[0], 4096336452, 6), o2 = l(o2, r3, n2, i2, t3[7], 1126891415, 10), i2 = l(i2, o2, r3, n2, t3[14], 2878612391, 15), n2 = l(n2, i2, o2, r3, t3[5], 4237533241, 21), r3 = l(r3, n2, i2, o2, t3[12], 1700485571, 6), o2 = l(o2, r3, n2, i2, t3[3], 2399980690, 10), i2 = l(i2, o2, r3, n2, t3[10], 4293915773, 15), n2 = l(n2, i2, o2, r3, t3[1], 2240044497, 21), r3 = l(r3, n2, i2, o2, t3[8], 1873313359, 6), o2 = l(o2, r3, n2, i2, t3[15], 4264355552, 10), i2 = l(i2, o2, r3, n2, t3[6], 2734768916, 15), n2 = l(n2, i2, o2, r3, t3[13], 1309151649, 21), r3 = l(r3, n2, i2, o2, t3[4], 4149444226, 6), o2 = l(o2, r3, n2, i2, t3[11], 3174756917, 10), i2 = l(i2, o2, r3, n2, t3[2], 718787259, 15), n2 = l(n2, i2, o2, r3, t3[9], 3951481745, 21), this._a = this._a + r3 | 0, this._b = this._b + n2 | 0, this._c = this._c + i2 | 0, this._d = this._d + o2 | 0; - }, s.prototype._digest = function() { - this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); - var t3 = o.allocUnsafe(16); - return t3.writeInt32LE(this._a, 0), t3.writeInt32LE(this._b, 4), t3.writeInt32LE(this._c, 8), t3.writeInt32LE(this._d, 12), t3; - }, t2.exports = s; - }, 3047: (t2, e2, r2) => { - var n = r2(3550), i = r2(7376); - function o(t3) { - this.rand = t3 || new i.Rand(); - } - t2.exports = o, o.create = function(t3) { - return new o(t3); - }, o.prototype._randbelow = function(t3) { - var e3 = t3.bitLength(), r3 = Math.ceil(e3 / 8); - do { - var i2 = new n(this.rand.generate(r3)); - } while (i2.cmp(t3) >= 0); - return i2; - }, o.prototype._randrange = function(t3, e3) { - var r3 = e3.sub(t3); - return t3.add(this._randbelow(r3)); - }, o.prototype.test = function(t3, e3, r3) { - var i2 = t3.bitLength(), o2 = n.mont(t3), a = new n(1).toRed(o2); - e3 || (e3 = Math.max(1, i2 / 48 | 0)); - for (var s = t3.subn(1), u = 0; !s.testn(u); u++) - ; - for (var f = t3.shrn(u), c = s.toRed(o2); e3 > 0; e3--) { - var h = this._randrange(new n(2), s); - r3 && r3(h); - var l = h.toRed(o2).redPow(f); - if (l.cmp(a) !== 0 && l.cmp(c) !== 0) { - for (var d = 1; d < u; d++) { - if ((l = l.redSqr()).cmp(a) === 0) - return false; - if (l.cmp(c) === 0) - break; - } - if (d === u) - return false; - } - } - return true; - }, o.prototype.getDivisor = function(t3, e3) { - var r3 = t3.bitLength(), i2 = n.mont(t3), o2 = new n(1).toRed(i2); - e3 || (e3 = Math.max(1, r3 / 48 | 0)); - for (var a = t3.subn(1), s = 0; !a.testn(s); s++) - ; - for (var u = t3.shrn(s), f = a.toRed(i2); e3 > 0; e3--) { - var c = this._randrange(new n(2), a), h = t3.gcd(c); - if (h.cmpn(1) !== 0) - return h; - var l = c.toRed(i2).redPow(u); - if (l.cmp(o2) !== 0 && l.cmp(f) !== 0) { - for (var d = 1; d < s; d++) { - if ((l = l.redSqr()).cmp(o2) === 0) - return l.fromRed().subn(1).gcd(t3); - if (l.cmp(f) === 0) - break; - } - if (d === s) - return (l = l.redSqr()).fromRed().subn(1).gcd(t3); - } - } - return false; - }; - }, 9746: (t2) => { - function e2(t3, e3) { - if (!t3) - throw new Error(e3 || "Assertion failed"); - } - t2.exports = e2, e2.equal = function(t3, e3, r2) { - if (t3 != e3) - throw new Error(r2 || "Assertion failed: " + t3 + " != " + e3); - }; - }, 4504: (t2, e2) => { - var r2 = e2; - function n(t3) { - return t3.length === 1 ? "0" + t3 : t3; - } - function i(t3) { - for (var e3 = "", r3 = 0; r3 < t3.length; r3++) - e3 += n(t3[r3].toString(16)); - return e3; - } - r2.toArray = function(t3, e3) { - if (Array.isArray(t3)) - return t3.slice(); - if (!t3) - return []; - var r3 = []; - if (typeof t3 != "string") { - for (var n2 = 0; n2 < t3.length; n2++) - r3[n2] = 0 | t3[n2]; - return r3; - } - if (e3 === "hex") - for ((t3 = t3.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (t3 = "0" + t3), n2 = 0; n2 < t3.length; n2 += 2) - r3.push(parseInt(t3[n2] + t3[n2 + 1], 16)); - else - for (n2 = 0; n2 < t3.length; n2++) { - var i2 = t3.charCodeAt(n2), o = i2 >> 8, a = 255 & i2; - o ? r3.push(o, a) : r3.push(a); - } - return r3; - }, r2.zero2 = n, r2.toHex = i, r2.encode = function(t3, e3) { - return e3 === "hex" ? i(t3) : t3; - }; - }, 4244: (t2) => { - var e2 = function(t3) { - return t3 != t3; - }; - t2.exports = function(t3, r2) { - return t3 === 0 && r2 === 0 ? 1 / t3 == 1 / r2 : t3 === r2 || !(!e2(t3) || !e2(r2)); - }; - }, 609: (t2, e2, r2) => { - var n = r2(4289), i = r2(5559), o = r2(4244), a = r2(5624), s = r2(2281), u = i(a(), Object); - n(u, {getPolyfill: a, implementation: o, shim: s}), t2.exports = u; - }, 5624: (t2, e2, r2) => { - var n = r2(4244); - t2.exports = function() { - return typeof Object.is == "function" ? Object.is : n; - }; - }, 2281: (t2, e2, r2) => { - var n = r2(5624), i = r2(4289); - t2.exports = function() { - var t3 = n(); - return i(Object, {is: t3}, {is: function() { - return Object.is !== t3; - }}), t3; - }; - }, 8987: (t2, e2, r2) => { - var n; - if (!Object.keys) { - var i = Object.prototype.hasOwnProperty, o = Object.prototype.toString, a = r2(1414), s = Object.prototype.propertyIsEnumerable, u = !s.call({toString: null}, "toString"), f = s.call(function() { - }, "prototype"), c = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], h = function(t3) { - var e3 = t3.constructor; - return e3 && e3.prototype === t3; - }, l = {$applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true}, d = function() { - if (typeof window == "undefined") - return false; - for (var t3 in window) - try { - if (!l["$" + t3] && i.call(window, t3) && window[t3] !== null && typeof window[t3] == "object") - try { - h(window[t3]); - } catch (t4) { - return true; - } - } catch (t4) { - return true; - } - return false; - }(); - n = function(t3) { - var e3 = t3 !== null && typeof t3 == "object", r3 = o.call(t3) === "[object Function]", n2 = a(t3), s2 = e3 && o.call(t3) === "[object String]", l2 = []; - if (!e3 && !r3 && !n2) - throw new TypeError("Object.keys called on a non-object"); - var p = f && r3; - if (s2 && t3.length > 0 && !i.call(t3, 0)) - for (var y = 0; y < t3.length; ++y) - l2.push(String(y)); - if (n2 && t3.length > 0) - for (var m = 0; m < t3.length; ++m) - l2.push(String(m)); - else - for (var b in t3) - p && b === "prototype" || !i.call(t3, b) || l2.push(String(b)); - if (u) - for (var g = function(t4) { - if (typeof window == "undefined" || !d) - return h(t4); - try { - return h(t4); - } catch (t5) { - return false; - } - }(t3), v = 0; v < c.length; ++v) - g && c[v] === "constructor" || !i.call(t3, c[v]) || l2.push(c[v]); - return l2; - }; - } - t2.exports = n; - }, 2215: (t2, e2, r2) => { - var n = Array.prototype.slice, i = r2(1414), o = Object.keys, a = o ? function(t3) { - return o(t3); - } : r2(8987), s = Object.keys; - a.shim = function() { - return Object.keys ? function() { - var t3 = Object.keys(arguments); - return t3 && t3.length === arguments.length; - }(1, 2) || (Object.keys = function(t3) { - return i(t3) ? s(n.call(t3)) : s(t3); - }) : Object.keys = a, Object.keys || a; - }, t2.exports = a; - }, 1414: (t2) => { - var e2 = Object.prototype.toString; - t2.exports = function(t3) { - var r2 = e2.call(t3), n = r2 === "[object Arguments]"; - return n || (n = r2 !== "[object Array]" && t3 !== null && typeof t3 == "object" && typeof t3.length == "number" && t3.length >= 0 && e2.call(t3.callee) === "[object Function]"), n; - }; - }, 873: (t2) => { - t2.exports = JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}'); - }, 2818: (t2, e2, r2) => { - var n = r2(9809); - e2.certificate = r2(1934); - var i = n.define("RSAPrivateKey", function() { - this.seq().obj(this.key("version").int(), this.key("modulus").int(), this.key("publicExponent").int(), this.key("privateExponent").int(), this.key("prime1").int(), this.key("prime2").int(), this.key("exponent1").int(), this.key("exponent2").int(), this.key("coefficient").int()); - }); - e2.RSAPrivateKey = i; - var o = n.define("RSAPublicKey", function() { - this.seq().obj(this.key("modulus").int(), this.key("publicExponent").int()); - }); - e2.RSAPublicKey = o; - var a = n.define("SubjectPublicKeyInfo", function() { - this.seq().obj(this.key("algorithm").use(s), this.key("subjectPublicKey").bitstr()); - }); - e2.PublicKey = a; - var s = n.define("AlgorithmIdentifier", function() { - this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional()); - }), u = n.define("PrivateKeyInfo", function() { - this.seq().obj(this.key("version").int(), this.key("algorithm").use(s), this.key("subjectPrivateKey").octstr()); - }); - e2.PrivateKey = u; - var f = n.define("EncryptedPrivateKeyInfo", function() { - this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(), this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(), this.key("kdeparams").seq().obj(this.key("salt").octstr(), this.key("iters").int())), this.key("cipher").seq().obj(this.key("algo").objid(), this.key("iv").octstr()))), this.key("subjectPrivateKey").octstr()); - }); - e2.EncryptedPrivateKey = f; - var c = n.define("DSAPrivateKey", function() { - this.seq().obj(this.key("version").int(), this.key("p").int(), this.key("q").int(), this.key("g").int(), this.key("pub_key").int(), this.key("priv_key").int()); - }); - e2.DSAPrivateKey = c, e2.DSAparam = n.define("DSAparam", function() { - this.int(); - }); - var h = n.define("ECPrivateKey", function() { - this.seq().obj(this.key("version").int(), this.key("privateKey").octstr(), this.key("parameters").optional().explicit(0).use(l), this.key("publicKey").optional().explicit(1).bitstr()); - }); - e2.ECPrivateKey = h; - var l = n.define("ECParameters", function() { - this.choice({namedCurve: this.objid()}); - }); - e2.signature = n.define("signature", function() { - this.seq().obj(this.key("r").int(), this.key("s").int()); - }); - }, 1934: (t2, e2, r2) => { - var n = r2(9809), i = n.define("Time", function() { - this.choice({utcTime: this.utctime(), generalTime: this.gentime()}); - }), o = n.define("AttributeTypeValue", function() { - this.seq().obj(this.key("type").objid(), this.key("value").any()); - }), a = n.define("AlgorithmIdentifier", function() { - this.seq().obj(this.key("algorithm").objid(), this.key("parameters").optional(), this.key("curve").objid().optional()); - }), s = n.define("SubjectPublicKeyInfo", function() { - this.seq().obj(this.key("algorithm").use(a), this.key("subjectPublicKey").bitstr()); - }), u = n.define("RelativeDistinguishedName", function() { - this.setof(o); - }), f = n.define("RDNSequence", function() { - this.seqof(u); - }), c = n.define("Name", function() { - this.choice({rdnSequence: this.use(f)}); - }), h = n.define("Validity", function() { - this.seq().obj(this.key("notBefore").use(i), this.key("notAfter").use(i)); - }), l = n.define("Extension", function() { - this.seq().obj(this.key("extnID").objid(), this.key("critical").bool().def(false), this.key("extnValue").octstr()); - }), d = n.define("TBSCertificate", function() { - this.seq().obj(this.key("version").explicit(0).int().optional(), this.key("serialNumber").int(), this.key("signature").use(a), this.key("issuer").use(c), this.key("validity").use(h), this.key("subject").use(c), this.key("subjectPublicKeyInfo").use(s), this.key("issuerUniqueID").implicit(1).bitstr().optional(), this.key("subjectUniqueID").implicit(2).bitstr().optional(), this.key("extensions").explicit(3).seqof(l).optional()); - }), p = n.define("X509Certificate", function() { - this.seq().obj(this.key("tbsCertificate").use(d), this.key("signatureAlgorithm").use(a), this.key("signatureValue").bitstr()); - }); - t2.exports = p; - }, 7631: (t2, e2, r2) => { - var n = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m, i = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m, o = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m, a = r2(3048), s = r2(4696), u = r2(9509).Buffer; - t2.exports = function(t3, e3) { - var r3, f = t3.toString(), c = f.match(n); - if (c) { - var h = "aes" + c[1], l = u.from(c[2], "hex"), d = u.from(c[3].replace(/[\r\n]/g, ""), "base64"), p = a(e3, l.slice(0, 8), parseInt(c[1], 10)).key, y = [], m = s.createDecipheriv(h, p, l); - y.push(m.update(d)), y.push(m.final()), r3 = u.concat(y); - } else { - var b = f.match(o); - r3 = u.from(b[2].replace(/[\r\n]/g, ""), "base64"); - } - return {tag: f.match(i)[1], data: r3}; - }; - }, 980: (t2, e2, r2) => { - var n = r2(2818), i = r2(873), o = r2(7631), a = r2(4696), s = r2(5632), u = r2(9509).Buffer; - function f(t3) { - var e3; - typeof t3 != "object" || u.isBuffer(t3) || (e3 = t3.passphrase, t3 = t3.key), typeof t3 == "string" && (t3 = u.from(t3)); - var r3, f2, c = o(t3, e3), h = c.tag, l = c.data; - switch (h) { - case "CERTIFICATE": - f2 = n.certificate.decode(l, "der").tbsCertificate.subjectPublicKeyInfo; - case "PUBLIC KEY": - switch (f2 || (f2 = n.PublicKey.decode(l, "der")), r3 = f2.algorithm.algorithm.join(".")) { - case "1.2.840.113549.1.1.1": - return n.RSAPublicKey.decode(f2.subjectPublicKey.data, "der"); - case "1.2.840.10045.2.1": - return f2.subjectPrivateKey = f2.subjectPublicKey, {type: "ec", data: f2}; - case "1.2.840.10040.4.1": - return f2.algorithm.params.pub_key = n.DSAparam.decode(f2.subjectPublicKey.data, "der"), {type: "dsa", data: f2.algorithm.params}; - default: - throw new Error("unknown key id " + r3); - } - case "ENCRYPTED PRIVATE KEY": - l = function(t4, e4) { - var r4 = t4.algorithm.decrypt.kde.kdeparams.salt, n2 = parseInt(t4.algorithm.decrypt.kde.kdeparams.iters.toString(), 10), o2 = i[t4.algorithm.decrypt.cipher.algo.join(".")], f3 = t4.algorithm.decrypt.cipher.iv, c2 = t4.subjectPrivateKey, h2 = parseInt(o2.split("-")[1], 10) / 8, l2 = s.pbkdf2Sync(e4, r4, n2, h2, "sha1"), d = a.createDecipheriv(o2, l2, f3), p = []; - return p.push(d.update(c2)), p.push(d.final()), u.concat(p); - }(l = n.EncryptedPrivateKey.decode(l, "der"), e3); - case "PRIVATE KEY": - switch (r3 = (f2 = n.PrivateKey.decode(l, "der")).algorithm.algorithm.join(".")) { - case "1.2.840.113549.1.1.1": - return n.RSAPrivateKey.decode(f2.subjectPrivateKey, "der"); - case "1.2.840.10045.2.1": - return {curve: f2.algorithm.curve, privateKey: n.ECPrivateKey.decode(f2.subjectPrivateKey, "der").privateKey}; - case "1.2.840.10040.4.1": - return f2.algorithm.params.priv_key = n.DSAparam.decode(f2.subjectPrivateKey, "der"), {type: "dsa", params: f2.algorithm.params}; - default: - throw new Error("unknown key id " + r3); - } - case "RSA PUBLIC KEY": - return n.RSAPublicKey.decode(l, "der"); - case "RSA PRIVATE KEY": - return n.RSAPrivateKey.decode(l, "der"); - case "DSA PRIVATE KEY": - return {type: "dsa", params: n.DSAPrivateKey.decode(l, "der")}; - case "EC PRIVATE KEY": - return {curve: (l = n.ECPrivateKey.decode(l, "der")).parameters.value, privateKey: l.privateKey}; - default: - throw new Error("unknown key type " + h); - } - } - t2.exports = f, f.signature = n.signature; - }, 5632: (t2, e2, r2) => { - e2.pbkdf2 = r2(8638), e2.pbkdf2Sync = r2(1257); - }, 8638: (t2, e2, r2) => { - var n, i, o = r2(9509).Buffer, a = r2(7357), s = r2(2368), u = r2(1257), f = r2(7777), c = r2.g.crypto && r2.g.crypto.subtle, h = {sha: "SHA-1", "sha-1": "SHA-1", sha1: "SHA-1", sha256: "SHA-256", "sha-256": "SHA-256", sha384: "SHA-384", "sha-384": "SHA-384", "sha-512": "SHA-512", sha512: "SHA-512"}, l = []; - function d() { - return i || (i = r2.g.process && r2.g.process.nextTick ? r2.g.process.nextTick : r2.g.queueMicrotask ? r2.g.queueMicrotask : r2.g.setImmediate ? r2.g.setImmediate : r2.g.setTimeout); - } - function p(t3, e3, r3, n2, i2) { - return c.importKey("raw", t3, {name: "PBKDF2"}, false, ["deriveBits"]).then(function(t4) { - return c.deriveBits({name: "PBKDF2", salt: e3, iterations: r3, hash: {name: i2}}, t4, n2 << 3); - }).then(function(t4) { - return o.from(t4); - }); - } - t2.exports = function(t3, e3, i2, y, m, b) { - typeof m == "function" && (b = m, m = void 0); - var g = h[(m = m || "sha1").toLowerCase()]; - if (g && typeof r2.g.Promise == "function") { - if (a(i2, y), t3 = f(t3, s, "Password"), e3 = f(e3, s, "Salt"), typeof b != "function") - throw new Error("No callback provided to pbkdf2"); - !function(t4, e4) { - t4.then(function(t5) { - d()(function() { - e4(null, t5); - }); - }, function(t5) { - d()(function() { - e4(t5); - }); - }); - }(function(t4) { - if (r2.g.process && !r2.g.process.browser) - return Promise.resolve(false); - if (!c || !c.importKey || !c.deriveBits) - return Promise.resolve(false); - if (l[t4] !== void 0) - return l[t4]; - var e4 = p(n = n || o.alloc(8), n, 10, 128, t4).then(function() { - return true; - }).catch(function() { - return false; - }); - return l[t4] = e4, e4; - }(g).then(function(r3) { - return r3 ? p(t3, e3, i2, y, g) : u(t3, e3, i2, y, m); - }), b); - } else - d()(function() { - var r3; - try { - r3 = u(t3, e3, i2, y, m); - } catch (t4) { - return b(t4); - } - b(null, r3); - }); - }; - }, 2368: (t2, e2, r2) => { - var n, i = r2(4155); - n = r2.g.process && r2.g.process.browser ? "utf-8" : r2.g.process && r2.g.process.version ? parseInt(i.version.split(".")[0].slice(1), 10) >= 6 ? "utf-8" : "binary" : "utf-8", t2.exports = n; - }, 7357: (t2) => { - var e2 = Math.pow(2, 30) - 1; - t2.exports = function(t3, r2) { - if (typeof t3 != "number") - throw new TypeError("Iterations not a number"); - if (t3 < 0) - throw new TypeError("Bad iterations"); - if (typeof r2 != "number") - throw new TypeError("Key length not a number"); - if (r2 < 0 || r2 > e2 || r2 != r2) - throw new TypeError("Bad key length"); - }; - }, 1257: (t2, e2, r2) => { - var n = r2(8028), i = r2(9785), o = r2(9072), a = r2(9509).Buffer, s = r2(7357), u = r2(2368), f = r2(7777), c = a.alloc(128), h = {md5: 16, sha1: 20, sha224: 28, sha256: 32, sha384: 48, sha512: 64, rmd160: 20, ripemd160: 20}; - function l(t3, e3, r3) { - var s2 = function(t4) { - return t4 === "rmd160" || t4 === "ripemd160" ? function(t5) { - return new i().update(t5).digest(); - } : t4 === "md5" ? n : function(e4) { - return o(t4).update(e4).digest(); - }; - }(t3), u2 = t3 === "sha512" || t3 === "sha384" ? 128 : 64; - e3.length > u2 ? e3 = s2(e3) : e3.length < u2 && (e3 = a.concat([e3, c], u2)); - for (var f2 = a.allocUnsafe(u2 + h[t3]), l2 = a.allocUnsafe(u2 + h[t3]), d = 0; d < u2; d++) - f2[d] = 54 ^ e3[d], l2[d] = 92 ^ e3[d]; - var p = a.allocUnsafe(u2 + r3 + 4); - f2.copy(p, 0, 0, u2), this.ipad1 = p, this.ipad2 = f2, this.opad = l2, this.alg = t3, this.blocksize = u2, this.hash = s2, this.size = h[t3]; - } - l.prototype.run = function(t3, e3) { - return t3.copy(e3, this.blocksize), this.hash(e3).copy(this.opad, this.blocksize), this.hash(this.opad); - }, t2.exports = function(t3, e3, r3, n2, i2) { - s(r3, n2); - var o2 = new l(i2 = i2 || "sha1", t3 = f(t3, u, "Password"), (e3 = f(e3, u, "Salt")).length), c2 = a.allocUnsafe(n2), d = a.allocUnsafe(e3.length + 4); - e3.copy(d, 0, 0, e3.length); - for (var p = 0, y = h[i2], m = Math.ceil(n2 / y), b = 1; b <= m; b++) { - d.writeUInt32BE(b, e3.length); - for (var g = o2.run(d, o2.ipad1), v = g, w = 1; w < r3; w++) { - v = o2.run(v, o2.ipad2); - for (var _ = 0; _ < y; _++) - g[_] ^= v[_]; - } - g.copy(c2, p), p += y; - } - return c2; - }; - }, 7777: (t2, e2, r2) => { - var n = r2(9509).Buffer; - t2.exports = function(t3, e3, r3) { - if (n.isBuffer(t3)) - return t3; - if (typeof t3 == "string") - return n.from(t3, e3); - if (ArrayBuffer.isView(t3)) - return n.from(t3.buffer); - throw new TypeError(r3 + " must be a string, a Buffer, a typed array or a DataView"); - }; - }, 4155: (t2) => { - var e2, r2, n = t2.exports = {}; - function i() { - throw new Error("setTimeout has not been defined"); - } - function o() { - throw new Error("clearTimeout has not been defined"); - } - function a(t3) { - if (e2 === setTimeout) - return setTimeout(t3, 0); - if ((e2 === i || !e2) && setTimeout) - return e2 = setTimeout, setTimeout(t3, 0); - try { - return e2(t3, 0); - } catch (r3) { - try { - return e2.call(null, t3, 0); - } catch (r4) { - return e2.call(this, t3, 0); - } - } - } - !function() { - try { - e2 = typeof setTimeout == "function" ? setTimeout : i; - } catch (t3) { - e2 = i; - } - try { - r2 = typeof clearTimeout == "function" ? clearTimeout : o; - } catch (t3) { - r2 = o; - } - }(); - var s, u = [], f = false, c = -1; - function h() { - f && s && (f = false, s.length ? u = s.concat(u) : c = -1, u.length && l()); - } - function l() { - if (!f) { - var t3 = a(h); - f = true; - for (var e3 = u.length; e3; ) { - for (s = u, u = []; ++c < e3; ) - s && s[c].run(); - c = -1, e3 = u.length; - } - s = null, f = false, function(t4) { - if (r2 === clearTimeout) - return clearTimeout(t4); - if ((r2 === o || !r2) && clearTimeout) - return r2 = clearTimeout, clearTimeout(t4); - try { - r2(t4); - } catch (e4) { - try { - return r2.call(null, t4); - } catch (e5) { - return r2.call(this, t4); - } - } - }(t3); - } - } - function d(t3, e3) { - this.fun = t3, this.array = e3; - } - function p() { - } - n.nextTick = function(t3) { - var e3 = new Array(arguments.length - 1); - if (arguments.length > 1) - for (var r3 = 1; r3 < arguments.length; r3++) - e3[r3 - 1] = arguments[r3]; - u.push(new d(t3, e3)), u.length !== 1 || f || a(l); - }, d.prototype.run = function() { - this.fun.apply(null, this.array); - }, n.title = "browser", n.browser = true, n.env = {}, n.argv = [], n.version = "", n.versions = {}, n.on = p, n.addListener = p, n.once = p, n.off = p, n.removeListener = p, n.removeAllListeners = p, n.emit = p, n.prependListener = p, n.prependOnceListener = p, n.listeners = function(t3) { - return []; - }, n.binding = function(t3) { - throw new Error("process.binding is not supported"); - }, n.cwd = function() { - return "/"; - }, n.chdir = function(t3) { - throw new Error("process.chdir is not supported"); - }, n.umask = function() { - return 0; - }; - }, 7900: (t2, e2, r2) => { - e2.publicEncrypt = r2(6559), e2.privateDecrypt = r2(6138), e2.privateEncrypt = function(t3, r3) { - return e2.publicEncrypt(t3, r3, true); - }, e2.publicDecrypt = function(t3, r3) { - return e2.privateDecrypt(t3, r3, true); - }; - }, 9199: (t2, e2, r2) => { - var n = r2(3482), i = r2(9509).Buffer; - function o(t3) { - var e3 = i.allocUnsafe(4); - return e3.writeUInt32BE(t3, 0), e3; - } - t2.exports = function(t3, e3) { - for (var r3, a = i.alloc(0), s = 0; a.length < e3; ) - r3 = o(s++), a = i.concat([a, n("sha1").update(t3).update(r3).digest()]); - return a.slice(0, e3); - }; - }, 6138: (t2, e2, r2) => { - var n = r2(980), i = r2(9199), o = r2(7859), a = r2(3550), s = r2(3663), u = r2(3482), f = r2(4818), c = r2(9509).Buffer; - t2.exports = function(t3, e3, r3) { - var h; - h = t3.padding ? t3.padding : r3 ? 1 : 4; - var l, d = n(t3), p = d.modulus.byteLength(); - if (e3.length > p || new a(e3).cmp(d.modulus) >= 0) - throw new Error("decryption error"); - l = r3 ? f(new a(e3), d) : s(e3, d); - var y = c.alloc(p - l.length); - if (l = c.concat([y, l], p), h === 4) - return function(t4, e4) { - var r4 = t4.modulus.byteLength(), n2 = u("sha1").update(c.alloc(0)).digest(), a2 = n2.length; - if (e4[0] !== 0) - throw new Error("decryption error"); - var s2 = e4.slice(1, a2 + 1), f2 = e4.slice(a2 + 1), h2 = o(s2, i(f2, a2)), l2 = o(f2, i(h2, r4 - a2 - 1)); - if (function(t5, e5) { - t5 = c.from(t5), e5 = c.from(e5); - var r5 = 0, n3 = t5.length; - t5.length !== e5.length && (r5++, n3 = Math.min(t5.length, e5.length)); - for (var i2 = -1; ++i2 < n3; ) - r5 += t5[i2] ^ e5[i2]; - return r5; - }(n2, l2.slice(0, a2))) - throw new Error("decryption error"); - for (var d2 = a2; l2[d2] === 0; ) - d2++; - if (l2[d2++] !== 1) - throw new Error("decryption error"); - return l2.slice(d2); - }(d, l); - if (h === 1) - return function(t4, e4, r4) { - for (var n2 = e4.slice(0, 2), i2 = 2, o2 = 0; e4[i2++] !== 0; ) - if (i2 >= e4.length) { - o2++; - break; - } - var a2 = e4.slice(2, i2 - 1); - if ((n2.toString("hex") !== "0002" && !r4 || n2.toString("hex") !== "0001" && r4) && o2++, a2.length < 8 && o2++, o2) - throw new Error("decryption error"); - return e4.slice(i2); - }(0, l, r3); - if (h === 3) - return l; - throw new Error("unknown padding"); - }; - }, 6559: (t2, e2, r2) => { - var n = r2(980), i = r2(1798), o = r2(3482), a = r2(9199), s = r2(7859), u = r2(3550), f = r2(4818), c = r2(3663), h = r2(9509).Buffer; - t2.exports = function(t3, e3, r3) { - var l; - l = t3.padding ? t3.padding : r3 ? 1 : 4; - var d, p = n(t3); - if (l === 4) - d = function(t4, e4) { - var r4 = t4.modulus.byteLength(), n2 = e4.length, f2 = o("sha1").update(h.alloc(0)).digest(), c2 = f2.length, l2 = 2 * c2; - if (n2 > r4 - l2 - 2) - throw new Error("message too long"); - var d2 = h.alloc(r4 - n2 - l2 - 2), p2 = r4 - c2 - 1, y = i(c2), m = s(h.concat([f2, d2, h.alloc(1, 1), e4], p2), a(y, p2)), b = s(y, a(m, c2)); - return new u(h.concat([h.alloc(1), b, m], r4)); - }(p, e3); - else if (l === 1) - d = function(t4, e4, r4) { - var n2, o2 = e4.length, a2 = t4.modulus.byteLength(); - if (o2 > a2 - 11) - throw new Error("message too long"); - return n2 = r4 ? h.alloc(a2 - o2 - 3, 255) : function(t5) { - for (var e5, r5 = h.allocUnsafe(t5), n3 = 0, o3 = i(2 * t5), a3 = 0; n3 < t5; ) - a3 === o3.length && (o3 = i(2 * t5), a3 = 0), (e5 = o3[a3++]) && (r5[n3++] = e5); - return r5; - }(a2 - o2 - 3), new u(h.concat([h.from([0, r4 ? 1 : 2]), n2, h.alloc(1), e4], a2)); - }(p, e3, r3); - else { - if (l !== 3) - throw new Error("unknown padding"); - if ((d = new u(e3)).cmp(p.modulus) >= 0) - throw new Error("data too long for modulus"); - } - return r3 ? c(d, p) : f(d, p); - }; - }, 4818: (t2, e2, r2) => { - var n = r2(3550), i = r2(9509).Buffer; - t2.exports = function(t3, e3) { - return i.from(t3.toRed(n.mont(e3.modulus)).redPow(new n(e3.publicExponent)).fromRed().toArray()); - }; - }, 7859: (t2) => { - t2.exports = function(t3, e2) { - for (var r2 = t3.length, n = -1; ++n < r2; ) - t3[n] ^= e2[n]; - return t3; - }; - }, 1798: (t2, e2, r2) => { - var n = r2(4155), i = 65536, o = r2(9509).Buffer, a = r2.g.crypto || r2.g.msCrypto; - a && a.getRandomValues ? t2.exports = function(t3, e3) { - if (t3 > 4294967295) - throw new RangeError("requested too many random bytes"); - var r3 = o.allocUnsafe(t3); - if (t3 > 0) - if (t3 > i) - for (var s = 0; s < t3; s += i) - a.getRandomValues(r3.slice(s, s + i)); - else - a.getRandomValues(r3); - return typeof e3 == "function" ? n.nextTick(function() { - e3(null, r3); - }) : r3; - } : t2.exports = function() { - throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"); - }; - }, 7963: (t2, e2, r2) => { - var n = r2(4155); - function i() { - throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11"); - } - var o = r2(9509), a = r2(1798), s = o.Buffer, u = o.kMaxLength, f = r2.g.crypto || r2.g.msCrypto, c = Math.pow(2, 32) - 1; - function h(t3, e3) { - if (typeof t3 != "number" || t3 != t3) - throw new TypeError("offset must be a number"); - if (t3 > c || t3 < 0) - throw new TypeError("offset must be a uint32"); - if (t3 > u || t3 > e3) - throw new RangeError("offset out of range"); - } - function l(t3, e3, r3) { - if (typeof t3 != "number" || t3 != t3) - throw new TypeError("size must be a number"); - if (t3 > c || t3 < 0) - throw new TypeError("size must be a uint32"); - if (t3 + e3 > r3 || t3 > u) - throw new RangeError("buffer too small"); - } - function d(t3, e3, r3, i2) { - if (n.browser) { - var o2 = t3.buffer, s2 = new Uint8Array(o2, e3, r3); - return f.getRandomValues(s2), i2 ? void n.nextTick(function() { - i2(null, t3); - }) : t3; - } - if (!i2) - return a(r3).copy(t3, e3), t3; - a(r3, function(r4, n2) { - if (r4) - return i2(r4); - n2.copy(t3, e3), i2(null, t3); - }); - } - f && f.getRandomValues || !n.browser ? (e2.randomFill = function(t3, e3, n2, i2) { - if (!(s.isBuffer(t3) || t3 instanceof r2.g.Uint8Array)) - throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); - if (typeof e3 == "function") - i2 = e3, e3 = 0, n2 = t3.length; - else if (typeof n2 == "function") - i2 = n2, n2 = t3.length - e3; - else if (typeof i2 != "function") - throw new TypeError('"cb" argument must be a function'); - return h(e3, t3.length), l(n2, e3, t3.length), d(t3, e3, n2, i2); - }, e2.randomFillSync = function(t3, e3, n2) { - if (e3 === void 0 && (e3 = 0), !(s.isBuffer(t3) || t3 instanceof r2.g.Uint8Array)) - throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); - return h(e3, t3.length), n2 === void 0 && (n2 = t3.length - e3), l(n2, e3, t3.length), d(t3, e3, n2); - }) : (e2.randomFill = i, e2.randomFillSync = i); - }, 4281: (t2) => { - var e2 = {}; - function r2(t3, r3, n2) { - n2 || (n2 = Error); - var i = function(t4) { - var e3, n3; - function i2(e4, n4, i3) { - return t4.call(this, function(t5, e5, n5) { - return typeof r3 == "string" ? r3 : r3(t5, e5, n5); - }(e4, n4, i3)) || this; - } - return n3 = t4, (e3 = i2).prototype = Object.create(n3.prototype), e3.prototype.constructor = e3, e3.__proto__ = n3, i2; - }(n2); - i.prototype.name = n2.name, i.prototype.code = t3, e2[t3] = i; - } - function n(t3, e3) { - if (Array.isArray(t3)) { - var r3 = t3.length; - return t3 = t3.map(function(t4) { - return String(t4); - }), r3 > 2 ? "one of ".concat(e3, " ").concat(t3.slice(0, r3 - 1).join(", "), ", or ") + t3[r3 - 1] : r3 === 2 ? "one of ".concat(e3, " ").concat(t3[0], " or ").concat(t3[1]) : "of ".concat(e3, " ").concat(t3[0]); - } - return "of ".concat(e3, " ").concat(String(t3)); - } - r2("ERR_INVALID_OPT_VALUE", function(t3, e3) { - return 'The value "' + e3 + '" is invalid for option "' + t3 + '"'; - }, TypeError), r2("ERR_INVALID_ARG_TYPE", function(t3, e3, r3) { - var i, o, a, s, u; - if (typeof e3 == "string" && (o = "not ", e3.substr(0, o.length) === o) ? (i = "must not be", e3 = e3.replace(/^not /, "")) : i = "must be", function(t4, e4, r4) { - return (r4 === void 0 || r4 > t4.length) && (r4 = t4.length), t4.substring(r4 - e4.length, r4) === e4; - }(t3, " argument")) - a = "The ".concat(t3, " ").concat(i, " ").concat(n(e3, "type")); - else { - var f = (typeof u != "number" && (u = 0), u + ".".length > (s = t3).length || s.indexOf(".", u) === -1 ? "argument" : "property"); - a = 'The "'.concat(t3, '" ').concat(f, " ").concat(i, " ").concat(n(e3, "type")); - } - return a + ". Received type ".concat(typeof r3); - }, TypeError), r2("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"), r2("ERR_METHOD_NOT_IMPLEMENTED", function(t3) { - return "The " + t3 + " method is not implemented"; - }), r2("ERR_STREAM_PREMATURE_CLOSE", "Premature close"), r2("ERR_STREAM_DESTROYED", function(t3) { - return "Cannot call " + t3 + " after a stream was destroyed"; - }), r2("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"), r2("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"), r2("ERR_STREAM_WRITE_AFTER_END", "write after end"), r2("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError), r2("ERR_UNKNOWN_ENCODING", function(t3) { - return "Unknown encoding: " + t3; - }, TypeError), r2("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"), t2.exports.q = e2; - }, 6753: (t2, e2, r2) => { - var n = r2(4155), i = Object.keys || function(t3) { - var e3 = []; - for (var r3 in t3) - e3.push(r3); - return e3; - }; - t2.exports = c; - var o = r2(9481), a = r2(4229); - r2(5717)(c, o); - for (var s = i(a.prototype), u = 0; u < s.length; u++) { - var f = s[u]; - c.prototype[f] || (c.prototype[f] = a.prototype[f]); - } - function c(t3) { - if (!(this instanceof c)) - return new c(t3); - o.call(this, t3), a.call(this, t3), this.allowHalfOpen = true, t3 && (t3.readable === false && (this.readable = false), t3.writable === false && (this.writable = false), t3.allowHalfOpen === false && (this.allowHalfOpen = false, this.once("end", h))); - } - function h() { - this._writableState.ended || n.nextTick(l, this); - } - function l(t3) { - t3.end(); - } - Object.defineProperty(c.prototype, "writableHighWaterMark", {enumerable: false, get: function() { - return this._writableState.highWaterMark; - }}), Object.defineProperty(c.prototype, "writableBuffer", {enumerable: false, get: function() { - return this._writableState && this._writableState.getBuffer(); - }}), Object.defineProperty(c.prototype, "writableLength", {enumerable: false, get: function() { - return this._writableState.length; - }}), Object.defineProperty(c.prototype, "destroyed", {enumerable: false, get: function() { - return this._readableState !== void 0 && this._writableState !== void 0 && this._readableState.destroyed && this._writableState.destroyed; - }, set: function(t3) { - this._readableState !== void 0 && this._writableState !== void 0 && (this._readableState.destroyed = t3, this._writableState.destroyed = t3); - }}); - }, 2725: (t2, e2, r2) => { - t2.exports = i; - var n = r2(4605); - function i(t3) { - if (!(this instanceof i)) - return new i(t3); - n.call(this, t3); - } - r2(5717)(i, n), i.prototype._transform = function(t3, e3, r3) { - r3(null, t3); - }; - }, 9481: (t2, e2, r2) => { - var n, i = r2(4155); - t2.exports = A, A.ReadableState = E, r2(7187).EventEmitter; - var o, a = function(t3, e3) { - return t3.listeners(e3).length; - }, s = r2(2503), u = r2(8764).Buffer, f = r2.g.Uint8Array || function() { - }, c = r2(4616); - o = c && c.debuglog ? c.debuglog("stream") : function() { - }; - var h, l, d, p = r2(7327), y = r2(1195), m = r2(2457).getHighWaterMark, b = r2(4281).q, g = b.ERR_INVALID_ARG_TYPE, v = b.ERR_STREAM_PUSH_AFTER_EOF, w = b.ERR_METHOD_NOT_IMPLEMENTED, _ = b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; - r2(5717)(A, s); - var M = y.errorOrDestroy, S = ["error", "close", "destroy", "pause", "resume"]; - function E(t3, e3, i2) { - n = n || r2(6753), t3 = t3 || {}, typeof i2 != "boolean" && (i2 = e3 instanceof n), this.objectMode = !!t3.objectMode, i2 && (this.objectMode = this.objectMode || !!t3.readableObjectMode), this.highWaterMark = m(this, t3, "readableHighWaterMark", i2), this.buffer = new p(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = false, this.endEmitted = false, this.reading = false, this.sync = true, this.needReadable = false, this.emittedReadable = false, this.readableListening = false, this.resumeScheduled = false, this.paused = true, this.emitClose = t3.emitClose !== false, this.autoDestroy = !!t3.autoDestroy, this.destroyed = false, this.defaultEncoding = t3.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = false, this.decoder = null, this.encoding = null, t3.encoding && (h || (h = r2(2553).s), this.decoder = new h(t3.encoding), this.encoding = t3.encoding); - } - function A(t3) { - if (n = n || r2(6753), !(this instanceof A)) - return new A(t3); - var e3 = this instanceof n; - this._readableState = new E(t3, this, e3), this.readable = true, t3 && (typeof t3.read == "function" && (this._read = t3.read), typeof t3.destroy == "function" && (this._destroy = t3.destroy)), s.call(this); - } - function k(t3, e3, r3, n2, i2) { - o("readableAddChunk", e3); - var a2, s2 = t3._readableState; - if (e3 === null) - s2.reading = false, function(t4, e4) { - if (o("onEofChunk"), !e4.ended) { - if (e4.decoder) { - var r4 = e4.decoder.end(); - r4 && r4.length && (e4.buffer.push(r4), e4.length += e4.objectMode ? 1 : r4.length); - } - e4.ended = true, e4.sync ? O(t4) : (e4.needReadable = false, e4.emittedReadable || (e4.emittedReadable = true, R(t4))); - } - }(t3, s2); - else if (i2 || (a2 = function(t4, e4) { - var r4, n3; - return n3 = e4, u.isBuffer(n3) || n3 instanceof f || typeof e4 == "string" || e4 === void 0 || t4.objectMode || (r4 = new g("chunk", ["string", "Buffer", "Uint8Array"], e4)), r4; - }(s2, e3)), a2) - M(t3, a2); - else if (s2.objectMode || e3 && e3.length > 0) - if (typeof e3 == "string" || s2.objectMode || Object.getPrototypeOf(e3) === u.prototype || (e3 = function(t4) { - return u.from(t4); - }(e3)), n2) - s2.endEmitted ? M(t3, new _()) : B(t3, s2, e3, true); - else if (s2.ended) - M(t3, new v()); - else { - if (s2.destroyed) - return false; - s2.reading = false, s2.decoder && !r3 ? (e3 = s2.decoder.write(e3), s2.objectMode || e3.length !== 0 ? B(t3, s2, e3, false) : P(t3, s2)) : B(t3, s2, e3, false); - } - else - n2 || (s2.reading = false, P(t3, s2)); - return !s2.ended && (s2.length < s2.highWaterMark || s2.length === 0); - } - function B(t3, e3, r3, n2) { - e3.flowing && e3.length === 0 && !e3.sync ? (e3.awaitDrain = 0, t3.emit("data", r3)) : (e3.length += e3.objectMode ? 1 : r3.length, n2 ? e3.buffer.unshift(r3) : e3.buffer.push(r3), e3.needReadable && O(t3)), P(t3, e3); - } - Object.defineProperty(A.prototype, "destroyed", {enumerable: false, get: function() { - return this._readableState !== void 0 && this._readableState.destroyed; - }, set: function(t3) { - this._readableState && (this._readableState.destroyed = t3); - }}), A.prototype.destroy = y.destroy, A.prototype._undestroy = y.undestroy, A.prototype._destroy = function(t3, e3) { - e3(t3); - }, A.prototype.push = function(t3, e3) { - var r3, n2 = this._readableState; - return n2.objectMode ? r3 = true : typeof t3 == "string" && ((e3 = e3 || n2.defaultEncoding) !== n2.encoding && (t3 = u.from(t3, e3), e3 = ""), r3 = true), k(this, t3, e3, false, r3); - }, A.prototype.unshift = function(t3) { - return k(this, t3, null, true, false); - }, A.prototype.isPaused = function() { - return this._readableState.flowing === false; - }, A.prototype.setEncoding = function(t3) { - h || (h = r2(2553).s); - var e3 = new h(t3); - this._readableState.decoder = e3, this._readableState.encoding = this._readableState.decoder.encoding; - for (var n2 = this._readableState.buffer.head, i2 = ""; n2 !== null; ) - i2 += e3.write(n2.data), n2 = n2.next; - return this._readableState.buffer.clear(), i2 !== "" && this._readableState.buffer.push(i2), this._readableState.length = i2.length, this; - }; - var T = 1073741824; - function x(t3, e3) { - return t3 <= 0 || e3.length === 0 && e3.ended ? 0 : e3.objectMode ? 1 : t3 != t3 ? e3.flowing && e3.length ? e3.buffer.head.data.length : e3.length : (t3 > e3.highWaterMark && (e3.highWaterMark = function(t4) { - return t4 >= T ? t4 = T : (t4--, t4 |= t4 >>> 1, t4 |= t4 >>> 2, t4 |= t4 >>> 4, t4 |= t4 >>> 8, t4 |= t4 >>> 16, t4++), t4; - }(t3)), t3 <= e3.length ? t3 : e3.ended ? e3.length : (e3.needReadable = true, 0)); - } - function O(t3) { - var e3 = t3._readableState; - o("emitReadable", e3.needReadable, e3.emittedReadable), e3.needReadable = false, e3.emittedReadable || (o("emitReadable", e3.flowing), e3.emittedReadable = true, i.nextTick(R, t3)); - } - function R(t3) { - var e3 = t3._readableState; - o("emitReadable_", e3.destroyed, e3.length, e3.ended), e3.destroyed || !e3.length && !e3.ended || (t3.emit("readable"), e3.emittedReadable = false), e3.needReadable = !e3.flowing && !e3.ended && e3.length <= e3.highWaterMark, C(t3); - } - function P(t3, e3) { - e3.readingMore || (e3.readingMore = true, i.nextTick(I, t3, e3)); - } - function I(t3, e3) { - for (; !e3.reading && !e3.ended && (e3.length < e3.highWaterMark || e3.flowing && e3.length === 0); ) { - var r3 = e3.length; - if (o("maybeReadMore read 0"), t3.read(0), r3 === e3.length) - break; - } - e3.readingMore = false; - } - function j(t3) { - var e3 = t3._readableState; - e3.readableListening = t3.listenerCount("readable") > 0, e3.resumeScheduled && !e3.paused ? e3.flowing = true : t3.listenerCount("data") > 0 && t3.resume(); - } - function U(t3) { - o("readable nexttick read 0"), t3.read(0); - } - function N(t3, e3) { - o("resume", e3.reading), e3.reading || t3.read(0), e3.resumeScheduled = false, t3.emit("resume"), C(t3), e3.flowing && !e3.reading && t3.read(0); - } - function C(t3) { - var e3 = t3._readableState; - for (o("flow", e3.flowing); e3.flowing && t3.read() !== null; ) - ; - } - function D(t3, e3) { - return e3.length === 0 ? null : (e3.objectMode ? r3 = e3.buffer.shift() : !t3 || t3 >= e3.length ? (r3 = e3.decoder ? e3.buffer.join("") : e3.buffer.length === 1 ? e3.buffer.first() : e3.buffer.concat(e3.length), e3.buffer.clear()) : r3 = e3.buffer.consume(t3, e3.decoder), r3); - var r3; - } - function L(t3) { - var e3 = t3._readableState; - o("endReadable", e3.endEmitted), e3.endEmitted || (e3.ended = true, i.nextTick(K, e3, t3)); - } - function K(t3, e3) { - if (o("endReadableNT", t3.endEmitted, t3.length), !t3.endEmitted && t3.length === 0 && (t3.endEmitted = true, e3.readable = false, e3.emit("end"), t3.autoDestroy)) { - var r3 = e3._writableState; - (!r3 || r3.autoDestroy && r3.finished) && e3.destroy(); - } - } - function z(t3, e3) { - for (var r3 = 0, n2 = t3.length; r3 < n2; r3++) - if (t3[r3] === e3) - return r3; - return -1; - } - A.prototype.read = function(t3) { - o("read", t3), t3 = parseInt(t3, 10); - var e3 = this._readableState, r3 = t3; - if (t3 !== 0 && (e3.emittedReadable = false), t3 === 0 && e3.needReadable && ((e3.highWaterMark !== 0 ? e3.length >= e3.highWaterMark : e3.length > 0) || e3.ended)) - return o("read: emitReadable", e3.length, e3.ended), e3.length === 0 && e3.ended ? L(this) : O(this), null; - if ((t3 = x(t3, e3)) === 0 && e3.ended) - return e3.length === 0 && L(this), null; - var n2, i2 = e3.needReadable; - return o("need readable", i2), (e3.length === 0 || e3.length - t3 < e3.highWaterMark) && o("length less than watermark", i2 = true), e3.ended || e3.reading ? o("reading or ended", i2 = false) : i2 && (o("do read"), e3.reading = true, e3.sync = true, e3.length === 0 && (e3.needReadable = true), this._read(e3.highWaterMark), e3.sync = false, e3.reading || (t3 = x(r3, e3))), (n2 = t3 > 0 ? D(t3, e3) : null) === null ? (e3.needReadable = e3.length <= e3.highWaterMark, t3 = 0) : (e3.length -= t3, e3.awaitDrain = 0), e3.length === 0 && (e3.ended || (e3.needReadable = true), r3 !== t3 && e3.ended && L(this)), n2 !== null && this.emit("data", n2), n2; - }, A.prototype._read = function(t3) { - M(this, new w("_read()")); - }, A.prototype.pipe = function(t3, e3) { - var r3 = this, n2 = this._readableState; - switch (n2.pipesCount) { - case 0: - n2.pipes = t3; - break; - case 1: - n2.pipes = [n2.pipes, t3]; - break; - default: - n2.pipes.push(t3); - } - n2.pipesCount += 1, o("pipe count=%d opts=%j", n2.pipesCount, e3); - var s2 = e3 && e3.end === false || t3 === i.stdout || t3 === i.stderr ? y2 : u2; - function u2() { - o("onend"), t3.end(); - } - n2.endEmitted ? i.nextTick(s2) : r3.once("end", s2), t3.on("unpipe", function e4(i2, a2) { - o("onunpipe"), i2 === r3 && a2 && a2.hasUnpiped === false && (a2.hasUnpiped = true, o("cleanup"), t3.removeListener("close", d2), t3.removeListener("finish", p2), t3.removeListener("drain", f2), t3.removeListener("error", l2), t3.removeListener("unpipe", e4), r3.removeListener("end", u2), r3.removeListener("end", y2), r3.removeListener("data", h2), c2 = true, !n2.awaitDrain || t3._writableState && !t3._writableState.needDrain || f2()); - }); - var f2 = function(t4) { - return function() { - var e4 = t4._readableState; - o("pipeOnDrain", e4.awaitDrain), e4.awaitDrain && e4.awaitDrain--, e4.awaitDrain === 0 && a(t4, "data") && (e4.flowing = true, C(t4)); - }; - }(r3); - t3.on("drain", f2); - var c2 = false; - function h2(e4) { - o("ondata"); - var i2 = t3.write(e4); - o("dest.write", i2), i2 === false && ((n2.pipesCount === 1 && n2.pipes === t3 || n2.pipesCount > 1 && z(n2.pipes, t3) !== -1) && !c2 && (o("false write response, pause", n2.awaitDrain), n2.awaitDrain++), r3.pause()); - } - function l2(e4) { - o("onerror", e4), y2(), t3.removeListener("error", l2), a(t3, "error") === 0 && M(t3, e4); - } - function d2() { - t3.removeListener("finish", p2), y2(); - } - function p2() { - o("onfinish"), t3.removeListener("close", d2), y2(); - } - function y2() { - o("unpipe"), r3.unpipe(t3); - } - return r3.on("data", h2), function(t4, e4, r4) { - if (typeof t4.prependListener == "function") - return t4.prependListener(e4, r4); - t4._events && t4._events.error ? Array.isArray(t4._events.error) ? t4._events.error.unshift(r4) : t4._events.error = [r4, t4._events.error] : t4.on(e4, r4); - }(t3, "error", l2), t3.once("close", d2), t3.once("finish", p2), t3.emit("pipe", r3), n2.flowing || (o("pipe resume"), r3.resume()), t3; - }, A.prototype.unpipe = function(t3) { - var e3 = this._readableState, r3 = {hasUnpiped: false}; - if (e3.pipesCount === 0) - return this; - if (e3.pipesCount === 1) - return t3 && t3 !== e3.pipes || (t3 || (t3 = e3.pipes), e3.pipes = null, e3.pipesCount = 0, e3.flowing = false, t3 && t3.emit("unpipe", this, r3)), this; - if (!t3) { - var n2 = e3.pipes, i2 = e3.pipesCount; - e3.pipes = null, e3.pipesCount = 0, e3.flowing = false; - for (var o2 = 0; o2 < i2; o2++) - n2[o2].emit("unpipe", this, {hasUnpiped: false}); - return this; - } - var a2 = z(e3.pipes, t3); - return a2 === -1 || (e3.pipes.splice(a2, 1), e3.pipesCount -= 1, e3.pipesCount === 1 && (e3.pipes = e3.pipes[0]), t3.emit("unpipe", this, r3)), this; - }, A.prototype.on = function(t3, e3) { - var r3 = s.prototype.on.call(this, t3, e3), n2 = this._readableState; - return t3 === "data" ? (n2.readableListening = this.listenerCount("readable") > 0, n2.flowing !== false && this.resume()) : t3 === "readable" && (n2.endEmitted || n2.readableListening || (n2.readableListening = n2.needReadable = true, n2.flowing = false, n2.emittedReadable = false, o("on readable", n2.length, n2.reading), n2.length ? O(this) : n2.reading || i.nextTick(U, this))), r3; - }, A.prototype.addListener = A.prototype.on, A.prototype.removeListener = function(t3, e3) { - var r3 = s.prototype.removeListener.call(this, t3, e3); - return t3 === "readable" && i.nextTick(j, this), r3; - }, A.prototype.removeAllListeners = function(t3) { - var e3 = s.prototype.removeAllListeners.apply(this, arguments); - return t3 !== "readable" && t3 !== void 0 || i.nextTick(j, this), e3; - }, A.prototype.resume = function() { - var t3 = this._readableState; - return t3.flowing || (o("resume"), t3.flowing = !t3.readableListening, function(t4, e3) { - e3.resumeScheduled || (e3.resumeScheduled = true, i.nextTick(N, t4, e3)); - }(this, t3)), t3.paused = false, this; - }, A.prototype.pause = function() { - return o("call pause flowing=%j", this._readableState.flowing), this._readableState.flowing !== false && (o("pause"), this._readableState.flowing = false, this.emit("pause")), this._readableState.paused = true, this; - }, A.prototype.wrap = function(t3) { - var e3 = this, r3 = this._readableState, n2 = false; - for (var i2 in t3.on("end", function() { - if (o("wrapped end"), r3.decoder && !r3.ended) { - var t4 = r3.decoder.end(); - t4 && t4.length && e3.push(t4); - } - e3.push(null); - }), t3.on("data", function(i3) { - o("wrapped data"), r3.decoder && (i3 = r3.decoder.write(i3)), r3.objectMode && i3 == null || (r3.objectMode || i3 && i3.length) && (e3.push(i3) || (n2 = true, t3.pause())); - }), t3) - this[i2] === void 0 && typeof t3[i2] == "function" && (this[i2] = function(e4) { - return function() { - return t3[e4].apply(t3, arguments); - }; - }(i2)); - for (var a2 = 0; a2 < S.length; a2++) - t3.on(S[a2], this.emit.bind(this, S[a2])); - return this._read = function(e4) { - o("wrapped _read", e4), n2 && (n2 = false, t3.resume()); - }, this; - }, typeof Symbol == "function" && (A.prototype[Symbol.asyncIterator] = function() { - return l === void 0 && (l = r2(5850)), l(this); - }), Object.defineProperty(A.prototype, "readableHighWaterMark", {enumerable: false, get: function() { - return this._readableState.highWaterMark; - }}), Object.defineProperty(A.prototype, "readableBuffer", {enumerable: false, get: function() { - return this._readableState && this._readableState.buffer; - }}), Object.defineProperty(A.prototype, "readableFlowing", {enumerable: false, get: function() { - return this._readableState.flowing; - }, set: function(t3) { - this._readableState && (this._readableState.flowing = t3); - }}), A._fromList = D, Object.defineProperty(A.prototype, "readableLength", {enumerable: false, get: function() { - return this._readableState.length; - }}), typeof Symbol == "function" && (A.from = function(t3, e3) { - return d === void 0 && (d = r2(5167)), d(A, t3, e3); - }); - }, 4605: (t2, e2, r2) => { - t2.exports = c; - var n = r2(4281).q, i = n.ERR_METHOD_NOT_IMPLEMENTED, o = n.ERR_MULTIPLE_CALLBACK, a = n.ERR_TRANSFORM_ALREADY_TRANSFORMING, s = n.ERR_TRANSFORM_WITH_LENGTH_0, u = r2(6753); - function f(t3, e3) { - var r3 = this._transformState; - r3.transforming = false; - var n2 = r3.writecb; - if (n2 === null) - return this.emit("error", new o()); - r3.writechunk = null, r3.writecb = null, e3 != null && this.push(e3), n2(t3); - var i2 = this._readableState; - i2.reading = false, (i2.needReadable || i2.length < i2.highWaterMark) && this._read(i2.highWaterMark); - } - function c(t3) { - if (!(this instanceof c)) - return new c(t3); - u.call(this, t3), this._transformState = {afterTransform: f.bind(this), needTransform: false, transforming: false, writecb: null, writechunk: null, writeencoding: null}, this._readableState.needReadable = true, this._readableState.sync = false, t3 && (typeof t3.transform == "function" && (this._transform = t3.transform), typeof t3.flush == "function" && (this._flush = t3.flush)), this.on("prefinish", h); - } - function h() { - var t3 = this; - typeof this._flush != "function" || this._readableState.destroyed ? l(this, null, null) : this._flush(function(e3, r3) { - l(t3, e3, r3); - }); - } - function l(t3, e3, r3) { - if (e3) - return t3.emit("error", e3); - if (r3 != null && t3.push(r3), t3._writableState.length) - throw new s(); - if (t3._transformState.transforming) - throw new a(); - return t3.push(null); - } - r2(5717)(c, u), c.prototype.push = function(t3, e3) { - return this._transformState.needTransform = false, u.prototype.push.call(this, t3, e3); - }, c.prototype._transform = function(t3, e3, r3) { - r3(new i("_transform()")); - }, c.prototype._write = function(t3, e3, r3) { - var n2 = this._transformState; - if (n2.writecb = r3, n2.writechunk = t3, n2.writeencoding = e3, !n2.transforming) { - var i2 = this._readableState; - (n2.needTransform || i2.needReadable || i2.length < i2.highWaterMark) && this._read(i2.highWaterMark); - } - }, c.prototype._read = function(t3) { - var e3 = this._transformState; - e3.writechunk === null || e3.transforming ? e3.needTransform = true : (e3.transforming = true, this._transform(e3.writechunk, e3.writeencoding, e3.afterTransform)); - }, c.prototype._destroy = function(t3, e3) { - u.prototype._destroy.call(this, t3, function(t4) { - e3(t4); - }); - }; - }, 4229: (t2, e2, r2) => { - var n, i = r2(4155); - function o(t3) { - var e3 = this; - this.next = null, this.entry = null, this.finish = function() { - !function(t4, e4, r3) { - var n2 = t4.entry; - for (t4.entry = null; n2; ) { - var i2 = n2.callback; - e4.pendingcb--, i2(void 0), n2 = n2.next; - } - e4.corkedRequestsFree.next = t4; - }(e3, t3); - }; - } - t2.exports = A, A.WritableState = E; - var a, s = {deprecate: r2(7781)}, u = r2(2503), f = r2(8764).Buffer, c = r2.g.Uint8Array || function() { - }, h = r2(1195), l = r2(2457).getHighWaterMark, d = r2(4281).q, p = d.ERR_INVALID_ARG_TYPE, y = d.ERR_METHOD_NOT_IMPLEMENTED, m = d.ERR_MULTIPLE_CALLBACK, b = d.ERR_STREAM_CANNOT_PIPE, g = d.ERR_STREAM_DESTROYED, v = d.ERR_STREAM_NULL_VALUES, w = d.ERR_STREAM_WRITE_AFTER_END, _ = d.ERR_UNKNOWN_ENCODING, M = h.errorOrDestroy; - function S() { - } - function E(t3, e3, a2) { - n = n || r2(6753), t3 = t3 || {}, typeof a2 != "boolean" && (a2 = e3 instanceof n), this.objectMode = !!t3.objectMode, a2 && (this.objectMode = this.objectMode || !!t3.writableObjectMode), this.highWaterMark = l(this, t3, "writableHighWaterMark", a2), this.finalCalled = false, this.needDrain = false, this.ending = false, this.ended = false, this.finished = false, this.destroyed = false; - var s2 = t3.decodeStrings === false; - this.decodeStrings = !s2, this.defaultEncoding = t3.defaultEncoding || "utf8", this.length = 0, this.writing = false, this.corked = 0, this.sync = true, this.bufferProcessing = false, this.onwrite = function(t4) { - !function(t5, e4) { - var r3 = t5._writableState, n2 = r3.sync, o2 = r3.writecb; - if (typeof o2 != "function") - throw new m(); - if (function(t6) { - t6.writing = false, t6.writecb = null, t6.length -= t6.writelen, t6.writelen = 0; - }(r3), e4) - !function(t6, e5, r4, n3, o3) { - --e5.pendingcb, r4 ? (i.nextTick(o3, n3), i.nextTick(R, t6, e5), t6._writableState.errorEmitted = true, M(t6, n3)) : (o3(n3), t6._writableState.errorEmitted = true, M(t6, n3), R(t6, e5)); - }(t5, r3, n2, e4, o2); - else { - var a3 = x(r3) || t5.destroyed; - a3 || r3.corked || r3.bufferProcessing || !r3.bufferedRequest || T(t5, r3), n2 ? i.nextTick(B, t5, r3, a3, o2) : B(t5, r3, a3, o2); - } - }(e3, t4); - }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = false, this.errorEmitted = false, this.emitClose = t3.emitClose !== false, this.autoDestroy = !!t3.autoDestroy, this.bufferedRequestCount = 0, this.corkedRequestsFree = new o(this); - } - function A(t3) { - var e3 = this instanceof (n = n || r2(6753)); - if (!e3 && !a.call(A, this)) - return new A(t3); - this._writableState = new E(t3, this, e3), this.writable = true, t3 && (typeof t3.write == "function" && (this._write = t3.write), typeof t3.writev == "function" && (this._writev = t3.writev), typeof t3.destroy == "function" && (this._destroy = t3.destroy), typeof t3.final == "function" && (this._final = t3.final)), u.call(this); - } - function k(t3, e3, r3, n2, i2, o2, a2) { - e3.writelen = n2, e3.writecb = a2, e3.writing = true, e3.sync = true, e3.destroyed ? e3.onwrite(new g("write")) : r3 ? t3._writev(i2, e3.onwrite) : t3._write(i2, o2, e3.onwrite), e3.sync = false; - } - function B(t3, e3, r3, n2) { - r3 || function(t4, e4) { - e4.length === 0 && e4.needDrain && (e4.needDrain = false, t4.emit("drain")); - }(t3, e3), e3.pendingcb--, n2(), R(t3, e3); - } - function T(t3, e3) { - e3.bufferProcessing = true; - var r3 = e3.bufferedRequest; - if (t3._writev && r3 && r3.next) { - var n2 = e3.bufferedRequestCount, i2 = new Array(n2), a2 = e3.corkedRequestsFree; - a2.entry = r3; - for (var s2 = 0, u2 = true; r3; ) - i2[s2] = r3, r3.isBuf || (u2 = false), r3 = r3.next, s2 += 1; - i2.allBuffers = u2, k(t3, e3, true, e3.length, i2, "", a2.finish), e3.pendingcb++, e3.lastBufferedRequest = null, a2.next ? (e3.corkedRequestsFree = a2.next, a2.next = null) : e3.corkedRequestsFree = new o(e3), e3.bufferedRequestCount = 0; - } else { - for (; r3; ) { - var f2 = r3.chunk, c2 = r3.encoding, h2 = r3.callback; - if (k(t3, e3, false, e3.objectMode ? 1 : f2.length, f2, c2, h2), r3 = r3.next, e3.bufferedRequestCount--, e3.writing) - break; - } - r3 === null && (e3.lastBufferedRequest = null); - } - e3.bufferedRequest = r3, e3.bufferProcessing = false; - } - function x(t3) { - return t3.ending && t3.length === 0 && t3.bufferedRequest === null && !t3.finished && !t3.writing; - } - function O(t3, e3) { - t3._final(function(r3) { - e3.pendingcb--, r3 && M(t3, r3), e3.prefinished = true, t3.emit("prefinish"), R(t3, e3); - }); - } - function R(t3, e3) { - var r3 = x(e3); - if (r3 && (function(t4, e4) { - e4.prefinished || e4.finalCalled || (typeof t4._final != "function" || e4.destroyed ? (e4.prefinished = true, t4.emit("prefinish")) : (e4.pendingcb++, e4.finalCalled = true, i.nextTick(O, t4, e4))); - }(t3, e3), e3.pendingcb === 0 && (e3.finished = true, t3.emit("finish"), e3.autoDestroy))) { - var n2 = t3._readableState; - (!n2 || n2.autoDestroy && n2.endEmitted) && t3.destroy(); - } - return r3; - } - r2(5717)(A, u), E.prototype.getBuffer = function() { - for (var t3 = this.bufferedRequest, e3 = []; t3; ) - e3.push(t3), t3 = t3.next; - return e3; - }, function() { - try { - Object.defineProperty(E.prototype, "buffer", {get: s.deprecate(function() { - return this.getBuffer(); - }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")}); - } catch (t3) { - } - }(), typeof Symbol == "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] == "function" ? (a = Function.prototype[Symbol.hasInstance], Object.defineProperty(A, Symbol.hasInstance, {value: function(t3) { - return !!a.call(this, t3) || this === A && t3 && t3._writableState instanceof E; - }})) : a = function(t3) { - return t3 instanceof this; - }, A.prototype.pipe = function() { - M(this, new b()); - }, A.prototype.write = function(t3, e3, r3) { - var n2, o2 = this._writableState, a2 = false, s2 = !o2.objectMode && (n2 = t3, f.isBuffer(n2) || n2 instanceof c); - return s2 && !f.isBuffer(t3) && (t3 = function(t4) { - return f.from(t4); - }(t3)), typeof e3 == "function" && (r3 = e3, e3 = null), s2 ? e3 = "buffer" : e3 || (e3 = o2.defaultEncoding), typeof r3 != "function" && (r3 = S), o2.ending ? function(t4, e4) { - var r4 = new w(); - M(t4, r4), i.nextTick(e4, r4); - }(this, r3) : (s2 || function(t4, e4, r4, n3) { - var o3; - return r4 === null ? o3 = new v() : typeof r4 == "string" || e4.objectMode || (o3 = new p("chunk", ["string", "Buffer"], r4)), !o3 || (M(t4, o3), i.nextTick(n3, o3), false); - }(this, o2, t3, r3)) && (o2.pendingcb++, a2 = function(t4, e4, r4, n3, i2, o3) { - if (!r4) { - var a3 = function(t5, e5, r5) { - return t5.objectMode || t5.decodeStrings === false || typeof e5 != "string" || (e5 = f.from(e5, r5)), e5; - }(e4, n3, i2); - n3 !== a3 && (r4 = true, i2 = "buffer", n3 = a3); - } - var s3 = e4.objectMode ? 1 : n3.length; - e4.length += s3; - var u2 = e4.length < e4.highWaterMark; - if (u2 || (e4.needDrain = true), e4.writing || e4.corked) { - var c2 = e4.lastBufferedRequest; - e4.lastBufferedRequest = {chunk: n3, encoding: i2, isBuf: r4, callback: o3, next: null}, c2 ? c2.next = e4.lastBufferedRequest : e4.bufferedRequest = e4.lastBufferedRequest, e4.bufferedRequestCount += 1; - } else - k(t4, e4, false, s3, n3, i2, o3); - return u2; - }(this, o2, s2, t3, e3, r3)), a2; - }, A.prototype.cork = function() { - this._writableState.corked++; - }, A.prototype.uncork = function() { - var t3 = this._writableState; - t3.corked && (t3.corked--, t3.writing || t3.corked || t3.bufferProcessing || !t3.bufferedRequest || T(this, t3)); - }, A.prototype.setDefaultEncoding = function(t3) { - if (typeof t3 == "string" && (t3 = t3.toLowerCase()), !(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((t3 + "").toLowerCase()) > -1)) - throw new _(t3); - return this._writableState.defaultEncoding = t3, this; - }, Object.defineProperty(A.prototype, "writableBuffer", {enumerable: false, get: function() { - return this._writableState && this._writableState.getBuffer(); - }}), Object.defineProperty(A.prototype, "writableHighWaterMark", {enumerable: false, get: function() { - return this._writableState.highWaterMark; - }}), A.prototype._write = function(t3, e3, r3) { - r3(new y("_write()")); - }, A.prototype._writev = null, A.prototype.end = function(t3, e3, r3) { - var n2 = this._writableState; - return typeof t3 == "function" ? (r3 = t3, t3 = null, e3 = null) : typeof e3 == "function" && (r3 = e3, e3 = null), t3 != null && this.write(t3, e3), n2.corked && (n2.corked = 1, this.uncork()), n2.ending || function(t4, e4, r4) { - e4.ending = true, R(t4, e4), r4 && (e4.finished ? i.nextTick(r4) : t4.once("finish", r4)), e4.ended = true, t4.writable = false; - }(this, n2, r3), this; - }, Object.defineProperty(A.prototype, "writableLength", {enumerable: false, get: function() { - return this._writableState.length; - }}), Object.defineProperty(A.prototype, "destroyed", {enumerable: false, get: function() { - return this._writableState !== void 0 && this._writableState.destroyed; - }, set: function(t3) { - this._writableState && (this._writableState.destroyed = t3); - }}), A.prototype.destroy = h.destroy, A.prototype._undestroy = h.undestroy, A.prototype._destroy = function(t3, e3) { - e3(t3); - }; - }, 5850: (t2, e2, r2) => { - var n, i = r2(4155); - function o(t3, e3, r3) { - return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; - } - var a = r2(8610), s = Symbol("lastResolve"), u = Symbol("lastReject"), f = Symbol("error"), c = Symbol("ended"), h = Symbol("lastPromise"), l = Symbol("handlePromise"), d = Symbol("stream"); - function p(t3, e3) { - return {value: t3, done: e3}; - } - function y(t3) { - var e3 = t3[s]; - if (e3 !== null) { - var r3 = t3[d].read(); - r3 !== null && (t3[h] = null, t3[s] = null, t3[u] = null, e3(p(r3, false))); - } - } - function m(t3) { - i.nextTick(y, t3); - } - var b = Object.getPrototypeOf(function() { - }), g = Object.setPrototypeOf((o(n = {get stream() { - return this[d]; - }, next: function() { - var t3 = this, e3 = this[f]; - if (e3 !== null) - return Promise.reject(e3); - if (this[c]) - return Promise.resolve(p(void 0, true)); - if (this[d].destroyed) - return new Promise(function(e4, r4) { - i.nextTick(function() { - t3[f] ? r4(t3[f]) : e4(p(void 0, true)); - }); - }); - var r3, n2 = this[h]; - if (n2) - r3 = new Promise(function(t4, e4) { - return function(r4, n3) { - t4.then(function() { - e4[c] ? r4(p(void 0, true)) : e4[l](r4, n3); - }, n3); - }; - }(n2, this)); - else { - var o2 = this[d].read(); - if (o2 !== null) - return Promise.resolve(p(o2, false)); - r3 = new Promise(this[l]); - } - return this[h] = r3, r3; - }}, Symbol.asyncIterator, function() { - return this; - }), o(n, "return", function() { - var t3 = this; - return new Promise(function(e3, r3) { - t3[d].destroy(null, function(t4) { - t4 ? r3(t4) : e3(p(void 0, true)); - }); - }); - }), n), b); - t2.exports = function(t3) { - var e3, r3 = Object.create(g, (o(e3 = {}, d, {value: t3, writable: true}), o(e3, s, {value: null, writable: true}), o(e3, u, {value: null, writable: true}), o(e3, f, {value: null, writable: true}), o(e3, c, {value: t3._readableState.endEmitted, writable: true}), o(e3, l, {value: function(t4, e4) { - var n2 = r3[d].read(); - n2 ? (r3[h] = null, r3[s] = null, r3[u] = null, t4(p(n2, false))) : (r3[s] = t4, r3[u] = e4); - }, writable: true}), e3)); - return r3[h] = null, a(t3, function(t4) { - if (t4 && t4.code !== "ERR_STREAM_PREMATURE_CLOSE") { - var e4 = r3[u]; - return e4 !== null && (r3[h] = null, r3[s] = null, r3[u] = null, e4(t4)), void (r3[f] = t4); - } - var n2 = r3[s]; - n2 !== null && (r3[h] = null, r3[s] = null, r3[u] = null, n2(p(void 0, true))), r3[c] = true; - }), t3.on("readable", m.bind(null, r3)), r3; - }; - }, 7327: (t2, e2, r2) => { - function n(t3, e3) { - var r3 = Object.keys(t3); - if (Object.getOwnPropertySymbols) { - var n2 = Object.getOwnPropertySymbols(t3); - e3 && (n2 = n2.filter(function(e4) { - return Object.getOwnPropertyDescriptor(t3, e4).enumerable; - })), r3.push.apply(r3, n2); - } - return r3; - } - function i(t3, e3, r3) { - return e3 in t3 ? Object.defineProperty(t3, e3, {value: r3, enumerable: true, configurable: true, writable: true}) : t3[e3] = r3, t3; - } - function o(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) { - var n2 = e3[r3]; - n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(t3, n2.key, n2); - } - } - var a = r2(8764).Buffer, s = r2(2361).inspect, u = s && s.custom || "inspect"; - t2.exports = function() { - function t3() { - !function(t4, e4) { - if (!(t4 instanceof e4)) - throw new TypeError("Cannot call a class as a function"); - }(this, t3), this.head = null, this.tail = null, this.length = 0; - } - var e3, r3; - return e3 = t3, (r3 = [{key: "push", value: function(t4) { - var e4 = {data: t4, next: null}; - this.length > 0 ? this.tail.next = e4 : this.head = e4, this.tail = e4, ++this.length; - }}, {key: "unshift", value: function(t4) { - var e4 = {data: t4, next: this.head}; - this.length === 0 && (this.tail = e4), this.head = e4, ++this.length; - }}, {key: "shift", value: function() { - if (this.length !== 0) { - var t4 = this.head.data; - return this.length === 1 ? this.head = this.tail = null : this.head = this.head.next, --this.length, t4; - } - }}, {key: "clear", value: function() { - this.head = this.tail = null, this.length = 0; - }}, {key: "join", value: function(t4) { - if (this.length === 0) - return ""; - for (var e4 = this.head, r4 = "" + e4.data; e4 = e4.next; ) - r4 += t4 + e4.data; - return r4; - }}, {key: "concat", value: function(t4) { - if (this.length === 0) - return a.alloc(0); - for (var e4, r4, n2, i2 = a.allocUnsafe(t4 >>> 0), o2 = this.head, s2 = 0; o2; ) - e4 = o2.data, r4 = i2, n2 = s2, a.prototype.copy.call(e4, r4, n2), s2 += o2.data.length, o2 = o2.next; - return i2; - }}, {key: "consume", value: function(t4, e4) { - var r4; - return t4 < this.head.data.length ? (r4 = this.head.data.slice(0, t4), this.head.data = this.head.data.slice(t4)) : r4 = t4 === this.head.data.length ? this.shift() : e4 ? this._getString(t4) : this._getBuffer(t4), r4; - }}, {key: "first", value: function() { - return this.head.data; - }}, {key: "_getString", value: function(t4) { - var e4 = this.head, r4 = 1, n2 = e4.data; - for (t4 -= n2.length; e4 = e4.next; ) { - var i2 = e4.data, o2 = t4 > i2.length ? i2.length : t4; - if (o2 === i2.length ? n2 += i2 : n2 += i2.slice(0, t4), (t4 -= o2) == 0) { - o2 === i2.length ? (++r4, e4.next ? this.head = e4.next : this.head = this.tail = null) : (this.head = e4, e4.data = i2.slice(o2)); - break; - } - ++r4; - } - return this.length -= r4, n2; - }}, {key: "_getBuffer", value: function(t4) { - var e4 = a.allocUnsafe(t4), r4 = this.head, n2 = 1; - for (r4.data.copy(e4), t4 -= r4.data.length; r4 = r4.next; ) { - var i2 = r4.data, o2 = t4 > i2.length ? i2.length : t4; - if (i2.copy(e4, e4.length - t4, 0, o2), (t4 -= o2) == 0) { - o2 === i2.length ? (++n2, r4.next ? this.head = r4.next : this.head = this.tail = null) : (this.head = r4, r4.data = i2.slice(o2)); - break; - } - ++n2; - } - return this.length -= n2, e4; - }}, {key: u, value: function(t4, e4) { - return s(this, function(t5) { - for (var e5 = 1; e5 < arguments.length; e5++) { - var r4 = arguments[e5] != null ? arguments[e5] : {}; - e5 % 2 ? n(Object(r4), true).forEach(function(e6) { - i(t5, e6, r4[e6]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t5, Object.getOwnPropertyDescriptors(r4)) : n(Object(r4)).forEach(function(e6) { - Object.defineProperty(t5, e6, Object.getOwnPropertyDescriptor(r4, e6)); - }); - } - return t5; - }({}, e4, {depth: 0, customInspect: false})); - }}]) && o(e3.prototype, r3), t3; - }(); - }, 1195: (t2, e2, r2) => { - var n = r2(4155); - function i(t3, e3) { - a(t3, e3), o(t3); - } - function o(t3) { - t3._writableState && !t3._writableState.emitClose || t3._readableState && !t3._readableState.emitClose || t3.emit("close"); - } - function a(t3, e3) { - t3.emit("error", e3); - } - t2.exports = {destroy: function(t3, e3) { - var r3 = this, s = this._readableState && this._readableState.destroyed, u = this._writableState && this._writableState.destroyed; - return s || u ? (e3 ? e3(t3) : t3 && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = true, n.nextTick(a, this, t3)) : n.nextTick(a, this, t3)), this) : (this._readableState && (this._readableState.destroyed = true), this._writableState && (this._writableState.destroyed = true), this._destroy(t3 || null, function(t4) { - !e3 && t4 ? r3._writableState ? r3._writableState.errorEmitted ? n.nextTick(o, r3) : (r3._writableState.errorEmitted = true, n.nextTick(i, r3, t4)) : n.nextTick(i, r3, t4) : e3 ? (n.nextTick(o, r3), e3(t4)) : n.nextTick(o, r3); - }), this); - }, undestroy: function() { - this._readableState && (this._readableState.destroyed = false, this._readableState.reading = false, this._readableState.ended = false, this._readableState.endEmitted = false), this._writableState && (this._writableState.destroyed = false, this._writableState.ended = false, this._writableState.ending = false, this._writableState.finalCalled = false, this._writableState.prefinished = false, this._writableState.finished = false, this._writableState.errorEmitted = false); - }, errorOrDestroy: function(t3, e3) { - var r3 = t3._readableState, n2 = t3._writableState; - r3 && r3.autoDestroy || n2 && n2.autoDestroy ? t3.destroy(e3) : t3.emit("error", e3); - }}; - }, 8610: (t2, e2, r2) => { - var n = r2(4281).q.ERR_STREAM_PREMATURE_CLOSE; - function i() { - } - t2.exports = function t3(e3, r3, o) { - if (typeof r3 == "function") - return t3(e3, null, r3); - r3 || (r3 = {}), o = function(t4) { - var e4 = false; - return function() { - if (!e4) { - e4 = true; - for (var r4 = arguments.length, n2 = new Array(r4), i2 = 0; i2 < r4; i2++) - n2[i2] = arguments[i2]; - t4.apply(this, n2); - } - }; - }(o || i); - var a = r3.readable || r3.readable !== false && e3.readable, s = r3.writable || r3.writable !== false && e3.writable, u = function() { - e3.writable || c(); - }, f = e3._writableState && e3._writableState.finished, c = function() { - s = false, f = true, a || o.call(e3); - }, h = e3._readableState && e3._readableState.endEmitted, l = function() { - a = false, h = true, s || o.call(e3); - }, d = function(t4) { - o.call(e3, t4); - }, p = function() { - var t4; - return a && !h ? (e3._readableState && e3._readableState.ended || (t4 = new n()), o.call(e3, t4)) : s && !f ? (e3._writableState && e3._writableState.ended || (t4 = new n()), o.call(e3, t4)) : void 0; - }, y = function() { - e3.req.on("finish", c); - }; - return function(t4) { - return t4.setHeader && typeof t4.abort == "function"; - }(e3) ? (e3.on("complete", c), e3.on("abort", p), e3.req ? y() : e3.on("request", y)) : s && !e3._writableState && (e3.on("end", u), e3.on("close", u)), e3.on("end", l), e3.on("finish", c), r3.error !== false && e3.on("error", d), e3.on("close", p), function() { - e3.removeListener("complete", c), e3.removeListener("abort", p), e3.removeListener("request", y), e3.req && e3.req.removeListener("finish", c), e3.removeListener("end", u), e3.removeListener("close", u), e3.removeListener("finish", c), e3.removeListener("end", l), e3.removeListener("error", d), e3.removeListener("close", p); - }; - }; - }, 5167: (t2) => { - t2.exports = function() { - throw new Error("Readable.from is not available in the browser"); - }; - }, 9946: (t2, e2, r2) => { - var n, i = r2(4281).q, o = i.ERR_MISSING_ARGS, a = i.ERR_STREAM_DESTROYED; - function s(t3) { - if (t3) - throw t3; - } - function u(t3, e3, i2, o2) { - o2 = function(t4) { - var e4 = false; - return function() { - e4 || (e4 = true, t4.apply(void 0, arguments)); - }; - }(o2); - var s2 = false; - t3.on("close", function() { - s2 = true; - }), n === void 0 && (n = r2(8610)), n(t3, {readable: e3, writable: i2}, function(t4) { - if (t4) - return o2(t4); - s2 = true, o2(); - }); - var u2 = false; - return function(e4) { - if (!s2 && !u2) - return u2 = true, function(t4) { - return t4.setHeader && typeof t4.abort == "function"; - }(t3) ? t3.abort() : typeof t3.destroy == "function" ? t3.destroy() : void o2(e4 || new a("pipe")); - }; - } - function f(t3) { - t3(); - } - function c(t3, e3) { - return t3.pipe(e3); - } - function h(t3) { - return t3.length ? typeof t3[t3.length - 1] != "function" ? s : t3.pop() : s; - } - t2.exports = function() { - for (var t3 = arguments.length, e3 = new Array(t3), r3 = 0; r3 < t3; r3++) - e3[r3] = arguments[r3]; - var n2, i2 = h(e3); - if (Array.isArray(e3[0]) && (e3 = e3[0]), e3.length < 2) - throw new o("streams"); - var a2 = e3.map(function(t4, r4) { - var o2 = r4 < e3.length - 1; - return u(t4, o2, r4 > 0, function(t5) { - n2 || (n2 = t5), t5 && a2.forEach(f), o2 || (a2.forEach(f), i2(n2)); - }); - }); - return e3.reduce(c); - }; - }, 2457: (t2, e2, r2) => { - var n = r2(4281).q.ERR_INVALID_OPT_VALUE; - t2.exports = {getHighWaterMark: function(t3, e3, r3, i) { - var o = function(t4, e4, r4) { - return t4.highWaterMark != null ? t4.highWaterMark : e4 ? t4[r4] : null; - }(e3, i, r3); - if (o != null) { - if (!isFinite(o) || Math.floor(o) !== o || o < 0) - throw new n(i ? r3 : "highWaterMark", o); - return Math.floor(o); - } - return t3.objectMode ? 16 : 16384; - }}; - }, 2503: (t2, e2, r2) => { - t2.exports = r2(7187).EventEmitter; - }, 8473: (t2, e2, r2) => { - (e2 = t2.exports = r2(9481)).Stream = e2, e2.Readable = e2, e2.Writable = r2(4229), e2.Duplex = r2(6753), e2.Transform = r2(4605), e2.PassThrough = r2(2725), e2.finished = r2(8610), e2.pipeline = r2(9946); - }, 9785: (t2, e2, r2) => { - var n = r2(8764).Buffer, i = r2(5717), o = r2(3349), a = new Array(16), s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], u = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], f = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], c = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11], h = [0, 1518500249, 1859775393, 2400959708, 2840853838], l = [1352829926, 1548603684, 1836072691, 2053994217, 0]; - function d() { - o.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520; - } - function p(t3, e3) { - return t3 << e3 | t3 >>> 32 - e3; - } - function y(t3, e3, r3, n2, i2, o2, a2, s2) { - return p(t3 + (e3 ^ r3 ^ n2) + o2 + a2 | 0, s2) + i2 | 0; - } - function m(t3, e3, r3, n2, i2, o2, a2, s2) { - return p(t3 + (e3 & r3 | ~e3 & n2) + o2 + a2 | 0, s2) + i2 | 0; - } - function b(t3, e3, r3, n2, i2, o2, a2, s2) { - return p(t3 + ((e3 | ~r3) ^ n2) + o2 + a2 | 0, s2) + i2 | 0; - } - function g(t3, e3, r3, n2, i2, o2, a2, s2) { - return p(t3 + (e3 & n2 | r3 & ~n2) + o2 + a2 | 0, s2) + i2 | 0; - } - function v(t3, e3, r3, n2, i2, o2, a2, s2) { - return p(t3 + (e3 ^ (r3 | ~n2)) + o2 + a2 | 0, s2) + i2 | 0; - } - i(d, o), d.prototype._update = function() { - for (var t3 = a, e3 = 0; e3 < 16; ++e3) - t3[e3] = this._block.readInt32LE(4 * e3); - for (var r3 = 0 | this._a, n2 = 0 | this._b, i2 = 0 | this._c, o2 = 0 | this._d, d2 = 0 | this._e, w = 0 | this._a, _ = 0 | this._b, M = 0 | this._c, S = 0 | this._d, E = 0 | this._e, A = 0; A < 80; A += 1) { - var k, B; - A < 16 ? (k = y(r3, n2, i2, o2, d2, t3[s[A]], h[0], f[A]), B = v(w, _, M, S, E, t3[u[A]], l[0], c[A])) : A < 32 ? (k = m(r3, n2, i2, o2, d2, t3[s[A]], h[1], f[A]), B = g(w, _, M, S, E, t3[u[A]], l[1], c[A])) : A < 48 ? (k = b(r3, n2, i2, o2, d2, t3[s[A]], h[2], f[A]), B = b(w, _, M, S, E, t3[u[A]], l[2], c[A])) : A < 64 ? (k = g(r3, n2, i2, o2, d2, t3[s[A]], h[3], f[A]), B = m(w, _, M, S, E, t3[u[A]], l[3], c[A])) : (k = v(r3, n2, i2, o2, d2, t3[s[A]], h[4], f[A]), B = y(w, _, M, S, E, t3[u[A]], l[4], c[A])), r3 = d2, d2 = o2, o2 = p(i2, 10), i2 = n2, n2 = k, w = E, E = S, S = p(M, 10), M = _, _ = B; - } - var T = this._b + i2 + S | 0; - this._b = this._c + o2 + E | 0, this._c = this._d + d2 + w | 0, this._d = this._e + r3 + _ | 0, this._e = this._a + n2 + M | 0, this._a = T; - }, d.prototype._digest = function() { - this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); - var t3 = n.alloc ? n.alloc(20) : new n(20); - return t3.writeInt32LE(this._a, 0), t3.writeInt32LE(this._b, 4), t3.writeInt32LE(this._c, 8), t3.writeInt32LE(this._d, 12), t3.writeInt32LE(this._e, 16), t3; - }, t2.exports = d; - }, 9509: (t2, e2, r2) => { - var n = r2(8764), i = n.Buffer; - function o(t3, e3) { - for (var r3 in t3) - e3[r3] = t3[r3]; - } - function a(t3, e3, r3) { - return i(t3, e3, r3); - } - i.from && i.alloc && i.allocUnsafe && i.allocUnsafeSlow ? t2.exports = n : (o(n, e2), e2.Buffer = a), a.prototype = Object.create(i.prototype), o(i, a), a.from = function(t3, e3, r3) { - if (typeof t3 == "number") - throw new TypeError("Argument must not be a number"); - return i(t3, e3, r3); - }, a.alloc = function(t3, e3, r3) { - if (typeof t3 != "number") - throw new TypeError("Argument must be a number"); - var n2 = i(t3); - return e3 !== void 0 ? typeof r3 == "string" ? n2.fill(e3, r3) : n2.fill(e3) : n2.fill(0), n2; - }, a.allocUnsafe = function(t3) { - if (typeof t3 != "number") - throw new TypeError("Argument must be a number"); - return i(t3); - }, a.allocUnsafeSlow = function(t3) { - if (typeof t3 != "number") - throw new TypeError("Argument must be a number"); - return n.SlowBuffer(t3); - }; - }, 2399: (t2, e2, r2) => { - var n, i = r2(4155), o = r2(8764), a = o.Buffer, s = {}; - for (n in o) - o.hasOwnProperty(n) && n !== "SlowBuffer" && n !== "Buffer" && (s[n] = o[n]); - var u = s.Buffer = {}; - for (n in a) - a.hasOwnProperty(n) && n !== "allocUnsafe" && n !== "allocUnsafeSlow" && (u[n] = a[n]); - if (s.Buffer.prototype = a.prototype, u.from && u.from !== Uint8Array.from || (u.from = function(t3, e3, r3) { - if (typeof t3 == "number") - throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof t3); - if (t3 && t3.length === void 0) - throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t3); - return a(t3, e3, r3); - }), u.alloc || (u.alloc = function(t3, e3, r3) { - if (typeof t3 != "number") - throw new TypeError('The "size" argument must be of type number. Received type ' + typeof t3); - if (t3 < 0 || t3 >= 2 * (1 << 30)) - throw new RangeError('The value "' + t3 + '" is invalid for option "size"'); - var n2 = a(t3); - return e3 && e3.length !== 0 ? typeof r3 == "string" ? n2.fill(e3, r3) : n2.fill(e3) : n2.fill(0), n2; - }), !s.kStringMaxLength) - try { - s.kStringMaxLength = i.binding("buffer").kStringMaxLength; - } catch (t3) { - } - s.constants || (s.constants = {MAX_LENGTH: s.kMaxLength}, s.kStringMaxLength && (s.constants.MAX_STRING_LENGTH = s.kStringMaxLength)), t2.exports = s; - }, 7221: (t2, e2, r2) => { - t2.exports = r2(9119)(r2(8573)); - }, 8573: (t2, e2, r2) => { - const n = new (r2(6266)).ec("secp256k1"), i = n.curve, o = i.n.constructor; - function a(t3) { - const e3 = t3[0]; - switch (e3) { - case 2: - case 3: - return t3.length !== 33 ? null : function(t4, e4) { - let r3 = new o(e4); - if (r3.cmp(i.p) >= 0) - return null; - r3 = r3.toRed(i.red); - let a2 = r3.redSqr().redIMul(r3).redIAdd(i.b).redSqrt(); - return t4 === 3 !== a2.isOdd() && (a2 = a2.redNeg()), n.keyPair({pub: {x: r3, y: a2}}); - }(e3, t3.subarray(1, 33)); - case 4: - case 6: - case 7: - return t3.length !== 65 ? null : function(t4, e4, r3) { - let a2 = new o(e4), s2 = new o(r3); - if (a2.cmp(i.p) >= 0 || s2.cmp(i.p) >= 0) - return null; - if (a2 = a2.toRed(i.red), s2 = s2.toRed(i.red), (t4 === 6 || t4 === 7) && s2.isOdd() !== (t4 === 7)) - return null; - const u = a2.redSqr().redIMul(a2); - return s2.redSqr().redISub(u.redIAdd(i.b)).isZero() ? n.keyPair({pub: {x: a2, y: s2}}) : null; - }(e3, t3.subarray(1, 33), t3.subarray(33, 65)); - default: - return null; - } - } - function s(t3, e3) { - const r3 = e3.encode(null, t3.length === 33); - for (let e4 = 0; e4 < t3.length; ++e4) - t3[e4] = r3[e4]; - } - t2.exports = {contextRandomize: () => 0, privateKeyVerify(t3) { - const e3 = new o(t3); - return e3.cmp(i.n) < 0 && !e3.isZero() ? 0 : 1; - }, privateKeyNegate(t3) { - const e3 = new o(t3), r3 = i.n.sub(e3).umod(i.n).toArrayLike(Uint8Array, "be", 32); - return t3.set(r3), 0; - }, privateKeyTweakAdd(t3, e3) { - const r3 = new o(e3); - if (r3.cmp(i.n) >= 0) - return 1; - if (r3.iadd(new o(t3)), r3.cmp(i.n) >= 0 && r3.isub(i.n), r3.isZero()) - return 1; - const n2 = r3.toArrayLike(Uint8Array, "be", 32); - return t3.set(n2), 0; - }, privateKeyTweakMul(t3, e3) { - let r3 = new o(e3); - if (r3.cmp(i.n) >= 0 || r3.isZero()) - return 1; - r3.imul(new o(t3)), r3.cmp(i.n) >= 0 && (r3 = r3.umod(i.n)); - const n2 = r3.toArrayLike(Uint8Array, "be", 32); - return t3.set(n2), 0; - }, publicKeyVerify: (t3) => a(t3) === null ? 1 : 0, publicKeyCreate(t3, e3) { - const r3 = new o(e3); - return r3.cmp(i.n) >= 0 || r3.isZero() ? 1 : (s(t3, n.keyFromPrivate(e3).getPublic()), 0); - }, publicKeyConvert(t3, e3) { - const r3 = a(e3); - return r3 === null ? 1 : (s(t3, r3.getPublic()), 0); - }, publicKeyNegate(t3, e3) { - const r3 = a(e3); - if (r3 === null) - return 1; - const n2 = r3.getPublic(); - return n2.y = n2.y.redNeg(), s(t3, n2), 0; - }, publicKeyCombine(t3, e3) { - const r3 = new Array(e3.length); - for (let t4 = 0; t4 < e3.length; ++t4) - if (r3[t4] = a(e3[t4]), r3[t4] === null) - return 1; - let n2 = r3[0].getPublic(); - for (let t4 = 1; t4 < r3.length; ++t4) - n2 = n2.add(r3[t4].pub); - return n2.isInfinity() ? 2 : (s(t3, n2), 0); - }, publicKeyTweakAdd(t3, e3, r3) { - const n2 = a(e3); - if (n2 === null) - return 1; - if ((r3 = new o(r3)).cmp(i.n) >= 0) - return 2; - const u = n2.getPublic().add(i.g.mul(r3)); - return u.isInfinity() ? 2 : (s(t3, u), 0); - }, publicKeyTweakMul(t3, e3, r3) { - const n2 = a(e3); - return n2 === null ? 1 : (r3 = new o(r3)).cmp(i.n) >= 0 || r3.isZero() ? 2 : (s(t3, n2.getPublic().mul(r3)), 0); - }, signatureNormalize(t3) { - const e3 = new o(t3.subarray(0, 32)), r3 = new o(t3.subarray(32, 64)); - return e3.cmp(i.n) >= 0 || r3.cmp(i.n) >= 0 ? 1 : (r3.cmp(n.nh) === 1 && t3.set(i.n.sub(r3).toArrayLike(Uint8Array, "be", 32), 32), 0); - }, signatureExport(t3, e3) { - const r3 = e3.subarray(0, 32), n2 = e3.subarray(32, 64); - if (new o(r3).cmp(i.n) >= 0) - return 1; - if (new o(n2).cmp(i.n) >= 0) - return 1; - const {output: a2} = t3; - let s2 = a2.subarray(4, 37); - s2[0] = 0, s2.set(r3, 1); - let u = 33, f = 0; - for (; u > 1 && s2[f] === 0 && !(128 & s2[f + 1]); --u, ++f) - ; - if (s2 = s2.subarray(f), 128 & s2[0]) - return 1; - if (u > 1 && s2[0] === 0 && !(128 & s2[1])) - return 1; - let c = a2.subarray(39, 72); - c[0] = 0, c.set(n2, 1); - let h = 33, l = 0; - for (; h > 1 && c[l] === 0 && !(128 & c[l + 1]); --h, ++l) - ; - return c = c.subarray(l), 128 & c[0] || h > 1 && c[0] === 0 && !(128 & c[1]) ? 1 : (t3.outputlen = 6 + u + h, a2[0] = 48, a2[1] = t3.outputlen - 2, a2[2] = 2, a2[3] = s2.length, a2.set(s2, 4), a2[4 + u] = 2, a2[5 + u] = c.length, a2.set(c, 6 + u), 0); - }, signatureImport(t3, e3) { - if (e3.length < 8) - return 1; - if (e3.length > 72) - return 1; - if (e3[0] !== 48) - return 1; - if (e3[1] !== e3.length - 2) - return 1; - if (e3[2] !== 2) - return 1; - const r3 = e3[3]; - if (r3 === 0) - return 1; - if (5 + r3 >= e3.length) - return 1; - if (e3[4 + r3] !== 2) - return 1; - const n2 = e3[5 + r3]; - if (n2 === 0) - return 1; - if (6 + r3 + n2 !== e3.length) - return 1; - if (128 & e3[4]) - return 1; - if (r3 > 1 && e3[4] === 0 && !(128 & e3[5])) - return 1; - if (128 & e3[r3 + 6]) - return 1; - if (n2 > 1 && e3[r3 + 6] === 0 && !(128 & e3[r3 + 7])) - return 1; - let a2 = e3.subarray(4, 4 + r3); - if (a2.length === 33 && a2[0] === 0 && (a2 = a2.subarray(1)), a2.length > 32) - return 1; - let s2 = e3.subarray(6 + r3); - if (s2.length === 33 && s2[0] === 0 && (s2 = s2.slice(1)), s2.length > 32) - throw new Error("S length is too long"); - let u = new o(a2); - u.cmp(i.n) >= 0 && (u = new o(0)); - let f = new o(e3.subarray(6 + r3)); - return f.cmp(i.n) >= 0 && (f = new o(0)), t3.set(u.toArrayLike(Uint8Array, "be", 32), 0), t3.set(f.toArrayLike(Uint8Array, "be", 32), 32), 0; - }, ecdsaSign(t3, e3, r3, a2, s2) { - if (s2) { - const t4 = s2; - s2 = (n2) => { - const i2 = t4(e3, r3, null, a2, n2); - if (!(i2 instanceof Uint8Array && i2.length === 32)) - throw new Error("This is the way"); - return new o(i2); - }; - } - const u = new o(r3); - if (u.cmp(i.n) >= 0 || u.isZero()) - return 1; - let f; - try { - f = n.sign(e3, r3, {canonical: true, k: s2, pers: a2}); - } catch (t4) { - return 1; - } - return t3.signature.set(f.r.toArrayLike(Uint8Array, "be", 32), 0), t3.signature.set(f.s.toArrayLike(Uint8Array, "be", 32), 32), t3.recid = f.recoveryParam, 0; - }, ecdsaVerify(t3, e3, r3) { - const s2 = {r: t3.subarray(0, 32), s: t3.subarray(32, 64)}, u = new o(s2.r), f = new o(s2.s); - if (u.cmp(i.n) >= 0 || f.cmp(i.n) >= 0) - return 1; - if (f.cmp(n.nh) === 1 || u.isZero() || f.isZero()) - return 3; - const c = a(r3); - if (c === null) - return 2; - const h = c.getPublic(); - return n.verify(e3, s2, h) ? 0 : 3; - }, ecdsaRecover(t3, e3, r3, a2) { - const u = {r: e3.slice(0, 32), s: e3.slice(32, 64)}, f = new o(u.r), c = new o(u.s); - if (f.cmp(i.n) >= 0 || c.cmp(i.n) >= 0) - return 1; - if (f.isZero() || c.isZero()) - return 2; - let h; - try { - h = n.recoverPubKey(a2, u, r3); - } catch (t4) { - return 2; - } - return s(t3, h), 0; - }, ecdh(t3, e3, r3, s2, u, f, c) { - const h = a(e3); - if (h === null) - return 1; - const l = new o(r3); - if (l.cmp(i.n) >= 0 || l.isZero()) - return 2; - const d = h.getPublic().mul(l); - if (u === void 0) { - const e4 = d.encode(null, true), r4 = n.hash().update(e4).digest(); - for (let e5 = 0; e5 < 32; ++e5) - t3[e5] = r4[e5]; - } else { - f || (f = new Uint8Array(32)); - const e4 = d.getX().toArray("be", 32); - for (let t4 = 0; t4 < 32; ++t4) - f[t4] = e4[t4]; - c || (c = new Uint8Array(32)); - const r4 = d.getY().toArray("be", 32); - for (let t4 = 0; t4 < 32; ++t4) - c[t4] = r4[t4]; - const n2 = u(f, c, s2); - if (!(n2 instanceof Uint8Array && n2.length === t3.length)) - return 2; - t3.set(n2); - } - return 0; - }}; - }, 9119: (t2) => { - const e2 = "Impossible case. Please create issue.", r2 = "The tweak was out of range or the resulted private key is invalid", n = "The tweak was out of range or equal to zero", i = "Public Key could not be parsed", o = "Public Key serialization error", a = "Signature could not be parsed"; - function s(t3, e3) { - if (!t3) - throw new Error(e3); - } - function u(t3, e3, r3) { - if (s(e3 instanceof Uint8Array, `Expected ${t3} to be an Uint8Array`), r3 !== void 0) - if (Array.isArray(r3)) { - const n2 = `Expected ${t3} to be an Uint8Array with length [${r3.join(", ")}]`; - s(r3.includes(e3.length), n2); - } else { - const n2 = `Expected ${t3} to be an Uint8Array with length ${r3}`; - s(e3.length === r3, n2); - } - } - function f(t3) { - s(h(t3) === "Boolean", "Expected compressed to be a Boolean"); - } - function c(t3 = (t4) => new Uint8Array(t4), e3) { - return typeof t3 == "function" && (t3 = t3(e3)), u("output", t3, e3), t3; - } - function h(t3) { - return Object.prototype.toString.call(t3).slice(8, -1); - } - t2.exports = (t3) => ({contextRandomize(e3) { - switch (s(e3 === null || e3 instanceof Uint8Array, "Expected seed to be an Uint8Array or null"), e3 !== null && u("seed", e3, 32), t3.contextRandomize(e3)) { - case 1: - throw new Error("Unknow error on context randomization"); - } - }, privateKeyVerify: (e3) => (u("private key", e3, 32), t3.privateKeyVerify(e3) === 0), privateKeyNegate(r3) { - switch (u("private key", r3, 32), t3.privateKeyNegate(r3)) { - case 0: - return r3; - case 1: - throw new Error(e2); - } - }, privateKeyTweakAdd(e3, n2) { - switch (u("private key", e3, 32), u("tweak", n2, 32), t3.privateKeyTweakAdd(e3, n2)) { - case 0: - return e3; - case 1: - throw new Error(r2); - } - }, privateKeyTweakMul(e3, r3) { - switch (u("private key", e3, 32), u("tweak", r3, 32), t3.privateKeyTweakMul(e3, r3)) { - case 0: - return e3; - case 1: - throw new Error(n); - } - }, publicKeyVerify: (e3) => (u("public key", e3, [33, 65]), t3.publicKeyVerify(e3) === 0), publicKeyCreate(e3, r3 = true, n2) { - switch (u("private key", e3, 32), f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyCreate(n2, e3)) { - case 0: - return n2; - case 1: - throw new Error("Private Key is invalid"); - case 2: - throw new Error(o); - } - }, publicKeyConvert(e3, r3 = true, n2) { - switch (u("public key", e3, [33, 65]), f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyConvert(n2, e3)) { - case 0: - return n2; - case 1: - throw new Error(i); - case 2: - throw new Error(o); - } - }, publicKeyNegate(r3, n2 = true, a2) { - switch (u("public key", r3, [33, 65]), f(n2), a2 = c(a2, n2 ? 33 : 65), t3.publicKeyNegate(a2, r3)) { - case 0: - return a2; - case 1: - throw new Error(i); - case 2: - throw new Error(e2); - case 3: - throw new Error(o); - } - }, publicKeyCombine(e3, r3 = true, n2) { - s(Array.isArray(e3), "Expected public keys to be an Array"), s(e3.length > 0, "Expected public keys array will have more than zero items"); - for (const t4 of e3) - u("public key", t4, [33, 65]); - switch (f(r3), n2 = c(n2, r3 ? 33 : 65), t3.publicKeyCombine(n2, e3)) { - case 0: - return n2; - case 1: - throw new Error(i); - case 2: - throw new Error("The sum of the public keys is not valid"); - case 3: - throw new Error(o); - } - }, publicKeyTweakAdd(e3, n2, o2 = true, a2) { - switch (u("public key", e3, [33, 65]), u("tweak", n2, 32), f(o2), a2 = c(a2, o2 ? 33 : 65), t3.publicKeyTweakAdd(a2, e3, n2)) { - case 0: - return a2; - case 1: - throw new Error(i); - case 2: - throw new Error(r2); - } - }, publicKeyTweakMul(e3, r3, o2 = true, a2) { - switch (u("public key", e3, [33, 65]), u("tweak", r3, 32), f(o2), a2 = c(a2, o2 ? 33 : 65), t3.publicKeyTweakMul(a2, e3, r3)) { - case 0: - return a2; - case 1: - throw new Error(i); - case 2: - throw new Error(n); - } - }, signatureNormalize(e3) { - switch (u("signature", e3, 64), t3.signatureNormalize(e3)) { - case 0: - return e3; - case 1: - throw new Error(a); - } - }, signatureExport(r3, n2) { - u("signature", r3, 64); - const i2 = {output: n2 = c(n2, 72), outputlen: 72}; - switch (t3.signatureExport(i2, r3)) { - case 0: - return n2.slice(0, i2.outputlen); - case 1: - throw new Error(a); - case 2: - throw new Error(e2); - } - }, signatureImport(r3, n2) { - switch (u("signature", r3), n2 = c(n2, 64), t3.signatureImport(n2, r3)) { - case 0: - return n2; - case 1: - throw new Error(a); - case 2: - throw new Error(e2); - } - }, ecdsaSign(r3, n2, i2 = {}, o2) { - u("message", r3, 32), u("private key", n2, 32), s(h(i2) === "Object", "Expected options to be an Object"), i2.data !== void 0 && u("options.data", i2.data), i2.noncefn !== void 0 && s(h(i2.noncefn) === "Function", "Expected options.noncefn to be a Function"); - const a2 = {signature: o2 = c(o2, 64), recid: null}; - switch (t3.ecdsaSign(a2, r3, n2, i2.data, i2.noncefn)) { - case 0: - return a2; - case 1: - throw new Error("The nonce generation function failed, or the private key was invalid"); - case 2: - throw new Error(e2); - } - }, ecdsaVerify(e3, r3, n2) { - switch (u("signature", e3, 64), u("message", r3, 32), u("public key", n2, [33, 65]), t3.ecdsaVerify(e3, r3, n2)) { - case 0: - return true; - case 3: - return false; - case 1: - throw new Error(a); - case 2: - throw new Error(i); - } - }, ecdsaRecover(r3, n2, i2, o2 = true, l) { - switch (u("signature", r3, 64), s(h(n2) === "Number" && n2 >= 0 && n2 <= 3, "Expected recovery id to be a Number within interval [0, 3]"), u("message", i2, 32), f(o2), l = c(l, o2 ? 33 : 65), t3.ecdsaRecover(l, r3, n2, i2)) { - case 0: - return l; - case 1: - throw new Error(a); - case 2: - throw new Error("Public key could not be recover"); - case 3: - throw new Error(e2); - } - }, ecdh(e3, r3, n2 = {}, o2) { - switch (u("public key", e3, [33, 65]), u("private key", r3, 32), s(h(n2) === "Object", "Expected options to be an Object"), n2.data !== void 0 && u("options.data", n2.data), n2.hashfn !== void 0 ? (s(h(n2.hashfn) === "Function", "Expected options.hashfn to be a Function"), n2.xbuf !== void 0 && u("options.xbuf", n2.xbuf, 32), n2.ybuf !== void 0 && u("options.ybuf", n2.ybuf, 32), u("output", o2)) : o2 = c(o2, 32), t3.ecdh(o2, e3, r3, n2.data, n2.hashfn, n2.xbuf, n2.ybuf)) { - case 0: - return o2; - case 1: - throw new Error(i); - case 2: - throw new Error("Scalar was invalid (zero or overflow)"); - } - }}); - }, 4189: (t2, e2, r2) => { - var n = r2(9509).Buffer; - function i(t3, e3) { - this._block = n.alloc(t3), this._finalSize = e3, this._blockSize = t3, this._len = 0; - } - i.prototype.update = function(t3, e3) { - typeof t3 == "string" && (e3 = e3 || "utf8", t3 = n.from(t3, e3)); - for (var r3 = this._block, i2 = this._blockSize, o = t3.length, a = this._len, s = 0; s < o; ) { - for (var u = a % i2, f = Math.min(o - s, i2 - u), c = 0; c < f; c++) - r3[u + c] = t3[s + c]; - s += f, (a += f) % i2 == 0 && this._update(r3); - } - return this._len += o, this; - }, i.prototype.digest = function(t3) { - var e3 = this._len % this._blockSize; - this._block[e3] = 128, this._block.fill(0, e3 + 1), e3 >= this._finalSize && (this._update(this._block), this._block.fill(0)); - var r3 = 8 * this._len; - if (r3 <= 4294967295) - this._block.writeUInt32BE(r3, this._blockSize - 4); - else { - var n2 = (4294967295 & r3) >>> 0, i2 = (r3 - n2) / 4294967296; - this._block.writeUInt32BE(i2, this._blockSize - 8), this._block.writeUInt32BE(n2, this._blockSize - 4); - } - this._update(this._block); - var o = this._hash(); - return t3 ? o.toString(t3) : o; - }, i.prototype._update = function() { - throw new Error("_update must be implemented by subclass"); - }, t2.exports = i; - }, 9072: (t2, e2, r2) => { - var n = t2.exports = function(t3) { - t3 = t3.toLowerCase(); - var e3 = n[t3]; - if (!e3) - throw new Error(t3 + " is not supported (we accept pull requests)"); - return new e3(); - }; - n.sha = r2(4448), n.sha1 = r2(8336), n.sha224 = r2(8432), n.sha256 = r2(7499), n.sha384 = r2(1686), n.sha512 = r2(7816); - }, 4448: (t2, e2, r2) => { - var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [1518500249, 1859775393, -1894007588, -899497514], s = new Array(80); - function u() { - this.init(), this._w = s, i.call(this, 64, 56); - } - function f(t3) { - return t3 << 30 | t3 >>> 2; - } - function c(t3, e3, r3, n2) { - return t3 === 0 ? e3 & r3 | ~e3 & n2 : t3 === 2 ? e3 & r3 | e3 & n2 | r3 & n2 : e3 ^ r3 ^ n2; - } - n(u, i), u.prototype.init = function() { - return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; - }, u.prototype._update = function(t3) { - for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, h = 0; h < 16; ++h) - r3[h] = t3.readInt32BE(4 * h); - for (; h < 80; ++h) - r3[h] = r3[h - 3] ^ r3[h - 8] ^ r3[h - 14] ^ r3[h - 16]; - for (var l = 0; l < 80; ++l) { - var d = ~~(l / 20), p = 0 | ((e3 = n2) << 5 | e3 >>> 27) + c(d, i2, o2, s2) + u2 + r3[l] + a[d]; - u2 = s2, s2 = o2, o2 = f(i2), i2 = n2, n2 = p; - } - this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0; - }, u.prototype._hash = function() { - var t3 = o.allocUnsafe(20); - return t3.writeInt32BE(0 | this._a, 0), t3.writeInt32BE(0 | this._b, 4), t3.writeInt32BE(0 | this._c, 8), t3.writeInt32BE(0 | this._d, 12), t3.writeInt32BE(0 | this._e, 16), t3; - }, t2.exports = u; - }, 8336: (t2, e2, r2) => { - var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [1518500249, 1859775393, -1894007588, -899497514], s = new Array(80); - function u() { - this.init(), this._w = s, i.call(this, 64, 56); - } - function f(t3) { - return t3 << 5 | t3 >>> 27; - } - function c(t3) { - return t3 << 30 | t3 >>> 2; - } - function h(t3, e3, r3, n2) { - return t3 === 0 ? e3 & r3 | ~e3 & n2 : t3 === 2 ? e3 & r3 | e3 & n2 | r3 & n2 : e3 ^ r3 ^ n2; - } - n(u, i), u.prototype.init = function() { - return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; - }, u.prototype._update = function(t3) { - for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, l = 0; l < 16; ++l) - r3[l] = t3.readInt32BE(4 * l); - for (; l < 80; ++l) - r3[l] = (e3 = r3[l - 3] ^ r3[l - 8] ^ r3[l - 14] ^ r3[l - 16]) << 1 | e3 >>> 31; - for (var d = 0; d < 80; ++d) { - var p = ~~(d / 20), y = f(n2) + h(p, i2, o2, s2) + u2 + r3[d] + a[p] | 0; - u2 = s2, s2 = o2, o2 = c(i2), i2 = n2, n2 = y; - } - this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0; - }, u.prototype._hash = function() { - var t3 = o.allocUnsafe(20); - return t3.writeInt32BE(0 | this._a, 0), t3.writeInt32BE(0 | this._b, 4), t3.writeInt32BE(0 | this._c, 8), t3.writeInt32BE(0 | this._d, 12), t3.writeInt32BE(0 | this._e, 16), t3; - }, t2.exports = u; - }, 8432: (t2, e2, r2) => { - var n = r2(5717), i = r2(7499), o = r2(4189), a = r2(9509).Buffer, s = new Array(64); - function u() { - this.init(), this._w = s, o.call(this, 64, 56); - } - n(u, i), u.prototype.init = function() { - return this._a = 3238371032, this._b = 914150663, this._c = 812702999, this._d = 4144912697, this._e = 4290775857, this._f = 1750603025, this._g = 1694076839, this._h = 3204075428, this; - }, u.prototype._hash = function() { - var t3 = a.allocUnsafe(28); - return t3.writeInt32BE(this._a, 0), t3.writeInt32BE(this._b, 4), t3.writeInt32BE(this._c, 8), t3.writeInt32BE(this._d, 12), t3.writeInt32BE(this._e, 16), t3.writeInt32BE(this._f, 20), t3.writeInt32BE(this._g, 24), t3; - }, t2.exports = u; - }, 7499: (t2, e2, r2) => { - var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [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], s = new Array(64); - function u() { - this.init(), this._w = s, i.call(this, 64, 56); - } - function f(t3, e3, r3) { - return r3 ^ t3 & (e3 ^ r3); - } - function c(t3, e3, r3) { - return t3 & e3 | r3 & (t3 | e3); - } - function h(t3) { - return (t3 >>> 2 | t3 << 30) ^ (t3 >>> 13 | t3 << 19) ^ (t3 >>> 22 | t3 << 10); - } - function l(t3) { - return (t3 >>> 6 | t3 << 26) ^ (t3 >>> 11 | t3 << 21) ^ (t3 >>> 25 | t3 << 7); - } - function d(t3) { - return (t3 >>> 7 | t3 << 25) ^ (t3 >>> 18 | t3 << 14) ^ t3 >>> 3; - } - n(u, i), u.prototype.init = function() { - return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, this._g = 528734635, this._h = 1541459225, this; - }, u.prototype._update = function(t3) { - for (var e3, r3 = this._w, n2 = 0 | this._a, i2 = 0 | this._b, o2 = 0 | this._c, s2 = 0 | this._d, u2 = 0 | this._e, p = 0 | this._f, y = 0 | this._g, m = 0 | this._h, b = 0; b < 16; ++b) - r3[b] = t3.readInt32BE(4 * b); - for (; b < 64; ++b) - r3[b] = 0 | (((e3 = r3[b - 2]) >>> 17 | e3 << 15) ^ (e3 >>> 19 | e3 << 13) ^ e3 >>> 10) + r3[b - 7] + d(r3[b - 15]) + r3[b - 16]; - for (var g = 0; g < 64; ++g) { - var v = m + l(u2) + f(u2, p, y) + a[g] + r3[g] | 0, w = h(n2) + c(n2, i2, o2) | 0; - m = y, y = p, p = u2, u2 = s2 + v | 0, s2 = o2, o2 = i2, i2 = n2, n2 = v + w | 0; - } - this._a = n2 + this._a | 0, this._b = i2 + this._b | 0, this._c = o2 + this._c | 0, this._d = s2 + this._d | 0, this._e = u2 + this._e | 0, this._f = p + this._f | 0, this._g = y + this._g | 0, this._h = m + this._h | 0; - }, u.prototype._hash = function() { - var t3 = o.allocUnsafe(32); - return t3.writeInt32BE(this._a, 0), t3.writeInt32BE(this._b, 4), t3.writeInt32BE(this._c, 8), t3.writeInt32BE(this._d, 12), t3.writeInt32BE(this._e, 16), t3.writeInt32BE(this._f, 20), t3.writeInt32BE(this._g, 24), t3.writeInt32BE(this._h, 28), t3; - }, t2.exports = u; - }, 1686: (t2, e2, r2) => { - var n = r2(5717), i = r2(7816), o = r2(4189), a = r2(9509).Buffer, s = new Array(160); - function u() { - this.init(), this._w = s, o.call(this, 128, 112); - } - n(u, i), u.prototype.init = function() { - return this._ah = 3418070365, this._bh = 1654270250, this._ch = 2438529370, this._dh = 355462360, this._eh = 1731405415, this._fh = 2394180231, this._gh = 3675008525, this._hh = 1203062813, this._al = 3238371032, this._bl = 914150663, this._cl = 812702999, this._dl = 4144912697, this._el = 4290775857, this._fl = 1750603025, this._gl = 1694076839, this._hl = 3204075428, this; - }, u.prototype._hash = function() { - var t3 = a.allocUnsafe(48); - function e3(e4, r3, n2) { - t3.writeInt32BE(e4, n2), t3.writeInt32BE(r3, n2 + 4); - } - return e3(this._ah, this._al, 0), e3(this._bh, this._bl, 8), e3(this._ch, this._cl, 16), e3(this._dh, this._dl, 24), e3(this._eh, this._el, 32), e3(this._fh, this._fl, 40), t3; - }, t2.exports = u; - }, 7816: (t2, e2, r2) => { - var n = r2(5717), i = r2(4189), o = r2(9509).Buffer, a = [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], s = new Array(160); - function u() { - this.init(), this._w = s, i.call(this, 128, 112); - } - function f(t3, e3, r3) { - return r3 ^ t3 & (e3 ^ r3); - } - function c(t3, e3, r3) { - return t3 & e3 | r3 & (t3 | e3); - } - function h(t3, e3) { - return (t3 >>> 28 | e3 << 4) ^ (e3 >>> 2 | t3 << 30) ^ (e3 >>> 7 | t3 << 25); - } - function l(t3, e3) { - return (t3 >>> 14 | e3 << 18) ^ (t3 >>> 18 | e3 << 14) ^ (e3 >>> 9 | t3 << 23); - } - function d(t3, e3) { - return (t3 >>> 1 | e3 << 31) ^ (t3 >>> 8 | e3 << 24) ^ t3 >>> 7; - } - function p(t3, e3) { - return (t3 >>> 1 | e3 << 31) ^ (t3 >>> 8 | e3 << 24) ^ (t3 >>> 7 | e3 << 25); - } - function y(t3, e3) { - return (t3 >>> 19 | e3 << 13) ^ (e3 >>> 29 | t3 << 3) ^ t3 >>> 6; - } - function m(t3, e3) { - return (t3 >>> 19 | e3 << 13) ^ (e3 >>> 29 | t3 << 3) ^ (t3 >>> 6 | e3 << 26); - } - function b(t3, e3) { - return t3 >>> 0 < e3 >>> 0 ? 1 : 0; - } - n(u, i), u.prototype.init = function() { - return this._ah = 1779033703, this._bh = 3144134277, this._ch = 1013904242, this._dh = 2773480762, this._eh = 1359893119, this._fh = 2600822924, this._gh = 528734635, this._hh = 1541459225, this._al = 4089235720, this._bl = 2227873595, this._cl = 4271175723, this._dl = 1595750129, this._el = 2917565137, this._fl = 725511199, this._gl = 4215389547, this._hl = 327033209, this; - }, u.prototype._update = function(t3) { - for (var e3 = this._w, r3 = 0 | this._ah, n2 = 0 | this._bh, i2 = 0 | this._ch, o2 = 0 | this._dh, s2 = 0 | this._eh, u2 = 0 | this._fh, g = 0 | this._gh, v = 0 | this._hh, w = 0 | this._al, _ = 0 | this._bl, M = 0 | this._cl, S = 0 | this._dl, E = 0 | this._el, A = 0 | this._fl, k = 0 | this._gl, B = 0 | this._hl, T = 0; T < 32; T += 2) - e3[T] = t3.readInt32BE(4 * T), e3[T + 1] = t3.readInt32BE(4 * T + 4); - for (; T < 160; T += 2) { - var x = e3[T - 30], O = e3[T - 30 + 1], R = d(x, O), P = p(O, x), I = y(x = e3[T - 4], O = e3[T - 4 + 1]), j = m(O, x), U = e3[T - 14], N = e3[T - 14 + 1], C = e3[T - 32], D = e3[T - 32 + 1], L = P + N | 0, K = R + U + b(L, P) | 0; - K = (K = K + I + b(L = L + j | 0, j) | 0) + C + b(L = L + D | 0, D) | 0, e3[T] = K, e3[T + 1] = L; - } - for (var z = 0; z < 160; z += 2) { - K = e3[z], L = e3[z + 1]; - var q = c(r3, n2, i2), H = c(w, _, M), F = h(r3, w), V = h(w, r3), W = l(s2, E), J = l(E, s2), $ = a[z], G = a[z + 1], Z = f(s2, u2, g), Y = f(E, A, k), X = B + J | 0, Q = v + W + b(X, B) | 0; - Q = (Q = (Q = Q + Z + b(X = X + Y | 0, Y) | 0) + $ + b(X = X + G | 0, G) | 0) + K + b(X = X + L | 0, L) | 0; - var tt = V + H | 0, et = F + q + b(tt, V) | 0; - v = g, B = k, g = u2, k = A, u2 = s2, A = E, s2 = o2 + Q + b(E = S + X | 0, S) | 0, o2 = i2, S = M, i2 = n2, M = _, n2 = r3, _ = w, r3 = Q + et + b(w = X + tt | 0, X) | 0; - } - this._al = this._al + w | 0, this._bl = this._bl + _ | 0, this._cl = this._cl + M | 0, this._dl = this._dl + S | 0, this._el = this._el + E | 0, this._fl = this._fl + A | 0, this._gl = this._gl + k | 0, this._hl = this._hl + B | 0, this._ah = this._ah + r3 + b(this._al, w) | 0, this._bh = this._bh + n2 + b(this._bl, _) | 0, this._ch = this._ch + i2 + b(this._cl, M) | 0, this._dh = this._dh + o2 + b(this._dl, S) | 0, this._eh = this._eh + s2 + b(this._el, E) | 0, this._fh = this._fh + u2 + b(this._fl, A) | 0, this._gh = this._gh + g + b(this._gl, k) | 0, this._hh = this._hh + v + b(this._hl, B) | 0; - }, u.prototype._hash = function() { - var t3 = o.allocUnsafe(64); - function e3(e4, r3, n2) { - t3.writeInt32BE(e4, n2), t3.writeInt32BE(r3, n2 + 4); - } - return e3(this._ah, this._al, 0), e3(this._bh, this._bl, 8), e3(this._ch, this._cl, 16), e3(this._dh, this._dl, 24), e3(this._eh, this._el, 32), e3(this._fh, this._fl, 40), e3(this._gh, this._gl, 48), e3(this._hh, this._hl, 56), t3; - }, t2.exports = u; - }, 2830: (t2, e2, r2) => { - t2.exports = i; - var n = r2(7187).EventEmitter; - function i() { - n.call(this); - } - r2(5717)(i, n), i.Readable = r2(9481), i.Writable = r2(4229), i.Duplex = r2(6753), i.Transform = r2(4605), i.PassThrough = r2(2725), i.finished = r2(8610), i.pipeline = r2(9946), i.Stream = i, i.prototype.pipe = function(t3, e3) { - var r3 = this; - function i2(e4) { - t3.writable && t3.write(e4) === false && r3.pause && r3.pause(); - } - function o() { - r3.readable && r3.resume && r3.resume(); - } - r3.on("data", i2), t3.on("drain", o), t3._isStdio || e3 && e3.end === false || (r3.on("end", s), r3.on("close", u)); - var a = false; - function s() { - a || (a = true, t3.end()); - } - function u() { - a || (a = true, typeof t3.destroy == "function" && t3.destroy()); - } - function f(t4) { - if (c(), n.listenerCount(this, "error") === 0) - throw t4; - } - function c() { - r3.removeListener("data", i2), t3.removeListener("drain", o), r3.removeListener("end", s), r3.removeListener("close", u), r3.removeListener("error", f), t3.removeListener("error", f), r3.removeListener("end", c), r3.removeListener("close", c), t3.removeListener("close", c); - } - return r3.on("error", f), t3.on("error", f), r3.on("end", c), r3.on("close", c), t3.on("close", c), t3.emit("pipe", r3), t3; - }; - }, 2553: (t2, e2, r2) => { - var n = r2(9509).Buffer, i = n.isEncoding || function(t3) { - switch ((t3 = "" + t3) && t3.toLowerCase()) { - case "hex": - case "utf8": - case "utf-8": - case "ascii": - case "binary": - case "base64": - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - case "raw": - return true; - default: - return false; - } - }; - function o(t3) { - var e3; - switch (this.encoding = function(t4) { - var e4 = function(t5) { - if (!t5) - return "utf8"; - for (var e5; ; ) - switch (t5) { - case "utf8": - case "utf-8": - return "utf8"; - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return "utf16le"; - case "latin1": - case "binary": - return "latin1"; - case "base64": - case "ascii": - case "hex": - return t5; - default: - if (e5) - return; - t5 = ("" + t5).toLowerCase(), e5 = true; - } - }(t4); - if (typeof e4 != "string" && (n.isEncoding === i || !i(t4))) - throw new Error("Unknown encoding: " + t4); - return e4 || t4; - }(t3), this.encoding) { - case "utf16le": - this.text = u, this.end = f, e3 = 4; - break; - case "utf8": - this.fillLast = s, e3 = 4; - break; - case "base64": - this.text = c, this.end = h, e3 = 3; - break; - default: - return this.write = l, void (this.end = d); - } - this.lastNeed = 0, this.lastTotal = 0, this.lastChar = n.allocUnsafe(e3); - } - function a(t3) { - return t3 <= 127 ? 0 : t3 >> 5 == 6 ? 2 : t3 >> 4 == 14 ? 3 : t3 >> 3 == 30 ? 4 : t3 >> 6 == 2 ? -1 : -2; - } - function s(t3) { - var e3 = this.lastTotal - this.lastNeed, r3 = function(t4, e4, r4) { - if ((192 & e4[0]) != 128) - return t4.lastNeed = 0, "\uFFFD"; - if (t4.lastNeed > 1 && e4.length > 1) { - if ((192 & e4[1]) != 128) - return t4.lastNeed = 1, "\uFFFD"; - if (t4.lastNeed > 2 && e4.length > 2 && (192 & e4[2]) != 128) - return t4.lastNeed = 2, "\uFFFD"; - } - }(this, t3); - return r3 !== void 0 ? r3 : this.lastNeed <= t3.length ? (t3.copy(this.lastChar, e3, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal)) : (t3.copy(this.lastChar, e3, 0, t3.length), void (this.lastNeed -= t3.length)); - } - function u(t3, e3) { - if ((t3.length - e3) % 2 == 0) { - var r3 = t3.toString("utf16le", e3); - if (r3) { - var n2 = r3.charCodeAt(r3.length - 1); - if (n2 >= 55296 && n2 <= 56319) - return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = t3[t3.length - 2], this.lastChar[1] = t3[t3.length - 1], r3.slice(0, -1); - } - return r3; - } - return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = t3[t3.length - 1], t3.toString("utf16le", e3, t3.length - 1); - } - function f(t3) { - var e3 = t3 && t3.length ? this.write(t3) : ""; - if (this.lastNeed) { - var r3 = this.lastTotal - this.lastNeed; - return e3 + this.lastChar.toString("utf16le", 0, r3); - } - return e3; - } - function c(t3, e3) { - var r3 = (t3.length - e3) % 3; - return r3 === 0 ? t3.toString("base64", e3) : (this.lastNeed = 3 - r3, this.lastTotal = 3, r3 === 1 ? this.lastChar[0] = t3[t3.length - 1] : (this.lastChar[0] = t3[t3.length - 2], this.lastChar[1] = t3[t3.length - 1]), t3.toString("base64", e3, t3.length - r3)); - } - function h(t3) { - var e3 = t3 && t3.length ? this.write(t3) : ""; - return this.lastNeed ? e3 + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : e3; - } - function l(t3) { - return t3.toString(this.encoding); - } - function d(t3) { - return t3 && t3.length ? this.write(t3) : ""; - } - e2.s = o, o.prototype.write = function(t3) { - if (t3.length === 0) - return ""; - var e3, r3; - if (this.lastNeed) { - if ((e3 = this.fillLast(t3)) === void 0) - return ""; - r3 = this.lastNeed, this.lastNeed = 0; - } else - r3 = 0; - return r3 < t3.length ? e3 ? e3 + this.text(t3, r3) : this.text(t3, r3) : e3 || ""; - }, o.prototype.end = function(t3) { - var e3 = t3 && t3.length ? this.write(t3) : ""; - return this.lastNeed ? e3 + "\uFFFD" : e3; - }, o.prototype.text = function(t3, e3) { - var r3 = function(t4, e4, r4) { - var n3 = e4.length - 1; - if (n3 < r4) - return 0; - var i2 = a(e4[n3]); - return i2 >= 0 ? (i2 > 0 && (t4.lastNeed = i2 - 1), i2) : --n3 < r4 || i2 === -2 ? 0 : (i2 = a(e4[n3])) >= 0 ? (i2 > 0 && (t4.lastNeed = i2 - 2), i2) : --n3 < r4 || i2 === -2 ? 0 : (i2 = a(e4[n3])) >= 0 ? (i2 > 0 && (i2 === 2 ? i2 = 0 : t4.lastNeed = i2 - 3), i2) : 0; - }(this, t3, e3); - if (!this.lastNeed) - return t3.toString("utf8", e3); - this.lastTotal = r3; - var n2 = t3.length - (r3 - this.lastNeed); - return t3.copy(this.lastChar, 0, n2), t3.toString("utf8", e3, n2); - }, o.prototype.fillLast = function(t3) { - if (this.lastNeed <= t3.length) - return t3.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal); - t3.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, t3.length), this.lastNeed -= t3.length; - }; - }, 3607: function(t2, e2, r2) { - var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { - return e3[r3]; - }}); - } : function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; - }), i = this && this.__exportStar || function(t3, e3) { - for (var r3 in t3) - r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), i(r2(1999), e2), i(r2(3915), e2); - var o = r2(1417); - Object.defineProperty(e2, "base64to16", {enumerable: true, get: function() { - return o.base64to16; - }}), Object.defineProperty(e2, "encodeBase16", {enumerable: true, get: function() { - return o.encodeBase16; - }}), Object.defineProperty(e2, "decodeBase16", {enumerable: true, get: function() { - return o.decodeBase16; - }}), Object.defineProperty(e2, "encodeBase64", {enumerable: true, get: function() { - return o.encodeBase64; - }}), Object.defineProperty(e2, "decodeBase64", {enumerable: true, get: function() { - return o.decodeBase64; - }}); - }, 5050: function(t2, e2, r2) { - var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), a = this && this.__decorate || function(t3, e3, r3, n2) { - var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; - if (typeof Reflect == "object" && typeof Reflect.decorate == "function") - a2 = Reflect.decorate(t3, e3, r3, n2); - else - for (var s2 = t3.length - 1; s2 >= 0; s2--) - (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); - return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; - }, s = this && this.__metadata || function(t3, e3) { - if (typeof Reflect == "object" && typeof Reflect.metadata == "function") - return Reflect.metadata(t3, e3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.URef = e2.AccessRights = e2.KeyValue = e2.AccountHash = e2.KeyVariant = e2.CLValue = e2.CLTypedAndToBytesHelper = e2.CLTypeHelper = e2.OptionType = e2.MapValue = e2.PublicKey = e2.Tuple3 = e2.Tuple2 = e2.Tuple1 = e2.List = e2.fromBytesByCLType = e2.StringValue = e2.Unit = e2.U512 = e2.U128 = e2.I64 = e2.U64 = e2.I32 = e2.U32 = e2.U8 = e2.Bool = e2.Result = e2.FromBytesError = e2.SimpleType = e2.staticImplements = e2.CLTypedAndToBytes = void 0; - var u, f, c, h = r2(3286), l = r2(3917), d = r2(2092), p = r2(1417), y = r2(5371), m = r2(3492), b = r2(2964), g = r2(4546), v = function() { - function t3() { - } - return t3.prototype.clTypeEncoded = function() { - return G.toBytesHelper(this.clType()); - }, t3; - }(); - e2.CLTypedAndToBytes = v, e2.staticImplements = function() { - return function(t3) { - }; - }, function(t3) { - t3[t3.Bool = 0] = "Bool", t3[t3.I32 = 1] = "I32", t3[t3.I64 = 2] = "I64", t3[t3.U8 = 3] = "U8", t3[t3.U32 = 4] = "U32", t3[t3.U64 = 5] = "U64", t3[t3.U128 = 6] = "U128", t3[t3.U256 = 7] = "U256", t3[t3.U512 = 8] = "U512", t3[t3.Unit = 9] = "Unit", t3[t3.String = 10] = "String", t3[t3.Key = 11] = "Key", t3[t3.URef = 12] = "URef", t3[t3.PublicKey = 22] = "PublicKey"; - }(u = e2.SimpleType || (e2.SimpleType = {})), function(t3) { - t3[t3.Option = 13] = "Option", t3[t3.List = 14] = "List", t3[t3.ByteArray = 15] = "ByteArray", t3[t3.Result = 16] = "Result", t3[t3.Map = 17] = "Map", t3[t3.Tuple1 = 18] = "Tuple1", t3[t3.Tuple2 = 19] = "Tuple2", t3[t3.Tuple3 = 20] = "Tuple3", t3[t3.Any = 21] = "Any"; - }(f || (f = {})), function(t3) { - t3[t3.Ok = 0] = "Ok", t3[t3.EarlyEndOfStream = 1] = "EarlyEndOfStream", t3[t3.FormattingError = 2] = "FormattingError"; - }(c = e2.FromBytesError || (e2.FromBytesError = {})); - var w = function() { - function t3(t4, e3, r3) { - this.val = t4, this.rem = e3, this.error = r3; - } - return t3.Err = function(e3) { - return new t3(null, null, e3); - }, t3.Ok = function(e3, r3) { - return new t3(e3, r3, c.Ok); - }, t3.prototype.remainder = function() { - if (this.rem === null) - throw new Error("Don't have remainder"); - return this.rem; - }, t3.prototype.value = function() { - if (!this.hasValue()) - throw new Error("Don't have value"); - return this.val; - }, t3.prototype.hasValue = function() { - return this.val !== null; - }, t3.prototype.hasError = function() { - return this.error !== c.Ok; - }, t3; - }(); - e2.Result = w; - var _ = function(t3) { - function e3(e4) { - var r4 = t3.call(this) || this; - return r4.val = e4, r4; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.toBytes = function() { - return new Uint8Array([this.val ? 1 : 0]); - }, e3.prototype.clType = function() { - return u.Bool; - }, e3.fromBytes = function(t4) { - return t4.length === 0 ? w.Err(c.EarlyEndOfStream) : t4[0] === 1 ? w.Ok(new r3(true), t4.subarray(1)) : t4[0] === 0 ? w.Ok(new r3(false), t4.subarray(1)) : w.Err(c.FormattingError); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Boolean])], e3); - }(v); - e2.Bool = _; - var M = function(t3) { - function e3(e4, r3, n2) { - var i2 = t3.call(this) || this; - return i2.toBytes = function() { - return l.toBytesNumber(i2.bitSize, i2.signed, i2.val); - }, i2.name = (r3 ? "i" : "u") + e4, i2.bitSize = e4, i2.signed = r3, i2.val = d.BigNumber.from(n2), i2; - } - return o(e3, t3), e3; - }(v), S = function(t3) { - function e3(e4) { - return t3.call(this, 8, false, e4) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.U8; - }, e3.fromBytes = function(t4) { - return t4.length === 0 ? w.Err(c.EarlyEndOfStream) : w.Ok(new r3(t4[0]), t4.subarray(1)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Number])], e3); - }(M); - e2.U8 = S; - var E = function(t3) { - function e3(e4) { - return t3.call(this, 32, false, e4) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.U32; - }, e3.fromBytes = function(t4) { - if (t4.length < 4) - return w.Err(c.EarlyEndOfStream); - var e4 = i.from(t4.subarray(0, 4)).readUInt32LE(0); - return w.Ok(new r3(e4), t4.subarray(4)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Number])], e3); - }(M); - e2.U32 = E; - var A = function(t3) { - function e3(e4) { - return t3.call(this, 32, true, e4) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.I32; - }, e3.fromBytes = function(t4) { - if (t4.length < 4) - return w.Err(c.EarlyEndOfStream); - var e4 = i.from(t4.subarray(0, 4)).readInt32LE(0); - return w.Ok(new r3(e4), t4.subarray(4)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Number])], e3); - }(M); - e2.I32 = A; - var k = function(t3) { - function e3(e4) { - return t3.call(this, 64, false, e4) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.U64; - }, e3.fromBytes = function(t4) { - var e4 = Uint8Array.from(t4); - if (t4.length < 8) - return w.Err(c.EarlyEndOfStream); - var n2 = e4.subarray(0, 8), i2 = e4.subarray(8); - return w.Ok(new r3(d.BigNumber.from(n2.reverse())), i2); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Object])], e3); - }(M); - e2.U64 = k; - var B = function(t3) { - function e3(e4) { - return t3.call(this, 64, true, e4) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.I64; - }, e3.fromBytes = function(t4) { - if (t4.length < 8) - return w.Err(c.EarlyEndOfStream); - var e4 = Uint8Array.from(t4), n2 = e4.subarray(0, 8), i2 = e4.subarray(8); - return w.Ok(new r3(d.BigNumber.from(n2.reverse()).fromTwos(64)), i2); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Object])], e3); - }(M); - e2.I64 = B; - var T = function(t3) { - function e3(e4) { - return t3.call(this, 128, false, e4) || this; - } - return o(e3, t3), e3.prototype.clType = function() { - return u.U128; - }, e3.fromBytes = function(t4) { - return z(t4, 128); - }, a([function(t4) { - }, s("design:paramtypes", [Object])], e3); - }(M); - e2.U128 = T; - var x = function(t3) { - function e3(e4) { - return t3.call(this, 256, false, e4) || this; - } - return o(e3, t3), e3.prototype.clType = function() { - return u.U256; - }, e3.fromBytes = function(t4) { - return z(t4, 256); - }, a([function(t4) { - }, s("design:paramtypes", [Object])], e3); - }(M), O = function(t3) { - function e3(e4) { - return t3.call(this, 512, false, e4) || this; - } - return o(e3, t3), e3.prototype.clType = function() { - return u.U512; - }, e3.fromBytes = function(t4) { - return z(t4, 512); - }, a([function(t4) { - }, s("design:paramtypes", [Object])], e3); - }(M); - e2.U512 = O; - var R = function(t3) { - function e3() { - return t3 !== null && t3.apply(this, arguments) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.Unit; - }, e3.prototype.toBytes = function() { - return Uint8Array.from([]); - }, e3.fromBytes = function(t4) { - return w.Ok(new r3(), t4); - }, r3 = a([function(t4) { - }], e3); - }(v); - e2.Unit = R; - var P = function(t3) { - function e3(e4) { - var r4 = t3.call(this) || this; - return r4.val = e4, r4.toBytes = function() { - return l.toBytesString(r4.val); - }, r4; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.String; - }, e3.fromBytes = function(t4) { - var e4 = E.fromBytes(t4); - if (e4.hasError()) - return w.Err(e4.error); - var n2 = e4.value().val.toNumber(), o2 = i.from(e4.remainder().subarray(0, n2)).toString("utf8"); - return w.Ok(new r3(o2), e4.remainder().subarray(n2)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [String])], e3); - }(v); - e2.StringValue = P, e2.fromBytesByCLType = function(t3, e3) { - return t3 instanceof H ? j.fromBytes(t3, e3) : t3 instanceof W ? U.fromBytes(t3, e3) : t3 instanceof J ? N.fromBytes(t3, e3) : t3 instanceof $ ? C.fromBytes(t3, e3) : t3 instanceof F ? K.fromBytes(e3) : t3 instanceof V ? L.fromBytes(t3, e3) : t3 instanceof q ? y.Option.fromBytes(t3, e3) : I(t3, e3); - }; - var I = function(t3, e3) { - var r3; - switch (t3) { - case u.Bool: - r3 = _.fromBytes(e3); - break; - case u.I32: - r3 = A.fromBytes(e3); - break; - case u.I64: - r3 = B.fromBytes(e3); - break; - case u.U8: - r3 = S.fromBytes(e3); - break; - case u.U32: - r3 = E.fromBytes(e3); - break; - case u.U64: - r3 = k.fromBytes(e3); - break; - case u.U128: - r3 = T.fromBytes(e3); - break; - case u.U256: - r3 = x.fromBytes(e3); - break; - case u.U512: - r3 = O.fromBytes(e3); - break; - case u.Unit: - r3 = R.fromBytes(e3); - break; - case u.String: - r3 = P.fromBytes(e3); - break; - case u.Key: - r3 = nt.fromBytes(e3); - break; - case u.URef: - r3 = at.fromBytes(e3); - break; - case u.PublicKey: - r3 = D.fromBytes(e3); - break; - default: - r3 = w.Err(c.FormattingError); - } - return r3.hasError() ? w.Err(r3.error) : w.Ok(r3.value(), r3.remainder()); - }, j = function(t3) { - function r3(e3) { - var r4 = t3.call(this) || this; - if (r4.vec = e3, e3.length === 0) - throw new Error("Can't create instance for empty list"); - return r4; - } - return o(r3, t3), r3.prototype.clType = function() { - return G.list(this.vec[0].clType()); - }, r3.prototype.toBytes = function() { - return l.toBytesVecT(this.vec); - }, r3.fromBytes = function(t4, n2) { - var i2 = E.fromBytes(n2); - if (i2.hasError()) - return w.Err(i2.error); - for (var o2 = i2.value().val.toNumber(), a2 = [], s2 = i2.remainder(), u2 = 0; u2 < o2; u2++) { - var f2 = e2.fromBytesByCLType(t4.innerType, s2); - if (f2.hasError()) - return w.Err(f2.error); - a2.push(f2.value()), s2 = f2.remainder(); - } - return w.Ok(new r3(a2), s2); - }, r3; - }(v); - e2.List = j; - var U = function(t3) { - function r3(e3) { - var r4 = t3.call(this) || this; - return r4.v0 = e3, r4; - } - return o(r3, t3), r3.prototype.toBytes = function() { - return this.v0.toBytes(); - }, r3.prototype.clType = function() { - return G.tuple1(this.v0.clType()); - }, r3.fromBytes = function(t4, n2) { - var i2 = e2.fromBytesByCLType(t4.t0, n2); - if (i2.hasError()) - return w.Err(i2.error); - var o2 = new r3(i2.value()); - return w.Ok(o2, i2.remainder()); - }, r3; - }(v); - e2.Tuple1 = U; - var N = function(t3) { - function r3(e3, r4) { - var n2 = t3.call(this) || this; - return n2.v0 = e3, n2.v1 = r4, n2; - } - return o(r3, t3), r3.prototype.toBytes = function() { - return h.concat([this.v0.toBytes(), this.v1.toBytes()]); - }, r3.prototype.clType = function() { - return G.tuple2(this.v0.clType(), this.v1.clType()); - }, r3.fromBytes = function(t4, n2) { - var i2 = e2.fromBytesByCLType(t4.t0, n2); - if (i2.hasError()) - return w.Err(i2.error); - var o2 = e2.fromBytesByCLType(t4.t1, i2.remainder()); - if (o2.hasError()) - return w.Err(o2.error); - var a2 = new r3(i2.value(), o2.value()); - return w.Ok(a2, o2.remainder()); - }, r3; - }(v); - e2.Tuple2 = N; - var C = function(t3) { - function r3(e3, r4, n2) { - var i2 = t3.call(this) || this; - return i2.v0 = e3, i2.v1 = r4, i2.v2 = n2, i2; - } - return o(r3, t3), r3.prototype.clType = function() { - return G.tuple3(this.v0.clType(), this.v1.clType(), this.v2.clType()); - }, r3.prototype.toBytes = function() { - return h.concat([this.v0.toBytes(), this.v1.toBytes(), this.v2.toBytes()]); - }, r3.fromBytes = function(t4, n2) { - var i2 = e2.fromBytesByCLType(t4.t0, n2); - if (i2.hasError()) - return w.Err(i2.error); - var o2 = e2.fromBytesByCLType(t4.t1, i2.remainder()); - if (o2.hasError()) - return w.Err(o2.error); - var a2 = e2.fromBytesByCLType(t4.t2, o2.remainder()); - if (a2.hasError()) - return w.Err(a2.error); - var s2 = new r3(i2.value(), o2.value(), a2.value()); - return w.Ok(s2, a2.remainder()); - }, r3; - }(v); - e2.Tuple3 = C; - var D = function(t3) { - function e3(e4, r4) { - var n2 = t3.call(this) || this; - return n2.rawPublicKey = e4, n2.tag = r4, n2; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return u.PublicKey; - }, e3.prototype.toBytes = function() { - return h.concat([Uint8Array.from([this.tag]), l.toBytesBytesArray(this.rawPublicKey)]); - }, e3.prototype.toAccountHex = function() { - var t4; - switch (this.tag) { - case 1: - t4 = "01" + p.encodeBase16(this.rawPublicKey); - break; - case 2: - t4 = "02" + p.encodeBase16(this.rawPublicKey); - break; - default: - throw new Error("Unsupported type of public key"); - } - return t4; - }, e3.prototype.isEd25519 = function() { - return this.tag === 1; - }, e3.prototype.isSecp256K1 = function() { - return this.tag === 2; - }, e3.prototype.toAccountHash = function() { - var t4 = this.signatureAlgorithm(), e4 = i.from([0]), r4 = i.concat([i.from(t4.toLowerCase()), e4]); - return this.rawPublicKey.length === 0 ? i.from([]) : m.byteHash(i.concat([r4, i.from(this.rawPublicKey)])); - }, e3.fromEd25519 = function(t4) { - return new r3(t4, 1); - }, e3.fromSecp256K1 = function(t4) { - return new r3(t4, 2); - }, e3.from = function(t4, e4) { - switch (e4) { - case b.SignatureAlgorithm.Ed25519: - return r3.fromEd25519(t4); - case b.SignatureAlgorithm.Secp256K1: - return r3.fromSecp256K1(t4); - default: - throw new Error("Unsupported type of public key"); - } - }, e3.fromHex = function(t4) { - if (t4.length < 2) - throw new Error("asymmetric key error: too short"); - var e4 = p.decodeBase16(t4); - switch (e4[0]) { - case 1: - return r3.fromEd25519(e4.subarray(1)); - case 2: - return r3.fromSecp256K1(e4.subarray(1)); - default: - throw new Error("Unsupported type of public key"); - } - }, e3.prototype.signatureAlgorithm = function() { - switch (this.tag) { - case 1: - return b.SignatureAlgorithm.Ed25519; - case 2: - return b.SignatureAlgorithm.Secp256K1; - default: - throw new Error("Unsupported type of public key"); - } - }, e3.fromBytes = function(t4) { - if (t4.length < 1) - return w.Err(c.EarlyEndOfStream); - var e4, n2 = t4[0], i2 = 1; - switch (n2) { - case 1: - e4 = 32; - break; - case 2: - e4 = 33; - break; - default: - return w.Err(c.FormattingError); - } - var o2 = t4.subarray(i2, i2 + e4); - i2 += e4; - var a2 = new r3(o2, n2); - return w.Ok(a2, t4.subarray(i2)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Uint8Array, Number])], e3); - }(v); - e2.PublicKey = D; - var L = function(t3) { - function r3(e3) { - var r4 = t3.call(this) || this; - return r4.v = e3, r4; - } - return o(r3, t3), r3.prototype.toBytes = function() { - var t4 = this.v.map(function(t5) { - return h.concat([t5.key.toBytes(), t5.value.toBytes()]); - }); - return t4.splice(0, 0, l.toBytesU32(this.v.length)), h.concat(t4); - }, r3.prototype.clType = function() { - return new V(this.v[0].key.clType(), this.v[0].value.clType()); - }, r3.fromBytes = function(t4, n2) { - var i2 = E.fromBytes(n2); - if (i2.hasError()) - return w.Err(i2.error); - for (var o2 = i2.value().val.toNumber(), a2 = [], s2 = i2.remainder(), u2 = 0; u2 < o2; u2++) { - var f2 = e2.fromBytesByCLType(t4.keyType, s2); - if (f2.hasError()) - return w.Err(f2.error); - s2 = f2.remainder(); - var c2 = e2.fromBytesByCLType(t4.valueType, s2); - if (c2.hasError()) - return w.Err(c2.error); - s2 = c2.remainder(), a2.push({key: f2.value(), value: c2.value()}); - } - return w.Ok(new r3(a2), s2); - }, r3; - }(v); - e2.MapValue = L; - var K = function(t3) { - function e3(e4) { - var r4 = t3.call(this) || this; - return r4.rawBytes = e4, r4; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.clType = function() { - return G.byteArray(this.rawBytes.length); - }, e3.prototype.toBytes = function() { - return l.toBytesBytesArray(this.rawBytes); - }, e3.fromBytes = function(t4) { - var e4 = new r3(t4.subarray(0, 32)); - return w.Ok(e4, t4.subarray(32)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Uint8Array])], e3); - }(v), z = function(t3, e3) { - var r3 = e3 / 8; - if (t3.length < 1) - return w.Err(c.EarlyEndOfStream); - var n2, i2 = Uint8Array.from(t3), o2 = i2[0]; - if (o2 > r3) - return w.Err(c.FormattingError); - if (o2 + 1 > t3.length) - return w.Err(c.EarlyEndOfStream); - n2 = o2 === 0 ? [0] : i2.subarray(1, 1 + o2); - var a2 = i2.subarray(1 + o2); - return e3 === 128 ? w.Ok(new T(d.BigNumber.from(n2.reverse())), a2) : e3 === 256 ? w.Ok(new x(d.BigNumber.from(n2.reverse())), a2) : e3 === 512 ? w.Ok(new O(d.BigNumber.from(n2.reverse())), a2) : w.Err(c.FormattingError); - }, q = function() { - function t3(t4) { - this.innerType = t4, this.tag = f.Option; - } - return t3.prototype.toJSON = function() { - var e3, r3 = Y(this.innerType); - return (e3 = {})[t3.TypeId] = r3, e3; - }, t3.TypeId = "Option", t3; - }(); - e2.OptionType = q; - var H = function() { - function t3(t4) { - this.tag = f.List, this.innerType = t4; - } - return t3.prototype.toJSON = function() { - var e3, r3 = Y(this.innerType); - return (e3 = {})[t3.TypeId] = r3, e3; - }, t3.TypeId = "List", t3; - }(), F = function() { - function t3(t4) { - this.size = t4, this.tag = f.ByteArray; - } - return t3.prototype.toJSON = function() { - var e3; - return (e3 = {})[t3.TypeId] = this.size, e3; - }, t3.TypeId = "ByteArray", t3; - }(), V = function() { - function t3(t4, e3) { - this.keyType = t4, this.valueType = e3, this.tag = f.Map; - } - return t3.prototype.toJSON = function() { - var e3; - return (e3 = {})[t3.TypeId] = {key: Y(this.keyType), value: Y(this.valueType)}, e3; - }, t3.TypeId = "Map", t3; - }(), W = function() { - function t3(t4) { - this.t0 = t4, this.tag = f.Tuple1; - } - return t3.prototype.toJSON = function() { - var e3, r3 = Y(this.t0); - return (e3 = {})[t3.TypeId] = r3, e3; - }, t3.TypeId = "Tuple1", t3; - }(), J = function() { - function t3(t4, e3) { - this.t0 = t4, this.t1 = e3, this.tag = f.Tuple2; - } - return t3.prototype.toJSON = function() { - var e3, r3 = Y(this.t0), n2 = Y(this.t1); - return (e3 = {})[t3.TypeId] = [r3, n2], e3; - }, t3.TypeId = "Tuple2", t3; - }(), $ = function() { - function t3(t4, e3, r3) { - this.t0 = t4, this.t1 = e3, this.t2 = r3, this.tag = f.Tuple3; - } - return t3.prototype.toJSON = function() { - var e3, r3 = Y(this.t0), n2 = Y(this.t1), i2 = Y(this.t2); - return (e3 = {})[t3.TypeId] = [r3, n2, i2], e3; - }, t3.TypeId = "Tuple3", t3; - }(), G = function() { - function t3() { - } - return t3.u8 = function() { - return u.U8; - }, t3.u32 = function() { - return u.U32; - }, t3.u64 = function() { - return u.U64; - }, t3.u128 = function() { - return u.U128; - }, t3.u256 = function() { - return u.U256; - }, t3.u512 = function() { - return u.U512; - }, t3.i32 = function() { - return u.I32; - }, t3.i64 = function() { - return u.I64; - }, t3.bool = function() { - return u.Bool; - }, t3.unit = function() { - return u.Unit; - }, t3.string = function() { - return u.String; - }, t3.key = function() { - return u.Key; - }, t3.publicKey = function() { - return u.PublicKey; - }, t3.uRef = function() { - return u.URef; - }, t3.option = function(t4) { - return new q(t4); - }, t3.list = function(t4) { - return new H(t4); - }, t3.byteArray = function(t4) { - return new F(t4); - }, t3.map = function(t4, e3) { - return new V(t4, e3); - }, t3.tuple1 = function(t4) { - return new W(t4); - }, t3.tuple2 = function(t4, e3) { - return new J(t4, e3); - }, t3.tuple3 = function(t4, e3, r3) { - return new $(t4, e3, r3); - }, t3.fromBytes = function(e3) { - if (e3.length < 1) - return w.Err(c.EarlyEndOfStream); - var r3 = e3[0], n2 = e3.subarray(1); - switch (r3) { - case u.Bool: - case u.I32: - case u.I64: - case u.U8: - case u.U32: - case u.U64: - case u.U256: - case u.U512: - case u.Unit: - case u.String: - case u.Key: - case u.URef: - case u.PublicKey: - return w.Ok(r3, n2); - case f.Option: - return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.option(s2.value()), s2.remainder()); - case f.List: - return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.list(s2.value()), s2.remainder()); - case f.ByteArray: - var i2 = E.fromBytes(n2); - return i2.hasError() ? w.Err(i2.error) : w.Ok(t3.byteArray(i2.value().val.toNumber()), i2.remainder()); - case f.Result: - throw new Error("Result type is unsupported now"); - case f.Map: - var o2 = t3.fromBytes(n2); - if (o2.hasError()) - return w.Err(o2.error); - var a2 = t3.fromBytes(o2.remainder()); - return a2.hasError() ? w.Err(a2.error) : w.Ok(t3.map(o2.value(), a2.value()), a2.remainder()); - case f.Tuple1: - var s2; - return (s2 = t3.fromBytes(n2)).hasError() ? w.Err(s2.error) : w.Ok(t3.tuple1(s2.value()), s2.remainder()); - case f.Tuple2: - return (h2 = t3.fromBytes(n2)).hasError() ? w.Err(h2.error) : (l2 = t3.fromBytes(h2.remainder())).hasError() ? w.Err(l2.error) : w.Ok(t3.tuple2(h2.value(), l2.value()), l2.remainder()); - case f.Tuple3: - var h2, l2; - if ((h2 = t3.fromBytes(n2)).hasError()) - return w.Err(h2.error); - if ((l2 = t3.fromBytes(h2.remainder())).hasError()) - return w.Err(l2.error); - var d2 = t3.fromBytes(h2.remainder()); - return d2.hasError() ? w.Err(d2.error) : w.Ok(t3.tuple3(h2.value(), l2.value(), d2.value()), d2.remainder()); - case f.Any: - throw new Error("Any type is unsupported now"); - default: - return w.Err(c.FormattingError); - } - }, t3.toBytesHelper = function(e3) { - if (e3 instanceof H) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.innerType)]); - if (e3 instanceof W) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0)]); - if (e3 instanceof J) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0), t3.toBytesHelper(e3.t1)]); - if (e3 instanceof $) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.t0), t3.toBytesHelper(e3.t1), t3.toBytesHelper(e3.t2)]); - if (e3 instanceof F) - return h.concat([Uint8Array.from([e3.tag]), l.toBytesU32(e3.size)]); - if (e3 instanceof V) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.keyType), t3.toBytesHelper(e3.valueType)]); - if (e3 instanceof q) - return h.concat([Uint8Array.from([e3.tag]), t3.toBytesHelper(e3.innerType)]); - switch (e3) { - case u.Bool: - case u.I32: - case u.I64: - case u.U8: - case u.U32: - case u.U64: - case u.U128: - case u.U256: - case u.U512: - case u.Unit: - case u.String: - case u.Key: - case u.URef: - case u.PublicKey: - return Uint8Array.from([e3]); - default: - throw new Error("Wrong type"); - } - }, t3; - }(); - e2.CLTypeHelper = G; - var Z = function() { - function t3() { - } - return t3.list = function(t4) { - return new j(t4); - }, t3.tuple1 = function(t4) { - return new U(t4); - }, t3.tuple2 = function(t4, e3) { - return new N(t4, e3); - }, t3.tuple3 = function(t4, e3, r3) { - return new C(t4, e3, r3); - }, t3.option = function(t4, e3) { - return new y.Option(t4, e3); - }, t3.map = function(t4) { - return new L(t4); - }, t3.publicKey = function(t4) { - return D.fromEd25519(t4); - }, t3.bytes = function(t4) { - return new K(t4); - }, t3.bool = function(t4) { - return new _(t4); - }, t3.u8 = function(t4) { - return new S(t4); - }, t3.u32 = function(t4) { - return new E(t4); - }, t3.i32 = function(t4) { - return new A(t4); - }, t3.u64 = function(t4) { - return new k(t4); - }, t3.i64 = function(t4) { - return new B(t4); - }, t3.u128 = function(t4) { - return new T(t4); - }, t3.u256 = function(t4) { - return new x(t4); - }, t3.u512 = function(t4) { - return new O(t4); - }, t3.unit = function() { - return new R(); - }, t3.string = function(t4) { - return new P(t4); - }, t3; - }(); - e2.CLTypedAndToBytesHelper = Z; - var Y = function(t3) { - return t3 instanceof H || t3 instanceof W || t3 instanceof J || t3 instanceof $ || t3 instanceof F || t3 instanceof V || t3 instanceof q ? t3.toJSON() : function(t4) { - switch (t4) { - case u.Bool: - return "Bool"; - case u.I32: - return "I32"; - case u.I64: - return "I64"; - case u.U8: - return "U8"; - case u.U32: - return "U32"; - case u.U64: - return "U64"; - case u.U128: - return "U128"; - case u.U256: - return "U256"; - case u.U512: - return "U512"; - case u.Unit: - return "Unit"; - case u.String: - return "String"; - case u.Key: - return "Key"; - case u.URef: - return "URef"; - case u.PublicKey: - return "PublicKey"; - } - }(t3); - }, X = function(t3) { - if (typeof t3 == "string") - return function(t4) { - switch (t4) { - case "Bool": - return u.Bool; - case "I32": - return u.I32; - case "I64": - return u.I64; - case "U8": - return u.U8; - case "U32": - return u.U32; - case "U64": - return u.U64; - case "U128": - return u.U128; - case "U256": - return u.U256; - case "U512": - return u.U512; - case "Unit": - return u.Unit; - case "String": - return u.String; - case "Key": - return u.Key; - case "URef": - return u.URef; - case "PublicKey": - return u.PublicKey; - default: - throw new Error("The type " + t4 + " is not supported"); - } - }(t3); - if (typeof t3 == typeof {}) { - if (H.TypeId in t3) { - var e3 = X(t3[H.TypeId]); - return G.list(e3); - } - if (W.TypeId in t3) { - var r3 = X(t3[W.TypeId][0]); - return G.tuple1(r3); - } - if (J.TypeId in t3) { - var n2 = t3[J.TypeId], i2 = (r3 = X(n2[0]), X(n2[1])); - return G.tuple2(r3, i2); - } - if ($.TypeId in t3) { - n2 = t3[J.TypeId], r3 = X(n2[0]), i2 = X(n2[1]); - var o2 = X(n2[2]); - return G.tuple3(r3, i2, o2); - } - if (F.TypeId in t3) { - var a2 = t3[F.TypeId]; - return G.byteArray(a2); - } - if (q.TypeId in t3) - return e3 = X(t3[q.TypeId]), G.option(e3); - if (V.TypeId in t3) { - var s2 = X(t3[V.TypeId].key), f2 = X(t3[V.TypeId].value); - return G.map(s2, f2); - } - throw new Error("The type " + t3 + " is not supported"); - } - throw new Error("The type " + t3 + " is not supported"); - }; - function Q(t3, r3) { - var n2 = e2.fromBytesByCLType(t3.clType, p.decodeBase16(t3.bytes)); - return et.fromT(n2.value()); - } - var tt, et = function() { - function t3(t4, e3) { - this.value = t4, this.clType = e3, this.bytes = p.encodeBase16(this.value.toBytes()); - } - var r3; - return r3 = t3, t3.prototype.clValueBytes = function() { - return this.value.toBytes(); - }, t3.fromT = function(t4) { - return new r3(t4, t4.clType()); - }, t3.prototype.toBytes = function() { - return h.concat([l.toBytesArrayU8(this.clValueBytes()), G.toBytesHelper(this.clType)]); - }, t3.fromBytes = function(t4) { - var n2 = K.fromBytes(t4); - if (n2.hasError()) - return w.Err(n2.error); - var i2 = G.fromBytes(n2.remainder()); - if (i2.hasError()) - return w.Err(i2.error); - var o2 = e2.fromBytesByCLType(i2.value(), n2.value().rawBytes), a2 = new r3(o2.value(), i2.value()); - return w.Ok(a2, i2.remainder()); - }, t3.prototype.reconstruct = function() { - var t4 = e2.fromBytesByCLType(this.clType, p.decodeBase16(this.bytes)); - if (t4.hasError()) - throw new Error("Failed to deserialize CLValue"); - this.value = t4.value(); - }, t3.list = function(t4) { - return r3.fromT(new j(t4)); - }, t3.tuple1 = function(t4) { - return r3.fromT(new U(t4)); - }, t3.tuple2 = function(t4, e3) { - return r3.fromT(new N(t4, e3)); - }, t3.tuple3 = function(t4, e3, n2) { - return r3.fromT(new C(t4, e3, n2)); - }, t3.option = function(t4, e3) { - return r3.fromT(new y.Option(t4, e3)); - }, t3.map = function(t4) { - return r3.fromT(new L(t4)); - }, t3.publicKey = function(t4) { - return r3.fromT(t4); - }, t3.byteArray = function(t4) { - return r3.fromT(new K(t4)); - }, t3.prototype.isBigNumber = function() { - return this.clType === u.U8 || this.clType === u.I32 || this.clType === u.I64 || this.clType === u.U32 || this.clType === u.U64 || this.clType === u.U128 || this.clType === u.U256 || this.clType === u.U512; - }, t3.prototype.asBigNumber = function() { - if (this.isBigNumber()) { - var t4 = this.value; - return d.BigNumber.from(t4.val); - } - throw new Error("The CLValue is not an instance of BigNumber"); - }, t3.prototype.isBoolean = function() { - return this.clType === u.Bool; - }, t3.prototype.asBoolean = function() { - if (!this.isBoolean()) - throw new Error("The CLValue is not an instance of Boolean"); - return this.value.val; - }, t3.prototype.isString = function() { - return this.clType === u.String; - }, t3.prototype.asString = function() { - if (!this.isString()) - throw new Error("The CLValue is not an instance of String"); - return this.value.val; - }, t3.prototype.isPublicKey = function() { - return this.clType === u.PublicKey; - }, t3.prototype.asPublicKey = function() { - if (!this.isPublicKey()) - throw new Error("The CLValue is not an instance of PublicKey"); - return this.value; - }, t3.prototype.isKey = function() { - return this.clType === u.Key; - }, t3.prototype.asKey = function() { - if (!this.isKey()) - throw new Error("The CLValue is not an instance of Key"); - return this.value; - }, t3.prototype.isURef = function() { - return this.clType === u.URef; - }, t3.prototype.asURef = function() { - if (!this.isURef()) - throw new Error("The CLValue is not an instance of URef"); - return this.value; - }, t3.prototype.isBytesArray = function() { - return this.clType instanceof F; - }, t3.prototype.asBytesArray = function() { - if (!this.isBytesArray()) - throw new Error("The CLValue is not an instance of BytesArray"); - return this.value.toBytes(); - }, t3.prototype.isOption = function() { - return this.clType instanceof q; - }, t3.prototype.asOption = function() { - if (!this.isOption()) - throw new Error("The CLValue is not an instance of Option"); - return this.value; - }, t3.prototype.isList = function() { - return this.clType instanceof H; - }, t3.prototype.asList = function() { - if (!this.isList()) - throw new Error("The CLValue is not an instance of List"); - var t4 = this.clType, e3 = j.fromBytes(t4, this.clValueBytes()); - if (e3.hasError()) - throw new Error("The CLValue can not be parsed to list."); - return e3.value().vec.map(function(t5) { - return r3.fromT(t5); - }); - }, t3.bool = function(t4) { - return r3.fromT(new _(t4)); - }, t3.u8 = function(t4) { - return r3.fromT(new S(t4)); - }, t3.u32 = function(t4) { - return r3.fromT(new E(t4)); - }, t3.i32 = function(t4) { - return r3.fromT(new A(t4)); - }, t3.u64 = function(t4) { - return r3.fromT(new k(t4)); - }, t3.i64 = function(t4) { - return r3.fromT(new B(t4)); - }, t3.u128 = function(t4) { - return r3.fromT(new T(t4)); - }, t3.u256 = function(t4) { - return r3.fromT(new x(t4)); - }, t3.u512 = function(t4) { - return r3.fromT(new O(t4)); - }, t3.unit = function() { - return r3.fromT(new R()); - }, t3.string = function(t4) { - return r3.fromT(new P(t4)); - }, t3.key = function(t4) { - return r3.fromT(t4); - }, t3.uref = function(t4) { - return r3.fromT(t4); - }, t3.stringList = function(t4) { - var e3 = Z.list(t4.map(function(t5) { - return Z.string(t5); - })); - return new r3(e3, G.list(u.String)); - }, a([g.jsonMember({name: "cl_type", serializer: Y, deserializer: X}), s("design:type", Object)], t3.prototype, "clType", void 0), a([g.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "bytes", void 0), a([g.jsonMember({serializer: function(t4) { - return "null"; - }, deserializer: function(t4) { - return null; - }}), s("design:type", Object)], t3.prototype, "parsed", void 0), r3 = a([g.jsonObject({initializer: function(t4, e3) { - return Q(t4); - }}), s("design:paramtypes", [v, Object])], t3); - }(); - e2.CLValue = et, function(t3) { - t3[t3.ACCOUNT_ID = 0] = "ACCOUNT_ID", t3[t3.HASH_ID = 1] = "HASH_ID", t3[t3.UREF_ID = 2] = "UREF_ID"; - }(tt = e2.KeyVariant || (e2.KeyVariant = {})); - var rt = function(t3) { - function e3(e4) { - var r4 = t3.call(this) || this; - return r4.bytes = e4, r4; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.toBytes = function() { - return this.bytes; - }, e3.prototype.clType = function() { - return G.byteArray(32); - }, e3.fromBytes = function(t4) { - if (t4.length < 32) - return w.Err(c.EarlyEndOfStream); - var e4 = t4.subarray(0, 32), n2 = new r3(e4); - return w.Ok(n2, t4.subarray(32)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Uint8Array])], e3); - }(v); - e2.AccountHash = rt; - var nt = function(t3) { - function e3() { - return t3 !== null && t3.apply(this, arguments) || this; - } - var r3; - return o(e3, t3), r3 = e3, e3.prototype.isHash = function() { - return this.variant === tt.HASH_ID; - }, e3.prototype.isURef = function() { - return this.variant === tt.UREF_ID; - }, e3.prototype.isAccount = function() { - return this.variant === tt.ACCOUNT_ID; - }, e3.fromURef = function(t4) { - var e4 = new r3(); - return e4.variant = tt.UREF_ID, e4.uRef = t4, e4; - }, e3.fromHash = function(t4) { - var e4 = new r3(); - return e4.variant = tt.HASH_ID, e4.hash = t4, e4; - }, e3.fromAccount = function(t4) { - var e4 = new r3(); - return e4.variant = tt.ACCOUNT_ID, e4.account = t4, e4; - }, e3.prototype.clType = function() { - return u.Key; - }, e3.prototype.toBytes = function() { - if (this.variant === tt.ACCOUNT_ID) - return h.concat([Uint8Array.from([this.variant]), this.account.toBytes()]); - if (this.variant === tt.HASH_ID) - return h.concat([Uint8Array.from([this.variant]), this.hash]); - if (this.variant === tt.UREF_ID) - return h.concat([Uint8Array.from([this.variant]), this.uRef.toBytes()]); - throw new Error("Unknown variant"); - }, e3.fromBytes = function(t4) { - if (t4.length < 1) - return w.Err(c.EarlyEndOfStream); - var e4 = t4[0], n2 = 1; - if (e4 === tt.HASH_ID) { - var i2 = t4.subarray(n2, 32 + n2); - n2 += 32; - var o2 = r3.fromHash(i2); - return w.Ok(o2, t4.subarray(n2)); - } - if (e4 === tt.UREF_ID) { - var a2 = t4.subarray(1), s2 = at.fromBytes(a2); - return s2.hasError() ? w.Err(s2.error) : (o2 = r3.fromURef(s2.value()), w.Ok(o2, s2.remainder())); - } - if (e4 === tt.ACCOUNT_ID) { - var u2 = t4.subarray(1), f2 = rt.fromBytes(u2); - return f2.hasError() ? w.Err(f2.error) : (o2 = r3.fromAccount(f2.value()), w.Ok(o2, f2.remainder())); - } - return w.Err(c.FormattingError); - }, r3 = a([function(t4) { - }], e3); - }(v); - e2.KeyValue = nt; - var it, ot = "uref-"; - (it = e2.AccessRights || (e2.AccessRights = {}))[it.None = 0] = "None", it[it.READ = 1] = "READ", it[it.WRITE = 2] = "WRITE", it[it.ADD = 4] = "ADD", it[it.READ_WRITE = 3] = "READ_WRITE", it[it.READ_ADD = 5] = "READ_ADD", it[it.ADD_WRITE = 6] = "ADD_WRITE", it[it.READ_ADD_WRITE = 7] = "READ_ADD_WRITE"; - var at = function(t3) { - function e3(e4, r4) { - var n2 = t3.call(this) || this; - if (n2.uRefAddr = e4, n2.accessRights = r4, n2.uRefAddr.byteLength !== 32) - throw new Error("The length of URefAddr should be 32"); - return n2; - } - var r3; - return o(e3, t3), r3 = e3, e3.fromFormattedStr = function(t4) { - if (!t4.startsWith(ot)) - throw new Error("prefix is not 'uref-'"); - var e4 = t4.substring(ot.length).split("-", 2); - if (e4.length !== 2) - throw new Error("no access rights as suffix"); - var n2 = p.decodeBase16(e4[0]), i2 = parseInt(e4[1], 8); - return new r3(n2, i2); - }, e3.prototype.toFormattedStr = function() { - return [ot, p.encodeBase16(this.uRefAddr), this.accessRights.toString(8)].join("-"); - }, e3.prototype.toBytes = function() { - return h.concat([this.uRefAddr, Uint8Array.from([this.accessRights])]); - }, e3.prototype.clType = function() { - return G.uRef(); - }, e3.fromBytes = function(t4) { - if (t4.length < 33) - return w.Err(c.EarlyEndOfStream); - var e4 = t4.subarray(0, 32), n2 = t4[32], i2 = new r3(e4, n2); - return w.Ok(i2, t4.subarray(33)); - }, r3 = a([function(t4) { - }, s("design:paramtypes", [Uint8Array, Number])], e3); - }(v); - e2.URef = at; - }, 3368: function(t2, e2, r2) { - var n = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u2(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u2(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u2(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u2((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, i = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperClient = void 0; - var o = r2(1999), a = r2(3915), s = r2(1417), u = r2(2964), f = r2(3655), c = r2(2092), h = function() { - function t3(t4) { - this.nodeClient = new o.CasperServiceByJsonRPC(t4); - } - return t3.prototype.newKeyPair = function(t4) { - switch (t4) { - case u.SignatureAlgorithm.Ed25519: - return a.Keys.Ed25519.new(); - case u.SignatureAlgorithm.Secp256K1: - return a.Keys.Secp256K1.new(); - default: - throw new Error("Invalid signature algorithm"); - } - }, t3.prototype.loadPublicKeyFromFile = function(t4, e3) { - switch (e3) { - case u.SignatureAlgorithm.Ed25519: - return a.Keys.Ed25519.parsePublicKeyFile(t4); - case u.SignatureAlgorithm.Secp256K1: - return a.Keys.Secp256K1.parsePublicKeyFile(t4); - default: - throw new Error("Invalid signature algorithm"); - } - }, t3.prototype.loadPrivateKeyFromFile = function(t4, e3) { - switch (e3) { - case u.SignatureAlgorithm.Ed25519: - return a.Keys.Ed25519.parsePrivateKeyFile(t4); - case u.SignatureAlgorithm.Secp256K1: - return a.Keys.Secp256K1.parsePrivateKeyFile(t4); - default: - throw new Error("Invalid signature algorithm"); - } - }, t3.prototype.loadKeyPairFromPrivateFile = function(t4, e3) { - switch (e3) { - case u.SignatureAlgorithm.Ed25519: - return a.Keys.Ed25519.loadKeyPairFromPrivateFile(t4); - case u.SignatureAlgorithm.Secp256K1: - return a.Keys.Secp256K1.loadKeyPairFromPrivateFile(t4); - default: - throw new Error("Invalid signature algorithm"); - } - }, t3.prototype.newHdWallet = function(t4) { - return f.CasperHDKey.fromMasterSeed(t4); - }, t3.prototype.privateToPublicKey = function(t4, e3) { - switch (e3) { - case u.SignatureAlgorithm.Ed25519: - return a.Keys.Ed25519.privateToPublicKey(t4); - case u.SignatureAlgorithm.Secp256K1: - return a.Keys.Secp256K1.privateToPublicKey(t4); - default: - throw new Error("Invalid signature algorithm"); - } - }, t3.prototype.makeDeploy = function(t4, e3, r3) { - return a.DeployUtil.makeDeploy(t4, e3, r3); - }, t3.prototype.signDeploy = function(t4, e3) { - return a.DeployUtil.signDeploy(t4, e3); - }, t3.prototype.putDeploy = function(t4) { - return this.nodeClient.deploy(t4).then(function(t5) { - return t5.deploy_hash; - }); - }, t3.prototype.deployToJson = function(t4) { - return a.DeployUtil.deployToJson(t4); - }, t3.prototype.deployFromJson = function(t4) { - return a.DeployUtil.deployFromJson(t4); - }, t3.prototype.makeTransferDeploy = function(t4, e3, r3) { - if (!e3.isTransfer()) - throw new Error("The session is not a Transfer ExecutableDeployItem"); - return this.makeDeploy(t4, e3, r3); - }, t3.prototype.balanceOfByPublicKey = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - return [2, this.balanceOfByAccountHash(s.encodeBase16(t4.toAccountHash()))]; - }); - }); - }, t3.prototype.balanceOfByAccountHash = function(t4) { - return n(this, void 0, void 0, function() { - var e3, r3; - return i(this, function(n2) { - switch (n2.label) { - case 0: - return n2.trys.push([0, 4, , 5]), [4, this.nodeClient.getLatestBlockInfo().then(function(t5) { - var e4; - return (e4 = t5.block) === null || e4 === void 0 ? void 0 : e4.header.state_root_hash; - })]; - case 1: - return (e3 = n2.sent()) ? [4, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(e3, t4)] : [2, c.BigNumber.from(0)]; - case 2: - return (r3 = n2.sent()) ? [4, this.nodeClient.getAccountBalance(e3, r3)] : [2, c.BigNumber.from(0)]; - case 3: - return [2, n2.sent()]; - case 4: - return n2.sent(), [2, c.BigNumber.from(0)]; - case 5: - return [2]; - } - }); - }); - }, t3.prototype.getDeploy = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, this.nodeClient.getDeployInfo(t4).then(function(t5) { - return [a.DeployUtil.deployFromJson(t5), t5]; - })]; - case 1: - return [2, e3.sent()]; - } - }); - }); - }, t3.prototype.getAccountMainPurseUref = function(t4) { - return n(this, void 0, void 0, function() { - var e3; - return i(this, function(r3) { - switch (r3.label) { - case 0: - return [4, this.nodeClient.getLatestBlockInfo().then(function(t5) { - var e4; - return (e4 = t5.block) === null || e4 === void 0 ? void 0 : e4.header.state_root_hash; - })]; - case 1: - return (e3 = r3.sent()) ? [4, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(e3, s.encodeBase16(t4.toAccountHash()))] : [2, null]; - case 2: - return [2, r3.sent()]; - } - }); - }); - }, t3; - }(); - e2.CasperClient = h; - }, 3655: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperHDKey = void 0; - var i = r2(949), o = r2(4237), a = r2(2964), s = function() { - function t3(t4) { - this.hdKey = t4, this.bip44Index = 506; - } - return t3.prototype.bip44Path = function(t4) { - return ["m", "44'", this.bip44Index + "'", "0'", "0", "" + t4].join("/"); - }, t3.fromMasterSeed = function(e3) { - return new t3(i.HDKey.fromMasterSeed(n.from(e3))); - }, t3.prototype.publicKey = function() { - return this.hdKey.publicKey; - }, t3.prototype.privateKey = function() { - return this.hdKey.privateKey; - }, t3.prototype.privateExtendedKey = function() { - return this.hdKey.privateExtendedKey; - }, t3.prototype.publicExtendedKey = function() { - return this.hdKey.publicExtendedKey; - }, t3.prototype.derive = function(t4) { - var e3 = this.hdKey.derive(t4); - return new a.Secp256K1(new Uint8Array(e3.publicKey), new Uint8Array(e3.privateKey)); - }, t3.prototype.deriveIndex = function(t4) { - return this.derive(this.bip44Path(t4)); - }, t3.prototype.sign = function(t4) { - return this.hdKey.sign(o.sha256(n.from(t4))); - }, t3.prototype.verify = function(t4, e3) { - return this.hdKey.verify(o.sha256(n.from(e3)), n.from(t4)); - }, t3.prototype.toJSON = function() { - return this.hdKey.toJSON(); - }, t3; - }(); - e2.CasperHDKey = s; - }, 3492: function(t2, e2, r2) { - var n = r2(8764).Buffer, i = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { - return e3[r3]; - }}); - } : function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; - }), o = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { - Object.defineProperty(t3, "default", {enumerable: true, value: e3}); - } : function(t3, e3) { - t3.default = e3; - }), a = this && this.__importStar || function(t3) { - if (t3 && t3.__esModule) - return t3; - var e3 = {}; - if (t3 != null) - for (var r3 in t3) - r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && i(e3, t3, r3); - return o(e3, t3), e3; - }, s = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.Transfer = e2.Faucet = e2.BoundContract = e2.Contract = e2.byteHash = void 0; - var u = s(r2(1191)), f = a(r2(2349)), c = a(r2(4922)), h = r2(4922), l = r2(6349), d = r2(5050); - e2.byteHash = function(t3) { - return u.default.blake2b(t3, null, 32); - }; - var p = function() { - function t3(t4, e3) { - this.sessionWasm = f.readFileSync(t4), this.paymentWasm = e3 ? f.readFileSync(e3) : n.from(""); - } - return t3.prototype.deploy = function(t4, e3, r3, n2, i2) { - var o2 = h.ExecutableDeployItem.newModuleBytes(this.sessionWasm, t4), a2 = l.RuntimeArgs.fromMap({amount: d.CLValue.u512(e3.toString())}), s2 = h.ExecutableDeployItem.newModuleBytes(this.paymentWasm, a2), u2 = c.makeDeploy(new h.DeployParams(r3, i2), o2, s2); - return c.signDeploy(u2, n2); - }, t3; - }(); - e2.Contract = p; - var y = function() { - function t3(t4, e3) { - this.contract = t4, this.contractKeyPair = e3; - } - return t3.prototype.deploy = function(t4, e3, r3) { - return this.contract.deploy(t4, e3, this.contractKeyPair.publicKey, this.contractKeyPair, r3); - }, t3; - }(); - e2.BoundContract = y; - var m = function() { - function t3() { - } - return t3.args = function(t4) { - var e3 = d.KeyValue.fromAccount(new d.AccountHash(t4)); - return l.RuntimeArgs.fromMap({account: d.CLValue.key(e3)}); - }, t3; - }(); - e2.Faucet = m; - var b = function() { - function t3() { - } - return t3.args = function(t4, e3) { - var r3 = d.CLValue.key(d.KeyValue.fromAccount(new d.AccountHash(t4))); - return l.RuntimeArgs.fromMap({account: r3, amount: d.CLValue.u512(e3.toString())}); - }, t3; - }(); - e2.Transfer = b; - }, 1417: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}), e2.decodeBase16 = e2.encodeBase16 = e2.base64to16 = void 0; - var i = r2(6885), o = r2(6885); - function a(t3) { - return n.from(t3).toString("hex"); - } - Object.defineProperty(e2, "encodeBase64", {enumerable: true, get: function() { - return o.encodeBase64; - }}), Object.defineProperty(e2, "decodeBase64", {enumerable: true, get: function() { - return o.decodeBase64; - }}), e2.base64to16 = function(t3) { - return a(i.decodeBase64(t3)); - }, e2.encodeBase16 = a, e2.decodeBase16 = function(t3) { - return new Uint8Array(n.from(t3, "hex")); - }; - }, 4922: function(t2, e2, r2) { - var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), a = this && this.__decorate || function(t3, e3, r3, n2) { - var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; - if (typeof Reflect == "object" && typeof Reflect.decorate == "function") - a2 = Reflect.decorate(t3, e3, r3, n2); - else - for (var s2 = t3.length - 1; s2 >= 0; s2--) - (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); - return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; - }, s = this && this.__metadata || function(t3, e3) { - if (typeof Reflect == "object" && typeof Reflect.metadata == "function") - return Reflect.metadata(t3, e3); - }, u = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.deployToBytes = e2.validateDeploy = e2.deploySizeInBytes = e2.addArgToDeploy = e2.deployFromJson = e2.deployToJson = e2.standardPayment = e2.setSignature = e2.signDeploy = e2.makeDeploy = e2.DeployParams = e2.ContractType = e2.serializeApprovals = e2.serializeBody = e2.serializeHeader = e2.Deploy = e2.ExecutableDeployItem = e2.Transfer = e2.StoredVersionedContractByHash = e2.StoredVersionedContractByName = e2.StoredContractByName = e2.StoredContractByHash = e2.ModuleBytes = e2.Approval = e2.DeployHeader = e2.UniqAddress = e2.dehumanizerTTL = e2.humanizerTTL = void 0; - var f = r2(3286), c = u(r2(1191)), h = r2(5371), l = r2(1417), d = u(r2(9695)), p = r2(5050), y = r2(3917), m = r2(6349), b = r2(3915), g = r2(2964), v = r2(2092), w = r2(4546), _ = r2(6811), M = r2(2831), S = d.default.humanizer({spacer: "", serialComma: false, conjunction: " ", delimiter: " ", language: "shortEn", languages: {shortEn: {d: function() { - return "day"; - }, h: function() { - return "h"; - }, m: function() { - return "m"; - }, s: function() { - return "s"; - }, ms: function() { - return "ms"; - }}}}), E = function(t3) { - return l.encodeBase16(t3); - }, A = function(t3) { - return l.decodeBase16(t3); - }; - e2.humanizerTTL = function(t3) { - return S(t3); - }, e2.dehumanizerTTL = function(t3) { - return t3.split(" ").map(function(t4) { - if (t4.includes("ms")) - return Number(t4.replace("ms", "")); - if (t4.includes("s") && !t4.includes("m")) - return 1e3 * Number(t4.replace("s", "")); - if (t4.includes("m") && !t4.includes("s")) - return 60 * Number(t4.replace("m", "")) * 1e3; - if (t4.includes("h")) - return 60 * Number(t4.replace("h", "")) * 60 * 1e3; - if (t4.includes("day")) - return 24 * Number(t4.replace("day", "")) * 60 * 60 * 1e3; - throw Error("Unsuported TTL unit"); - }).reduce(function(t4, e3) { - return t4 + e3; - }); - }; - var k = function() { - function t3(t4, e3) { - if (!(t4 instanceof p.PublicKey)) - throw new Error("publicKey is not an instance of PublicKey"); - var r3 = v.BigNumber.from(e3); - if (r3.gt("18446744073709551615")) - throw new Error("transferId max value is U64"); - this.transferId = r3, this.publicKey = t4; - } - return t3.prototype.toString = function() { - return this.publicKey.toAccountHex() + "-" + this.transferId.toHexString(); - }, t3.fromString = function(e3) { - var r3 = e3.split("-"), n2 = r3[0], i2 = r3[1]; - return new t3(p.PublicKey.fromHex(n2), i2); - }, t3; - }(); - e2.UniqAddress = k; - var B = function() { - function t3(t4, e3, r3, n2, i2, o2, a2) { - this.account = t4, this.timestamp = e3, this.ttl = r3, this.gasPrice = n2, this.bodyHash = i2, this.dependencies = o2, this.chainName = a2; - } - return t3.prototype.toBytes = function() { - return f.concat([this.account.toBytes(), y.toBytesU64(this.timestamp), y.toBytesU64(this.ttl), y.toBytesU64(this.gasPrice), y.toBytesDeployHash(this.bodyHash), y.toBytesVecT(this.dependencies.map(function(t4) { - return new T(t4); - })), y.toBytesString(this.chainName)]); - }, a([w.jsonMember({serializer: function(t4) { - return t4.toAccountHex(); - }, deserializer: function(t4) { - return p.PublicKey.fromHex(t4); - }}), s("design:type", p.PublicKey)], t3.prototype, "account", void 0), a([w.jsonMember({serializer: function(t4) { - return new Date(t4).toISOString(); - }, deserializer: function(t4) { - return Date.parse(t4); - }}), s("design:type", Number)], t3.prototype, "timestamp", void 0), a([w.jsonMember({serializer: e2.humanizerTTL, deserializer: e2.dehumanizerTTL}), s("design:type", Number)], t3.prototype, "ttl", void 0), a([w.jsonMember({constructor: Number, name: "gas_price"}), s("design:type", Number)], t3.prototype, "gasPrice", void 0), a([w.jsonMember({name: "body_hash", serializer: E, deserializer: A}), s("design:type", Uint8Array)], t3.prototype, "bodyHash", void 0), a([w.jsonArrayMember(_.ByteArray, {serializer: function(t4) { - return t4.map(function(t5) { - return E(t5); - }); - }, deserializer: function(t4) { - return t4.map(function(t5) { - return A(t5); - }); - }}), s("design:type", Array)], t3.prototype, "dependencies", void 0), a([w.jsonMember({name: "chain_name", constructor: String}), s("design:type", String)], t3.prototype, "chainName", void 0), a([w.jsonObject, s("design:paramtypes", [p.PublicKey, Number, Number, Number, Uint8Array, Array, String])], t3); - }(); - e2.DeployHeader = B; - var T = function() { - function t3(t4) { - this.hash = t4; - } - return t3.prototype.toBytes = function() { - return y.toBytesDeployHash(this.hash); - }, t3; - }(), x = function() { - function t3() { - } - return a([w.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "signer", void 0), a([w.jsonMember({constructor: String}), s("design:type", String)], t3.prototype, "signature", void 0), a([w.jsonObject], t3); - }(); - e2.Approval = x; - var O = function() { - function t3() { - } - return t3.prototype.getArgByName = function(t4) { - return this.args.args.get(t4); - }, t3.prototype.setArg = function(t4, e3) { - this.args.args.set(t4, e3); - }, t3; - }(), R = function(t3) { - var e3 = {args: t3}; - return new w.TypedJSON(m.RuntimeArgs).parse(e3); - }, P = function(t3) { - var e3 = new w.TypedJSON(m.RuntimeArgs).toPlainJson(t3); - return Object.values(e3)[0]; - }, I = function(t3) { - function e3(e4, r3) { - var n2 = t3.call(this) || this; - return n2.tag = 0, n2.moduleBytes = e4, n2.args = r3, n2; - } - return o(e3, t3), e3.prototype.toBytes = function() { - return f.concat([Uint8Array.from([this.tag]), y.toBytesArrayU8(this.moduleBytes), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({name: "module_bytes", serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "moduleBytes", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, m.RuntimeArgs])], e3); - }(O); - e2.ModuleBytes = I; - var j = function(t3) { - function e3(e4, r3, n2) { - var i2 = t3.call(this) || this; - return i2.tag = 1, i2.entryPoint = r3, i2.args = n2, i2.hash = e4, i2; - } - return o(e3, t3), e3.prototype.toBytes = function() { - return f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.hash), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "hash", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, String, m.RuntimeArgs])], e3); - }(O); - e2.StoredContractByHash = j; - var U = function(t3) { - function e3(e4, r3, n2) { - var i2 = t3.call(this) || this; - return i2.tag = 2, i2.name = e4, i2.entryPoint = r3, i2.args = n2, i2; - } - return o(e3, t3), e3.prototype.toBytes = function() { - return f.concat([Uint8Array.from([this.tag]), y.toBytesString(this.name), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({constructor: String}), s("design:type", String)], e3.prototype, "name", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [String, String, m.RuntimeArgs])], e3); - }(O); - e2.StoredContractByName = U; - var N = function(t3) { - function e3(e4, r3, n2, i2) { - var o2 = t3.call(this) || this; - return o2.tag = 4, o2.name = e4, o2.version = r3, o2.entryPoint = n2, o2.args = i2, o2; - } - return o(e3, t3), e3.prototype.toBytes = function() { - var t4; - return t4 = this.version === null ? new h.Option(null, p.CLTypeHelper.u32()) : new h.Option(new p.U32(this.version)), f.concat([Uint8Array.from([this.tag]), y.toBytesString(this.name), t4.toBytes(), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({constructor: String}), s("design:type", String)], e3.prototype, "name", void 0), a([w.jsonMember({constructor: Number, preserveNull: true}), s("design:type", Object)], e3.prototype, "version", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [String, Object, String, m.RuntimeArgs])], e3); - }(O); - e2.StoredVersionedContractByName = N; - var C = function(t3) { - function e3(e4, r3, n2, i2) { - var o2 = t3.call(this) || this; - return o2.tag = 3, o2.hash = e4, o2.version = r3, o2.entryPoint = n2, o2.args = i2, o2; - } - return o(e3, t3), e3.prototype.toBytes = function() { - var t4; - return t4 = this.version === null ? new h.Option(null, p.CLTypeHelper.u32()) : new h.Option(new p.U32(this.version)), f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.hash), t4.toBytes(), y.toBytesString(this.entryPoint), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], e3.prototype, "hash", void 0), a([w.jsonMember({constructor: Number, preserveNull: true}), s("design:type", Object)], e3.prototype, "version", void 0), a([w.jsonMember({name: "entry_point", constructor: String}), s("design:type", String)], e3.prototype, "entryPoint", void 0), a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, Object, String, m.RuntimeArgs])], e3); - }(O); - e2.StoredVersionedContractByHash = C; - var D = function(t3) { - function e3(e4) { - var r3 = t3.call(this) || this; - return r3.tag = 5, r3.args = e4, r3; - } - return o(e3, t3), e3.prototype.toBytes = function() { - return f.concat([Uint8Array.from([this.tag]), y.toBytesBytesArray(this.args.toBytes())]); - }, a([w.jsonMember({deserializer: R, serializer: P}), s("design:type", m.RuntimeArgs)], e3.prototype, "args", void 0), a([w.jsonObject, s("design:paramtypes", [m.RuntimeArgs])], e3); - }(O); - e2.Transfer = D; - var L = function() { - function t3() { - } - var e3; - return e3 = t3, t3.prototype.toBytes = function() { - if (this.isModuleBytes()) - return this.moduleBytes.toBytes(); - if (this.isStoredContractByHash()) - return this.storedContractByHash.toBytes(); - if (this.isStoredContractByName()) - return this.storedContractByName.toBytes(); - if (this.isStoredVersionContractByHash()) - return this.storedVersionedContractByHash.toBytes(); - if (this.isStoredVersionContractByName()) - return this.storedVersionedContractByName.toBytes(); - if (this.isTransfer()) - return this.transfer.toBytes(); - throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); - }, t3.prototype.getArgByName = function(t4) { - if (this.isModuleBytes()) - return this.moduleBytes.getArgByName(t4); - if (this.isStoredContractByHash()) - return this.storedContractByHash.getArgByName(t4); - if (this.isStoredContractByName()) - return this.storedContractByName.getArgByName(t4); - if (this.isStoredVersionContractByHash()) - return this.storedVersionedContractByHash.getArgByName(t4); - if (this.isStoredVersionContractByName()) - return this.storedVersionedContractByName.getArgByName(t4); - if (this.isTransfer()) - return this.transfer.getArgByName(t4); - throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); - }, t3.prototype.setArg = function(t4, e4) { - if (this.isModuleBytes()) - return this.moduleBytes.setArg(t4, e4); - if (this.isStoredContractByHash()) - return this.storedContractByHash.setArg(t4, e4); - if (this.isStoredContractByName()) - return this.storedContractByName.setArg(t4, e4); - if (this.isStoredVersionContractByHash()) - return this.storedVersionedContractByHash.setArg(t4, e4); - if (this.isStoredVersionContractByName()) - return this.storedVersionedContractByName.setArg(t4, e4); - if (this.isTransfer()) - return this.transfer.setArg(t4, e4); - throw new Error("failed to serialize ExecutableDeployItemJsonWrapper"); - }, t3.fromExecutableDeployItemInternal = function(t4) { - var r3 = new e3(); - switch (t4.tag) { - case 0: - r3.moduleBytes = t4; - break; - case 1: - r3.storedContractByHash = t4; - break; - case 2: - r3.storedContractByName = t4; - break; - case 3: - r3.storedVersionedContractByHash = t4; - break; - case 4: - r3.storedVersionedContractByName = t4; - break; - case 5: - r3.transfer = t4; - } - return r3; - }, t3.newModuleBytes = function(t4, r3) { - return e3.fromExecutableDeployItemInternal(new I(t4, r3)); - }, t3.newStoredContractByHash = function(t4, r3, n2) { - return e3.fromExecutableDeployItemInternal(new j(t4, r3, n2)); - }, t3.newStoredContractByName = function(t4, r3, n2) { - return e3.fromExecutableDeployItemInternal(new U(t4, r3, n2)); - }, t3.newStoredVersionContractByHash = function(t4, r3, n2, i2) { - return e3.fromExecutableDeployItemInternal(new C(t4, r3, n2, i2)); - }, t3.newStoredVersionContractByName = function(t4, r3, n2, i2) { - return e3.fromExecutableDeployItemInternal(new N(t4, r3, n2, i2)); - }, t3.newTransfer = function(t4, r3, n2, i2) { - n2 === void 0 && (n2 = null); - var o2 = m.RuntimeArgs.fromMap({}); - if (o2.insert("amount", p.CLValue.u512(t4)), n2 && o2.insert("source", p.CLValue.uref(n2)), r3 instanceof b.URef) - o2.insert("target", p.CLValue.uref(r3)); - else { - if (!(r3 instanceof p.PublicKey)) - throw new Error("Please specify target"); - o2.insert("target", p.CLValue.byteArray(r3.toAccountHash())); - } - if (i2 === void 0) - throw new Error("transfer-id missing in new transfer."); - return o2.insert("id", p.CLValue.option(p.CLTypedAndToBytesHelper.u64(i2), p.CLTypeHelper.u64())), e3.fromExecutableDeployItemInternal(new D(o2)); - }, t3.newTransferWithOptionalTransferId = function(t4, r3, n2, i2) { - var o2 = m.RuntimeArgs.fromMap({}); - if (o2.insert("amount", p.CLValue.u512(t4)), n2 && o2.insert("source", p.CLValue.uref(n2)), r3 instanceof b.URef) - o2.insert("target", p.CLValue.uref(r3)); - else { - if (!(r3 instanceof p.PublicKey)) - throw new Error("Please specify target"); - o2.insert("target", p.CLValue.byteArray(r3.toAccountHash())); - } - return i2 != null ? o2.insert("id", p.CLValue.option(p.CLTypedAndToBytesHelper.u64(i2), p.CLTypeHelper.u64())) : o2.insert("id", p.CLValue.option(null, p.CLTypeHelper.u64())), e3.fromExecutableDeployItemInternal(new D(o2)); - }, t3.newTransferToUniqAddress = function(t4, e4, r3, n2, i2, o2, a2, s2) { - o2 === void 0 && (o2 = 1), a2 === void 0 && (a2 = 18e5); - var u2 = new b.DeployUtil.DeployParams(t4, i2, o2, a2), f2 = b.DeployUtil.standardPayment(n2), c2 = b.DeployUtil.ExecutableDeployItem.newTransfer(r3, e4.publicKey, s2, e4.transferId); - return b.DeployUtil.makeDeploy(u2, c2, f2); - }, t3.prototype.isModuleBytes = function() { - return !!this.moduleBytes; - }, t3.prototype.asModuleBytes = function() { - return this.moduleBytes; - }, t3.prototype.isStoredContractByHash = function() { - return !!this.storedContractByHash; - }, t3.prototype.asStoredContractByHash = function() { - return this.storedContractByHash; - }, t3.prototype.isStoredContractByName = function() { - return !!this.storedContractByName; - }, t3.prototype.asStoredContractByName = function() { - return this.storedContractByName; - }, t3.prototype.isStoredVersionContractByName = function() { - return !!this.storedVersionedContractByName; - }, t3.prototype.asStoredVersionContractByName = function() { - return this.storedVersionedContractByName; - }, t3.prototype.isStoredVersionContractByHash = function() { - return !!this.storedVersionedContractByHash; - }, t3.prototype.asStoredVersionContractByHash = function() { - return this.storedVersionedContractByHash; - }, t3.prototype.isTransfer = function() { - return !!this.transfer; - }, t3.prototype.asTransfer = function() { - return this.transfer; - }, a([w.jsonMember({name: "ModuleBytes", constructor: I}), s("design:type", I)], t3.prototype, "moduleBytes", void 0), a([w.jsonMember({name: "StoredContractByHash", constructor: j}), s("design:type", j)], t3.prototype, "storedContractByHash", void 0), a([w.jsonMember({name: "StoredContractByName", constructor: U}), s("design:type", U)], t3.prototype, "storedContractByName", void 0), a([w.jsonMember({name: "StoredVersionedContractByHash", constructor: C}), s("design:type", C)], t3.prototype, "storedVersionedContractByHash", void 0), a([w.jsonMember({name: "StoredVersionedContractByName", constructor: N}), s("design:type", N)], t3.prototype, "storedVersionedContractByName", void 0), a([w.jsonMember({name: "Transfer", constructor: D}), s("design:type", D)], t3.prototype, "transfer", void 0), e3 = a([w.jsonObject], t3); - }(); - e2.ExecutableDeployItem = L; - var K, z = function() { - function t3(t4, e3, r3, n2, i2) { - this.approvals = i2, this.session = n2, this.payment = r3, this.header = e3, this.hash = t4; - } - return t3.prototype.isTransfer = function() { - return this.session.isTransfer(); - }, t3.prototype.isStandardPayment = function() { - var t4; - return !!this.payment.isModuleBytes() && ((t4 = this.payment.asModuleBytes()) === null || t4 === void 0 ? void 0 : t4.moduleBytes.length) === 0; - }, a([w.jsonMember({serializer: E, deserializer: A}), s("design:type", Uint8Array)], t3.prototype, "hash", void 0), a([w.jsonMember({constructor: B}), s("design:type", B)], t3.prototype, "header", void 0), a([w.jsonMember({constructor: L}), s("design:type", L)], t3.prototype, "payment", void 0), a([w.jsonMember({constructor: L}), s("design:type", L)], t3.prototype, "session", void 0), a([w.jsonArrayMember(x), s("design:type", Array)], t3.prototype, "approvals", void 0), a([w.jsonObject, s("design:paramtypes", [Uint8Array, B, L, L, Array])], t3); - }(); - e2.Deploy = z, e2.serializeHeader = function(t3) { - return t3.toBytes(); - }, e2.serializeBody = function(t3, e3) { - return f.concat([t3.toBytes(), e3.toBytes()]); - }, e2.serializeApprovals = function(t3) { - var e3 = y.toBytesU32(t3.length), r3 = f.concat(t3.map(function(t4) { - return f.concat([Uint8Array.from(i.from(t4.signer, "hex")), Uint8Array.from(i.from(t4.signature, "hex"))]); - })); - return f.concat([e3, r3]); - }, (K = e2.ContractType || (e2.ContractType = {})).WASM = "WASM", K.Hash = "Hash", K.Name = "Name"; - function q(t3, r3, n2) { - var i2 = e2.serializeBody(n2, r3), o2 = c.default.blake2b(i2, null, 32), a2 = new B(t3.accountPublicKey, t3.timestamp, t3.ttl, t3.gasPrice, o2, t3.dependencies, t3.chainName), s2 = e2.serializeHeader(a2), u2 = c.default.blake2b(s2, null, 32); - return new z(u2, a2, n2, r3, []); - } - e2.DeployParams = function(t3, e3, r3, n2, i2, o2) { - r3 === void 0 && (r3 = 1), n2 === void 0 && (n2 = 18e5), i2 === void 0 && (i2 = []), this.accountPublicKey = t3, this.chainName = e3, this.gasPrice = r3, this.ttl = n2, this.dependencies = i2, this.timestamp = o2, this.dependencies = i2.filter(function(t4) { - return i2.filter(function(e4) { - return l.encodeBase16(t4) === l.encodeBase16(e4); - }).length < 2; - }), o2 || (this.timestamp = Date.now()); - }, e2.makeDeploy = q, e2.signDeploy = function(t3, e3) { - var r3 = new x(), n2 = e3.sign(t3.hash); - switch (r3.signer = e3.accountHex(), e3.signatureAlgorithm) { - case g.SignatureAlgorithm.Ed25519: - r3.signature = b.Keys.Ed25519.accountHex(n2); - break; - case g.SignatureAlgorithm.Secp256K1: - r3.signature = b.Keys.Secp256K1.accountHex(n2); - } - return t3.approvals.push(r3), t3; - }, e2.setSignature = function(t3, e3, r3) { - var n2 = new x(); - switch (n2.signer = r3.toAccountHex(), r3.signatureAlgorithm()) { - case g.SignatureAlgorithm.Ed25519: - n2.signature = b.Keys.Ed25519.accountHex(e3); - break; - case g.SignatureAlgorithm.Secp256K1: - n2.signature = b.Keys.Secp256K1.accountHex(e3); - } - return t3.approvals.push(n2), t3; - }, e2.standardPayment = function(t3) { - var e3 = m.RuntimeArgs.fromMap({amount: p.CLValue.u512(t3.toString())}); - return L.newModuleBytes(Uint8Array.from([]), e3); - }, e2.deployToJson = function(t3) { - return {deploy: new w.TypedJSON(z).toPlainJson(t3)}; - }, e2.deployFromJson = function(t3) { - var r3 = new w.TypedJSON(z).parse(t3.deploy); - if (r3 !== void 0 && e2.validateDeploy(r3).ok) - return r3; - }, e2.addArgToDeploy = function(t3, e3, r3) { - if (t3.approvals.length !== 0) - throw Error("Can not add argument to already signed deploy."); - var n2 = new b.DeployUtil.DeployParams(t3.header.account, t3.header.chainName, t3.header.gasPrice, t3.header.ttl, t3.header.dependencies, t3.header.timestamp), i2 = t3.session; - return i2.setArg(e3, r3), q(n2, i2, t3.payment); - }, e2.deploySizeInBytes = function(t3) { - var r3 = t3.hash.length, n2 = e2.serializeBody(t3.payment, t3.session).length; - return r3 + e2.serializeHeader(t3.header).length + n2 + t3.approvals.map(function(t4) { - return (t4.signature.length + t4.signer.length) / 2; - }).reduce(function(t4, e3) { - return t4 + e3; - }, 0); - }, e2.validateDeploy = function(t3) { - var r3 = e2.serializeBody(t3.payment, t3.session), n2 = c.default.blake2b(r3, null, 32); - if (!H(t3.header.bodyHash, n2)) - return M.Err("Invalid deploy: bodyHash missmatch. Expected: " + n2 + ", \n got: " + t3.header.bodyHash + "."); - var i2 = e2.serializeHeader(t3.header), o2 = c.default.blake2b(i2, null, 32); - return H(t3.hash, o2) ? M.Ok(t3) : M.Err("Invalid deploy: hash missmatch. Expected: " + o2 + ", \n got: " + t3.hash + "."); - }; - var H = function(t3, e3) { - return t3.length === e3.length && t3.every(function(t4, r3) { - return t4 === e3[r3]; - }); - }; - e2.deployToBytes = function(t3) { - return f.concat([e2.serializeHeader(t3.header), t3.hash, e2.serializeBody(t3.payment, t3.session), e2.serializeApprovals(t3.approvals)]); - }; - }, 2964: function(t2, e2, r2) { - var n, i = r2(8764).Buffer, o = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }), a = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { - return e3[r3]; - }}); - } : function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; - }), s = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { - Object.defineProperty(t3, "default", {enumerable: true, value: e3}); - } : function(t3, e3) { - t3.default = e3; - }), u = this && this.__importStar || function(t3) { - if (t3 && t3.__esModule) - return t3; - var e3 = {}; - if (t3 != null) - for (var r3 in t3) - r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && a(e3, t3, r3); - return s(e3, t3), e3; - }, f = this && this.__importDefault || function(t3) { - return t3 && t3.__esModule ? t3 : {default: t3}; - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.Secp256K1 = e2.Ed25519 = e2.AsymmetricKey = e2.readBase64WithPEM = e2.SignatureAlgorithm = void 0; - var c, h = u(r2(2349)), l = u(r2(6811)), d = r2(6885), p = r2(3607), y = r2(3915), m = r2(3492), b = f(r2(6215)), g = u(r2(5053)), v = f(r2(8917)), w = r2(4237), _ = new v.default("secp256k1"); - function M(t3, e3) { - var r3 = i.from([0]), n2 = i.concat([i.from(t3), r3]); - return e3.length === 0 ? i.from([]) : m.byteHash(i.concat([n2, i.from(e3)])); - } - function S(t3) { - var e3 = t3.split(/\r?\n/).filter(function(t4) { - return !t4.startsWith("---"); - }).join("").trim(); - return d.decodeBase64(e3); - } - !function(t3) { - t3.Ed25519 = "ed25519", t3.Secp256K1 = "secp256k1"; - }(c = e2.SignatureAlgorithm || (e2.SignatureAlgorithm = {})), e2.readBase64WithPEM = S; - var E = function() { - function t3(t4, e3, r3) { - this.publicKey = y.PublicKey.from(t4, r3), this.privateKey = e3, this.signatureAlgorithm = r3; - } - return t3.prototype.accountHash = function() { - return this.publicKey.toAccountHash(); - }, t3.prototype.accountHex = function() { - return this.publicKey.toAccountHex(); - }, t3.prototype.toPem = function(t4, e3) { - return "-----BEGIN " + t4 + "-----\n" + e3 + "\n-----END " + t4 + "-----\n"; - }, t3; - }(); - e2.AsymmetricKey = E; - var A = function(t3) { - function e3(e4) { - return t3.call(this, e4.publicKey, e4.secretKey, c.Ed25519) || this; - } - return o(e3, t3), e3.new = function() { - return new e3(l.sign_keyPair()); - }, e3.accountHex = function(t4) { - return "01" + p.encodeBase16(t4); - }, e3.parseKeyFiles = function(t4, r3) { - var n2 = e3.parsePublicKeyFile(t4), o2 = e3.parsePrivateKeyFile(r3); - return new e3({publicKey: n2, secretKey: i.concat([o2, n2])}); - }, e3.accountHash = function(t4) { - return M(c.Ed25519, t4); - }, e3.parseKeyPair = function(t4, r3) { - var n2 = e3.parsePublicKey(t4), i2 = e3.parsePrivateKey(r3), o2 = new Uint8Array(n2.length + i2.length); - return o2.set(i2), o2.set(n2, i2.length), new e3({publicKey: n2, secretKey: o2}); - }, e3.parsePrivateKeyFile = function(t4) { - return e3.parsePrivateKey(e3.readBase64File(t4)); - }, e3.parsePublicKeyFile = function(t4) { - return e3.parsePublicKey(e3.readBase64File(t4)); - }, e3.parsePrivateKey = function(t4) { - return e3.parseKey(t4, 0, 32); - }, e3.parsePublicKey = function(t4) { - return e3.parseKey(t4, 32, 64); - }, e3.readBase64WithPEM = function(t4) { - return S(t4); - }, e3.readBase64File = function(t4) { - var r3 = h.readFileSync(t4).toString(); - return e3.readBase64WithPEM(r3); - }, e3.parseKey = function(t4, e4, r3) { - var n2 = t4.length, o2 = n2 === 32 ? t4 : n2 === 64 ? i.from(t4).slice(e4, r3) : n2 > 32 && n2 < 64 ? i.from(t4).slice(n2 % 32) : null; - if (o2 == null || o2.length !== 32) - throw Error("Unexpected key length: " + n2); - return o2; - }, e3.prototype.exportPrivateKeyInPem = function() { - var t4 = i.from([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]), r3 = p.encodeBase64(i.concat([t4, i.from(e3.parsePrivateKey(this.privateKey))])); - return this.toPem("PRIVATE KEY", r3); - }, e3.prototype.exportPublicKeyInPem = function() { - var t4 = i.from([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]), e4 = p.encodeBase64(i.concat([t4, i.from(this.publicKey.rawPublicKey)])); - return this.toPem("PUBLIC KEY", e4); - }, e3.prototype.sign = function(t4) { - return l.sign_detached(t4, this.privateKey); - }, e3.prototype.verify = function(t4, e4) { - return l.sign_detached_verify(e4, t4, this.publicKey.rawPublicKey); - }, e3.privateToPublicKey = function(t4) { - return t4.length === 64 ? l.sign_keyPair_fromSecretKey(t4).publicKey : l.sign_keyPair_fromSeed(t4).publicKey; - }, e3.loadKeyPairFromPrivateFile = function(t4) { - var r3 = e3.parsePrivateKeyFile(t4), n2 = e3.privateToPublicKey(r3); - return e3.parseKeyPair(n2, r3); - }, e3; - }(E); - e2.Ed25519 = A; - var k = function(t3) { - function e3(e4, r3) { - return t3.call(this, e4, r3, c.Secp256K1) || this; - } - return o(e3, t3), e3.new = function() { - var t4 = b.default.generatePrivate(); - return new e3(Uint8Array.from(b.default.getPublicCompressed(t4)), t4); - }, e3.parseKeyFiles = function(t4, r3) { - var n2 = e3.parsePublicKeyFile(t4), i2 = e3.parsePrivateKeyFile(r3); - return new e3(n2, i2); - }, e3.accountHash = function(t4) { - return M(c.Secp256K1, t4); - }, e3.accountHex = function(t4) { - return "02" + p.encodeBase16(t4); - }, e3.parseKeyPair = function(t4, r3, n2) { - var i2 = e3.parsePublicKey(t4, n2), o2 = e3.parsePrivateKey(r3, n2); - return new e3(i2, o2); - }, e3.parsePrivateKeyFile = function(t4) { - return e3.parsePrivateKey(e3.readBase64File(t4)); - }, e3.parsePublicKeyFile = function(t4) { - return e3.parsePublicKey(e3.readBase64File(t4)); - }, e3.parsePrivateKey = function(t4, e4) { - var r3; - return e4 === void 0 && (e4 = "der"), r3 = e4 === "der" ? _.encodePrivate(i.from(t4), "der", "raw") : p.encodeBase16(t4), i.from(r3, "hex"); - }, e3.parsePublicKey = function(t4, e4) { - var r3; - return e4 === void 0 && (e4 = "der"), r3 = e4 === "der" ? _.encodePublic(i.from(t4), "der", "raw") : p.encodeBase16(t4), Uint8Array.from(i.from(r3, "hex")); - }, e3.readBase64WithPEM = function(t4) { - return S(t4); - }, e3.readBase64File = function(t4) { - var r3 = h.readFileSync(t4).toString(); - return e3.readBase64WithPEM(r3); - }, e3.prototype.exportPrivateKeyInPem = function() { - return _.encodePrivate(p.encodeBase16(this.privateKey), "raw", "pem"); - }, e3.prototype.exportPublicKeyInPem = function() { - return _.encodePublic(p.encodeBase16(this.publicKey.rawPublicKey), "raw", "pem"); - }, e3.prototype.sign = function(t4) { - return g.ecdsaSign(w.sha256(i.from(t4)), this.privateKey).signature; - }, e3.prototype.verify = function(t4, e4) { - return g.ecdsaVerify(t4, w.sha256(i.from(e4)), this.publicKey.rawPublicKey); - }, e3.privateToPublicKey = function(t4) { - return g.publicKeyCreate(t4, true); - }, e3.loadKeyPairFromPrivateFile = function(t4) { - var r3 = e3.parsePrivateKeyFile(t4), n2 = e3.privateToPublicKey(r3); - return e3.parseKeyPair(n2, r3, "raw"); - }, e3.deriveIndex = function(t4, e4) { - return t4.deriveIndex(e4); - }, e3; - }(E); - e2.Secp256K1 = k; - }, 6349: function(t2, e2, r2) { - var n = this && this.__decorate || function(t3, e3, r3, n2) { - var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; - if (typeof Reflect == "object" && typeof Reflect.decorate == "function") - a2 = Reflect.decorate(t3, e3, r3, n2); - else - for (var s2 = t3.length - 1; s2 >= 0; s2--) - (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); - return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; - }, i = this && this.__metadata || function(t3, e3) { - if (typeof Reflect == "object" && typeof Reflect.metadata == "function") - return Reflect.metadata(t3, e3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.RuntimeArgs = e2.NamedArg = void 0; - var o = r2(3917), a = r2(5050), s = r2(3286), u = r2(4546), f = function() { - function t3(t4, e3) { - this.name = t4, this.value = e3; - } - return t3.prototype.toBytes = function() { - var t4 = o.toBytesString(this.name), e3 = this.value.toBytes(); - return s.concat([t4, e3]); - }, t3.fromBytes = function(e3) { - var r3 = a.StringValue.fromBytes(e3); - if (r3.hasError()) - return a.Result.Err(r3.error); - var n2 = a.CLValue.fromBytes(r3.remainder()); - return n2.hasError() ? a.Result.Err(n2.error) : a.Result.Ok(new t3(r3.value().val, n2.value()), n2.remainder()); - }, t3; - }(); - e2.NamedArg = f; - var c = function(t3) { - var e3 = new u.TypedJSON(a.CLValue); - return new Map(Array.from(t3, function(t4) { - var r3 = t4[0], n2 = t4[1]; - return [r3, e3.parse(n2)]; - })); - }, h = function(t3) { - var e3 = new u.TypedJSON(a.CLValue); - return Array.from(t3, function(t4) { - var r3 = t4[0], n2 = t4[1]; - return [r3, e3.toPlainJson(n2)]; - }); - }, l = function() { - function t3(t4) { - this.args = t4; - } - var e3; - return e3 = t3, t3.fromMap = function(t4) { - var r3 = new Map(Object.keys(t4).map(function(e4) { - return [e4, t4[e4]]; - })); - return new e3(r3); - }, t3.fromNamedArgs = function(t4) { - var r3 = t4.reduce(function(t5, e4) { - return t5[e4.name] = e4.value, t5; - }, {}); - return e3.fromMap(r3); - }, t3.prototype.insert = function(t4, e4) { - this.args.set(t4, e4); - }, t3.prototype.toBytes = function() { - var t4 = Array.from(this.args.entries()).map(function(t5) { - return new f(t5[0], t5[1]); - }); - return o.toBytesVecT(t4); - }, t3.fromBytes = function(t4) { - var r3 = a.U32.fromBytes(t4); - if (r3.hasError()) - return a.Result.Err(r3.error); - for (var n2 = r3.value().val.toNumber(), i2 = r3.remainder(), o2 = [], s2 = 0; s2 < n2; s2++) { - var u2 = f.fromBytes(i2); - if (u2.hasError()) - return a.Result.Err(u2.error); - o2.push(u2.value()), i2 = u2.remainder(); - } - return a.Result.Ok(e3.fromNamedArgs(o2), i2); - }, n([u.jsonMember({serializer: h, deserializer: c}), i("design:type", Map)], t3.prototype, "args", void 0), e3 = n([u.jsonObject(), i("design:paramtypes", [Map])], t3); - }(); - e2.RuntimeArgs = l; - }, 165: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}), e2.Args = e2.UInt64Arg = e2.PublicKeyArg = e2.ByteSequenceArg = e2.ByteArrayArg = void 0; - var i = function(t3) { - var e3 = n.alloc(4); - return e3.writeInt32LE(t3, 0), e3; - }; - e2.ByteArrayArg = function(t3) { - return n.from(t3); - }, e2.ByteSequenceArg = function(t3) { - return n.concat([i(t3.length), t3].map(n.from)); - }, e2.PublicKeyArg = e2.ByteArrayArg, e2.UInt64Arg = function(t3) { - var e3 = n.alloc(8); - return e3.writeBigUInt64LE(t3, 0), e3; - }, e2.Args = function() { - for (var t3 = [], r3 = 0; r3 < arguments.length; r3++) - t3[r3] = arguments[r3]; - var o = [i(t3.length)].concat(t3.map(e2.ByteSequenceArg)); - return n.concat(o.map(n.from)); - }; - }, 2896: function(t2, e2) { - var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i, o) { - function a(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o(t5); - } - } - function s(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o(t5); - } - } - function u(t4) { - var e4; - t4.done ? i(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a, s); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, n = this && this.__generator || function(t3, e3) { - var r3, n2, i, o, a = {label: 0, sent: function() { - if (1 & i[0]) - throw i[1]; - return i[1]; - }, trys: [], ops: []}; - return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { - return this; - }), o; - function s(o2) { - return function(s2) { - return function(o3) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a; ) - try { - if (r3 = 1, n2 && (i = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i = n2.return) && i.call(n2), 0) : n2.next) && !(i = i.call(n2, o3[1])).done) - return i; - switch (n2 = 0, i && (o3 = [2 & o3[0], i.value]), o3[0]) { - case 0: - case 1: - i = o3; - break; - case 4: - return a.label++, {value: o3[1], done: false}; - case 5: - a.label++, n2 = o3[1], o3 = [0]; - continue; - case 7: - o3 = a.ops.pop(), a.trys.pop(); - continue; - default: - if (!((i = (i = a.trys).length > 0 && i[i.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { - a = 0; - continue; - } - if (o3[0] === 3 && (!i || o3[1] > i[0] && o3[1] < i[3])) { - a.label = o3[1]; - break; - } - if (o3[0] === 6 && a.label < i[1]) { - a.label = i[1], i = o3; - break; - } - if (i && a.label < i[2]) { - a.label = i[2], a.ops.push(o3); - break; - } - i[2] && a.ops.pop(), a.trys.pop(); - continue; - } - o3 = e3.call(t3, a); - } catch (t4) { - o3 = [6, t4], n2 = 0; - } finally { - r3 = i = 0; - } - if (5 & o3[0]) - throw o3[1]; - return {value: o3[0] ? o3[1] : void 0, done: true}; - }([o2, s2]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.signTestDeploy = e2.getToSignMessageID = e2.createTestAccount = e2.createNewVault = e2.resetExistingVault = e2.hasCreatedVault = e2.forceDisconnect = e2.forceConnection = e2.disconnectFromSite = e2.sign = e2.getActivePublicKey = e2.getSelectedPublicKeyBase64 = e2.sendConnectionRequest = e2.isConnected = e2.getVersion = void 0, e2.getVersion = function() { - return r2(void 0, void 0, void 0, function() { - return n(this, function(t3) { - switch (t3.label) { - case 0: - return t3.trys.push([0, 2, , 3]), [4, window.casperlabsHelper.getVersion()]; - case 1: - return [2, t3.sent()]; - case 2: - return t3.sent(), [2, "<1.0.0"]; - case 3: - return [2]; - } - }); - }); - }, e2.isConnected = function() { - return r2(void 0, void 0, void 0, function() { - return n(this, function(t3) { - switch (t3.label) { - case 0: - return [4, window.casperlabsHelper.isConnected()]; - case 1: - return [2, t3.sent()]; - } - }); - }); - }, e2.sendConnectionRequest = function() { - return window.casperlabsHelper.requestConnection(); - }, e2.getSelectedPublicKeyBase64 = function() { - return window.casperlabsHelper.getSelectedPublicKeyBase64(); - }, e2.getActivePublicKey = function() { - return window.casperlabsHelper.getActivePublicKey(); - }, e2.sign = function(t3, e3, r3) { - return window.casperlabsHelper.sign(t3, e3, r3); - }, e2.disconnectFromSite = function() { - return window.casperlabsHelper.disconnectFromSite(); - }, e2.forceConnection = function() { - return window.signerTestingHelper.forceConnection(); - }, e2.forceDisconnect = function() { - return window.signerTestingHelper.forceDisconnect(); - }, e2.hasCreatedVault = function() { - return window.signerTestingHelper.hasCreatedVault(); - }, e2.resetExistingVault = function() { - return window.signerTestingHelper.resetExistingVault(); - }, e2.createNewVault = function(t3) { - return window.signerTestingHelper.createNewVault(t3); - }, e2.createTestAccount = function(t3, e3) { - return window.signerTestingHelper.createTestAccount(t3, e3); - }, e2.getToSignMessageID = function() { - return window.signerTestingHelper.getToSignMessageID(); - }, e2.signTestDeploy = function(t3) { - return window.signerTestingHelper.signTestDeploy(t3); - }; - }, 5778: function(t2, e2, r2) { - var n = this && this.__decorate || function(t3, e3, r3, n2) { - var i2, o2 = arguments.length, a2 = o2 < 3 ? e3 : n2 === null ? n2 = Object.getOwnPropertyDescriptor(e3, r3) : n2; - if (typeof Reflect == "object" && typeof Reflect.decorate == "function") - a2 = Reflect.decorate(t3, e3, r3, n2); - else - for (var s2 = t3.length - 1; s2 >= 0; s2--) - (i2 = t3[s2]) && (a2 = (o2 < 3 ? i2(a2) : o2 > 3 ? i2(e3, r3, a2) : i2(e3, r3)) || a2); - return o2 > 3 && a2 && Object.defineProperty(e3, r3, a2), a2; - }, i = this && this.__metadata || function(t3, e3) { - if (typeof Reflect == "object" && typeof Reflect.metadata == "function") - return Reflect.metadata(t3, e3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.StoredValue = e2.ContractMetadataJson = e2.EraInfoJson = e2.SeigniorageAllocation = e2.DeployInfoJson = e2.TransferJson = void 0; - var o = r2(4546), a = r2(5050), s = function() { - function t3() { - } - return n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "name", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "key", void 0), n([o.jsonObject], t3); - }(), u = function() { - function t3() { - } - return n([o.jsonMember({name: "account_hash", constructor: String}), i("design:type", String)], t3.prototype, "accountHash", void 0), n([o.jsonMember({constructor: Number}), i("design:type", Number)], t3.prototype, "weight", void 0), n([o.jsonObject], t3); - }(), f = function() { - function t3() { - } - return n([o.jsonMember({constructor: Number}), i("design:type", Number)], t3.prototype, "deployment", void 0), n([o.jsonMember({name: "key_management", constructor: Number}), i("design:type", Number)], t3.prototype, "keyManagement", void 0), n([o.jsonObject], t3); - }(), c = function() { - function t3() { - } - return t3.prototype.accountHash = function() { - return this._accountHash; - }, n([o.jsonMember({name: "account_hash", constructor: String}), i("design:type", String)], t3.prototype, "_accountHash", void 0), n([o.jsonArrayMember(s, {name: "named_keys"}), i("design:type", Array)], t3.prototype, "namedKeys", void 0), n([o.jsonMember({name: "main_purse", constructor: String}), i("design:type", String)], t3.prototype, "mainPurse", void 0), n([o.jsonArrayMember(u, {name: "associated_keys"}), i("design:type", Array)], t3.prototype, "associatedKeys", void 0), n([o.jsonMember({name: "action_thresholds", constructor: f}), i("design:type", f)], t3.prototype, "actionThresholds", void 0), n([o.jsonObject], t3); - }(), h = function() { - function t3() { - } - return n([o.jsonMember({name: "deploy_hash", constructor: String}), i("design:type", String)], t3.prototype, "deployHash", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "from", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "source", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "target", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "gas", void 0), n([o.jsonMember({constructor: String, preserveNull: true}), i("design:type", Object)], t3.prototype, "id", void 0), n([o.jsonObject], t3); - }(); - e2.TransferJson = h; - var l = function() { - function t3() { - } - return n([o.jsonMember({name: "deploy_hash", constructor: String}), i("design:type", String)], t3.prototype, "deployHash", void 0), n([o.jsonArrayMember(String), i("design:type", Array)], t3.prototype, "transfers", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "from", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "source", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "gas", void 0), n([o.jsonObject], t3); - }(); - e2.DeployInfoJson = l; - var d = function() { - function t3() { - } - return n([o.jsonMember({name: "validator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "validatorPublicKey", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonObject], t3); - }(), p = function() { - function t3() { - } - return n([o.jsonMember({name: "delegator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "delegatorPublicKey", void 0), n([o.jsonMember({name: "validator_public_key", constructor: String}), i("design:type", String)], t3.prototype, "validatorPublicKey", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "amount", void 0), n([o.jsonObject], t3); - }(), y = function() { - function t3() { - } - return n([o.jsonMember({constructor: d}), i("design:type", d)], t3.prototype, "Validator", void 0), n([o.jsonMember({constructor: p}), i("design:type", p)], t3.prototype, "Delegator", void 0), n([o.jsonObject], t3); - }(); - e2.SeigniorageAllocation = y; - var m = function() { - function t3() { - } - return n([o.jsonArrayMember(y, {name: "seigniorage_allocations"}), i("design:type", Array)], t3.prototype, "seigniorageAllocations", void 0), n([o.jsonObject], t3); - }(); - e2.EraInfoJson = m; - var b = function() { - function t3() { - } - return n([o.jsonMember({name: "contract_package_hash", constructor: String}), i("design:type", String)], t3.prototype, "contractPackageHash", void 0), n([o.jsonMember({name: "contract_wasm_hash", constructor: String}), i("design:type", String)], t3.prototype, "contractWasmHash", void 0), n([o.jsonMember({name: "protocol_version", constructor: String}), i("design:type", String)], t3.prototype, "protocolVersion", void 0), n([o.jsonObject], t3); - }(); - e2.ContractMetadataJson = b; - var g = function() { - function t3() { - } - return n([o.jsonMember({constructor: a.CLValue}), i("design:type", a.CLValue)], t3.prototype, "CLValue", void 0), n([o.jsonMember({constructor: c}), i("design:type", c)], t3.prototype, "Account", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "ContractWASM", void 0), n([o.jsonMember({constructor: b}), i("design:type", b)], t3.prototype, "Contract", void 0), n([o.jsonMember({constructor: String}), i("design:type", String)], t3.prototype, "ContractPackage", void 0), n([o.jsonMember({constructor: h}), i("design:type", h)], t3.prototype, "Transfer", void 0), n([o.jsonMember({constructor: l}), i("design:type", l)], t3.prototype, "DeployInfo", void 0), n([o.jsonMember({constructor: m}), i("design:type", m)], t3.prototype, "EraInfo", void 0), n([o.jsonObject], t3); - }(); - e2.StoredValue = g; - }, 3917: (t2, e2, r2) => { - var n = r2(8764).Buffer; - Object.defineProperty(e2, "__esModule", {value: true}), e2.toBytesStringList = e2.toBytesVecT = e2.toBytesBytesArray = e2.toBytesArrayU8 = e2.toBytesString = e2.toBytesU512 = e2.toBytesDeployHash = e2.toBytesU256 = e2.toBytesU128 = e2.toBytesI64 = e2.toBytesU64 = e2.toBytesU32 = e2.toBytesI32 = e2.toBytesU8 = e2.toBytesNumber = void 0; - var i = r2(2092), o = r2(2279), a = r2(3286), s = r2(5050); - function u(t3) { - return e2.toBytesNumber(32, false, t3); - } - function f(t3) { - var e3 = t3.map(function(t4) { - return t4.toBytes(); - }); - return e3.splice(0, 0, u(t3.length)), a.concat(e3); - } - e2.toBytesNumber = function(t3, e3, r3) { - var n2 = i.BigNumber.from(r3), s2 = o.MaxUint256.mask(t3); - if (e3) { - var u2 = s2.mask(t3 - 1); - if (n2.gt(u2) || n2.lt(u2.add(o.One).mul(o.NegativeOne))) - throw new Error("value out-of-bounds, value: " + r3); - } else if (n2.lt(o.Zero) || n2.gt(s2.mask(t3))) - throw new Error("value out-of-bounds, value: " + r3); - n2 = n2.toTwos(t3).mask(t3); - var f2 = a.arrayify(n2); - if (n2.gte(0)) { - if (t3 > 64) - return a.concat([f2, Uint8Array.from([f2.length])]).reverse(); - var c = t3 / 8; - return a.concat([f2.reverse(), new Uint8Array(c - f2.length)]); - } - return f2.reverse(); - }, e2.toBytesU8 = function(t3) { - return e2.toBytesNumber(8, false, t3); - }, e2.toBytesI32 = function(t3) { - return e2.toBytesNumber(32, true, t3); - }, e2.toBytesU32 = u, e2.toBytesU64 = function(t3) { - return e2.toBytesNumber(64, false, t3); - }, e2.toBytesI64 = function(t3) { - return e2.toBytesNumber(64, true, t3); - }, e2.toBytesU128 = function(t3) { - return e2.toBytesNumber(128, false, t3); - }, e2.toBytesU256 = function(t3) { - return e2.toBytesNumber(256, false, t3); - }, e2.toBytesDeployHash = function(t3) { - return t3; - }, e2.toBytesU512 = function(t3) { - return e2.toBytesNumber(512, false, t3); - }, e2.toBytesString = function(t3) { - var e3 = Uint8Array.from(n.from(t3)); - return a.concat([u(e3.byteLength), e3]); - }, e2.toBytesArrayU8 = function(t3) { - return a.concat([u(t3.length), t3]); - }, e2.toBytesBytesArray = function(t3) { - return t3; - }, e2.toBytesVecT = f, e2.toBytesStringList = function(t3) { - return f(t3.map(function(t4) { - return s.CLValue.string(t4); - })); - }; - }, 3915: function(t2, e2, r2) { - var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { - return e3[r3]; - }}); - } : function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; - }), i = this && this.__setModuleDefault || (Object.create ? function(t3, e3) { - Object.defineProperty(t3, "default", {enumerable: true, value: e3}); - } : function(t3, e3) { - t3.default = e3; - }), o = this && this.__importStar || function(t3) { - if (t3 && t3.__esModule) - return t3; - var e3 = {}; - if (t3 != null) - for (var r3 in t3) - r3 !== "default" && Object.hasOwnProperty.call(t3, r3) && n(e3, t3, r3); - return i(e3, t3), e3; - }, a = this && this.__exportStar || function(t3, e3) { - for (var r3 in t3) - r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.Signer = e2.DeployUtil = e2.Serialization = e2.Keys = e2.Contracts = void 0; - var s = o(r2(3492)); - e2.Contracts = s; - var u = o(r2(4922)); - e2.DeployUtil = u; - var f = o(r2(2964)); - e2.Keys = f; - var c = o(r2(165)); - e2.Serialization = c; - var h = o(r2(2896)); - e2.Signer = h, a(r2(5050), e2), a(r2(6349), e2), a(r2(3368), e2), a(r2(5371), e2); - }, 5371: function(t2, e2, r2) { - var n, i = this && this.__extends || (n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - e4.hasOwnProperty(r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }, function(t3, e3) { - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - }); - Object.defineProperty(e2, "__esModule", {value: true}), e2.Option = void 0; - var o = r2(5050), a = r2(3286), s = function(t3) { - function e3(e4, r3) { - var n2 = t3.call(this) || this; - if (n2.t = e4, e4 === null) { - if (!r3) - throw new Error("You had to assign innerType for None"); - n2.innerType = r3; - } else - n2.innerType = e4.clType(); - return n2; - } - return i(e3, t3), e3.prototype.isNone = function() { - return this.t === null; - }, e3.prototype.isSome = function() { - return this.t !== null; - }, e3.prototype.getSome = function() { - if (!this.isSome()) - throw new Error("Value is None"); - return o.CLValue.fromT(this.t); - }, e3.prototype.toBytes = function() { - return this.t === null ? Uint8Array.from([0]) : a.concat([Uint8Array.from([1]), this.t.toBytes()]); - }, e3.prototype.clType = function() { - return o.CLTypeHelper.option(this.innerType); - }, e3.fromBytes = function(t4, r3) { - var n2 = o.U8.fromBytes(r3); - if (n2.hasError()) - return o.Result.Err(n2.error); - var i2 = n2.value().val.toNumber(); - if (i2 === 0) - return o.Result.Ok(new e3(null, t4.innerType), n2.remainder()); - if (i2 === 1) { - var a2 = o.fromBytesByCLType(t4.innerType, n2.remainder()); - return a2.hasError() ? o.Result.Err(a2.error) : o.Result.Ok(new e3(a2.value(), t4.innerType), a2.remainder()); - } - return o.Result.Err(o.FromBytesError.FormattingError); - }, e3; - }(o.CLTypedAndToBytes); - e2.Option = s; - }, 8132: function(t2, e2) { - var r2 = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o) { - function a(t4) { - try { - u(n2.next(t4)); - } catch (t5) { - o(t5); - } - } - function s(t4) { - try { - u(n2.throw(t4)); - } catch (t5) { - o(t5); - } - } - function u(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a, s); - } - u((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, n = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o, a = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o = {next: s(0), throw: s(1), return: s(2)}, typeof Symbol == "function" && (o[Symbol.iterator] = function() { - return this; - }), o; - function s(o2) { - return function(s2) { - return function(o3) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o3[0] ? n2.return : o3[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o3[1])).done) - return i2; - switch (n2 = 0, i2 && (o3 = [2 & o3[0], i2.value]), o3[0]) { - case 0: - case 1: - i2 = o3; - break; - case 4: - return a.label++, {value: o3[1], done: false}; - case 5: - a.label++, n2 = o3[1], o3 = [0]; - continue; - case 7: - o3 = a.ops.pop(), a.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a.trys).length > 0 && i2[i2.length - 1]) || o3[0] !== 6 && o3[0] !== 2)) { - a = 0; - continue; - } - if (o3[0] === 3 && (!i2 || o3[1] > i2[0] && o3[1] < i2[3])) { - a.label = o3[1]; - break; - } - if (o3[0] === 6 && a.label < i2[1]) { - a.label = i2[1], i2 = o3; - break; - } - if (i2 && a.label < i2[2]) { - a.label = i2[2], a.ops.push(o3); - break; - } - i2[2] && a.ops.pop(), a.trys.pop(); - continue; - } - o3 = e3.call(t3, a); - } catch (t4) { - o3 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o3[0]) - throw o3[1]; - return {value: o3[0] ? o3[1] : void 0, done: true}; - }([o2, s2]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.BalanceServiceByJsonRPC = void 0; - var i = function() { - function t3(t4) { - this.casperService = t4, this.balanceUrefs = new Map(); - } - return t3.prototype.getAccountBalance = function(t4, e3) { - return r2(this, void 0, void 0, function() { - var r3, i2; - return n(this, function(n2) { - switch (n2.label) { - case 0: - return n2.trys.push([0, 5, , 6]), [4, this.casperService.getStateRootHash(t4)]; - case 1: - return r3 = n2.sent(), (i2 = this.balanceUrefs.get(e3.toAccountHex())) ? [3, 3] : [4, this.casperService.getAccountBalanceUrefByPublicKey(r3, e3)]; - case 2: - (i2 = n2.sent()) && this.balanceUrefs.set(e3.toAccountHex(), i2), n2.label = 3; - case 3: - return i2 ? [4, this.casperService.getAccountBalance(r3, i2)] : [2, void 0]; - case 4: - return [2, n2.sent()]; - case 5: - return n2.sent(), [2, void 0]; - case 6: - return [2]; - } - }); - }); - }, t3; - }(); - e2.BalanceServiceByJsonRPC = i; - }, 9693: function(t2, e2, r2) { - var n = this && this.__awaiter || function(t3, e3, r3, n2) { - return new (r3 || (r3 = Promise))(function(i2, o2) { - function a2(t4) { - try { - u2(n2.next(t4)); - } catch (t5) { - o2(t5); - } - } - function s2(t4) { - try { - u2(n2.throw(t4)); - } catch (t5) { - o2(t5); - } - } - function u2(t4) { - var e4; - t4.done ? i2(t4.value) : (e4 = t4.value, e4 instanceof r3 ? e4 : new r3(function(t5) { - t5(e4); - })).then(a2, s2); - } - u2((n2 = n2.apply(t3, e3 || [])).next()); - }); - }, i = this && this.__generator || function(t3, e3) { - var r3, n2, i2, o2, a2 = {label: 0, sent: function() { - if (1 & i2[0]) - throw i2[1]; - return i2[1]; - }, trys: [], ops: []}; - return o2 = {next: s2(0), throw: s2(1), return: s2(2)}, typeof Symbol == "function" && (o2[Symbol.iterator] = function() { - return this; - }), o2; - function s2(o3) { - return function(s3) { - return function(o4) { - if (r3) - throw new TypeError("Generator is already executing."); - for (; a2; ) - try { - if (r3 = 1, n2 && (i2 = 2 & o4[0] ? n2.return : o4[0] ? n2.throw || ((i2 = n2.return) && i2.call(n2), 0) : n2.next) && !(i2 = i2.call(n2, o4[1])).done) - return i2; - switch (n2 = 0, i2 && (o4 = [2 & o4[0], i2.value]), o4[0]) { - case 0: - case 1: - i2 = o4; - break; - case 4: - return a2.label++, {value: o4[1], done: false}; - case 5: - a2.label++, n2 = o4[1], o4 = [0]; - continue; - case 7: - o4 = a2.ops.pop(), a2.trys.pop(); - continue; - default: - if (!((i2 = (i2 = a2.trys).length > 0 && i2[i2.length - 1]) || o4[0] !== 6 && o4[0] !== 2)) { - a2 = 0; - continue; - } - if (o4[0] === 3 && (!i2 || o4[1] > i2[0] && o4[1] < i2[3])) { - a2.label = o4[1]; - break; - } - if (o4[0] === 6 && a2.label < i2[1]) { - a2.label = i2[1], i2 = o4; - break; - } - if (i2 && a2.label < i2[2]) { - a2.label = i2[2], a2.ops.push(o4); - break; - } - i2[2] && a2.ops.pop(), a2.trys.pop(); - continue; - } - o4 = e3.call(t3, a2); - } catch (t4) { - o4 = [6, t4], n2 = 0; - } finally { - r3 = i2 = 0; - } - if (5 & o4[0]) - throw o4[1]; - return {value: o4[0] ? o4[1] : void 0, done: true}; - }([o3, s3]); - }; - } - }; - Object.defineProperty(e2, "__esModule", {value: true}), e2.CasperServiceByJsonRPC = void 0; - var o = r2(4927), a = r2(3607), s = r2(4922), u = r2(4546), f = r2(5778), c = r2(2092), h = function() { - function t3(t4) { - var e3 = new o.HTTPTransport(t4), r3 = new o.RequestManager([e3]); - this.client = new o.Client(r3); - } - return t3.prototype.getDeployInfo = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, this.client.request({method: "info_get_deploy", params: {deploy_hash: t4}})]; - case 1: - return [2, e3.sent()]; - } - }); - }); - }, t3.prototype.getBlockInfo = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, this.client.request({method: "chain_get_block", params: {block_identifier: {Hash: t4}}}).then(function(e4) { - if (e4.block !== null && e4.block.hash !== t4) - throw new Error("Returned block does not have a matching hash."); - return e4; - })]; - case 1: - return [2, e3.sent()]; - } - }); - }); - }, t3.prototype.getBlockInfoByHeight = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, this.client.request({method: "chain_get_block", params: {block_identifier: {Height: t4}}}).then(function(e4) { - if (e4.block !== null && e4.block.header.height !== t4) - throw new Error("Returned block does not have a matching height."); - return e4; - })]; - case 1: - return [2, e3.sent()]; - } - }); - }); - }, t3.prototype.getLatestBlockInfo = function() { - return n(this, void 0, void 0, function() { - return i(this, function(t4) { - switch (t4.label) { - case 0: - return [4, this.client.request({method: "chain_get_block"})]; - case 1: - return [2, t4.sent()]; - } - }); - }); - }, t3.prototype.getPeers = function() { - return n(this, void 0, void 0, function() { - return i(this, function(t4) { - switch (t4.label) { - case 0: - return [4, this.client.request({method: "info_get_peers"})]; - case 1: - return [2, t4.sent()]; - } - }); - }); - }, t3.prototype.getStatus = function() { - return n(this, void 0, void 0, function() { - return i(this, function(t4) { - switch (t4.label) { - case 0: - return [4, this.client.request({method: "info_get_status"})]; - case 1: - return [2, t4.sent()]; - } - }); - }); - }, t3.prototype.getValidatorsInfo = function() { - return n(this, void 0, void 0, function() { - return i(this, function(t4) { - switch (t4.label) { - case 0: - return [4, this.client.request({method: "state_get_auction_info"})]; - case 1: - return [2, t4.sent()]; - } - }); - }); - }, t3.prototype.getAccountBalanceUrefByPublicKeyHash = function(t4, e3) { - return n(this, void 0, void 0, function() { - return i(this, function(r3) { - switch (r3.label) { - case 0: - return [4, this.getBlockState(t4, "account-hash-" + e3, []).then(function(t5) { - return t5.Account; - })]; - case 1: - return [2, r3.sent().mainPurse]; - } - }); - }); - }, t3.prototype.getAccountBalanceUrefByPublicKey = function(t4, e3) { - return n(this, void 0, void 0, function() { - return i(this, function(r3) { - return [2, this.getAccountBalanceUrefByPublicKeyHash(t4, a.encodeBase16(e3.toAccountHash()))]; - }); - }); - }, t3.prototype.getAccountBalance = function(t4, e3) { - return n(this, void 0, void 0, function() { - return i(this, function(r3) { - switch (r3.label) { - case 0: - return [4, this.client.request({method: "state_get_balance", params: {state_root_hash: t4, purse_uref: e3}}).then(function(t5) { - return c.BigNumber.from(t5.balance_value); - })]; - case 1: - return [2, r3.sent()]; - } - }); - }); - }, t3.prototype.getStateRootHash = function(t4) { - return n(this, void 0, void 0, function() { - return i(this, function(e3) { - switch (e3.label) { - case 0: - return [4, this.client.request({method: "chain_get_state_root_hash", params: {block_hash: t4}}).then(function(t5) { - return t5.state_root_hash; - })]; - case 1: - return [2, e3.sent()]; - } - }); - }); - }, t3.prototype.getBlockState = function(t4, e3, r3) { - return n(this, void 0, void 0, function() { - var n2, o2; - return i(this, function(i2) { - switch (i2.label) { - case 0: - return [4, this.client.request({method: "state_get_item", params: {state_root_hash: t4, key: e3, path: r3}})]; - case 1: - return (n2 = i2.sent()).error ? [2, n2] : (o2 = n2.stored_value, [2, new u.TypedJSON(f.StoredValue).parse(o2)]); - } - }); - }); - }, t3.prototype.deploy = function(t4) { - return n(this, void 0, void 0, function() { - var e3; - return i(this, function(r3) { - switch (r3.label) { - case 0: - if ((e3 = a.DeployUtil.deploySizeInBytes(t4)) > 1048576) - throw Error("Deploy can not be send, because it's too large: " + e3 + " bytes. Max size is 1 megabyte."); - return [4, this.client.request({method: "account_put_deploy", params: s.deployToJson(t4)})]; - case 1: - return [2, r3.sent()]; - } - }); - }); - }, t3; - }(); - e2.CasperServiceByJsonRPC = h; - }, 1999: function(t2, e2, r2) { - var n = this && this.__createBinding || (Object.create ? function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), Object.defineProperty(t3, n2, {enumerable: true, get: function() { - return e3[r3]; - }}); - } : function(t3, e3, r3, n2) { - n2 === void 0 && (n2 = r3), t3[n2] = e3[r3]; - }), i = this && this.__exportStar || function(t3, e3) { - for (var r3 in t3) - r3 === "default" || e3.hasOwnProperty(r3) || n(e3, t3, r3); - }; - Object.defineProperty(e2, "__esModule", {value: true}), i(r2(9693), e2), i(r2(8132), e2); - }, 2831: (t2, e2, r2) => { - function n(t3) { - var e3 = String(t3); - if (e3 === "[object Object]") - try { - e3 = JSON.stringify(t3); - } catch (t4) { - } - return e3; - } - r2.r(e2), r2.d(e2, {Err: () => a, ErrImpl: () => o, None: () => f, Ok: () => u, OkImpl: () => s, Option: () => c, Result: () => i, Some: () => h}); - var i, o = function() { - function t3(e3) { - if (!(this instanceof t3)) - return new t3(e3); - this.ok = false, this.err = true, this.val = e3; - } - return t3.prototype[Symbol.iterator] = function() { - return {next: function() { - return {done: true, value: void 0}; - }}; - }, t3.prototype.else = function(t4) { - return t4; - }, t3.prototype.unwrapOr = function(t4) { - return t4; - }, t3.prototype.expect = function(t4) { - throw new Error(t4 + " - Error: " + n(this.val)); - }, t3.prototype.unwrap = function() { - throw new Error("Tried to unwrap Error: " + n(this.val)); - }, t3.prototype.map = function(t4) { - return this; - }, t3.prototype.andThen = function(t4) { - return this; - }, t3.prototype.mapErr = function(t4) { - return new a(t4(this.val)); - }, t3.prototype.toString = function() { - return "Err(" + n(this.val) + ")"; - }, t3.EMPTY = new t3(void 0), t3; - }(), a = o, s = function() { - function t3(e3) { - if (!(this instanceof t3)) - return new t3(e3); - this.ok = true, this.err = false, this.val = e3; - } - return t3.prototype[Symbol.iterator] = function() { - var t4 = Object(this.val); - return Symbol.iterator in t4 ? t4[Symbol.iterator]() : {next: function() { - return {done: true, value: void 0}; - }}; - }, t3.prototype.else = function(t4) { - return this.val; - }, t3.prototype.unwrapOr = function(t4) { - return this.val; - }, t3.prototype.expect = function(t4) { - return this.val; - }, t3.prototype.unwrap = function() { - return this.val; - }, t3.prototype.map = function(t4) { - return new u(t4(this.val)); - }, t3.prototype.andThen = function(t4) { - return t4(this.val); - }, t3.prototype.mapErr = function(t4) { - return this; - }, t3.prototype.safeUnwrap = function() { - return this.val; - }, t3.prototype.toString = function() { - return "Ok(" + n(this.val) + ")"; - }, t3.EMPTY = new t3(void 0), t3; - }(), u = s; - !function(t3) { - t3.all = function() { - for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) - t4[e3] = arguments[e3]; - for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { - var o2 = i2[n2]; - if (!o2.ok) - return o2; - r3.push(o2.val); - } - return new u(r3); - }, t3.any = function() { - for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) - t4[e3] = arguments[e3]; - for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { - var o2 = i2[n2]; - if (o2.ok) - return o2; - r3.push(o2.val); - } - return new a(r3); - }, t3.wrap = function(t4) { - try { - return new u(t4()); - } catch (t5) { - return new a(t5); - } - }, t3.wrapAsync = function(t4) { - try { - return t4().then(function(t5) { - return new u(t5); - }).catch(function(t5) { - return new a(t5); - }); - } catch (t5) { - return Promise.resolve(new a(t5)); - } - }, t3.isResult = function(t4) { - return t4 instanceof a || t4 instanceof u; - }; - }(i || (i = {})); - var f = new (function() { - function t3() { - this.some = false, this.none = true; - } - return t3.prototype[Symbol.iterator] = function() { - return {next: function() { - return {done: true, value: void 0}; - }}; - }, t3.prototype.unwrapOr = function(t4) { - return t4; - }, t3.prototype.expect = function(t4) { - throw new Error("" + t4); - }, t3.prototype.unwrap = function() { - throw new Error("Tried to unwrap None"); - }, t3.prototype.map = function(t4) { - return this; - }, t3.prototype.andThen = function(t4) { - return this; - }, t3.prototype.toString = function() { - return "None"; - }, t3; - }())(); - Object.freeze(f); - var c, h = function() { - function t3(e3) { - if (!(this instanceof t3)) - return new t3(e3); - this.some = true, this.none = false, this.val = e3; - } - return t3.prototype[Symbol.iterator] = function() { - var t4 = Object(this.val); - return Symbol.iterator in t4 ? t4[Symbol.iterator]() : {next: function() { - return {done: true, value: void 0}; - }}; - }, t3.prototype.unwrapOr = function(t4) { - return this.val; - }, t3.prototype.expect = function(t4) { - return this.val; - }, t3.prototype.unwrap = function() { - return this.val; - }, t3.prototype.map = function(t4) { - return h(t4(this.val)); - }, t3.prototype.andThen = function(t4) { - return t4(this.val); - }, t3.prototype.safeUnwrap = function() { - return this.val; - }, t3.prototype.toString = function() { - return "Some(" + n(this.val) + ")"; - }, t3.EMPTY = new t3(void 0), t3; - }(); - !function(t3) { - t3.all = function() { - for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) - t4[e3] = arguments[e3]; - for (var r3 = [], n2 = 0, i2 = t4; n2 < i2.length; n2++) { - var o2 = i2[n2]; - if (!o2.some) - return o2; - r3.push(o2.val); - } - return h(r3); - }, t3.any = function() { - for (var t4 = [], e3 = 0; e3 < arguments.length; e3++) - t4[e3] = arguments[e3]; - for (var r3 = 0, n2 = t4; r3 < n2.length; r3++) { - var i2 = n2[r3]; - return i2.some, i2; - } - return f; - }, t3.isOption = function(t4) { - return t4 instanceof h || t4 === f; - }; - }(c || (c = {})); - }, 6811: (t2, e2, r2) => { - function n(t3) { - return new Uint8Array(t3); - } - function i(t3) { - return new Uint16Array(t3); - } - function o(t3) { - return new Uint32Array(t3); - } - function a(t3) { - return new Int32Array(t3); - } - function s(t3) { - return new Float64Array(t3); - } - function u(t3) { - if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t3)) - throw new TypeError("invalid base64 string"); - } - function f(t3) { - if (!/^(?:[A-Fa-f0-9]{2})+$/.test(t3)) - throw new TypeError("invalid hex string"); - } - r2.r(e2), r2.d(e2, {ByteArray: () => n, HalfArray: () => i, IntArray: () => a, NumArray: () => s, WordArray: () => o, _hash: () => mt, _onetimeauth: () => st, _randomBytes: () => A, _scalarMult: () => X, _scalarMult_base: () => Q, _verify_16: () => M, _verify_32: () => S, auth: () => Ct, auth_full: () => Kt, blake2b: () => Qt, blake2b_final: () => re, blake2b_init: () => te, blake2b_update: () => ee, blake2s: () => zt, blake2s_final: () => Ft, blake2s_init: () => qt, blake2s_update: () => Ht, box: () => ut, box_after: () => ct, box_before: () => ft, box_keyPair: () => dt, box_keyPair_fromSecretKey: () => pt, box_open: () => ht, box_open_after: () => lt, decodeBase64: () => p, decodeHex: () => g, decodeUTF8: () => l, encodeBase64: () => d, encodeHex: () => m, encodeUTF8: () => h, hash: () => yt, randomBytes: () => k, scalarMult: () => Z, scalarMult_base: () => Y, scalarbase: () => xt, scalarmult: () => Ot, sealedbox: () => le, sealedbox_open: () => de, secretbox: () => ot, secretbox_open: () => at, sign: () => wt, sign_detached: () => Mt, sign_detached_verify: () => St, sign_keyPair: () => Et, sign_keyPair_fromSecretKey: () => At, sign_keyPair_fromSeed: () => kt, sign_open: () => _t, validateBase64: () => u, validateHex: () => f, verify: () => E}); - var c = String.fromCharCode; - function h(t3) { - return decodeURIComponent(escape(c.apply(void 0, t3))); - } - function l(t3) { - if (typeof t3 != "string") - throw new TypeError("expected string"); - for (var e3 = unescape(encodeURIComponent(t3)), r3 = n(e3.length), i2 = 0; i2 < e3.length; i2++) - r3[i2] = e3.charCodeAt(i2); - return r3; - } - function d(t3) { - return btoa(c.apply(void 0, t3)); - } - function p(t3) { - u(t3); - for (var e3 = atob(t3), r3 = n(e3.length), i2 = 0; i2 < e3.length; i2++) - r3[i2] = e3.charCodeAt(i2); - return r3; - } - function y(t3) { - return t3 + (t3 < 10 ? 48 : 87); - } - function m(t3) { - for (var e3 = n(t3.length << 1), r3 = 0, i2 = void 0; r3 < t3.length; r3++) - e3[i2 = r3 << 1] = y(t3[r3] >> 8), e3[i2 + 1] = y(15 & t3[r3]); - return c.apply(void 0, e3); - } - function b(t3, e3) { - var r3 = t3.charCodeAt(e3); - return r3 - (r3 < 58 ? 48 : r3 < 71 ? 55 : 87); - } - function g(t3) { - f(t3); - for (var e3 = n(t3.length >> 1), r3 = 0; r3 < e3.length; r3 += 2) - e3[r3] = b(t3, r3) << 8 | b(t3, r3 + 1); - return e3; - } - function v(t3, e3) { - if (t3.length != 32) - throw new Error("bad key size"); - if (e3.length != 24) - throw new Error("bad nonce size"); - } - function w() { - for (var t3 = [], e3 = 0; e3 < arguments.length; e3++) - t3[e3] = arguments[e3]; - for (var r3 = 0, n2 = t3; r3 < n2.length; r3++) { - var i2 = n2[r3]; - if (!(i2 instanceof Uint8Array)) - throw new TypeError("unexpected type, use ByteArray"); - } - } - function _(t3, e3, r3, n2, i2) { - var o2, a2 = 0; - for (o2 = 0; o2 < i2; o2++) - a2 |= t3[e3 + o2] ^ r3[n2 + o2]; - return (1 & a2 - 1 >>> 8) - 1; - } - function M(t3, e3, r3, n2) { - return _(t3, e3, r3, n2, 16); - } - function S(t3, e3, r3, n2) { - return _(t3, e3, r3, n2, 32); - } - function E(t3, e3) { - return w(t3, e3), t3.length > 0 && e3.length > 0 && t3.length == e3.length && _(t3, 0, e3, 0, t3.length) == 0; - } - function A(t3, e3) { - for (var r3 = 0; r3 < e3; r3 += 65536) - crypto.getRandomValues(t3.subarray(r3, r3 + Math.min(e3 - r3, 65536))); - } - function k(t3) { - var e3 = n(t3); - return A(e3, t3), e3; - } - function B(t3) { - var e3 = s(16); - if (t3) - for (var r3 = 0; r3 < t3.length; r3++) - e3[r3] = t3[r3]; - return e3; - } - var T = n(16), x = n(32); - x[0] = 9; - var O = B(), R = B([1]), P = B([56129, 1]), I = B([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), j = B([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), U = B([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), N = B([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), C = B([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]); - function D(t3, e3, r3) { - for (var n2 = 0; n2 < 16; n2++) - t3[n2] = e3[n2] + r3[n2]; - } - function L(t3, e3, r3) { - for (var n2 = 0; n2 < 16; n2++) - t3[n2] = e3[n2] - r3[n2]; - } - function K(t3, e3, r3) { - var n2, i2, o2 = 0, a2 = 0, s2 = 0, u2 = 0, f2 = 0, c2 = 0, h2 = 0, l2 = 0, d2 = 0, p2 = 0, y2 = 0, m2 = 0, b2 = 0, g2 = 0, v2 = 0, w2 = 0, _2 = 0, M2 = 0, S2 = 0, E2 = 0, A2 = 0, k2 = 0, B2 = 0, T2 = 0, x2 = 0, O2 = 0, R2 = 0, P2 = 0, I2 = 0, j2 = 0, U2 = 0, N2 = r3[0], C2 = r3[1], D2 = r3[2], L2 = r3[3], K2 = r3[4], z2 = r3[5], q2 = r3[6], H2 = r3[7], F2 = r3[8], V2 = r3[9], W2 = r3[10], J2 = r3[11], $2 = r3[12], G2 = r3[13], Z2 = r3[14], Y2 = r3[15]; - o2 += (n2 = e3[0]) * N2, a2 += n2 * C2, s2 += n2 * D2, u2 += n2 * L2, f2 += n2 * K2, c2 += n2 * z2, h2 += n2 * q2, l2 += n2 * H2, d2 += n2 * F2, p2 += n2 * V2, y2 += n2 * W2, m2 += n2 * J2, b2 += n2 * $2, g2 += n2 * G2, v2 += n2 * Z2, w2 += n2 * Y2, a2 += (n2 = e3[1]) * N2, s2 += n2 * C2, u2 += n2 * D2, f2 += n2 * L2, c2 += n2 * K2, h2 += n2 * z2, l2 += n2 * q2, d2 += n2 * H2, p2 += n2 * F2, y2 += n2 * V2, m2 += n2 * W2, b2 += n2 * J2, g2 += n2 * $2, v2 += n2 * G2, w2 += n2 * Z2, _2 += n2 * Y2, s2 += (n2 = e3[2]) * N2, u2 += n2 * C2, f2 += n2 * D2, c2 += n2 * L2, h2 += n2 * K2, l2 += n2 * z2, d2 += n2 * q2, p2 += n2 * H2, y2 += n2 * F2, m2 += n2 * V2, b2 += n2 * W2, g2 += n2 * J2, v2 += n2 * $2, w2 += n2 * G2, _2 += n2 * Z2, M2 += n2 * Y2, u2 += (n2 = e3[3]) * N2, f2 += n2 * C2, c2 += n2 * D2, h2 += n2 * L2, l2 += n2 * K2, d2 += n2 * z2, p2 += n2 * q2, y2 += n2 * H2, m2 += n2 * F2, b2 += n2 * V2, g2 += n2 * W2, v2 += n2 * J2, w2 += n2 * $2, _2 += n2 * G2, M2 += n2 * Z2, S2 += n2 * Y2, f2 += (n2 = e3[4]) * N2, c2 += n2 * C2, h2 += n2 * D2, l2 += n2 * L2, d2 += n2 * K2, p2 += n2 * z2, y2 += n2 * q2, m2 += n2 * H2, b2 += n2 * F2, g2 += n2 * V2, v2 += n2 * W2, w2 += n2 * J2, _2 += n2 * $2, M2 += n2 * G2, S2 += n2 * Z2, E2 += n2 * Y2, c2 += (n2 = e3[5]) * N2, h2 += n2 * C2, l2 += n2 * D2, d2 += n2 * L2, p2 += n2 * K2, y2 += n2 * z2, m2 += n2 * q2, b2 += n2 * H2, g2 += n2 * F2, v2 += n2 * V2, w2 += n2 * W2, _2 += n2 * J2, M2 += n2 * $2, S2 += n2 * G2, E2 += n2 * Z2, A2 += n2 * Y2, h2 += (n2 = e3[6]) * N2, l2 += n2 * C2, d2 += n2 * D2, p2 += n2 * L2, y2 += n2 * K2, m2 += n2 * z2, b2 += n2 * q2, g2 += n2 * H2, v2 += n2 * F2, w2 += n2 * V2, _2 += n2 * W2, M2 += n2 * J2, S2 += n2 * $2, E2 += n2 * G2, A2 += n2 * Z2, k2 += n2 * Y2, l2 += (n2 = e3[7]) * N2, d2 += n2 * C2, p2 += n2 * D2, y2 += n2 * L2, m2 += n2 * K2, b2 += n2 * z2, g2 += n2 * q2, v2 += n2 * H2, w2 += n2 * F2, _2 += n2 * V2, M2 += n2 * W2, S2 += n2 * J2, E2 += n2 * $2, A2 += n2 * G2, k2 += n2 * Z2, B2 += n2 * Y2, d2 += (n2 = e3[8]) * N2, p2 += n2 * C2, y2 += n2 * D2, m2 += n2 * L2, b2 += n2 * K2, g2 += n2 * z2, v2 += n2 * q2, w2 += n2 * H2, _2 += n2 * F2, M2 += n2 * V2, S2 += n2 * W2, E2 += n2 * J2, A2 += n2 * $2, k2 += n2 * G2, B2 += n2 * Z2, T2 += n2 * Y2, p2 += (n2 = e3[9]) * N2, y2 += n2 * C2, m2 += n2 * D2, b2 += n2 * L2, g2 += n2 * K2, v2 += n2 * z2, w2 += n2 * q2, _2 += n2 * H2, M2 += n2 * F2, S2 += n2 * V2, E2 += n2 * W2, A2 += n2 * J2, k2 += n2 * $2, B2 += n2 * G2, T2 += n2 * Z2, x2 += n2 * Y2, y2 += (n2 = e3[10]) * N2, m2 += n2 * C2, b2 += n2 * D2, g2 += n2 * L2, v2 += n2 * K2, w2 += n2 * z2, _2 += n2 * q2, M2 += n2 * H2, S2 += n2 * F2, E2 += n2 * V2, A2 += n2 * W2, k2 += n2 * J2, B2 += n2 * $2, T2 += n2 * G2, x2 += n2 * Z2, O2 += n2 * Y2, m2 += (n2 = e3[11]) * N2, b2 += n2 * C2, g2 += n2 * D2, v2 += n2 * L2, w2 += n2 * K2, _2 += n2 * z2, M2 += n2 * q2, S2 += n2 * H2, E2 += n2 * F2, A2 += n2 * V2, k2 += n2 * W2, B2 += n2 * J2, T2 += n2 * $2, x2 += n2 * G2, O2 += n2 * Z2, R2 += n2 * Y2, b2 += (n2 = e3[12]) * N2, g2 += n2 * C2, v2 += n2 * D2, w2 += n2 * L2, _2 += n2 * K2, M2 += n2 * z2, S2 += n2 * q2, E2 += n2 * H2, A2 += n2 * F2, k2 += n2 * V2, B2 += n2 * W2, T2 += n2 * J2, x2 += n2 * $2, O2 += n2 * G2, R2 += n2 * Z2, P2 += n2 * Y2, g2 += (n2 = e3[13]) * N2, v2 += n2 * C2, w2 += n2 * D2, _2 += n2 * L2, M2 += n2 * K2, S2 += n2 * z2, E2 += n2 * q2, A2 += n2 * H2, k2 += n2 * F2, B2 += n2 * V2, T2 += n2 * W2, x2 += n2 * J2, O2 += n2 * $2, R2 += n2 * G2, P2 += n2 * Z2, I2 += n2 * Y2, v2 += (n2 = e3[14]) * N2, w2 += n2 * C2, _2 += n2 * D2, M2 += n2 * L2, S2 += n2 * K2, E2 += n2 * z2, A2 += n2 * q2, k2 += n2 * H2, B2 += n2 * F2, T2 += n2 * V2, x2 += n2 * W2, O2 += n2 * J2, R2 += n2 * $2, P2 += n2 * G2, I2 += n2 * Z2, j2 += n2 * Y2, w2 += (n2 = e3[15]) * N2, a2 += 38 * (M2 += n2 * D2), s2 += 38 * (S2 += n2 * L2), u2 += 38 * (E2 += n2 * K2), f2 += 38 * (A2 += n2 * z2), c2 += 38 * (k2 += n2 * q2), h2 += 38 * (B2 += n2 * H2), l2 += 38 * (T2 += n2 * F2), d2 += 38 * (x2 += n2 * V2), p2 += 38 * (O2 += n2 * W2), y2 += 38 * (R2 += n2 * J2), m2 += 38 * (P2 += n2 * $2), b2 += 38 * (I2 += n2 * G2), g2 += 38 * (j2 += n2 * Z2), v2 += 38 * (U2 += n2 * Y2), o2 = (n2 = (o2 += 38 * (_2 += n2 * C2)) + (i2 = 1) + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), a2 = (n2 = a2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), s2 = (n2 = s2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), u2 = (n2 = u2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), f2 = (n2 = f2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), c2 = (n2 = c2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), h2 = (n2 = h2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), l2 = (n2 = l2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), d2 = (n2 = d2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), p2 = (n2 = p2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), y2 = (n2 = y2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), m2 = (n2 = m2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), b2 = (n2 = b2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), g2 = (n2 = g2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), v2 = (n2 = v2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), w2 = (n2 = w2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), o2 = (n2 = (o2 += i2 - 1 + 37 * (i2 - 1)) + (i2 = 1) + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), a2 = (n2 = a2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), s2 = (n2 = s2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), u2 = (n2 = u2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), f2 = (n2 = f2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), c2 = (n2 = c2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), h2 = (n2 = h2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), l2 = (n2 = l2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), d2 = (n2 = d2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), p2 = (n2 = p2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), y2 = (n2 = y2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), m2 = (n2 = m2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), b2 = (n2 = b2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), g2 = (n2 = g2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), v2 = (n2 = v2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), w2 = (n2 = w2 + i2 + 65535) - 65536 * (i2 = Math.floor(n2 / 65536)), o2 += i2 - 1 + 37 * (i2 - 1), t3[0] = o2, t3[1] = a2, t3[2] = s2, t3[3] = u2, t3[4] = f2, t3[5] = c2, t3[6] = h2, t3[7] = l2, t3[8] = d2, t3[9] = p2, t3[10] = y2, t3[11] = m2, t3[12] = b2, t3[13] = g2, t3[14] = v2, t3[15] = w2; - } - function z(t3, e3) { - K(t3, e3, e3); - } - function q(t3, e3) { - for (var r3 = 0; r3 < 16; r3++) - t3[r3] = 0 | e3[r3]; - } - function H(t3) { - var e3, r3, n2 = 1; - for (e3 = 0; e3 < 16; e3++) - r3 = t3[e3] + n2 + 65535, n2 = Math.floor(r3 / 65536), t3[e3] = r3 - 65536 * n2; - t3[0] += n2 - 1 + 37 * (n2 - 1); - } - function F(t3, e3, r3) { - for (var n2, i2 = ~(r3 - 1), o2 = 0; o2 < 16; o2++) - n2 = i2 & (t3[o2] ^ e3[o2]), t3[o2] ^= n2, e3[o2] ^= n2; - } - function V(t3, e3) { - var r3, n2, i2, o2 = B(), a2 = B(); - for (r3 = 0; r3 < 16; r3++) - a2[r3] = e3[r3]; - for (H(a2), H(a2), H(a2), n2 = 0; n2 < 2; n2++) { - for (o2[0] = a2[0] - 65517, r3 = 1; r3 < 15; r3++) - o2[r3] = a2[r3] - 65535 - (o2[r3 - 1] >> 16 & 1), o2[r3 - 1] &= 65535; - o2[15] = a2[15] - 32767 - (o2[14] >> 16 & 1), i2 = o2[15] >> 16 & 1, o2[14] &= 65535, F(a2, o2, 1 - i2); - } - for (r3 = 0; r3 < 16; r3++) - t3[2 * r3] = 255 & a2[r3], t3[2 * r3 + 1] = a2[r3] >> 8; - } - function W(t3, e3) { - var r3 = n(32), i2 = n(32); - return V(r3, t3), V(i2, e3), S(r3, 0, i2, 0); - } - function J(t3) { - var e3 = n(32); - return V(e3, t3), 1 & e3[0]; - } - function $(t3, e3) { - for (var r3 = 0; r3 < 16; r3++) - t3[r3] = e3[2 * r3] + (e3[2 * r3 + 1] << 8); - t3[15] &= 32767; - } - function G(t3, e3) { - var r3, n2 = B(); - for (r3 = 0; r3 < 16; r3++) - n2[r3] = e3[r3]; - for (r3 = 253; r3 >= 0; r3--) - z(n2, n2), r3 !== 2 && r3 !== 4 && K(n2, n2, e3); - for (r3 = 0; r3 < 16; r3++) - t3[r3] = n2[r3]; - } - function Z(t3, e3) { - if (w(t3, e3), t3.length !== 32) - throw new Error("bad n size"); - if (e3.length !== 32) - throw new Error("bad p size"); - var r3 = n(32); - return X(r3, t3, e3), r3; - } - function Y(t3) { - if (w(t3), t3.length !== 32) - throw new Error("bad n size"); - var e3 = n(32); - return Q(e3, t3), e3; - } - function X(t3, e3, r3) { - var i2, o2, a2 = n(32), u2 = s(80), f2 = B(), c2 = B(), h2 = B(), l2 = B(), d2 = B(), p2 = B(); - for (o2 = 0; o2 < 31; o2++) - a2[o2] = e3[o2]; - for (a2[31] = 127 & e3[31] | 64, a2[0] &= 248, $(u2, r3), o2 = 0; o2 < 16; o2++) - c2[o2] = u2[o2], l2[o2] = f2[o2] = h2[o2] = 0; - for (f2[0] = l2[0] = 1, o2 = 254; o2 >= 0; --o2) - F(f2, c2, i2 = a2[o2 >>> 3] >>> (7 & o2) & 1), F(h2, l2, i2), D(d2, f2, h2), L(f2, f2, h2), D(h2, c2, l2), L(c2, c2, l2), z(l2, d2), z(p2, f2), K(f2, h2, f2), K(h2, c2, d2), D(d2, f2, h2), L(f2, f2, h2), z(c2, f2), L(h2, l2, p2), K(f2, h2, P), D(f2, f2, l2), K(h2, h2, f2), K(f2, l2, p2), K(l2, c2, u2), z(c2, d2), F(f2, c2, i2), F(h2, l2, i2); - for (o2 = 0; o2 < 16; o2++) - u2[o2 + 16] = f2[o2], u2[o2 + 32] = h2[o2], u2[o2 + 48] = c2[o2], u2[o2 + 64] = l2[o2]; - var y2 = u2.subarray(32), m2 = u2.subarray(16); - return G(y2, y2), K(m2, m2, y2), V(t3, m2), 0; - } - function Q(t3, e3) { - return X(t3, e3, x); - } - function tt(t3, e3, r3, n2) { - for (var i2, o2 = 255 & n2[0] | (255 & n2[1]) << 8 | (255 & n2[2]) << 16 | (255 & n2[3]) << 24, a2 = 255 & r3[0] | (255 & r3[1]) << 8 | (255 & r3[2]) << 16 | (255 & r3[3]) << 24, s2 = 255 & r3[4] | (255 & r3[5]) << 8 | (255 & r3[6]) << 16 | (255 & r3[7]) << 24, u2 = 255 & r3[8] | (255 & r3[9]) << 8 | (255 & r3[10]) << 16 | (255 & r3[11]) << 24, f2 = 255 & r3[12] | (255 & r3[13]) << 8 | (255 & r3[14]) << 16 | (255 & r3[15]) << 24, c2 = 255 & n2[4] | (255 & n2[5]) << 8 | (255 & n2[6]) << 16 | (255 & n2[7]) << 24, h2 = 255 & e3[0] | (255 & e3[1]) << 8 | (255 & e3[2]) << 16 | (255 & e3[3]) << 24, l2 = 255 & e3[4] | (255 & e3[5]) << 8 | (255 & e3[6]) << 16 | (255 & e3[7]) << 24, d2 = 255 & e3[8] | (255 & e3[9]) << 8 | (255 & e3[10]) << 16 | (255 & e3[11]) << 24, p2 = 255 & e3[12] | (255 & e3[13]) << 8 | (255 & e3[14]) << 16 | (255 & e3[15]) << 24, y2 = 255 & n2[8] | (255 & n2[9]) << 8 | (255 & n2[10]) << 16 | (255 & n2[11]) << 24, m2 = 255 & r3[16] | (255 & r3[17]) << 8 | (255 & r3[18]) << 16 | (255 & r3[19]) << 24, b2 = 255 & r3[20] | (255 & r3[21]) << 8 | (255 & r3[22]) << 16 | (255 & r3[23]) << 24, g2 = 255 & r3[24] | (255 & r3[25]) << 8 | (255 & r3[26]) << 16 | (255 & r3[27]) << 24, v2 = 255 & r3[28] | (255 & r3[29]) << 8 | (255 & r3[30]) << 16 | (255 & r3[31]) << 24, w2 = 255 & n2[12] | (255 & n2[13]) << 8 | (255 & n2[14]) << 16 | (255 & n2[15]) << 24, _2 = o2, M2 = a2, S2 = s2, E2 = u2, A2 = f2, k2 = c2, B2 = h2, T2 = l2, x2 = d2, O2 = p2, R2 = y2, P2 = m2, I2 = b2, j2 = g2, U2 = v2, N2 = w2, C2 = 0; C2 < 20; C2 += 2) - _2 ^= (i2 = (I2 ^= (i2 = (x2 ^= (i2 = (A2 ^= (i2 = _2 + I2 | 0) << 7 | i2 >>> 25) + _2 | 0) << 9 | i2 >>> 23) + A2 | 0) << 13 | i2 >>> 19) + x2 | 0) << 18 | i2 >>> 14, k2 ^= (i2 = (M2 ^= (i2 = (j2 ^= (i2 = (O2 ^= (i2 = k2 + M2 | 0) << 7 | i2 >>> 25) + k2 | 0) << 9 | i2 >>> 23) + O2 | 0) << 13 | i2 >>> 19) + j2 | 0) << 18 | i2 >>> 14, R2 ^= (i2 = (B2 ^= (i2 = (S2 ^= (i2 = (U2 ^= (i2 = R2 + B2 | 0) << 7 | i2 >>> 25) + R2 | 0) << 9 | i2 >>> 23) + U2 | 0) << 13 | i2 >>> 19) + S2 | 0) << 18 | i2 >>> 14, N2 ^= (i2 = (P2 ^= (i2 = (T2 ^= (i2 = (E2 ^= (i2 = N2 + P2 | 0) << 7 | i2 >>> 25) + N2 | 0) << 9 | i2 >>> 23) + E2 | 0) << 13 | i2 >>> 19) + T2 | 0) << 18 | i2 >>> 14, _2 ^= (i2 = (E2 ^= (i2 = (S2 ^= (i2 = (M2 ^= (i2 = _2 + E2 | 0) << 7 | i2 >>> 25) + _2 | 0) << 9 | i2 >>> 23) + M2 | 0) << 13 | i2 >>> 19) + S2 | 0) << 18 | i2 >>> 14, k2 ^= (i2 = (A2 ^= (i2 = (T2 ^= (i2 = (B2 ^= (i2 = k2 + A2 | 0) << 7 | i2 >>> 25) + k2 | 0) << 9 | i2 >>> 23) + B2 | 0) << 13 | i2 >>> 19) + T2 | 0) << 18 | i2 >>> 14, R2 ^= (i2 = (O2 ^= (i2 = (x2 ^= (i2 = (P2 ^= (i2 = R2 + O2 | 0) << 7 | i2 >>> 25) + R2 | 0) << 9 | i2 >>> 23) + P2 | 0) << 13 | i2 >>> 19) + x2 | 0) << 18 | i2 >>> 14, N2 ^= (i2 = (U2 ^= (i2 = (j2 ^= (i2 = (I2 ^= (i2 = N2 + U2 | 0) << 7 | i2 >>> 25) + N2 | 0) << 9 | i2 >>> 23) + I2 | 0) << 13 | i2 >>> 19) + j2 | 0) << 18 | i2 >>> 14; - _2 = _2 + o2 | 0, M2 = M2 + a2 | 0, S2 = S2 + s2 | 0, E2 = E2 + u2 | 0, A2 = A2 + f2 | 0, k2 = k2 + c2 | 0, B2 = B2 + h2 | 0, T2 = T2 + l2 | 0, x2 = x2 + d2 | 0, O2 = O2 + p2 | 0, R2 = R2 + y2 | 0, P2 = P2 + m2 | 0, I2 = I2 + b2 | 0, j2 = j2 + g2 | 0, U2 = U2 + v2 | 0, N2 = N2 + w2 | 0, t3[0] = _2 >>> 0 & 255, t3[1] = _2 >>> 8 & 255, t3[2] = _2 >>> 16 & 255, t3[3] = _2 >>> 24 & 255, t3[4] = M2 >>> 0 & 255, t3[5] = M2 >>> 8 & 255, t3[6] = M2 >>> 16 & 255, t3[7] = M2 >>> 24 & 255, t3[8] = S2 >>> 0 & 255, t3[9] = S2 >>> 8 & 255, t3[10] = S2 >>> 16 & 255, t3[11] = S2 >>> 24 & 255, t3[12] = E2 >>> 0 & 255, t3[13] = E2 >>> 8 & 255, t3[14] = E2 >>> 16 & 255, t3[15] = E2 >>> 24 & 255, t3[16] = A2 >>> 0 & 255, t3[17] = A2 >>> 8 & 255, t3[18] = A2 >>> 16 & 255, t3[19] = A2 >>> 24 & 255, t3[20] = k2 >>> 0 & 255, t3[21] = k2 >>> 8 & 255, t3[22] = k2 >>> 16 & 255, t3[23] = k2 >>> 24 & 255, t3[24] = B2 >>> 0 & 255, t3[25] = B2 >>> 8 & 255, t3[26] = B2 >>> 16 & 255, t3[27] = B2 >>> 24 & 255, t3[28] = T2 >>> 0 & 255, t3[29] = T2 >>> 8 & 255, t3[30] = T2 >>> 16 & 255, t3[31] = T2 >>> 24 & 255, t3[32] = x2 >>> 0 & 255, t3[33] = x2 >>> 8 & 255, t3[34] = x2 >>> 16 & 255, t3[35] = x2 >>> 24 & 255, t3[36] = O2 >>> 0 & 255, t3[37] = O2 >>> 8 & 255, t3[38] = O2 >>> 16 & 255, t3[39] = O2 >>> 24 & 255, t3[40] = R2 >>> 0 & 255, t3[41] = R2 >>> 8 & 255, t3[42] = R2 >>> 16 & 255, t3[43] = R2 >>> 24 & 255, t3[44] = P2 >>> 0 & 255, t3[45] = P2 >>> 8 & 255, t3[46] = P2 >>> 16 & 255, t3[47] = P2 >>> 24 & 255, t3[48] = I2 >>> 0 & 255, t3[49] = I2 >>> 8 & 255, t3[50] = I2 >>> 16 & 255, t3[51] = I2 >>> 24 & 255, t3[52] = j2 >>> 0 & 255, t3[53] = j2 >>> 8 & 255, t3[54] = j2 >>> 16 & 255, t3[55] = j2 >>> 24 & 255, t3[56] = U2 >>> 0 & 255, t3[57] = U2 >>> 8 & 255, t3[58] = U2 >>> 16 & 255, t3[59] = U2 >>> 24 & 255, t3[60] = N2 >>> 0 & 255, t3[61] = N2 >>> 8 & 255, t3[62] = N2 >>> 16 & 255, t3[63] = N2 >>> 24 & 255; - } - function et(t3, e3, r3, n2) { - for (var i2, o2 = 255 & n2[0] | (255 & n2[1]) << 8 | (255 & n2[2]) << 16 | (255 & n2[3]) << 24, a2 = 255 & r3[0] | (255 & r3[1]) << 8 | (255 & r3[2]) << 16 | (255 & r3[3]) << 24, s2 = 255 & r3[4] | (255 & r3[5]) << 8 | (255 & r3[6]) << 16 | (255 & r3[7]) << 24, u2 = 255 & r3[8] | (255 & r3[9]) << 8 | (255 & r3[10]) << 16 | (255 & r3[11]) << 24, f2 = 255 & r3[12] | (255 & r3[13]) << 8 | (255 & r3[14]) << 16 | (255 & r3[15]) << 24, c2 = 255 & n2[4] | (255 & n2[5]) << 8 | (255 & n2[6]) << 16 | (255 & n2[7]) << 24, h2 = 255 & e3[0] | (255 & e3[1]) << 8 | (255 & e3[2]) << 16 | (255 & e3[3]) << 24, l2 = 255 & e3[4] | (255 & e3[5]) << 8 | (255 & e3[6]) << 16 | (255 & e3[7]) << 24, d2 = 255 & e3[8] | (255 & e3[9]) << 8 | (255 & e3[10]) << 16 | (255 & e3[11]) << 24, p2 = 255 & e3[12] | (255 & e3[13]) << 8 | (255 & e3[14]) << 16 | (255 & e3[15]) << 24, y2 = 255 & n2[8] | (255 & n2[9]) << 8 | (255 & n2[10]) << 16 | (255 & n2[11]) << 24, m2 = 255 & r3[16] | (255 & r3[17]) << 8 | (255 & r3[18]) << 16 | (255 & r3[19]) << 24, b2 = 255 & r3[20] | (255 & r3[21]) << 8 | (255 & r3[22]) << 16 | (255 & r3[23]) << 24, g2 = 255 & r3[24] | (255 & r3[25]) << 8 | (255 & r3[26]) << 16 | (255 & r3[27]) << 24, v2 = 255 & r3[28] | (255 & r3[29]) << 8 | (255 & r3[30]) << 16 | (255 & r3[31]) << 24, w2 = 255 & n2[12] | (255 & n2[13]) << 8 | (255 & n2[14]) << 16 | (255 & n2[15]) << 24, _2 = 0; _2 < 20; _2 += 2) - o2 ^= (i2 = (b2 ^= (i2 = (d2 ^= (i2 = (f2 ^= (i2 = o2 + b2 | 0) << 7 | i2 >>> 25) + o2 | 0) << 9 | i2 >>> 23) + f2 | 0) << 13 | i2 >>> 19) + d2 | 0) << 18 | i2 >>> 14, c2 ^= (i2 = (a2 ^= (i2 = (g2 ^= (i2 = (p2 ^= (i2 = c2 + a2 | 0) << 7 | i2 >>> 25) + c2 | 0) << 9 | i2 >>> 23) + p2 | 0) << 13 | i2 >>> 19) + g2 | 0) << 18 | i2 >>> 14, y2 ^= (i2 = (h2 ^= (i2 = (s2 ^= (i2 = (v2 ^= (i2 = y2 + h2 | 0) << 7 | i2 >>> 25) + y2 | 0) << 9 | i2 >>> 23) + v2 | 0) << 13 | i2 >>> 19) + s2 | 0) << 18 | i2 >>> 14, w2 ^= (i2 = (m2 ^= (i2 = (l2 ^= (i2 = (u2 ^= (i2 = w2 + m2 | 0) << 7 | i2 >>> 25) + w2 | 0) << 9 | i2 >>> 23) + u2 | 0) << 13 | i2 >>> 19) + l2 | 0) << 18 | i2 >>> 14, o2 ^= (i2 = (u2 ^= (i2 = (s2 ^= (i2 = (a2 ^= (i2 = o2 + u2 | 0) << 7 | i2 >>> 25) + o2 | 0) << 9 | i2 >>> 23) + a2 | 0) << 13 | i2 >>> 19) + s2 | 0) << 18 | i2 >>> 14, c2 ^= (i2 = (f2 ^= (i2 = (l2 ^= (i2 = (h2 ^= (i2 = c2 + f2 | 0) << 7 | i2 >>> 25) + c2 | 0) << 9 | i2 >>> 23) + h2 | 0) << 13 | i2 >>> 19) + l2 | 0) << 18 | i2 >>> 14, y2 ^= (i2 = (p2 ^= (i2 = (d2 ^= (i2 = (m2 ^= (i2 = y2 + p2 | 0) << 7 | i2 >>> 25) + y2 | 0) << 9 | i2 >>> 23) + m2 | 0) << 13 | i2 >>> 19) + d2 | 0) << 18 | i2 >>> 14, w2 ^= (i2 = (v2 ^= (i2 = (g2 ^= (i2 = (b2 ^= (i2 = w2 + v2 | 0) << 7 | i2 >>> 25) + w2 | 0) << 9 | i2 >>> 23) + b2 | 0) << 13 | i2 >>> 19) + g2 | 0) << 18 | i2 >>> 14; - t3[0] = o2 >>> 0 & 255, t3[1] = o2 >>> 8 & 255, t3[2] = o2 >>> 16 & 255, t3[3] = o2 >>> 24 & 255, t3[4] = c2 >>> 0 & 255, t3[5] = c2 >>> 8 & 255, t3[6] = c2 >>> 16 & 255, t3[7] = c2 >>> 24 & 255, t3[8] = y2 >>> 0 & 255, t3[9] = y2 >>> 8 & 255, t3[10] = y2 >>> 16 & 255, t3[11] = y2 >>> 24 & 255, t3[12] = w2 >>> 0 & 255, t3[13] = w2 >>> 8 & 255, t3[14] = w2 >>> 16 & 255, t3[15] = w2 >>> 24 & 255, t3[16] = h2 >>> 0 & 255, t3[17] = h2 >>> 8 & 255, t3[18] = h2 >>> 16 & 255, t3[19] = h2 >>> 24 & 255, t3[20] = l2 >>> 0 & 255, t3[21] = l2 >>> 8 & 255, t3[22] = l2 >>> 16 & 255, t3[23] = l2 >>> 24 & 255, t3[24] = d2 >>> 0 & 255, t3[25] = d2 >>> 8 & 255, t3[26] = d2 >>> 16 & 255, t3[27] = d2 >>> 24 & 255, t3[28] = p2 >>> 0 & 255, t3[29] = p2 >>> 8 & 255, t3[30] = p2 >>> 16 & 255, t3[31] = p2 >>> 24 & 255; - } - var rt = n([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); - function nt(t3, e3, r3, i2, o2, a2, s2) { - var u2 = n(32), f2 = n(8); - et(u2, a2, s2, rt); - for (var c2 = 0; c2 < 8; c2++) - f2[c2] = a2[c2 + 16]; - return function(t4, e4, r4, i3, o3, a3, s3) { - var u3, f3, c3 = n(16), h2 = n(64); - for (f3 = 0; f3 < 16; f3++) - c3[f3] = 0; - for (f3 = 0; f3 < 8; f3++) - c3[f3] = a3[f3]; - for (; o3 >= 64; ) { - for (tt(h2, c3, s3, rt), f3 = 0; f3 < 64; f3++) - t4[e4 + f3] = r4[i3 + f3] ^ h2[f3]; - for (u3 = 1, f3 = 8; f3 < 16; f3++) - u3 = u3 + (255 & c3[f3]) | 0, c3[f3] = 255 & u3, u3 >>>= 8; - o3 -= 64, e4 += 64, i3 += 64; - } - if (o3 > 0) - for (tt(h2, c3, s3, rt), f3 = 0; f3 < o3; f3++) - t4[e4 + f3] = r4[i3 + f3] ^ h2[f3]; - return 0; - }(t3, e3, r3, i2, o2, f2, u2); - } - function it(t3, e3, r3, n2) { - for (var i2, o2, a2, s2, u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2, w2, _2, M2, S2 = t3.fin ? 0 : 2048, E2 = t3.h, A2 = t3.r, k2 = E2[0], B2 = E2[1], T2 = E2[2], x2 = E2[3], O2 = E2[4], R2 = E2[5], P2 = E2[6], I2 = E2[7], j2 = E2[8], U2 = E2[9], N2 = A2[0], C2 = A2[1], D2 = A2[2], L2 = A2[3], K2 = A2[4], z2 = A2[5], q2 = A2[6], H2 = A2[7], F2 = A2[8], V2 = A2[9]; n2 >= 16; ) - d2 = l2 = 0, d2 += (k2 += 8191 & (i2 = 255 & e3[r3 + 0] | (255 & e3[r3 + 1]) << 8)) * N2, d2 += (B2 += 8191 & (i2 >>> 13 | (o2 = 255 & e3[r3 + 2] | (255 & e3[r3 + 3]) << 8) << 3)) * (5 * V2), d2 += (T2 += 8191 & (o2 >>> 10 | (a2 = 255 & e3[r3 + 4] | (255 & e3[r3 + 5]) << 8) << 6)) * (5 * F2), d2 += (x2 += 8191 & (a2 >>> 7 | (s2 = 255 & e3[r3 + 6] | (255 & e3[r3 + 7]) << 8) << 9)) * (5 * H2), l2 = (d2 += (O2 += 8191 & (s2 >>> 4 | (u2 = 255 & e3[r3 + 8] | (255 & e3[r3 + 9]) << 8) << 12)) * (5 * q2)) >>> 13, d2 &= 8191, d2 += (R2 += u2 >>> 1 & 8191) * (5 * z2), d2 += (P2 += 8191 & (u2 >>> 14 | (f2 = 255 & e3[r3 + 10] | (255 & e3[r3 + 11]) << 8) << 2)) * (5 * K2), d2 += (I2 += 8191 & (f2 >>> 11 | (c2 = 255 & e3[r3 + 12] | (255 & e3[r3 + 13]) << 8) << 5)) * (5 * L2), d2 += (j2 += 8191 & (c2 >>> 8 | (h2 = 255 & e3[r3 + 14] | (255 & e3[r3 + 15]) << 8) << 8)) * (5 * D2), p2 = l2 += (d2 += (U2 += h2 >>> 5 | S2) * (5 * C2)) >>> 13, p2 += k2 * C2, p2 += B2 * N2, p2 += T2 * (5 * V2), p2 += x2 * (5 * F2), l2 = (p2 += O2 * (5 * H2)) >>> 13, p2 &= 8191, p2 += R2 * (5 * q2), p2 += P2 * (5 * z2), p2 += I2 * (5 * K2), p2 += j2 * (5 * L2), l2 += (p2 += U2 * (5 * D2)) >>> 13, p2 &= 8191, y2 = l2, y2 += k2 * D2, y2 += B2 * C2, y2 += T2 * N2, y2 += x2 * (5 * V2), l2 = (y2 += O2 * (5 * F2)) >>> 13, y2 &= 8191, y2 += R2 * (5 * H2), y2 += P2 * (5 * q2), y2 += I2 * (5 * z2), y2 += j2 * (5 * K2), m2 = l2 += (y2 += U2 * (5 * L2)) >>> 13, m2 += k2 * L2, m2 += B2 * D2, m2 += T2 * C2, m2 += x2 * N2, l2 = (m2 += O2 * (5 * V2)) >>> 13, m2 &= 8191, m2 += R2 * (5 * F2), m2 += P2 * (5 * H2), m2 += I2 * (5 * q2), m2 += j2 * (5 * z2), b2 = l2 += (m2 += U2 * (5 * K2)) >>> 13, b2 += k2 * K2, b2 += B2 * L2, b2 += T2 * D2, b2 += x2 * C2, l2 = (b2 += O2 * N2) >>> 13, b2 &= 8191, b2 += R2 * (5 * V2), b2 += P2 * (5 * F2), b2 += I2 * (5 * H2), b2 += j2 * (5 * q2), g2 = l2 += (b2 += U2 * (5 * z2)) >>> 13, g2 += k2 * z2, g2 += B2 * K2, g2 += T2 * L2, g2 += x2 * D2, l2 = (g2 += O2 * C2) >>> 13, g2 &= 8191, g2 += R2 * N2, g2 += P2 * (5 * V2), g2 += I2 * (5 * F2), g2 += j2 * (5 * H2), v2 = l2 += (g2 += U2 * (5 * q2)) >>> 13, v2 += k2 * q2, v2 += B2 * z2, v2 += T2 * K2, v2 += x2 * L2, l2 = (v2 += O2 * D2) >>> 13, v2 &= 8191, v2 += R2 * C2, v2 += P2 * N2, v2 += I2 * (5 * V2), v2 += j2 * (5 * F2), w2 = l2 += (v2 += U2 * (5 * H2)) >>> 13, w2 += k2 * H2, w2 += B2 * q2, w2 += T2 * z2, w2 += x2 * K2, l2 = (w2 += O2 * L2) >>> 13, w2 &= 8191, w2 += R2 * D2, w2 += P2 * C2, w2 += I2 * N2, w2 += j2 * (5 * V2), _2 = l2 += (w2 += U2 * (5 * F2)) >>> 13, _2 += k2 * F2, _2 += B2 * H2, _2 += T2 * q2, _2 += x2 * z2, l2 = (_2 += O2 * K2) >>> 13, _2 &= 8191, _2 += R2 * L2, _2 += P2 * D2, _2 += I2 * C2, _2 += j2 * N2, M2 = l2 += (_2 += U2 * (5 * V2)) >>> 13, M2 += k2 * V2, M2 += B2 * F2, M2 += T2 * H2, M2 += x2 * q2, l2 = (M2 += O2 * z2) >>> 13, M2 &= 8191, M2 += R2 * K2, M2 += P2 * L2, M2 += I2 * D2, M2 += j2 * C2, k2 = d2 = 8191 & (l2 = (l2 = ((l2 += (M2 += U2 * N2) >>> 13) << 2) + l2 | 0) + (d2 &= 8191) | 0), B2 = p2 += l2 >>>= 13, T2 = y2 &= 8191, x2 = m2 &= 8191, O2 = b2 &= 8191, R2 = g2 &= 8191, P2 = v2 &= 8191, I2 = w2 &= 8191, j2 = _2 &= 8191, U2 = M2 &= 8191, r3 += 16, n2 -= 16; - E2[0] = k2, E2[1] = B2, E2[2] = T2, E2[3] = x2, E2[4] = O2, E2[5] = R2, E2[6] = P2, E2[7] = I2, E2[8] = j2, E2[9] = U2; - } - function ot(t3, e3, r3) { - w(t3, e3, r3), v(r3, e3); - for (var i2 = n(32 + t3.length), o2 = n(i2.length), a2 = 0; a2 < t3.length; a2++) - i2[a2 + 32] = t3[a2]; - return function(t4, e4, r4, n2, i3) { - if (r4 < 32) - return -1; - nt(t4, 0, e4, 0, r4, n2, i3), st(t4, 16, t4, 32, r4 - 32, t4); - for (var o3 = 0; o3 < 16; o3++) - t4[o3] = 0; - }(o2, i2, i2.length, e3, r3), o2.subarray(16); - } - function at(t3, e3, r3) { - w(t3, e3, r3), v(r3, e3); - for (var i2 = n(16 + t3.length), o2 = n(i2.length), a2 = 0; a2 < t3.length; a2++) - i2[a2 + 16] = t3[a2]; - if (!(i2.length < 32 || function(t4, e4, r4, i3, o3) { - var a3 = n(32); - if (r4 < 32) - return -1; - if (function(t5, e5, r5, i4, o4) { - var a4 = n(32), s3 = n(8); - et(a4, i4, o4, rt); - for (var u2 = 0; u2 < 8; u2++) - s3[u2] = i4[u2 + 16]; - (function(t6, e6, r6, i5, o5) { - var a5, s4, u3 = n(16), f2 = n(64); - for (s4 = 0; s4 < 16; s4++) - u3[s4] = 0; - for (s4 = 0; s4 < 8; s4++) - u3[s4] = i5[s4]; - for (; r6 >= 64; ) { - for (tt(f2, u3, o5, rt), s4 = 0; s4 < 64; s4++) - t6[e6 + s4] = f2[s4]; - for (a5 = 1, s4 = 8; s4 < 16; s4++) - a5 = a5 + (255 & u3[s4]) | 0, u3[s4] = 255 & a5, a5 >>>= 8; - r6 -= 64, e6 += 64; - } - if (r6 > 0) - for (tt(f2, u3, o5, rt), s4 = 0; s4 < r6; s4++) - t6[e6 + s4] = f2[s4]; - })(t5, e5, r5, s3, a4); - }(a3, 0, 32, i3, o3), function(t5, e5, r5, i4, o4, a4) { - var s3 = n(16); - return st(s3, 0, r5, 32, o4, a4), M(t5, 16, s3, 0); - }(e4, 0, e4, 0, r4 - 32, a3) !== 0) - return -1; - nt(t4, 0, e4, 0, r4, i3, o3); - for (var s2 = 0; s2 < 32; s2++) - t4[s2] = 0; - return 0; - }(o2, i2, i2.length, e3, r3) !== 0)) - return o2.subarray(32); - } - function st(t3, e3, r3, o2, a2, s2) { - var u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2 = (u2 = s2, b2 = i(10), g2 = i(8), f2 = 255 & u2[0] | (255 & u2[1]) << 8, b2[0] = 8191 & f2, c2 = 255 & u2[2] | (255 & u2[3]) << 8, b2[1] = 8191 & (f2 >>> 13 | c2 << 3), h2 = 255 & u2[4] | (255 & u2[5]) << 8, b2[2] = 7939 & (c2 >>> 10 | h2 << 6), l2 = 255 & u2[6] | (255 & u2[7]) << 8, b2[3] = 8191 & (h2 >>> 7 | l2 << 9), d2 = 255 & u2[8] | (255 & u2[9]) << 8, b2[4] = 255 & (l2 >>> 4 | d2 << 12), b2[5] = d2 >>> 1 & 8190, p2 = 255 & u2[10] | (255 & u2[11]) << 8, b2[6] = 8191 & (d2 >>> 14 | p2 << 2), y2 = 255 & u2[12] | (255 & u2[13]) << 8, b2[7] = 8065 & (p2 >>> 11 | y2 << 5), m2 = 255 & u2[14] | (255 & u2[15]) << 8, b2[8] = 8191 & (y2 >>> 8 | m2 << 8), b2[9] = m2 >>> 5 & 127, g2[0] = 255 & u2[16] | (255 & u2[17]) << 8, g2[1] = 255 & u2[18] | (255 & u2[19]) << 8, g2[2] = 255 & u2[20] | (255 & u2[21]) << 8, g2[3] = 255 & u2[22] | (255 & u2[23]) << 8, g2[4] = 255 & u2[24] | (255 & u2[25]) << 8, g2[5] = 255 & u2[26] | (255 & u2[27]) << 8, g2[6] = 255 & u2[28] | (255 & u2[29]) << 8, g2[7] = 255 & u2[30] | (255 & u2[31]) << 8, {buffer: n(16), r: b2, h: i(10), pad: g2, leftover: 0, fin: 0}); - return function(t4, e4, r4, n2) { - var i2, o3, a3 = t4.buffer; - if (t4.leftover) { - for ((o3 = 16 - t4.leftover) > n2 && (o3 = n2), i2 = 0; i2 < o3; i2++) - a3[t4.leftover + i2] = e4[r4 + i2]; - if (n2 -= o3, r4 += o3, t4.leftover += o3, t4.leftover < 16) - return; - it(t4, a3, 0, 16), t4.leftover = 0; - } - if (n2 >= 16 && (it(t4, e4, r4, o3 = n2 - n2 % 16), r4 += o3, n2 -= o3), n2) { - for (i2 = 0; i2 < n2; i2++) - a3[t4.leftover + i2] = e4[r4 + i2]; - t4.leftover += n2; - } - }(v2, r3, o2, a2), function(t4, e4, r4) { - var n2, o3, a3, s3, u3 = i(10), f3 = t4.buffer, c3 = t4.h, h3 = t4.pad, l3 = t4.leftover; - if (l3) { - for (s3 = l3, f3[s3++] = 1; s3 < 16; s3++) - f3[s3] = 0; - t4.fin = 1, it(t4, f3, 0, 16); - } - for (n2 = c3[1] >>> 13, c3[1] &= 8191, s3 = 2; s3 < 10; s3++) - c3[s3] += n2, n2 = c3[s3] >>> 13, c3[s3] &= 8191; - for (c3[0] += 5 * n2, n2 = c3[0] >>> 13, c3[0] &= 8191, c3[1] += n2, n2 = c3[1] >>> 13, c3[1] &= 8191, c3[2] += n2, u3[0] = c3[0] + 5, n2 = u3[0] >>> 13, u3[0] &= 8191, s3 = 1; s3 < 10; s3++) - u3[s3] = c3[s3] + n2, n2 = u3[s3] >>> 13, u3[s3] &= 8191; - for (u3[9] -= 8192, o3 = (1 ^ n2) - 1, s3 = 0; s3 < 10; s3++) - u3[s3] &= o3; - for (o3 = ~o3, s3 = 0; s3 < 10; s3++) - c3[s3] = c3[s3] & o3 | u3[s3]; - for (c3[0] = 65535 & (c3[0] | c3[1] << 13), c3[1] = 65535 & (c3[1] >>> 3 | c3[2] << 10), c3[2] = 65535 & (c3[2] >>> 6 | c3[3] << 7), c3[3] = 65535 & (c3[3] >>> 9 | c3[4] << 4), c3[4] = 65535 & (c3[4] >>> 12 | c3[5] << 1 | c3[6] << 14), c3[5] = 65535 & (c3[6] >>> 2 | c3[7] << 11), c3[6] = 65535 & (c3[7] >>> 5 | c3[8] << 8), c3[7] = 65535 & (c3[8] >>> 8 | c3[9] << 5), a3 = c3[0] + h3[0], c3[0] = 65535 & a3, s3 = 1; s3 < 8; s3++) - a3 = (c3[s3] + h3[s3] | 0) + (a3 >>> 16) | 0, c3[s3] = 65535 & a3; - e4[r4 + 0] = c3[0] >>> 0 & 255, e4[r4 + 1] = c3[0] >>> 8 & 255, e4[r4 + 2] = c3[1] >>> 0 & 255, e4[r4 + 3] = c3[1] >>> 8 & 255, e4[r4 + 4] = c3[2] >>> 0 & 255, e4[r4 + 5] = c3[2] >>> 8 & 255, e4[r4 + 6] = c3[3] >>> 0 & 255, e4[r4 + 7] = c3[3] >>> 8 & 255, e4[r4 + 8] = c3[4] >>> 0 & 255, e4[r4 + 9] = c3[4] >>> 8 & 255, e4[r4 + 10] = c3[5] >>> 0 & 255, e4[r4 + 11] = c3[5] >>> 8 & 255, e4[r4 + 12] = c3[6] >>> 0 & 255, e4[r4 + 13] = c3[6] >>> 8 & 255, e4[r4 + 14] = c3[7] >>> 0 & 255, e4[r4 + 15] = c3[7] >>> 8 & 255; - }(v2, t3, e3), 0; - } - function ut(t3, e3, r3, n2) { - return ot(t3, e3, ft(r3, n2)); - } - function ft(t3, e3) { - w(t3, e3), function(t4, e4) { - if (t4.length != 32) - throw new Error("bad public key size"); - if (e4.length != 32) - throw new Error("bad secret key size"); - }(t3, e3); - var r3 = n(32); - return function(t4, e4, r4) { - var i2 = n(32); - X(i2, r4, e4), et(t4, T, i2, rt); - }(r3, t3, e3), r3; - } - var ct = ot; - function ht(t3, e3, r3, n2) { - return at(t3, e3, ft(r3, n2)); - } - var lt = at; - function dt() { - var t3, e3, r3 = n(32), i2 = n(32); - return t3 = r3, A(e3 = i2, 32), Q(t3, e3), {publicKey: r3, secretKey: i2}; - } - function pt(t3) { - if (w(t3), t3.length !== 32) - throw new Error("bad secret key size"); - var e3 = n(32); - return Q(e3, t3), {publicKey: e3, secretKey: n(t3)}; - } - function yt(t3) { - w(t3); - var e3 = n(64); - return mt(e3, t3, t3.length), e3; - } - function mt(t3, e3, r3) { - var i2, o2 = a(8), s2 = a(8), u2 = n(256), f2 = r3; - for (o2[0] = 1779033703, o2[1] = 3144134277, o2[2] = 1013904242, o2[3] = 2773480762, o2[4] = 1359893119, o2[5] = 2600822924, o2[6] = 528734635, o2[7] = 1541459225, s2[0] = 4089235720, s2[1] = 2227873595, s2[2] = 4271175723, s2[3] = 1595750129, s2[4] = 2917565137, s2[5] = 725511199, s2[6] = 4215389547, s2[7] = 327033209, gt(o2, s2, e3, r3), r3 %= 128, i2 = 0; i2 < r3; i2++) - u2[i2] = e3[f2 - r3 + i2]; - for (u2[r3] = 128, u2[(r3 = 256 - 128 * (r3 < 112 ? 1 : 0)) - 9] = 0, vt(u2, r3 - 8, f2 / 536870912 | 0, f2 << 3), gt(o2, s2, u2, r3), i2 = 0; i2 < 8; i2++) - vt(t3, 8 * i2, o2[i2], s2[i2]); - return 0; - } - var bt = [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 gt(t3, e3, r3, n2) { - for (var i2, o2, s2, u2, f2, c2, h2, l2, d2, p2, y2, m2, b2, g2, v2, w2, _2, M2, S2, E2, A2, k2, B2, T2, x2, O2, R2 = a(16), P2 = a(16), I2 = t3[0], j2 = t3[1], U2 = t3[2], N2 = t3[3], C2 = t3[4], D2 = t3[5], L2 = t3[6], K2 = t3[7], z2 = e3[0], q2 = e3[1], H2 = e3[2], F2 = e3[3], V2 = e3[4], W2 = e3[5], J2 = e3[6], $2 = e3[7], G2 = 0; n2 >= 128; ) { - for (S2 = 0; S2 < 16; S2++) - E2 = 8 * S2 + G2, R2[S2] = r3[E2 + 0] << 24 | r3[E2 + 1] << 16 | r3[E2 + 2] << 8 | r3[E2 + 3], P2[S2] = r3[E2 + 4] << 24 | r3[E2 + 5] << 16 | r3[E2 + 6] << 8 | r3[E2 + 7]; - for (S2 = 0; S2 < 80; S2++) - if (i2 = I2, o2 = j2, s2 = U2, u2 = N2, f2 = C2, c2 = D2, h2 = L2, d2 = z2, p2 = q2, y2 = H2, m2 = F2, b2 = V2, g2 = W2, v2 = J2, B2 = 65535 & (k2 = $2), T2 = k2 >>> 16, x2 = 65535 & (A2 = K2), O2 = A2 >>> 16, B2 += 65535 & (k2 = (V2 >>> 14 | C2 << 18) ^ (V2 >>> 18 | C2 << 14) ^ (C2 >>> 9 | V2 << 23)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (C2 >>> 14 | V2 << 18) ^ (C2 >>> 18 | V2 << 14) ^ (V2 >>> 9 | C2 << 23)), O2 += A2 >>> 16, B2 += 65535 & (k2 = V2 & W2 ^ ~V2 & J2), T2 += k2 >>> 16, x2 += 65535 & (A2 = C2 & D2 ^ ~C2 & L2), O2 += A2 >>> 16, B2 += 65535 & (k2 = bt[2 * S2 + 1]), T2 += k2 >>> 16, x2 += 65535 & (A2 = bt[2 * S2]), O2 += A2 >>> 16, A2 = R2[S2 % 16], T2 += (k2 = P2[S2 % 16]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16, B2 = 65535 & (k2 = M2 = 65535 & B2 | T2 << 16), T2 = k2 >>> 16, x2 = 65535 & (A2 = _2 = 65535 & x2 | (O2 += x2 >>> 16) << 16), O2 = A2 >>> 16, B2 += 65535 & (k2 = (z2 >>> 28 | I2 << 4) ^ (I2 >>> 2 | z2 << 30) ^ (I2 >>> 7 | z2 << 25)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (I2 >>> 28 | z2 << 4) ^ (z2 >>> 2 | I2 << 30) ^ (z2 >>> 7 | I2 << 25)), O2 += A2 >>> 16, T2 += (k2 = z2 & q2 ^ z2 & H2 ^ q2 & H2) >>> 16, x2 += 65535 & (A2 = I2 & j2 ^ I2 & U2 ^ j2 & U2), O2 += A2 >>> 16, l2 = 65535 & (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) | (O2 += x2 >>> 16) << 16, w2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = m2), T2 = k2 >>> 16, x2 = 65535 & (A2 = u2), O2 = A2 >>> 16, T2 += (k2 = M2) >>> 16, x2 += 65535 & (A2 = _2), O2 += A2 >>> 16, j2 = i2, U2 = o2, N2 = s2, C2 = u2 = 65535 & (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) | (O2 += x2 >>> 16) << 16, D2 = f2, L2 = c2, K2 = h2, I2 = l2, q2 = d2, H2 = p2, F2 = y2, V2 = m2 = 65535 & B2 | T2 << 16, W2 = b2, J2 = g2, $2 = v2, z2 = w2, S2 % 16 == 15) - for (E2 = 0; E2 < 16; E2++) - A2 = R2[E2], B2 = 65535 & (k2 = P2[E2]), T2 = k2 >>> 16, x2 = 65535 & A2, O2 = A2 >>> 16, A2 = R2[(E2 + 9) % 16], B2 += 65535 & (k2 = P2[(E2 + 9) % 16]), T2 += k2 >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, _2 = R2[(E2 + 1) % 16], B2 += 65535 & (k2 = ((M2 = P2[(E2 + 1) % 16]) >>> 1 | _2 << 31) ^ (M2 >>> 8 | _2 << 24) ^ (M2 >>> 7 | _2 << 25)), T2 += k2 >>> 16, x2 += 65535 & (A2 = (_2 >>> 1 | M2 << 31) ^ (_2 >>> 8 | M2 << 24) ^ _2 >>> 7), O2 += A2 >>> 16, _2 = R2[(E2 + 14) % 16], T2 += (k2 = ((M2 = P2[(E2 + 14) % 16]) >>> 19 | _2 << 13) ^ (_2 >>> 29 | M2 << 3) ^ (M2 >>> 6 | _2 << 26)) >>> 16, x2 += 65535 & (A2 = (_2 >>> 19 | M2 << 13) ^ (M2 >>> 29 | _2 << 3) ^ _2 >>> 6), O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, R2[E2] = 65535 & x2 | O2 << 16, P2[E2] = 65535 & B2 | T2 << 16; - B2 = 65535 & (k2 = z2), T2 = k2 >>> 16, x2 = 65535 & (A2 = I2), O2 = A2 >>> 16, A2 = t3[0], T2 += (k2 = e3[0]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[0] = I2 = 65535 & x2 | O2 << 16, e3[0] = z2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = q2), T2 = k2 >>> 16, x2 = 65535 & (A2 = j2), O2 = A2 >>> 16, A2 = t3[1], T2 += (k2 = e3[1]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[1] = j2 = 65535 & x2 | O2 << 16, e3[1] = q2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = H2), T2 = k2 >>> 16, x2 = 65535 & (A2 = U2), O2 = A2 >>> 16, A2 = t3[2], T2 += (k2 = e3[2]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[2] = U2 = 65535 & x2 | O2 << 16, e3[2] = H2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = F2), T2 = k2 >>> 16, x2 = 65535 & (A2 = N2), O2 = A2 >>> 16, A2 = t3[3], T2 += (k2 = e3[3]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[3] = N2 = 65535 & x2 | O2 << 16, e3[3] = F2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = V2), T2 = k2 >>> 16, x2 = 65535 & (A2 = C2), O2 = A2 >>> 16, A2 = t3[4], T2 += (k2 = e3[4]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[4] = C2 = 65535 & x2 | O2 << 16, e3[4] = V2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = W2), T2 = k2 >>> 16, x2 = 65535 & (A2 = D2), O2 = A2 >>> 16, A2 = t3[5], T2 += (k2 = e3[5]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[5] = D2 = 65535 & x2 | O2 << 16, e3[5] = W2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = J2), T2 = k2 >>> 16, x2 = 65535 & (A2 = L2), O2 = A2 >>> 16, A2 = t3[6], T2 += (k2 = e3[6]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[6] = L2 = 65535 & x2 | O2 << 16, e3[6] = J2 = 65535 & B2 | T2 << 16, B2 = 65535 & (k2 = $2), T2 = k2 >>> 16, x2 = 65535 & (A2 = K2), O2 = A2 >>> 16, A2 = t3[7], T2 += (k2 = e3[7]) >>> 16, x2 += 65535 & A2, O2 += A2 >>> 16, O2 += (x2 += (T2 += (B2 += 65535 & k2) >>> 16) >>> 16) >>> 16, t3[7] = K2 = 65535 & x2 | O2 << 16, e3[7] = $2 = 65535 & B2 | T2 << 16, G2 += 128, n2 -= 128; - } - return n2; - } - function vt(t3, e3, r3, n2) { - t3[e3] = r3 >> 24 & 255, t3[e3 + 1] = r3 >> 16 & 255, t3[e3 + 2] = r3 >> 8 & 255, t3[e3 + 3] = 255 & r3, t3[e3 + 4] = n2 >> 24 & 255, t3[e3 + 5] = n2 >> 16 & 255, t3[e3 + 6] = n2 >> 8 & 255, t3[e3 + 7] = 255 & n2; - } - function wt(t3, e3) { - if (w(t3, e3), e3.length !== 64) - throw new Error("bad secret key size"); - var r3 = n(64 + t3.length); - return function(t4, e4, r4, i2) { - var o2, a2, u2 = n(64), f2 = n(64), c2 = n(64), h2 = s(64), l2 = [B(), B(), B(), B()]; - mt(u2, i2, 32), u2[0] &= 248, u2[31] &= 127, u2[31] |= 64; - for (o2 = 0; o2 < r4; o2++) - t4[64 + o2] = e4[o2]; - for (o2 = 0; o2 < 32; o2++) - t4[32 + o2] = u2[32 + o2]; - for (mt(c2, t4.subarray(32), r4 + 32), Pt(c2), xt(l2, c2), Rt(t4, l2), o2 = 32; o2 < 64; o2++) - t4[o2] = i2[o2]; - for (mt(f2, t4, r4 + 64), Pt(f2), o2 = 0; o2 < 64; o2++) - h2[o2] = 0; - for (o2 = 0; o2 < 32; o2++) - h2[o2] = c2[o2]; - for (o2 = 0; o2 < 32; o2++) - for (a2 = 0; a2 < 32; a2++) - h2[o2 + a2] += f2[o2] * u2[a2]; - jt(t4.subarray(32), h2); - }(r3, t3, t3.length, e3), r3; - } - function _t(t3, e3) { - if (w(t3, e3), e3.length !== 32) - throw new Error("bad public key size"); - var r3 = n(t3.length), i2 = Tt(r3, t3, t3.length, e3); - if (!(i2 < 0)) { - for (var o2 = n(i2), a2 = 0; a2 < o2.length; a2++) - o2[a2] = r3[a2]; - return o2; - } - } - function Mt(t3, e3) { - for (var r3 = wt(t3, e3), i2 = n(64), o2 = 0; o2 < i2.length; o2++) - i2[o2] = r3[o2]; - return i2; - } - function St(t3, e3, r3) { - if (w(t3, e3, r3), e3.length !== 64) - throw new Error("bad signature size"); - if (r3.length !== 32) - throw new Error("bad public key size"); - var i2, o2 = n(64 + t3.length), a2 = n(64 + t3.length); - for (i2 = 0; i2 < 64; i2++) - o2[i2] = e3[i2]; - for (i2 = 0; i2 < t3.length; i2++) - o2[i2 + 64] = t3[i2]; - return Tt(a2, o2, o2.length, r3) >= 0; - } - function Et() { - var t3 = n(32), e3 = n(64); - return Bt(t3, e3, false), {publicKey: t3, secretKey: e3}; - } - function At(t3) { - if (w(t3), t3.length !== 64) - throw new Error("bad secret key size"); - for (var e3 = n(32), r3 = 0; r3 < e3.length; r3++) - e3[r3] = t3[32 + r3]; - return {publicKey: e3, secretKey: n(t3)}; - } - function kt(t3) { - if (w(t3), t3.length !== 32) - throw new Error("bad seed size"); - for (var e3 = n(32), r3 = n(64), i2 = 0; i2 < 32; i2++) - r3[i2] = t3[i2]; - return Bt(e3, r3, true), {publicKey: e3, secretKey: r3}; - } - function Bt(t3, e3, r3) { - var i2, o2 = n(64), a2 = [B(), B(), B(), B()]; - for (r3 || A(e3, 32), mt(o2, e3, 32), o2[0] &= 248, o2[31] &= 127, o2[31] |= 64, xt(a2, o2), Rt(t3, a2), i2 = 0; i2 < 32; i2++) - e3[i2 + 32] = t3[i2]; - return 0; - } - function Tt(t3, e3, r3, i2) { - var o2, a2 = n(32), s2 = n(64), u2 = [B(), B(), B(), B()], f2 = [B(), B(), B(), B()]; - if (r3 < 64 || function(t4, e4) { - var r4 = B(), n2 = B(), i3 = B(), o3 = B(), a3 = B(), s3 = B(), u3 = B(); - return q(t4[2], R), $(t4[1], e4), z(i3, t4[1]), K(o3, i3, I), L(i3, i3, t4[2]), D(o3, t4[2], o3), z(a3, o3), z(s3, a3), K(u3, s3, a3), K(r4, u3, i3), K(r4, r4, o3), function(t5, e5) { - var r5, n3 = B(); - for (r5 = 0; r5 < 16; r5++) - n3[r5] = e5[r5]; - for (r5 = 250; r5 >= 0; r5--) - z(n3, n3), r5 !== 1 && K(n3, n3, e5); - for (r5 = 0; r5 < 16; r5++) - t5[r5] = n3[r5]; - }(r4, r4), K(r4, r4, i3), K(r4, r4, o3), K(r4, r4, o3), K(t4[0], r4, o3), z(n2, t4[0]), K(n2, n2, o3), W(n2, i3) && K(t4[0], t4[0], C), z(n2, t4[0]), K(n2, n2, o3), W(n2, i3) ? -1 : (J(t4[0]) === e4[31] >> 7 && L(t4[0], O, t4[0]), K(t4[3], t4[0], t4[1]), 0); - }(f2, i2)) - return -1; - for (o2 = 0; o2 < r3; o2++) - t3[o2] = e3[o2]; - for (o2 = 0; o2 < 32; o2++) - t3[o2 + 32] = i2[o2]; - if (mt(s2, t3, r3), Pt(s2), Ot(u2, f2, s2), xt(f2, e3.subarray(32)), Ut(u2, f2), Rt(a2, u2), r3 -= 64, S(e3, 0, a2, 0)) { - for (o2 = 0; o2 < r3; o2++) - t3[o2] = 0; - return -1; - } - for (o2 = 0; o2 < r3; o2++) - t3[o2] = e3[o2 + 64]; - return r3; - } - function xt(t3, e3) { - var r3 = [B(), B(), B(), B()]; - q(r3[0], U), q(r3[1], N), q(r3[2], R), K(r3[3], U, N), Ot(t3, r3, e3); - } - function Ot(t3, e3, r3) { - var n2, i2; - for (q(t3[0], O), q(t3[1], R), q(t3[2], R), q(t3[3], O), i2 = 255; i2 >= 0; --i2) - Nt(t3, e3, n2 = r3[i2 / 8 | 0] >> (7 & i2) & 1), Ut(e3, t3), Ut(t3, t3), Nt(t3, e3, n2); - } - function Rt(t3, e3) { - var r3 = B(), n2 = B(), i2 = B(); - G(i2, e3[2]), K(r3, e3[0], i2), K(n2, e3[1], i2), V(t3, n2), t3[31] ^= J(r3) << 7; - } - function Pt(t3) { - var e3, r3 = s(64); - for (e3 = 0; e3 < 64; e3++) - r3[e3] = t3[e3]; - for (e3 = 0; e3 < 64; e3++) - t3[e3] = 0; - jt(t3, r3); - } - var It = s([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]); - function jt(t3, e3) { - var r3, n2, i2, o2; - for (n2 = 63; n2 >= 32; --n2) { - for (r3 = 0, i2 = n2 - 32, o2 = n2 - 12; i2 < o2; ++i2) - e3[i2] += r3 - 16 * e3[n2] * It[i2 - (n2 - 32)], r3 = e3[i2] + 128 >> 8, e3[i2] -= 256 * r3; - e3[i2] += r3, e3[n2] = 0; - } - for (r3 = 0, i2 = 0; i2 < 32; i2++) - e3[i2] += r3 - (e3[31] >> 4) * It[i2], r3 = e3[i2] >> 8, e3[i2] &= 255; - for (i2 = 0; i2 < 32; i2++) - e3[i2] -= r3 * It[i2]; - for (n2 = 0; n2 < 32; n2++) - e3[n2 + 1] += e3[n2] >> 8, t3[n2] = 255 & e3[n2]; - } - function Ut(t3, e3) { - var r3 = B(), n2 = B(), i2 = B(), o2 = B(), a2 = B(), s2 = B(), u2 = B(), f2 = B(), c2 = B(); - L(r3, t3[1], t3[0]), L(c2, e3[1], e3[0]), K(r3, r3, c2), D(n2, t3[0], t3[1]), D(c2, e3[0], e3[1]), K(n2, n2, c2), K(i2, t3[3], e3[3]), K(i2, i2, j), K(o2, t3[2], e3[2]), D(o2, o2, o2), L(a2, n2, r3), L(s2, o2, i2), D(u2, o2, i2), D(f2, n2, r3), K(t3[0], a2, s2), K(t3[1], f2, u2), K(t3[2], u2, s2), K(t3[3], a2, f2); - } - function Nt(t3, e3, r3) { - for (var n2 = 0; n2 < 4; n2++) - F(t3[n2], e3[n2], r3); - } - function Ct(t3, e3) { - var r3 = n(32); - return r3.set(Lt(t3, e3).subarray(0, 32)), r3; - } - var Dt = 128; - function Lt(t3, e3) { - var r3, i2, o2 = n(Dt + Math.max(64, t3.length)); - for (e3.length > Dt && (e3 = yt(e3)), r3 = 0; r3 < Dt; r3++) - o2[r3] = 54; - for (r3 = 0; r3 < e3.length; r3++) - o2[r3] ^= e3[r3]; - for (o2.set(t3, Dt), i2 = yt(o2.subarray(0, Dt + t3.length)), r3 = 0; r3 < Dt; r3++) - o2[r3] = 92; - for (r3 = 0; r3 < e3.length; r3++) - o2[r3] ^= e3[r3]; - return o2.set(i2, Dt), yt(o2.subarray(0, Dt + i2.length)); - } - var Kt = Lt; - function zt(t3, e3, r3) { - r3 === void 0 && (r3 = 32); - var n2 = qt(r3, e3); - return Ht(n2, t3), Ft(n2); - } - function qt(t3, e3) { - if (!(t3 > 0 && t3 <= 32)) - throw new Error("Incorrect output length, should be in [1, 32]"); - var r3 = e3 ? e3.length : 0; - if (e3 && !(r3 > 0 && r3 <= 32)) - throw new Error("Incorrect key length, should be in [1, 32]"); - var n2 = {h: o(Vt), b: o(64), c: 0, t: 0, outlen: t3}; - return n2.h[0] ^= 16842752 ^ r3 << 8 ^ t3, r3 && (Ht(n2, e3), n2.c = 64), n2; - } - function Ht(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) - t3.c === 64 && (t3.t += t3.c, Gt(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; - } - function Ft(t3) { - for (t3.t += t3.c; t3.c < 64; ) - t3.b[t3.c++] = 0; - Gt(t3, true); - for (var e3 = n(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) - e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3) & 255; - return e3; - } - var Vt = o([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), Wt = n([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]), Jt = o(16), $t = o(16); - function Gt(t3, e3) { - var r3 = 0; - for (r3 = 0; r3 < 8; r3++) - Jt[r3] = t3.h[r3], Jt[r3 + 8] = Vt[r3]; - for (Jt[12] ^= t3.t, Jt[13] ^= t3.t / 4294967296, e3 && (Jt[14] = ~Jt[14]), r3 = 0; r3 < 16; r3++) - $t[r3] = Zt(t3.b, 4 * r3); - for (r3 = 0; r3 < 10; r3++) - Yt(0, 4, 8, 12, $t[Wt[16 * r3 + 0]], $t[Wt[16 * r3 + 1]]), Yt(1, 5, 9, 13, $t[Wt[16 * r3 + 2]], $t[Wt[16 * r3 + 3]]), Yt(2, 6, 10, 14, $t[Wt[16 * r3 + 4]], $t[Wt[16 * r3 + 5]]), Yt(3, 7, 11, 15, $t[Wt[16 * r3 + 6]], $t[Wt[16 * r3 + 7]]), Yt(0, 5, 10, 15, $t[Wt[16 * r3 + 8]], $t[Wt[16 * r3 + 9]]), Yt(1, 6, 11, 12, $t[Wt[16 * r3 + 10]], $t[Wt[16 * r3 + 11]]), Yt(2, 7, 8, 13, $t[Wt[16 * r3 + 12]], $t[Wt[16 * r3 + 13]]), Yt(3, 4, 9, 14, $t[Wt[16 * r3 + 14]], $t[Wt[16 * r3 + 15]]); - for (r3 = 0; r3 < 8; r3++) - t3.h[r3] ^= Jt[r3] ^ Jt[r3 + 8]; - } - function Zt(t3, e3) { - return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; - } - function Yt(t3, e3, r3, n2, i2, o2) { - Jt[t3] = Jt[t3] + Jt[e3] + i2, Jt[n2] = Xt(Jt[n2] ^ Jt[t3], 16), Jt[r3] = Jt[r3] + Jt[n2], Jt[e3] = Xt(Jt[e3] ^ Jt[r3], 12), Jt[t3] = Jt[t3] + Jt[e3] + o2, Jt[n2] = Xt(Jt[n2] ^ Jt[t3], 8), Jt[r3] = Jt[r3] + Jt[n2], Jt[e3] = Xt(Jt[e3] ^ Jt[r3], 7); - } - function Xt(t3, e3) { - return t3 >>> e3 ^ t3 << 32 - e3; - } - function Qt(t3, e3, r3) { - r3 === void 0 && (r3 = 64); - var n2 = te(r3, e3); - return ee(n2, t3), re(n2); - } - function te(t3, e3) { - if (t3 === 0 || t3 > 64) - throw new Error("Illegal output length, expected 0 < length <= 64"); - if (e3 && e3.length > 64) - throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64"); - for (var r3 = o(16), i2 = 0; i2 < 16; i2++) - r3[i2] = ne[i2]; - var a2 = e3 ? e3.length : 0; - r3[0] ^= 16842752 ^ a2 << 8 ^ t3; - var s2 = {b: n(128), h: r3, t: 0, c: 0, outlen: t3}; - return e3 && (ee(s2, e3), s2.c = 128), s2; - } - function ee(t3, e3) { - for (var r3 = 0; r3 < e3.length; r3++) - t3.c === 128 && (t3.t += t3.c, se(t3, false), t3.c = 0), t3.b[t3.c++] = e3[r3]; - } - function re(t3) { - for (t3.t += t3.c; t3.c < 128; ) - t3.b[t3.c++] = 0; - se(t3, true); - for (var e3 = n(t3.outlen), r3 = 0; r3 < t3.outlen; r3++) - e3[r3] = t3.h[r3 >> 2] >> 8 * (3 & r3); - return e3; - } - var ne = o([4089235720, 1779033703, 2227873595, 3144134277, 4271175723, 1013904242, 1595750129, 2773480762, 2917565137, 1359893119, 725511199, 2600822924, 4215389547, 528734635, 327033209, 1541459225]), ie = n([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3].map(function(t3) { - return 2 * t3; - })), oe = o(32), ae = o(32); - function se(t3, e3) { - var r3; - for (r3 = 0; r3 < 16; r3++) - oe[r3] = t3.h[r3], oe[r3 + 16] = ne[r3]; - for (oe[24] = oe[24] ^ t3.t, oe[25] = oe[25] ^ t3.t / 4294967296, e3 && (oe[28] = ~oe[28], oe[29] = ~oe[29]), r3 = 0; r3 < 32; r3++) - ae[r3] = ce(t3.b, 4 * r3); - for (r3 = 0; r3 < 12; r3++) - he(0, 8, 16, 24, ie[16 * r3 + 0], ie[16 * r3 + 1]), he(2, 10, 18, 26, ie[16 * r3 + 2], ie[16 * r3 + 3]), he(4, 12, 20, 28, ie[16 * r3 + 4], ie[16 * r3 + 5]), he(6, 14, 22, 30, ie[16 * r3 + 6], ie[16 * r3 + 7]), he(0, 10, 20, 30, ie[16 * r3 + 8], ie[16 * r3 + 9]), he(2, 12, 22, 24, ie[16 * r3 + 10], ie[16 * r3 + 11]), he(4, 14, 16, 26, ie[16 * r3 + 12], ie[16 * r3 + 13]), he(6, 8, 18, 28, ie[16 * r3 + 14], ie[16 * r3 + 15]); - for (r3 = 0; r3 < 16; r3++) - t3.h[r3] = t3.h[r3] ^ oe[r3] ^ oe[r3 + 16]; - } - function ue(t3, e3, r3) { - var n2 = t3[e3] + t3[r3], i2 = t3[e3 + 1] + t3[r3 + 1]; - n2 >= 4294967296 && i2++, t3[e3] = n2, t3[e3 + 1] = i2; - } - function fe(t3, e3, r3, n2) { - var i2 = t3[e3] + r3; - r3 < 0 && (i2 += 4294967296); - var o2 = t3[e3 + 1] + n2; - i2 >= 4294967296 && o2++, t3[e3] = i2, t3[e3 + 1] = o2; - } - function ce(t3, e3) { - return t3[e3] ^ t3[e3 + 1] << 8 ^ t3[e3 + 2] << 16 ^ t3[e3 + 3] << 24; - } - function he(t3, e3, r3, n2, i2, o2) { - var a2 = ae[i2], s2 = ae[i2 + 1], u2 = ae[o2], f2 = ae[o2 + 1]; - ue(oe, t3, e3), fe(oe, t3, a2, s2); - var c2 = oe[n2] ^ oe[t3], h2 = oe[n2 + 1] ^ oe[t3 + 1]; - oe[n2] = h2, oe[n2 + 1] = c2, ue(oe, r3, n2), c2 = oe[e3] ^ oe[r3], h2 = oe[e3 + 1] ^ oe[r3 + 1], oe[e3] = c2 >>> 24 ^ h2 << 8, oe[e3 + 1] = h2 >>> 24 ^ c2 << 8, ue(oe, t3, e3), fe(oe, t3, u2, f2), c2 = oe[n2] ^ oe[t3], h2 = oe[n2 + 1] ^ oe[t3 + 1], oe[n2] = c2 >>> 16 ^ h2 << 16, oe[n2 + 1] = h2 >>> 16 ^ c2 << 16, ue(oe, r3, n2), c2 = oe[e3] ^ oe[r3], h2 = oe[e3 + 1] ^ oe[r3 + 1], oe[e3] = h2 >>> 31 ^ c2 << 1, oe[e3 + 1] = c2 >>> 31 ^ h2 << 1; - } - function le(t3, e3) { - var r3 = n(48 + t3.length), i2 = dt(); - r3.set(i2.publicKey); - var o2 = ut(t3, pe(i2.publicKey, e3), e3, i2.secretKey); - r3.set(o2, i2.publicKey.length); - for (var a2 = 0; a2 < i2.secretKey.length; a2++) - i2.secretKey[a2] = 0; - return r3; - } - function de(t3, e3, r3) { - if (!(t3.length < 48)) { - var n2 = t3.subarray(0, 32), i2 = pe(n2, e3); - return ht(t3.subarray(32), i2, n2, r3); - } - } - function pe(t3, e3) { - var r3 = te(24); - return ee(r3, t3), ee(r3, e3), re(r3); - } - }, 6885: function(t2, e2, r2) { - var n = r2(8924).Buffer; - !function(e3, r3) { - t2.exports ? t2.exports = r3() : (e3.nacl || (e3.nacl = {}), e3.nacl.util = r3()); - }(this, function() { - var t3 = {}; - function e3(t4) { - if (!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t4)) - throw new TypeError("invalid encoding"); - } - return t3.decodeUTF8 = function(t4) { - if (typeof t4 != "string") - throw new TypeError("expected string"); - var e4, r3 = unescape(encodeURIComponent(t4)), n2 = new Uint8Array(r3.length); - for (e4 = 0; e4 < r3.length; e4++) - n2[e4] = r3.charCodeAt(e4); - return n2; - }, t3.encodeUTF8 = function(t4) { - var e4, r3 = []; - for (e4 = 0; e4 < t4.length; e4++) - r3.push(String.fromCharCode(t4[e4])); - return decodeURIComponent(escape(r3.join(""))); - }, typeof atob == "undefined" ? n.from !== void 0 ? (t3.encodeBase64 = function(t4) { - return n.from(t4).toString("base64"); - }, t3.decodeBase64 = function(t4) { - return e3(t4), new Uint8Array(Array.prototype.slice.call(n.from(t4, "base64"), 0)); - }) : (t3.encodeBase64 = function(t4) { - return new n(t4).toString("base64"); - }, t3.decodeBase64 = function(t4) { - return e3(t4), new Uint8Array(Array.prototype.slice.call(new n(t4, "base64"), 0)); - }) : (t3.encodeBase64 = function(t4) { - var e4, r3 = [], n2 = t4.length; - for (e4 = 0; e4 < n2; e4++) - r3.push(String.fromCharCode(t4[e4])); - return btoa(r3.join("")); - }, t3.decodeBase64 = function(t4) { - e3(t4); - var r3, n2 = atob(t4), i = new Uint8Array(n2.length); - for (r3 = 0; r3 < n2.length; r3++) - i[r3] = n2.charCodeAt(r3); - return i; - }), t3; - }); - }, 188: (t2, e2, r2) => { - r2.d(e2, {m: () => s, Z: () => u}); - var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); - function s(t3, e3) { - if (t3.__type != null) - return e3.get(t3.__type); - } - var u = function() { - function t3() { - this.typeResolver = s, this.errorHandler = n.H, this.deserializationStrategy = new Map([[a.IK.ctor, n.yR], [Number, l], [String, l], [Boolean, l], [Date, m], [ArrayBuffer, b], [DataView, g], [Array, d], [Set, p], [Map, y], [Float32Array, w], [Float64Array, w], [Uint8Array, _], [Uint8ClampedArray, _], [Uint16Array, _], [Uint32Array, _]]); - } - return t3.prototype.setDeserializationStrategy = function(t4, e3) { - this.deserializationStrategy.set(t4, e3); - }, t3.prototype.setNameResolver = function(t4) { - this.nameResolver = t4; - }, t3.prototype.setTypeResolver = function(t4) { - if (typeof t4 != "function") - throw new TypeError("'typeResolverCallback' is not a function."); - this.typeResolver = t4; - }, t3.prototype.getTypeResolver = function() { - return this.typeResolver; - }, t3.prototype.setErrorHandler = function(t4) { - if (typeof t4 != "function") - throw new TypeError("'errorHandlerCallback' is not a function."); - this.errorHandler = t4; - }, t3.prototype.getErrorHandler = function() { - return this.errorHandler; - }, t3.prototype.convertSingleValue = function(t4, e3, r3, s2, u2) { - if (s2 === void 0 && (s2 = "object"), this.retrievePreserveNull(u2) && t4 === null) - return null; - if ((0, n.Jf)(t4)) { - var f2 = this.deserializationStrategy.get(e3.ctor); - if (f2 !== void 0) - return f2(t4, e3, r3, s2, this, u2); - if (typeof t4 == "object") - return function(t5, e4, r4, s3, u3) { - if (typeof t5 == "object" && t5 !== null) { - var f3 = e4.ctor, c3 = i.WR.getFromConstructor(f3), h2 = r4, l2 = u3.getTypeResolver(); - c3 !== void 0 && (c3.processDeferredKnownTypes(), h2 = u3.mergeKnownTypes(h2, u3.createKnownTypesMap(c3.knownTypes)), c3.typeResolver != null && (l2 = c3.typeResolver)); - var d2 = l2(t5, h2); - if (d2 != null && (0, n.me)(d2, f3) && (f3 = d2, (c3 = i.WR.getFromConstructor(d2)) !== void 0 && (h2 = u3.mergeKnownTypes(h2, u3.createKnownTypesMap(c3.knownTypes)))), (c3 == null ? void 0 : c3.isExplicitlyMarked) === true) { - var p2 = c3, y2 = {}, m2 = (0, o.JH)(u3.options, p2.options); - p2.dataMembers.forEach(function(e5, r5) { - var i2, a2 = t5[r5], s4 = (0, n.$0)(p2.classType) + "." + r5, f4 = (0, o.JH)(m2, e5.options); - if (e5.deserializer != null) - i2 = e5.deserializer(a2); - else { - if (e5.type == null) - throw new TypeError("Cannot deserialize " + s4 + " there is no constructor nor deserialization function to use."); - i2 = u3.convertSingleValue(a2, e5.type(), h2, s4, f4); - } - (0, n.Jf)(i2) || u3.retrievePreserveNull(f4) && i2 === null ? y2[e5.key] = i2 : e5.isRequired === true && u3.getErrorHandler()(new TypeError("Missing required member '" + s4 + "'.")); - }); - var b2 = void 0; - if (typeof c3.initializerCallback == "function") - try { - if ((b2 = c3.initializerCallback(y2, t5)) == null) - throw new TypeError("Cannot deserialize " + s3 + ": 'initializer' function returned undefined/null, but '" + (0, n.$0)(c3.classType) + "' was expected."); - if (!(b2 instanceof c3.classType)) - throw new TypeError("Cannot deserialize " + s3 + ":'initializer' returned '" + (0, n.$0)(b2.constructor) + "', but '" + (0, n.$0)(c3.classType) + "' was expected, and '" + (0, n.$0)(b2.constructor) + "' is not a subtype of '" + (0, n.$0)(c3.classType) + "'"); - } catch (t6) { - return void u3.getErrorHandler()(t6); - } - else - b2 = u3.instantiateType(f3); - Object.assign(b2, y2); - var g2 = c3.onDeserializedMethodName; - return g2 != null && (typeof b2[g2] == "function" ? b2[g2]() : typeof b2.constructor[g2] == "function" ? b2.constructor[g2]() : u3.getErrorHandler()(new TypeError("onDeserialized callback'" + (0, n.$0)(c3.classType) + "." + g2 + "' is not a method."))), b2; - } - var v2 = {}; - return Object.keys(t5).forEach(function(e5) { - v2[e5] = u3.convertSingleValue(t5[e5], new a.h2(t5[e5].constructor), r4, e5); - }), v2; - } - u3.getErrorHandler()(new TypeError("Cannot deserialize " + s3 + ": 'sourceObject' must be a defined object.")); - }(t4, e3, r3, s2, this); - var c2 = "Could not deserialize '" + s2 + "'; don't know how to deserialize type"; - e3.hasFriendlyName() && (c2 += " '" + e3.ctor.name + "'"), this.errorHandler(new TypeError(c2 + ".")); - } - }, t3.prototype.instantiateType = function(t4) { - return new t4(); - }, t3.prototype.mergeKnownTypes = function() { - for (var t4 = this, e3 = [], r3 = 0; r3 < arguments.length; r3++) - e3[r3] = arguments[r3]; - var n2 = new Map(); - return e3.forEach(function(e4) { - e4.forEach(function(e5, r4) { - t4.nameResolver === void 0 ? n2.set(r4, e5) : n2.set(t4.nameResolver(e5), e5); - }); - }), n2; - }, t3.prototype.createKnownTypesMap = function(t4) { - var e3 = this, r3 = new Map(); - return t4.forEach(function(t5) { - if (e3.nameResolver === void 0) { - var n2 = i.WR.getFromConstructor(t5), o2 = (n2 == null ? void 0 : n2.isExplicitlyMarked) === true ? n2.name : null; - r3.set(o2 != null ? o2 : t5.name, t5); - } else - r3.set(e3.nameResolver(t5), t5); - }), r3; - }, t3.prototype.retrievePreserveNull = function(t4) { - return (0, o.l_)("preserveNull", (0, o.JH)(this.options, t4)); - }, t3; - }(); - function f(t3, e3, r3, n2) { - throw new TypeError("Could not deserialize " + n2 + " as " + t3 + ": expected " + e3 + ", got " + r3 + "."); - } - function c(t3, e3, r3) { - return "Could not deserialize " + r3 + ": expected '" + (typeof t3 == "function" ? (0, n.$0)(t3) : t3) + "', got '" + (typeof e3 == "function" ? (0, n.$0)(e3) : e3) + "'."; - } - function h(t3) { - return t3 == null ? "undefined" : (0, n.$0)(t3.constructor); - } - function l(t3, e3, r3, i2) { - if (t3.constructor !== e3.ctor) - throw new TypeError(c((0, n.$0)(e3.ctor), t3.constructor, i2)); - return t3; - } - function d(t3, e3, r3, n2, i2, o2) { - if (!(e3 instanceof a.GJ)) - throw new TypeError("Could not deserialize " + n2 + " as Array: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); - return Array.isArray(t3) ? e3.elementType == null ? (i2.getErrorHandler()(new TypeError("Could not deserialize " + n2 + " as Array: missing constructor reference of Array elements.")), []) : t3.map(function(t4, a2) { - try { - return i2.convertSingleValue(t4, e3.elementType, r3, n2 + "[" + a2 + "]", o2); - } catch (t5) { - return void i2.getErrorHandler()(t5); - } - }) : (i2.getErrorHandler()(new TypeError(c(Array, t3.constructor, n2))), []); - } - function p(t3, e3, r3, n2, i2, o2) { - if (!(e3 instanceof a.do)) - throw new TypeError("Could not deserialize " + n2 + " as Set: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); - if (!Array.isArray(t3)) - return i2.getErrorHandler()(new TypeError(c(Array, t3.constructor, n2))), new Set(); - if (e3.elementType == null) - return i2.getErrorHandler()(new TypeError("Could not deserialize " + n2 + " as Set: missing constructor reference of Set elements.")), new Set(); - var s2 = new Set(); - return t3.forEach(function(t4, a2) { - try { - s2.add(i2.convertSingleValue(t4, e3.elementType, r3, n2 + "[" + a2 + "]", o2)); - } catch (t5) { - i2.getErrorHandler()(t5); - } - }), s2; - } - function y(t3, e3, r3, i2, o2, s2) { - if (!(e3 instanceof a.br)) - throw new TypeError("Could not deserialize " + i2 + " as Map: incorrect TypeDescriptor detected,please use proper annotation or function for this type"); - var u2 = e3.getCompleteOptions().shape; - if (!function(t4, e4) { - return e4 === 0 && Array.isArray(t4) || e4 === 1 && typeof t4 == "object"; - }(t3, u2)) { - var f2 = u2 === 0 ? Array : Object; - return o2.getErrorHandler()(new TypeError(c(f2, t3.constructor, i2))), new Map(); - } - if (e3.keyType == null) - return o2.getErrorHandler()(new TypeError("Could not deserialize " + i2 + " as Map: missing key constructor.")), new Map(); - if (e3.valueType == null) - return o2.getErrorHandler()(new TypeError("Could not deserialize " + i2 + " as Map: missing value constructor.")), new Map(); - var h2 = i2 + "[].key", l2 = i2 + "[].value", d2 = new Map(); - return u2 === 1 ? Object.keys(t3).forEach(function(i3) { - try { - var a2 = o2.convertSingleValue(i3, e3.keyType, r3, h2, s2); - (0, n.Jf)(a2) && d2.set(a2, o2.convertSingleValue(t3[i3], e3.valueType, r3, l2, s2)); - } catch (t4) { - o2.getErrorHandler()(t4); - } - }) : t3.forEach(function(t4) { - try { - var i3 = o2.convertSingleValue(t4.key, e3.keyType, r3, h2, s2); - (0, n.Jf)(i3) && d2.set(i3, o2.convertSingleValue(t4.value, e3.valueType, r3, l2, s2)); - } catch (t5) { - o2.getErrorHandler()(t5); - } - }), d2; - } - function m(t3, e3, r3, n2) { - if (typeof t3 == "number") { - if (t3 % 1 != 0) - throw new TypeError("Could not deserialize " + n2 + " as Date: expected an integer, got a number with decimal places."); - return new Date(t3); - } - return typeof t3 == "string" ? new Date(t3) : t3 instanceof Date ? t3 : void f("Date", "an ISO-8601 string", h(t3), n2); - } - function b(t3, e3, r3, n2) { - return typeof t3 != "string" && f("ArrayBuffer", "a string source", h(t3), n2), v(t3); - } - function g(t3, e3, r3, n2) { - return typeof t3 != "string" && f("DataView", "a string source", h(t3), n2), new DataView(v(t3)); - } - function v(t3) { - for (var e3 = new ArrayBuffer(2 * t3.length), r3 = new Uint16Array(e3), n2 = 0, i2 = t3.length; n2 < i2; n2++) - r3[n2] = t3.charCodeAt(n2); - return e3; - } - function w(t3, e3, r3, n2) { - var i2 = e3.ctor; - return Array.isArray(t3) && t3.every(function(t4) { - return !isNaN(t4); - }) ? new i2(t3) : f(i2.name, "a numeric source array", h(t3), n2); - } - function _(t3, e3, r3, n2) { - var i2 = e3.ctor; - return Array.isArray(t3) && t3.every(function(t4) { - return !isNaN(t4); - }) ? new i2(t3.map(function(t4) { - return ~~t4; - })) : f(e3.ctor.name, "a numeric source array", h(t3), n2); - } - }, 5077: (t2, e2, r2) => { - r2.d(e2, {Vf: () => o, AZ: () => a, lW: () => s, by: () => u, W0: () => f, me: () => c, H: () => h, KE: () => l, Jf: () => d, V9: () => p, df: () => y, $0: () => m, yR: () => b}); - var n = r2(8145), i = r2(8665), o = "If the type is not yet defined, for example due to circular references, add '() => ' before it. E.g. @jsonMember(() => Foo)", a = 'Make sure that you have both "experimentalDecorators" and "emitDecoratorMetadata" enabled in your tsconfig.json'; - function s(t3) { - return [Date, Number, String, Boolean].indexOf(t3) !== -1; - } - function u(t3) { - return [Float32Array, Float64Array, Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array].indexOf(t3) !== -1; - } - function f(t3, e3) { - return typeof t3 != "string" || function(t4, e4) { - var r3 = e4 === String || e4 === ArrayBuffer || e4 === DataView, n2 = t4.length >= 2 && t4[0] === '"' && t4[t4.length - 1] === '"'; - if (e4 === Date) { - var i2 = !isNaN(Number(t4.trim())); - return !n2 && !i2; - } - return r3 && !n2; - }(t3, e3) ? t3 : JSON.parse(t3); - } - function c(t3, e3) { - return t3 === e3 || t3.prototype instanceof e3; - } - function h(t3) { - for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) - e3[r3 - 1] = arguments[r3]; - typeof console == "object" && typeof console.error == "function" ? console.error.apply(console, (0, n.pr)([t3], e3)) : typeof console == "object" && typeof console.log == "function" && console.log.apply(console, (0, n.pr)(["ERROR: " + t3], e3)); - } - function l(t3) { - for (var e3 = [], r3 = 1; r3 < arguments.length; r3++) - e3[r3 - 1] = arguments[r3]; - typeof console == "object" && typeof console.warn == "function" ? console.warn.apply(console, (0, n.pr)([t3], e3)) : typeof console == "object" && typeof console.log == "function" && console.log.apply(console, (0, n.pr)(["WARNING: " + t3], e3)); - } - function d(t3) { - return !(t3 == null); - } - function p(t3, e3) { - return e3 === i.IK.ctor || (typeof t3 == "number" ? e3 === Number : typeof t3 == "string" ? e3 === String : typeof t3 == "boolean" ? e3 === Boolean : !!function(t4) { - return typeof t4 == "object"; - }(t3) && t3 instanceof e3); - } - var y = typeof Reflect == "object" && typeof Reflect.getMetadata == "function"; - function m(t3) { - return typeof t3.name == "string" ? t3.name : "undefined"; - } - function b(t3) { - return t3; - } - }, 4546: (t2, e2, r2) => { - r2.r(e2), r2.d(e2, {TypedJSON: () => n.r5, defaultTypeResolver: () => i.m, defaultTypeEmitter: () => o.C, JsonObjectMetadata: () => a.WR, jsonObject: () => s.O, jsonMember: () => u.R, jsonArrayMember: () => f.g, jsonSetMember: () => c.b, jsonMapMember: () => h.W, toJson: () => l.Q, ArrayT: () => d.AJ, AnyT: () => d.IK, SetT: () => d.zc, MapT: () => d.mY, SetTypeDescriptor: () => d.do, ArrayTypeDescriptor: () => d.GJ, MapTypeDescriptor: () => d.br}); - var n = r2(3380), i = r2(188), o = r2(6844), a = r2(4606), s = r2(4991), u = r2(255), f = r2(8991), c = r2(8120), h = r2(6558), l = r2(9225), d = r2(8665), p = r2(7759), y = {}; - for (const t3 in p) - ["default", "TypedJSON", "defaultTypeResolver", "defaultTypeEmitter", "JsonObjectMetadata", "jsonObject", "jsonMember", "jsonArrayMember", "jsonSetMember", "jsonMapMember", "toJson", "ArrayT", "AnyT", "SetT", "MapT", "SetTypeDescriptor", "ArrayTypeDescriptor", "MapTypeDescriptor"].indexOf(t3) < 0 && (y[t3] = () => p[t3]); - r2.d(e2, y); - }, 8991: (t2, e2, r2) => { - r2.d(e2, {g: () => s, r: () => u}); - var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); - function s(t3, e3) { - return e3 === void 0 && (e3 = {}), function(r3, s2) { - var f, c = "@jsonArrayMember on " + (0, n.$0)(r3.constructor) + "." + String(s2), h = (0, a.JD)(t3, c), l = e3.dimensions == null ? 1 : e3.dimensions; - if (!isNaN(l) && l < 1) - (0, n.H)(c + ": 'dimensions' option must be at least 1."); - else { - var d = n.df ? Reflect.getMetadata("design:type", r3, s2) : null; - d == null || d === Array || d === Object ? (0, i.d3)(r3, s2, {type: function() { - return u((0, a._k)(h()), l); - }, emitDefaultValue: e3.emitDefaultValue, isRequired: e3.isRequired, options: (0, o.M3)(e3), key: s2.toString(), name: (f = e3.name) !== null && f !== void 0 ? f : s2.toString(), deserializer: e3.deserializer, serializer: e3.serializer}) : (0, n.H)(c + ": property is not an Array. " + n.AZ); - } - }; - } - function u(t3, e3) { - for (var r3 = new a.GJ(t3), n2 = 1; n2 < e3; ++n2) - r3 = new a.GJ(r3); - return r3; - } - }, 6558: (t2, e2, r2) => { - r2.d(e2, {W: () => s}); - var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); - function s(t3, e3, r3) { - return r3 === void 0 && (r3 = {}), function(s2, u) { - var f, c = "@jsonMapMember on " + (0, n.$0)(s2.constructor) + "." + String(u), h = (0, a.JD)(t3, c), l = (0, a.JD)(e3, c), d = n.df ? Reflect.getMetadata("design:type", s2, u) : null; - d == null || d === Map || d === Object ? (0, i.d3)(s2, u, {type: function() { - return (0, a.mY)(h(), l(), {shape: r3.shape}); - }, emitDefaultValue: r3.emitDefaultValue, isRequired: r3.isRequired, options: (0, o.M3)(r3), key: u.toString(), name: (f = r3.name) !== null && f !== void 0 ? f : u.toString(), deserializer: r3.deserializer, serializer: r3.serializer}) : (0, n.H)(c + ": property is not a Map. " + n.AZ); - }; - } - }, 255: (t2, e2, r2) => { - r2.d(e2, {R: () => s}); - var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); - function s(t3, e3) { - var r3, s2; - if (typeof e3 != "string" && typeof e3 != "symbol") - return r3 = t3, s2 = e3, function(t4, e4) { - var u3, c2, h2 = "@jsonMember on " + (0, n.$0)(t4.constructor) + "." + String(e4); - if ((0, a.nW)(r3) || (0, a.p3)(r3) ? c2 = (0, a.JD)(r3, h2) : s2 = r3, s2 = s2 != null ? s2 : {}, Object.prototype.hasOwnProperty.call(s2, "constructor")) { - if (c2 !== void 0) - throw new Error("Cannot both define constructor option and type. Only one allowed."); - if (!(0, n.Jf)(s2.constructor)) - return void (0, n.H)(h2 + ": cannot resolve specified property constructor at runtime. " + n.Vf); - var l2 = (0, a._k)(s2.constructor); - c2 = function() { - return l2; - }, n.df && !(0, n.me)(l2.ctor, Reflect.getMetadata("design:type", t4, e4)) && (0, n.KE)(h2 + ": detected property type does not match 'constructor' option."); - } else if (c2 !== void 0) - ; - else if (n.df) { - var d2 = Reflect.getMetadata("design:type", t4, e4); - if (d2 == null) - return void (0, n.H)(h2 + ": cannot resolve detected property constructor at runtime. " + n.Vf); - c2 = function() { - return (0, a._k)(d2); - }; - } else if (s2.deserializer === void 0) - return void (0, n.H)(h2 + ": Cannot determine type"); - var p = c2 == null ? void 0 : c2(); - p !== void 0 && f(h2, p) || (0, i.d3)(t4, e4, {type: c2 === void 0 ? void 0 : function() { - return (0, a._k)(c2()); - }, emitDefaultValue: s2.emitDefaultValue, isRequired: s2.isRequired, options: (0, o.M3)(s2), key: e4.toString(), name: (u3 = s2.name) !== null && u3 !== void 0 ? u3 : e4.toString(), deserializer: s2.deserializer, serializer: s2.serializer}); - }; - var u2 = e3, c = t3, h = "@jsonMember on " + (0, n.$0)(c.constructor) + "." + String(u2); - if (n.df) { - var l = Reflect.getMetadata("design:type", c, u2); - if (l != null) { - var d = (0, a._k)(l); - f(h, d) || (0, i.d3)(c, u2, {type: function() { - return d; - }, key: e3.toString(), name: e3.toString()}); - } else - (0, n.H)(h + ": could not resolve detected property constructor at runtime. Potential solutions:\n - " + n.Vf + "\n - " + n.AZ); - } else - (0, n.H)(h + ": ReflectDecorators is required if the type is not explicitly provided with e.g. @jsonMember(Number)"); - } - function u(t3, e3) { - return t3 instanceof a.eh ? t3.ctor === e3 : t3 === e3; - } - function f(t3, e3) { - return e3 instanceof a.GJ || !u(e3, Array) ? e3 instanceof a.do || !u(e3, Set) ? !(e3 instanceof a.br || !u(e3, Map) || ((0, n.H)(t3 + ": property is a Map. Use the jsonMapMember decorator to serialize this property."), 0)) : ((0, n.H)(t3 + ": property is a Set. Use the jsonSetMember decorator to serialize this property."), true) : ((0, n.H)(t3 + ": property is an Array. Use the jsonArrayMember decorator to serialize this property."), true); - } - }, 4991: (t2, e2, r2) => { - r2.d(e2, {O: () => o}); - var n = r2(4606), i = r2(2651); - function o(t3) { - var e3; - function r3(t4) { - var r4 = n.WR.ensurePresentInPrototype(t4.prototype); - r4.isExplicitlyMarked = true, r4.onDeserializedMethodName = e3.onDeserialized, r4.beforeSerializationMethodName = e3.beforeSerialization, e3.typeResolver != null && (r4.typeResolver = e3.typeResolver), e3.typeHintEmitter != null && (r4.typeHintEmitter = e3.typeHintEmitter), r4.initializerCallback = e3.initializer, e3.name != null && (r4.name = e3.name); - var o2 = (0, i.M3)(e3); - o2 !== void 0 && (r4.options = o2), e3.knownTypes != null && e3.knownTypes.filter(function(t5) { - return Boolean(t5); - }).forEach(function(t5) { - return r4.knownTypes.add(t5); - }); - } - if (e3 = typeof t3 == "function" ? {} : t3 != null ? t3 : {}, typeof t3 != "function") - return r3; - r3(t3); - } - }, 8120: (t2, e2, r2) => { - r2.d(e2, {b: () => s}); - var n = r2(5077), i = r2(4606), o = r2(2651), a = r2(8665); - function s(t3, e3) { - return e3 === void 0 && (e3 = {}), function(r3, s2) { - var u, f = "@jsonSetMember on " + (0, n.$0)(r3.constructor) + "." + String(s2), c = (0, a.JD)(t3, f), h = n.df ? Reflect.getMetadata("design:type", r3, s2) : null; - h == null || h === Set || h === Object ? (0, i.d3)(r3, s2, {type: function() { - return (0, a.zc)(c()); - }, emitDefaultValue: e3.emitDefaultValue, isRequired: e3.isRequired, options: (0, o.M3)(e3), key: s2.toString(), name: (u = e3.name) !== null && u !== void 0 ? u : s2.toString(), deserializer: e3.deserializer, serializer: e3.serializer}) : (0, n.H)(f + ": property is not a Set. " + n.AZ); - }; - } - }, 4606: (t2, e2, r2) => { - r2.d(e2, {WR: () => o, d3: () => a}); - var n = r2(5077), i = "__typedJsonJsonObjectMetadataInformation__", o = function() { - function t3(t4) { - this.dataMembers = new Map(), this.knownTypes = new Set(), this.knownTypesDeferred = [], this.isExplicitlyMarked = false, this.isHandledWithoutAnnotation = false, this.classType = t4; - } - return t3.getJsonObjectName = function(e3) { - var r3 = t3.getFromConstructor(e3); - return r3 === void 0 ? (0, n.$0)(e3) : (0, n.$0)(r3.classType); - }, t3.getFromConstructor = function(e3) { - var r3 = e3.prototype; - if (r3 != null) { - var n2; - if (Object.prototype.hasOwnProperty.call(r3, i) && (n2 = r3[i]), (n2 == null ? void 0 : n2.isExplicitlyMarked) === true) - return n2; - if (t3.doesHandleWithoutAnnotation(e3)) { - var o2 = new t3(e3); - return o2.isExplicitlyMarked = true, o2; - } - } - }, t3.ensurePresentInPrototype = function(e3) { - if (Object.prototype.hasOwnProperty.call(e3, i)) - return e3[i]; - var r3 = new t3(e3.constructor), n2 = e3[i]; - return n2 !== void 0 && (n2.dataMembers.forEach(function(t4, e4) { - r3.dataMembers.set(e4, t4); - }), n2.knownTypes.forEach(function(t4) { - r3.knownTypes.add(t4); - }), r3.typeResolver = n2.typeResolver, r3.typeHintEmitter = n2.typeHintEmitter), Object.defineProperty(e3, i, {enumerable: false, configurable: false, writable: false, value: r3}), r3; - }, t3.getKnownTypeNameFromType = function(e3) { - var r3 = t3.getFromConstructor(e3); - return r3 === void 0 ? (0, n.$0)(e3) : (0, n.$0)(r3.classType); - }, t3.doesHandleWithoutAnnotation = function(t4) { - return (0, n.lW)(t4) || (0, n.by)(t4) || t4 === DataView || t4 === ArrayBuffer; - }, t3.prototype.processDeferredKnownTypes = function() { - var t4 = this; - this.knownTypesDeferred.forEach(function(e3) { - e3().getTypes().forEach(function(e4) { - return t4.knownTypes.add(e4); - }); - }), this.knownTypesDeferred = []; - }, t3; - }(); - function a(t3, e3, r3) { - var i2 = "@jsonMember on " + (0, n.$0)(t3.constructor) + "." + String(e3); - if (typeof t3 != "function") - if (typeof t3[e3] != "function") - if (r3 == null || r3.type === void 0 && r3.deserializer === void 0) - (0, n.H)(i2 + ": JsonMemberMetadata has unknown type."); - else { - var a2 = o.ensurePresentInPrototype(t3); - r3.deserializer === void 0 && a2.knownTypesDeferred.push(r3.type), Object.keys(r3).forEach(function(t4) { - return r3[t4] === void 0 && delete r3[t4]; - }), a2.dataMembers.set(r3.name, r3); - } - else - (0, n.H)(i2 + ": cannot use a method property."); - else - (0, n.H)(i2 + ": cannot use a static property."); - } - }, 2651: (t2, e2, r2) => { - r2.d(e2, {M3: () => o, l_: () => a, JH: () => s}); - var n = r2(8145), i = ["preserveNull"]; - function o(t3) { - var e3 = Object.keys(t3).filter(function(t4) { - return i.indexOf(t4) > -1; - }).reduce(function(e4, r3) { - return e4[r3] = t3[r3], e4; - }, {}); - return Object.keys(e3).length > 0 ? e3 : void 0; - } - function a(t3, e3) { - return e3 != null && e3[t3] != null ? e3[t3] : function(t4) { - switch (t4) { - case "preserveNull": - return false; - } - return null; - }(t3); - } - function s(t3, e3) { - return e3 == null ? t3 : (0, n.pi)((0, n.pi)({}, t3), e3); - } - }, 3380: (t2, e2, r2) => { - r2.d(e2, {r5: () => h}); - var n = r2(8145), i = r2(188), o = r2(5077), a = r2(8991), s = r2(4606), u = r2(2651), f = r2(6844), c = r2(8665), h = function() { - function t3(t4, e3) { - this.serializer = new f.e(), this.deserializer = new i.Z(), this.globalKnownTypes = [], this.indent = 0; - var r3 = s.WR.getFromConstructor(t4); - if (r3 === void 0 || !r3.isExplicitlyMarked && !r3.isHandledWithoutAnnotation) - throw new TypeError("The TypedJSON root data type must have the @jsonObject decorator used."); - this.nameResolver = function(t5) { - return (0, o.$0)(t5); - }, this.rootConstructor = t4, this.errorHandler = function(t5) { - return (0, o.H)(t5); - }, this.config(e3); - } - return t3.parse = function(e3, r3, n2) { - return new t3(r3, n2).parse(e3); - }, t3.parseAsArray = function(e3, r3, n2, i2) { - return new t3(r3, n2).parseAsArray(e3, i2); - }, t3.parseAsSet = function(e3, r3, n2) { - return new t3(r3, n2).parseAsSet(e3); - }, t3.parseAsMap = function(e3, r3, n2, i2) { - return new t3(n2, i2).parseAsMap(e3, r3); - }, t3.toPlainJson = function(e3, r3, n2) { - return new t3(r3, n2).toPlainJson(e3); - }, t3.toPlainArray = function(e3, r3, n2, i2) { - return new t3(r3, i2).toPlainArray(e3, n2); - }, t3.toPlainSet = function(e3, r3, n2) { - return new t3(r3, n2).toPlainSet(e3); - }, t3.toPlainMap = function(e3, r3, n2, i2) { - return new t3(n2, i2).toPlainMap(e3, r3); - }, t3.stringify = function(e3, r3, n2) { - return new t3(r3, n2).stringify(e3); - }, t3.stringifyAsArray = function(e3, r3, n2, i2) { - return new t3(r3, i2).stringifyAsArray(e3, n2); - }, t3.stringifyAsSet = function(e3, r3, n2) { - return new t3(r3, n2).stringifyAsSet(e3); - }, t3.stringifyAsMap = function(e3, r3, n2, i2) { - return new t3(n2, i2).stringifyAsMap(e3, r3); - }, t3.setGlobalConfig = function(t4) { - Object.assign(this._globalConfig, t4); - }, t3.mapType = function(t4, e3) { - this._globalConfig.mappedTypes == null && (this._globalConfig.mappedTypes = new Map()), this._globalConfig.mappedTypes.set(t4, e3); - }, t3.prototype.config = function(e3) { - var r3 = this; - (e3 = (0, n.pi)((0, n.pi)({}, t3._globalConfig), e3)).knownTypes != null && t3._globalConfig.knownTypes != null && (e3.knownTypes = Array.from(new Set(e3.knownTypes.concat(t3._globalConfig.knownTypes)))); - var i2 = (0, u.M3)(e3); - this.serializer.options = i2, this.deserializer.options = i2, e3.errorHandler != null && (this.errorHandler = e3.errorHandler, this.deserializer.setErrorHandler(e3.errorHandler), this.serializer.setErrorHandler(e3.errorHandler)), e3.replacer != null && (this.replacer = e3.replacer), e3.typeResolver != null && this.deserializer.setTypeResolver(e3.typeResolver), e3.typeHintEmitter != null && this.serializer.setTypeHintEmitter(e3.typeHintEmitter), e3.indent != null && (this.indent = e3.indent), e3.mappedTypes != null && e3.mappedTypes.forEach(function(t4, e4) { - r3.setSerializationStrategies(e4, t4); - }), e3.nameResolver != null && (this.nameResolver = e3.nameResolver, this.deserializer.setNameResolver(e3.nameResolver)), e3.knownTypes != null && (e3.knownTypes.forEach(function(t4, e4) { - t4 == null && (0, o.KE)("TypedJSON.config: 'knownTypes' contains an undefined/null value (element " + e4 + ")."); - }), this.globalKnownTypes = e3.knownTypes); - }, t3.prototype.mapType = function(t4, e3) { - this.setSerializationStrategies(t4, e3); - }, t3.prototype.parse = function(t4) { - var e3, r3 = this, n2 = (0, o.W0)(t4, this.rootConstructor), i2 = s.WR.getFromConstructor(this.rootConstructor), a2 = new Map(); - this.globalKnownTypes.filter(function(t5) { - return t5; - }).forEach(function(t5) { - a2.set(r3.nameResolver(t5), t5); - }), i2 !== void 0 && (i2.processDeferredKnownTypes(), i2.knownTypes.forEach(function(t5) { - a2.set(r3.nameResolver(t5), t5); - })); - try { - e3 = this.deserializer.convertSingleValue(n2, (0, c._k)(this.rootConstructor), a2); - } catch (t5) { - this.errorHandler(t5); - } - return e3; - }, t3.prototype.parseAsArray = function(t4, e3) { - e3 === void 0 && (e3 = 1); - var r3 = (0, o.W0)(t4, Array); - return this.deserializer.convertSingleValue(r3, (0, a.r)((0, c._k)(this.rootConstructor), e3), this._mapKnownTypes(this.globalKnownTypes)); - }, t3.prototype.parseAsSet = function(t4) { - var e3 = (0, o.W0)(t4, Set); - return this.deserializer.convertSingleValue(e3, (0, c.zc)(this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); - }, t3.prototype.parseAsMap = function(t4, e3) { - var r3 = (0, o.W0)(t4, Map); - return this.deserializer.convertSingleValue(r3, (0, c.mY)(e3, this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); - }, t3.prototype.toPlainJson = function(t4) { - try { - return this.serializer.convertSingleValue(t4, (0, c._k)(this.rootConstructor)); - } catch (t5) { - this.errorHandler(t5); - } - }, t3.prototype.toPlainArray = function(t4, e3) { - e3 === void 0 && (e3 = 1); - try { - return this.serializer.convertSingleValue(t4, (0, a.r)((0, c._k)(this.rootConstructor), e3)); - } catch (t5) { - this.errorHandler(t5); - } - }, t3.prototype.toPlainSet = function(t4) { - try { - return this.serializer.convertSingleValue(t4, (0, c.zc)(this.rootConstructor)); - } catch (t5) { - this.errorHandler(t5); - } - }, t3.prototype.toPlainMap = function(t4, e3) { - try { - return this.serializer.convertSingleValue(t4, (0, c.mY)(e3, this.rootConstructor)); - } catch (t5) { - this.errorHandler(t5); - } - }, t3.prototype.stringify = function(t4) { - var e3 = this.toPlainJson(t4); - return e3 === void 0 ? "" : JSON.stringify(e3, this.replacer, this.indent); - }, t3.prototype.stringifyAsArray = function(t4, e3) { - return JSON.stringify(this.toPlainArray(t4, e3), this.replacer, this.indent); - }, t3.prototype.stringifyAsSet = function(t4) { - return JSON.stringify(this.toPlainSet(t4), this.replacer, this.indent); - }, t3.prototype.stringifyAsMap = function(t4, e3) { - return JSON.stringify(this.toPlainMap(t4, e3), this.replacer, this.indent); - }, t3.prototype._mapKnownTypes = function(t4) { - var e3 = this, r3 = new Map(); - return t4.filter(function(t5) { - return t5; - }).forEach(function(t5) { - return r3.set(e3.nameResolver(t5), t5); - }), r3; - }, t3.prototype.setSerializationStrategies = function(t4, e3) { - e3.deserializer != null && this.deserializer.setDeserializationStrategy(t4, function(t5) { - return e3.deserializer(t5); - }), e3.serializer != null && this.serializer.setSerializationStrategy(t4, function(t5) { - return e3.serializer(t5); - }); - }, t3._globalConfig = {}, t3; - }(); - }, 6844: (t2, e2, r2) => { - r2.d(e2, {C: () => u, e: () => f}); - var n = r2(8145), i = r2(5077), o = r2(4606), a = r2(2651), s = r2(8665); - function u(t3, e3, r3, n2) { - var o2; - e3.constructor !== r3 && (t3.__type = (o2 = n2 == null ? void 0 : n2.name) !== null && o2 !== void 0 ? o2 : (0, i.$0)(e3.constructor)); - } - var f = function() { - function t3() { - this.typeHintEmitter = u, this.errorHandler = i.H, this.serializationStrategy = new Map([[s.IK.ctor, i.yR], [Date, i.yR], [Number, i.yR], [String, i.yR], [Boolean, i.yR], [ArrayBuffer, p], [DataView, y], [Array, c], [Set, h], [Map, l], [Float32Array, d], [Float64Array, d], [Int8Array, d], [Uint8Array, d], [Uint8ClampedArray, d], [Int16Array, d], [Uint16Array, d], [Int32Array, d], [Uint32Array, d]]); - } - return t3.prototype.setSerializationStrategy = function(t4, e3) { - this.serializationStrategy.set(t4, e3); - }, t3.prototype.setTypeHintEmitter = function(t4) { - if (typeof t4 != "function") - throw new TypeError("'typeEmitterCallback' is not a function."); - this.typeHintEmitter = t4; - }, t3.prototype.getTypeHintEmitter = function() { - return this.typeHintEmitter; - }, t3.prototype.setErrorHandler = function(t4) { - if (typeof t4 != "function") - throw new TypeError("'errorHandlerCallback' is not a function."); - this.errorHandler = t4; - }, t3.prototype.getErrorHandler = function() { - return this.errorHandler; - }, t3.prototype.retrievePreserveNull = function(t4) { - return (0, a.l_)("preserveNull", (0, a.JH)(this.options, t4)); - }, t3.prototype.convertSingleValue = function(t4, e3, r3, s2) { - if (r3 === void 0 && (r3 = "object"), this.retrievePreserveNull(s2) && t4 === null) - return null; - if ((0, i.Jf)(t4)) - if ((0, i.V9)(t4, e3.ctor)) { - var u2 = this.serializationStrategy.get(e3.ctor); - if (u2 !== void 0) - return u2(t4, e3, r3, this, s2); - if (typeof t4 == "object") - return function(t5, e4, r4, s3, u3) { - var f3, c3, h3 = s3.getTypeHintEmitter(); - if ((f3 = t5.constructor !== e4.ctor && t5 instanceof e4.ctor ? o.WR.getFromConstructor(t5.constructor) : o.WR.getFromConstructor(e4.ctor)) === void 0) - c3 = (0, n.pi)({}, t5); - else { - var l2 = f3.beforeSerializationMethodName; - l2 != null && (typeof t5[l2] == "function" ? t5[l2]() : typeof t5.constructor[l2] == "function" ? t5.constructor[l2]() : s3.getErrorHandler()(new TypeError("beforeSerialization callback '" + (0, i.$0)(f3.classType) + "." + l2 + "' is not a method."))); - var d2 = f3; - c3 = {}; - var p2 = (0, a.JH)(s3.options, d2.options); - d2.typeHintEmitter != null && (h3 = d2.typeHintEmitter), d2.dataMembers.forEach(function(e5) { - var r5, n2 = (0, a.JH)(p2, e5.options); - if (e5.serializer != null) - r5 = e5.serializer(t5[e5.key]); - else { - if (e5.type == null) - throw new TypeError("Could not serialize " + e5.name + ", there is no constructor nor serialization function to use."); - r5 = s3.convertSingleValue(t5[e5.key], e5.type(), (0, i.$0)(d2.classType) + "." + e5.key, n2); - } - (s3.retrievePreserveNull(n2) && r5 === null || (0, i.Jf)(r5)) && (c3[e5.name] = r5); - }); - } - return h3(c3, t5, e4.ctor, f3), c3; - }(t4, e3, 0, this); - var f2 = "Could not serialize '" + r3 + "'; don't know how to serialize type"; - e3.hasFriendlyName() && (f2 += " '" + e3.ctor.name + "'"), this.errorHandler(new TypeError(f2 + ".")); - } else { - var c2 = (0, i.$0)(e3.ctor), h2 = (0, i.$0)(t4.constructor); - this.errorHandler(new TypeError("Could not serialize '" + r3 + "': expected '" + c2 + "', got '" + h2 + "'.")); - } - }, t3; - }(); - function c(t3, e3, r3, n2, o2) { - if (!(e3 instanceof s.GJ)) - throw new TypeError("Could not serialize " + r3 + " as Array: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); - if (e3.elementType == null) - throw new TypeError("Could not serialize " + r3 + " as Array: missing element type definition."); - return t3.forEach(function(t4, a2) { - if (!(n2.retrievePreserveNull(o2) && t4 === null || (0, i.V9)(t4, e3.elementType.ctor))) { - var s2 = (0, i.$0)(e3.elementType.ctor), u2 = t4 && (0, i.$0)(t4.constructor); - throw new TypeError("Could not serialize " + r3 + "[" + a2 + "]: expected '" + s2 + "', got '" + u2 + "'."); - } - }), t3.map(function(t4, i2) { - return n2.convertSingleValue(t4, e3.elementType, r3 + "[" + i2 + "]", o2); - }); - } - function h(t3, e3, r3, n2, o2) { - if (!(e3 instanceof s.do)) - throw new TypeError("Could not serialize " + r3 + " as Set: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); - if (e3.elementType == null) - throw new TypeError("Could not serialize " + r3 + " as Set: missing element type definition."); - r3 += "[]"; - var a2 = []; - return t3.forEach(function(t4) { - var s2 = n2.convertSingleValue(t4, e3.elementType, r3, o2); - (0, i.Jf)(t4) && !(0, i.Jf)(s2) || a2.push(s2); - }), a2; - } - function l(t3, e3, r3, n2, o2) { - if (!(e3 instanceof s.br)) - throw new TypeError("Could not serialize " + r3 + " as Map: incorrect TypeDescriptor detected, please use proper annotation or function for this type"); - if (e3.valueType == null) - throw new TypeError("Could not serialize " + r3 + " as Map: missing value type definition."); - if (e3.keyType == null) - throw new TypeError("Could not serialize " + r3 + " as Map: missing key type definition."); - var a2 = r3 + "[].key", u2 = r3 + "[].value", f2 = e3.getCompleteOptions().shape, c2 = f2 === 1 ? {} : [], h2 = n2.retrievePreserveNull(o2); - return t3.forEach(function(t4, r4) { - var s2 = {key: n2.convertSingleValue(r4, e3.keyType, a2, o2), value: n2.convertSingleValue(t4, e3.valueType, u2, o2)}, l2 = (0, i.Jf)(s2.key), d2 = s2.value === null && h2 || (0, i.Jf)(s2.value); - l2 && d2 && (f2 === 1 ? c2[s2.key] = s2.value : c2.push(s2)); - }), c2; - } - function d(t3) { - return Array.from(t3); - } - function p(t3) { - return Array.from(new Uint16Array(t3)).map(function(t4) { - return String.fromCharCode(t4); - }).join(""); - } - function y(t3) { - return p(t3.buffer); - } - }, 9225: (t2, e2, r2) => { - r2.d(e2, {Q: () => i}); - var n = r2(3380); - function i(t3) { - if (typeof t3 != "function") - return function(e3) { - o(e3, t3); - }; - o(t3, {}); - } - function o(t3, e3) { - if (e3.overwrite !== true && t3.prototype.toJSON !== void 0) - throw new Error(t3.name + " already has toJSON defined!"); - t3.prototype.toJSON = function() { - return n.r5.toPlainJson(this, Object.getPrototypeOf(this).constructor); - }; - } - }, 8665: (t2, e2, r2) => { - r2.d(e2, {eh: () => o, h2: () => a, GJ: () => u, AJ: () => f, do: () => c, zc: () => h, br: () => l, mY: () => d, IK: () => p, nW: () => y, p3: () => m, _k: () => b, JD: () => g}); - var n = r2(8145), i = r2(5077), o = function() { - function t3(t4) { - this.ctor = t4; - } - return t3.prototype.getTypes = function() { - return [this.ctor]; - }, t3.prototype.hasFriendlyName = function() { - return this.ctor.name !== "Object"; - }, t3; - }(), a = function(t3) { - function e3(e4) { - return t3.call(this, e4) || this; - } - return (0, n.ZT)(e3, t3), e3; - }(o), s = function(t3) { - function e3(e4) { - return t3.call(this, e4) || this; - } - return (0, n.ZT)(e3, t3), e3; - }(o), u = function(t3) { - function e3(e4) { - var r3 = t3.call(this, Array) || this; - return r3.elementType = e4, r3; - } - return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { - return t3.prototype.getTypes.call(this).concat(this.elementType.getTypes()); - }, e3; - }(s); - function f(t3) { - return new u(b(t3)); - } - var c = function(t3) { - function e3(e4) { - var r3 = t3.call(this, Set) || this; - return r3.elementType = e4, r3; - } - return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { - return t3.prototype.getTypes.call(this).concat(this.elementType.getTypes()); - }, e3; - }(s); - function h(t3) { - return new c(b(t3)); - } - var l = function(t3) { - function e3(e4, r3, n2) { - var i2 = t3.call(this, Map) || this; - return i2.keyType = e4, i2.valueType = r3, i2.options = n2, i2; - } - return (0, n.ZT)(e3, t3), e3.prototype.getTypes = function() { - return t3.prototype.getTypes.call(this).concat(this.keyType.getTypes(), this.valueType.getTypes()); - }, e3.prototype.getCompleteOptions = function() { - var t4, e4; - return {shape: (e4 = (t4 = this.options) === null || t4 === void 0 ? void 0 : t4.shape) !== null && e4 !== void 0 ? e4 : 0}; - }, e3; - }(s); - function d(t3, e3, r3) { - return new l(b(t3), b(e3), r3); - } - var p = new a(function() { - }); - function y(t3) { - return t3 != null && (typeof t3 == "function" || t3 instanceof o); - } - function m(t3) { - return typeof t3 == "function" && t3.name === ""; - } - function b(t3) { - return t3 instanceof o ? t3 : new a(t3); - } - function g(t3, e3) { - if (t3 == null) - throw new Error("No type given on " + e3 + ". " + i.Vf); - return m(t3) ? t3 : function() { - return t3; - }; - } - }, 7759: () => { - }, 8145: (t2, e2, r2) => { - r2.d(e2, {ZT: () => i, pi: () => o, pr: () => a}); - var n = function(t3, e3) { - return (n = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(t4, e4) { - t4.__proto__ = e4; - } || function(t4, e4) { - for (var r3 in e4) - Object.prototype.hasOwnProperty.call(e4, r3) && (t4[r3] = e4[r3]); - })(t3, e3); - }; - function i(t3, e3) { - if (typeof e3 != "function" && e3 !== null) - throw new TypeError("Class extends value " + String(e3) + " is not a constructor or null"); - function r3() { - this.constructor = t3; - } - n(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3()); - } - var o = function() { - return (o = Object.assign || function(t3) { - for (var e3, r3 = 1, n2 = arguments.length; r3 < n2; r3++) - for (var i2 in e3 = arguments[r3]) - Object.prototype.hasOwnProperty.call(e3, i2) && (t3[i2] = e3[i2]); - return t3; - }).apply(this, arguments); - }; - function a() { - for (var t3 = 0, e3 = 0, r3 = arguments.length; e3 < r3; e3++) - t3 += arguments[e3].length; - var n2 = Array(t3), i2 = 0; - for (e3 = 0; e3 < r3; e3++) - for (var o2 = arguments[e3], a2 = 0, s = o2.length; a2 < s; a2++, i2++) - n2[i2] = o2[a2]; - return n2; - } - }, 7781: (t2, e2, r2) => { - function n(t3) { - try { - if (!r2.g.localStorage) - return false; - } catch (t4) { - return false; - } - var e3 = r2.g.localStorage[t3]; - return e3 != null && String(e3).toLowerCase() === "true"; - } - t2.exports = function(t3, e3) { - if (n("noDeprecation")) - return t3; - var r3 = false; - return function() { - if (!r3) { - if (n("throwDeprecation")) - throw new Error(e3); - n("traceDeprecation") ? console.trace(e3) : console.warn(e3), r3 = true; - } - return t3.apply(this, arguments); - }; - }; - }, 384: (t2) => { - t2.exports = function(t3) { - return t3 && typeof t3 == "object" && typeof t3.copy == "function" && typeof t3.fill == "function" && typeof t3.readUInt8 == "function"; - }; - }, 5955: (t2, e2, r2) => { - var n = r2(2584), i = r2(8662), o = r2(6430), a = r2(5692); - function s(t3) { - return t3.call.bind(t3); - } - var u = typeof BigInt != "undefined", f = typeof Symbol != "undefined", c = s(Object.prototype.toString), h = s(Number.prototype.valueOf), l = s(String.prototype.valueOf), d = s(Boolean.prototype.valueOf); - if (u) - var p = s(BigInt.prototype.valueOf); - if (f) - var y = s(Symbol.prototype.valueOf); - function m(t3, e3) { - if (typeof t3 != "object") - return false; - try { - return e3(t3), true; - } catch (t4) { - return false; - } - } - function b(t3) { - return c(t3) === "[object Map]"; - } - function g(t3) { - return c(t3) === "[object Set]"; - } - function v(t3) { - return c(t3) === "[object WeakMap]"; - } - function w(t3) { - return c(t3) === "[object WeakSet]"; - } - function _(t3) { - return c(t3) === "[object ArrayBuffer]"; - } - function M(t3) { - return typeof ArrayBuffer != "undefined" && (_.working ? _(t3) : t3 instanceof ArrayBuffer); - } - function S(t3) { - return c(t3) === "[object DataView]"; - } - function E(t3) { - return typeof DataView != "undefined" && (S.working ? S(t3) : t3 instanceof DataView); - } - function A(t3) { - return c(t3) === "[object SharedArrayBuffer]"; - } - function k(t3) { - return typeof SharedArrayBuffer != "undefined" && (A.working ? A(t3) : t3 instanceof SharedArrayBuffer); - } - function B(t3) { - return m(t3, h); - } - function T(t3) { - return m(t3, l); - } - function x(t3) { - return m(t3, d); - } - function O(t3) { - return u && m(t3, p); - } - function R(t3) { - return f && m(t3, y); - } - e2.isArgumentsObject = n, e2.isGeneratorFunction = i, e2.isTypedArray = a, e2.isPromise = function(t3) { - return typeof Promise != "undefined" && t3 instanceof Promise || t3 !== null && typeof t3 == "object" && typeof t3.then == "function" && typeof t3.catch == "function"; - }, e2.isArrayBufferView = function(t3) { - return typeof ArrayBuffer != "undefined" && ArrayBuffer.isView ? ArrayBuffer.isView(t3) : a(t3) || E(t3); - }, e2.isUint8Array = function(t3) { - return o(t3) === "Uint8Array"; - }, e2.isUint8ClampedArray = function(t3) { - return o(t3) === "Uint8ClampedArray"; - }, e2.isUint16Array = function(t3) { - return o(t3) === "Uint16Array"; - }, e2.isUint32Array = function(t3) { - return o(t3) === "Uint32Array"; - }, e2.isInt8Array = function(t3) { - return o(t3) === "Int8Array"; - }, e2.isInt16Array = function(t3) { - return o(t3) === "Int16Array"; - }, e2.isInt32Array = function(t3) { - return o(t3) === "Int32Array"; - }, e2.isFloat32Array = function(t3) { - return o(t3) === "Float32Array"; - }, e2.isFloat64Array = function(t3) { - return o(t3) === "Float64Array"; - }, e2.isBigInt64Array = function(t3) { - return o(t3) === "BigInt64Array"; - }, e2.isBigUint64Array = function(t3) { - return o(t3) === "BigUint64Array"; - }, b.working = typeof Map != "undefined" && b(new Map()), e2.isMap = function(t3) { - return typeof Map != "undefined" && (b.working ? b(t3) : t3 instanceof Map); - }, g.working = typeof Set != "undefined" && g(new Set()), e2.isSet = function(t3) { - return typeof Set != "undefined" && (g.working ? g(t3) : t3 instanceof Set); - }, v.working = typeof WeakMap != "undefined" && v(new WeakMap()), e2.isWeakMap = function(t3) { - return typeof WeakMap != "undefined" && (v.working ? v(t3) : t3 instanceof WeakMap); - }, w.working = typeof WeakSet != "undefined" && w(new WeakSet()), e2.isWeakSet = function(t3) { - return w(t3); - }, _.working = typeof ArrayBuffer != "undefined" && _(new ArrayBuffer()), e2.isArrayBuffer = M, S.working = typeof ArrayBuffer != "undefined" && typeof DataView != "undefined" && S(new DataView(new ArrayBuffer(1), 0, 1)), e2.isDataView = E, A.working = typeof SharedArrayBuffer != "undefined" && A(new SharedArrayBuffer()), e2.isSharedArrayBuffer = k, e2.isAsyncFunction = function(t3) { - return c(t3) === "[object AsyncFunction]"; - }, e2.isMapIterator = function(t3) { - return c(t3) === "[object Map Iterator]"; - }, e2.isSetIterator = function(t3) { - return c(t3) === "[object Set Iterator]"; - }, e2.isGeneratorObject = function(t3) { - return c(t3) === "[object Generator]"; - }, e2.isWebAssemblyCompiledModule = function(t3) { - return c(t3) === "[object WebAssembly.Module]"; - }, e2.isNumberObject = B, e2.isStringObject = T, e2.isBooleanObject = x, e2.isBigIntObject = O, e2.isSymbolObject = R, e2.isBoxedPrimitive = function(t3) { - return B(t3) || T(t3) || x(t3) || O(t3) || R(t3); - }, e2.isAnyArrayBuffer = function(t3) { - return typeof Uint8Array != "undefined" && (M(t3) || k(t3)); - }, ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function(t3) { - Object.defineProperty(e2, t3, {enumerable: false, value: function() { - throw new Error(t3 + " is not supported in userland"); - }}); - }); - }, 9539: (t2, e2, r2) => { - var n = r2(4155), i = Object.getOwnPropertyDescriptors || function(t3) { - for (var e3 = Object.keys(t3), r3 = {}, n2 = 0; n2 < e3.length; n2++) - r3[e3[n2]] = Object.getOwnPropertyDescriptor(t3, e3[n2]); - return r3; - }, o = /%[sdj%]/g; - e2.format = function(t3) { - if (!v(t3)) { - for (var e3 = [], r3 = 0; r3 < arguments.length; r3++) - e3.push(f(arguments[r3])); - return e3.join(" "); - } - r3 = 1; - for (var n2 = arguments, i2 = n2.length, a2 = String(t3).replace(o, function(t4) { - if (t4 === "%%") - return "%"; - if (r3 >= i2) - return t4; - switch (t4) { - case "%s": - return String(n2[r3++]); - case "%d": - return Number(n2[r3++]); - case "%j": - try { - return JSON.stringify(n2[r3++]); - } catch (t5) { - return "[Circular]"; - } - default: - return t4; - } - }), s2 = n2[r3]; r3 < i2; s2 = n2[++r3]) - b(s2) || !M(s2) ? a2 += " " + s2 : a2 += " " + f(s2); - return a2; - }, e2.deprecate = function(t3, r3) { - if (n !== void 0 && n.noDeprecation === true) - return t3; - if (n === void 0) - return function() { - return e2.deprecate(t3, r3).apply(this, arguments); - }; - var i2 = false; - return function() { - if (!i2) { - if (n.throwDeprecation) - throw new Error(r3); - n.traceDeprecation ? console.trace(r3) : console.error(r3), i2 = true; - } - return t3.apply(this, arguments); - }; - }; - var a = {}, s = /^$/; - if (n.env.NODE_DEBUG) { - var u = n.env.NODE_DEBUG; - u = u.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase(), s = new RegExp("^" + u + "$", "i"); - } - function f(t3, r3) { - var n2 = {seen: [], stylize: h}; - return arguments.length >= 3 && (n2.depth = arguments[2]), arguments.length >= 4 && (n2.colors = arguments[3]), m(r3) ? n2.showHidden = r3 : r3 && e2._extend(n2, r3), w(n2.showHidden) && (n2.showHidden = false), w(n2.depth) && (n2.depth = 2), w(n2.colors) && (n2.colors = false), w(n2.customInspect) && (n2.customInspect = true), n2.colors && (n2.stylize = c), l(n2, t3, n2.depth); - } - function c(t3, e3) { - var r3 = f.styles[e3]; - return r3 ? "[" + f.colors[r3][0] + "m" + t3 + "[" + f.colors[r3][1] + "m" : t3; - } - function h(t3, e3) { - return t3; - } - function l(t3, r3, n2) { - if (t3.customInspect && r3 && A(r3.inspect) && r3.inspect !== e2.inspect && (!r3.constructor || r3.constructor.prototype !== r3)) { - var i2 = r3.inspect(n2, t3); - return v(i2) || (i2 = l(t3, i2, n2)), i2; - } - var o2 = function(t4, e3) { - if (w(e3)) - return t4.stylize("undefined", "undefined"); - if (v(e3)) { - var r4 = "'" + JSON.stringify(e3).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; - return t4.stylize(r4, "string"); - } - return g(e3) ? t4.stylize("" + e3, "number") : m(e3) ? t4.stylize("" + e3, "boolean") : b(e3) ? t4.stylize("null", "null") : void 0; - }(t3, r3); - if (o2) - return o2; - var a2 = Object.keys(r3), s2 = function(t4) { - var e3 = {}; - return t4.forEach(function(t5, r4) { - e3[t5] = true; - }), e3; - }(a2); - if (t3.showHidden && (a2 = Object.getOwnPropertyNames(r3)), E(r3) && (a2.indexOf("message") >= 0 || a2.indexOf("description") >= 0)) - return d(r3); - if (a2.length === 0) { - if (A(r3)) { - var u2 = r3.name ? ": " + r3.name : ""; - return t3.stylize("[Function" + u2 + "]", "special"); - } - if (_(r3)) - return t3.stylize(RegExp.prototype.toString.call(r3), "regexp"); - if (S(r3)) - return t3.stylize(Date.prototype.toString.call(r3), "date"); - if (E(r3)) - return d(r3); - } - var f2, c2 = "", h2 = false, M2 = ["{", "}"]; - return y(r3) && (h2 = true, M2 = ["[", "]"]), A(r3) && (c2 = " [Function" + (r3.name ? ": " + r3.name : "") + "]"), _(r3) && (c2 = " " + RegExp.prototype.toString.call(r3)), S(r3) && (c2 = " " + Date.prototype.toUTCString.call(r3)), E(r3) && (c2 = " " + d(r3)), a2.length !== 0 || h2 && r3.length != 0 ? n2 < 0 ? _(r3) ? t3.stylize(RegExp.prototype.toString.call(r3), "regexp") : t3.stylize("[Object]", "special") : (t3.seen.push(r3), f2 = h2 ? function(t4, e3, r4, n3, i3) { - for (var o3 = [], a3 = 0, s3 = e3.length; a3 < s3; ++a3) - O(e3, String(a3)) ? o3.push(p(t4, e3, r4, n3, String(a3), true)) : o3.push(""); - return i3.forEach(function(i4) { - i4.match(/^\d+$/) || o3.push(p(t4, e3, r4, n3, i4, true)); - }), o3; - }(t3, r3, n2, s2, a2) : a2.map(function(e3) { - return p(t3, r3, n2, s2, e3, h2); - }), t3.seen.pop(), function(t4, e3, r4) { - return t4.reduce(function(t5, e4) { - return e4.indexOf("\n"), t5 + e4.replace(/\u001b\[\d\d?m/g, "").length + 1; - }, 0) > 60 ? r4[0] + (e3 === "" ? "" : e3 + "\n ") + " " + t4.join(",\n ") + " " + r4[1] : r4[0] + e3 + " " + t4.join(", ") + " " + r4[1]; - }(f2, c2, M2)) : M2[0] + c2 + M2[1]; - } - function d(t3) { - return "[" + Error.prototype.toString.call(t3) + "]"; - } - function p(t3, e3, r3, n2, i2, o2) { - var a2, s2, u2; - if ((u2 = Object.getOwnPropertyDescriptor(e3, i2) || {value: e3[i2]}).get ? s2 = u2.set ? t3.stylize("[Getter/Setter]", "special") : t3.stylize("[Getter]", "special") : u2.set && (s2 = t3.stylize("[Setter]", "special")), O(n2, i2) || (a2 = "[" + i2 + "]"), s2 || (t3.seen.indexOf(u2.value) < 0 ? (s2 = b(r3) ? l(t3, u2.value, null) : l(t3, u2.value, r3 - 1)).indexOf("\n") > -1 && (s2 = o2 ? s2.split("\n").map(function(t4) { - return " " + t4; - }).join("\n").substr(2) : "\n" + s2.split("\n").map(function(t4) { - return " " + t4; - }).join("\n")) : s2 = t3.stylize("[Circular]", "special")), w(a2)) { - if (o2 && i2.match(/^\d+$/)) - return s2; - (a2 = JSON.stringify("" + i2)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (a2 = a2.substr(1, a2.length - 2), a2 = t3.stylize(a2, "name")) : (a2 = a2.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), a2 = t3.stylize(a2, "string")); - } - return a2 + ": " + s2; - } - function y(t3) { - return Array.isArray(t3); - } - function m(t3) { - return typeof t3 == "boolean"; - } - function b(t3) { - return t3 === null; - } - function g(t3) { - return typeof t3 == "number"; - } - function v(t3) { - return typeof t3 == "string"; - } - function w(t3) { - return t3 === void 0; - } - function _(t3) { - return M(t3) && k(t3) === "[object RegExp]"; - } - function M(t3) { - return typeof t3 == "object" && t3 !== null; - } - function S(t3) { - return M(t3) && k(t3) === "[object Date]"; - } - function E(t3) { - return M(t3) && (k(t3) === "[object Error]" || t3 instanceof Error); - } - function A(t3) { - return typeof t3 == "function"; - } - function k(t3) { - return Object.prototype.toString.call(t3); - } - function B(t3) { - return t3 < 10 ? "0" + t3.toString(10) : t3.toString(10); - } - e2.debuglog = function(t3) { - if (t3 = t3.toUpperCase(), !a[t3]) - if (s.test(t3)) { - var r3 = n.pid; - a[t3] = function() { - var n2 = e2.format.apply(e2, arguments); - console.error("%s %d: %s", t3, r3, n2); - }; - } else - a[t3] = function() { - }; - return a[t3]; - }, e2.inspect = f, f.colors = {bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39]}, f.styles = {special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red"}, e2.types = r2(5955), e2.isArray = y, e2.isBoolean = m, e2.isNull = b, e2.isNullOrUndefined = function(t3) { - return t3 == null; - }, e2.isNumber = g, e2.isString = v, e2.isSymbol = function(t3) { - return typeof t3 == "symbol"; - }, e2.isUndefined = w, e2.isRegExp = _, e2.types.isRegExp = _, e2.isObject = M, e2.isDate = S, e2.types.isDate = S, e2.isError = E, e2.types.isNativeError = E, e2.isFunction = A, e2.isPrimitive = function(t3) { - return t3 === null || typeof t3 == "boolean" || typeof t3 == "number" || typeof t3 == "string" || typeof t3 == "symbol" || t3 === void 0; - }, e2.isBuffer = r2(384); - var T = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - function x() { - var t3 = new Date(), e3 = [B(t3.getHours()), B(t3.getMinutes()), B(t3.getSeconds())].join(":"); - return [t3.getDate(), T[t3.getMonth()], e3].join(" "); - } - function O(t3, e3) { - return Object.prototype.hasOwnProperty.call(t3, e3); - } - e2.log = function() { - console.log("%s - %s", x(), e2.format.apply(e2, arguments)); - }, e2.inherits = r2(5717), e2._extend = function(t3, e3) { - if (!e3 || !M(e3)) - return t3; - for (var r3 = Object.keys(e3), n2 = r3.length; n2--; ) - t3[r3[n2]] = e3[r3[n2]]; - return t3; - }; - var R = typeof Symbol != "undefined" ? Symbol("util.promisify.custom") : void 0; - function P(t3, e3) { - if (!t3) { - var r3 = new Error("Promise was rejected with a falsy value"); - r3.reason = t3, t3 = r3; - } - return e3(t3); - } - e2.promisify = function(t3) { - if (typeof t3 != "function") - throw new TypeError('The "original" argument must be of type Function'); - if (R && t3[R]) { - var e3; - if (typeof (e3 = t3[R]) != "function") - throw new TypeError('The "util.promisify.custom" argument must be of type Function'); - return Object.defineProperty(e3, R, {value: e3, enumerable: false, writable: false, configurable: true}), e3; - } - function e3() { - for (var e4, r3, n2 = new Promise(function(t4, n3) { - e4 = t4, r3 = n3; - }), i2 = [], o2 = 0; o2 < arguments.length; o2++) - i2.push(arguments[o2]); - i2.push(function(t4, n3) { - t4 ? r3(t4) : e4(n3); - }); - try { - t3.apply(this, i2); - } catch (t4) { - r3(t4); - } - return n2; - } - return Object.setPrototypeOf(e3, Object.getPrototypeOf(t3)), R && Object.defineProperty(e3, R, {value: e3, enumerable: false, writable: false, configurable: true}), Object.defineProperties(e3, i(t3)); - }, e2.promisify.custom = R, e2.callbackify = function(t3) { - if (typeof t3 != "function") - throw new TypeError('The "original" argument must be of type Function'); - function e3() { - for (var e4 = [], r3 = 0; r3 < arguments.length; r3++) - e4.push(arguments[r3]); - var i2 = e4.pop(); - if (typeof i2 != "function") - throw new TypeError("The last argument must be of type Function"); - var o2 = this, a2 = function() { - return i2.apply(o2, arguments); - }; - t3.apply(this, e4).then(function(t4) { - n.nextTick(a2.bind(null, null, t4)); - }, function(t4) { - n.nextTick(P.bind(null, t4, a2)); - }); - } - return Object.setPrototypeOf(e3, Object.getPrototypeOf(t3)), Object.defineProperties(e3, i(t3)), e3; - }; - }, 7147: (t2, e2, r2) => { - r2.r(e2), r2.d(e2, {Headers: () => p, Request: () => _, Response: () => S, DOMException: () => A, fetch: () => k}); - var n = typeof globalThis != "undefined" && globalThis || typeof self != "undefined" && self || n !== void 0 && n, i = "URLSearchParams" in n, o = "Symbol" in n && "iterator" in Symbol, a = "FileReader" in n && "Blob" in n && function() { - try { - return new Blob(), true; - } catch (t3) { - return false; - } - }(), s = "FormData" in n, u = "ArrayBuffer" in n; - if (u) - var f = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], c = ArrayBuffer.isView || function(t3) { - return t3 && f.indexOf(Object.prototype.toString.call(t3)) > -1; - }; - function h(t3) { - if (typeof t3 != "string" && (t3 = String(t3)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t3) || t3 === "") - throw new TypeError('Invalid character in header field name: "' + t3 + '"'); - return t3.toLowerCase(); - } - function l(t3) { - return typeof t3 != "string" && (t3 = String(t3)), t3; - } - function d(t3) { - var e3 = {next: function() { - var e4 = t3.shift(); - return {done: e4 === void 0, value: e4}; - }}; - return o && (e3[Symbol.iterator] = function() { - return e3; - }), e3; - } - function p(t3) { - this.map = {}, t3 instanceof p ? t3.forEach(function(t4, e3) { - this.append(e3, t4); - }, this) : Array.isArray(t3) ? t3.forEach(function(t4) { - this.append(t4[0], t4[1]); - }, this) : t3 && Object.getOwnPropertyNames(t3).forEach(function(e3) { - this.append(e3, t3[e3]); - }, this); - } - function y(t3) { - if (t3.bodyUsed) - return Promise.reject(new TypeError("Already read")); - t3.bodyUsed = true; - } - function m(t3) { - return new Promise(function(e3, r3) { - t3.onload = function() { - e3(t3.result); - }, t3.onerror = function() { - r3(t3.error); - }; - }); - } - function b(t3) { - var e3 = new FileReader(), r3 = m(e3); - return e3.readAsArrayBuffer(t3), r3; - } - function g(t3) { - if (t3.slice) - return t3.slice(0); - var e3 = new Uint8Array(t3.byteLength); - return e3.set(new Uint8Array(t3)), e3.buffer; - } - function v() { - return this.bodyUsed = false, this._initBody = function(t3) { - var e3; - this.bodyUsed = this.bodyUsed, this._bodyInit = t3, t3 ? typeof t3 == "string" ? this._bodyText = t3 : a && Blob.prototype.isPrototypeOf(t3) ? this._bodyBlob = t3 : s && FormData.prototype.isPrototypeOf(t3) ? this._bodyFormData = t3 : i && URLSearchParams.prototype.isPrototypeOf(t3) ? this._bodyText = t3.toString() : u && a && (e3 = t3) && DataView.prototype.isPrototypeOf(e3) ? (this._bodyArrayBuffer = g(t3.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : u && (ArrayBuffer.prototype.isPrototypeOf(t3) || c(t3)) ? this._bodyArrayBuffer = g(t3) : this._bodyText = t3 = Object.prototype.toString.call(t3) : this._bodyText = "", this.headers.get("content-type") || (typeof t3 == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i && URLSearchParams.prototype.isPrototypeOf(t3) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")); - }, a && (this.blob = function() { - var t3 = y(this); - if (t3) - return t3; - if (this._bodyBlob) - return Promise.resolve(this._bodyBlob); - if (this._bodyArrayBuffer) - return Promise.resolve(new Blob([this._bodyArrayBuffer])); - if (this._bodyFormData) - throw new Error("could not read FormData body as blob"); - return Promise.resolve(new Blob([this._bodyText])); - }, this.arrayBuffer = function() { - return this._bodyArrayBuffer ? y(this) || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset, this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength)) : Promise.resolve(this._bodyArrayBuffer)) : this.blob().then(b); - }), this.text = function() { - var t3, e3, r3, n2 = y(this); - if (n2) - return n2; - if (this._bodyBlob) - return t3 = this._bodyBlob, r3 = m(e3 = new FileReader()), e3.readAsText(t3), r3; - if (this._bodyArrayBuffer) - return Promise.resolve(function(t4) { - for (var e4 = new Uint8Array(t4), r4 = new Array(e4.length), n3 = 0; n3 < e4.length; n3++) - r4[n3] = String.fromCharCode(e4[n3]); - return r4.join(""); - }(this._bodyArrayBuffer)); - if (this._bodyFormData) - throw new Error("could not read FormData body as text"); - return Promise.resolve(this._bodyText); - }, s && (this.formData = function() { - return this.text().then(M); - }), this.json = function() { - return this.text().then(JSON.parse); - }, this; - } - p.prototype.append = function(t3, e3) { - t3 = h(t3), e3 = l(e3); - var r3 = this.map[t3]; - this.map[t3] = r3 ? r3 + ", " + e3 : e3; - }, p.prototype.delete = function(t3) { - delete this.map[h(t3)]; - }, p.prototype.get = function(t3) { - return t3 = h(t3), this.has(t3) ? this.map[t3] : null; - }, p.prototype.has = function(t3) { - return this.map.hasOwnProperty(h(t3)); - }, p.prototype.set = function(t3, e3) { - this.map[h(t3)] = l(e3); - }, p.prototype.forEach = function(t3, e3) { - for (var r3 in this.map) - this.map.hasOwnProperty(r3) && t3.call(e3, this.map[r3], r3, this); - }, p.prototype.keys = function() { - var t3 = []; - return this.forEach(function(e3, r3) { - t3.push(r3); - }), d(t3); - }, p.prototype.values = function() { - var t3 = []; - return this.forEach(function(e3) { - t3.push(e3); - }), d(t3); - }, p.prototype.entries = function() { - var t3 = []; - return this.forEach(function(e3, r3) { - t3.push([r3, e3]); - }), d(t3); - }, o && (p.prototype[Symbol.iterator] = p.prototype.entries); - var w = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; - function _(t3, e3) { - if (!(this instanceof _)) - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); - var r3, n2, i2 = (e3 = e3 || {}).body; - if (t3 instanceof _) { - if (t3.bodyUsed) - throw new TypeError("Already read"); - this.url = t3.url, this.credentials = t3.credentials, e3.headers || (this.headers = new p(t3.headers)), this.method = t3.method, this.mode = t3.mode, this.signal = t3.signal, i2 || t3._bodyInit == null || (i2 = t3._bodyInit, t3.bodyUsed = true); - } else - this.url = String(t3); - if (this.credentials = e3.credentials || this.credentials || "same-origin", !e3.headers && this.headers || (this.headers = new p(e3.headers)), this.method = (n2 = (r3 = e3.method || this.method || "GET").toUpperCase(), w.indexOf(n2) > -1 ? n2 : r3), this.mode = e3.mode || this.mode || null, this.signal = e3.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && i2) - throw new TypeError("Body not allowed for GET or HEAD requests"); - if (this._initBody(i2), !(this.method !== "GET" && this.method !== "HEAD" || e3.cache !== "no-store" && e3.cache !== "no-cache")) { - var o2 = /([?&])_=[^&]*/; - o2.test(this.url) ? this.url = this.url.replace(o2, "$1_=" + new Date().getTime()) : this.url += (/\?/.test(this.url) ? "&" : "?") + "_=" + new Date().getTime(); - } - } - function M(t3) { - var e3 = new FormData(); - return t3.trim().split("&").forEach(function(t4) { - if (t4) { - var r3 = t4.split("="), n2 = r3.shift().replace(/\+/g, " "), i2 = r3.join("=").replace(/\+/g, " "); - e3.append(decodeURIComponent(n2), decodeURIComponent(i2)); - } - }), e3; - } - function S(t3, e3) { - if (!(this instanceof S)) - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); - e3 || (e3 = {}), this.type = "default", this.status = e3.status === void 0 ? 200 : e3.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = e3.statusText === void 0 ? "" : "" + e3.statusText, this.headers = new p(e3.headers), this.url = e3.url || "", this._initBody(t3); - } - _.prototype.clone = function() { - return new _(this, {body: this._bodyInit}); - }, v.call(_.prototype), v.call(S.prototype), S.prototype.clone = function() { - return new S(this._bodyInit, {status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url}); - }, S.error = function() { - var t3 = new S(null, {status: 0, statusText: ""}); - return t3.type = "error", t3; - }; - var E = [301, 302, 303, 307, 308]; - S.redirect = function(t3, e3) { - if (E.indexOf(e3) === -1) - throw new RangeError("Invalid status code"); - return new S(null, {status: e3, headers: {location: t3}}); - }; - var A = n.DOMException; - try { - new A(); - } catch (t3) { - (A = function(t4, e3) { - this.message = t4, this.name = e3; - var r3 = Error(t4); - this.stack = r3.stack; - }).prototype = Object.create(Error.prototype), A.prototype.constructor = A; - } - function k(t3, e3) { - return new Promise(function(r3, i2) { - var o2 = new _(t3, e3); - if (o2.signal && o2.signal.aborted) - return i2(new A("Aborted", "AbortError")); - var s2 = new XMLHttpRequest(); - function f2() { - s2.abort(); - } - s2.onload = function() { - var t4, e4, n2 = {status: s2.status, statusText: s2.statusText, headers: (t4 = s2.getAllResponseHeaders() || "", e4 = new p(), t4.replace(/\r?\n[\t ]+/g, " ").split("\r").map(function(t5) { - return t5.indexOf("\n") === 0 ? t5.substr(1, t5.length) : t5; - }).forEach(function(t5) { - var r4 = t5.split(":"), n3 = r4.shift().trim(); - if (n3) { - var i4 = r4.join(":").trim(); - e4.append(n3, i4); - } - }), e4)}; - n2.url = "responseURL" in s2 ? s2.responseURL : n2.headers.get("X-Request-URL"); - var i3 = "response" in s2 ? s2.response : s2.responseText; - setTimeout(function() { - r3(new S(i3, n2)); - }, 0); - }, s2.onerror = function() { - setTimeout(function() { - i2(new TypeError("Network request failed")); - }, 0); - }, s2.ontimeout = function() { - setTimeout(function() { - i2(new TypeError("Network request failed")); - }, 0); - }, s2.onabort = function() { - setTimeout(function() { - i2(new A("Aborted", "AbortError")); - }, 0); - }, s2.open(o2.method, function(t4) { - try { - return t4 === "" && n.location.href ? n.location.href : t4; - } catch (e4) { - return t4; - } - }(o2.url), true), o2.credentials === "include" ? s2.withCredentials = true : o2.credentials === "omit" && (s2.withCredentials = false), "responseType" in s2 && (a ? s2.responseType = "blob" : u && o2.headers.get("Content-Type") && o2.headers.get("Content-Type").indexOf("application/octet-stream") !== -1 && (s2.responseType = "arraybuffer")), !e3 || typeof e3.headers != "object" || e3.headers instanceof p ? o2.headers.forEach(function(t4, e4) { - s2.setRequestHeader(e4, t4); - }) : Object.getOwnPropertyNames(e3.headers).forEach(function(t4) { - s2.setRequestHeader(t4, l(e3.headers[t4])); - }), o2.signal && (o2.signal.addEventListener("abort", f2), s2.onreadystatechange = function() { - s2.readyState === 4 && o2.signal.removeEventListener("abort", f2); - }), s2.send(o2._bodyInit === void 0 ? null : o2._bodyInit); - }); - } - k.polyfill = true, n.fetch || (n.fetch = k, n.Headers = p, n.Request = _, n.Response = S); - }, 6430: (t2, e2, r2) => { - var n = r2(9804), i = r2(6314), o = r2(1924), a = o("Object.prototype.toString"), s = r2(1405)() && typeof Symbol.toStringTag == "symbol", u = i(), f = o("String.prototype.slice"), c = {}, h = r2(4079), l = Object.getPrototypeOf; - s && h && l && n(u, function(t3) { - if (typeof r2.g[t3] == "function") { - var e3 = new r2.g[t3](); - if (!(Symbol.toStringTag in e3)) - throw new EvalError("this engine has support for Symbol.toStringTag, but " + t3 + " does not have the property! Please report this."); - var n2 = l(e3), i2 = h(n2, Symbol.toStringTag); - if (!i2) { - var o2 = l(n2); - i2 = h(o2, Symbol.toStringTag); - } - c[t3] = i2.get; - } - }); - var d = r2(5692); - t2.exports = function(t3) { - return !!d(t3) && (s ? function(t4) { - var e3 = false; - return n(c, function(r3, n2) { - if (!e3) - try { - var i2 = r3.call(t4); - i2 === n2 && (e3 = i2); - } catch (t5) { - } - }), e3; - }(t3) : f(a(t3), 8, -1)); - }; - }, 6601: () => { - }, 9214: () => { - }, 1922: () => { - }, 2363: () => { - }, 2361: () => { - }, 4616: () => { - }, 8924: () => { - }, 2349: () => { - }}, e = {}; - function r(n) { - var i = e[n]; - if (i !== void 0) - return i.exports; - var o = e[n] = {id: n, loaded: false, exports: {}}; - return t[n].call(o.exports, o, o.exports, r), o.loaded = true, o.exports; - } - return r.n = (t2) => { - var e2 = t2 && t2.__esModule ? () => t2.default : () => t2; - return r.d(e2, {a: e2}), e2; - }, r.d = (t2, e2) => { - for (var n in e2) - r.o(e2, n) && !r.o(t2, n) && Object.defineProperty(t2, n, {enumerable: true, get: e2[n]}); - }, r.g = function() { - if (typeof globalThis == "object") - return globalThis; - try { - return this || new Function("return this")(); - } catch (t2) { - if (typeof window == "object") - return window; - } - }(), r.o = (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r.r = (t2) => { - typeof Symbol != "undefined" && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, {value: "Module"}), Object.defineProperty(t2, "__esModule", {value: true}); - }, r.nmd = (t2) => (t2.paths = [], t2.children || (t2.children = []), t2), r(3607); - })(); - }); - }); - var lib$1 = /* @__PURE__ */ getDefaultExportFromCjs(lib); - export default lib$1; \ No newline at end of file diff --git a/app/assets/v2/js/lib/casper/casper_js_sdk.js b/app/assets/v2/js/lib/casper/casper_js_sdk.js new file mode 100644 index 00000000000..f138ed99920 --- /dev/null +++ b/app/assets/v2/js/lib/casper/casper_js_sdk.js @@ -0,0 +1,45844 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.casper = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { + if (arguments[0] === 10) { + if (!_warnedToStringRadix) { + _warnedToStringRadix = true; + logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); + } + } + else if (arguments[0] === 16) { + logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + else { + logger.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + } + return toBN(this).toString(10); + }; + BigNumber.prototype.toHexString = function () { + return this._hex; + }; + BigNumber.prototype.toJSON = function (key) { + return { type: "BigNumber", hex: this.toHexString() }; + }; + BigNumber.from = function (value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/^-?0x[0-9a-f]+$/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN(value))); + } + return logger.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + var anyValue = value; + if (typeof (anyValue) === "bigint") { + return BigNumber.from(anyValue.toString()); + } + if (bytes_1.isBytes(anyValue)) { + return BigNumber.from(bytes_1.hexlify(anyValue)); + } + if (anyValue) { + // Hexable interface (takes piority) + if (anyValue.toHexString) { + var hex = anyValue.toHexString(); + if (typeof (hex) === "string") { + return BigNumber.from(hex); + } + } + else { + // For now, handle legacy JSON-ified values (goes away in v6) + var hex = anyValue._hex; + // New-form JSON + if (hex == null && anyValue.type === "BigNumber") { + hex = anyValue.hex; + } + if (typeof (hex) === "string") { + if (bytes_1.isHexString(hex) || (hex[0] === "-" && bytes_1.isHexString(hex.substring(1)))) { + return BigNumber.from(hex); + } + } + } + } + return logger.throwArgumentError("invalid BigNumber value", "value", value); + }; + BigNumber.isBigNumber = function (value) { + return !!(value && value._isBigNumber); + }; + return BigNumber; + }()); + exports.BigNumber = BigNumber; + // Normalize the hex string + function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + logger.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; + } + function toBigNumber(value) { + return BigNumber.from(toHex(value)); + } + function toBN(value) { + var hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN("-" + hex.substring(3), 16)); + } + return new BN(hex.substring(2), 16); + } + function throwFault(fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return logger.throwError(fault, logger_1.Logger.errors.NUMERIC_FAULT, params); + } + // value should have no prefix + function _base36To16(value) { + return (new BN(value, 36)).toString(16); + } + exports._base36To16 = _base36To16; + // value should have no prefix + function _base16To36(value) { + return (new BN(value, 16)).toString(36); + } + exports._base16To36 = _base16To36; + + },{"./_version":1,"@ethersproject/bytes":6,"@ethersproject/logger":13,"bn.js":45}],3:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.FixedNumber = exports.FixedFormat = exports.parseFixed = exports.formatFixed = void 0; + var bytes_1 = require("@ethersproject/bytes"); + var logger_1 = require("@ethersproject/logger"); + var _version_1 = require("./_version"); + var logger = new logger_1.Logger(_version_1.version); + var bignumber_1 = require("./bignumber"); + var _constructorGuard = {}; + var Zero = bignumber_1.BigNumber.from(0); + var NegativeOne = bignumber_1.BigNumber.from(-1); + function throwFault(message, fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return logger.throwError(message, logger_1.Logger.errors.NUMERIC_FAULT, params); + } + // Constant to pull zeros from for multipliers + var zeros = "0"; + while (zeros.length < 256) { + zeros += zeros; + } + // Returns a string "1" followed by decimal "0"s + function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = bignumber_1.BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return logger.throwArgumentError("invalid decimal size", "decimals", decimals); + } + function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = bignumber_1.BigNumber.from(value); + var negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + var fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + var whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; + } + exports.formatFixed = formatFixed; + function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + logger.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return bignumber_1.BigNumber.from(value); + } + // Is it negative? + var negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + logger.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + var comps = value.split("."); + if (comps.length > 2) { + logger.throwArgumentError("too many decimal points", "value", value); + } + var whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + var wholeValue = bignumber_1.BigNumber.from(whole); + var fractionValue = bignumber_1.BigNumber.from(fraction); + var wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; + } + exports.parseFixed = parseFixed; + var FixedFormat = /** @class */ (function () { + function FixedFormat(constructorGuard, signed, width, decimals) { + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + FixedFormat.from = function (value) { + if (value instanceof FixedFormat) { + return value; + } + var signed = true; + var width = 128; + var decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + var check = function (key, type, defaultValue) { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard, signed, width, decimals); + }; + return FixedFormat; + }()); + exports.FixedFormat = FixedFormat; + var FixedNumber = /** @class */ (function () { + function FixedNumber(constructorGuard, hex, value, format) { + var _newTarget = this.constructor; + logger.checkNew(_newTarget, FixedNumber); + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + FixedNumber.prototype._checkFormat = function (other) { + if (this.format.name !== other.format.name) { + logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + }; + FixedNumber.prototype.addUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.subUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.mulUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + }; + FixedNumber.prototype.divUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.floor = function () { + var comps = this.toString().split("."); + var result = FixedNumber.from(comps[0], this.format); + var hasFraction = !comps[1].match(/^(0*)$/); + if (this.isNegative() && hasFraction) { + result = result.subUnsafe(ONE); + } + return result; + }; + FixedNumber.prototype.ceiling = function () { + var comps = this.toString().split("."); + var result = FixedNumber.from(comps[0], this.format); + var hasFraction = !comps[1].match(/^(0*)$/); + if (!this.isNegative() && hasFraction) { + result = result.addUnsafe(ONE); + } + return result; + }; + // @TODO: Support other rounding algorithms + FixedNumber.prototype.round = function (decimals) { + if (decimals == null) { + decimals = 0; + } + // If we are already in range, we're done + var comps = this.toString().split("."); + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + logger.throwArgumentError("invalid decimal count", "decimals", decimals); + } + if (comps[1].length <= decimals) { + return this; + } + var factor = FixedNumber.from("1" + zeros.substring(0, decimals)); + return this.mulUnsafe(factor).addUnsafe(BUMP).floor().divUnsafe(factor); + }; + FixedNumber.prototype.isZero = function () { + return (this._value === "0.0"); + }; + FixedNumber.prototype.isNegative = function () { + return (this._value[0] === "-"); + }; + FixedNumber.prototype.toString = function () { return this._value; }; + FixedNumber.prototype.toHexString = function (width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger.throwArgumentError("invalid byte width", "width", width); + } + var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return bytes_1.hexZeroPad(hex, width / 8); + }; + FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; + FixedNumber.prototype.toFormat = function (format) { + return FixedNumber.fromString(this._value, format); + }; + FixedNumber.fromValue = function (value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && !bignumber_1.isBigNumberish(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + }; + FixedNumber.fromString = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + var numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + var hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = bytes_1.hexZeroPad(hex, fixedFormat.width / 8); + } + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.fromBytes = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + if (bytes_1.arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + var numeric = bignumber_1.BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.from = function (value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (bytes_1.isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) { + throw error; + } + } + return logger.throwArgumentError("invalid FixedNumber value", "value", value); + }; + FixedNumber.isFixedNumber = function (value) { + return !!(value && value._isFixedNumber); + }; + return FixedNumber; + }()); + exports.FixedNumber = FixedNumber; + var ONE = FixedNumber.from(1); + var BUMP = FixedNumber.from("0.5"); + + },{"./_version":1,"./bignumber":2,"@ethersproject/bytes":6,"@ethersproject/logger":13}],4:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports._base36To16 = exports._base16To36 = exports.parseFixed = exports.FixedNumber = exports.FixedFormat = exports.formatFixed = exports.BigNumber = void 0; + var bignumber_1 = require("./bignumber"); + Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } }); + var fixednumber_1 = require("./fixednumber"); + Object.defineProperty(exports, "formatFixed", { enumerable: true, get: function () { return fixednumber_1.formatFixed; } }); + Object.defineProperty(exports, "FixedFormat", { enumerable: true, get: function () { return fixednumber_1.FixedFormat; } }); + Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return fixednumber_1.FixedNumber; } }); + Object.defineProperty(exports, "parseFixed", { enumerable: true, get: function () { return fixednumber_1.parseFixed; } }); + // Internal methods used by address + var bignumber_2 = require("./bignumber"); + Object.defineProperty(exports, "_base16To36", { enumerable: true, get: function () { return bignumber_2._base16To36; } }); + Object.defineProperty(exports, "_base36To16", { enumerable: true, get: function () { return bignumber_2._base36To16; } }); + + },{"./bignumber":2,"./fixednumber":3}],5:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = void 0; + exports.version = "bytes/5.1.0"; + + },{}],6:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.joinSignature = exports.splitSignature = exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = void 0; + var logger_1 = require("@ethersproject/logger"); + var _version_1 = require("./_version"); + var logger = new logger_1.Logger(_version_1.version); + /////////////////////////////// + function isHexable(value) { + return !!(value.toHexString); + } + function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + var args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; + } + function isBytesLike(value) { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); + } + exports.isBytesLike = isBytesLike; + function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (value.length == null) { + return false; + } + for (var i = 0; i < value.length; i++) { + var v = value[i]; + if (typeof (v) !== "number" || v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + return true; + } + exports.isBytes = isBytes; + function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid arrayify value"); + var result = []; + while (value) { + result.unshift(value & 0xff); + value = parseInt(String(value / 256)); + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + var hex = value.substring(2); + if (hex.length % 2) { + if (options.hexPad === "left") { + hex = "0x0" + hex.substring(2); + } + else if (options.hexPad === "right") { + hex += "0"; + } + else { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + } + var result = []; + for (var i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return logger.throwArgumentError("invalid arrayify value", "value", value); + } + exports.arrayify = arrayify; + function concat(items) { + var objects = items.map(function (item) { return arrayify(item); }); + var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0); + var result = new Uint8Array(length); + objects.reduce(function (offset, object) { + result.set(object, offset); + return offset + object.length; + }, 0); + return addSlice(result); + } + exports.concat = concat; + function stripZeros(value) { + var result = arrayify(value); + if (result.length === 0) { + return result; + } + // Find the first non-zero entry + var start = 0; + while (start < result.length && result[start] === 0) { + start++; + } + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + return result; + } + exports.stripZeros = stripZeros; + function zeroPad(value, length) { + value = arrayify(value); + if (value.length > length) { + logger.throwArgumentError("value out of range", "value", arguments[0]); + } + var result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); + } + exports.zeroPad = zeroPad; + function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; + } + exports.isHexString = isHexString; + var HexCharacters = "0123456789abcdef"; + function hexlify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid hexlify value"); + var hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + if (hex.length) { + if (hex.length % 2) { + hex = "0" + hex; + } + return "0x" + hex; + } + return "0x00"; + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + return value.toHexString(); + } + if (isHexString(value)) { + if (value.length % 2) { + if (options.hexPad === "left") { + value = "0x0" + value.substring(2); + } + else if (options.hexPad === "right") { + value += "0"; + } + else { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + } + return value.toLowerCase(); + } + if (isBytes(value)) { + var result = "0x"; + for (var i = 0; i < value.length; i++) { + var v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + return logger.throwArgumentError("invalid hexlify value", "value", value); + } + exports.hexlify = hexlify; + /* + function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; + } + */ + function hexDataLength(data) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + return null; + } + return (data.length - 2) / 2; + } + exports.hexDataLength = hexDataLength; + function hexDataSlice(data, offset, endOffset) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + logger.throwArgumentError("invalid hexData", "value", data); + } + offset = 2 + 2 * offset; + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + return "0x" + data.substring(offset); + } + exports.hexDataSlice = hexDataSlice; + function hexConcat(items) { + var result = "0x"; + items.forEach(function (item) { + result += hexlify(item).substring(2); + }); + return result; + } + exports.hexConcat = hexConcat; + function hexValue(value) { + var trimmed = hexStripZeros(hexlify(value, { hexPad: "left" })); + if (trimmed === "0x") { + return "0x0"; + } + return trimmed; + } + exports.hexValue = hexValue; + function hexStripZeros(value) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + var offset = 0; + while (offset < value.length && value[offset] === "0") { + offset++; + } + return "0x" + value.substring(offset); + } + exports.hexStripZeros = hexStripZeros; + function hexZeroPad(value, length) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + else if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + if (value.length > 2 * length + 2) { + logger.throwArgumentError("value out of range", "value", arguments[1]); + } + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + return value; + } + exports.hexZeroPad = hexZeroPad; + function splitSignature(signature) { + var result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + if (isBytesLike(signature)) { + var bytes = arrayify(signature); + if (bytes.length !== 65) { + logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + // Get the r, s and v + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + result.v = bytes[64]; + // Allow a recid to be used as the v + if (result.v < 27) { + if (result.v === 0 || result.v === 1) { + result.v += 27; + } + else { + logger.throwArgumentError("signature invalid v byte", "signature", signature); + } + } + // Compute recoveryParam from v + result.recoveryParam = 1 - (result.v % 2); + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { + bytes[32] |= 0x80; + } + result._vs = hexlify(bytes.slice(32, 64)); + } + else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + var vs_1 = zeroPad(arrayify(result._vs), 32); + result._vs = hexlify(vs_1); + // Set or check the recid + var recoveryParam = ((vs_1[0] >= 128) ? 1 : 0); + if (result.recoveryParam == null) { + result.recoveryParam = recoveryParam; + } + else if (result.recoveryParam !== recoveryParam) { + logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + // Set or check the s + vs_1[0] &= 0x7f; + var s = hexlify(vs_1); + if (result.s == null) { + result.s = s; + } + else if (result.s !== s) { + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + } + // Use recid and v to populate each other + if (result.recoveryParam == null) { + if (result.v == null) { + logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature); + } + else if (result.v === 0 || result.v === 1) { + result.recoveryParam = result.v; + } + else { + result.recoveryParam = 1 - (result.v % 2); + } + } + else { + if (result.v == null) { + result.v = 27 + result.recoveryParam; + } + else if (result.recoveryParam !== (1 - (result.v % 2))) { + logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); + } + } + if (result.r == null || !isHexString(result.r)) { + logger.throwArgumentError("signature missing or invalid r", "signature", signature); + } + else { + result.r = hexZeroPad(result.r, 32); + } + if (result.s == null || !isHexString(result.s)) { + logger.throwArgumentError("signature missing or invalid s", "signature", signature); + } + else { + result.s = hexZeroPad(result.s, 32); + } + var vs = arrayify(result.s); + if (vs[0] >= 128) { + logger.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { + vs[0] |= 0x80; + } + var _vs = hexlify(vs); + if (result._vs) { + if (!isHexString(result._vs)) { + logger.throwArgumentError("signature invalid _vs", "signature", signature); + } + result._vs = hexZeroPad(result._vs, 32); + } + // Set or check the _vs + if (result._vs == null) { + result._vs = _vs; + } + else if (result._vs !== _vs) { + logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature); + } + } + return result; + } + exports.splitSignature = splitSignature; + function joinSignature(signature) { + signature = splitSignature(signature); + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c" : "0x1b") + ])); + } + exports.joinSignature = joinSignature; + + },{"./_version":5,"@ethersproject/logger":13}],7:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.AddressZero = void 0; + exports.AddressZero = "0x0000000000000000000000000000000000000000"; + + },{}],8:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = void 0; + var bignumber_1 = require("@ethersproject/bignumber"); + var NegativeOne = ( /*#__PURE__*/bignumber_1.BigNumber.from(-1)); + exports.NegativeOne = NegativeOne; + var Zero = ( /*#__PURE__*/bignumber_1.BigNumber.from(0)); + exports.Zero = Zero; + var One = ( /*#__PURE__*/bignumber_1.BigNumber.from(1)); + exports.One = One; + var Two = ( /*#__PURE__*/bignumber_1.BigNumber.from(2)); + exports.Two = Two; + var WeiPerEther = ( /*#__PURE__*/bignumber_1.BigNumber.from("1000000000000000000")); + exports.WeiPerEther = WeiPerEther; + var MaxUint256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); + exports.MaxUint256 = MaxUint256; + + },{"@ethersproject/bignumber":4}],9:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.HashZero = void 0; + exports.HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; + + },{}],10:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.EtherSymbol = exports.HashZero = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.AddressZero = void 0; + var addresses_1 = require("./addresses"); + Object.defineProperty(exports, "AddressZero", { enumerable: true, get: function () { return addresses_1.AddressZero; } }); + var bignumbers_1 = require("./bignumbers"); + Object.defineProperty(exports, "NegativeOne", { enumerable: true, get: function () { return bignumbers_1.NegativeOne; } }); + Object.defineProperty(exports, "Zero", { enumerable: true, get: function () { return bignumbers_1.Zero; } }); + Object.defineProperty(exports, "One", { enumerable: true, get: function () { return bignumbers_1.One; } }); + Object.defineProperty(exports, "Two", { enumerable: true, get: function () { return bignumbers_1.Two; } }); + Object.defineProperty(exports, "WeiPerEther", { enumerable: true, get: function () { return bignumbers_1.WeiPerEther; } }); + Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return bignumbers_1.MaxUint256; } }); + var hashes_1 = require("./hashes"); + Object.defineProperty(exports, "HashZero", { enumerable: true, get: function () { return hashes_1.HashZero; } }); + var strings_1 = require("./strings"); + Object.defineProperty(exports, "EtherSymbol", { enumerable: true, get: function () { return strings_1.EtherSymbol; } }); + + },{"./addresses":7,"./bignumbers":8,"./hashes":9,"./strings":11}],11:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.EtherSymbol = void 0; + // NFKC (composed) // (decomposed) + exports.EtherSymbol = "\u039e"; // "\uD835\uDF63"; + + },{}],12:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = void 0; + exports.version = "logger/5.1.0"; + + },{}],13:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Logger = exports.ErrorCode = exports.LogLevel = void 0; + var _permanentCensorErrors = false; + var _censorErrors = false; + var LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 }; + var _logLevel = LogLevels["default"]; + var _version_1 = require("./_version"); + var _globalLogger = null; + function _checkNormalize() { + try { + var missing_1 = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) { + try { + if ("test".normalize(form) !== "test") { + throw new Error("bad normalize"); + } + ; + } + catch (error) { + missing_1.push(form); + } + }); + if (missing_1.length) { + throw new Error("missing " + missing_1.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; + } + var _normalizeError = _checkNormalize(); + var LogLevel; + (function (LogLevel) { + LogLevel["DEBUG"] = "DEBUG"; + LogLevel["INFO"] = "INFO"; + LogLevel["WARNING"] = "WARNING"; + LogLevel["ERROR"] = "ERROR"; + LogLevel["OFF"] = "OFF"; + })(LogLevel = exports.LogLevel || (exports.LogLevel = {})); + var ErrorCode; + (function (ErrorCode) { + /////////////////// + // Generic Errors + // Unknown Error + ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR"; + // Not Implemented + ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; + // Unsupported Operation + // - operation + ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION"; + // Network Error (i.e. Ethereum Network, such as an invalid chain ID) + // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown) + ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR"; + // Some sort of bad response from the server + ErrorCode["SERVER_ERROR"] = "SERVER_ERROR"; + // Timeout + ErrorCode["TIMEOUT"] = "TIMEOUT"; + /////////////////// + // Operational Errors + // Buffer Overrun + ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN"; + // Numeric Fault + // - operation: the operation being executed + // - fault: the reason this faulted + ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT"; + /////////////////// + // Argument Errors + // Missing new operator to an object + // - name: The name of the class + ErrorCode["MISSING_NEW"] = "MISSING_NEW"; + // Invalid argument (e.g. value is incompatible with type) to a function: + // - argument: The argument name that was invalid + // - value: The value of the argument + ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT"; + // Missing argument to a function: + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT"; + // Too many arguments + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT"; + /////////////////// + // Blockchain Errors + // Call exception + // - transaction: the transaction + // - address?: the contract address + // - args?: The arguments passed into the function + // - method?: The Solidity method signature + // - errorSignature?: The EIP848 error signature + // - errorArgs?: The EIP848 error parameters + // - reason: The reason (only for EIP848 "Error(string)") + ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION"; + // Insufficien funds (< value + gasLimit * gasPrice) + // - transaction: the transaction attempted + ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS"; + // Nonce has already been used + // - transaction: the transaction attempted + ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED"; + // The replacement fee for the transaction is too low + // - transaction: the transaction attempted + ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED"; + // The gas limit could not be estimated + // - transaction: the transaction passed to estimateGas + ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT"; + })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {})); + ; + var Logger = /** @class */ (function () { + function Logger(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + Logger.prototype._log = function (logLevel, args) { + var level = logLevel.toLowerCase(); + if (LogLevels[level] == null) { + this.throwArgumentError("invalid log level name", "logLevel", logLevel); + } + if (_logLevel > LogLevels[level]) { + return; + } + console.log.apply(console, args); + }; + Logger.prototype.debug = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.DEBUG, args); + }; + Logger.prototype.info = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.INFO, args); + }; + Logger.prototype.warn = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.WARNING, args); + }; + Logger.prototype.makeError = function (message, code, params) { + // Errors are being censored + if (_censorErrors) { + return this.makeError("censored error", code, {}); + } + if (!code) { + code = Logger.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + var messageDetails = []; + Object.keys(params).forEach(function (key) { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("code=" + code); + messageDetails.push("version=" + this.version); + var reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + var error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; + }; + Logger.prototype.throwError = function (message, code, params) { + throw this.makeError(message, code, params); + }; + Logger.prototype.throwArgumentError = function (message, name, value) { + return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { + argument: name, + value: value + }); + }; + Logger.prototype.assert = function (condition, message, code, params) { + if (!!condition) { + return; + } + this.throwError(message, code, params); + }; + Logger.prototype.assertArgument = function (condition, message, name, value) { + if (!!condition) { + return; + } + this.throwArgumentError(message, name, value); + }; + Logger.prototype.checkNormalize = function (message) { + if (message == null) { + message = "platform missing String.prototype.normalize"; + } + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } + }; + Logger.prototype.checkSafeUint53 = function (value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } + }; + Logger.prototype.checkArgumentCount = function (count, expectedCount, message) { + if (message) { + message = ": " + message; + } + else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + }; + Logger.prototype.checkNew = function (target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger.prototype.checkAbstract = function (target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger.globalLogger = function () { + if (!_globalLogger) { + _globalLogger = new Logger(_version_1.version); + } + return _globalLogger; + }; + Logger.setCensorship = function (censorship, permanent) { + if (!censorship && permanent) { + this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + if (_permanentCensorErrors) { + if (!censorship) { + return; + } + this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + }; + Logger.setLogLevel = function (logLevel) { + var level = LogLevels[logLevel.toLowerCase()]; + if (level == null) { + Logger.globalLogger().warn("invalid log level - " + logLevel); + return; + } + _logLevel = level; + }; + Logger.from = function (version) { + return new Logger(version); + }; + Logger.errors = ErrorCode; + Logger.levels = LogLevel; + return Logger; + }()); + exports.Logger = Logger; + + },{"./_version":12}],14:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + /** + * OpenRPC Client JS is a browser-compatible JSON-RPC client with multiple transports and + * multiple request managers to enable features like round-robin or fallback-by-position. + * + * @example + * ```typescript + * import { RequestManager, HTTPTransport, Client } from '@open-rpc/client-js'; + * const transport = new HTTPTransport('http://localhost:3333'); + * const client = new Client(new RequestManager([transport])); + * const result = await client.request({method: 'addition', params: [2, 2]}); + * // => { jsonrpc: '2.0', id: 1, result: 4 } + * ``` + * + */ + var Client = /** @class */ (function () { + function Client(requestManager) { + this.requestManager = requestManager; + } + /** + * Initiates [[RequestManager.startBatch]] in order to build a batch call. + * + * Subsequent calls to [[Client.request]] will be added to the batch. Once [[Client.stopBatch]] is called, the + * promises for the [[Client.request]] will then be resolved. If the [[RequestManager]] already has a batch in + * progress, this method is a noop. + * + * @example + * myClient.startBatch(); + * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); + * myClient.request({method: "foo", params: ["baz"]}).then(() => console.log('foobaz')); + * myClient.stopBatch(); + */ + Client.prototype.startBatch = function () { + return this.requestManager.startBatch(); + }; + /** + * Initiates [[RequestManager.stopBatch]] in order to finalize and send the batch to the underlying transport. + * + * [[Client.stopBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For + * that reason, [[Client.startBatch]] MUST be called before [[Client.stopBatch]]. + * + * @example + * myClient.startBatch(); + * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); + * myClient.request({method: "foo", params: ["baz"]}).then(() => console.log('foobaz')); + * myClient.stopBatch(); + */ + Client.prototype.stopBatch = function () { + return this.requestManager.stopBatch(); + }; + /** + * A JSON-RPC call is represented by sending a Request object to a Server. + * + * @param requestObject.method A String containing the name of the method to be invoked. Method names that begin with the word rpc + * followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions and + * MUST NOT be used for anything else. + * @param requestObject.params A Structured value that holds the parameter values to be used during the invocation of the method. + * + * @example + * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); + */ + Client.prototype.request = function (requestObject, timeout) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!this.requestManager.connectPromise) return [3 /*break*/, 2]; + return [4 /*yield*/, this.requestManager.connectPromise]; + case 1: + _a.sent(); + _a.label = 2; + case 2: return [2 /*return*/, this.requestManager.request(requestObject, false, timeout)]; + } + }); + }); + }; + Client.prototype.notify = function (requestObject) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!this.requestManager.connectPromise) return [3 /*break*/, 2]; + return [4 /*yield*/, this.requestManager.connectPromise]; + case 1: + _a.sent(); + _a.label = 2; + case 2: return [2 /*return*/, this.requestManager.request(requestObject, true, null)]; + } + }); + }); + }; + Client.prototype.onNotification = function (callback) { + this.requestManager.requestChannel.addListener("notification", callback); + }; + Client.prototype.onError = function (callback) { + this.requestManager.requestChannel.addListener("error", callback); + }; + /** + * Close connection + */ + Client.prototype.close = function () { + this.requestManager.close(); + }; + return Client; + }()); + exports.default = Client; + + },{}],15:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.convertJSONToRPCError = exports.JSONRPCError = exports.ERR_UNKNOWN = exports.ERR_MISSIING_ID = exports.ERR_TIMEOUT = void 0; + exports.ERR_TIMEOUT = 7777; + exports.ERR_MISSIING_ID = 7878; + exports.ERR_UNKNOWN = 7979; + var JSONRPCError = /** @class */ (function (_super) { + __extends(JSONRPCError, _super); + function JSONRPCError(message, code, data) { + var _newTarget = this.constructor; + var _this = _super.call(this, message) || this; + _this.message = message; + _this.code = code; + _this.data = data; + Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain: see https://github.com/open-rpc/client-js/issues/209 + return _this; + } + return JSONRPCError; + }(Error)); + exports.JSONRPCError = JSONRPCError; + exports.convertJSONToRPCError = function (payload) { + if (payload.error) { + var _a = payload.error, message = _a.message, code = _a.code, data = _a.data; + return new JSONRPCError(message, code, data); + } + return new JSONRPCError("Unknown error", exports.ERR_UNKNOWN, payload); + }; + + },{}],16:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.getNotifications = exports.getBatchRequests = exports.isNotification = void 0; + exports.isNotification = function (data) { + return (data.request.id === undefined || data.request.id === null); + }; + exports.getBatchRequests = function (data) { + if (data instanceof Array) { + return data.filter(function (datum) { + var id = datum.request.request.id; + return id !== null && id !== undefined; + }).map(function (batchRequest) { + return batchRequest.request; + }); + } + return []; + }; + exports.getNotifications = function (data) { + if (data instanceof Array) { + return data.filter(function (datum) { + return exports.isNotification(datum.request); + }).map(function (batchRequest) { + return batchRequest.request; + }); + } + if (exports.isNotification(data)) { + return [data]; + } + return []; + }; + + },{}],17:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var events_1 = require("events"); + /* + ** Naive Request Manager, only use 1st transport. + * A more complex request manager could try each transport. + * If a transport fails, or times out, move on to the next. + */ + var RequestManager = /** @class */ (function () { + function RequestManager(transports) { + this.batch = []; + this.batchStarted = false; + this.lastId = -1; + this.transports = transports; + this.requests = {}; + this.connectPromise = this.connect(); + this.requestChannel = new events_1.EventEmitter(); + } + RequestManager.prototype.connect = function () { + var _this = this; + return Promise.all(this.transports.map(function (transport) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + transport.subscribe("error", this.handleError.bind(this)); + transport.subscribe("notification", this.handleNotification.bind(this)); + return [4 /*yield*/, transport.connect()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); })); + }; + RequestManager.prototype.getPrimaryTransport = function () { + return this.transports[0]; + }; + RequestManager.prototype.request = function (requestObject, notification, timeout) { + if (notification === void 0) { notification = false; } + return __awaiter(this, void 0, void 0, function () { + var internalID, id, payload, result; + var _this = this; + return __generator(this, function (_a) { + internalID = (++this.lastId).toString(); + id = notification ? null : internalID; + payload = { request: this.makeRequest(requestObject.method, requestObject.params || [], id), internalID: internalID }; + if (this.batchStarted) { + result = new Promise(function (resolve, reject) { + _this.batch.push({ resolve: resolve, reject: reject, request: payload }); + }); + return [2 /*return*/, result]; + } + return [2 /*return*/, this.getPrimaryTransport().sendData(payload, timeout)]; + }); + }); + }; + RequestManager.prototype.close = function () { + this.requestChannel.removeAllListeners(); + this.transports.forEach(function (transport) { + transport.unsubscribe(); + transport.close(); + }); + }; + /** + * Begins a batch call by setting the [[RequestManager.batchStarted]] flag to `true`. + * + * [[RequestManager.batch]] is a singleton - only one batch can exist at a given time, per [[RequestManager]]. + * + */ + RequestManager.prototype.startBatch = function () { + this.batchStarted = true; + }; + RequestManager.prototype.stopBatch = function () { + if (this.batchStarted === false) { + throw new Error("cannot end that which has never started"); + } + if (this.batch.length === 0) { + this.batchStarted = false; + return; + } + this.getPrimaryTransport().sendData(this.batch); + this.batch = []; + this.batchStarted = false; + }; + RequestManager.prototype.makeRequest = function (method, params, id) { + if (id) { + return { jsonrpc: "2.0", id: id, method: method, params: params }; + } + return { jsonrpc: "2.0", method: method, params: params }; + }; + RequestManager.prototype.handleError = function (data) { + this.requestChannel.emit("error", data); + }; + RequestManager.prototype.handleNotification = function (data) { + this.requestChannel.emit("notification", data); + }; + return RequestManager; + }()); + exports.default = RequestManager; + + },{"events":303}],18:[function(require,module,exports){ + "use strict"; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.PostMessageIframeTransport = exports.PostMessageWindowTransport = exports.JSONRPCError = exports.WebSocketTransport = exports.EventEmitterTransport = exports.HTTPTransport = exports.RequestManager = exports.Client = void 0; + var RequestManager_1 = __importDefault(require("./RequestManager")); + exports.RequestManager = RequestManager_1.default; + var EventEmitterTransport_1 = __importDefault(require("./transports/EventEmitterTransport")); + exports.EventEmitterTransport = EventEmitterTransport_1.default; + var HTTPTransport_1 = __importDefault(require("./transports/HTTPTransport")); + exports.HTTPTransport = HTTPTransport_1.default; + var WebSocketTransport_1 = __importDefault(require("./transports/WebSocketTransport")); + exports.WebSocketTransport = WebSocketTransport_1.default; + var PostMessageWindowTransport_1 = __importDefault(require("./transports/PostMessageWindowTransport")); + exports.PostMessageWindowTransport = PostMessageWindowTransport_1.default; + var PostMessageIframeTransport_1 = __importDefault(require("./transports/PostMessageIframeTransport")); + exports.PostMessageIframeTransport = PostMessageIframeTransport_1.default; + var Error_1 = require("./Error"); + Object.defineProperty(exports, "JSONRPCError", { enumerable: true, get: function () { return Error_1.JSONRPCError; } }); + var Client_1 = __importDefault(require("./Client")); + exports.Client = Client_1.default; + exports.default = Client_1.default; + + },{"./Client":14,"./Error":15,"./RequestManager":17,"./transports/EventEmitterTransport":19,"./transports/HTTPTransport":20,"./transports/PostMessageIframeTransport":21,"./transports/PostMessageWindowTransport":22,"./transports/WebSocketTransport":25}],19:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + var Transport_1 = require("./Transport"); + var Request_1 = require("../Request"); + var Error_1 = require("../Error"); + var EventEmitterTransport = /** @class */ (function (_super) { + __extends(EventEmitterTransport, _super); + function EventEmitterTransport(destEmitter, reqUri, resUri) { + var _this = _super.call(this) || this; + _this.connection = destEmitter; + _this.reqUri = reqUri; + _this.resUri = resUri; + return _this; + } + EventEmitterTransport.prototype.connect = function () { + var _this = this; + this.connection.on(this.resUri, function (data) { + _this.transportRequestManager.resolveResponse(data); + }); + return Promise.resolve(); + }; + EventEmitterTransport.prototype.sendData = function (data, timeout) { + if (timeout === void 0) { timeout = null; } + var prom = this.transportRequestManager.addRequest(data, timeout); + var notifications = Request_1.getNotifications(data); + var parsedData = this.parseData(data); + try { + this.connection.emit(this.reqUri, parsedData); + this.transportRequestManager.settlePendingRequest(notifications); + return prom; + } + catch (e) { + var responseErr = new Error_1.JSONRPCError(e.message, Error_1.ERR_UNKNOWN, e); + this.transportRequestManager.settlePendingRequest(notifications, responseErr); + return Promise.reject(responseErr); + } + }; + EventEmitterTransport.prototype.close = function () { + this.connection.removeAllListeners(); + }; + return EventEmitterTransport; + }(Transport_1.Transport)); + exports.default = EventEmitterTransport; + + },{"../Error":15,"../Request":16,"./Transport":23}],20:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.HTTPTransport = void 0; + var isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); + var Transport_1 = require("./Transport"); + var Request_1 = require("../Request"); + var Error_1 = require("../Error"); + var HTTPTransport = /** @class */ (function (_super) { + __extends(HTTPTransport, _super); + function HTTPTransport(uri, options) { + var _this = _super.call(this) || this; + _this.onlyNotifications = function (data) { + if (data instanceof Array) { + return data.every(function (datum) { return datum.request.request.id === null || datum.request.request.id === undefined; }); + } + return (data.request.id === null || data.request.id === undefined); + }; + _this.uri = uri; + _this.credentials = options && options.credentials; + _this.headers = HTTPTransport.setupHeaders(options && options.headers); + return _this; + } + HTTPTransport.prototype.connect = function () { + return Promise.resolve(); + }; + HTTPTransport.prototype.sendData = function (data, timeout) { + if (timeout === void 0) { timeout = null; } + return __awaiter(this, void 0, void 0, function () { + var prom, notifications, batch, result, body, responseErr, e_1, responseErr; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + prom = this.transportRequestManager.addRequest(data, timeout); + notifications = Request_1.getNotifications(data); + batch = Request_1.getBatchRequests(data); + _a.label = 1; + case 1: + _a.trys.push([1, 4, , 5]); + return [4 /*yield*/, isomorphic_fetch_1.default(this.uri, { + method: "POST", + headers: this.headers, + body: JSON.stringify(this.parseData(data)), + credentials: this.credentials, + })]; + case 2: + result = _a.sent(); + // requirements are that notifications are successfully sent + this.transportRequestManager.settlePendingRequest(notifications); + if (this.onlyNotifications(data)) { + return [2 /*return*/, Promise.resolve()]; + } + return [4 /*yield*/, result.text()]; + case 3: + body = _a.sent(); + responseErr = this.transportRequestManager.resolveResponse(body); + if (responseErr) { + // requirements are that batch requuests are successfully resolved + // this ensures that individual requests within the batch request are settled + this.transportRequestManager.settlePendingRequest(batch, responseErr); + return [2 /*return*/, Promise.reject(responseErr)]; + } + return [3 /*break*/, 5]; + case 4: + e_1 = _a.sent(); + responseErr = new Error_1.JSONRPCError(e_1.message, Error_1.ERR_UNKNOWN, e_1); + this.transportRequestManager.settlePendingRequest(notifications, responseErr); + this.transportRequestManager.settlePendingRequest(Request_1.getBatchRequests(data), responseErr); + return [2 /*return*/, Promise.reject(responseErr)]; + case 5: return [2 /*return*/, prom]; + } + }); + }); + }; + // tslint:disable-next-line:no-empty + HTTPTransport.prototype.close = function () { }; + HTTPTransport.setupHeaders = function (headerOptions) { + var headers = new Headers(headerOptions); + // Overwrite header options to ensure correct content type. + headers.set("Content-Type", "application/json"); + return headers; + }; + return HTTPTransport; + }(Transport_1.Transport)); + exports.HTTPTransport = HTTPTransport; + exports.default = HTTPTransport; + + },{"../Error":15,"../Request":16,"./Transport":23,"isomorphic-fetch":98}],21:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var Transport_1 = require("./Transport"); + var PostMessageIframeTransport = /** @class */ (function (_super) { + __extends(PostMessageIframeTransport, _super); + function PostMessageIframeTransport(uri) { + var _this = _super.call(this) || this; + _this.messageHandler = function (ev) { + _this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); + }; + _this.uri = uri; + _this.postMessageID = "post-message-transport-" + Math.random(); + return _this; + } + PostMessageIframeTransport.prototype.createWindow = function (uri) { + var _this = this; + return new Promise(function (resolve, reject) { + var frame; + var iframe = document.createElement("iframe"); + iframe.setAttribute("id", _this.postMessageID); + iframe.setAttribute("width", "0px"); + iframe.setAttribute("height", "0px"); + iframe.setAttribute("style", "visiblity:hidden;border:none;outline:none;"); + iframe.addEventListener("load", function () { + resolve(frame); + }); + iframe.setAttribute("src", uri); + window.document.body.appendChild(iframe); + frame = iframe.contentWindow; + }); + }; + PostMessageIframeTransport.prototype.connect = function () { + var _this = this; + var urlRegex = /^(http|https):\/\/.*$/; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!urlRegex.test(this.uri)) { + reject(new Error("Bad URI")); + } + _a = this; + return [4 /*yield*/, this.createWindow(this.uri)]; + case 1: + _a.frame = _b.sent(); + window.addEventListener("message", this.messageHandler); + resolve(); + return [2 /*return*/]; + } + }); + }); }); + }; + PostMessageIframeTransport.prototype.sendData = function (data, timeout) { + if (timeout === void 0) { timeout = 5000; } + return __awaiter(this, void 0, void 0, function () { + var prom; + return __generator(this, function (_a) { + prom = this.transportRequestManager.addRequest(data, null); + if (this.frame) { + this.frame.postMessage(data.request, "*"); + } + return [2 /*return*/, prom]; + }); + }); + }; + PostMessageIframeTransport.prototype.close = function () { + var el = document.getElementById(this.postMessageID); + el === null || el === void 0 ? void 0 : el.remove(); + window.removeEventListener("message", this.messageHandler); + }; + return PostMessageIframeTransport; + }(Transport_1.Transport)); + exports.default = PostMessageIframeTransport; + + },{"./Transport":23}],22:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var Transport_1 = require("./Transport"); + var openPopup = function (url) { + var width = 400; + var height = window.screen.height; + var left = 0; + var top = 0; + return window.open(url, "inspector:popup", "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",resizable,scrollbars=yes,status=1"); + }; + var PostMessageTransport = /** @class */ (function (_super) { + __extends(PostMessageTransport, _super); + function PostMessageTransport(uri) { + var _this = _super.call(this) || this; + _this.messageHandler = function (ev) { + _this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); + }; + _this.uri = uri; + _this.postMessageID = "post-message-transport-" + Math.random(); + return _this; + } + PostMessageTransport.prototype.createWindow = function (uri) { + return new Promise(function (resolve, reject) { + var frame; + frame = openPopup(uri); + setTimeout(function () { + resolve(frame); + }, 3000); + }); + }; + PostMessageTransport.prototype.connect = function () { + var _this = this; + var urlRegex = /^(http|https):\/\/.*$/; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!urlRegex.test(this.uri)) { + reject(new Error("Bad URI")); + } + _a = this; + return [4 /*yield*/, this.createWindow(this.uri)]; + case 1: + _a.frame = _b.sent(); + window.addEventListener("message", this.messageHandler); + resolve(); + return [2 /*return*/]; + } + }); + }); }); + }; + PostMessageTransport.prototype.sendData = function (data, timeout) { + if (timeout === void 0) { timeout = 5000; } + return __awaiter(this, void 0, void 0, function () { + var prom; + return __generator(this, function (_a) { + prom = this.transportRequestManager.addRequest(data, null); + if (this.frame) { + this.frame.postMessage(data.request, this.uri); + } + return [2 /*return*/, prom]; + }); + }); + }; + PostMessageTransport.prototype.close = function () { + if (this.frame) { + window.removeEventListener("message", this.messageHandler); + this.frame.close(); + } + }; + return PostMessageTransport; + }(Transport_1.Transport)); + exports.default = PostMessageTransport; + + },{"./Transport":23}],23:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Transport = void 0; + var TransportRequestManager_1 = require("./TransportRequestManager"); + var Transport = /** @class */ (function () { + function Transport() { + this.transportRequestManager = new TransportRequestManager_1.TransportRequestManager(); + // add a noop for the error event to not require handling the error event + // tslint:disable-next-line:no-empty + this.transportRequestManager.transportEventChannel.on("error", function () { }); + } + Transport.prototype.subscribe = function (event, handler) { + this.transportRequestManager.transportEventChannel.addListener(event, handler); + }; + Transport.prototype.unsubscribe = function (event, handler) { + if (!event) { + return this.transportRequestManager.transportEventChannel.removeAllListeners(); + } + if (event && handler) { + this.transportRequestManager.transportEventChannel.removeListener(event, handler); + } + }; + Transport.prototype.parseData = function (data) { + if (data instanceof Array) { + return data.map(function (batch) { return batch.request.request; }); + } + return data.request; + }; + return Transport; + }()); + exports.Transport = Transport; + + },{"./TransportRequestManager":24}],24:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.TransportRequestManager = void 0; + var events_1 = require("events"); + var Error_1 = require("../Error"); + var TransportRequestManager = /** @class */ (function () { + function TransportRequestManager() { + this.pendingRequest = {}; + this.pendingBatchRequest = {}; + this.transportEventChannel = new events_1.EventEmitter(); + } + TransportRequestManager.prototype.addRequest = function (data, timeout) { + this.transportEventChannel.emit("pending", data); + if (data instanceof Array) { + this.addBatchReq(data, timeout); + return Promise.resolve(); + } + return this.addReq(data.internalID, timeout); + }; + TransportRequestManager.prototype.settlePendingRequest = function (request, error) { + var _this = this; + request.forEach(function (req) { + var resolver = _this.pendingRequest[req.internalID]; + delete _this.pendingBatchRequest[req.internalID]; + if (resolver === undefined) { + return; + } + if (error) { + resolver.reject(error); + return; + } + resolver.resolve(); + }); + }; + TransportRequestManager.prototype.resolveResponse = function (payload, emitError) { + if (emitError === void 0) { emitError = true; } + var data = payload; + try { + data = JSON.parse(payload); + if (this.checkJSONRPC(data) === false) { + return; // ignore messages that are not conforming to JSON-RPC + } + if (data instanceof Array) { + return this.resolveBatch(data, emitError); + } + return this.resolveRes(data, emitError); + } + catch (e) { + var err = new Error_1.JSONRPCError("Bad response format", Error_1.ERR_UNKNOWN, payload); + if (emitError) { + this.transportEventChannel.emit("error", err); + } + return err; + } + }; + TransportRequestManager.prototype.addBatchReq = function (batches, timeout) { + var _this = this; + batches.forEach(function (batch) { + var resolve = batch.resolve, reject = batch.reject; + var internalID = batch.request.internalID; + _this.pendingBatchRequest[internalID] = true; + _this.pendingRequest[internalID] = { resolve: resolve, reject: reject }; + }); + return Promise.resolve(); + }; + TransportRequestManager.prototype.addReq = function (id, timeout) { + var _this = this; + return new Promise(function (resolve, reject) { + if (timeout !== null && timeout) { + _this.setRequestTimeout(id, timeout, reject); + } + _this.pendingRequest[id] = { resolve: resolve, reject: reject }; + }); + }; + TransportRequestManager.prototype.checkJSONRPC = function (data) { + var payload = [data]; + if (data instanceof Array) { + payload = data; + } + return payload.every(function (datum) { return (datum.result !== undefined || datum.error !== undefined || datum.method !== undefined); }); + }; + TransportRequestManager.prototype.processResult = function (payload, prom) { + if (payload.error) { + var err = Error_1.convertJSONToRPCError(payload); + prom.reject(err); + return; + } + prom.resolve(payload.result); + }; + TransportRequestManager.prototype.resolveBatch = function (payload, emitError) { + var _this = this; + var results = payload.map(function (datum) { + return _this.resolveRes(datum, emitError); + }); + var errors = results.filter(function (result) { return result; }); + if (errors.length > 0) { + return errors[0]; + } + return undefined; + }; + TransportRequestManager.prototype.resolveRes = function (data, emitError) { + var id = data.id, error = data.error; + var status = this.pendingRequest[id]; + if (status) { + delete this.pendingRequest[id]; + this.processResult(data, status); + this.transportEventChannel.emit("response", data); + return; + } + if (id === undefined && error === undefined) { + this.transportEventChannel.emit("notification", data); + return; + } + var err; + if (error) { + err = Error_1.convertJSONToRPCError(data); + } + if (emitError && error && err) { + this.transportEventChannel.emit("error", err); + } + return err; + }; + TransportRequestManager.prototype.setRequestTimeout = function (id, timeout, reject) { + var _this = this; + setTimeout(function () { + delete _this.pendingRequest[id]; + reject(new Error_1.JSONRPCError("Request timeout request took longer than " + timeout + " ms to resolve", Error_1.ERR_TIMEOUT)); + }, timeout); + }; + return TransportRequestManager; + }()); + exports.TransportRequestManager = TransportRequestManager; + + },{"../Error":15,"events":303}],25:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var isomorphic_ws_1 = __importDefault(require("isomorphic-ws")); + var Transport_1 = require("./Transport"); + var Request_1 = require("../Request"); + var Error_1 = require("../Error"); + var WebSocketTransport = /** @class */ (function (_super) { + __extends(WebSocketTransport, _super); + function WebSocketTransport(uri) { + var _this = _super.call(this) || this; + _this.uri = uri; + _this.connection = new isomorphic_ws_1.default(uri); + return _this; + } + WebSocketTransport.prototype.connect = function () { + var _this = this; + return new Promise(function (resolve, reject) { + var cb = function () { + _this.connection.removeEventListener("open", cb); + resolve(); + }; + _this.connection.addEventListener("open", cb); + _this.connection.addEventListener("message", function (message) { + var data = message.data; + _this.transportRequestManager.resolveResponse(data); + }); + }); + }; + WebSocketTransport.prototype.sendData = function (data, timeout) { + if (timeout === void 0) { timeout = 5000; } + return __awaiter(this, void 0, void 0, function () { + var prom, notifications; + var _this = this; + return __generator(this, function (_a) { + prom = this.transportRequestManager.addRequest(data, timeout); + notifications = Request_1.getNotifications(data); + this.connection.send(JSON.stringify(this.parseData(data)), function (err) { + if (err) { + var jsonError = new Error_1.JSONRPCError(err.message, Error_1.ERR_UNKNOWN, err); + _this.transportRequestManager.settlePendingRequest(notifications, jsonError); + _this.transportRequestManager.settlePendingRequest(Request_1.getBatchRequests(data), jsonError); + prom = Promise.reject(jsonError); + } + _this.transportRequestManager.settlePendingRequest(notifications); + }); + return [2 /*return*/, prom]; + }); + }); + }; + WebSocketTransport.prototype.close = function () { + this.connection.close(); + }; + return WebSocketTransport; + }(Transport_1.Transport)); + exports.default = WebSocketTransport; + + },{"../Error":15,"../Request":16,"./Transport":23,"isomorphic-ws":99}],26:[function(require,module,exports){ + 'use strict'; + + const asn1 = exports; + + asn1.bignum = require('bn.js'); + + asn1.define = require('./asn1/api').define; + asn1.base = require('./asn1/base'); + asn1.constants = require('./asn1/constants'); + asn1.decoders = require('./asn1/decoders'); + asn1.encoders = require('./asn1/encoders'); + + },{"./asn1/api":27,"./asn1/base":29,"./asn1/constants":33,"./asn1/decoders":35,"./asn1/encoders":38,"bn.js":45}],27:[function(require,module,exports){ + 'use strict'; + + const encoders = require('./encoders'); + const decoders = require('./decoders'); + const inherits = require('inherits'); + + const api = exports; + + api.define = function define(name, body) { + return new Entity(name, body); + }; + + function Entity(name, body) { + this.name = name; + this.body = body; + + this.decoders = {}; + this.encoders = {}; + } + + Entity.prototype._createNamed = function createNamed(Base) { + const name = this.name; + + function Generated(entity) { + this._initNamed(entity, name); + } + inherits(Generated, Base); + Generated.prototype._initNamed = function _initNamed(entity, name) { + Base.call(this, entity, name); + }; + + return new Generated(this); + }; + + Entity.prototype._getDecoder = function _getDecoder(enc) { + enc = enc || 'der'; + // Lazily create decoder + if (!this.decoders.hasOwnProperty(enc)) + this.decoders[enc] = this._createNamed(decoders[enc]); + return this.decoders[enc]; + }; + + Entity.prototype.decode = function decode(data, enc, options) { + return this._getDecoder(enc).decode(data, options); + }; + + Entity.prototype._getEncoder = function _getEncoder(enc) { + enc = enc || 'der'; + // Lazily create encoder + if (!this.encoders.hasOwnProperty(enc)) + this.encoders[enc] = this._createNamed(encoders[enc]); + return this.encoders[enc]; + }; + + Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { + return this._getEncoder(enc).encode(data, reporter); + }; + + },{"./decoders":35,"./encoders":38,"inherits":97}],28:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + const Reporter = require('../base/reporter').Reporter; + const Buffer = require('safer-buffer').Buffer; + + function DecoderBuffer(base, options) { + Reporter.call(this, options); + if (!Buffer.isBuffer(base)) { + this.error('Input not Buffer'); + return; + } + + this.base = base; + this.offset = 0; + this.length = base.length; + } + inherits(DecoderBuffer, Reporter); + exports.DecoderBuffer = DecoderBuffer; + + DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + Buffer.isBuffer(data.base) && + data.constructor.name === 'DecoderBuffer' && + typeof data.offset === 'number' && + typeof data.length === 'number' && + typeof data.save === 'function' && + typeof data.restore === 'function' && + typeof data.isEmpty === 'function' && + typeof data.readUInt8 === 'function' && + typeof data.skip === 'function' && + typeof data.raw === 'function'; + + return isCompatible; + }; + + DecoderBuffer.prototype.save = function save() { + return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; + }; + + DecoderBuffer.prototype.restore = function restore(save) { + // Return skipped data + const res = new DecoderBuffer(this.base); + res.offset = save.offset; + res.length = this.offset; + + this.offset = save.offset; + Reporter.prototype.restore.call(this, save.reporter); + + return res; + }; + + DecoderBuffer.prototype.isEmpty = function isEmpty() { + return this.offset === this.length; + }; + + DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { + if (this.offset + 1 <= this.length) + return this.base.readUInt8(this.offset++, true); + else + return this.error(fail || 'DecoderBuffer overrun'); + }; + + DecoderBuffer.prototype.skip = function skip(bytes, fail) { + if (!(this.offset + bytes <= this.length)) + return this.error(fail || 'DecoderBuffer overrun'); + + const res = new DecoderBuffer(this.base); + + // Share reporter state + res._reporterState = this._reporterState; + + res.offset = this.offset; + res.length = this.offset + bytes; + this.offset += bytes; + return res; + }; + + DecoderBuffer.prototype.raw = function raw(save) { + return this.base.slice(save ? save.offset : this.offset, this.length); + }; + + function EncoderBuffer(value, reporter) { + if (Array.isArray(value)) { + this.length = 0; + this.value = value.map(function(item) { + if (!EncoderBuffer.isEncoderBuffer(item)) + item = new EncoderBuffer(item, reporter); + this.length += item.length; + return item; + }, this); + } else if (typeof value === 'number') { + if (!(0 <= value && value <= 0xff)) + return reporter.error('non-byte EncoderBuffer value'); + this.value = value; + this.length = 1; + } else if (typeof value === 'string') { + this.value = value; + this.length = Buffer.byteLength(value); + } else if (Buffer.isBuffer(value)) { + this.value = value; + this.length = value.length; + } else { + return reporter.error('Unsupported type: ' + typeof value); + } + } + exports.EncoderBuffer = EncoderBuffer; + + EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + data.constructor.name === 'EncoderBuffer' && + typeof data.length === 'number' && + typeof data.join === 'function'; + + return isCompatible; + }; + + EncoderBuffer.prototype.join = function join(out, offset) { + if (!out) + out = Buffer.alloc(this.length); + if (!offset) + offset = 0; + + if (this.length === 0) + return out; + + if (Array.isArray(this.value)) { + this.value.forEach(function(item) { + item.join(out, offset); + offset += item.length; + }); + } else { + if (typeof this.value === 'number') + out[offset] = this.value; + else if (typeof this.value === 'string') + out.write(this.value, offset); + else if (Buffer.isBuffer(this.value)) + this.value.copy(out, offset); + offset += this.length; + } + + return out; + }; + + },{"../base/reporter":31,"inherits":97,"safer-buffer":123}],29:[function(require,module,exports){ + 'use strict'; + + const base = exports; + + base.Reporter = require('./reporter').Reporter; + base.DecoderBuffer = require('./buffer').DecoderBuffer; + base.EncoderBuffer = require('./buffer').EncoderBuffer; + base.Node = require('./node'); + + },{"./buffer":28,"./node":30,"./reporter":31}],30:[function(require,module,exports){ + 'use strict'; + + const Reporter = require('../base/reporter').Reporter; + const EncoderBuffer = require('../base/buffer').EncoderBuffer; + const DecoderBuffer = require('../base/buffer').DecoderBuffer; + const assert = require('minimalistic-assert'); + + // Supported tags + const tags = [ + 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', + 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', + 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', + 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr' + ]; + + // Public methods list + const methods = [ + 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', + 'any', 'contains' + ].concat(tags); + + // Overrided methods list + const overrided = [ + '_peekTag', '_decodeTag', '_use', + '_decodeStr', '_decodeObjid', '_decodeTime', + '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', + + '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', + '_encodeNull', '_encodeInt', '_encodeBool' + ]; + + function Node(enc, parent, name) { + const state = {}; + this._baseState = state; + + state.name = name; + state.enc = enc; + + state.parent = parent || null; + state.children = null; + + // State + state.tag = null; + state.args = null; + state.reverseArgs = null; + state.choice = null; + state.optional = false; + state.any = false; + state.obj = false; + state.use = null; + state.useDecoder = null; + state.key = null; + state['default'] = null; + state.explicit = null; + state.implicit = null; + state.contains = null; + + // Should create new instance on each method + if (!state.parent) { + state.children = []; + this._wrap(); + } + } + module.exports = Node; + + const stateProps = [ + 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', + 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', + 'implicit', 'contains' + ]; + + Node.prototype.clone = function clone() { + const state = this._baseState; + const cstate = {}; + stateProps.forEach(function(prop) { + cstate[prop] = state[prop]; + }); + const res = new this.constructor(cstate.parent); + res._baseState = cstate; + return res; + }; + + Node.prototype._wrap = function wrap() { + const state = this._baseState; + methods.forEach(function(method) { + this[method] = function _wrappedMethod() { + const clone = new this.constructor(this); + state.children.push(clone); + return clone[method].apply(clone, arguments); + }; + }, this); + }; + + Node.prototype._init = function init(body) { + const state = this._baseState; + + assert(state.parent === null); + body.call(this); + + // Filter children + state.children = state.children.filter(function(child) { + return child._baseState.parent === this; + }, this); + assert.equal(state.children.length, 1, 'Root node can have only one child'); + }; + + Node.prototype._useArgs = function useArgs(args) { + const state = this._baseState; + + // Filter children and args + const children = args.filter(function(arg) { + return arg instanceof this.constructor; + }, this); + args = args.filter(function(arg) { + return !(arg instanceof this.constructor); + }, this); + + if (children.length !== 0) { + assert(state.children === null); + state.children = children; + + // Replace parent to maintain backward link + children.forEach(function(child) { + child._baseState.parent = this; + }, this); + } + if (args.length !== 0) { + assert(state.args === null); + state.args = args; + state.reverseArgs = args.map(function(arg) { + if (typeof arg !== 'object' || arg.constructor !== Object) + return arg; + + const res = {}; + Object.keys(arg).forEach(function(key) { + if (key == (key | 0)) + key |= 0; + const value = arg[key]; + res[value] = key; + }); + return res; + }); + } + }; + + // + // Overrided methods + // + + overrided.forEach(function(method) { + Node.prototype[method] = function _overrided() { + const state = this._baseState; + throw new Error(method + ' not implemented for encoding: ' + state.enc); + }; + }); + + // + // Public methods + // + + tags.forEach(function(tag) { + Node.prototype[tag] = function _tagMethod() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + + assert(state.tag === null); + state.tag = tag; + + this._useArgs(args); + + return this; + }; + }); + + Node.prototype.use = function use(item) { + assert(item); + const state = this._baseState; + + assert(state.use === null); + state.use = item; + + return this; + }; + + Node.prototype.optional = function optional() { + const state = this._baseState; + + state.optional = true; + + return this; + }; + + Node.prototype.def = function def(val) { + const state = this._baseState; + + assert(state['default'] === null); + state['default'] = val; + state.optional = true; + + return this; + }; + + Node.prototype.explicit = function explicit(num) { + const state = this._baseState; + + assert(state.explicit === null && state.implicit === null); + state.explicit = num; + + return this; + }; + + Node.prototype.implicit = function implicit(num) { + const state = this._baseState; + + assert(state.explicit === null && state.implicit === null); + state.implicit = num; + + return this; + }; + + Node.prototype.obj = function obj() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + + state.obj = true; + + if (args.length !== 0) + this._useArgs(args); + + return this; + }; + + Node.prototype.key = function key(newKey) { + const state = this._baseState; + + assert(state.key === null); + state.key = newKey; + + return this; + }; + + Node.prototype.any = function any() { + const state = this._baseState; + + state.any = true; + + return this; + }; + + Node.prototype.choice = function choice(obj) { + const state = this._baseState; + + assert(state.choice === null); + state.choice = obj; + this._useArgs(Object.keys(obj).map(function(key) { + return obj[key]; + })); + + return this; + }; + + Node.prototype.contains = function contains(item) { + const state = this._baseState; + + assert(state.use === null); + state.contains = item; + + return this; + }; + + // + // Decoding + // + + Node.prototype._decode = function decode(input, options) { + const state = this._baseState; + + // Decode root node + if (state.parent === null) + return input.wrapResult(state.children[0]._decode(input, options)); + + let result = state['default']; + let present = true; + + let prevKey = null; + if (state.key !== null) + prevKey = input.enterKey(state.key); + + // Check if tag is there + if (state.optional) { + let tag = null; + if (state.explicit !== null) + tag = state.explicit; + else if (state.implicit !== null) + tag = state.implicit; + else if (state.tag !== null) + tag = state.tag; + + if (tag === null && !state.any) { + // Trial and Error + const save = input.save(); + try { + if (state.choice === null) + this._decodeGeneric(state.tag, input, options); + else + this._decodeChoice(input, options); + present = true; + } catch (e) { + present = false; + } + input.restore(save); + } else { + present = this._peekTag(input, tag, state.any); + + if (input.isError(present)) + return present; + } + } + + // Push object on stack + let prevObj; + if (state.obj && present) + prevObj = input.enterObject(); + + if (present) { + // Unwrap explicit values + if (state.explicit !== null) { + const explicit = this._decodeTag(input, state.explicit); + if (input.isError(explicit)) + return explicit; + input = explicit; + } + + const start = input.offset; + + // Unwrap implicit and normal values + if (state.use === null && state.choice === null) { + let save; + if (state.any) + save = input.save(); + const body = this._decodeTag( + input, + state.implicit !== null ? state.implicit : state.tag, + state.any + ); + if (input.isError(body)) + return body; + + if (state.any) + result = input.raw(save); + else + input = body; + } + + if (options && options.track && state.tag !== null) + options.track(input.path(), start, input.length, 'tagged'); + + if (options && options.track && state.tag !== null) + options.track(input.path(), input.offset, input.length, 'content'); + + // Select proper method for tag + if (state.any) { + // no-op + } else if (state.choice === null) { + result = this._decodeGeneric(state.tag, input, options); + } else { + result = this._decodeChoice(input, options); + } + + if (input.isError(result)) + return result; + + // Decode children + if (!state.any && state.choice === null && state.children !== null) { + state.children.forEach(function decodeChildren(child) { + // NOTE: We are ignoring errors here, to let parser continue with other + // parts of encoded data + child._decode(input, options); + }); + } + + // Decode contained/encoded by schema, only in bit or octet strings + if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { + const data = new DecoderBuffer(result); + result = this._getUse(state.contains, input._reporterState.obj) + ._decode(data, options); + } + } + + // Pop object + if (state.obj && present) + result = input.leaveObject(prevObj); + + // Set key + if (state.key !== null && (result !== null || present === true)) + input.leaveKey(prevKey, state.key, result); + else if (prevKey !== null) + input.exitKey(prevKey); + + return result; + }; + + Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { + const state = this._baseState; + + if (tag === 'seq' || tag === 'set') + return null; + if (tag === 'seqof' || tag === 'setof') + return this._decodeList(input, tag, state.args[0], options); + else if (/str$/.test(tag)) + return this._decodeStr(input, tag, options); + else if (tag === 'objid' && state.args) + return this._decodeObjid(input, state.args[0], state.args[1], options); + else if (tag === 'objid') + return this._decodeObjid(input, null, null, options); + else if (tag === 'gentime' || tag === 'utctime') + return this._decodeTime(input, tag, options); + else if (tag === 'null_') + return this._decodeNull(input, options); + else if (tag === 'bool') + return this._decodeBool(input, options); + else if (tag === 'objDesc') + return this._decodeStr(input, tag, options); + else if (tag === 'int' || tag === 'enum') + return this._decodeInt(input, state.args && state.args[0], options); + + if (state.use !== null) { + return this._getUse(state.use, input._reporterState.obj) + ._decode(input, options); + } else { + return input.error('unknown tag: ' + tag); + } + }; + + Node.prototype._getUse = function _getUse(entity, obj) { + + const state = this._baseState; + // Create altered use decoder if implicit is set + state.useDecoder = this._use(entity, obj); + assert(state.useDecoder._baseState.parent === null); + state.useDecoder = state.useDecoder._baseState.children[0]; + if (state.implicit !== state.useDecoder._baseState.implicit) { + state.useDecoder = state.useDecoder.clone(); + state.useDecoder._baseState.implicit = state.implicit; + } + return state.useDecoder; + }; + + Node.prototype._decodeChoice = function decodeChoice(input, options) { + const state = this._baseState; + let result = null; + let match = false; + + Object.keys(state.choice).some(function(key) { + const save = input.save(); + const node = state.choice[key]; + try { + const value = node._decode(input, options); + if (input.isError(value)) + return false; + + result = { type: key, value: value }; + match = true; + } catch (e) { + input.restore(save); + return false; + } + return true; + }, this); + + if (!match) + return input.error('Choice not matched'); + + return result; + }; + + // + // Encoding + // + + Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { + return new EncoderBuffer(data, this.reporter); + }; + + Node.prototype._encode = function encode(data, reporter, parent) { + const state = this._baseState; + if (state['default'] !== null && state['default'] === data) + return; + + const result = this._encodeValue(data, reporter, parent); + if (result === undefined) + return; + + if (this._skipDefault(result, reporter, parent)) + return; + + return result; + }; + + Node.prototype._encodeValue = function encode(data, reporter, parent) { + const state = this._baseState; + + // Decode root node + if (state.parent === null) + return state.children[0]._encode(data, reporter || new Reporter()); + + let result = null; + + // Set reporter to share it with a child class + this.reporter = reporter; + + // Check if data is there + if (state.optional && data === undefined) { + if (state['default'] !== null) + data = state['default']; + else + return; + } + + // Encode children first + let content = null; + let primitive = false; + if (state.any) { + // Anything that was given is translated to buffer + result = this._createEncoderBuffer(data); + } else if (state.choice) { + result = this._encodeChoice(data, reporter); + } else if (state.contains) { + content = this._getUse(state.contains, parent)._encode(data, reporter); + primitive = true; + } else if (state.children) { + content = state.children.map(function(child) { + if (child._baseState.tag === 'null_') + return child._encode(null, reporter, data); + + if (child._baseState.key === null) + return reporter.error('Child should have a key'); + const prevKey = reporter.enterKey(child._baseState.key); + + if (typeof data !== 'object') + return reporter.error('Child expected, but input is not object'); + + const res = child._encode(data[child._baseState.key], reporter, data); + reporter.leaveKey(prevKey); + + return res; + }, this).filter(function(child) { + return child; + }); + content = this._createEncoderBuffer(content); + } else { + if (state.tag === 'seqof' || state.tag === 'setof') { + // TODO(indutny): this should be thrown on DSL level + if (!(state.args && state.args.length === 1)) + return reporter.error('Too many args for : ' + state.tag); + + if (!Array.isArray(data)) + return reporter.error('seqof/setof, but data is not Array'); + + const child = this.clone(); + child._baseState.implicit = null; + content = this._createEncoderBuffer(data.map(function(item) { + const state = this._baseState; + + return this._getUse(state.args[0], data)._encode(item, reporter); + }, child)); + } else if (state.use !== null) { + result = this._getUse(state.use, parent)._encode(data, reporter); + } else { + content = this._encodePrimitive(state.tag, data); + primitive = true; + } + } + + // Encode data itself + if (!state.any && state.choice === null) { + const tag = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? 'universal' : 'context'; + + if (tag === null) { + if (state.use === null) + reporter.error('Tag could be omitted only for .use()'); + } else { + if (state.use === null) + result = this._encodeComposite(tag, primitive, cls, content); + } + } + + // Wrap in explicit + if (state.explicit !== null) + result = this._encodeComposite(state.explicit, false, 'context', result); + + return result; + }; + + Node.prototype._encodeChoice = function encodeChoice(data, reporter) { + const state = this._baseState; + + const node = state.choice[data.type]; + if (!node) { + assert( + false, + data.type + ' not found in ' + + JSON.stringify(Object.keys(state.choice))); + } + return node._encode(data.value, reporter); + }; + + Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { + const state = this._baseState; + + if (/str$/.test(tag)) + return this._encodeStr(data, tag); + else if (tag === 'objid' && state.args) + return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); + else if (tag === 'objid') + return this._encodeObjid(data, null, null); + else if (tag === 'gentime' || tag === 'utctime') + return this._encodeTime(data, tag); + else if (tag === 'null_') + return this._encodeNull(); + else if (tag === 'int' || tag === 'enum') + return this._encodeInt(data, state.args && state.reverseArgs[0]); + else if (tag === 'bool') + return this._encodeBool(data); + else if (tag === 'objDesc') + return this._encodeStr(data, tag); + else + throw new Error('Unsupported tag: ' + tag); + }; + + Node.prototype._isNumstr = function isNumstr(str) { + return /^[0-9 ]*$/.test(str); + }; + + Node.prototype._isPrintstr = function isPrintstr(str) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); + }; + + },{"../base/buffer":28,"../base/reporter":31,"minimalistic-assert":103}],31:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + + function Reporter(options) { + this._reporterState = { + obj: null, + path: [], + options: options || {}, + errors: [] + }; + } + exports.Reporter = Reporter; + + Reporter.prototype.isError = function isError(obj) { + return obj instanceof ReporterError; + }; + + Reporter.prototype.save = function save() { + const state = this._reporterState; + + return { obj: state.obj, pathLen: state.path.length }; + }; + + Reporter.prototype.restore = function restore(data) { + const state = this._reporterState; + + state.obj = data.obj; + state.path = state.path.slice(0, data.pathLen); + }; + + Reporter.prototype.enterKey = function enterKey(key) { + return this._reporterState.path.push(key); + }; + + Reporter.prototype.exitKey = function exitKey(index) { + const state = this._reporterState; + + state.path = state.path.slice(0, index - 1); + }; + + Reporter.prototype.leaveKey = function leaveKey(index, key, value) { + const state = this._reporterState; + + this.exitKey(index); + if (state.obj !== null) + state.obj[key] = value; + }; + + Reporter.prototype.path = function path() { + return this._reporterState.path.join('/'); + }; + + Reporter.prototype.enterObject = function enterObject() { + const state = this._reporterState; + + const prev = state.obj; + state.obj = {}; + return prev; + }; + + Reporter.prototype.leaveObject = function leaveObject(prev) { + const state = this._reporterState; + + const now = state.obj; + state.obj = prev; + return now; + }; + + Reporter.prototype.error = function error(msg) { + let err; + const state = this._reporterState; + + const inherited = msg instanceof ReporterError; + if (inherited) { + err = msg; + } else { + err = new ReporterError(state.path.map(function(elem) { + return '[' + JSON.stringify(elem) + ']'; + }).join(''), msg.message || msg, msg.stack); + } + + if (!state.options.partial) + throw err; + + if (!inherited) + state.errors.push(err); + + return err; + }; + + Reporter.prototype.wrapResult = function wrapResult(result) { + const state = this._reporterState; + if (!state.options.partial) + return result; + + return { + result: this.isError(result) ? null : result, + errors: state.errors + }; + }; + + function ReporterError(path, msg) { + this.path = path; + this.rethrow(msg); + } + inherits(ReporterError, Error); + + ReporterError.prototype.rethrow = function rethrow(msg) { + this.message = msg + ' at: ' + (this.path || '(shallow)'); + if (Error.captureStackTrace) + Error.captureStackTrace(this, ReporterError); + + if (!this.stack) { + try { + // IE only adds stack when thrown + throw new Error(this.message); + } catch (e) { + this.stack = e.stack; + } + } + return this; + }; + + },{"inherits":97}],32:[function(require,module,exports){ + 'use strict'; + + // Helper + function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; + } + + exports.tagClass = { + 0: 'universal', + 1: 'application', + 2: 'context', + 3: 'private' + }; + exports.tagClassByName = reverse(exports.tagClass); + + exports.tag = { + 0x00: 'end', + 0x01: 'bool', + 0x02: 'int', + 0x03: 'bitstr', + 0x04: 'octstr', + 0x05: 'null_', + 0x06: 'objid', + 0x07: 'objDesc', + 0x08: 'external', + 0x09: 'real', + 0x0a: 'enum', + 0x0b: 'embed', + 0x0c: 'utf8str', + 0x0d: 'relativeOid', + 0x10: 'seq', + 0x11: 'set', + 0x12: 'numstr', + 0x13: 'printstr', + 0x14: 't61str', + 0x15: 'videostr', + 0x16: 'ia5str', + 0x17: 'utctime', + 0x18: 'gentime', + 0x19: 'graphstr', + 0x1a: 'iso646str', + 0x1b: 'genstr', + 0x1c: 'unistr', + 0x1d: 'charstr', + 0x1e: 'bmpstr' + }; + exports.tagByName = reverse(exports.tag); + + },{}],33:[function(require,module,exports){ + 'use strict'; + + const constants = exports; + + // Helper + constants._reverse = function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; + }; + + constants.der = require('./der'); + + },{"./der":32}],34:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + + const bignum = require('bn.js'); + const DecoderBuffer = require('../base/buffer').DecoderBuffer; + const Node = require('../base/node'); + + // Import DER constants + const der = require('../constants/der'); + + function DERDecoder(entity) { + this.enc = 'der'; + this.name = entity.name; + this.entity = entity; + + // Construct base tree + this.tree = new DERNode(); + this.tree._init(entity.body); + } + module.exports = DERDecoder; + + DERDecoder.prototype.decode = function decode(data, options) { + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } + + return this.tree._decode(data, options); + }; + + // Tree methods + + function DERNode(parent) { + Node.call(this, 'der', parent); + } + inherits(DERNode, Node); + + DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { + if (buffer.isEmpty()) + return false; + + const state = buffer.save(); + const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); + if (buffer.isError(decodedTag)) + return decodedTag; + + buffer.restore(state); + + return decodedTag.tag === tag || decodedTag.tagStr === tag || + (decodedTag.tagStr + 'of') === tag || any; + }; + + DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { + const decodedTag = derDecodeTag(buffer, + 'Failed to decode tag of "' + tag + '"'); + if (buffer.isError(decodedTag)) + return decodedTag; + + let len = derDecodeLen(buffer, + decodedTag.primitive, + 'Failed to get length of "' + tag + '"'); + + // Failure + if (buffer.isError(len)) + return len; + + if (!any && + decodedTag.tag !== tag && + decodedTag.tagStr !== tag && + decodedTag.tagStr + 'of' !== tag) { + return buffer.error('Failed to match tag: "' + tag + '"'); + } + + if (decodedTag.primitive || len !== null) + return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); + + // Indefinite length... find END tag + const state = buffer.save(); + const res = this._skipUntilEnd( + buffer, + 'Failed to skip indefinite length body: "' + this.tag + '"'); + if (buffer.isError(res)) + return res; + + len = buffer.offset - state.offset; + buffer.restore(state); + return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); + }; + + DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { + for (;;) { + const tag = derDecodeTag(buffer, fail); + if (buffer.isError(tag)) + return tag; + const len = derDecodeLen(buffer, tag.primitive, fail); + if (buffer.isError(len)) + return len; + + let res; + if (tag.primitive || len !== null) + res = buffer.skip(len); + else + res = this._skipUntilEnd(buffer, fail); + + // Failure + if (buffer.isError(res)) + return res; + + if (tag.tagStr === 'end') + break; + } + }; + + DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, + options) { + const result = []; + while (!buffer.isEmpty()) { + const possibleEnd = this._peekTag(buffer, 'end'); + if (buffer.isError(possibleEnd)) + return possibleEnd; + + const res = decoder.decode(buffer, 'der', options); + if (buffer.isError(res) && possibleEnd) + break; + result.push(res); + } + return result; + }; + + DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { + if (tag === 'bitstr') { + const unused = buffer.readUInt8(); + if (buffer.isError(unused)) + return unused; + return { unused: unused, data: buffer.raw() }; + } else if (tag === 'bmpstr') { + const raw = buffer.raw(); + if (raw.length % 2 === 1) + return buffer.error('Decoding of string type: bmpstr length mismatch'); + + let str = ''; + for (let i = 0; i < raw.length / 2; i++) { + str += String.fromCharCode(raw.readUInt16BE(i * 2)); + } + return str; + } else if (tag === 'numstr') { + const numstr = buffer.raw().toString('ascii'); + if (!this._isNumstr(numstr)) { + return buffer.error('Decoding of string type: ' + + 'numstr unsupported characters'); + } + return numstr; + } else if (tag === 'octstr') { + return buffer.raw(); + } else if (tag === 'objDesc') { + return buffer.raw(); + } else if (tag === 'printstr') { + const printstr = buffer.raw().toString('ascii'); + if (!this._isPrintstr(printstr)) { + return buffer.error('Decoding of string type: ' + + 'printstr unsupported characters'); + } + return printstr; + } else if (/str$/.test(tag)) { + return buffer.raw().toString(); + } else { + return buffer.error('Decoding of string type: ' + tag + ' unsupported'); + } + }; + + DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { + let result; + const identifiers = []; + let ident = 0; + let subident = 0; + while (!buffer.isEmpty()) { + subident = buffer.readUInt8(); + ident <<= 7; + ident |= subident & 0x7f; + if ((subident & 0x80) === 0) { + identifiers.push(ident); + ident = 0; + } + } + if (subident & 0x80) + identifiers.push(ident); + + const first = (identifiers[0] / 40) | 0; + const second = identifiers[0] % 40; + + if (relative) + result = identifiers; + else + result = [first, second].concat(identifiers.slice(1)); + + if (values) { + let tmp = values[result.join(' ')]; + if (tmp === undefined) + tmp = values[result.join('.')]; + if (tmp !== undefined) + result = tmp; + } + + return result; + }; + + DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { + const str = buffer.raw().toString(); + + let year; + let mon; + let day; + let hour; + let min; + let sec; + if (tag === 'gentime') { + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; + } else if (tag === 'utctime') { + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; + if (year < 70) + year = 2000 + year; + else + year = 1900 + year; + } else { + return buffer.error('Decoding ' + tag + ' time is not supported yet'); + } + + return Date.UTC(year, mon - 1, day, hour, min, sec, 0); + }; + + DERNode.prototype._decodeNull = function decodeNull() { + return null; + }; + + DERNode.prototype._decodeBool = function decodeBool(buffer) { + const res = buffer.readUInt8(); + if (buffer.isError(res)) + return res; + else + return res !== 0; + }; + + DERNode.prototype._decodeInt = function decodeInt(buffer, values) { + // Bigint, return as it is (assume big endian) + const raw = buffer.raw(); + let res = new bignum(raw); + + if (values) + res = values[res.toString(10)] || res; + + return res; + }; + + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === 'function') + entity = entity(obj); + return entity._getDecoder('der').tree; + }; + + // Utility methods + + function derDecodeTag(buf, fail) { + let tag = buf.readUInt8(fail); + if (buf.isError(tag)) + return tag; + + const cls = der.tagClass[tag >> 6]; + const primitive = (tag & 0x20) === 0; + + // Multi-octet tag - load + if ((tag & 0x1f) === 0x1f) { + let oct = tag; + tag = 0; + while ((oct & 0x80) === 0x80) { + oct = buf.readUInt8(fail); + if (buf.isError(oct)) + return oct; + + tag <<= 7; + tag |= oct & 0x7f; + } + } else { + tag &= 0x1f; + } + const tagStr = der.tag[tag]; + + return { + cls: cls, + primitive: primitive, + tag: tag, + tagStr: tagStr + }; + } + + function derDecodeLen(buf, primitive, fail) { + let len = buf.readUInt8(fail); + if (buf.isError(len)) + return len; + + // Indefinite form + if (!primitive && len === 0x80) + return null; + + // Definite form + if ((len & 0x80) === 0) { + // Short form + return len; + } + + // Long form + const num = len & 0x7f; + if (num > 4) + return buf.error('length octect is too long'); + + len = 0; + for (let i = 0; i < num; i++) { + len <<= 8; + const j = buf.readUInt8(fail); + if (buf.isError(j)) + return j; + len |= j; + } + + return len; + } + + },{"../base/buffer":28,"../base/node":30,"../constants/der":32,"bn.js":45,"inherits":97}],35:[function(require,module,exports){ + 'use strict'; + + const decoders = exports; + + decoders.der = require('./der'); + decoders.pem = require('./pem'); + + },{"./der":34,"./pem":36}],36:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + const Buffer = require('safer-buffer').Buffer; + + const DERDecoder = require('./der'); + + function PEMDecoder(entity) { + DERDecoder.call(this, entity); + this.enc = 'pem'; + } + inherits(PEMDecoder, DERDecoder); + module.exports = PEMDecoder; + + PEMDecoder.prototype.decode = function decode(data, options) { + const lines = data.toString().split(/[\r\n]+/g); + + const label = options.label.toUpperCase(); + + const re = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(re); + if (match === null) + continue; + + if (match[2] !== label) + continue; + + if (start === -1) { + if (match[1] !== 'BEGIN') + break; + start = i; + } else { + if (match[1] !== 'END') + break; + end = i; + break; + } + } + if (start === -1 || end === -1) + throw new Error('PEM section not found for: ' + label); + + const base64 = lines.slice(start + 1, end).join(''); + // Remove excessive symbols + base64.replace(/[^a-z0-9+/=]+/gi, ''); + + const input = Buffer.from(base64, 'base64'); + return DERDecoder.prototype.decode.call(this, input, options); + }; + + },{"./der":34,"inherits":97,"safer-buffer":123}],37:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + const Buffer = require('safer-buffer').Buffer; + const Node = require('../base/node'); + + // Import DER constants + const der = require('../constants/der'); + + function DEREncoder(entity) { + this.enc = 'der'; + this.name = entity.name; + this.entity = entity; + + // Construct base tree + this.tree = new DERNode(); + this.tree._init(entity.body); + } + module.exports = DEREncoder; + + DEREncoder.prototype.encode = function encode(data, reporter) { + return this.tree._encode(data, reporter).join(); + }; + + // Tree methods + + function DERNode(parent) { + Node.call(this, 'der', parent); + } + inherits(DERNode, Node); + + DERNode.prototype._encodeComposite = function encodeComposite(tag, + primitive, + cls, + content) { + const encodedTag = encodeTag(tag, primitive, cls, this.reporter); + + // Short form + if (content.length < 0x80) { + const header = Buffer.alloc(2); + header[0] = encodedTag; + header[1] = content.length; + return this._createEncoderBuffer([ header, content ]); + } + + // Long form + // Count octets required to store length + let lenOctets = 1; + for (let i = content.length; i >= 0x100; i >>= 8) + lenOctets++; + + const header = Buffer.alloc(1 + 1 + lenOctets); + header[0] = encodedTag; + header[1] = 0x80 | lenOctets; + + for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) + header[i] = j & 0xff; + + return this._createEncoderBuffer([ header, content ]); + }; + + DERNode.prototype._encodeStr = function encodeStr(str, tag) { + if (tag === 'bitstr') { + return this._createEncoderBuffer([ str.unused | 0, str.data ]); + } else if (tag === 'bmpstr') { + const buf = Buffer.alloc(str.length * 2); + for (let i = 0; i < str.length; i++) { + buf.writeUInt16BE(str.charCodeAt(i), i * 2); + } + return this._createEncoderBuffer(buf); + } else if (tag === 'numstr') { + if (!this._isNumstr(str)) { + return this.reporter.error('Encoding of string type: numstr supports ' + + 'only digits and space'); + } + return this._createEncoderBuffer(str); + } else if (tag === 'printstr') { + if (!this._isPrintstr(str)) { + return this.reporter.error('Encoding of string type: printstr supports ' + + 'only latin upper and lower case letters, ' + + 'digits, space, apostrophe, left and rigth ' + + 'parenthesis, plus sign, comma, hyphen, ' + + 'dot, slash, colon, equal sign, ' + + 'question mark'); + } + return this._createEncoderBuffer(str); + } else if (/str$/.test(tag)) { + return this._createEncoderBuffer(str); + } else if (tag === 'objDesc') { + return this._createEncoderBuffer(str); + } else { + return this.reporter.error('Encoding of string type: ' + tag + + ' unsupported'); + } + }; + + DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { + if (typeof id === 'string') { + if (!values) + return this.reporter.error('string objid given, but no values map found'); + if (!values.hasOwnProperty(id)) + return this.reporter.error('objid not found in values map'); + id = values[id].split(/[\s.]+/g); + for (let i = 0; i < id.length; i++) + id[i] |= 0; + } else if (Array.isArray(id)) { + id = id.slice(); + for (let i = 0; i < id.length; i++) + id[i] |= 0; + } + + if (!Array.isArray(id)) { + return this.reporter.error('objid() should be either array or string, ' + + 'got: ' + JSON.stringify(id)); + } + + if (!relative) { + if (id[1] >= 40) + return this.reporter.error('Second objid identifier OOB'); + id.splice(0, 2, id[0] * 40 + id[1]); + } + + // Count number of octets + let size = 0; + for (let i = 0; i < id.length; i++) { + let ident = id[i]; + for (size++; ident >= 0x80; ident >>= 7) + size++; + } + + const objid = Buffer.alloc(size); + let offset = objid.length - 1; + for (let i = id.length - 1; i >= 0; i--) { + let ident = id[i]; + objid[offset--] = ident & 0x7f; + while ((ident >>= 7) > 0) + objid[offset--] = 0x80 | (ident & 0x7f); + } + + return this._createEncoderBuffer(objid); + }; + + function two(num) { + if (num < 10) + return '0' + num; + else + return num; + } + + DERNode.prototype._encodeTime = function encodeTime(time, tag) { + let str; + const date = new Date(time); + + if (tag === 'gentime') { + str = [ + two(date.getUTCFullYear()), + two(date.getUTCMonth() + 1), + two(date.getUTCDate()), + two(date.getUTCHours()), + two(date.getUTCMinutes()), + two(date.getUTCSeconds()), + 'Z' + ].join(''); + } else if (tag === 'utctime') { + str = [ + two(date.getUTCFullYear() % 100), + two(date.getUTCMonth() + 1), + two(date.getUTCDate()), + two(date.getUTCHours()), + two(date.getUTCMinutes()), + two(date.getUTCSeconds()), + 'Z' + ].join(''); + } else { + this.reporter.error('Encoding ' + tag + ' time is not supported yet'); + } + + return this._encodeStr(str, 'octstr'); + }; + + DERNode.prototype._encodeNull = function encodeNull() { + return this._createEncoderBuffer(''); + }; + + DERNode.prototype._encodeInt = function encodeInt(num, values) { + if (typeof num === 'string') { + if (!values) + return this.reporter.error('String int or enum given, but no values map'); + if (!values.hasOwnProperty(num)) { + return this.reporter.error('Values map doesn\'t contain: ' + + JSON.stringify(num)); + } + num = values[num]; + } + + // Bignum, assume big endian + if (typeof num !== 'number' && !Buffer.isBuffer(num)) { + const numArray = num.toArray(); + if (!num.sign && numArray[0] & 0x80) { + numArray.unshift(0); + } + num = Buffer.from(numArray); + } + + if (Buffer.isBuffer(num)) { + let size = num.length; + if (num.length === 0) + size++; + + const out = Buffer.alloc(size); + num.copy(out); + if (num.length === 0) + out[0] = 0; + return this._createEncoderBuffer(out); + } + + if (num < 0x80) + return this._createEncoderBuffer(num); + + if (num < 0x100) + return this._createEncoderBuffer([0, num]); + + let size = 1; + for (let i = num; i >= 0x100; i >>= 8) + size++; + + const out = new Array(size); + for (let i = out.length - 1; i >= 0; i--) { + out[i] = num & 0xff; + num >>= 8; + } + if(out[0] & 0x80) { + out.unshift(0); + } + + return this._createEncoderBuffer(Buffer.from(out)); + }; + + DERNode.prototype._encodeBool = function encodeBool(value) { + return this._createEncoderBuffer(value ? 0xff : 0); + }; + + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === 'function') + entity = entity(obj); + return entity._getEncoder('der').tree; + }; + + DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { + const state = this._baseState; + let i; + if (state['default'] === null) + return false; + + const data = dataBuffer.join(); + if (state.defaultBuffer === undefined) + state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); + + if (data.length !== state.defaultBuffer.length) + return false; + + for (i=0; i < data.length; i++) + if (data[i] !== state.defaultBuffer[i]) + return false; + + return true; + }; + + // Utility methods + + function encodeTag(tag, primitive, cls, reporter) { + let res; + + if (tag === 'seqof') + tag = 'seq'; + else if (tag === 'setof') + tag = 'set'; + + if (der.tagByName.hasOwnProperty(tag)) + res = der.tagByName[tag]; + else if (typeof tag === 'number' && (tag | 0) === tag) + res = tag; + else + return reporter.error('Unknown tag: ' + tag); + + if (res >= 0x1f) + return reporter.error('Multi-octet tag encoding unsupported'); + + if (!primitive) + res |= 0x20; + + res |= (der.tagClassByName[cls || 'universal'] << 6); + + return res; + } + + },{"../base/node":30,"../constants/der":32,"inherits":97,"safer-buffer":123}],38:[function(require,module,exports){ + 'use strict'; + + const encoders = exports; + + encoders.der = require('./der'); + encoders.pem = require('./pem'); + + },{"./der":37,"./pem":39}],39:[function(require,module,exports){ + 'use strict'; + + const inherits = require('inherits'); + + const DEREncoder = require('./der'); + + function PEMEncoder(entity) { + DEREncoder.call(this, entity); + this.enc = 'pem'; + } + inherits(PEMEncoder, DEREncoder); + module.exports = PEMEncoder; + + PEMEncoder.prototype.encode = function encode(data, options) { + const buf = DEREncoder.prototype.encode.call(this, data); + + const p = buf.toString('base64'); + const out = [ '-----BEGIN ' + options.label + '-----' ]; + for (let i = 0; i < p.length; i += 64) + out.push(p.slice(i, i + 64)); + out.push('-----END ' + options.label + '-----'); + return out.join('\n'); + }; + + },{"./der":37,"inherits":97}],40:[function(require,module,exports){ + 'use strict' + // base-x encoding / decoding + // Copyright (c) 2018 base-x contributors + // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) + // Distributed under the MIT software license, see the accompanying + // file LICENSE or http://www.opensource.org/licenses/mit-license.php. + // @ts-ignore + var _Buffer = require('safe-buffer').Buffer + function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } + BASE_MAP[xc] = i + } + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up + function encode (source) { + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. + while (pbegin !== pend) { + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + pbegin++ + } + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ + } + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } + return str + } + function decodeUnsafe (source) { + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return _Buffer.alloc(0) } + var psz = 0 + // Skip leading spaces. + if (source[psz] === ' ') { return } + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 + while (source[psz] === LEADER) { + zeroes++ + psz++ + } + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. + while (source[psz]) { + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + psz++ + } + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ + } + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) + vch.fill(0x00, 0, zeroes) + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] + } + return vch + } + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } + throw new Error('Non-base' + BASE + ' character') + } + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } + } + module.exports = base + + },{"safe-buffer":122}],41:[function(require,module,exports){ + // Blake2B in pure Javascript + // Adapted from the reference implementation in RFC7693 + // Ported to Javascript by DC - https://github.com/dcposch + + var util = require('./util') + + // 64-bit unsigned addition + // Sets v[a,a+1] += v[b,b+1] + // v should be a Uint32Array + function ADD64AA (v, a, b) { + var o0 = v[a] + v[b] + var o1 = v[a + 1] + v[b + 1] + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 + } + + // 64-bit unsigned addition + // Sets v[a,a+1] += b + // b0 is the low 32 bits of b, b1 represents the high 32 bits + function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0 + if (b0 < 0) { + o0 += 0x100000000 + } + var o1 = v[a + 1] + b1 + if (o0 >= 0x100000000) { + o1++ + } + v[a] = o0 + v[a + 1] = o1 + } + + // Little-endian byte access + function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) + } + + // G Mixing function + // The ROTRs are inlined for speed + function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix] + var x1 = m[ix + 1] + var y0 = m[iy] + var y1 = m[iy + 1] + + ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a] + var xor1 = v[d + 1] ^ v[a + 1] + v[d] = xor1 + v[d + 1] = xor0 + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor0 >>> 24) ^ (xor1 << 8) + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) + + ADD64AA(v, a, b) + ADD64AC(v, a, y0, y1) + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a] + xor1 = v[d + 1] ^ v[a + 1] + v[d] = (xor0 >>> 16) ^ (xor1 << 16) + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) + + ADD64AA(v, c, d) + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c] + xor1 = v[b + 1] ^ v[c + 1] + v[b] = (xor1 >>> 31) ^ (xor0 << 1) + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) + } + + // Initialization Vector + var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 + ]) + + var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 + ] + + // These are offsets into a uint64 buffer. + // Multiply them all by 2 to make them offsets into a uint32 buffer, + // because this is Javascript and we don't have uint64s + var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) + + // Compression function. 'last' flag indicates last block. + // Note we're representing 16 uint64s as 32 uint32s + var v = new Uint32Array(32) + var m = new Uint32Array(32) + function blake2bCompress (ctx, last) { + var i = 0 + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i] + v[i + 16] = BLAKE2B_IV32[i] + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t + v[25] = v[25] ^ (ctx.t / 0x100000000) + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28] + v[29] = ~v[29] + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i) + } + + // twelve rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 64) + for (i = 0; i < 12; i++) { + // util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64) + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) + } + // util.debugPrint(' (i=12) v[16]', v, 64) + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] + } + // util.debugPrint('h[8]', ctx.h, 64) + } + + // Creates a BLAKE2b hashing context + // Requires an output length between 1 and 64 bytes + // Takes an optional Uint8Array key + function blake2bInit (outlen, key) { + if (outlen === 0 || outlen > 64) { + throw new Error('Illegal output length, expected 0 < length <= 64') + } + if (key && key.length > 64) { + throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64') + } + + // state, 'param block' + var ctx = { + b: new Uint8Array(128), + h: new Uint32Array(16), + t: 0, // input count + c: 0, // pointer within buffer + outlen: outlen // output length in bytes + } + + // initialize hash state + for (var i = 0; i < 16; i++) { + ctx.h[i] = BLAKE2B_IV32[i] + } + var keylen = key ? key.length : 0 + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + // key the hash, if applicable + if (key) { + blake2bUpdate(ctx, key) + // at the end + ctx.c = 128 + } + + return ctx + } + + // Updates a BLAKE2b streaming hash + // Requires hash context and Uint8Array (byte array) + function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c // add counters + blake2bCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } + } + + // Completes a BLAKE2b streaming hash + // Returns a Uint8Array containing the message digest + function blake2bFinal (ctx) { + ctx.t += ctx.c // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2bCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) + } + return out + } + + // Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array + // + // Returns a n-byte Uint8Array + // + // Parameters: + // - input - the input bytes, as a string, Buffer or Uint8Array + // - key - optional key Uint8Array, up to 64 bytes + // - outlen - optional output length in bytes, default 64 + function blake2b (input, key, outlen) { + // preprocess inputs + outlen = outlen || 64 + input = util.normalizeInput(input) + + // do the math + var ctx = blake2bInit(outlen, key) + blake2bUpdate(ctx, input) + return blake2bFinal(ctx) + } + + // Computes the BLAKE2B hash of a string or byte array + // + // Returns an n-byte hash in hex, all lowercase + // + // Parameters: + // - input - the input bytes, as a string, Buffer, or Uint8Array + // - key - optional key Uint8Array, up to 64 bytes + // - outlen - optional output length in bytes, default 64 + function blake2bHex (input, key, outlen) { + var output = blake2b(input, key, outlen) + return util.toHex(output) + } + + module.exports = { + blake2b: blake2b, + blake2bHex: blake2bHex, + blake2bInit: blake2bInit, + blake2bUpdate: blake2bUpdate, + blake2bFinal: blake2bFinal + } + + },{"./util":44}],42:[function(require,module,exports){ + // BLAKE2s hash function in pure Javascript + // Adapted from the reference implementation in RFC7693 + // Ported to Javascript by DC - https://github.com/dcposch + + var util = require('./util') + + // Little-endian byte access. + // Expects a Uint8Array and an index + // Returns the little-endian uint32 at v[i..i+3] + function B2S_GET32 (v, i) { + return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24) + } + + // Mixing function G. + function B2S_G (a, b, c, d, x, y) { + v[a] = v[a] + v[b] + x + v[d] = ROTR32(v[d] ^ v[a], 16) + v[c] = v[c] + v[d] + v[b] = ROTR32(v[b] ^ v[c], 12) + v[a] = v[a] + v[b] + y + v[d] = ROTR32(v[d] ^ v[a], 8) + v[c] = v[c] + v[d] + v[b] = ROTR32(v[b] ^ v[c], 7) + } + + // 32-bit right rotation + // x should be a uint32 + // y must be between 1 and 31, inclusive + function ROTR32 (x, y) { + return (x >>> y) ^ (x << (32 - y)) + } + + // Initialization Vector. + var BLAKE2S_IV = new Uint32Array([ + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, + 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19]) + + var SIGMA = new Uint8Array([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]) + + // Compression function. "last" flag indicates last block + var v = new Uint32Array(16) + var m = new Uint32Array(16) + function blake2sCompress (ctx, last) { + var i = 0 + for (i = 0; i < 8; i++) { // init work variables + v[i] = ctx.h[i] + v[i + 8] = BLAKE2S_IV[i] + } + + v[12] ^= ctx.t // low 32 bits of offset + v[13] ^= (ctx.t / 0x100000000) // high 32 bits + if (last) { // last block flag set ? + v[14] = ~v[14] + } + + for (i = 0; i < 16; i++) { // get little-endian words + m[i] = B2S_GET32(ctx.b, 4 * i) + } + + // ten rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + // util.debugPrint(' m[16]', m, 32) + for (i = 0; i < 10; i++) { + // util.debugPrint(' (i=' + i + ') v[16]', v, 32) + B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]) + B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]) + B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]) + B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]) + B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]) + B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]) + B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]) + B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]) + } + // util.debugPrint(' (i=10) v[16]', v, 32) + + for (i = 0; i < 8; i++) { + ctx.h[i] ^= v[i] ^ v[i + 8] + } + // util.debugPrint('h[8]', ctx.h, 32) + } + + // Creates a BLAKE2s hashing context + // Requires an output length between 1 and 32 bytes + // Takes an optional Uint8Array key + function blake2sInit (outlen, key) { + if (!(outlen > 0 && outlen <= 32)) { + throw new Error('Incorrect output length, should be in [1, 32]') + } + var keylen = key ? key.length : 0 + if (key && !(keylen > 0 && keylen <= 32)) { + throw new Error('Incorrect key length, should be in [1, 32]') + } + + var ctx = { + h: new Uint32Array(BLAKE2S_IV), // hash state + b: new Uint32Array(64), // input block + c: 0, // pointer within block + t: 0, // input count + outlen: outlen // output length in bytes + } + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen + + if (keylen > 0) { + blake2sUpdate(ctx, key) + ctx.c = 64 // at the end + } + + return ctx + } + + // Updates a BLAKE2s streaming hash + // Requires hash context and Uint8Array (byte array) + function blake2sUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 64) { // buffer full ? + ctx.t += ctx.c // add counters + blake2sCompress(ctx, false) // compress (not last) + ctx.c = 0 // counter to zero + } + ctx.b[ctx.c++] = input[i] + } + } + + // Completes a BLAKE2s streaming hash + // Returns a Uint8Array containing the message digest + function blake2sFinal (ctx) { + ctx.t += ctx.c // mark last block offset + while (ctx.c < 64) { // fill up with zeros + ctx.b[ctx.c++] = 0 + } + blake2sCompress(ctx, true) // final block flag = 1 + + // little endian convert and store + var out = new Uint8Array(ctx.outlen) + for (var i = 0; i < ctx.outlen; i++) { + out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xFF + } + return out + } + + // Computes the BLAKE2S hash of a string or byte array, and returns a Uint8Array + // + // Returns a n-byte Uint8Array + // + // Parameters: + // - input - the input bytes, as a string, Buffer, or Uint8Array + // - key - optional key Uint8Array, up to 32 bytes + // - outlen - optional output length in bytes, default 64 + function blake2s (input, key, outlen) { + // preprocess inputs + outlen = outlen || 32 + input = util.normalizeInput(input) + + // do the math + var ctx = blake2sInit(outlen, key) + blake2sUpdate(ctx, input) + return blake2sFinal(ctx) + } + + // Computes the BLAKE2S hash of a string or byte array + // + // Returns an n-byte hash in hex, all lowercase + // + // Parameters: + // - input - the input bytes, as a string, Buffer, or Uint8Array + // - key - optional key Uint8Array, up to 32 bytes + // - outlen - optional output length in bytes, default 64 + function blake2sHex (input, key, outlen) { + var output = blake2s(input, key, outlen) + return util.toHex(output) + } + + module.exports = { + blake2s: blake2s, + blake2sHex: blake2sHex, + blake2sInit: blake2sInit, + blake2sUpdate: blake2sUpdate, + blake2sFinal: blake2sFinal + } + + },{"./util":44}],43:[function(require,module,exports){ + var b2b = require('./blake2b') + var b2s = require('./blake2s') + + module.exports = { + blake2b: b2b.blake2b, + blake2bHex: b2b.blake2bHex, + blake2bInit: b2b.blake2bInit, + blake2bUpdate: b2b.blake2bUpdate, + blake2bFinal: b2b.blake2bFinal, + blake2s: b2s.blake2s, + blake2sHex: b2s.blake2sHex, + blake2sInit: b2s.blake2sInit, + blake2sUpdate: b2s.blake2sUpdate, + blake2sFinal: b2s.blake2sFinal + } + + },{"./blake2b":41,"./blake2s":42}],44:[function(require,module,exports){ + (function (Buffer){(function (){ + var ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array' + + // For convenience, let people hash a string, not just a Uint8Array + function normalizeInput (input) { + var ret + if (input instanceof Uint8Array) { + ret = input + } else if (input instanceof Buffer) { + ret = new Uint8Array(input) + } else if (typeof (input) === 'string') { + ret = new Uint8Array(Buffer.from(input, 'utf8')) + } else { + throw new Error(ERROR_MSG_INPUT) + } + return ret + } + + // Converts a Uint8Array to a hexadecimal string + // For example, toHex([255, 0, 255]) returns "ff00ff" + function toHex (bytes) { + return Array.prototype.map.call(bytes, function (n) { + return (n < 16 ? '0' : '') + n.toString(16) + }).join('') + } + + // Converts any value in [0...2^32-1] to an 8-character hex string + function uint32ToHex (val) { + return (0x100000000 + val).toString(16).substring(1) + } + + // For debugging: prints out hash state in the same format as the RFC + // sample computation exactly, so that you can diff + function debugPrint (label, arr, size) { + var msg = '\n' + label + ' = ' + for (var i = 0; i < arr.length; i += 2) { + if (size === 32) { + msg += uint32ToHex(arr[i]).toUpperCase() + msg += ' ' + msg += uint32ToHex(arr[i + 1]).toUpperCase() + } else if (size === 64) { + msg += uint32ToHex(arr[i + 1]).toUpperCase() + msg += uint32ToHex(arr[i]).toUpperCase() + } else throw new Error('Invalid size ' + size) + if (i % 6 === 4) { + msg += '\n' + new Array(label.length + 4).join(' ') + } else if (i < arr.length - 2) { + msg += ' ' + } + } + console.log(msg) + } + + // For performance testing: generates N bytes of input, hashes M times + // Measures and prints MB/second hash performance each time + function testSpeed (hashFn, N, M) { + var startMs = new Date().getTime() + + var input = new Uint8Array(N) + for (var i = 0; i < N; i++) { + input[i] = i % 256 + } + var genMs = new Date().getTime() + console.log('Generated random input in ' + (genMs - startMs) + 'ms') + startMs = genMs + + for (i = 0; i < M; i++) { + var hashHex = hashFn(input) + var hashMs = new Date().getTime() + var ms = hashMs - startMs + startMs = hashMs + console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...') + console.log(Math.round(N / (1 << 20) / (ms / 1000) * 100) / 100 + ' MB PER SECOND') + } + } + + module.exports = { + normalizeInput: normalizeInput, + toHex: toHex, + debugPrint: debugPrint, + testSpeed: testSpeed + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266}],45:[function(require,module,exports){ + (function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } + + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // 'A' - 'F' + if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + // '0' - '9' + } else { + return (c - 48) & 0xf; + } + } + + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + // 24-bits chunks + var off = 0; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } + + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + this.strip(); + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is BN v4 instance + r.strip(); + } else { + // r is BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; + })(typeof module === 'undefined' || module, this); + + },{"buffer":222}],46:[function(require,module,exports){ + var r; + + module.exports = function rand(len) { + if (!r) + r = new Rand(null); + + return r.generate(len); + }; + + function Rand(rand) { + this.rand = rand; + } + module.exports.Rand = Rand; + + Rand.prototype.generate = function generate(len) { + return this._rand(len); + }; + + // Emulate crypto API using randy + Rand.prototype._rand = function _rand(n) { + if (this.rand.getBytes) + return this.rand.getBytes(n); + + var res = new Uint8Array(n); + for (var i = 0; i < res.length; i++) + res[i] = this.rand.getByte(); + return res; + }; + + if (typeof self === 'object') { + if (self.crypto && self.crypto.getRandomValues) { + // Modern browsers + Rand.prototype._rand = function _rand(n) { + var arr = new Uint8Array(n); + self.crypto.getRandomValues(arr); + return arr; + }; + } else if (self.msCrypto && self.msCrypto.getRandomValues) { + // IE + Rand.prototype._rand = function _rand(n) { + var arr = new Uint8Array(n); + self.msCrypto.getRandomValues(arr); + return arr; + }; + + // Safari's WebWorkers do not have `crypto` + } else if (typeof window === 'object') { + // Old junk + Rand.prototype._rand = function() { + throw new Error('Not implemented yet'); + }; + } + } else { + // Node.js or Web worker with no crypto support + try { + var crypto = require('crypto'); + if (typeof crypto.randomBytes !== 'function') + throw new Error('Not supported'); + + Rand.prototype._rand = function _rand(n) { + return crypto.randomBytes(n); + }; + } catch (e) { + } + } + + },{"crypto":222}],47:[function(require,module,exports){ + var basex = require('base-x') + var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' + + module.exports = basex(ALPHABET) + + },{"base-x":40}],48:[function(require,module,exports){ + 'use strict' + + var base58 = require('bs58') + var Buffer = require('safe-buffer').Buffer + + module.exports = function (checksumFn) { + // Encode a buffer as a base58-check encoded string + function encode (payload) { + var checksum = checksumFn(payload) + + return base58.encode(Buffer.concat([ + payload, + checksum + ], payload.length + 4)) + } + + function decodeRaw (buffer) { + var payload = buffer.slice(0, -4) + var checksum = buffer.slice(-4) + var newChecksum = checksumFn(payload) + + if (checksum[0] ^ newChecksum[0] | + checksum[1] ^ newChecksum[1] | + checksum[2] ^ newChecksum[2] | + checksum[3] ^ newChecksum[3]) return + + return payload + } + + // Decode a base58-check encoded string to a buffer, no result if checksum is wrong + function decodeUnsafe (string) { + var buffer = base58.decodeUnsafe(string) + if (!buffer) return + + return decodeRaw(buffer) + } + + function decode (string) { + var buffer = base58.decode(string) + var payload = decodeRaw(buffer, checksumFn) + if (!payload) throw new Error('Invalid checksum') + return payload + } + + return { + encode: encode, + decode: decode, + decodeUnsafe: decodeUnsafe + } + } + + },{"bs58":47,"safe-buffer":122}],49:[function(require,module,exports){ + 'use strict' + + var createHash = require('create-hash') + var bs58checkBase = require('./base') + + // SHA256(SHA256(buffer)) + function sha256x2 (buffer) { + var tmp = createHash('sha256').update(buffer).digest() + return createHash('sha256').update(tmp).digest() + } + + module.exports = bs58checkBase(sha256x2) + + },{"./base":48,"create-hash":51}],50:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + var Transform = require('stream').Transform + var StringDecoder = require('string_decoder').StringDecoder + var inherits = require('inherits') + + function CipherBase (hashMode) { + Transform.call(this) + this.hashMode = typeof hashMode === 'string' + if (this.hashMode) { + this[hashMode] = this._finalOrDigest + } else { + this.final = this._finalOrDigest + } + if (this._final) { + this.__final = this._final + this._final = null + } + this._decoder = null + this._encoding = null + } + inherits(CipherBase, Transform) + + CipherBase.prototype.update = function (data, inputEnc, outputEnc) { + if (typeof data === 'string') { + data = Buffer.from(data, inputEnc) + } + + var outData = this._update(data) + if (this.hashMode) return this + + if (outputEnc) { + outData = this._toString(outData, outputEnc) + } + + return outData + } + + CipherBase.prototype.setAutoPadding = function () {} + CipherBase.prototype.getAuthTag = function () { + throw new Error('trying to get auth tag in unsupported state') + } + + CipherBase.prototype.setAuthTag = function () { + throw new Error('trying to set auth tag in unsupported state') + } + + CipherBase.prototype.setAAD = function () { + throw new Error('trying to set aad in unsupported state') + } + + CipherBase.prototype._transform = function (data, _, next) { + var err + try { + if (this.hashMode) { + this._update(data) + } else { + this.push(this._update(data)) + } + } catch (e) { + err = e + } finally { + next(err) + } + } + CipherBase.prototype._flush = function (done) { + var err + try { + this.push(this.__final()) + } catch (e) { + err = e + } + + done(err) + } + CipherBase.prototype._finalOrDigest = function (outputEnc) { + var outData = this.__final() || Buffer.alloc(0) + if (outputEnc) { + outData = this._toString(outData, outputEnc, true) + } + return outData + } + + CipherBase.prototype._toString = function (value, enc, fin) { + if (!this._decoder) { + this._decoder = new StringDecoder(enc) + this._encoding = enc + } + + if (this._encoding !== enc) throw new Error('can\'t switch encodings') + + var out = this._decoder.write(value) + if (fin) { + out += this._decoder.end() + } + + return out + } + + module.exports = CipherBase + + },{"inherits":97,"safe-buffer":122,"stream":374,"string_decoder":389}],51:[function(require,module,exports){ + 'use strict' + var inherits = require('inherits') + var MD5 = require('md5.js') + var RIPEMD160 = require('ripemd160') + var sha = require('sha.js') + var Base = require('cipher-base') + + function Hash (hash) { + Base.call(this, 'digest') + + this._hash = hash + } + + inherits(Hash, Base) + + Hash.prototype._update = function (data) { + this._hash.update(data) + } + + Hash.prototype._final = function () { + return this._hash.digest() + } + + module.exports = function createHash (alg) { + alg = alg.toLowerCase() + if (alg === 'md5') return new MD5() + if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160() + + return new Hash(sha(alg)) + } + + },{"cipher-base":50,"inherits":97,"md5.js":102,"ripemd160":121,"sha.js":128}],52:[function(require,module,exports){ + var MD5 = require('md5.js') + + module.exports = function (buffer) { + return new MD5().update(buffer).digest() + } + + },{"md5.js":102}],53:[function(require,module,exports){ + 'use strict' + var inherits = require('inherits') + var Legacy = require('./legacy') + var Base = require('cipher-base') + var Buffer = require('safe-buffer').Buffer + var md5 = require('create-hash/md5') + var RIPEMD160 = require('ripemd160') + + var sha = require('sha.js') + + var ZEROS = Buffer.alloc(128) + + function Hmac (alg, key) { + Base.call(this, 'digest') + if (typeof key === 'string') { + key = Buffer.from(key) + } + + var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 + + this._alg = alg + this._key = key + if (key.length > blocksize) { + var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) + key = hash.update(key).digest() + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) + var opad = this._opad = Buffer.allocUnsafe(blocksize) + + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) + this._hash.update(ipad) + } + + inherits(Hmac, Base) + + Hmac.prototype._update = function (data) { + this._hash.update(data) + } + + Hmac.prototype._final = function () { + var h = this._hash.digest() + var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg) + return hash.update(this._opad).update(h).digest() + } + + module.exports = function createHmac (alg, key) { + alg = alg.toLowerCase() + if (alg === 'rmd160' || alg === 'ripemd160') { + return new Hmac('rmd160', key) + } + if (alg === 'md5') { + return new Legacy(md5, key) + } + return new Hmac(alg, key) + } + + },{"./legacy":54,"cipher-base":50,"create-hash/md5":52,"inherits":97,"ripemd160":121,"safe-buffer":122,"sha.js":128}],54:[function(require,module,exports){ + 'use strict' + var inherits = require('inherits') + var Buffer = require('safe-buffer').Buffer + + var Base = require('cipher-base') + + var ZEROS = Buffer.alloc(128) + var blocksize = 64 + + function Hmac (alg, key) { + Base.call(this, 'digest') + if (typeof key === 'string') { + key = Buffer.from(key) + } + + this._alg = alg + this._key = key + + if (key.length > blocksize) { + key = alg(key) + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) + var opad = this._opad = Buffer.allocUnsafe(blocksize) + + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + + this._hash = [ipad] + } + + inherits(Hmac, Base) + + Hmac.prototype._update = function (data) { + this._hash.push(data) + } + + Hmac.prototype._final = function () { + var h = this._alg(Buffer.concat(this._hash)) + return this._alg(Buffer.concat([this._opad, h])) + } + module.exports = Hmac + + },{"cipher-base":50,"inherits":97,"safe-buffer":122}],55:[function(require,module,exports){ + (function (global,Buffer){(function (){ + "use strict"; + + var EC = require("elliptic").ec; + + var ec = new EC("secp256k1"); + var browserCrypto = global.crypto || global.msCrypto || {}; + var subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; + + var nodeCrypto = require('crypto'); + + const EC_GROUP_ORDER = Buffer.from('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 'hex'); + const ZERO32 = Buffer.alloc(32, 0); + + function assert(condition, message) { + if (!condition) { + throw new Error(message || "Assertion failed"); + } + } + + function isScalar (x) { + return Buffer.isBuffer(x) && x.length === 32; + } + + function isValidPrivateKey(privateKey) { + if (!isScalar(privateKey)) + { + return false; + } + return privateKey.compare(ZERO32) > 0 && // > 0 + privateKey.compare(EC_GROUP_ORDER) < 0; // < G + } + + // Compare two buffers in constant time to prevent timing attacks. + function equalConstTime(b1, b2) { + if (b1.length !== b2.length) { + return false; + } + var res = 0; + for (var i = 0; i < b1.length; i++) { + res |= b1[i] ^ b2[i]; // jshint ignore:line + } + return res === 0; + } + + /* This must check if we're in the browser or + not, since the functions are different and does + not convert using browserify */ + function randomBytes(size) { + var arr = new Uint8Array(size); + if (typeof browserCrypto.getRandomValues === 'undefined') { + return Buffer.from(nodeCrypto.randomBytes(size)); + } else { + browserCrypto.getRandomValues(arr); + } + return Buffer.from(arr); + } + + function sha512(msg) { + return new Promise(function(resolve) { + var hash = nodeCrypto.createHash('sha512'); + var result = hash.update(msg).digest(); + resolve(new Uint8Array(result)); + }); + } + + function getAes(op) { + return function(iv, key, data) { + return new Promise(function(resolve) { + if (subtle) { + var importAlgorithm = {name: "AES-CBC"}; + var keyp = subtle.importKey("raw", key, importAlgorithm, false, [op]); + return keyp.then(function(cryptoKey) { + var encAlgorithm = {name: "AES-CBC", iv: iv}; + return subtle[op](encAlgorithm, cryptoKey, data); + }).then(function(result) { + resolve(Buffer.from(new Uint8Array(result))); + }); + } else { + if (op === 'encrypt') { + var cipher = nodeCrypto.createCipheriv('aes-256-cbc', key, iv); + let firstChunk = cipher.update(data); + let secondChunk = cipher.final(); + resolve(Buffer.concat([firstChunk, secondChunk])); + } + else if (op === 'decrypt') { + var decipher = nodeCrypto.createDecipheriv('aes-256-cbc', key, iv); + let firstChunk = decipher.update(data); + let secondChunk = decipher.final(); + resolve(Buffer.concat([firstChunk, secondChunk])); + } + } + }); + }; + } + + var aesCbcEncrypt = getAes("encrypt"); + var aesCbcDecrypt = getAes("decrypt"); + + function hmacSha256Sign(key, msg) { + return new Promise(function(resolve) { + var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key)); + hmac.update(msg); + var result = hmac.digest(); + resolve(result); + }); + } + + function hmacSha256Verify(key, msg, sig) { + return new Promise(function(resolve) { + var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key)); + hmac.update(msg); + var expectedSig = hmac.digest(); + resolve(equalConstTime(expectedSig, sig)); + }); + } + + /** + * Generate a new valid private key. Will use the window.crypto or window.msCrypto as source + * depending on your browser. + * @return {Buffer} A 32-byte private key. + * @function + */ + exports.generatePrivate = function () { + var privateKey = randomBytes(32); + while (!isValidPrivateKey(privateKey)) { + privateKey = randomBytes(32); + } + return privateKey; + }; + + var getPublic = exports.getPublic = function(privateKey) { + // This function has sync API so we throw an error immediately. + assert(privateKey.length === 32, "Bad private key"); + assert(isValidPrivateKey(privateKey), "Bad private key"); + // XXX(Kagami): `elliptic.utils.encode` returns array for every + // encoding except `hex`. + return Buffer.from(ec.keyFromPrivate(privateKey).getPublic("arr")); + }; + + /** + * Get compressed version of public key. + */ + var getPublicCompressed = exports.getPublicCompressed = function(privateKey) { // jshint ignore:line + assert(privateKey.length === 32, "Bad private key"); + assert(isValidPrivateKey(privateKey), "Bad private key"); + // See https://github.com/wanderer/secp256k1-node/issues/46 + let compressed = true; + return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, "arr")); + }; + + // NOTE(Kagami): We don't use promise shim in Browser implementation + // because it's supported natively in new browsers (see + // ) and we can use only new browsers + // because of the WebCryptoAPI (see + // ). + exports.sign = function(privateKey, msg) { + return new Promise(function(resolve) { + assert(privateKey.length === 32, "Bad private key"); + assert(isValidPrivateKey(privateKey), "Bad private key"); + assert(msg.length > 0, "Message should not be empty"); + assert(msg.length <= 32, "Message is too long"); + resolve(Buffer.from(ec.sign(msg, privateKey, {canonical: true}).toDER())); + }); + }; + + exports.verify = function(publicKey, msg, sig) { + return new Promise(function(resolve, reject) { + assert(publicKey.length === 65 || publicKey.length === 33, "Bad public key"); + if (publicKey.length === 65) + { + assert(publicKey[0] === 4, "Bad public key"); + } + if (publicKey.length === 33) + { + assert(publicKey[0] === 2 || publicKey[0] === 3, "Bad public key"); + } + assert(msg.length > 0, "Message should not be empty"); + assert(msg.length <= 32, "Message is too long"); + if (ec.verify(msg, sig, publicKey)) { + resolve(null); + } else { + reject(new Error("Bad signature")); + } + }); + }; + + var derive = exports.derive = function(privateKeyA, publicKeyB) { + return new Promise(function(resolve) { + assert(Buffer.isBuffer(privateKeyA), "Bad private key"); + assert(Buffer.isBuffer(publicKeyB), "Bad public key"); + assert(privateKeyA.length === 32, "Bad private key"); + assert(isValidPrivateKey(privateKeyA), "Bad private key"); + assert(publicKeyB.length === 65 || publicKeyB.length === 33, "Bad public key"); + if (publicKeyB.length === 65) + { + assert(publicKeyB[0] === 4, "Bad public key"); + } + if (publicKeyB.length === 33) + { + assert(publicKeyB[0] === 2 || publicKeyB[0] === 3, "Bad public key"); + } + var keyA = ec.keyFromPrivate(privateKeyA); + var keyB = ec.keyFromPublic(publicKeyB); + var Px = keyA.derive(keyB.getPublic()); // BN instance + resolve(Buffer.from(Px.toArray())); + }); + }; + + exports.encrypt = function(publicKeyTo, msg, opts) { + opts = opts || {}; + // Tmp variables to save context from flat promises; + var iv, ephemPublicKey, ciphertext, macKey; + return new Promise(function(resolve) { + var ephemPrivateKey = opts.ephemPrivateKey || randomBytes(32); + // There is a very unlikely possibility that it is not a valid key + while(!isValidPrivateKey(ephemPrivateKey)) + { + ephemPrivateKey = opts.ephemPrivateKey || randomBytes(32); + } + ephemPublicKey = getPublic(ephemPrivateKey); + resolve(derive(ephemPrivateKey, publicKeyTo)); + }).then(function(Px) { + return sha512(Px); + }).then(function(hash) { + iv = opts.iv || randomBytes(16); + var encryptionKey = hash.slice(0, 32); + macKey = hash.slice(32); + return aesCbcEncrypt(iv, encryptionKey, msg); + }).then(function(data) { + ciphertext = data; + var dataToMac = Buffer.concat([iv, ephemPublicKey, ciphertext]); + return hmacSha256Sign(macKey, dataToMac); + }).then(function(mac) { + return { + iv: iv, + ephemPublicKey: ephemPublicKey, + ciphertext: ciphertext, + mac: mac, + }; + }); + }; + + exports.decrypt = function(privateKey, opts) { + // Tmp variable to save context from flat promises; + var encryptionKey; + return derive(privateKey, opts.ephemPublicKey).then(function(Px) { + return sha512(Px); + }).then(function(hash) { + encryptionKey = hash.slice(0, 32); + var macKey = hash.slice(32); + var dataToMac = Buffer.concat([ + opts.iv, + opts.ephemPublicKey, + opts.ciphertext + ]); + return hmacSha256Verify(macKey, dataToMac, opts.mac); + }).then(function(macGood) { + assert(macGood, "Bad MAC"); + return aesCbcDecrypt(opts.iv, encryptionKey, opts.ciphertext); + }).then(function(msg) { + return Buffer.from(new Uint8Array(msg)); + }); + }; + + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) + },{"buffer":266,"crypto":274,"elliptic":56}],56:[function(require,module,exports){ + 'use strict'; + + var elliptic = exports; + + elliptic.version = require('../package.json').version; + elliptic.utils = require('./elliptic/utils'); + elliptic.rand = require('brorand'); + elliptic.curve = require('./elliptic/curve'); + elliptic.curves = require('./elliptic/curves'); + + // Protocols + elliptic.ec = require('./elliptic/ec'); + elliptic.eddsa = require('./elliptic/eddsa'); + + },{"../package.json":71,"./elliptic/curve":59,"./elliptic/curves":62,"./elliptic/ec":63,"./elliptic/eddsa":66,"./elliptic/utils":70,"brorand":46}],57:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + var utils = require('../utils'); + var getNAF = utils.getNAF; + var getJSF = utils.getJSF; + var assert = utils.assert; + + function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + + this._bitLength = this.n ? this.n.bitLength() : 0; + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } + } + module.exports = BaseCurve; + + BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); + }; + + BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); + }; + + BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + var j; + var nafW; + for (j = 0; j < naf.length; j += doubles.step) { + nafW = 0; + for (var l = j + doubles.step - 1; l >= j; l--) + nafW = (nafW << 1) + naf[l]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (j = 0; j < repr.length; j++) { + nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); + }; + + BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w, this._bitLength); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var l = 0; i >= 0 && naf[i] === 0; i--) + l++; + if (i >= 0) + l++; + acc = acc.dblp(l); + + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; + }; + + BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + var i; + var j; + var p; + for (i = 0; i < len; i++) { + p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); + naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3, /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (j = 0; j < len; j++) { + var z = tmp[j]; + p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); + }; + + function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; + } + BaseCurve.BasePoint = BasePoint; + + BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); + }; + + BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); + }; + + BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); + }; + + BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); + }; + + BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); + }; + + BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); + }; + + BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null, + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; + }; + + BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); + }; + + BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles, + }; + }; + + BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res, + }; + }; + + BasePoint.prototype._getBeta = function _getBeta() { + return null; + }; + + BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; + }; + + },{"../utils":70,"bn.js":45}],58:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var BN = require('bn.js'); + var inherits = require('inherits'); + var Base = require('./base'); + + var assert = utils.assert; + + function EdwardsCurve(conf) { + // NOTE: Important as we are creating point in Base.call() + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; + + Base.call(this, 'edwards', conf); + + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; + } + inherits(EdwardsCurve, Base); + module.exports = EdwardsCurve; + + EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); + }; + + EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); + }; + + // Just for compatibility with Short curve + EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); + }; + + EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var x2 = x.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x2)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); + + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); + }; + + EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); + + // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) + var y2 = y.redSqr(); + var lhs = y2.redSub(this.c2); + var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); + var x2 = lhs.redMul(rhs.redInvm()); + + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } + + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); + + return this.point(x, y); + }; + + EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; + + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); + + var x2 = point.x.redSqr(); + var y2 = point.y.redSqr(); + var lhs = x2.redMul(this.a).redAdd(y2); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); + + return lhs.cmp(rhs) === 0; + }; + + function Point(curve, x, y, z, t) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && y === null && z === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = z ? new BN(z, 16) : this.curve.one; + this.t = t && new BN(t, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + + // Use extended coordinates + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); + } + } + } + inherits(Point, Base.BasePoint); + + EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); + }; + + EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); + }; + + Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); + }; + + Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.x.cmpn(0) === 0 && + (this.y.cmp(this.z) === 0 || + (this.zOne && this.y.cmp(this.curve.c) === 0)); + }; + + Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = 2 * Z1^2 + var c = this.z.redSqr(); + c = c.redIAdd(c); + // D = a * A + var d = this.curve._mulA(a); + // E = (X1 + Y1)^2 - A - B + var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); + // G = D + B + var g = d.redAdd(b); + // F = G - C + var f = g.redSub(c); + // H = D - B + var h = d.redSub(b); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); + }; + + Point.prototype._projDbl = function _projDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #doubling-dbl-2008-bbjlp + // #doubling-dbl-2007-bl + // and others + // Generally 3M + 4S or 2M + 4S + + // B = (X1 + Y1)^2 + var b = this.x.redAdd(this.y).redSqr(); + // C = X1^2 + var c = this.x.redSqr(); + // D = Y1^2 + var d = this.y.redSqr(); + + var nx; + var ny; + var nz; + var e; + var h; + var j; + if (this.curve.twisted) { + // E = a * C + e = this.curve._mulA(c); + // F = E + D + var f = e.redAdd(d); + if (this.zOne) { + // X3 = (B - C - D) * (F - 2) + nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F^2 - 2 * F + nz = f.redSqr().redSub(f).redSub(f); + } else { + // H = Z1^2 + h = this.z.redSqr(); + // J = F - 2 * H + j = f.redSub(h).redISub(h); + // X3 = (B-C-D)*J + nx = b.redSub(c).redISub(d).redMul(j); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F * J + nz = f.redMul(j); + } + } else { + // E = C + D + e = c.redAdd(d); + // H = (c * Z1)^2 + h = this.curve._mulC(this.z).redSqr(); + // J = E - 2 * H + j = e.redSub(h).redSub(h); + // X3 = c * (B - E) * J + nx = this.curve._mulC(b.redISub(e)).redMul(j); + // Y3 = c * E * (C - D) + ny = this.curve._mulC(e).redMul(c.redISub(d)); + // Z3 = E * J + nz = e.redMul(j); + } + return this.curve.point(nx, ny, nz); + }; + + Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); + }; + + Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M + + // A = (Y1 - X1) * (Y2 - X2) + var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); + // B = (Y1 + X1) * (Y2 + X2) + var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); + // C = T1 * k * T2 + var c = this.t.redMul(this.curve.dd).redMul(p.t); + // D = Z1 * 2 * Z2 + var d = this.z.redMul(p.z.redAdd(p.z)); + // E = B - A + var e = b.redSub(a); + // F = D - C + var f = d.redSub(c); + // G = D + C + var g = d.redAdd(c); + // H = B + A + var h = b.redAdd(a); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); + }; + + Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S + + // A = Z1 * Z2 + var a = this.z.redMul(p.z); + // B = A^2 + var b = a.redSqr(); + // C = X1 * X2 + var c = this.x.redMul(p.x); + // D = Y1 * Y2 + var d = this.y.redMul(p.y); + // E = d * C * D + var e = this.curve.d.redMul(c).redMul(d); + // F = B - E + var f = b.redSub(e); + // G = B + E + var g = b.redAdd(e); + // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) + var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); + var nx = a.redMul(f).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + // Y3 = A * G * (D - a * C) + ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); + // Z3 = F * G + nz = f.redMul(g); + } else { + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); + } + return this.curve.point(nx, ny, nz); + }; + + Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; + + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); + }; + + Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); + }; + + Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); + }; + + Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); + }; + + Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; + + // Normalize coordinates + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; + }; + + Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); + }; + + Point.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); + }; + + Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); + }; + + Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; + }; + + Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(this.z); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } + }; + + // Compatibility with BaseCurve + Point.prototype.toP = Point.prototype.normalize; + Point.prototype.mixedAdd = Point.prototype.add; + + },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],59:[function(require,module,exports){ + 'use strict'; + + var curve = exports; + + curve.base = require('./base'); + curve.short = require('./short'); + curve.mont = require('./mont'); + curve.edwards = require('./edwards'); + + },{"./base":57,"./edwards":58,"./mont":60,"./short":61}],60:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + var inherits = require('inherits'); + var Base = require('./base'); + + var utils = require('../utils'); + + function MontCurve(conf) { + Base.call(this, 'mont', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + inherits(MontCurve, Base); + module.exports = MontCurve; + + MontCurve.prototype.validate = function validate(point) { + var x = point.normalize().x; + var x2 = x.redSqr(); + var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); + var y = rhs.redSqrt(); + + return y.redSqr().cmp(rhs) === 0; + }; + + function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x, 16); + this.z = new BN(z, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + } + } + inherits(Point, Base.BasePoint); + + MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); + }; + + MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); + }; + + MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); + }; + + Point.prototype.precompute = function precompute() { + // No-op + }; + + Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); + }; + + Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); + }; + + Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; + }; + + Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A + + // A = X1 + Z1 + var a = this.x.redAdd(this.z); + // AA = A^2 + var aa = a.redSqr(); + // B = X1 - Z1 + var b = this.x.redSub(this.z); + // BB = B^2 + var bb = b.redSqr(); + // C = AA - BB + var c = aa.redSub(bb); + // X3 = AA * BB + var nx = aa.redMul(bb); + // Z3 = C * (BB + A24 * C) + var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); + return this.curve.point(nx, nz); + }; + + Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); + }; + + Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A + + // A = X2 + Z2 + var a = this.x.redAdd(this.z); + // B = X2 - Z2 + var b = this.x.redSub(this.z); + // C = X3 + Z3 + var c = p.x.redAdd(p.z); + // D = X3 - Z3 + var d = p.x.redSub(p.z); + // DA = D * A + var da = d.redMul(a); + // CB = C * B + var cb = c.redMul(b); + // X5 = Z1 * (DA + CB)^2 + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + // Z5 = X1 * (DA - CB)^2 + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); + }; + + Point.prototype.mul = function mul(k) { + var t = k.clone(); + var a = this; // (N / 2) * Q + Q + var b = this.curve.point(null, null); // (N / 2) * Q + var c = this; // Q + + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); + + for (var i = bits.length - 1; i >= 0; i--) { + if (bits[i] === 0) { + // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q + a = a.diffAdd(b, c); + // N * Q = 2 * ((N / 2) * Q + Q)) + b = b.dbl(); + } else { + // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) + b = a.diffAdd(b, c); + // N * Q + Q = 2 * ((N / 2) * Q + Q) + a = a.dbl(); + } + } + return b; + }; + + Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); + }; + + Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); + }; + + Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; + }; + + Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; + }; + + Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); + + return this.x.fromRed(); + }; + + },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],61:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var BN = require('bn.js'); + var inherits = require('inherits'); + var Base = require('./base'); + + var assert = utils.assert; + + function ShortCurve(conf) { + Base.call(this, 'short', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); + } + inherits(ShortCurve, Base); + module.exports = ShortCurve; + + ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16), + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis, + }; + }; + + ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; + }; + + ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; + }; + + ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; + }; + + ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); + }; + + ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; + }; + + ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + + function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } + } + inherits(Point, Base.BasePoint); + + ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); + }; + + ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); + }; + + Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul), + }, + }; + } + return beta; + }; + + Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1), + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1), + }, + } ]; + }; + + Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), + }, + }; + return res; + }; + + Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + Point.prototype.isInfinity = function isInfinity() { + return this.inf; + }; + + Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + + Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + + Point.prototype.getX = function getX() { + return this.x.fromRed(); + }; + + Point.prototype.getY = function getY() { + return this.y.fromRed(); + }; + + Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); + }; + + Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); + }; + + Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); + }; + + Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); + }; + + Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate), + }, + }; + } + return res; + }; + + Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; + }; + + function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + + this.zOne = this.z === this.curve.one; + } + inherits(JPoint, Base.BasePoint); + + ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); + }; + + JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); + }; + + JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }; + + JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + }; + + JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); + }; + + JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); + + return this.curve._wnafMul(this, k); + }; + + JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; + }; + + JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } + }; + + JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; + }; + + },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],62:[function(require,module,exports){ + 'use strict'; + + var curves = exports; + + var hash = require('hash.js'); + var curve = require('./curve'); + var utils = require('./utils'); + + var assert = utils.assert; + + function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve.short(options); + else if (options.type === 'edwards') + this.curve = new curve.edwards(options); + else + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); + } + curves.PresetCurve = PresetCurve; + + function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve, + }); + return curve; + }, + }); + } + + defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811', + ], + }); + + defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34', + ], + }); + + defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5', + ], + }); + + defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f', + ], + }); + + defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650', + ], + }); + + defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '9', + ], + }); + + defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', + + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], + }); + + var pre; + try { + pre = require('./precomputed/secp256k1'); + } catch (e) { + pre = undefined; + } + + defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash.sha256, + + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], + }); + + },{"./curve":59,"./precomputed/secp256k1":69,"./utils":70,"hash.js":83}],63:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + var HmacDRBG = require('hmac-drbg'); + var utils = require('../utils'); + var curves = require('../curves'); + var rand = require('brorand'); + var assert = utils.assert; + + var KeyPair = require('./key'); + var Signature = require('./signature'); + + function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); + + options = curves[options]; + } + + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; + + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; + } + module.exports = EC; + + EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); + }; + + EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); + }; + + EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); + }; + + EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray(), + }); + + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (;;) { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; + + priv.iaddn(1); + return this.keyFromPrivate(priv); + } + }; + + EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; + }; + + EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; + + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); + + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); + + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); + + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); + + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); + + for (var iter = 0; ; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; + + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; + + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; + + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; + + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } + + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + } + }; + + EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); + + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; + + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + var p; + + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + return p.getX().umod(this.n).cmp(r) === 0; + } + + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K + + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); + }; + + EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); + + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; + + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); + + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); + + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); + + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); + }; + + EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; + + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; + } + + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); + }; + + },{"../curves":62,"../utils":70,"./key":64,"./signature":65,"bn.js":45,"brorand":46,"hmac-drbg":95}],64:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + var utils = require('../utils'); + var assert = utils.assert; + + function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); + } + module.exports = KeyPair; + + KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); + }; + + KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); + }; + + KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); + + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; + + return { result: true, reason: null }; + }; + + KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); + }; + + KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; + }; + + KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); + + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); + }; + + KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); + }; + + // ECDH + KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); + }; + + // ECDSA + KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); + }; + + KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); + }; + + KeyPair.prototype.inspect = function inspect() { + return ''; + }; + + },{"../utils":70,"bn.js":45}],65:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + + var utils = require('../utils'); + var assert = utils.assert; + + function Signature(options, enc) { + if (options instanceof Signature) + return options; + + if (this._importDER(options, enc)) + return; + + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; + } + module.exports = Signature; + + function Position() { + this.place = 0; + } + + function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; + + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } + + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } + + // Leading zeroes + if (val <= 0x7f) { + return false; + } + + p.place = off; + return val; + } + + function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; + } + if (i === 0) { + return buf; + } + return buf.slice(i); + } + + Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if (len === false) { + return false; + } + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + if (rlen === false) { + return false; + } + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (slen === false) { + return false; + } + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0) { + if (r[1] & 0x80) { + r = r.slice(1); + } else { + // Leading zeroes + return false; + } + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } + + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; + }; + + function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); + } + + Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); + }; + + },{"../utils":70,"bn.js":45}],66:[function(require,module,exports){ + 'use strict'; + + var hash = require('hash.js'); + var curves = require('../curves'); + var utils = require('../utils'); + var assert = utils.assert; + var parseBytes = utils.parseBytes; + var KeyPair = require('./key'); + var Signature = require('./signature'); + + function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); + + if (!(this instanceof EDDSA)) + return new EDDSA(curve); + + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); + + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; + } + + module.exports = EDDSA; + + /** + * @param {Array|String} message - message bytes + * @param {Array|String|KeyPair} secret - secret bytes or a keypair + * @returns {Signature} - signature + */ + EDDSA.prototype.sign = function sign(message, secret) { + message = parseBytes(message); + var key = this.keyFromSecret(secret); + var r = this.hashInt(key.messagePrefix(), message); + var R = this.g.mul(r); + var Rencoded = this.encodePoint(R); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message) + .mul(key.priv()); + var S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); + }; + + /** + * @param {Array} message - message bytes + * @param {Array|String|Signature} sig - sig bytes + * @param {Array|String|Point|KeyPair} pub - public key + * @returns {Boolean} - true if public key matches sig of message + */ + EDDSA.prototype.verify = function verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); + }; + + EDDSA.prototype.hashInt = function hashInt() { + var hash = this.hash(); + for (var i = 0; i < arguments.length; i++) + hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); + }; + + EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); + }; + + EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); + }; + + EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); + }; + + /** + * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 + * + * EDDSA defines methods for encoding and decoding points and integers. These are + * helper convenience methods, that pass along to utility functions implied + * parameters. + * + */ + EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray('le', this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; + }; + + EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); + + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); + }; + + EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); + }; + + EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); + }; + + EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; + }; + + },{"../curves":62,"../utils":70,"./key":67,"./signature":68,"hash.js":83}],67:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var assert = utils.assert; + var parseBytes = utils.parseBytes; + var cachedProperty = utils.cachedProperty; + + /** + * @param {EDDSA} eddsa - instance + * @param {Object} params - public/private key parameters + * + * @param {Array} [params.secret] - secret seed bytes + * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) + * @param {Array} [params.pub] - public key point encoded as bytes + * + */ + function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; + else + this._pubBytes = parseBytes(params.pub); + } + + KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); + }; + + KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); + }; + + KeyPair.prototype.secret = function secret() { + return this._secret; + }; + + cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); + }); + + cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); + }); + + cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; + + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; + + return a; + }); + + cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); + }); + + cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); + }); + + cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); + }); + + KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); + }; + + KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); + }; + + KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); + }; + + KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); + }; + + module.exports = KeyPair; + + },{"../utils":70}],68:[function(require,module,exports){ + 'use strict'; + + var BN = require('bn.js'); + var utils = require('../utils'); + var assert = utils.assert; + var cachedProperty = utils.cachedProperty; + var parseBytes = utils.parseBytes; + + /** + * @param {EDDSA} eddsa - eddsa instance + * @param {Array|Object} sig - + * @param {Array|Point} [sig.R] - R point as Point or bytes + * @param {Array|bn} [sig.S] - S scalar as bn or bytes + * @param {Array} [sig.Rencoded] - R point encoded + * @param {Array} [sig.Sencoded] - S scalar encoded + */ + function Signature(eddsa, sig) { + this.eddsa = eddsa; + + if (typeof sig !== 'object') + sig = parseBytes(sig); + + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } + + assert(sig.R && sig.S, 'Signature without R or S'); + + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; + + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; + } + + cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); + }); + + cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); + }); + + cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); + }); + + cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); + }); + + Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); + }; + + Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); + }; + + module.exports = Signature; + + },{"../utils":70,"bn.js":45}],69:[function(require,module,exports){ + module.exports = { + doubles: { + step: 4, + points: [ + [ + 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', + 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', + ], + [ + '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', + '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', + ], + [ + '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', + 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', + ], + [ + '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', + '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', + ], + [ + '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', + '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', + ], + [ + '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', + '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', + ], + [ + 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', + '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', + ], + [ + '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', + 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', + ], + [ + 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', + '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', + ], + [ + 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', + 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', + ], + [ + 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', + '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', + ], + [ + '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', + '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', + ], + [ + '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', + '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', + ], + [ + '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', + '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', + ], + [ + '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', + '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', + ], + [ + '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', + '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', + ], + [ + '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', + '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', + ], + [ + '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', + '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', + ], + [ + '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', + 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', + ], + [ + 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', + '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', + ], + [ + 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', + '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', + ], + [ + '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', + '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', + ], + [ + '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', + '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', + ], + [ + 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', + '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', + ], + [ + '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', + 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', + ], + [ + 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', + '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', + ], + [ + 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', + 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', + ], + [ + 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', + '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', + ], + [ + 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', + 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', + ], + [ + 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', + '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', + ], + [ + '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', + 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', + ], + [ + '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', + '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', + ], + [ + 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', + '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', + ], + [ + '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', + 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', + ], + [ + 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', + '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', + ], + [ + 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', + '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', + ], + [ + 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', + 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', + ], + [ + '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', + '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', + ], + [ + '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', + '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', + ], + [ + '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', + 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', + ], + [ + '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', + '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', + ], + [ + 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', + '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', + ], + [ + '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', + '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', + ], + [ + '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', + 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', + ], + [ + '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', + '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', + ], + [ + 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', + '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', + ], + [ + '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', + 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', + ], + [ + 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', + 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', + ], + [ + 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', + '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', + ], + [ + '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', + 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', + ], + [ + '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', + 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', + ], + [ + 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', + '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', + ], + [ + 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', + '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', + ], + [ + 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', + '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', + ], + [ + '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', + 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', + ], + [ + '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', + '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', + ], + [ + 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', + 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', + ], + [ + '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', + 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', + ], + [ + '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', + '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', + ], + [ + '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', + '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', + ], + [ + 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', + 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', + ], + [ + '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', + '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', + ], + [ + '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', + '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', + ], + [ + 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', + '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', + ], + [ + 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', + 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', + ], + ], + }, + naf: { + wnd: 7, + points: [ + [ + 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', + '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', + ], + [ + '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', + 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', + ], + [ + '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', + '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', + ], + [ + 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', + 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', + ], + [ + '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', + 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', + ], + [ + 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', + 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', + ], + [ + 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', + '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', + ], + [ + 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', + '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', + ], + [ + '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', + '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', + ], + [ + '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', + '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', + ], + [ + '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', + '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', + ], + [ + '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', + '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', + ], + [ + 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', + 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', + ], + [ + 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', + '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', + ], + [ + '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', + 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', + ], + [ + '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', + 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', + ], + [ + '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', + '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', + ], + [ + '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', + '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', + ], + [ + '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', + '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', + ], + [ + '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', + 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', + ], + [ + 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', + 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', + ], + [ + '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', + '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', + ], + [ + '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', + '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', + ], + [ + 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', + 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', + ], + [ + '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', + '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', + ], + [ + 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', + 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', + ], + [ + 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', + 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', + ], + [ + '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', + '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', + ], + [ + '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', + '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', + ], + [ + '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', + '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', + ], + [ + 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', + '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', + ], + [ + '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', + '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', + ], + [ + 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', + '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', + ], + [ + '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', + 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', + ], + [ + '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', + 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', + ], + [ + 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', + 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', + ], + [ + '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', + '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', + ], + [ + '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', + 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', + ], + [ + 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', + 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', + ], + [ + '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', + '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', + ], + [ + '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', + 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', + ], + [ + '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', + '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', + ], + [ + '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', + 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', + ], + [ + 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', + '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', + ], + [ + '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', + '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', + ], + [ + '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', + 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', + ], + [ + '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', + 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', + ], + [ + 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', + 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', + ], + [ + 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', + 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', + ], + [ + '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', + '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', + ], + [ + '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', + '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', + ], + [ + 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', + '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', + ], + [ + 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', + 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', + ], + [ + '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', + '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', + ], + [ + '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', + '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', + ], + [ + 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', + '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', + ], + [ + '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', + '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', + ], + [ + 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', + 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', + ], + [ + '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', + 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', + ], + [ + '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', + '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', + ], + [ + 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', + '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', + ], + [ + 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', + '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', + ], + [ + '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', + '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', + ], + [ + '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', + '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', + ], + [ + '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', + 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', + ], + [ + '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', + 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', + ], + [ + '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', + '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', + ], + [ + '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', + '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', + ], + [ + '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', + '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', + ], + [ + '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', + 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', + ], + [ + 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', + 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', + ], + [ + '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', + 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', + ], + [ + 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', + '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', + ], + [ + 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', + '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', + ], + [ + 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', + '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', + ], + [ + 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', + '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', + ], + [ + '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', + 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', + ], + [ + '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', + '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', + ], + [ + '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', + 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', + ], + [ + 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', + 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', + ], + [ + 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', + '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', + ], + [ + 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', + 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', + ], + [ + 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', + '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', + ], + [ + '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', + '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', + ], + [ + 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', + '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', + ], + [ + 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', + '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', + ], + [ + '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', + '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', + ], + [ + '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', + 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', + ], + [ + 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', + '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', + ], + [ + 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', + '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', + ], + [ + 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', + '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', + ], + [ + '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', + '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', + ], + [ + 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', + 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', + ], + [ + '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', + 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', + ], + [ + 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', + 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', + ], + [ + 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', + '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', + ], + [ + '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', + 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', + ], + [ + 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', + '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', + ], + [ + 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', + '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', + ], + [ + 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', + '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', + ], + [ + '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', + 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', + ], + [ + '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', + 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', + ], + [ + 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', + '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', + ], + [ + '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', + 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', + ], + [ + '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', + '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', + ], + [ + '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', + 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', + ], + [ + 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', + 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', + ], + [ + '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', + 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', + ], + [ + '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', + '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', + ], + [ + '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', + 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', + ], + [ + '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', + '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', + ], + [ + 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', + 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', + ], + [ + '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', + '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', + ], + [ + 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', + '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', + ], + [ + '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', + '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', + ], + [ + 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', + 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', + ], + [ + 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', + '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', + ], + [ + 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', + 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', + ], + [ + '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', + 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', + ], + [ + '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', + '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', + ], + [ + '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', + 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', + ], + [ + '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', + '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', + ], + [ + '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', + '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', + ], + [ + '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', + 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', + ], + [ + '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', + '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', + ], + [ + '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', + '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', + ], + [ + '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', + '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', + ], + ], + }, + }; + + },{}],70:[function(require,module,exports){ + 'use strict'; + + var utils = exports; + var BN = require('bn.js'); + var minAssert = require('minimalistic-assert'); + var minUtils = require('minimalistic-crypto-utils'); + + utils.assert = minAssert; + utils.toArray = minUtils.toArray; + utils.zero2 = minUtils.zero2; + utils.toHex = minUtils.toHex; + utils.encode = minUtils.encode; + + // Represent num in a w-NAF form + function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); + + var ws = 1 << (w + 1); + var k = num.clone(); + + for (var i = 0; i < naf.length; i++) { + var z; + var mod = k.andln(ws - 1); + if (k.isOdd()) { + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } + + naf[i] = z; + k.iushrn(1); + } + + return naf; + } + utils.getNAF = getNAF; + + // Represent k1, k2 in a Joint Sparse Form + function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; + + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); + + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } + + return jsf; + } + utils.getJSF = getJSF; + + function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; + } + utils.cachedProperty = cachedProperty; + + function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; + } + utils.parseBytes = parseBytes; + + function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); + } + utils.intFromLE = intFromLE; + + + },{"bn.js":45,"minimalistic-assert":103,"minimalistic-crypto-utils":104}],71:[function(require,module,exports){ + module.exports={ + "_args": [ + [ + "elliptic@6.5.4", + "/Users/apple/casper" + ] + ], + "_from": "elliptic@6.5.4", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.5.4", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.5.4", + "saveSpec": null, + "fetchSpec": "6.5.4" + }, + "_requiredBy": [ + "/browserify-sign", + "/create-ecdh", + "/eccrypto", + "/eccrypto/secp256k1", + "/key-encoder", + "/secp256k1" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_spec": "6.5.4", + "_where": "/Users/apple/casper", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" + } + + },{}],72:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function createHashFunction(hashConstructor) { + return function (msg) { + var hash = hashConstructor(); + hash.update(msg); + return Buffer.from(hash.digest()); + }; + } + exports.createHashFunction = createHashFunction; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266}],73:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var hdkey = require("./vendor/hdkey-without-crypto"); + exports.HDKey = hdkey; + + },{"./vendor/hdkey-without-crypto":78}],74:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var Ripemd160 = require("hash.js/lib/hash/ripemd").ripemd160; + var hash_utils_1 = require("../hash-utils"); + exports.ripemd160 = hash_utils_1.createHashFunction(function () { return new Ripemd160(); }); + + },{"../hash-utils":72,"hash.js/lib/hash/ripemd":86}],75:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var Sha256Hash = require("hash.js/lib/hash/sha/256"); + var hash_utils_1 = require("../hash-utils"); + exports.sha256 = hash_utils_1.createHashFunction(function () { return new Sha256Hash(); }); + + },{"../hash-utils":72,"hash.js/lib/hash/sha/256":90}],76:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var ripemd160_1 = require("../ripemd160"); + var sha256_1 = require("../sha256"); + exports.createHmac = require("create-hmac"); + exports.randomBytes = require("randombytes"); + var Hash = /** @class */ (function () { + function Hash(hashFunction) { + this.hashFunction = hashFunction; + this.buffers = []; + } + Hash.prototype.update = function (buffer) { + if (!Buffer.isBuffer(buffer)) { + throw new Error("hdkey-crypto shim is outdated"); + } + this.buffers.push(buffer); + return this; + }; + Hash.prototype.digest = function (param) { + if (param) { + throw new Error("hdkey-crypto shim is outdated"); + } + return this.hashFunction(Buffer.concat(this.buffers)); + }; + return Hash; + }()); + // We don't use create-hash here, as it doesn't work well with Rollup + exports.createHash = function (name) { + if (name === "ripemd160") { + return new Hash(ripemd160_1.ripemd160); + } + if (name === "sha256") { + return new Hash(sha256_1.sha256); + } + throw new Error("hdkey-crypto shim is outdated"); + }; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"../ripemd160":74,"../sha256":75,"buffer":266,"create-hmac":53,"randombytes":105}],77:[function(require,module,exports){ + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + Object.defineProperty(exports, "__esModule", { value: true }); + __export(require("../../shims/hdkey-secp256k1v3")); + + },{"../../shims/hdkey-secp256k1v3":81}],78:[function(require,module,exports){ + 'use strict'; + + function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + + var assert = _interopDefault(require('assert')); + var safeBuffer = _interopDefault(require('safe-buffer')); + var bs58check = _interopDefault(require('bs58check')); + + var cryptoShim = require("../shims/hdkey-crypto"); + + var secp256k1Shim = require("../shims/hdkey-secp256k1v3"); + + var Buffer = safeBuffer.Buffer; + + + + + var MASTER_SECRET = Buffer.from('Bitcoin seed', 'utf8'); + var HARDENED_OFFSET = 0x80000000; + var LEN = 78; + + // Bitcoin hardcoded by default, can use package `coininfo` for others + var BITCOIN_VERSIONS = {private: 0x0488ADE4, public: 0x0488B21E}; + + function HDKey (versions) { + this.versions = versions || BITCOIN_VERSIONS; + this.depth = 0; + this.index = 0; + this._privateKey = null; + this._publicKey = null; + this.chainCode = null; + this._fingerprint = 0; + this.parentFingerprint = 0; + } + + Object.defineProperty(HDKey.prototype, 'fingerprint', { get: function () { return this._fingerprint } }); + Object.defineProperty(HDKey.prototype, 'identifier', { get: function () { return this._identifier } }); + Object.defineProperty(HDKey.prototype, 'pubKeyHash', { get: function () { return this.identifier } }); + + Object.defineProperty(HDKey.prototype, 'privateKey', { + get: function () { + return this._privateKey + }, + set: function (value) { + assert.equal(value.length, 32, 'Private key must be 32 bytes.'); + assert(secp256k1Shim.privateKeyVerify(value) === true, 'Invalid private key'); + + this._privateKey = value; + this._publicKey = secp256k1Shim.publicKeyCreate(value, true); + this._identifier = hash160(this.publicKey); + this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); + } + }); + + Object.defineProperty(HDKey.prototype, 'publicKey', { + get: function () { + return this._publicKey + }, + set: function (value) { + assert(value.length === 33 || value.length === 65, 'Public key must be 33 or 65 bytes.'); + assert(secp256k1Shim.publicKeyVerify(value) === true, 'Invalid public key'); + + this._publicKey = secp256k1Shim.publicKeyConvert(value, true); // force compressed point + this._identifier = hash160(this.publicKey); + this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); + this._privateKey = null; + } + }); + + Object.defineProperty(HDKey.prototype, 'privateExtendedKey', { + get: function () { + if (this._privateKey) return bs58check.encode(serialize(this, this.versions.private, Buffer.concat([Buffer.alloc(1, 0), this.privateKey]))) + else return null + } + }); + + Object.defineProperty(HDKey.prototype, 'publicExtendedKey', { + get: function () { + return bs58check.encode(serialize(this, this.versions.public, this.publicKey)) + } + }); + + HDKey.prototype.derive = function (path) { + if (path === 'm' || path === 'M' || path === "m'" || path === "M'") { + return this + } + + var entries = path.split('/'); + var hdkey = this; + entries.forEach(function (c, i) { + if (i === 0) { + assert(/^[mM]{1}/.test(c), 'Path must start with "m" or "M"'); + return + } + + var hardened = (c.length > 1) && (c[c.length - 1] === "'"); + var childIndex = parseInt(c, 10); // & (HARDENED_OFFSET - 1) + assert(childIndex < HARDENED_OFFSET, 'Invalid index'); + if (hardened) childIndex += HARDENED_OFFSET; + + hdkey = hdkey.deriveChild(childIndex); + }); + + return hdkey + }; + + HDKey.prototype.deriveChild = function (index) { + var isHardened = index >= HARDENED_OFFSET; + var indexBuffer = Buffer.allocUnsafe(4); + indexBuffer.writeUInt32BE(index, 0); + + var data; + + if (isHardened) { // Hardened child + assert(this.privateKey, 'Could not derive hardened child key'); + + var pk = this.privateKey; + var zb = Buffer.alloc(1, 0); + pk = Buffer.concat([zb, pk]); + + // data = 0x00 || ser256(kpar) || ser32(index) + data = Buffer.concat([pk, indexBuffer]); + } else { // Normal child + // data = serP(point(kpar)) || ser32(index) + // = serP(Kpar) || ser32(index) + data = Buffer.concat([this.publicKey, indexBuffer]); + } + + var I = cryptoShim.createHmac('sha512', this.chainCode).update(data).digest(); + var IL = I.slice(0, 32); + var IR = I.slice(32); + + var hd = new HDKey(this.versions); + + // Private parent key -> private child key + if (this.privateKey) { + // ki = parse256(IL) + kpar (mod n) + try { + hd.privateKey = secp256k1Shim.privateKeyTweakAdd(this.privateKey, IL); + // throw if IL >= n || (privateKey + IL) === 0 + } catch (err) { + // In case parse256(IL) >= n or ki == 0, one should proceed with the next value for i + return this.deriveChild(index + 1) + } + // Public parent key -> public child key + } else { + // Ki = point(parse256(IL)) + Kpar + // = G*IL + Kpar + try { + hd.publicKey = secp256k1Shim.publicKeyTweakAdd(this.publicKey, IL, true); + // throw if IL >= n || (g**IL + publicKey) is infinity + } catch (err) { + // In case parse256(IL) >= n or Ki is the point at infinity, one should proceed with the next value for i + return this.deriveChild(index + 1) + } + } + + hd.chainCode = IR; + hd.depth = this.depth + 1; + hd.parentFingerprint = this.fingerprint;// .readUInt32BE(0) + hd.index = index; + + return hd + }; + + HDKey.prototype.sign = function (hash) { + return secp256k1Shim.sign(hash, this.privateKey).signature + }; + + HDKey.prototype.verify = function (hash, signature) { + return secp256k1Shim.verify(hash, signature, this.publicKey) + }; + + HDKey.prototype.wipePrivateData = function () { + if (this._privateKey) cryptoShim.randomBytes(this._privateKey.length).copy(this._privateKey); + this._privateKey = null; + return this + }; + + HDKey.prototype.toJSON = function () { + return { + xpriv: this.privateExtendedKey, + xpub: this.publicExtendedKey + } + }; + + HDKey.fromMasterSeed = function (seedBuffer, versions) { + var I = cryptoShim.createHmac('sha512', MASTER_SECRET).update(seedBuffer).digest(); + var IL = I.slice(0, 32); + var IR = I.slice(32); + + var hdkey = new HDKey(versions); + hdkey.chainCode = IR; + hdkey.privateKey = IL; + + return hdkey + }; + + HDKey.fromExtendedKey = function (base58key, versions) { + // => version(4) || depth(1) || fingerprint(4) || index(4) || chain(32) || key(33) + versions = versions || BITCOIN_VERSIONS; + var hdkey = new HDKey(versions); + + var keyBuffer = bs58check.decode(base58key); + + var version = keyBuffer.readUInt32BE(0); + assert(version === versions.private || version === versions.public, 'Version mismatch: does not match private or public'); + + hdkey.depth = keyBuffer.readUInt8(4); + hdkey.parentFingerprint = keyBuffer.readUInt32BE(5); + hdkey.index = keyBuffer.readUInt32BE(9); + hdkey.chainCode = keyBuffer.slice(13, 45); + + var key = keyBuffer.slice(45); + if (key.readUInt8(0) === 0) { // private + assert(version === versions.private, 'Version mismatch: version does not match private'); + hdkey.privateKey = key.slice(1); // cut off first 0x0 byte + } else { + assert(version === versions.public, 'Version mismatch: version does not match public'); + hdkey.publicKey = key; + } + + return hdkey + }; + + HDKey.fromJSON = function (obj) { + return HDKey.fromExtendedKey(obj.xpriv) + }; + + function serialize (hdkey, version, key) { + // => version(4) || depth(1) || fingerprint(4) || index(4) || chain(32) || key(33) + var buffer = Buffer.allocUnsafe(LEN); + + buffer.writeUInt32BE(version, 0); + buffer.writeUInt8(hdkey.depth, 4); + + var fingerprint = hdkey.depth ? hdkey.parentFingerprint : 0x00000000; + buffer.writeUInt32BE(fingerprint, 5); + buffer.writeUInt32BE(hdkey.index, 9); + + hdkey.chainCode.copy(buffer, 13); + key.copy(buffer, 45); + + return buffer + } + + function hash160 (buf) { + var sha = cryptoShim.createHash('sha256').update(buf).digest(); + return cryptoShim.createHash('ripemd160').update(sha).digest() + } + + HDKey.HARDENED_OFFSET = HARDENED_OFFSET; + var hdkey = HDKey; + + module.exports = hdkey; + + },{"../shims/hdkey-crypto":76,"../shims/hdkey-secp256k1v3":77,"assert":215,"bs58check":49,"safe-buffer":122}],79:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var randombytes = require("randombytes"); + function getRandomBytes(bytes) { + return new Promise(function (resolve, reject) { + randombytes(bytes, function (err, resp) { + if (err) { + reject(err); + return; + } + resolve(resp); + }); + }); + } + exports.getRandomBytes = getRandomBytes; + function getRandomBytesSync(bytes) { + return randombytes(bytes); + } + exports.getRandomBytesSync = getRandomBytesSync; + + },{"randombytes":105}],80:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + Object.defineProperty(exports, "__esModule", { value: true }); + var secp256k1_1 = require("secp256k1"); + var random_1 = require("./random"); + var SECP256K1_PRIVATE_KEY_SIZE = 32; + function createPrivateKey() { + return __awaiter(this, void 0, void 0, function () { + var pk; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!true) return [3 /*break*/, 2]; + return [4 /*yield*/, random_1.getRandomBytes(SECP256K1_PRIVATE_KEY_SIZE)]; + case 1: + pk = _a.sent(); + if (secp256k1_1.privateKeyVerify(pk)) { + return [2 /*return*/, pk]; + } + return [3 /*break*/, 0]; + case 2: return [2 /*return*/]; + } + }); + }); + } + exports.createPrivateKey = createPrivateKey; + function createPrivateKeySync() { + while (true) { + var pk = random_1.getRandomBytesSync(SECP256K1_PRIVATE_KEY_SIZE); + if (secp256k1_1.privateKeyVerify(pk)) { + return pk; + } + } + } + exports.createPrivateKeySync = createPrivateKeySync; + __export(require("secp256k1")); + + },{"./random":79,"secp256k1":124}],81:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var secp256k1 = __importStar(require("secp256k1")); + function privateKeyVerify(privateKey) { + return secp256k1.privateKeyVerify(privateKey); + } + exports.privateKeyVerify = privateKeyVerify; + function publicKeyCreate(privateKey, compressed) { + if (compressed === void 0) { compressed = true; } + return Buffer.from(secp256k1.publicKeyCreate(privateKey, compressed)); + } + exports.publicKeyCreate = publicKeyCreate; + function publicKeyVerify(publicKey) { + return secp256k1.publicKeyVerify(publicKey); + } + exports.publicKeyVerify = publicKeyVerify; + function publicKeyConvert(publicKey, compressed) { + if (compressed === void 0) { compressed = true; } + return Buffer.from(secp256k1.publicKeyConvert(publicKey, compressed)); + } + exports.publicKeyConvert = publicKeyConvert; + function privateKeyTweakAdd(publicKey, tweak) { + return Buffer.from(secp256k1.privateKeyTweakAdd(Buffer.from(publicKey), tweak)); + } + exports.privateKeyTweakAdd = privateKeyTweakAdd; + function publicKeyTweakAdd(publicKey, tweak, compressed) { + if (compressed === void 0) { compressed = true; } + return Buffer.from(secp256k1.publicKeyTweakAdd(Buffer.from(publicKey), tweak, compressed)); + } + exports.publicKeyTweakAdd = publicKeyTweakAdd; + function sign(message, privateKey) { + var ret = secp256k1.ecdsaSign(message, privateKey); + return { signature: Buffer.from(ret.signature), recovery: ret.recid }; + } + exports.sign = sign; + function verify(message, signature, publicKey) { + return secp256k1.ecdsaVerify(signature, message, publicKey); + } + exports.verify = verify; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266,"secp256k1":124}],82:[function(require,module,exports){ + 'use strict' + var Buffer = require('safe-buffer').Buffer + var Transform = require('readable-stream').Transform + var inherits = require('inherits') + + function throwIfNotStringOrBuffer (val, prefix) { + if (!Buffer.isBuffer(val) && typeof val !== 'string') { + throw new TypeError(prefix + ' must be a string or a buffer') + } + } + + function HashBase (blockSize) { + Transform.call(this) + + this._block = Buffer.allocUnsafe(blockSize) + this._blockSize = blockSize + this._blockOffset = 0 + this._length = [0, 0, 0, 0] + + this._finalized = false + } + + inherits(HashBase, Transform) + + HashBase.prototype._transform = function (chunk, encoding, callback) { + var error = null + try { + this.update(chunk, encoding) + } catch (err) { + error = err + } + + callback(error) + } + + HashBase.prototype._flush = function (callback) { + var error = null + try { + this.push(this.digest()) + } catch (err) { + error = err + } + + callback(error) + } + + HashBase.prototype.update = function (data, encoding) { + throwIfNotStringOrBuffer(data, 'Data') + if (this._finalized) throw new Error('Digest already called') + if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) + + // consume data + var block = this._block + var offset = 0 + while (this._blockOffset + data.length - offset >= this._blockSize) { + for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++] + this._update() + this._blockOffset = 0 + } + while (offset < data.length) block[this._blockOffset++] = data[offset++] + + // update length + for (var j = 0, carry = data.length * 8; carry > 0; ++j) { + this._length[j] += carry + carry = (this._length[j] / 0x0100000000) | 0 + if (carry > 0) this._length[j] -= 0x0100000000 * carry + } + + return this + } + + HashBase.prototype._update = function () { + throw new Error('_update is not implemented') + } + + HashBase.prototype.digest = function (encoding) { + if (this._finalized) throw new Error('Digest already called') + this._finalized = true + + var digest = this._digest() + if (encoding !== undefined) digest = digest.toString(encoding) + + // reset state + this._block.fill(0) + this._blockOffset = 0 + for (var i = 0; i < 4; ++i) this._length[i] = 0 + + return digest + } + + HashBase.prototype._digest = function () { + throw new Error('_digest is not implemented') + } + + module.exports = HashBase + + },{"inherits":97,"readable-stream":120,"safe-buffer":122}],83:[function(require,module,exports){ + var hash = exports; + + hash.utils = require('./hash/utils'); + hash.common = require('./hash/common'); + hash.sha = require('./hash/sha'); + hash.ripemd = require('./hash/ripemd'); + hash.hmac = require('./hash/hmac'); + + // Proxy hash functions to the main object + hash.sha1 = hash.sha.sha1; + hash.sha256 = hash.sha.sha256; + hash.sha224 = hash.sha.sha224; + hash.sha384 = hash.sha.sha384; + hash.sha512 = hash.sha.sha512; + hash.ripemd160 = hash.ripemd.ripemd160; + + },{"./hash/common":84,"./hash/hmac":85,"./hash/ripemd":86,"./hash/sha":87,"./hash/utils":94}],84:[function(require,module,exports){ + 'use strict'; + + var utils = require('./utils'); + var assert = 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 update(msg, enc) { + // Convert message to array, pad it, and join into 32bit blocks + msg = utils.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + + // Enough data, try updating + if (this.pending.length >= this._delta8) { + msg = this.pending; + + // Process pending data in blocks + var r = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r, msg.length); + if (this.pending.length === 0) + this.pending = null; + + msg = utils.join32(msg, 0, msg.length - r, 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()); + assert(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] = 0x80; + for (var i = 1; i < k; i++) + res[i] = 0; + + // Append length + 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) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = len & 0xff; + } else { + res[i++] = len & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 24) & 0xff; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + + for (t = 8; t < this.padLength; t++) + res[i++] = 0; + } + + return res; + }; + + },{"./utils":94,"minimalistic-assert":103}],85:[function(require,module,exports){ + 'use strict'; + + var utils = require('./utils'); + var assert = require('minimalistic-assert'); + + function Hmac(hash, key, enc) { + if (!(this instanceof Hmac)) + return new Hmac(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + + this._init(utils.toArray(key, enc)); + } + module.exports = Hmac; + + Hmac.prototype._init = function init(key) { + // Shorten key, if needed + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + assert(key.length <= this.blockSize); + + // Add padding to key + for (var i = key.length; i < this.blockSize; i++) + key.push(0); + + for (i = 0; i < key.length; i++) + key[i] ^= 0x36; + this.inner = new this.Hash().update(key); + + // 0x36 ^ 0x5c = 0x6a + for (i = 0; i < key.length; i++) + key[i] ^= 0x6a; + this.outer = new this.Hash().update(key); + }; + + Hmac.prototype.update = function update(msg, enc) { + this.inner.update(msg, enc); + return this; + }; + + Hmac.prototype.digest = function digest(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); + }; + + },{"./utils":94,"minimalistic-assert":103}],86:[function(require,module,exports){ + 'use strict'; + + var utils = require('./utils'); + var common = require('./common'); + + var rotl32 = utils.rotl32; + var sum32 = utils.sum32; + var sum32_3 = utils.sum32_3; + var sum32_4 = utils.sum32_4; + var BlockHash = common.BlockHash; + + function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + + BlockHash.call(this); + + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; + this.endian = 'little'; + } + utils.inherits(RIPEMD160, BlockHash); + exports.ripemd160 = RIPEMD160; + + RIPEMD160.blockSize = 512; + RIPEMD160.outSize = 160; + RIPEMD160.hmacStrength = 192; + RIPEMD160.padLength = 64; + + RIPEMD160.prototype._update = function update(msg, start) { + 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 Ah = A; + var Bh = B; + var Ch = C; + var Dh = D; + var Eh = E; + for (var j = 0; j < 80; j++) { + var T = sum32( + rotl32( + sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), + s[j]), + E); + A = E; + E = D; + D = rotl32(C, 10); + C = B; + B = T; + T = sum32( + rotl32( + sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), + sh[j]), + Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32(Ch, 10); + Ch = Bh; + Bh = T; + } + T = sum32_3(this.h[1], C, Dh); + this.h[1] = sum32_3(this.h[2], D, Eh); + this.h[2] = sum32_3(this.h[3], E, Ah); + this.h[3] = sum32_3(this.h[4], A, Bh); + this.h[4] = sum32_3(this.h[0], B, Ch); + this.h[0] = T; + }; + + RIPEMD160.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'little'); + else + return utils.split32(this.h, 'little'); + }; + + function f(j, x, y, z) { + if (j <= 15) + return x ^ y ^ z; + else if (j <= 31) + return (x & y) | ((~x) & z); + else if (j <= 47) + return (x | (~y)) ^ z; + else if (j <= 63) + return (x & z) | (y & (~z)); + else + return x ^ (y | (~z)); + } + + function K(j) { + if (j <= 15) + return 0x00000000; + else if (j <= 31) + return 0x5a827999; + else if (j <= 47) + return 0x6ed9eba1; + else if (j <= 63) + return 0x8f1bbcdc; + else + return 0xa953fd4e; + } + + function Kh(j) { + if (j <= 15) + return 0x50a28be6; + else if (j <= 31) + return 0x5c4dd124; + else if (j <= 47) + return 0x6d703ef3; + else if (j <= 63) + return 0x7a6d76e9; + else + return 0x00000000; + } + + var r = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 + ]; + + var rh = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 + ]; + + var s = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 + ]; + + var sh = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 + ]; + + },{"./common":84,"./utils":94}],87:[function(require,module,exports){ + 'use strict'; + + exports.sha1 = require('./sha/1'); + exports.sha224 = require('./sha/224'); + exports.sha256 = require('./sha/256'); + exports.sha384 = require('./sha/384'); + exports.sha512 = require('./sha/512'); + + },{"./sha/1":88,"./sha/224":89,"./sha/256":90,"./sha/384":91,"./sha/512":92}],88:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var common = require('../common'); + var shaCommon = require('./common'); + + 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 = [ + 0x5A827999, 0x6ED9EBA1, + 0x8F1BBCDC, 0xCA62C1D6 + ]; + + function SHA1() { + if (!(this instanceof SHA1)) + return new SHA1(); + + BlockHash.call(this); + this.h = [ + 0x67452301, 0xefcdab89, 0x98badcfe, + 0x10325476, 0xc3d2e1f0 ]; + 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'); + }; + + },{"../common":84,"../utils":94,"./common":93}],89:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var SHA256 = require('./256'); + + function SHA224() { + if (!(this instanceof SHA224)) + return new SHA224(); + + SHA256.call(this); + this.h = [ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; + } + 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) { + // Just truncate output + if (enc === 'hex') + return utils.toHex32(this.h.slice(0, 7), 'big'); + else + return utils.split32(this.h.slice(0, 7), 'big'); + }; + + + },{"../utils":94,"./256":90}],90:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var common = require('../common'); + var shaCommon = require('./common'); + var assert = 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 = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + + function SHA256() { + if (!(this instanceof SHA256)) + return new SHA256(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + 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]; + + assert(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'); + }; + + },{"../common":84,"../utils":94,"./common":93,"minimalistic-assert":103}],91:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + + var SHA512 = require('./512'); + + function SHA384() { + if (!(this instanceof SHA384)) + return new SHA384(); + + SHA512.call(this); + this.h = [ + 0xcbbb9d5d, 0xc1059ed8, + 0x629a292a, 0x367cd507, + 0x9159015a, 0x3070dd17, + 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, + 0x8eb44a87, 0x68581511, + 0xdb0c2e0d, 0x64f98fa7, + 0x47b5481d, 0xbefa4fa4 ]; + } + utils.inherits(SHA384, SHA512); + module.exports = SHA384; + + SHA384.blockSize = 1024; + SHA384.outSize = 384; + SHA384.hmacStrength = 192; + SHA384.padLength = 128; + + SHA384.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h.slice(0, 12), 'big'); + else + return utils.split32(this.h.slice(0, 12), 'big'); + }; + + },{"../utils":94,"./512":92}],92:[function(require,module,exports){ + 'use strict'; + + var utils = require('../utils'); + var common = require('../common'); + var assert = 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 = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 + ]; + + function SHA512() { + if (!(this instanceof SHA512)) + return new SHA512(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xf3bcc908, + 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, + 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, + 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, + 0x5be0cd19, 0x137e2179 ]; + 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; + + // 32 x 32bit words + 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]); // i - 2 + var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); + var c1_hi = W[i - 14]; // i - 7 + var c1_lo = W[i - 13]; + var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 + var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); + var c3_hi = W[i - 32]; // i - 16 + 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]; + + assert(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.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); + }; + + function ch64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ ((~xh) & zh); + if (r < 0) + r += 0x100000000; + return r; + } + + function ch64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ ((~xl) & zl); + if (r < 0) + r += 0x100000000; + return r; + } + + function maj64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); + if (r < 0) + r += 0x100000000; + return r; + } + + function maj64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); + if (r < 0) + r += 0x100000000; + return r; + } + + function s0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 28); + var c1_hi = rotr64_hi(xl, xh, 2); // 34 + var c2_hi = rotr64_hi(xl, xh, 7); // 39 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function s0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 28); + var c1_lo = rotr64_lo(xl, xh, 2); // 34 + var c2_lo = rotr64_lo(xl, xh, 7); // 39 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function s1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 14); + var c1_hi = rotr64_hi(xh, xl, 18); + var c2_hi = rotr64_hi(xl, xh, 9); // 41 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function s1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 14); + var c1_lo = rotr64_lo(xh, xl, 18); + var c2_lo = rotr64_lo(xl, xh, 9); // 41 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function g0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 1); + var c1_hi = rotr64_hi(xh, xl, 8); + var c2_hi = shr64_hi(xh, xl, 7); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function g0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 1); + var c1_lo = rotr64_lo(xh, xl, 8); + var c2_lo = shr64_lo(xh, xl, 7); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function g1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 19); + var c1_hi = rotr64_hi(xl, xh, 29); // 61 + var c2_hi = shr64_hi(xh, xl, 6); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function g1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 19); + var c1_lo = rotr64_lo(xl, xh, 29); // 61 + var c2_lo = shr64_lo(xh, xl, 6); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + },{"../common":84,"../utils":94,"minimalistic-assert":103}],93:[function(require,module,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; + + },{"../utils":94}],94:[function(require,module,exports){ + 'use strict'; + + var assert = require('minimalistic-assert'); + var inherits = require('inherits'); + + exports.inherits = inherits; + + function isSurrogatePair(msg, i) { + if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) { + return false; + } + if (i < 0 || i + 1 >= msg.length) { + return false; + } + return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00; + } + + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === 'string') { + if (!enc) { + // Inspired by stringToUtf8ByteArray() in closure-library by Google + // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143 + // Apache License 2.0 + // https://github.com/google/closure-library/blob/master/LICENSE + 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 = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF); + 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 toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; + } + exports.toHex = toHex; + + function htonl(w) { + var res = (w >>> 24) | + ((w >>> 8) & 0xff00) | + ((w << 8) & 0xff0000) | + ((w & 0xff) << 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; + assert(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) & 0xff; + res[k + 2] = (m >>> 8) & 0xff; + res[k + 3] = m & 0xff; + } else { + res[k + 3] = m >>> 24; + res[k + 2] = (m >>> 16) & 0xff; + res[k + 1] = (m >>> 8) & 0xff; + res[k] = m & 0xff; + } + } + 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 r = (al << (32 - num)) | (ah >>> num); + return r >>> 0; + } + exports.rotr64_hi = rotr64_hi; + + function rotr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 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 r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; + } + exports.shr64_lo = shr64_lo; + + },{"inherits":97,"minimalistic-assert":103}],95:[function(require,module,exports){ + 'use strict'; + + var hash = require('hash.js'); + var utils = require('minimalistic-crypto-utils'); + var assert = require('minimalistic-assert'); + + function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + + var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex'); + var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex'); + var pers = utils.toArray(options.pers, options.persEnc || 'hex'); + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + this._init(entropy, nonce, pers); + } + module.exports = HmacDRBG; + + HmacDRBG.prototype._init = function init(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i = 0; i < this.V.length; i++) { + this.K[i] = 0x00; + this.V[i] = 0x01; + } + + this._update(seed); + this._reseed = 1; + this.reseedInterval = 0x1000000000000; // 2^48 + }; + + HmacDRBG.prototype._hmac = function hmac() { + return new hash.hmac(this.hash, this.K); + }; + + HmacDRBG.prototype._update = function update(seed) { + var kmac = this._hmac() + .update(this.V) + .update([ 0x00 ]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + + this.K = this._hmac() + .update(this.V) + .update([ 0x01 ]) + .update(seed) + .digest(); + this.V = this._hmac().update(this.V).digest(); + }; + + HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { + // Optional entropy enc + if (typeof entropyEnc !== 'string') { + addEnc = add; + add = entropyEnc; + entropyEnc = null; + } + + entropy = utils.toArray(entropy, entropyEnc); + add = utils.toArray(add, addEnc); + + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + + this._update(entropy.concat(add || [])); + this._reseed = 1; + }; + + HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error('Reseed is required'); + + // Optional encoding + if (typeof enc !== 'string') { + addEnc = add; + add = enc; + enc = null; + } + + // Optional additional data + if (add) { + add = utils.toArray(add, addEnc || 'hex'); + this._update(add); + } + + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + + var res = temp.slice(0, len); + this._update(add); + this._reseed++; + return utils.encode(res, enc); + }; + + },{"hash.js":83,"minimalistic-assert":103,"minimalistic-crypto-utils":104}],96:[function(require,module,exports){ + // HumanizeDuration.js - https://git.io/j0HgmQ + + /* global define, module */ + + (function () { + // This has to be defined separately because of a bug: we want to alias + // `gr` and `el` for backwards-compatiblity. In a breaking change, we can + // remove `gr` entirely. + // See https://github.com/EvanHahn/HumanizeDuration.js/issues/143 for more. + var greek = { + y: function (c) { + return c === 1 ? "χρόνος" : "χρόνια"; + }, + mo: function (c) { + return c === 1 ? "μήνας" : "μήνες"; + }, + w: function (c) { + return c === 1 ? "εβδομάδα" : "εβδομάδες"; + }, + d: function (c) { + return c === 1 ? "μέρα" : "μέρες"; + }, + h: function (c) { + return c === 1 ? "ώρα" : "ώρες"; + }, + m: function (c) { + return c === 1 ? "λεπτό" : "λεπτά"; + }, + s: function (c) { + return c === 1 ? "δευτερόλεπτο" : "δευτερόλεπτα"; + }, + ms: function (c) { + return c === 1 + ? "χιλιοστό του δευτερολέπτου" + : "χιλιοστά του δευτερολέπτου"; + }, + decimal: ",", + }; + + var LANGUAGES = { + ar: { + y: function (c) { + return c === 1 ? "سنة" : "سنوات"; + }, + mo: function (c) { + return c === 1 ? "شهر" : "أشهر"; + }, + w: function (c) { + return c === 1 ? "أسبوع" : "أسابيع"; + }, + d: function (c) { + return c === 1 ? "يوم" : "أيام"; + }, + h: function (c) { + return c === 1 ? "ساعة" : "ساعات"; + }, + m: function (c) { + return c > 2 && c < 11 ? "دقائق" : "دقيقة"; + }, + s: function (c) { + return c === 1 ? "ثانية" : "ثواني"; + }, + ms: function (c) { + return c === 1 ? "جزء من الثانية" : "أجزاء من الثانية"; + }, + decimal: ",", + }, + bg: { + y: function (c) { + return ["години", "година", "години"][getSlavicForm(c)]; + }, + mo: function (c) { + return ["месеца", "месец", "месеца"][getSlavicForm(c)]; + }, + w: function (c) { + return ["седмици", "седмица", "седмици"][getSlavicForm(c)]; + }, + d: function (c) { + return ["дни", "ден", "дни"][getSlavicForm(c)]; + }, + h: function (c) { + return ["часа", "час", "часа"][getSlavicForm(c)]; + }, + m: function (c) { + return ["минути", "минута", "минути"][getSlavicForm(c)]; + }, + s: function (c) { + return ["секунди", "секунда", "секунди"][getSlavicForm(c)]; + }, + ms: function (c) { + return ["милисекунди", "милисекунда", "милисекунди"][getSlavicForm(c)]; + }, + decimal: ",", + }, + ca: { + y: function (c) { + return "any" + (c === 1 ? "" : "s"); + }, + mo: function (c) { + return "mes" + (c === 1 ? "" : "os"); + }, + w: function (c) { + return "setman" + (c === 1 ? "a" : "es"); + }, + d: function (c) { + return "di" + (c === 1 ? "a" : "es"); + }, + h: function (c) { + return "hor" + (c === 1 ? "a" : "es"); + }, + m: function (c) { + return "minut" + (c === 1 ? "" : "s"); + }, + s: function (c) { + return "segon" + (c === 1 ? "" : "s"); + }, + ms: function (c) { + return "milisegon" + (c === 1 ? "" : "s"); + }, + decimal: ",", + }, + cs: { + y: function (c) { + return ["rok", "roku", "roky", "let"][getCzechOrSlovakForm(c)]; + }, + mo: function (c) { + return ["měsíc", "měsíce", "měsíce", "měsíců"][getCzechOrSlovakForm(c)]; + }, + w: function (c) { + return ["týden", "týdne", "týdny", "týdnů"][getCzechOrSlovakForm(c)]; + }, + d: function (c) { + return ["den", "dne", "dny", "dní"][getCzechOrSlovakForm(c)]; + }, + h: function (c) { + return ["hodina", "hodiny", "hodiny", "hodin"][getCzechOrSlovakForm(c)]; + }, + m: function (c) { + return ["minuta", "minuty", "minuty", "minut"][getCzechOrSlovakForm(c)]; + }, + s: function (c) { + return ["sekunda", "sekundy", "sekundy", "sekund"][ + getCzechOrSlovakForm(c) + ]; + }, + ms: function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ + getCzechOrSlovakForm(c) + ]; + }, + decimal: ",", + }, + da: { + y: "år", + mo: function (c) { + return "måned" + (c === 1 ? "" : "er"); + }, + w: function (c) { + return "uge" + (c === 1 ? "" : "r"); + }, + d: function (c) { + return "dag" + (c === 1 ? "" : "e"); + }, + h: function (c) { + return "time" + (c === 1 ? "" : "r"); + }, + m: function (c) { + return "minut" + (c === 1 ? "" : "ter"); + }, + s: function (c) { + return "sekund" + (c === 1 ? "" : "er"); + }, + ms: function (c) { + return "millisekund" + (c === 1 ? "" : "er"); + }, + decimal: ",", + }, + de: { + y: function (c) { + return "Jahr" + (c === 1 ? "" : "e"); + }, + mo: function (c) { + return "Monat" + (c === 1 ? "" : "e"); + }, + w: function (c) { + return "Woche" + (c === 1 ? "" : "n"); + }, + d: function (c) { + return "Tag" + (c === 1 ? "" : "e"); + }, + h: function (c) { + return "Stunde" + (c === 1 ? "" : "n"); + }, + m: function (c) { + return "Minute" + (c === 1 ? "" : "n"); + }, + s: function (c) { + return "Sekunde" + (c === 1 ? "" : "n"); + }, + ms: function (c) { + return "Millisekunde" + (c === 1 ? "" : "n"); + }, + decimal: ",", + }, + el: greek, + en: { + y: function (c) { + return "year" + (c === 1 ? "" : "s"); + }, + mo: function (c) { + return "month" + (c === 1 ? "" : "s"); + }, + w: function (c) { + return "week" + (c === 1 ? "" : "s"); + }, + d: function (c) { + return "day" + (c === 1 ? "" : "s"); + }, + h: function (c) { + return "hour" + (c === 1 ? "" : "s"); + }, + m: function (c) { + return "minute" + (c === 1 ? "" : "s"); + }, + s: function (c) { + return "second" + (c === 1 ? "" : "s"); + }, + ms: function (c) { + return "millisecond" + (c === 1 ? "" : "s"); + }, + decimal: ".", + }, + es: { + y: function (c) { + return "año" + (c === 1 ? "" : "s"); + }, + mo: function (c) { + return "mes" + (c === 1 ? "" : "es"); + }, + w: function (c) { + return "semana" + (c === 1 ? "" : "s"); + }, + d: function (c) { + return "día" + (c === 1 ? "" : "s"); + }, + h: function (c) { + return "hora" + (c === 1 ? "" : "s"); + }, + m: function (c) { + return "minuto" + (c === 1 ? "" : "s"); + }, + s: function (c) { + return "segundo" + (c === 1 ? "" : "s"); + }, + ms: function (c) { + return "milisegundo" + (c === 1 ? "" : "s"); + }, + decimal: ",", + }, + et: { + y: function (c) { + return "aasta" + (c === 1 ? "" : "t"); + }, + mo: function (c) { + return "kuu" + (c === 1 ? "" : "d"); + }, + w: function (c) { + return "nädal" + (c === 1 ? "" : "at"); + }, + d: function (c) { + return "päev" + (c === 1 ? "" : "a"); + }, + h: function (c) { + return "tund" + (c === 1 ? "" : "i"); + }, + m: function (c) { + return "minut" + (c === 1 ? "" : "it"); + }, + s: function (c) { + return "sekund" + (c === 1 ? "" : "it"); + }, + ms: function (c) { + return "millisekund" + (c === 1 ? "" : "it"); + }, + decimal: ",", + }, + fa: { + y: "سال", + mo: "ماه", + w: "هفته", + d: "روز", + h: "ساعت", + m: "دقیقه", + s: "ثانیه", + ms: "میلی ثانیه", + decimal: ".", + }, + fi: { + y: function (c) { + return c === 1 ? "vuosi" : "vuotta"; + }, + mo: function (c) { + return c === 1 ? "kuukausi" : "kuukautta"; + }, + w: function (c) { + return "viikko" + (c === 1 ? "" : "a"); + }, + d: function (c) { + return "päivä" + (c === 1 ? "" : "ä"); + }, + h: function (c) { + return "tunti" + (c === 1 ? "" : "a"); + }, + m: function (c) { + return "minuutti" + (c === 1 ? "" : "a"); + }, + s: function (c) { + return "sekunti" + (c === 1 ? "" : "a"); + }, + ms: function (c) { + return "millisekunti" + (c === 1 ? "" : "a"); + }, + decimal: ",", + }, + fo: { + y: "ár", + mo: function (c) { + return c === 1 ? "mánaður" : "mánaðir"; + }, + w: function (c) { + return c === 1 ? "vika" : "vikur"; + }, + d: function (c) { + return c === 1 ? "dagur" : "dagar"; + }, + h: function (c) { + return c === 1 ? "tími" : "tímar"; + }, + m: function (c) { + return c === 1 ? "minuttur" : "minuttir"; + }, + s: "sekund", + ms: "millisekund", + decimal: ",", + }, + fr: { + y: function (c) { + return "an" + (c >= 2 ? "s" : ""); + }, + mo: "mois", + w: function (c) { + return "semaine" + (c >= 2 ? "s" : ""); + }, + d: function (c) { + return "jour" + (c >= 2 ? "s" : ""); + }, + h: function (c) { + return "heure" + (c >= 2 ? "s" : ""); + }, + m: function (c) { + return "minute" + (c >= 2 ? "s" : ""); + }, + s: function (c) { + return "seconde" + (c >= 2 ? "s" : ""); + }, + ms: function (c) { + return "milliseconde" + (c >= 2 ? "s" : ""); + }, + decimal: ",", + }, + gr: greek, + he: { + y: function (c) { + return c === 1 ? "שנה" : "שנים"; + }, + mo: function (c) { + return c === 1 ? "חודש" : "חודשים"; + }, + w: function (c) { + return c === 1 ? "שבוע" : "שבועות"; + }, + d: function (c) { + return c === 1 ? "יום" : "ימים"; + }, + h: function (c) { + return c === 1 ? "שעה" : "שעות"; + }, + m: function (c) { + return c === 1 ? "דקה" : "דקות"; + }, + s: function (c) { + return c === 1 ? "שניה" : "שניות"; + }, + ms: function (c) { + return c === 1 ? "מילישנייה" : "מילישניות"; + }, + decimal: ".", + }, + hr: { + y: function (c) { + if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { + return "godine"; + } + return "godina"; + }, + mo: function (c) { + if (c === 1) { + return "mjesec"; + } else if (c === 2 || c === 3 || c === 4) { + return "mjeseca"; + } + return "mjeseci"; + }, + w: function (c) { + if (c % 10 === 1 && c !== 11) { + return "tjedan"; + } + return "tjedna"; + }, + d: function (c) { + return c === 1 ? "dan" : "dana"; + }, + h: function (c) { + if (c === 1) { + return "sat"; + } else if (c === 2 || c === 3 || c === 4) { + return "sata"; + } + return "sati"; + }, + m: function (c) { + var mod10 = c % 10; + if ((mod10 === 2 || mod10 === 3 || mod10 === 4) && (c < 10 || c > 14)) { + return "minute"; + } + return "minuta"; + }, + s: function (c) { + var mod10 = c % 10; + if (mod10 === 5 || (Math.floor(c) === c && c >= 10 && c <= 19)) { + return "sekundi"; + } else if (mod10 === 1) { + return "sekunda"; + } else if (mod10 === 2 || mod10 === 3 || mod10 === 4) { + return "sekunde"; + } + return "sekundi"; + }, + ms: function (c) { + if (c === 1) { + return "milisekunda"; + } else if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { + return "milisekunde"; + } + return "milisekundi"; + }, + decimal: ",", + }, + hi: { + y: "साल", + mo: function (c) { + return c === 1 ? "महीना" : "महीने"; + }, + w: function (c) { + return c === 1 ? "हफ़्ता" : "हफ्ते"; + }, + d: "दिन", + h: function (c) { + return c === 1 ? "घंटा" : "घंटे"; + }, + m: "मिनट", + s: "सेकंड", + ms: "मिलीसेकंड", + decimal: ".", + }, + hu: { + y: "év", + mo: "hónap", + w: "hét", + d: "nap", + h: "óra", + m: "perc", + s: "másodperc", + ms: "ezredmásodperc", + decimal: ",", + }, + id: { + y: "tahun", + mo: "bulan", + w: "minggu", + d: "hari", + h: "jam", + m: "menit", + s: "detik", + ms: "milidetik", + decimal: ".", + }, + is: { + y: "ár", + mo: function (c) { + return "mánuð" + (c === 1 ? "ur" : "ir"); + }, + w: function (c) { + return "vik" + (c === 1 ? "a" : "ur"); + }, + d: function (c) { + return "dag" + (c === 1 ? "ur" : "ar"); + }, + h: function (c) { + return "klukkutím" + (c === 1 ? "i" : "ar"); + }, + m: function (c) { + return "mínút" + (c === 1 ? "a" : "ur"); + }, + s: function (c) { + return "sekúnd" + (c === 1 ? "a" : "ur"); + }, + ms: function (c) { + return "millisekúnd" + (c === 1 ? "a" : "ur"); + }, + decimal: ".", + }, + it: { + y: function (c) { + return "ann" + (c === 1 ? "o" : "i"); + }, + mo: function (c) { + return "mes" + (c === 1 ? "e" : "i"); + }, + w: function (c) { + return "settiman" + (c === 1 ? "a" : "e"); + }, + d: function (c) { + return "giorn" + (c === 1 ? "o" : "i"); + }, + h: function (c) { + return "or" + (c === 1 ? "a" : "e"); + }, + m: function (c) { + return "minut" + (c === 1 ? "o" : "i"); + }, + s: function (c) { + return "second" + (c === 1 ? "o" : "i"); + }, + ms: function (c) { + return "millisecond" + (c === 1 ? "o" : "i"); + }, + decimal: ",", + }, + ja: { + y: "年", + mo: "月", + w: "週", + d: "日", + h: "時間", + m: "分", + s: "秒", + ms: "ミリ秒", + decimal: ".", + }, + ko: { + y: "년", + mo: "개월", + w: "주일", + d: "일", + h: "시간", + m: "분", + s: "초", + ms: "밀리 초", + decimal: ".", + }, + lo: { + y: "ປີ", + mo: "ເດືອນ", + w: "ອາທິດ", + d: "ມື້", + h: "ຊົ່ວໂມງ", + m: "ນາທີ", + s: "ວິນາທີ", + ms: "ມິນລິວິນາທີ", + decimal: ",", + }, + lt: { + y: function (c) { + return c % 10 === 0 || (c % 100 >= 10 && c % 100 <= 20) + ? "metų" + : "metai"; + }, + mo: function (c) { + return ["mėnuo", "mėnesiai", "mėnesių"][getLithuanianForm(c)]; + }, + w: function (c) { + return ["savaitė", "savaitės", "savaičių"][getLithuanianForm(c)]; + }, + d: function (c) { + return ["diena", "dienos", "dienų"][getLithuanianForm(c)]; + }, + h: function (c) { + return ["valanda", "valandos", "valandų"][getLithuanianForm(c)]; + }, + m: function (c) { + return ["minutė", "minutės", "minučių"][getLithuanianForm(c)]; + }, + s: function (c) { + return ["sekundė", "sekundės", "sekundžių"][getLithuanianForm(c)]; + }, + ms: function (c) { + return ["milisekundė", "milisekundės", "milisekundžių"][ + getLithuanianForm(c) + ]; + }, + decimal: ",", + }, + lv: { + y: function (c) { + return getLatvianForm(c) ? "gads" : "gadi"; + }, + mo: function (c) { + return getLatvianForm(c) ? "mēnesis" : "mēneši"; + }, + w: function (c) { + return getLatvianForm(c) ? "nedēļa" : "nedēļas"; + }, + d: function (c) { + return getLatvianForm(c) ? "diena" : "dienas"; + }, + h: function (c) { + return getLatvianForm(c) ? "stunda" : "stundas"; + }, + m: function (c) { + return getLatvianForm(c) ? "minūte" : "minūtes"; + }, + s: function (c) { + return getLatvianForm(c) ? "sekunde" : "sekundes"; + }, + ms: function (c) { + return getLatvianForm(c) ? "milisekunde" : "milisekundes"; + }, + decimal: ",", + }, + ms: { + y: "tahun", + mo: "bulan", + w: "minggu", + d: "hari", + h: "jam", + m: "minit", + s: "saat", + ms: "milisaat", + decimal: ".", + }, + nl: { + y: "jaar", + mo: function (c) { + return c === 1 ? "maand" : "maanden"; + }, + w: function (c) { + return c === 1 ? "week" : "weken"; + }, + d: function (c) { + return c === 1 ? "dag" : "dagen"; + }, + h: "uur", + m: function (c) { + return c === 1 ? "minuut" : "minuten"; + }, + s: function (c) { + return c === 1 ? "seconde" : "seconden"; + }, + ms: function (c) { + return c === 1 ? "milliseconde" : "milliseconden"; + }, + decimal: ",", + }, + no: { + y: "år", + mo: function (c) { + return "måned" + (c === 1 ? "" : "er"); + }, + w: function (c) { + return "uke" + (c === 1 ? "" : "r"); + }, + d: function (c) { + return "dag" + (c === 1 ? "" : "er"); + }, + h: function (c) { + return "time" + (c === 1 ? "" : "r"); + }, + m: function (c) { + return "minutt" + (c === 1 ? "" : "er"); + }, + s: function (c) { + return "sekund" + (c === 1 ? "" : "er"); + }, + ms: function (c) { + return "millisekund" + (c === 1 ? "" : "er"); + }, + decimal: ",", + }, + pl: { + y: function (c) { + return ["rok", "roku", "lata", "lat"][getPolishForm(c)]; + }, + mo: function (c) { + return ["miesiąc", "miesiąca", "miesiące", "miesięcy"][ + getPolishForm(c) + ]; + }, + w: function (c) { + return ["tydzień", "tygodnia", "tygodnie", "tygodni"][getPolishForm(c)]; + }, + d: function (c) { + return ["dzień", "dnia", "dni", "dni"][getPolishForm(c)]; + }, + h: function (c) { + return ["godzina", "godziny", "godziny", "godzin"][getPolishForm(c)]; + }, + m: function (c) { + return ["minuta", "minuty", "minuty", "minut"][getPolishForm(c)]; + }, + s: function (c) { + return ["sekunda", "sekundy", "sekundy", "sekund"][getPolishForm(c)]; + }, + ms: function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ + getPolishForm(c) + ]; + }, + decimal: ",", + }, + pt: { + y: function (c) { + return "ano" + (c === 1 ? "" : "s"); + }, + mo: function (c) { + return c === 1 ? "mês" : "meses"; + }, + w: function (c) { + return "semana" + (c === 1 ? "" : "s"); + }, + d: function (c) { + return "dia" + (c === 1 ? "" : "s"); + }, + h: function (c) { + return "hora" + (c === 1 ? "" : "s"); + }, + m: function (c) { + return "minuto" + (c === 1 ? "" : "s"); + }, + s: function (c) { + return "segundo" + (c === 1 ? "" : "s"); + }, + ms: function (c) { + return "milissegundo" + (c === 1 ? "" : "s"); + }, + decimal: ",", + }, + ro: { + y: function (c) { + return c === 1 ? "an" : "ani"; + }, + mo: function (c) { + return c === 1 ? "lună" : "luni"; + }, + w: function (c) { + return c === 1 ? "săptămână" : "săptămâni"; + }, + d: function (c) { + return c === 1 ? "zi" : "zile"; + }, + h: function (c) { + return c === 1 ? "oră" : "ore"; + }, + m: function (c) { + return c === 1 ? "minut" : "minute"; + }, + s: function (c) { + return c === 1 ? "secundă" : "secunde"; + }, + ms: function (c) { + return c === 1 ? "milisecundă" : "milisecunde"; + }, + decimal: ",", + }, + ru: { + y: function (c) { + return ["лет", "год", "года"][getSlavicForm(c)]; + }, + mo: function (c) { + return ["месяцев", "месяц", "месяца"][getSlavicForm(c)]; + }, + w: function (c) { + return ["недель", "неделя", "недели"][getSlavicForm(c)]; + }, + d: function (c) { + return ["дней", "день", "дня"][getSlavicForm(c)]; + }, + h: function (c) { + return ["часов", "час", "часа"][getSlavicForm(c)]; + }, + m: function (c) { + return ["минут", "минута", "минуты"][getSlavicForm(c)]; + }, + s: function (c) { + return ["секунд", "секунда", "секунды"][getSlavicForm(c)]; + }, + ms: function (c) { + return ["миллисекунд", "миллисекунда", "миллисекунды"][ + getSlavicForm(c) + ]; + }, + decimal: ",", + }, + uk: { + y: function (c) { + return ["років", "рік", "роки"][getSlavicForm(c)]; + }, + mo: function (c) { + return ["місяців", "місяць", "місяці"][getSlavicForm(c)]; + }, + w: function (c) { + return ["тижнів", "тиждень", "тижні"][getSlavicForm(c)]; + }, + d: function (c) { + return ["днів", "день", "дні"][getSlavicForm(c)]; + }, + h: function (c) { + return ["годин", "година", "години"][getSlavicForm(c)]; + }, + m: function (c) { + return ["хвилин", "хвилина", "хвилини"][getSlavicForm(c)]; + }, + s: function (c) { + return ["секунд", "секунда", "секунди"][getSlavicForm(c)]; + }, + ms: function (c) { + return ["мілісекунд", "мілісекунда", "мілісекунди"][getSlavicForm(c)]; + }, + decimal: ",", + }, + ur: { + y: "سال", + mo: function (c) { + return c === 1 ? "مہینہ" : "مہینے"; + }, + w: function (c) { + return c === 1 ? "ہفتہ" : "ہفتے"; + }, + d: "دن", + h: function (c) { + return c === 1 ? "گھنٹہ" : "گھنٹے"; + }, + m: "منٹ", + s: "سیکنڈ", + ms: "ملی سیکنڈ", + decimal: ".", + }, + sk: { + y: function (c) { + return ["rok", "roky", "roky", "rokov"][getCzechOrSlovakForm(c)]; + }, + mo: function (c) { + return ["mesiac", "mesiace", "mesiace", "mesiacov"][ + getCzechOrSlovakForm(c) + ]; + }, + w: function (c) { + return ["týždeň", "týždne", "týždne", "týždňov"][ + getCzechOrSlovakForm(c) + ]; + }, + d: function (c) { + return ["deň", "dni", "dni", "dní"][getCzechOrSlovakForm(c)]; + }, + h: function (c) { + return ["hodina", "hodiny", "hodiny", "hodín"][getCzechOrSlovakForm(c)]; + }, + m: function (c) { + return ["minúta", "minúty", "minúty", "minút"][getCzechOrSlovakForm(c)]; + }, + s: function (c) { + return ["sekunda", "sekundy", "sekundy", "sekúnd"][ + getCzechOrSlovakForm(c) + ]; + }, + ms: function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekúnd"][ + getCzechOrSlovakForm(c) + ]; + }, + decimal: ",", + }, + sl: { + y: function (c) { + if (c % 10 === 1) { + return "leto"; + } else if (c % 100 === 2) { + return "leti"; + } else if ( + c % 100 === 3 || + c % 100 === 4 || + (Math.floor(c) !== c && c % 100 <= 5) + ) { + return "leta"; + } else { + return "let"; + } + }, + mo: function (c) { + if (c % 10 === 1) { + return "mesec"; + } else if (c % 100 === 2 || (Math.floor(c) !== c && c % 100 <= 5)) { + return "meseca"; + } else if (c % 10 === 3 || c % 10 === 4) { + return "mesece"; + } else { + return "mesecev"; + } + }, + w: function (c) { + if (c % 10 === 1) { + return "teden"; + } else if (c % 10 === 2 || (Math.floor(c) !== c && c % 100 <= 4)) { + return "tedna"; + } else if (c % 10 === 3 || c % 10 === 4) { + return "tedne"; + } else { + return "tednov"; + } + }, + d: function (c) { + return c % 100 === 1 ? "dan" : "dni"; + }, + h: function (c) { + if (c % 10 === 1) { + return "ura"; + } else if (c % 100 === 2) { + return "uri"; + } else if (c % 10 === 3 || c % 10 === 4 || Math.floor(c) !== c) { + return "ure"; + } else { + return "ur"; + } + }, + m: function (c) { + if (c % 10 === 1) { + return "minuta"; + } else if (c % 10 === 2) { + return "minuti"; + } else if ( + c % 10 === 3 || + c % 10 === 4 || + (Math.floor(c) !== c && c % 100 <= 4) + ) { + return "minute"; + } else { + return "minut"; + } + }, + s: function (c) { + if (c % 10 === 1) { + return "sekunda"; + } else if (c % 100 === 2) { + return "sekundi"; + } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { + return "sekunde"; + } else { + return "sekund"; + } + }, + ms: function (c) { + if (c % 10 === 1) { + return "milisekunda"; + } else if (c % 100 === 2) { + return "milisekundi"; + } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { + return "milisekunde"; + } else { + return "milisekund"; + } + }, + decimal: ",", + }, + sv: { + y: "år", + mo: function (c) { + return "månad" + (c === 1 ? "" : "er"); + }, + w: function (c) { + return "veck" + (c === 1 ? "a" : "or"); + }, + d: function (c) { + return "dag" + (c === 1 ? "" : "ar"); + }, + h: function (c) { + return "timm" + (c === 1 ? "e" : "ar"); + }, + m: function (c) { + return "minut" + (c === 1 ? "" : "er"); + }, + s: function (c) { + return "sekund" + (c === 1 ? "" : "er"); + }, + ms: function (c) { + return "millisekund" + (c === 1 ? "" : "er"); + }, + decimal: ",", + }, + sw: { + y: function (c) { + return c === 1 ? "mwaka" : "miaka"; + }, + mo: function (c) { + return c === 1 ? "mwezi" : "miezi"; + }, + w: "wiki", + d: function (c) { + return c === 1 ? "siku" : "masiku"; + }, + h: function (c) { + return c === 1 ? "saa" : "masaa"; + }, + m: "dakika", + s: "sekunde", + ms: "milisekunde", + decimal: ".", + }, + tr: { + y: "yıl", + mo: "ay", + w: "hafta", + d: "gün", + h: "saat", + m: "dakika", + s: "saniye", + ms: "milisaniye", + decimal: ",", + }, + th: { + y: "ปี", + mo: "เดือน", + w: "สัปดาห์", + d: "วัน", + h: "ชั่วโมง", + m: "นาที", + s: "วินาที", + ms: "มิลลิวินาที", + decimal: ".", + }, + vi: { + y: "năm", + mo: "tháng", + w: "tuần", + d: "ngày", + h: "giờ", + m: "phút", + s: "giây", + ms: "mili giây", + decimal: ",", + }, + zh_CN: { + y: "年", + mo: "个月", + w: "周", + d: "天", + h: "小时", + m: "分钟", + s: "秒", + ms: "毫秒", + decimal: ".", + }, + zh_TW: { + y: "年", + mo: "個月", + w: "周", + d: "天", + h: "小時", + m: "分鐘", + s: "秒", + ms: "毫秒", + decimal: ".", + }, + }; + + // You can create a humanizer, which returns a function with default + // parameters. + function humanizer(passedOptions) { + var result = function humanizer(ms, humanizerOptions) { + var options = assign({}, result, humanizerOptions || {}); + return doHumanization(ms, options); + }; + + return assign( + result, + { + language: "en", + delimiter: ", ", + spacer: " ", + conjunction: "", + serialComma: true, + units: ["y", "mo", "w", "d", "h", "m", "s"], + languages: {}, + round: false, + unitMeasures: { + y: 31557600000, + mo: 2629800000, + w: 604800000, + d: 86400000, + h: 3600000, + m: 60000, + s: 1000, + ms: 1, + }, + }, + passedOptions + ); + } + + // The main function is just a wrapper around a default humanizer. + var humanizeDuration = humanizer({}); + + // Build dictionary from options + function getDictionary(options) { + var languagesFromOptions = [options.language]; + + if (has(options, "fallbacks")) { + if (isArray(options.fallbacks) && options.fallbacks.length) { + languagesFromOptions = languagesFromOptions.concat(options.fallbacks); + } else { + throw new Error("fallbacks must be an array with at least one element"); + } + } + + for (var i = 0; i < languagesFromOptions.length; i++) { + var languageToTry = languagesFromOptions[i]; + if (has(options.languages, languageToTry)) { + return options.languages[languageToTry]; + } else if (has(LANGUAGES, languageToTry)) { + return LANGUAGES[languageToTry]; + } + } + + throw new Error("No language found."); + } + + // doHumanization does the bulk of the work. + function doHumanization(ms, options) { + var i, len, piece; + + // Make sure we have a positive number. + // Has the nice sideffect of turning Number objects into primitives. + ms = Math.abs(ms); + + var dictionary = getDictionary(options); + var pieces = []; + + // Start at the top and keep removing units, bit by bit. + var unitName, unitMS, unitCount; + for (i = 0, len = options.units.length; i < len; i++) { + unitName = options.units[i]; + unitMS = options.unitMeasures[unitName]; + + // What's the number of full units we can fit? + if (i + 1 === len) { + if (has(options, "maxDecimalPoints")) { + // We need to use this expValue to avoid rounding functionality of toFixed call + var expValue = Math.pow(10, options.maxDecimalPoints); + var unitCountFloat = ms / unitMS; + unitCount = parseFloat( + (Math.floor(expValue * unitCountFloat) / expValue).toFixed( + options.maxDecimalPoints + ) + ); + } else { + unitCount = ms / unitMS; + } + } else { + unitCount = Math.floor(ms / unitMS); + } + + // Add the string. + pieces.push({ + unitCount: unitCount, + unitName: unitName, + }); + + // Remove what we just figured out. + ms -= unitCount * unitMS; + } + + var firstOccupiedUnitIndex = 0; + for (i = 0; i < pieces.length; i++) { + if (pieces[i].unitCount) { + firstOccupiedUnitIndex = i; + break; + } + } + + if (options.round) { + var ratioToLargerUnit, previousPiece; + for (i = pieces.length - 1; i >= 0; i--) { + piece = pieces[i]; + piece.unitCount = Math.round(piece.unitCount); + + if (i === 0) { + break; + } + + previousPiece = pieces[i - 1]; + + ratioToLargerUnit = + options.unitMeasures[previousPiece.unitName] / + options.unitMeasures[piece.unitName]; + if ( + piece.unitCount % ratioToLargerUnit === 0 || + (options.largest && options.largest - 1 < i - firstOccupiedUnitIndex) + ) { + previousPiece.unitCount += piece.unitCount / ratioToLargerUnit; + piece.unitCount = 0; + } + } + } + + var result = []; + for (i = 0, pieces.length; i < len; i++) { + piece = pieces[i]; + if (piece.unitCount) { + result.push( + render(piece.unitCount, piece.unitName, dictionary, options) + ); + } + + if (result.length === options.largest) { + break; + } + } + + if (result.length) { + if (!options.conjunction || result.length === 1) { + return result.join(options.delimiter); + } else if (result.length === 2) { + return result.join(options.conjunction); + } else if (result.length > 2) { + return ( + result.slice(0, -1).join(options.delimiter) + + (options.serialComma ? "," : "") + + options.conjunction + + result.slice(-1) + ); + } + } else { + return render( + 0, + options.units[options.units.length - 1], + dictionary, + options + ); + } + } + + function render(count, type, dictionary, options) { + var decimal; + if (has(options, "decimal")) { + decimal = options.decimal; + } else if (has(dictionary, "decimal")) { + decimal = dictionary.decimal; + } else { + decimal = "."; + } + + var countStr = count.toString().replace(".", decimal); + + var dictionaryValue = dictionary[type]; + var word; + if (typeof dictionaryValue === "function") { + word = dictionaryValue(count); + } else { + word = dictionaryValue; + } + + return countStr + options.spacer + word; + } + + function assign(destination) { + var source; + for (var i = 1; i < arguments.length; i++) { + source = arguments[i]; + for (var prop in source) { + if (has(source, prop)) { + destination[prop] = source[prop]; + } + } + } + return destination; + } + + // Internal helper function for Polish language. + function getPolishForm(c) { + if (c === 1) { + return 0; + } else if (Math.floor(c) !== c) { + return 1; + } else if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) { + return 2; + } else { + return 3; + } + } + + // Internal helper function for Russian and Ukranian languages. + function getSlavicForm(c) { + if (Math.floor(c) !== c) { + return 2; + } else if ( + (c % 100 >= 5 && c % 100 <= 20) || + (c % 10 >= 5 && c % 10 <= 9) || + c % 10 === 0 + ) { + return 0; + } else if (c % 10 === 1) { + return 1; + } else if (c > 1) { + return 2; + } else { + return 0; + } + } + + // Internal helper function for Slovak language. + function getCzechOrSlovakForm(c) { + if (c === 1) { + return 0; + } else if (Math.floor(c) !== c) { + return 1; + } else if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) { + return 2; + } else { + return 3; + } + } + + // Internal helper function for Lithuanian language. + function getLithuanianForm(c) { + if (c === 1 || (c % 10 === 1 && c % 100 > 20)) { + return 0; + } else if ( + Math.floor(c) !== c || + (c % 10 >= 2 && c % 100 > 20) || + (c % 10 >= 2 && c % 100 < 10) + ) { + return 1; + } else { + return 2; + } + } + + // Internal helper function for Latvian language. + function getLatvianForm(c) { + return c % 10 === 1 && c % 100 !== 11; + } + + // We need to make sure we support browsers that don't have + // `Array.isArray`, so we define a fallback here. + var isArray = + Array.isArray || + function (arg) { + return Object.prototype.toString.call(arg) === "[object Array]"; + }; + + function has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + } + + humanizeDuration.getSupportedLanguages = function getSupportedLanguages() { + var result = []; + for (var language in LANGUAGES) { + if (has(LANGUAGES, language) && language !== "gr") { + result.push(language); + } + } + return result; + }; + + humanizeDuration.humanizer = humanizer; + + if (typeof define === "function" && define.amd) { + define(function () { + return humanizeDuration; + }); + } else if (typeof module !== "undefined" && module.exports) { + module.exports = humanizeDuration; + } else { + this.humanizeDuration = humanizeDuration; + } + })(); + + },{}],97:[function(require,module,exports){ + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + 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 { + // old school shim for old browsers + 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 + } + } + } + + },{}],98:[function(require,module,exports){ + // the whatwg-fetch polyfill installs the fetch() function + // on the global object (window or self) + // + // Return that as the export for use in Webpack, Browserify etc. + require('whatwg-fetch'); + module.exports = self.fetch.bind(self); + + },{"whatwg-fetch":180}],99:[function(require,module,exports){ + (function (global){(function (){ + // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js + + var ws = null + + if (typeof WebSocket !== 'undefined') { + ws = WebSocket + } else if (typeof MozWebSocket !== 'undefined') { + ws = MozWebSocket + } else if (typeof global !== 'undefined') { + ws = global.WebSocket || global.MozWebSocket + } else if (typeof window !== 'undefined') { + ws = window.WebSocket || window.MozWebSocket + } else if (typeof self !== 'undefined') { + ws = self.WebSocket || self.MozWebSocket + } + + module.exports = ws + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{}],100:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + const key_encoder_1 = require("./key-encoder"); + exports.default = key_encoder_1.default; + + },{"./key-encoder":101}],101:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + const elliptic_1 = require("elliptic"); + // @ts-ignore + const asn1 = require("asn1.js"); + const BN = require('bn.js'); + const ECPrivateKeyASN = asn1.define('ECPrivateKey', function () { + // @ts-ignore + const self = this; + self.seq().obj(self.key('version').int(), self.key('privateKey').octstr(), self.key('parameters').explicit(0).objid().optional(), self.key('publicKey').explicit(1).bitstr().optional()); + }); + const SubjectPublicKeyInfoASN = asn1.define('SubjectPublicKeyInfo', function () { + // @ts-ignore + const self = this; + self.seq().obj(self.key('algorithm').seq().obj(self.key("id").objid(), self.key("curve").objid()), self.key('pub').bitstr()); + }); + const curves = { + secp256k1: { + curveParameters: [1, 3, 132, 0, 10], + privatePEMOptions: { label: 'EC PRIVATE KEY' }, + publicPEMOptions: { label: 'PUBLIC KEY' }, + curve: new elliptic_1.ec('secp256k1') + } + }; + class KeyEncoder { + constructor(options) { + if (typeof options === 'string') { + if (options !== 'secp256k1') { + throw new Error('Unknown curve ' + options); + } + options = curves[options]; + } + this.options = options; + this.algorithmID = [1, 2, 840, 10045, 2, 1]; + } + privateKeyObject(rawPrivateKey, rawPublicKey) { + const privateKeyObject = { + version: new BN(1), + privateKey: Buffer.from(rawPrivateKey, 'hex'), + parameters: this.options.curveParameters + }; + if (rawPublicKey) { + privateKeyObject.publicKey = { + unused: 0, + data: Buffer.from(rawPublicKey, 'hex') + }; + } + return privateKeyObject; + } + publicKeyObject(rawPublicKey) { + return { + algorithm: { + id: this.algorithmID, + curve: this.options.curveParameters + }, + pub: { + unused: 0, + data: Buffer.from(rawPublicKey, 'hex') + } + }; + } + encodePrivate(privateKey, originalFormat, destinationFormat) { + let privateKeyObject; + /* Parse the incoming private key and convert it to a private key object */ + if (originalFormat === 'raw') { + if (typeof privateKey !== 'string') { + throw 'private key must be a string'; + } + let keyPair = this.options.curve.keyFromPrivate(privateKey, 'hex'); + let rawPublicKey = keyPair.getPublic('hex'); + privateKeyObject = this.privateKeyObject(privateKey, rawPublicKey); + } + else if (originalFormat === 'der') { + if (typeof privateKey !== 'string') { + // do nothing + } + else if (typeof privateKey === 'string') { + privateKey = Buffer.from(privateKey, 'hex'); + } + else { + throw 'private key must be a buffer or a string'; + } + privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'der'); + } + else if (originalFormat === 'pem') { + if (typeof privateKey !== 'string') { + throw 'private key must be a string'; + } + privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'pem', this.options.privatePEMOptions); + } + else { + throw 'invalid private key format'; + } + /* Export the private key object to the desired format */ + if (destinationFormat === 'raw') { + return privateKeyObject.privateKey.toString('hex'); + } + else if (destinationFormat === 'der') { + return ECPrivateKeyASN.encode(privateKeyObject, 'der').toString('hex'); + } + else if (destinationFormat === 'pem') { + return ECPrivateKeyASN.encode(privateKeyObject, 'pem', this.options.privatePEMOptions); + } + else { + throw 'invalid destination format for private key'; + } + } + encodePublic(publicKey, originalFormat, destinationFormat) { + let publicKeyObject; + /* Parse the incoming public key and convert it to a public key object */ + if (originalFormat === 'raw') { + if (typeof publicKey !== 'string') { + throw 'public key must be a string'; + } + publicKeyObject = this.publicKeyObject(publicKey); + } + else if (originalFormat === 'der') { + if (typeof publicKey !== 'string') { + // do nothing + } + else if (typeof publicKey === 'string') { + publicKey = Buffer.from(publicKey, 'hex'); + } + else { + throw 'public key must be a buffer or a string'; + } + publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'der'); + } + else if (originalFormat === 'pem') { + if (typeof publicKey !== 'string') { + throw 'public key must be a string'; + } + publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'pem', this.options.publicPEMOptions); + } + else { + throw 'invalid public key format'; + } + /* Export the private key object to the desired format */ + if (destinationFormat === 'raw') { + return publicKeyObject.pub.data.toString('hex'); + } + else if (destinationFormat === 'der') { + return SubjectPublicKeyInfoASN.encode(publicKeyObject, 'der').toString('hex'); + } + else if (destinationFormat === 'pem') { + return SubjectPublicKeyInfoASN.encode(publicKeyObject, 'pem', this.options.publicPEMOptions); + } + else { + throw 'invalid destination format for public key'; + } + } + } + exports.default = KeyEncoder; + KeyEncoder.ECPrivateKeyASN = ECPrivateKeyASN; + KeyEncoder.SubjectPublicKeyInfoASN = SubjectPublicKeyInfoASN; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"asn1.js":26,"bn.js":45,"buffer":266,"elliptic":56}],102:[function(require,module,exports){ + 'use strict' + var inherits = require('inherits') + var HashBase = require('hash-base') + var Buffer = require('safe-buffer').Buffer + + var ARRAY16 = new Array(16) + + function MD5 () { + HashBase.call(this, 64) + + // state + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + } + + inherits(MD5, HashBase) + + MD5.prototype._update = function () { + var M = ARRAY16 + for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4) + + var a = this._a + var b = this._b + var c = this._c + var d = this._d + + a = fnF(a, b, c, d, M[0], 0xd76aa478, 7) + d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12) + c = fnF(c, d, a, b, M[2], 0x242070db, 17) + b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22) + a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7) + d = fnF(d, a, b, c, M[5], 0x4787c62a, 12) + c = fnF(c, d, a, b, M[6], 0xa8304613, 17) + b = fnF(b, c, d, a, M[7], 0xfd469501, 22) + a = fnF(a, b, c, d, M[8], 0x698098d8, 7) + d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12) + c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17) + b = fnF(b, c, d, a, M[11], 0x895cd7be, 22) + a = fnF(a, b, c, d, M[12], 0x6b901122, 7) + d = fnF(d, a, b, c, M[13], 0xfd987193, 12) + c = fnF(c, d, a, b, M[14], 0xa679438e, 17) + b = fnF(b, c, d, a, M[15], 0x49b40821, 22) + + a = fnG(a, b, c, d, M[1], 0xf61e2562, 5) + d = fnG(d, a, b, c, M[6], 0xc040b340, 9) + c = fnG(c, d, a, b, M[11], 0x265e5a51, 14) + b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20) + a = fnG(a, b, c, d, M[5], 0xd62f105d, 5) + d = fnG(d, a, b, c, M[10], 0x02441453, 9) + c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14) + b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20) + a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5) + d = fnG(d, a, b, c, M[14], 0xc33707d6, 9) + c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14) + b = fnG(b, c, d, a, M[8], 0x455a14ed, 20) + a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5) + d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9) + c = fnG(c, d, a, b, M[7], 0x676f02d9, 14) + b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20) + + a = fnH(a, b, c, d, M[5], 0xfffa3942, 4) + d = fnH(d, a, b, c, M[8], 0x8771f681, 11) + c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16) + b = fnH(b, c, d, a, M[14], 0xfde5380c, 23) + a = fnH(a, b, c, d, M[1], 0xa4beea44, 4) + d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11) + c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16) + b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23) + a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4) + d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11) + c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16) + b = fnH(b, c, d, a, M[6], 0x04881d05, 23) + a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4) + d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11) + c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16) + b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23) + + a = fnI(a, b, c, d, M[0], 0xf4292244, 6) + d = fnI(d, a, b, c, M[7], 0x432aff97, 10) + c = fnI(c, d, a, b, M[14], 0xab9423a7, 15) + b = fnI(b, c, d, a, M[5], 0xfc93a039, 21) + a = fnI(a, b, c, d, M[12], 0x655b59c3, 6) + d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10) + c = fnI(c, d, a, b, M[10], 0xffeff47d, 15) + b = fnI(b, c, d, a, M[1], 0x85845dd1, 21) + a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6) + d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10) + c = fnI(c, d, a, b, M[6], 0xa3014314, 15) + b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21) + a = fnI(a, b, c, d, M[4], 0xf7537e82, 6) + d = fnI(d, a, b, c, M[11], 0xbd3af235, 10) + c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15) + b = fnI(b, c, d, a, M[9], 0xeb86d391, 21) + + this._a = (this._a + a) | 0 + this._b = (this._b + b) | 0 + this._c = (this._c + c) | 0 + this._d = (this._d + d) | 0 + } + + MD5.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80 + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64) + this._update() + this._blockOffset = 0 + } + + this._block.fill(0, this._blockOffset, 56) + this._block.writeUInt32LE(this._length[0], 56) + this._block.writeUInt32LE(this._length[1], 60) + this._update() + + // produce result + var buffer = Buffer.allocUnsafe(16) + buffer.writeInt32LE(this._a, 0) + buffer.writeInt32LE(this._b, 4) + buffer.writeInt32LE(this._c, 8) + buffer.writeInt32LE(this._d, 12) + return buffer + } + + function rotl (x, n) { + return (x << n) | (x >>> (32 - n)) + } + + function fnF (a, b, c, d, m, k, s) { + return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0 + } + + function fnG (a, b, c, d, m, k, s) { + return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0 + } + + function fnH (a, b, c, d, m, k, s) { + return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0 + } + + function fnI (a, b, c, d, m, k, s) { + return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0 + } + + module.exports = MD5 + + },{"hash-base":82,"inherits":97,"safe-buffer":122}],103:[function(require,module,exports){ + module.exports = assert; + + function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); + } + + assert.equal = function assertEqual(l, r, msg) { + if (l != r) + throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); + }; + + },{}],104:[function(require,module,exports){ + 'use strict'; + + var utils = exports; + + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== 'string') { + for (var i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + return res; + } + if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (var i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } else { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; + } + utils.toArray = toArray; + + function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; + } + utils.zero2 = zero2; + + function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; + } + utils.toHex = toHex; + + utils.encode = function encode(arr, enc) { + if (enc === 'hex') + return toHex(arr); + else + return arr; + }; + + },{}],105:[function(require,module,exports){ + (function (process,global){(function (){ + 'use strict' + + // limit of Crypto.getRandomValues() + // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues + var MAX_BYTES = 65536 + + // Node supports requesting up to this number of bytes + // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48 + var MAX_UINT32 = 4294967295 + + function oldBrowser () { + throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') + } + + var Buffer = require('safe-buffer').Buffer + var crypto = global.crypto || global.msCrypto + + if (crypto && crypto.getRandomValues) { + module.exports = randomBytes + } else { + module.exports = oldBrowser + } + + function randomBytes (size, cb) { + // phantomjs needs to throw + if (size > MAX_UINT32) throw new RangeError('requested too many random bytes') + + var bytes = Buffer.allocUnsafe(size) + + if (size > 0) { // getRandomValues fails on IE if size == 0 + if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues + // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues + for (var generated = 0; generated < size; generated += MAX_BYTES) { + // buffer.slice automatically checks if the end is past the end of + // the buffer so we don't have to here + crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES)) + } + } else { + crypto.getRandomValues(bytes) + } + } + + if (typeof cb === 'function') { + return process.nextTick(function () { + cb(null, bytes) + }) + } + + return bytes + } + + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"_process":353,"safe-buffer":122}],106:[function(require,module,exports){ + 'use strict'; + + function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + + var codes = {}; + + function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; + } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + + function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } + } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + + function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; + } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + + function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; + } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + + function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } + } + + createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; + }, TypeError); + createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + + msg += ". Received type ".concat(typeof actual); + return msg; + }, TypeError); + createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); + createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; + }); + createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); + createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; + }); + createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); + createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); + createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); + createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); + createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; + }, TypeError); + createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); + module.exports.codes = codes; + + },{}],107:[function(require,module,exports){ + (function (process){(function (){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + // a duplex stream is just a stream that is both readable and writable. + // Since JS doesn't have multiple prototypal inheritance, this class + // prototypally inherits from Readable, and then parasitically from + // Writable. + 'use strict'; + /**/ + + var objectKeys = Object.keys || function (obj) { + var keys = []; + + for (var key in obj) { + keys.push(key); + } + + return keys; + }; + /**/ + + + module.exports = Duplex; + + var Readable = require('./_stream_readable'); + + var Writable = require('./_stream_writable'); + + require('inherits')(Duplex, Readable); + + { + // Allow the keys array to be GC'ed. + var keys = objectKeys(Writable.prototype); + + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } + } + + function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); + Writable.call(this, options); + this.allowHalfOpen = true; + + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } + } + + Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } + }); + Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } + }); + Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } + }); // the no-half-open enforcer + + function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. + // But allow more writes to happen in this tick. + + process.nextTick(onEndNT, this); + } + + function onEndNT(self) { + self.end(); + } + + Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } + }); + }).call(this)}).call(this,require('_process')) + },{"./_stream_readable":109,"./_stream_writable":111,"_process":353,"inherits":97}],108:[function(require,module,exports){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + // a passthrough stream. + // basically just the most minimal sort of Transform stream. + // Every written chunk gets output as-is. + 'use strict'; + + module.exports = PassThrough; + + var Transform = require('./_stream_transform'); + + require('inherits')(PassThrough, Transform); + + function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); + } + + PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); + }; + },{"./_stream_transform":110,"inherits":97}],109:[function(require,module,exports){ + (function (process,global){(function (){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + 'use strict'; + + module.exports = Readable; + /**/ + + var Duplex; + /**/ + + Readable.ReadableState = ReadableState; + /**/ + + var EE = require('events').EventEmitter; + + var EElistenerCount = function EElistenerCount(emitter, type) { + return emitter.listeners(type).length; + }; + /**/ + + /**/ + + + var Stream = require('./internal/streams/stream'); + /**/ + + + var Buffer = require('buffer').Buffer; + + var OurUint8Array = global.Uint8Array || function () {}; + + function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); + } + + function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + } + /**/ + + + var debugUtil = require('util'); + + var debug; + + if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); + } else { + debug = function debug() {}; + } + /**/ + + + var BufferList = require('./internal/streams/buffer_list'); + + var destroyImpl = require('./internal/streams/destroy'); + + var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + + var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + + var StringDecoder; + var createReadableStreamAsyncIterator; + var from; + + require('inherits')(Readable, Stream); + + var errorOrDestroy = destroyImpl.errorOrDestroy; + var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + + function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + } + + function ReadableState(options, stream, isDuplex) { + Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + + this.sync = true; // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') + + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s + + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + + this.readingMore = false; + this.decoder = null; + this.encoding = null; + + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } + } + + function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy + + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); + } + + Object.defineProperty(Readable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined) { + return false; + } + + return this._readableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + } + }); + Readable.prototype.destroy = destroyImpl.destroy; + Readable.prototype._undestroy = destroyImpl.undestroy; + + Readable.prototype._destroy = function (err, cb) { + cb(err); + }; // Manually shove something into the read() buffer. + // This returns true if the highWaterMark has not been hit yet, + // similar to how Writable.write() returns true if you should + // write() some more. + + + Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); + }; // Unshift should *always* be something directly out of read() + + + Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); + }; + + function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); + var state = stream._readableState; + + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + + if (er) { + errorOrDestroy(stream, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream, state); + } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. + + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); + } + + function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream.emit('data', chunk); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); + } + + maybeReadMore(stream, state); + } + + function chunkInvalid(state, chunk) { + var er; + + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); + } + + return er; + } + + Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; + }; // backwards compatibility. + + + Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; + }; // Don't raise the hwm > 1GB + + + var MAX_HWM = 0x40000000; + + function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + + return n; + } // This function is designed to be inlinable, so please take care when making + // changes to the function body. + + + function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } // If we're asking for more than the current hwm, then raise the hwm. + + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; // Don't have enough + + if (!state.ended) { + state.needReadable = true; + return 0; + } + + return state.length; + } // you can override either this method, or the async _read(n) below. + + + Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. + + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + // if we need a readable event, then we need to do some reading. + + + var doRead = state.needReadable; + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some + + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + + + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + + this._read(state.highWaterMark); + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n = 0; + } else { + state.length -= n; + state.awaitDrain = 0; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. + + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + return ret; + }; + + function onEofChunk(stream, state) { + debug('onEofChunk'); + if (state.ended) return; + + if (state.decoder) { + var chunk = state.decoder.end(); + + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + + state.ended = true; + + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; + + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } + } // Don't emit readable right away in sync mode, because this can trigger + // another read() call => stack overflow. This way, it might trigger + // a nextTick recursion warning, but that's not so bad. + + + function emitReadable(stream) { + var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); + state.needReadable = false; + + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + process.nextTick(emitReadable_, stream); + } + } + + function emitReadable_(stream) { + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); + + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); + } // at this point, the user has presumably seen the 'readable' event, + // and called read() to consume some data. that may have triggered + // in turn another _read(n) call, in which case reading = true if + // it's in progress. + // However, if we're not ended, or reading, and the length < hwm, + // then go ahead and try to read some more preemptively. + + + function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(maybeReadMore_, stream, state); + } + } + + function maybeReadMore_(stream, state) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) // didn't get any data, stop spinning. + break; + } + + state.readingMore = false; + } // abstract method. to be overridden in specific implementation classes. + // call cb(er, data) where data is <= n in length. + // for virtual (non-string, non-buffer) streams, "length" is somewhat + // arbitrary, and perhaps not very meaningful. + + + Readable.prototype._read = function (n) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); + }; + + Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + + case 1: + state.pipes = [state.pipes, dest]; + break; + + default: + state.pipes.push(dest); + break; + } + + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); + + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + + + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + var cleanedUp = false; + + function cleanup() { + debug('cleanup'); // cleanup event handlers once the pipe is broken + + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + cleanedUp = true; // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + src.on('data', ondata); + + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + debug('dest.write', ret); + + if (ret === false) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + } + + src.pause(); + } + } // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + + + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. + + + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + + dest.once('close', onclose); + + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } // tell the dest that it's being piped to + + + dest.emit('pipe', src); // start the flow if it hasn't been started already. + + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; + }; + + function pipeOnDrain(src) { + return function pipeOnDrainFunctionResult() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; + } + + Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. + + if (state.pipesCount === 0) return this; // just one destination. most common case. + + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. + + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } // slow case. multiple pipe destinations. + + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + + + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + dest.emit('unpipe', this, unpipeInfo); + return this; + }; // set up data events if they are asked for + // Ensure readable listeners eventually get something + + + Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; + + if (ev === 'data') { + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); + } else if (ev === 'readable') { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug('on readable', state.length, state.reading); + + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); + } + } + } + + return res; + }; + + Readable.prototype.addListener = Readable.prototype.on; + + Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; + }; + + Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; + }; + + function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } + } + + function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); + } // pause() and resume() are remnants of the legacy readable stream API + // If the user uses them, then switch into old mode. + + + Readable.prototype.resume = function () { + var state = this._readableState; + + if (!state.flowing) { + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; + resume(this, state); + } + + state.paused = false; + return this; + }; + + function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(resume_, stream, state); + } + } + + function resume_(stream, state) { + debug('resume', state.reading); + + if (!state.reading) { + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); + } + + Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + + if (this._readableState.flowing !== false) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + + this._readableState.paused = true; + return this; + }; + + function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + + while (state.flowing && stream.read() !== null) { + ; + } + } // wrap an old-style stream as the async data source. + // This is *not* part of the readable stream interface. + // It is an ugly unfortunate mess of history. + + + Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + stream.on('end', function () { + debug('wrapped end'); + + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode + + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + + if (!ret) { + paused = true; + stream.pause(); + } + }); // proxy all the other methods. + // important when wrapping filters and duplexes. + + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } // proxy certain important events. + + + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } // when we try to consume some more bytes, simply unpause the + // underlying stream. + + + this._read = function (n) { + debug('wrapped _read', n); + + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; + }; + + if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; + } + + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.highWaterMark; + } + }); + Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } + }); + Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } + }); // exposed for testing purposes only. + + Readable._fromList = fromList; + Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } + }); // Pluck off n bytes from an array of buffers. + // Length is the combined lengths of all the buffers in the list. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + + function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = state.buffer.consume(n, state.decoder); + } + return ret; + } + + function endReadable(stream) { + var state = stream._readableState; + debug('endReadable', state.endEmitted); + + if (!state.endEmitted) { + state.ended = true; + process.nextTick(endReadableNT, state, stream); + } + } + + function endReadableNT(state, stream) { + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } + } + } + + if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = require('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; + } + + function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + + return -1; + } + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"../errors":106,"./_stream_duplex":107,"./internal/streams/async_iterator":112,"./internal/streams/buffer_list":113,"./internal/streams/destroy":114,"./internal/streams/from":116,"./internal/streams/state":118,"./internal/streams/stream":119,"_process":353,"buffer":266,"events":303,"inherits":97,"string_decoder/":135,"util":222}],110:[function(require,module,exports){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + // a transform stream is a readable/writable stream where you do + // something with the data. Sometimes it's called a "filter", + // but that's not a great name for it, since that implies a thing where + // some bits pass through, and others are simply ignored. (That would + // be a valid example of a transform, of course.) + // + // While the output is causally related to the input, it's not a + // necessarily symmetric or synchronous transformation. For example, + // a zlib stream might take multiple plain-text writes(), and then + // emit a single compressed chunk some time in the future. + // + // Here's how this works: + // + // The Transform stream has all the aspects of the readable and writable + // stream classes. When you write(chunk), that calls _write(chunk,cb) + // internally, and returns false if there's a lot of pending writes + // buffered up. When you call read(), that calls _read(n) until + // there's enough pending readable data buffered up. + // + // In a transform stream, the written data is placed in a buffer. When + // _read(n) is called, it transforms the queued up data, calling the + // buffered _write cb's as it consumes chunks. If consuming a single + // written chunk would result in multiple output chunks, then the first + // outputted bit calls the readcb, and subsequent chunks just go into + // the read buffer, and will cause it to emit 'readable' if necessary. + // + // This way, back-pressure is actually determined by the reading side, + // since _read has to be called to start processing a new chunk. However, + // a pathological inflate type of transform can cause excessive buffering + // here. For example, imagine a stream where every byte of input is + // interpreted as an integer from 0-255, and then results in that many + // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in + // 1kb of data being output. In this case, you could write a very small + // amount of input, and end up with a very large amount of output. In + // such a pathological inflating mechanism, there'd be no way to tell + // the system to stop doing the transform. A single 4MB write could + // cause the system to run out of memory. + // + // However, even in such a pathological case, only a single written chunk + // would be consumed, and then the rest would wait (un-transformed) until + // the results of the previous transformed chunk were consumed. + 'use strict'; + + module.exports = Transform; + + var _require$codes = require('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + + var Duplex = require('./_stream_duplex'); + + require('inherits')(Transform, Duplex); + + function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + + ts.writechunk = null; + ts.writecb = null; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } + } + + function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; // start out asking for a readable event once data is transformed. + + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } // When the writable side finishes, then flush out anything remaining. + + + this.on('prefinish', prefinish); + } + + function prefinish() { + var _this = this; + + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } + } + + Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); + }; // This is the part where you do stuff! + // override this function in implementation classes. + // 'chunk' is an input chunk. + // + // Call `push(newChunk)` to pass along transformed output + // to the readable side. You may call 'push' zero or more times. + // + // Call `cb(err)` when you are done with this chunk. If you pass + // an error, then that'll put the hurt on the whole operation. If you + // never call cb(), then you'll never get another chunk. + + + Transform.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); + }; + + Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } + }; // Doesn't matter what the args are here. + // _transform does all the work. + // That we got here means that the readable side wants more data. + + + Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } + }; + + Transform.prototype._destroy = function (err, cb) { + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); + }; + + function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); + } + },{"../errors":106,"./_stream_duplex":107,"inherits":97}],111:[function(require,module,exports){ + (function (process,global){(function (){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + // A bit simpler than readable streams. + // Implement an async ._write(chunk, encoding, cb), and it'll handle all + // the drain event emission and buffering. + 'use strict'; + + module.exports = Writable; + /* */ + + function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; + } // It seems a linked list but it is not + // there will be only 2 of these for each stream + + + function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function () { + onCorkedFinish(_this, state); + }; + } + /* */ + + /**/ + + + var Duplex; + /**/ + + Writable.WritableState = WritableState; + /**/ + + var internalUtil = { + deprecate: require('util-deprecate') + }; + /**/ + + /**/ + + var Stream = require('./internal/streams/stream'); + /**/ + + + var Buffer = require('buffer').Buffer; + + var OurUint8Array = global.Uint8Array || function () {}; + + function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); + } + + function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + } + + var destroyImpl = require('./internal/streams/destroy'); + + var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + + var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + + var errorOrDestroy = destroyImpl.errorOrDestroy; + + require('inherits')(Writable, Stream); + + function nop() {} + + function WritableState(options, stream, isDuplex) { + Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream + // contains buffers or objects. + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called + + this.finalCalled = false; // drain event flag. + + this.needDrain = false; // at the start of calling end() + + this.ending = false; // when end() has been called, and returned + + this.ended = false; // when 'finish' is emitted + + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + + this.length = 0; // a flag to see when we're in the middle of a write. + + this.writing = false; // when true all writes will be buffered until .uncork() call + + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + + this.sync = true; // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + + this.onwrite = function (er) { + onwrite(stream, er); + }; // the callback that the user supplies to write(chunk,encoding,cb) + + + this.writecb = null; // the amount that is being written when _write is called. + + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + + this.prefinished = false; // True if the error was already emitted and should not be thrown again + + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + + this.corkedRequestsFree = new CorkedRequest(this); + } + + WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + + while (current) { + out.push(current); + current = current.next; + } + + return out; + }; + + (function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} + })(); // Test _writableState for inheritance to account for Duplex streams, + // whose prototype chain only points to Readable. + + + var realHasInstance; + + if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; + } + }); + } else { + realHasInstance = function realHasInstance(object) { + return object instanceof this; + }; + } + + function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. + + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); + } // Otherwise people can pipe Writable streams, which is just wrong. + + + Writable.prototype.pipe = function () { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); + }; + + function writeAfterEnd(stream, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb + + errorOrDestroy(stream, er); + process.nextTick(cb, er); + } // Checks that a user-supplied chunk is valid, especially for the particular + // mode the stream is in. Currently this means that `null` is never accepted + // and undefined/non-string values are only allowed in object mode. + + + function validChunk(stream, state, chunk, cb) { + var er; + + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); + } + + if (er) { + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; + } + + return true; + } + + Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; + }; + + Writable.prototype.cork = function () { + this._writableState.corked++; + }; + + Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } + }; + + Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; + }; + + Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } + }); + + function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + + return chunk; + } + + Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } + }); // if we're already writing something, then just put this + // in the queue, and wait our turn. Otherwise, call _write + // If we return false, then we need a drain event, so set that flag. + + function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. + + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; + } + + function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; + } + + function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + process.nextTick(cb, er); // this can emit finish, and it will always happen + // after error + + process.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); // this can emit finish, but finish must + // always follow error + + finishMaybe(stream, state); + } + } + + function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; + } + + function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state) || stream.destroyed; + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + process.nextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } + } + + function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); + } // Must force callback to be called on nextTick, so that we don't + // emit 'drain' before the write() consumer gets the 'false' return + // value, and has a chance to attach a 'drain' listener. + + + function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } + } // if there's something in the buffer waiting, then process it + + + function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + + state.pendingcb++; + state.lastBufferedRequest = null; + + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; + } + + Writable.prototype._write = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); + }; + + Writable.prototype._writev = null; + + Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks + + if (state.corked) { + state.corked = 1; + this.uncork(); + } // ignore unnecessary end() calls. + + + if (!state.ending) endWritable(this, state, cb); + return this; + }; + + Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } + }); + + function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; + } + + function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + + if (err) { + errorOrDestroy(stream, err); + } + + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); + } + + function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function' && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } + } + + function finishMaybe(stream, state) { + var need = needFinish(state); + + if (need) { + prefinish(stream, state); + + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } + } + } + + return need; + } + + function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + + if (cb) { + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); + } + + state.ended = true; + stream.writable = false; + } + + function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; + } + + Object.defineProperty(Writable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._writableState === undefined) { + return false; + } + + return this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._writableState.destroyed = value; + } + }); + Writable.prototype.destroy = destroyImpl.destroy; + Writable.prototype._undestroy = destroyImpl.undestroy; + + Writable.prototype._destroy = function (err, cb) { + cb(err); + }; + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"../errors":106,"./_stream_duplex":107,"./internal/streams/destroy":114,"./internal/streams/state":118,"./internal/streams/stream":119,"_process":353,"buffer":266,"inherits":97,"util-deprecate":179}],112:[function(require,module,exports){ + (function (process){(function (){ + 'use strict'; + + var _Object$setPrototypeO; + + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + var finished = require('./end-of-stream'); + + var kLastResolve = Symbol('lastResolve'); + var kLastReject = Symbol('lastReject'); + var kError = Symbol('error'); + var kEnded = Symbol('ended'); + var kLastPromise = Symbol('lastPromise'); + var kHandlePromise = Symbol('handlePromise'); + var kStream = Symbol('stream'); + + function createIterResult(value, done) { + return { + value: value, + done: done + }; + } + + function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } + } + + function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); + } + + function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; + } + + var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); + var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } + }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; + }), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); + }), _Object$setPrototypeO), AsyncIteratorPrototype); + + var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; + }; + + module.exports = createReadableStreamAsyncIterator; + }).call(this)}).call(this,require('_process')) + },{"./end-of-stream":115,"_process":353}],113:[function(require,module,exports){ + 'use strict'; + + function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + + function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + + var _require = require('buffer'), + Buffer = _require.Buffer; + + var _require2 = require('util'), + inspect = _require2.inspect; + + var custom = inspect && inspect.custom || 'inspect'; + + function copyBuffer(src, target, offset) { + Buffer.prototype.copy.call(src, target, offset); + } + + module.exports = + /*#__PURE__*/ + function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + + while (p = p.next) { + ret += s + p.data; + } + + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. + + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. + + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; + }(); + },{"buffer":266,"util":222}],114:[function(require,module,exports){ + (function (process){(function (){ + 'use strict'; // undocumented cb() API, needed for core, not for public API + + function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } + } + + return this; + } // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + + if (this._readableState) { + this._readableState.destroyed = true; + } // if this is a duplex stream mark the writable part as destroyed as well + + + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process.nextTick(emitCloseNT, _this); + cb(err); + } else { + process.nextTick(emitCloseNT, _this); + } + }); + + return this; + } + + function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); + } + + function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); + } + + function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } + } + + function emitErrorNT(self, err) { + self.emit('error', err); + } + + function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); + } + + module.exports = { + destroy: destroy, + undestroy: undestroy, + errorOrDestroy: errorOrDestroy + }; + }).call(this)}).call(this,require('_process')) + },{"_process":353}],115:[function(require,module,exports){ + // Ported from https://github.com/mafintosh/end-of-stream with + // permission from the author, Mathias Buus (@mafintosh). + 'use strict'; + + var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + + function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; + } + + function noop() {} + + function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; + } + + function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; + } + + module.exports = eos; + },{"../../../errors":106}],116:[function(require,module,exports){ + module.exports = function () { + throw new Error('Readable.from is not available in the browser') + }; + + },{}],117:[function(require,module,exports){ + // Ported from https://github.com/mafintosh/pump with + // permission from the author, Mathias Buus (@mafintosh). + 'use strict'; + + var eos; + + function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; + } + + var _require$codes = require('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + + function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; + } + + function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; + } + + function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = require('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; + } + + function call(fn) { + fn(); + } + + function pipe(from, to) { + return from.pipe(to); + } + + function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); + } + + function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); + } + + module.exports = pipeline; + },{"../../../errors":106,"./end-of-stream":115}],118:[function(require,module,exports){ + 'use strict'; + + var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; + + function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; + } + + function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; + } + + module.exports = { + getHighWaterMark: getHighWaterMark + }; + },{"../../../errors":106}],119:[function(require,module,exports){ + module.exports = require('events').EventEmitter; + + },{"events":303}],120:[function(require,module,exports){ + exports = module.exports = require('./lib/_stream_readable.js'); + exports.Stream = exports; + exports.Readable = exports; + exports.Writable = require('./lib/_stream_writable.js'); + exports.Duplex = require('./lib/_stream_duplex.js'); + exports.Transform = require('./lib/_stream_transform.js'); + exports.PassThrough = require('./lib/_stream_passthrough.js'); + exports.finished = require('./lib/internal/streams/end-of-stream.js'); + exports.pipeline = require('./lib/internal/streams/pipeline.js'); + + },{"./lib/_stream_duplex.js":107,"./lib/_stream_passthrough.js":108,"./lib/_stream_readable.js":109,"./lib/_stream_transform.js":110,"./lib/_stream_writable.js":111,"./lib/internal/streams/end-of-stream.js":115,"./lib/internal/streams/pipeline.js":117}],121:[function(require,module,exports){ + 'use strict' + var Buffer = require('buffer').Buffer + var inherits = require('inherits') + var HashBase = require('hash-base') + + var ARRAY16 = new Array(16) + + var zl = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 + ] + + var zr = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 + ] + + var sl = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 + ] + + var sr = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 + ] + + var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e] + var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000] + + function RIPEMD160 () { + HashBase.call(this, 64) + + // state + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 + } + + inherits(RIPEMD160, HashBase) + + RIPEMD160.prototype._update = function () { + var words = ARRAY16 + for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4) + + var al = this._a | 0 + var bl = this._b | 0 + var cl = this._c | 0 + var dl = this._d | 0 + var el = this._e | 0 + + var ar = this._a | 0 + var br = this._b | 0 + var cr = this._c | 0 + var dr = this._d | 0 + var er = this._e | 0 + + // computation + for (var i = 0; i < 80; i += 1) { + var tl + var tr + if (i < 16) { + tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]) + tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]) + } else if (i < 32) { + tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]) + tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]) + } else if (i < 48) { + tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]) + tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]) + } else if (i < 64) { + tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]) + tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]) + } else { // if (i<80) { + tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]) + tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]) + } + + al = el + el = dl + dl = rotl(cl, 10) + cl = bl + bl = tl + + ar = er + er = dr + dr = rotl(cr, 10) + cr = br + br = tr + } + + // update state + var t = (this._b + cl + dr) | 0 + this._b = (this._c + dl + er) | 0 + this._c = (this._d + el + ar) | 0 + this._d = (this._e + al + br) | 0 + this._e = (this._a + bl + cr) | 0 + this._a = t + } + + RIPEMD160.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80 + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64) + this._update() + this._blockOffset = 0 + } + + this._block.fill(0, this._blockOffset, 56) + this._block.writeUInt32LE(this._length[0], 56) + this._block.writeUInt32LE(this._length[1], 60) + this._update() + + // produce result + var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20) + buffer.writeInt32LE(this._a, 0) + buffer.writeInt32LE(this._b, 4) + buffer.writeInt32LE(this._c, 8) + buffer.writeInt32LE(this._d, 12) + buffer.writeInt32LE(this._e, 16) + return buffer + } + + function rotl (x, n) { + return (x << n) | (x >>> (32 - n)) + } + + function fn1 (a, b, c, d, e, m, k, s) { + return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 + } + + function fn2 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 + } + + function fn3 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 + } + + function fn4 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 + } + + function fn5 (a, b, c, d, e, m, k, s) { + return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 + } + + module.exports = RIPEMD160 + + },{"buffer":266,"hash-base":82,"inherits":97}],122:[function(require,module,exports){ + /*! safe-buffer. MIT License. Feross Aboukhadijeh */ + /* eslint-disable node/no-deprecated-api */ + var buffer = require('buffer') + var Buffer = buffer.Buffer + + // alternative to using Object.keys for old browsers + function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } + } + if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer + } else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer + } + + function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) + } + + SafeBuffer.prototype = Object.create(Buffer.prototype) + + // Copy static methods from Buffer + copyProps(Buffer, SafeBuffer) + + SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) + } + + SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf + } + + SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) + } + + SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) + } + + },{"buffer":266}],123:[function(require,module,exports){ + (function (process){(function (){ + /* eslint-disable node/no-deprecated-api */ + + 'use strict' + + var buffer = require('buffer') + var Buffer = buffer.Buffer + + var safer = {} + + var key + + for (key in buffer) { + if (!buffer.hasOwnProperty(key)) continue + if (key === 'SlowBuffer' || key === 'Buffer') continue + safer[key] = buffer[key] + } + + var Safer = safer.Buffer = {} + for (key in Buffer) { + if (!Buffer.hasOwnProperty(key)) continue + if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue + Safer[key] = Buffer[key] + } + + safer.Buffer.prototype = Buffer.prototype + + if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) + } + if (value && typeof value.length === 'undefined') { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) + } + return Buffer(value, encodingOrOffset, length) + } + } + + if (!Safer.alloc) { + Safer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) + } + if (size < 0 || size >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + var buf = Buffer(size) + if (!fill || fill.length === 0) { + buf.fill(0) + } else if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + return buf + } + } + + if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process.binding('buffer').kStringMaxLength + } catch (e) { + // we can't determine kStringMaxLength in environments where process.binding + // is unsupported, so let's not set it + } + } + + if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + } + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength + } + } + + module.exports = safer + + }).call(this)}).call(this,require('_process')) + },{"_process":353,"buffer":266}],124:[function(require,module,exports){ + module.exports = require('./lib')(require('./lib/elliptic')) + + },{"./lib":126,"./lib/elliptic":125}],125:[function(require,module,exports){ + const EC = require('elliptic').ec + + const ec = new EC('secp256k1') + const ecparams = ec.curve + + // Hack, we can not use bn.js@5, while elliptic uses bn.js@4 + // See https://github.com/indutny/elliptic/issues/191#issuecomment-569888758 + const BN = ecparams.n.constructor + + function loadCompressedPublicKey (first, xbuf) { + let x = new BN(xbuf) + + // overflow + if (x.cmp(ecparams.p) >= 0) return null + x = x.toRed(ecparams.red) + + // compute corresponding Y + let y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() + if ((first === 0x03) !== y.isOdd()) y = y.redNeg() + + return ec.keyPair({ pub: { x: x, y: y } }) + } + + function loadUncompressedPublicKey (first, xbuf, ybuf) { + let x = new BN(xbuf) + let y = new BN(ybuf) + + // overflow + if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null + + x = x.toRed(ecparams.red) + y = y.toRed(ecparams.red) + + // is odd flag + if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null + + // x*x*x + b = y*y + const x3 = x.redSqr().redIMul(x) + if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null + + return ec.keyPair({ pub: { x: x, y: y } }) + } + + function loadPublicKey (pubkey) { + // length should be validated in interface + const first = pubkey[0] + switch (first) { + case 0x02: + case 0x03: + if (pubkey.length !== 33) return null + return loadCompressedPublicKey(first, pubkey.subarray(1, 33)) + case 0x04: + case 0x06: + case 0x07: + if (pubkey.length !== 65) return null + return loadUncompressedPublicKey(first, pubkey.subarray(1, 33), pubkey.subarray(33, 65)) + default: + return null + } + } + + function savePublicKey (output, point) { + const pubkey = point.encode(null, output.length === 33) + // Loop should be faster because we do not need create extra Uint8Array + // output.set(new Uint8Array(pubkey)) + for (let i = 0; i < output.length; ++i) output[i] = pubkey[i] + } + + module.exports = { + contextRandomize () { + return 0 + }, + + privateKeyVerify (seckey) { + const bn = new BN(seckey) + return bn.cmp(ecparams.n) < 0 && !bn.isZero() ? 0 : 1 + }, + + privateKeyNegate (seckey) { + const bn = new BN(seckey) + const negate = ecparams.n.sub(bn).umod(ecparams.n).toArrayLike(Uint8Array, 'be', 32) + seckey.set(negate) + return 0 + }, + + privateKeyTweakAdd (seckey, tweak) { + const bn = new BN(tweak) + if (bn.cmp(ecparams.n) >= 0) return 1 + + bn.iadd(new BN(seckey)) + if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n) + if (bn.isZero()) return 1 + + const tweaked = bn.toArrayLike(Uint8Array, 'be', 32) + seckey.set(tweaked) + + return 0 + }, + + privateKeyTweakMul (seckey, tweak) { + let bn = new BN(tweak) + if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) return 1 + + bn.imul(new BN(seckey)) + if (bn.cmp(ecparams.n) >= 0) bn = bn.umod(ecparams.n) + + const tweaked = bn.toArrayLike(Uint8Array, 'be', 32) + seckey.set(tweaked) + + return 0 + }, + + publicKeyVerify (pubkey) { + const pair = loadPublicKey(pubkey) + return pair === null ? 1 : 0 + }, + + publicKeyCreate (output, seckey) { + const bn = new BN(seckey) + if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) return 1 + + const point = ec.keyFromPrivate(seckey).getPublic() + savePublicKey(output, point) + + return 0 + }, + + publicKeyConvert (output, pubkey) { + const pair = loadPublicKey(pubkey) + if (pair === null) return 1 + + const point = pair.getPublic() + savePublicKey(output, point) + + return 0 + }, + + publicKeyNegate (output, pubkey) { + const pair = loadPublicKey(pubkey) + if (pair === null) return 1 + + const point = pair.getPublic() + point.y = point.y.redNeg() + savePublicKey(output, point) + + return 0 + }, + + publicKeyCombine (output, pubkeys) { + const pairs = new Array(pubkeys.length) + for (let i = 0; i < pubkeys.length; ++i) { + pairs[i] = loadPublicKey(pubkeys[i]) + if (pairs[i] === null) return 1 + } + + let point = pairs[0].getPublic() + for (let i = 1; i < pairs.length; ++i) point = point.add(pairs[i].pub) + if (point.isInfinity()) return 2 + + savePublicKey(output, point) + + return 0 + }, + + publicKeyTweakAdd (output, pubkey, tweak) { + const pair = loadPublicKey(pubkey) + if (pair === null) return 1 + + tweak = new BN(tweak) + if (tweak.cmp(ecparams.n) >= 0) return 2 + + const point = pair.getPublic().add(ecparams.g.mul(tweak)) + if (point.isInfinity()) return 2 + + savePublicKey(output, point) + + return 0 + }, + + publicKeyTweakMul (output, pubkey, tweak) { + const pair = loadPublicKey(pubkey) + if (pair === null) return 1 + + tweak = new BN(tweak) + if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) return 2 + + const point = pair.getPublic().mul(tweak) + savePublicKey(output, point) + + return 0 + }, + + signatureNormalize (sig) { + const r = new BN(sig.subarray(0, 32)) + const s = new BN(sig.subarray(32, 64)) + if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) return 1 + + if (s.cmp(ec.nh) === 1) { + sig.set(ecparams.n.sub(s).toArrayLike(Uint8Array, 'be', 32), 32) + } + + return 0 + }, + + // Copied 1-to-1 from https://github.com/bitcoinjs/bip66/blob/master/index.js + // Adapted for Uint8Array instead Buffer + signatureExport (obj, sig) { + const sigR = sig.subarray(0, 32) + const sigS = sig.subarray(32, 64) + if (new BN(sigR).cmp(ecparams.n) >= 0) return 1 + if (new BN(sigS).cmp(ecparams.n) >= 0) return 1 + + const { output } = obj + + // Prepare R + let r = output.subarray(4, 4 + 33) + r[0] = 0x00 + r.set(sigR, 1) + + let lenR = 33 + let posR = 0 + for (; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR); + + r = r.subarray(posR) + if (r[0] & 0x80) return 1 + if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) return 1 + + // Prepare S + let s = output.subarray(6 + 33, 6 + 33 + 33) + s[0] = 0x00 + s.set(sigS, 1) + + let lenS = 33 + let posS = 0 + for (; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS); + + s = s.subarray(posS) + if (s[0] & 0x80) return 1 + if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) return 1 + + // Set output length for return + obj.outputlen = 6 + lenR + lenS + + // Output in specified format + // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] + output[0] = 0x30 + output[1] = obj.outputlen - 2 + output[2] = 0x02 + output[3] = r.length + output.set(r, 4) + output[4 + lenR] = 0x02 + output[5 + lenR] = s.length + output.set(s, 6 + lenR) + + return 0 + }, + + // Copied 1-to-1 from https://github.com/bitcoinjs/bip66/blob/master/index.js + // Adapted for Uint8Array instead Buffer + signatureImport (output, sig) { + if (sig.length < 8) return 1 + if (sig.length > 72) return 1 + if (sig[0] !== 0x30) return 1 + if (sig[1] !== sig.length - 2) return 1 + if (sig[2] !== 0x02) return 1 + + const lenR = sig[3] + if (lenR === 0) return 1 + if (5 + lenR >= sig.length) return 1 + if (sig[4 + lenR] !== 0x02) return 1 + + const lenS = sig[5 + lenR] + if (lenS === 0) return 1 + if ((6 + lenR + lenS) !== sig.length) return 1 + + if (sig[4] & 0x80) return 1 + if (lenR > 1 && (sig[4] === 0x00) && !(sig[5] & 0x80)) return 1 + + if (sig[lenR + 6] & 0x80) return 1 + if (lenS > 1 && (sig[lenR + 6] === 0x00) && !(sig[lenR + 7] & 0x80)) return 1 + + let sigR = sig.subarray(4, 4 + lenR) + if (sigR.length === 33 && sigR[0] === 0x00) sigR = sigR.subarray(1) + if (sigR.length > 32) return 1 + + let sigS = sig.subarray(6 + lenR) + if (sigS.length === 33 && sigS[0] === 0x00) sigS = sigS.slice(1) + if (sigS.length > 32) throw new Error('S length is too long') + + let r = new BN(sigR) + if (r.cmp(ecparams.n) >= 0) r = new BN(0) + + let s = new BN(sig.subarray(6 + lenR)) + if (s.cmp(ecparams.n) >= 0) s = new BN(0) + + output.set(r.toArrayLike(Uint8Array, 'be', 32), 0) + output.set(s.toArrayLike(Uint8Array, 'be', 32), 32) + + return 0 + }, + + ecdsaSign (obj, message, seckey, data, noncefn) { + if (noncefn) { + const _noncefn = noncefn + noncefn = (counter) => { + const nonce = _noncefn(message, seckey, null, data, counter) + + const isValid = nonce instanceof Uint8Array && nonce.length === 32 + if (!isValid) throw new Error('This is the way') + + return new BN(nonce) + } + } + + const d = new BN(seckey) + if (d.cmp(ecparams.n) >= 0 || d.isZero()) return 1 + + let sig + try { + sig = ec.sign(message, seckey, { canonical: true, k: noncefn, pers: data }) + } catch (err) { + return 1 + } + + obj.signature.set(sig.r.toArrayLike(Uint8Array, 'be', 32), 0) + obj.signature.set(sig.s.toArrayLike(Uint8Array, 'be', 32), 32) + obj.recid = sig.recoveryParam + + return 0 + }, + + ecdsaVerify (sig, msg32, pubkey) { + const sigObj = { r: sig.subarray(0, 32), s: sig.subarray(32, 64) } + + const sigr = new BN(sigObj.r) + const sigs = new BN(sigObj.s) + if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1 + if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return 3 + + const pair = loadPublicKey(pubkey) + if (pair === null) return 2 + + const point = pair.getPublic() + const isValid = ec.verify(msg32, sigObj, point) + return isValid ? 0 : 3 + }, + + ecdsaRecover (output, sig, recid, msg32) { + const sigObj = { r: sig.slice(0, 32), s: sig.slice(32, 64) } + + const sigr = new BN(sigObj.r) + const sigs = new BN(sigObj.s) + if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1 + + if (sigr.isZero() || sigs.isZero()) return 2 + + // Can throw `throw new Error('Unable to find sencond key candinate');` + let point + try { + point = ec.recoverPubKey(msg32, sigObj, recid) + } catch (err) { + return 2 + } + + savePublicKey(output, point) + + return 0 + }, + + ecdh (output, pubkey, seckey, data, hashfn, xbuf, ybuf) { + const pair = loadPublicKey(pubkey) + if (pair === null) return 1 + + const scalar = new BN(seckey) + if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) return 2 + + const point = pair.getPublic().mul(scalar) + + if (hashfn === undefined) { + const data = point.encode(null, true) + const sha256 = ec.hash().update(data).digest() + for (let i = 0; i < 32; ++i) output[i] = sha256[i] + } else { + if (!xbuf) xbuf = new Uint8Array(32) + const x = point.getX().toArray('be', 32) + for (let i = 0; i < 32; ++i) xbuf[i] = x[i] + + if (!ybuf) ybuf = new Uint8Array(32) + const y = point.getY().toArray('be', 32) + for (let i = 0; i < 32; ++i) ybuf[i] = y[i] + + const hash = hashfn(xbuf, ybuf, data) + + const isValid = hash instanceof Uint8Array && hash.length === output.length + if (!isValid) return 2 + + output.set(hash) + } + + return 0 + } + } + + },{"elliptic":56}],126:[function(require,module,exports){ + const errors = { + IMPOSSIBLE_CASE: 'Impossible case. Please create issue.', + TWEAK_ADD: + 'The tweak was out of range or the resulted private key is invalid', + TWEAK_MUL: 'The tweak was out of range or equal to zero', + CONTEXT_RANDOMIZE_UNKNOW: 'Unknow error on context randomization', + SECKEY_INVALID: 'Private Key is invalid', + PUBKEY_PARSE: 'Public Key could not be parsed', + PUBKEY_SERIALIZE: 'Public Key serialization error', + PUBKEY_COMBINE: 'The sum of the public keys is not valid', + SIG_PARSE: 'Signature could not be parsed', + SIGN: 'The nonce generation function failed, or the private key was invalid', + RECOVER: 'Public key could not be recover', + ECDH: 'Scalar was invalid (zero or overflow)' + } + + function assert (cond, msg) { + if (!cond) throw new Error(msg) + } + + function isUint8Array (name, value, length) { + assert(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`) + + if (length !== undefined) { + if (Array.isArray(length)) { + const numbers = length.join(', ') + const msg = `Expected ${name} to be an Uint8Array with length [${numbers}]` + assert(length.includes(value.length), msg) + } else { + const msg = `Expected ${name} to be an Uint8Array with length ${length}` + assert(value.length === length, msg) + } + } + } + + function isCompressed (value) { + assert(toTypeString(value) === 'Boolean', 'Expected compressed to be a Boolean') + } + + function getAssertedOutput (output = (len) => new Uint8Array(len), length) { + if (typeof output === 'function') output = output(length) + isUint8Array('output', output, length) + return output + } + + function toTypeString (value) { + return Object.prototype.toString.call(value).slice(8, -1) + } + + module.exports = (secp256k1) => { + return { + contextRandomize (seed) { + assert( + seed === null || seed instanceof Uint8Array, + 'Expected seed to be an Uint8Array or null' + ) + if (seed !== null) isUint8Array('seed', seed, 32) + + switch (secp256k1.contextRandomize(seed)) { + case 1: + throw new Error(errors.CONTEXT_RANDOMIZE_UNKNOW) + } + }, + + privateKeyVerify (seckey) { + isUint8Array('private key', seckey, 32) + + return secp256k1.privateKeyVerify(seckey) === 0 + }, + + privateKeyNegate (seckey) { + isUint8Array('private key', seckey, 32) + + switch (secp256k1.privateKeyNegate(seckey)) { + case 0: + return seckey + case 1: + throw new Error(errors.IMPOSSIBLE_CASE) + } + }, + + privateKeyTweakAdd (seckey, tweak) { + isUint8Array('private key', seckey, 32) + isUint8Array('tweak', tweak, 32) + + switch (secp256k1.privateKeyTweakAdd(seckey, tweak)) { + case 0: + return seckey + case 1: + throw new Error(errors.TWEAK_ADD) + } + }, + + privateKeyTweakMul (seckey, tweak) { + isUint8Array('private key', seckey, 32) + isUint8Array('tweak', tweak, 32) + + switch (secp256k1.privateKeyTweakMul(seckey, tweak)) { + case 0: + return seckey + case 1: + throw new Error(errors.TWEAK_MUL) + } + }, + + publicKeyVerify (pubkey) { + isUint8Array('public key', pubkey, [33, 65]) + + return secp256k1.publicKeyVerify(pubkey) === 0 + }, + + publicKeyCreate (seckey, compressed = true, output) { + isUint8Array('private key', seckey, 32) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyCreate(output, seckey)) { + case 0: + return output + case 1: + throw new Error(errors.SECKEY_INVALID) + case 2: + throw new Error(errors.PUBKEY_SERIALIZE) + } + }, + + publicKeyConvert (pubkey, compressed = true, output) { + isUint8Array('public key', pubkey, [33, 65]) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyConvert(output, pubkey)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.PUBKEY_SERIALIZE) + } + }, + + publicKeyNegate (pubkey, compressed = true, output) { + isUint8Array('public key', pubkey, [33, 65]) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyNegate(output, pubkey)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.IMPOSSIBLE_CASE) + case 3: + throw new Error(errors.PUBKEY_SERIALIZE) + } + }, + + publicKeyCombine (pubkeys, compressed = true, output) { + assert(Array.isArray(pubkeys), 'Expected public keys to be an Array') + assert(pubkeys.length > 0, 'Expected public keys array will have more than zero items') + for (const pubkey of pubkeys) { + isUint8Array('public key', pubkey, [33, 65]) + } + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyCombine(output, pubkeys)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.PUBKEY_COMBINE) + case 3: + throw new Error(errors.PUBKEY_SERIALIZE) + } + }, + + publicKeyTweakAdd (pubkey, tweak, compressed = true, output) { + isUint8Array('public key', pubkey, [33, 65]) + isUint8Array('tweak', tweak, 32) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyTweakAdd(output, pubkey, tweak)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.TWEAK_ADD) + } + }, + + publicKeyTweakMul (pubkey, tweak, compressed = true, output) { + isUint8Array('public key', pubkey, [33, 65]) + isUint8Array('tweak', tweak, 32) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.publicKeyTweakMul(output, pubkey, tweak)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.TWEAK_MUL) + } + }, + + signatureNormalize (sig) { + isUint8Array('signature', sig, 64) + + switch (secp256k1.signatureNormalize(sig)) { + case 0: + return sig + case 1: + throw new Error(errors.SIG_PARSE) + } + }, + + signatureExport (sig, output) { + isUint8Array('signature', sig, 64) + output = getAssertedOutput(output, 72) + + const obj = { output, outputlen: 72 } + switch (secp256k1.signatureExport(obj, sig)) { + case 0: + return output.slice(0, obj.outputlen) + case 1: + throw new Error(errors.SIG_PARSE) + case 2: + throw new Error(errors.IMPOSSIBLE_CASE) + } + }, + + signatureImport (sig, output) { + isUint8Array('signature', sig) + output = getAssertedOutput(output, 64) + + switch (secp256k1.signatureImport(output, sig)) { + case 0: + return output + case 1: + throw new Error(errors.SIG_PARSE) + case 2: + throw new Error(errors.IMPOSSIBLE_CASE) + } + }, + + ecdsaSign (msg32, seckey, options = {}, output) { + isUint8Array('message', msg32, 32) + isUint8Array('private key', seckey, 32) + assert(toTypeString(options) === 'Object', 'Expected options to be an Object') + if (options.data !== undefined) isUint8Array('options.data', options.data) + if (options.noncefn !== undefined) assert(toTypeString(options.noncefn) === 'Function', 'Expected options.noncefn to be a Function') + output = getAssertedOutput(output, 64) + + const obj = { signature: output, recid: null } + switch (secp256k1.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) { + case 0: + return obj + case 1: + throw new Error(errors.SIGN) + case 2: + throw new Error(errors.IMPOSSIBLE_CASE) + } + }, + + ecdsaVerify (sig, msg32, pubkey) { + isUint8Array('signature', sig, 64) + isUint8Array('message', msg32, 32) + isUint8Array('public key', pubkey, [33, 65]) + + switch (secp256k1.ecdsaVerify(sig, msg32, pubkey)) { + case 0: + return true + case 3: + return false + case 1: + throw new Error(errors.SIG_PARSE) + case 2: + throw new Error(errors.PUBKEY_PARSE) + } + }, + + ecdsaRecover (sig, recid, msg32, compressed = true, output) { + isUint8Array('signature', sig, 64) + assert( + toTypeString(recid) === 'Number' && + recid >= 0 && + recid <= 3, + 'Expected recovery id to be a Number within interval [0, 3]' + ) + isUint8Array('message', msg32, 32) + isCompressed(compressed) + output = getAssertedOutput(output, compressed ? 33 : 65) + + switch (secp256k1.ecdsaRecover(output, sig, recid, msg32)) { + case 0: + return output + case 1: + throw new Error(errors.SIG_PARSE) + case 2: + throw new Error(errors.RECOVER) + case 3: + throw new Error(errors.IMPOSSIBLE_CASE) + } + }, + + ecdh (pubkey, seckey, options = {}, output) { + isUint8Array('public key', pubkey, [33, 65]) + isUint8Array('private key', seckey, 32) + assert(toTypeString(options) === 'Object', 'Expected options to be an Object') + if (options.data !== undefined) isUint8Array('options.data', options.data) + if (options.hashfn !== undefined) { + assert(toTypeString(options.hashfn) === 'Function', 'Expected options.hashfn to be a Function') + if (options.xbuf !== undefined) isUint8Array('options.xbuf', options.xbuf, 32) + if (options.ybuf !== undefined) isUint8Array('options.ybuf', options.ybuf, 32) + isUint8Array('output', output) + } else { + output = getAssertedOutput(output, 32) + } + + switch (secp256k1.ecdh(output, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) { + case 0: + return output + case 1: + throw new Error(errors.PUBKEY_PARSE) + case 2: + throw new Error(errors.ECDH) + } + } + } + } + + },{}],127:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + + // prototype class for hash functions + function Hash (blockSize, finalSize) { + this._block = Buffer.alloc(blockSize) + this._finalSize = finalSize + this._blockSize = blockSize + this._len = 0 + } + + Hash.prototype.update = function (data, enc) { + if (typeof data === 'string') { + enc = enc || 'utf8' + data = Buffer.from(data, enc) + } + + var block = this._block + var blockSize = this._blockSize + var length = data.length + var accum = this._len + + for (var offset = 0; offset < length;) { + var assigned = accum % blockSize + var remainder = Math.min(length - offset, blockSize - assigned) + + for (var i = 0; i < remainder; i++) { + block[assigned + i] = data[offset + i] + } + + accum += remainder + offset += remainder + + if ((accum % blockSize) === 0) { + this._update(block) + } + } + + this._len += length + return this + } + + Hash.prototype.digest = function (enc) { + var rem = this._len % this._blockSize + + this._block[rem] = 0x80 + + // zero (rem + 1) trailing bits, where (rem + 1) is the smallest + // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize + this._block.fill(0, rem + 1) + + if (rem >= this._finalSize) { + this._update(this._block) + this._block.fill(0) + } + + var bits = this._len * 8 + + // uint32 + if (bits <= 0xffffffff) { + this._block.writeUInt32BE(bits, this._blockSize - 4) + + // uint64 + } else { + var lowBits = (bits & 0xffffffff) >>> 0 + var highBits = (bits - lowBits) / 0x100000000 + + this._block.writeUInt32BE(highBits, this._blockSize - 8) + this._block.writeUInt32BE(lowBits, this._blockSize - 4) + } + + this._update(this._block) + var hash = this._hash() + + return enc ? hash.toString(enc) : hash + } + + Hash.prototype._update = function () { + throw new Error('_update must be implemented by subclass') + } + + module.exports = Hash + + },{"safe-buffer":122}],128:[function(require,module,exports){ + var exports = module.exports = function SHA (algorithm) { + algorithm = algorithm.toLowerCase() + + var Algorithm = exports[algorithm] + if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') + + return new Algorithm() + } + + exports.sha = require('./sha') + exports.sha1 = require('./sha1') + exports.sha224 = require('./sha224') + exports.sha256 = require('./sha256') + exports.sha384 = require('./sha384') + exports.sha512 = require('./sha512') + + },{"./sha":129,"./sha1":130,"./sha224":131,"./sha256":132,"./sha384":133,"./sha512":134}],129:[function(require,module,exports){ + /* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined + * in FIPS PUB 180-1 + * This source code is derived from sha1.js of the same repository. + * The difference between SHA-0 and SHA-1 is just a bitwise rotate left + * operation was added. + */ + + var inherits = require('inherits') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var K = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 + ] + + var W = new Array(80) + + function Sha () { + this.init() + this._w = W + + Hash.call(this, 64, 56) + } + + inherits(Sha, Hash) + + Sha.prototype.init = function () { + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 + + return this + } + + function rotl5 (num) { + return (num << 5) | (num >>> 27) + } + + function rotl30 (num) { + return (num << 30) | (num >>> 2) + } + + function ft (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d + } + + Sha.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20) + var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 + + e = d + d = c + c = rotl30(b) + b = a + a = t + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 + } + + Sha.prototype._hash = function () { + var H = Buffer.allocUnsafe(20) + + H.writeInt32BE(this._a | 0, 0) + H.writeInt32BE(this._b | 0, 4) + H.writeInt32BE(this._c | 0, 8) + H.writeInt32BE(this._d | 0, 12) + H.writeInt32BE(this._e | 0, 16) + + return H + } + + module.exports = Sha + + },{"./hash":127,"inherits":97,"safe-buffer":122}],130:[function(require,module,exports){ + /* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined + * in FIPS PUB 180-1 + * Version 2.1a Copyright Paul Johnston 2000 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + */ + + var inherits = require('inherits') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var K = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 + ] + + var W = new Array(80) + + function Sha1 () { + this.init() + this._w = W + + Hash.call(this, 64, 56) + } + + inherits(Sha1, Hash) + + Sha1.prototype.init = function () { + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 + + return this + } + + function rotl1 (num) { + return (num << 1) | (num >>> 31) + } + + function rotl5 (num) { + return (num << 5) | (num >>> 27) + } + + function rotl30 (num) { + return (num << 30) | (num >>> 2) + } + + function ft (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d + } + + Sha1.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20) + var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 + + e = d + d = c + c = rotl30(b) + b = a + a = t + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 + } + + Sha1.prototype._hash = function () { + var H = Buffer.allocUnsafe(20) + + H.writeInt32BE(this._a | 0, 0) + H.writeInt32BE(this._b | 0, 4) + H.writeInt32BE(this._c | 0, 8) + H.writeInt32BE(this._d | 0, 12) + H.writeInt32BE(this._e | 0, 16) + + return H + } + + module.exports = Sha1 + + },{"./hash":127,"inherits":97,"safe-buffer":122}],131:[function(require,module,exports){ + /** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + + var inherits = require('inherits') + var Sha256 = require('./sha256') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var W = new Array(64) + + function Sha224 () { + this.init() + + this._w = W // new Array(64) + + Hash.call(this, 64, 56) + } + + inherits(Sha224, Sha256) + + Sha224.prototype.init = function () { + this._a = 0xc1059ed8 + this._b = 0x367cd507 + this._c = 0x3070dd17 + this._d = 0xf70e5939 + this._e = 0xffc00b31 + this._f = 0x68581511 + this._g = 0x64f98fa7 + this._h = 0xbefa4fa4 + + return this + } + + Sha224.prototype._hash = function () { + var H = Buffer.allocUnsafe(28) + + H.writeInt32BE(this._a, 0) + H.writeInt32BE(this._b, 4) + H.writeInt32BE(this._c, 8) + H.writeInt32BE(this._d, 12) + H.writeInt32BE(this._e, 16) + H.writeInt32BE(this._f, 20) + H.writeInt32BE(this._g, 24) + + return H + } + + module.exports = Sha224 + + },{"./hash":127,"./sha256":132,"inherits":97,"safe-buffer":122}],132:[function(require,module,exports){ + /** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + + var inherits = require('inherits') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var K = [ + 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, + 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, + 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, + 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, + 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, + 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, + 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, + 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, + 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, + 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, + 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, + 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, + 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, + 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, + 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, + 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 + ] + + var W = new Array(64) + + function Sha256 () { + this.init() + + this._w = W // new Array(64) + + Hash.call(this, 64, 56) + } + + inherits(Sha256, Hash) + + Sha256.prototype.init = function () { + this._a = 0x6a09e667 + this._b = 0xbb67ae85 + this._c = 0x3c6ef372 + this._d = 0xa54ff53a + this._e = 0x510e527f + this._f = 0x9b05688c + this._g = 0x1f83d9ab + this._h = 0x5be0cd19 + + return this + } + + function ch (x, y, z) { + return z ^ (x & (y ^ z)) + } + + function maj (x, y, z) { + return (x & y) | (z & (x | y)) + } + + function sigma0 (x) { + return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) + } + + function sigma1 (x) { + return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) + } + + function gamma0 (x) { + return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) + } + + function gamma1 (x) { + return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) + } + + Sha256.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + var f = this._f | 0 + var g = this._g | 0 + var h = this._h | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 + + for (var j = 0; j < 64; ++j) { + var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 + var T2 = (sigma0(a) + maj(a, b, c)) | 0 + + h = g + g = f + f = e + e = (d + T1) | 0 + d = c + c = b + b = a + a = (T1 + T2) | 0 + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 + this._f = (f + this._f) | 0 + this._g = (g + this._g) | 0 + this._h = (h + this._h) | 0 + } + + Sha256.prototype._hash = function () { + var H = Buffer.allocUnsafe(32) + + H.writeInt32BE(this._a, 0) + H.writeInt32BE(this._b, 4) + H.writeInt32BE(this._c, 8) + H.writeInt32BE(this._d, 12) + H.writeInt32BE(this._e, 16) + H.writeInt32BE(this._f, 20) + H.writeInt32BE(this._g, 24) + H.writeInt32BE(this._h, 28) + + return H + } + + module.exports = Sha256 + + },{"./hash":127,"inherits":97,"safe-buffer":122}],133:[function(require,module,exports){ + var inherits = require('inherits') + var SHA512 = require('./sha512') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var W = new Array(160) + + function Sha384 () { + this.init() + this._w = W + + Hash.call(this, 128, 112) + } + + inherits(Sha384, SHA512) + + Sha384.prototype.init = function () { + this._ah = 0xcbbb9d5d + this._bh = 0x629a292a + this._ch = 0x9159015a + this._dh = 0x152fecd8 + this._eh = 0x67332667 + this._fh = 0x8eb44a87 + this._gh = 0xdb0c2e0d + this._hh = 0x47b5481d + + this._al = 0xc1059ed8 + this._bl = 0x367cd507 + this._cl = 0x3070dd17 + this._dl = 0xf70e5939 + this._el = 0xffc00b31 + this._fl = 0x68581511 + this._gl = 0x64f98fa7 + this._hl = 0xbefa4fa4 + + return this + } + + Sha384.prototype._hash = function () { + var H = Buffer.allocUnsafe(48) + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset) + H.writeInt32BE(l, offset + 4) + } + + writeInt64BE(this._ah, this._al, 0) + writeInt64BE(this._bh, this._bl, 8) + writeInt64BE(this._ch, this._cl, 16) + writeInt64BE(this._dh, this._dl, 24) + writeInt64BE(this._eh, this._el, 32) + writeInt64BE(this._fh, this._fl, 40) + + return H + } + + module.exports = Sha384 + + },{"./hash":127,"./sha512":134,"inherits":97,"safe-buffer":122}],134:[function(require,module,exports){ + var inherits = require('inherits') + var Hash = require('./hash') + var Buffer = require('safe-buffer').Buffer + + var K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 + ] + + var W = new Array(160) + + function Sha512 () { + this.init() + this._w = W + + Hash.call(this, 128, 112) + } + + inherits(Sha512, Hash) + + Sha512.prototype.init = function () { + this._ah = 0x6a09e667 + this._bh = 0xbb67ae85 + this._ch = 0x3c6ef372 + this._dh = 0xa54ff53a + this._eh = 0x510e527f + this._fh = 0x9b05688c + this._gh = 0x1f83d9ab + this._hh = 0x5be0cd19 + + this._al = 0xf3bcc908 + this._bl = 0x84caa73b + this._cl = 0xfe94f82b + this._dl = 0x5f1d36f1 + this._el = 0xade682d1 + this._fl = 0x2b3e6c1f + this._gl = 0xfb41bd6b + this._hl = 0x137e2179 + + return this + } + + function Ch (x, y, z) { + return z ^ (x & (y ^ z)) + } + + function maj (x, y, z) { + return (x & y) | (z & (x | y)) + } + + function sigma0 (x, xl) { + return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) + } + + function sigma1 (x, xl) { + return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) + } + + function Gamma0 (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) + } + + function Gamma0l (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) + } + + function Gamma1 (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) + } + + function Gamma1l (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) + } + + function getCarry (a, b) { + return (a >>> 0) < (b >>> 0) ? 1 : 0 + } + + Sha512.prototype._update = function (M) { + var W = this._w + + var ah = this._ah | 0 + var bh = this._bh | 0 + var ch = this._ch | 0 + var dh = this._dh | 0 + var eh = this._eh | 0 + var fh = this._fh | 0 + var gh = this._gh | 0 + var hh = this._hh | 0 + + var al = this._al | 0 + var bl = this._bl | 0 + var cl = this._cl | 0 + var dl = this._dl | 0 + var el = this._el | 0 + var fl = this._fl | 0 + var gl = this._gl | 0 + var hl = this._hl | 0 + + for (var i = 0; i < 32; i += 2) { + W[i] = M.readInt32BE(i * 4) + W[i + 1] = M.readInt32BE(i * 4 + 4) + } + for (; i < 160; i += 2) { + var xh = W[i - 15 * 2] + var xl = W[i - 15 * 2 + 1] + var gamma0 = Gamma0(xh, xl) + var gamma0l = Gamma0l(xl, xh) + + xh = W[i - 2 * 2] + xl = W[i - 2 * 2 + 1] + var gamma1 = Gamma1(xh, xl) + var gamma1l = Gamma1l(xl, xh) + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7h = W[i - 7 * 2] + var Wi7l = W[i - 7 * 2 + 1] + + var Wi16h = W[i - 16 * 2] + var Wi16l = W[i - 16 * 2 + 1] + + var Wil = (gamma0l + Wi7l) | 0 + var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 + Wil = (Wil + gamma1l) | 0 + Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 + Wil = (Wil + Wi16l) | 0 + Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 + + W[i] = Wih + W[i + 1] = Wil + } + + for (var j = 0; j < 160; j += 2) { + Wih = W[j] + Wil = W[j + 1] + + var majh = maj(ah, bh, ch) + var majl = maj(al, bl, cl) + + var sigma0h = sigma0(ah, al) + var sigma0l = sigma0(al, ah) + var sigma1h = sigma1(eh, el) + var sigma1l = sigma1(el, eh) + + // t1 = h + sigma1 + ch + K[j] + W[j] + var Kih = K[j] + var Kil = K[j + 1] + + var chh = Ch(eh, fh, gh) + var chl = Ch(el, fl, gl) + + var t1l = (hl + sigma1l) | 0 + var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 + t1l = (t1l + chl) | 0 + t1h = (t1h + chh + getCarry(t1l, chl)) | 0 + t1l = (t1l + Kil) | 0 + t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 + t1l = (t1l + Wil) | 0 + t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 + + // t2 = sigma0 + maj + var t2l = (sigma0l + majl) | 0 + var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 + + hh = gh + hl = gl + gh = fh + gl = fl + fh = eh + fl = el + el = (dl + t1l) | 0 + eh = (dh + t1h + getCarry(el, dl)) | 0 + dh = ch + dl = cl + ch = bh + cl = bl + bh = ah + bl = al + al = (t1l + t2l) | 0 + ah = (t1h + t2h + getCarry(al, t1l)) | 0 + } + + this._al = (this._al + al) | 0 + this._bl = (this._bl + bl) | 0 + this._cl = (this._cl + cl) | 0 + this._dl = (this._dl + dl) | 0 + this._el = (this._el + el) | 0 + this._fl = (this._fl + fl) | 0 + this._gl = (this._gl + gl) | 0 + this._hl = (this._hl + hl) | 0 + + this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 + this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 + this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 + this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 + this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 + this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 + this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 + this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 + } + + Sha512.prototype._hash = function () { + var H = Buffer.allocUnsafe(64) + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset) + H.writeInt32BE(l, offset + 4) + } + + writeInt64BE(this._ah, this._al, 0) + writeInt64BE(this._bh, this._bl, 8) + writeInt64BE(this._ch, this._cl, 16) + writeInt64BE(this._dh, this._dl, 24) + writeInt64BE(this._eh, this._el, 32) + writeInt64BE(this._fh, this._fl, 40) + writeInt64BE(this._gh, this._gl, 48) + writeInt64BE(this._hh, this._hl, 56) + + return H + } + + module.exports = Sha512 + + },{"./hash":127,"inherits":97,"safe-buffer":122}],135:[function(require,module,exports){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + 'use strict'; + + /**/ + + var Buffer = require('safe-buffer').Buffer; + /**/ + + var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } + }; + + function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } + }; + + // Do not cache `Buffer.isEncoding` when checking encoding names as some + // modules monkey-patch it to support additional encodings + function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; + } + + // StringDecoder provides an interface for efficiently splitting a series of + // buffers into a series of JS strings without breaking apart multi-byte + // characters. + exports.StringDecoder = StringDecoder; + function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); + } + + StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; + }; + + StringDecoder.prototype.end = utf8End; + + // Returns only complete characters in a Buffer + StringDecoder.prototype.text = utf8Text; + + // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer + StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; + }; + + // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a + // continuation byte. If an invalid byte is detected, -2 is returned. + function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; + } + + // Checks at most 3 bytes at the end of a Buffer in order to detect an + // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) + // needed to complete the UTF-8 character (if applicable) are returned. + function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; + } + + // Validates as many continuation bytes for a multi-byte UTF-8 character as + // needed or are available. If we see a non-continuation byte where we expect + // one, we "replace" the validated continuation bytes we've seen so far with + // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding + // behavior. The continuation byte check is included three times in the case + // where all of the continuation bytes for a character exist in the same buffer. + // It is also done this way as a slight performance increase instead of using a + // loop. + function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } + } + + // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. + function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; + } + + // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a + // partial character, the character's bytes are buffered until the required + // number of bytes are available. + function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); + } + + // For UTF-8, a replacement character is added when ending on a partial + // character. + function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; + } + + // UTF-16LE typically needs two bytes per character, but even if we have an even + // number of bytes available, we need to check if we end on a leading/high + // surrogate. In that case, we need to wait for the next two bytes in order to + // decode the last character properly. + function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); + } + + // For UTF-16LE we do not explicitly append special replacement characters if we + // end on a partial character, we simply let v8 handle that. + function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; + } + + function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); + } + + function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; + } + + // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) + function simpleWrite(buf) { + return buf.toString(this.encoding); + } + + function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; + } + },{"safe-buffer":122}],136:[function(require,module,exports){ + (function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "tslib", "./result", "./option"], factory); + } + })(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var tslib_1 = require("tslib"); + tslib_1.__exportStar(require("./result"), exports); + tslib_1.__exportStar(require("./option"), exports); + }); + + },{"./option":137,"./result":138,"tslib":140}],137:[function(require,module,exports){ + (function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "./utils"], factory); + } + })(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Option = exports.Some = exports.None = void 0; + var utils_1 = require("./utils"); + /** + * Contains the None value + */ + var NoneImpl = /** @class */ (function () { + function NoneImpl() { + this.some = false; + this.none = true; + } + NoneImpl.prototype[Symbol.iterator] = function () { + return { + next: function () { + return { done: true, value: undefined }; + }, + }; + }; + NoneImpl.prototype.unwrapOr = function (val) { + return val; + }; + NoneImpl.prototype.expect = function (msg) { + throw new Error("" + msg); + }; + NoneImpl.prototype.unwrap = function () { + throw new Error("Tried to unwrap None"); + }; + NoneImpl.prototype.map = function (_mapper) { + return this; + }; + NoneImpl.prototype.andThen = function (op) { + return this; + }; + NoneImpl.prototype.toString = function () { + return 'None'; + }; + return NoneImpl; + }()); + // Export None as a singleton, then freeze it so it can't be modified + exports.None = new NoneImpl(); + Object.freeze(exports.None); + /** + * Contains the success value + */ + var SomeImpl = /** @class */ (function () { + function SomeImpl(val) { + if (!(this instanceof SomeImpl)) { + return new SomeImpl(val); + } + this.some = true; + this.none = false; + this.val = val; + } + /** + * Helper function if you know you have an Some and T is iterable + */ + SomeImpl.prototype[Symbol.iterator] = function () { + var obj = Object(this.val); + return Symbol.iterator in obj + ? obj[Symbol.iterator]() + : { + next: function () { + return { done: true, value: undefined }; + }, + }; + }; + SomeImpl.prototype.unwrapOr = function (_val) { + return this.val; + }; + SomeImpl.prototype.expect = function (_msg) { + return this.val; + }; + SomeImpl.prototype.unwrap = function () { + return this.val; + }; + SomeImpl.prototype.map = function (mapper) { + return exports.Some(mapper(this.val)); + }; + SomeImpl.prototype.andThen = function (mapper) { + return mapper(this.val); + }; + /** + * Returns the contained `Some` value, but never throws. + * Unlike `unwrap()`, this method doesn't throw and is only callable on an Some + * + * Therefore, it can be used instead of `unwrap()` as a maintainability safeguard + * that will fail to compile if the type of the Option is later changed to a None that can actually occur. + * + * (this is the `into_Some()` in rust) + */ + SomeImpl.prototype.safeUnwrap = function () { + return this.val; + }; + SomeImpl.prototype.toString = function () { + return "Some(" + utils_1.toString(this.val) + ")"; + }; + SomeImpl.EMPTY = new SomeImpl(undefined); + return SomeImpl; + }()); + // This allows Some to be callable - possible because of the es5 compilation target + exports.Some = SomeImpl; + var Option; + (function (Option) { + /** + * Parse a set of `Option`s, returning an array of all `Some` values. + * Short circuits with the first `None` found, if any + */ + function all() { + var options = []; + for (var _i = 0; _i < arguments.length; _i++) { + options[_i] = arguments[_i]; + } + var someOption = []; + for (var _a = 0, options_1 = options; _a < options_1.length; _a++) { + var option = options_1[_a]; + if (option.some) { + someOption.push(option.val); + } + else { + return option; + } + } + return exports.Some(someOption); + } + Option.all = all; + /** + * Parse a set of `Option`s, short-circuits when an input value is `Some`. + * If no `Some` is found, returns `None`. + */ + function any() { + var options = []; + for (var _i = 0; _i < arguments.length; _i++) { + options[_i] = arguments[_i]; + } + // short-circuits + for (var _a = 0, options_2 = options; _a < options_2.length; _a++) { + var option = options_2[_a]; + if (option.some) { + return option; + } + else { + return option; + } + } + // it must be None + return exports.None; + } + Option.any = any; + function isOption(value) { + return value instanceof exports.Some || value === exports.None; + } + Option.isOption = isOption; + })(Option = exports.Option || (exports.Option = {})); + }); + + },{"./utils":139}],138:[function(require,module,exports){ + (function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "./utils"], factory); + } + })(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Result = exports.Ok = exports.OkImpl = exports.Err = exports.ErrImpl = void 0; + var utils_1 = require("./utils"); + /** + * Contains the error value + */ + var ErrImpl = /** @class */ (function () { + function ErrImpl(val) { + if (!(this instanceof ErrImpl)) { + return new ErrImpl(val); + } + this.ok = false; + this.err = true; + this.val = val; + } + ErrImpl.prototype[Symbol.iterator] = function () { + return { + next: function () { + return { done: true, value: undefined }; + }, + }; + }; + /** + * @deprecated in favor of unwrapOr + * @see unwrapOr + */ + ErrImpl.prototype.else = function (val) { + return val; + }; + ErrImpl.prototype.unwrapOr = function (val) { + return val; + }; + ErrImpl.prototype.expect = function (msg) { + throw new Error(msg + " - Error: " + utils_1.toString(this.val)); + }; + ErrImpl.prototype.unwrap = function () { + throw new Error("Tried to unwrap Error: " + utils_1.toString(this.val)); + }; + ErrImpl.prototype.map = function (_mapper) { + return this; + }; + ErrImpl.prototype.andThen = function (op) { + return this; + }; + ErrImpl.prototype.mapErr = function (mapper) { + return new exports.Err(mapper(this.val)); + }; + ErrImpl.prototype.toString = function () { + return "Err(" + utils_1.toString(this.val) + ")"; + }; + /** An empty Err */ + ErrImpl.EMPTY = new ErrImpl(undefined); + return ErrImpl; + }()); + exports.ErrImpl = ErrImpl; + // This allows Err to be callable - possible because of the es5 compilation target + exports.Err = ErrImpl; + /** + * Contains the success value + */ + var OkImpl = /** @class */ (function () { + function OkImpl(val) { + if (!(this instanceof OkImpl)) { + return new OkImpl(val); + } + this.ok = true; + this.err = false; + this.val = val; + } + /** + * Helper function if you know you have an Ok and T is iterable + */ + OkImpl.prototype[Symbol.iterator] = function () { + var obj = Object(this.val); + return Symbol.iterator in obj + ? obj[Symbol.iterator]() + : { + next: function () { + return { done: true, value: undefined }; + }, + }; + }; + /** + * @see unwrapOr + * @deprecated in favor of unwrapOr + */ + OkImpl.prototype.else = function (_val) { + return this.val; + }; + OkImpl.prototype.unwrapOr = function (_val) { + return this.val; + }; + OkImpl.prototype.expect = function (_msg) { + return this.val; + }; + OkImpl.prototype.unwrap = function () { + return this.val; + }; + OkImpl.prototype.map = function (mapper) { + return new exports.Ok(mapper(this.val)); + }; + OkImpl.prototype.andThen = function (mapper) { + return mapper(this.val); + }; + OkImpl.prototype.mapErr = function (_mapper) { + return this; + }; + /** + * Returns the contained `Ok` value, but never throws. + * Unlike `unwrap()`, this method doesn't throw and is only callable on an Ok + * + * Therefore, it can be used instead of `unwrap()` as a maintainability safeguard + * that will fail to compile if the error type of the Result is later changed to an error that can actually occur. + * + * (this is the `into_ok()` in rust) + */ + OkImpl.prototype.safeUnwrap = function () { + return this.val; + }; + OkImpl.prototype.toString = function () { + return "Ok(" + utils_1.toString(this.val) + ")"; + }; + OkImpl.EMPTY = new OkImpl(undefined); + return OkImpl; + }()); + exports.OkImpl = OkImpl; + // This allows Ok to be callable - possible because of the es5 compilation target + exports.Ok = OkImpl; + var Result; + (function (Result) { + /** + * Parse a set of `Result`s, returning an array of all `Ok` values. + * Short circuits with the first `Err` found, if any + */ + function all() { + var results = []; + for (var _i = 0; _i < arguments.length; _i++) { + results[_i] = arguments[_i]; + } + var okResult = []; + for (var _a = 0, results_1 = results; _a < results_1.length; _a++) { + var result = results_1[_a]; + if (result.ok) { + okResult.push(result.val); + } + else { + return result; + } + } + return new exports.Ok(okResult); + } + Result.all = all; + /** + * Parse a set of `Result`s, short-circuits when an input value is `Ok`. + * If no `Ok` is found, returns an `Err` containing the collected error values + */ + function any() { + var results = []; + for (var _i = 0; _i < arguments.length; _i++) { + results[_i] = arguments[_i]; + } + var errResult = []; + // short-circuits + for (var _a = 0, results_2 = results; _a < results_2.length; _a++) { + var result = results_2[_a]; + if (result.ok) { + return result; + } + else { + errResult.push(result.val); + } + } + // it must be a Err + return new exports.Err(errResult); + } + Result.any = any; + /** + * Wrap an operation that may throw an Error (`try-catch` style) into checked exception style + * @param op The operation function + */ + function wrap(op) { + try { + return new exports.Ok(op()); + } + catch (e) { + return new exports.Err(e); + } + } + Result.wrap = wrap; + /** + * Wrap an async operation that may throw an Error (`try-catch` style) into checked exception style + * @param op The operation function + */ + function wrapAsync(op) { + try { + return op() + .then(function (val) { return new exports.Ok(val); }) + .catch(function (e) { return new exports.Err(e); }); + } + catch (e) { + return Promise.resolve(new exports.Err(e)); + } + } + Result.wrapAsync = wrapAsync; + function isResult(val) { + return val instanceof exports.Err || val instanceof exports.Ok; + } + Result.isResult = isResult; + })(Result = exports.Result || (exports.Result = {})); + }); + + },{"./utils":139}],139:[function(require,module,exports){ + (function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); + } + })(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.toString = void 0; + function toString(val) { + var value = String(val); + if (value === '[object Object]') { + try { + value = JSON.stringify(val); + } + catch (_a) { } + } + return value; + } + exports.toString = toString; + }); + + },{}],140:[function(require,module,exports){ + (function (global){(function (){ + /*! ***************************************************************************** + 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. + ***************************************************************************** */ + + /* global global, define, System, Reflect, Promise */ + var __extends; + var __assign; + var __rest; + var __decorate; + var __param; + var __metadata; + var __awaiter; + var __generator; + var __exportStar; + var __values; + var __read; + var __spread; + var __spreadArrays; + var __await; + var __asyncGenerator; + var __asyncDelegator; + var __asyncValues; + var __makeTemplateObject; + var __importStar; + var __importDefault; + var __classPrivateFieldGet; + var __classPrivateFieldSet; + var __createBinding; + (function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } + }) + (function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + + __extends = function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __awaiter = function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + + __generator = function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + + __createBinding = function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }; + + __exportStar = function (m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; + }; + + __values = function (o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + }; + + __read = function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + }; + + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + __spreadArrays = function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + __importStar = function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + __classPrivateFieldGet = function (receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + return privateMap.get(receiver); + }; + + __classPrivateFieldSet = function (receiver, privateMap, value) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + privateMap.set(receiver, value); + return value; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet); + exporter("__classPrivateFieldSet", __classPrivateFieldSet); + }); + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{}],141:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function ByteArray(n) { + return new Uint8Array(n); + } + exports.ByteArray = ByteArray; + function HalfArray(n) { + return new Uint16Array(n); + } + exports.HalfArray = HalfArray; + function WordArray(n) { + return new Uint32Array(n); + } + exports.WordArray = WordArray; + function IntArray(n) { + return new Int32Array(n); + } + exports.IntArray = IntArray; + function NumArray(n) { + return new Float64Array(n); + } + exports.NumArray = NumArray; + + },{}],142:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var hash_1 = require("./hash"); + function auth(msg, key) { + var out = array_1.ByteArray(32); + out.set(hmac(msg, key).subarray(0, 32)); + return out; + } + exports.auth = auth; + var BLOCK_SIZE = 128; + var HASH_SIZE = 64; + function hmac(msg, key) { + var buf = array_1.ByteArray(BLOCK_SIZE + Math.max(HASH_SIZE, msg.length)); + var i, innerHash; + if (key.length > BLOCK_SIZE) + key = hash_1.hash(key); + for (i = 0; i < BLOCK_SIZE; i++) + buf[i] = 0x36; + for (i = 0; i < key.length; i++) + buf[i] ^= key[i]; + buf.set(msg, BLOCK_SIZE); + innerHash = hash_1.hash(buf.subarray(0, BLOCK_SIZE + msg.length)); + for (i = 0; i < BLOCK_SIZE; i++) + buf[i] = 0x5c; + for (i = 0; i < key.length; i++) + buf[i] ^= key[i]; + buf.set(innerHash, BLOCK_SIZE); + return hash_1.hash(buf.subarray(0, BLOCK_SIZE + innerHash.length)); + } + exports.auth_full = hmac; + + },{"./array":141,"./hash":152}],143:[function(require,module,exports){ + "use strict"; + // Blake2B in pure Javascript + // Adapted from the reference implementation in RFC7693 + // Ported to Javascript by DC - https://github.com/dcposch + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + // Computes the BLAKE2B hash of a string or byte array, and returns a ByteArray + // + // Returns a n-byte ByteArray + // + // Parameters: + // - input - the input bytes, as a ByteArray + // - key - optional key ByteArray, up to 64 bytes + // - outlen - optional output length in bytes, default 64 + function blake2b(input, key, outlen) { + if (outlen === void 0) { outlen = 64; } + var ctx = blake2b_init(outlen, key); + blake2b_update(ctx, input); + return blake2b_final(ctx); + } + exports.blake2b = blake2b; + // Creates a BLAKE2b hashing context + // Requires an output length between 1 and 64 bytes + // Takes an optional ByteArray key + function blake2b_init(outlen, key) { + if (outlen === 0 || outlen > 64) + throw new Error('Illegal output length, expected 0 < length <= 64'); + if (key && key.length > 64) + throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64'); + // hash state + var h = array_1.WordArray(16); + // initialize hash state + for (var i = 0; i < 16; i++) + h[i] = BLAKE2B_IV32[i]; + var keylen = key ? key.length : 0; + h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; + // state, 'param block' + var ctx = { + b: array_1.ByteArray(128), + h: h, + t: 0, + c: 0, + outlen: outlen // output length in bytes + }; + // key the hash, if applicable + if (key) { + blake2b_update(ctx, key); + // at the end + ctx.c = 128; + } + return ctx; + } + exports.blake2b_init = blake2b_init; + // Updates a BLAKE2b streaming hash + // Requires hash context and Uint8Array (byte array) + function blake2b_update(ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c; // add counters + blake2b_compress(ctx, false); // compress (not last) + ctx.c = 0; // counter to zero + } + ctx.b[ctx.c++] = input[i]; + } + } + exports.blake2b_update = blake2b_update; + // Completes a BLAKE2b streaming hash + // Returns a Uint8Array containing the message digest + function blake2b_final(ctx) { + ctx.t += ctx.c; // mark last block offset + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0; + } + blake2b_compress(ctx, true); // final block flag = 1 + // little endian convert and store + var out = array_1.ByteArray(ctx.outlen); + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)); + } + return out; + } + exports.blake2b_final = blake2b_final; + // Initialization Vector + var BLAKE2B_IV32 = array_1.WordArray([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 + ]); + var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 + ]; + // These are offsets into a uint64 buffer. + // Multiply them all by 2 to make them offsets into a uint32 buffer, + // because this is Javascript and we don't have uint64s + var SIGMA82 = array_1.ByteArray(SIGMA8.map(function (x) { return x * 2; })); + // Compression function. 'last' flag indicates last block. + // Note we're representing 16 uint64s as 32 uint32s + var v = array_1.WordArray(32); + var m = array_1.WordArray(32); + function blake2b_compress(ctx, last) { + var i; + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i]; + v[i + 16] = BLAKE2B_IV32[i]; + } + // low 64 bits of offset + v[24] = v[24] ^ ctx.t; + v[25] = v[25] ^ (ctx.t / 0x100000000); + // high 64 bits not supported, offset may not be higher than 2**53-1 + // last block flag set ? + if (last) { + v[28] = ~v[28]; + v[29] = ~v[29]; + } + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i); + } + // twelve rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + for (i = 0; i < 12; i++) { + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]); + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]); + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]); + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]); + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]); + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]); + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]); + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]); + } + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16]; + } + } + // 64-bit unsigned addition + // Sets v[a,a+1] += v[b,b+1] + // v should be a Uint32Array + function ADD64AA(v, a, b) { + var o0 = v[a] + v[b], o1 = v[a + 1] + v[b + 1]; + if (o0 >= 0x100000000) + o1++; + v[a] = o0; + v[a + 1] = o1; + } + // 64-bit unsigned addition + // Sets v[a,a+1] += b + // b0 is the low 32 bits of b, b1 represents the high 32 bits + function ADD64AC(v, a, b0, b1) { + var o0 = v[a] + b0; + if (b0 < 0) + o0 += 0x100000000; + var o1 = v[a + 1] + b1; + if (o0 >= 0x100000000) + o1++; + v[a] = o0; + v[a + 1] = o1; + } + // Little-endian byte access + function B2B_GET32(arr, i) { + return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24); + } + // G Mixing function + // The ROTRs are inlined for speed + function B2B_G(a, b, c, d, ix, iy) { + var x0 = m[ix]; + var x1 = m[ix + 1]; + var y0 = m[iy]; + var y1 = m[iy + 1]; + ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a]; + var xor1 = v[d + 1] ^ v[a + 1]; + v[d] = xor1; + v[d + 1] = xor0; + ADD64AA(v, c, d); + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c]; + xor1 = v[b + 1] ^ v[c + 1]; + v[b] = (xor0 >>> 24) ^ (xor1 << 8); + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8); + ADD64AA(v, a, b); + ADD64AC(v, a, y0, y1); + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a]; + xor1 = v[d + 1] ^ v[a + 1]; + v[d] = (xor0 >>> 16) ^ (xor1 << 16); + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16); + ADD64AA(v, c, d); + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c]; + xor1 = v[b + 1] ^ v[c + 1]; + v[b] = (xor1 >>> 31) ^ (xor0 << 1); + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1); + } + + },{"./array":141}],144:[function(require,module,exports){ + "use strict"; + // Blake2S in pure Javascript + // Adapted from the reference implementation in RFC7693 + // Ported to Javascript by DC - https://github.com/dcposch + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + // Computes the BLAKE2S hash of a string or byte array, and returns a ByteArray + // + // Returns a n-byte ByteArray + // + // Parameters: + // - input - the input bytes, as a string, Buffer, or Uint8Array + // - key - optional key ByteArray, up to 32 bytes + // - outlen - optional output length in bytes, default 64 + function blake2s(input, key, outlen) { + if (outlen === void 0) { outlen = 32; } + var ctx = blake2s_init(outlen, key); + blake2s_update(ctx, input); + return blake2s_final(ctx); + } + exports.blake2s = blake2s; + // Creates a BLAKE2s hashing context + // Requires an output length between 1 and 32 bytes + // Takes an optional Uint8Array key + function blake2s_init(outlen, key) { + if (!(outlen > 0 && outlen <= 32)) { + throw new Error('Incorrect output length, should be in [1, 32]'); + } + var keylen = key ? key.length : 0; + if (key && !(keylen > 0 && keylen <= 32)) { + throw new Error('Incorrect key length, should be in [1, 32]'); + } + var ctx = { + h: array_1.WordArray(BLAKE2S_IV), + b: array_1.WordArray(64), + c: 0, + t: 0, + outlen: outlen // output length in bytes + }; + ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; + if (keylen) { + blake2s_update(ctx, key); + ctx.c = 64; // at the end + } + return ctx; + } + exports.blake2s_init = blake2s_init; + // Updates a BLAKE2s streaming hash + // Requires hash context and Uint8Array (byte array) + function blake2s_update(ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 64) { // buffer full ? + ctx.t += ctx.c; // add counters + blake2s_compress(ctx, false); // compress (not last) + ctx.c = 0; // counter to zero + } + ctx.b[ctx.c++] = input[i]; + } + } + exports.blake2s_update = blake2s_update; + // Completes a BLAKE2s streaming hash + // Returns a Uint8Array containing the message digest + function blake2s_final(ctx) { + ctx.t += ctx.c; // mark last block offset + while (ctx.c < 64) { // fill up with zeros + ctx.b[ctx.c++] = 0; + } + blake2s_compress(ctx, true); // final block flag = 1 + // little endian convert and store + var out = array_1.ByteArray(ctx.outlen); + for (var i = 0; i < ctx.outlen; i++) { + out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xFF; + } + return out; + } + exports.blake2s_final = blake2s_final; + // Initialization Vector. + var BLAKE2S_IV = array_1.WordArray([ + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, + 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 + ]); + var SIGMA = array_1.ByteArray([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 + ]); + // Compression function. "last" flag indicates last block + var v = array_1.WordArray(16); + var m = array_1.WordArray(16); + function blake2s_compress(ctx, last) { + var i = 0; + for (i = 0; i < 8; i++) { // init work variables + v[i] = ctx.h[i]; + v[i + 8] = BLAKE2S_IV[i]; + } + v[12] ^= ctx.t; // low 32 bits of offset + v[13] ^= (ctx.t / 0x100000000); // high 32 bits + if (last) { // last block flag set ? + v[14] = ~v[14]; + } + for (i = 0; i < 16; i++) { // get little-endian words + m[i] = B2S_GET32(ctx.b, 4 * i); + } + // ten rounds of mixing + // uncomment the DebugPrint calls to log the computation + // and match the RFC sample documentation + for (i = 0; i < 10; i++) { + B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]); + B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]); + B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]); + B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]); + B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]); + B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]); + B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]); + B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]); + } + for (i = 0; i < 8; i++) { + ctx.h[i] ^= v[i] ^ v[i + 8]; + } + } + // Little-endian byte access. + // Expects a ByteArray and an index + // Returns the little-endian uint32 at v[i..i+3] + function B2S_GET32(v, i) { + return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24); + } + // Mixing function G. + function B2S_G(a, b, c, d, x, y) { + v[a] = v[a] + v[b] + x; + v[d] = ROTR32(v[d] ^ v[a], 16); + v[c] = v[c] + v[d]; + v[b] = ROTR32(v[b] ^ v[c], 12); + v[a] = v[a] + v[b] + y; + v[d] = ROTR32(v[d] ^ v[a], 8); + v[c] = v[c] + v[d]; + v[b] = ROTR32(v[b] ^ v[c], 7); + } + // 32-bit right rotation + // x should be a uint32 + // y must be between 1 and 31, inclusive + function ROTR32(x, y) { + return (x >>> y) ^ (x << (32 - y)); + } + + },{"./array":141}],145:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var core_1 = require("./core"); + var random_1 = require("./random"); + var salsa20_1 = require("./salsa20"); + var scalarmult_1 = require("./scalarmult"); + var secretbox_1 = require("./secretbox"); + var check_1 = require("./check"); + function box(msg, nonce, publicKey, secretKey) { + var k = box_before(publicKey, secretKey); + return secretbox_1.secretbox(msg, nonce, k); + } + exports.box = box; + function box_before(publicKey, secretKey) { + check_1.checkArrayTypes(publicKey, secretKey); + check_1.checkBoxLengths(publicKey, secretKey); + var k = array_1.ByteArray(32 /* SharedKey */); + _box_beforenm(k, publicKey, secretKey); + return k; + } + exports.box_before = box_before; + exports.box_after = secretbox_1.secretbox; + function box_open(msg, nonce, publicKey, secretKey) { + var k = box_before(publicKey, secretKey); + return secretbox_1.secretbox_open(msg, nonce, k); + } + exports.box_open = box_open; + exports.box_open_after = secretbox_1.secretbox_open; + function box_keyPair() { + var pk = array_1.ByteArray(32 /* PublicKey */); + var sk = array_1.ByteArray(32 /* SecretKey */); + _box_keypair(pk, sk); + return { publicKey: pk, secretKey: sk }; + } + exports.box_keyPair = box_keyPair; + function box_keyPair_fromSecretKey(secretKey) { + check_1.checkArrayTypes(secretKey); + if (secretKey.length !== 32 /* SecretKey */) + throw new Error('bad secret key size'); + var pk = array_1.ByteArray(32 /* PublicKey */); + scalarmult_1._scalarMult_base(pk, secretKey); + return { publicKey: pk, secretKey: array_1.ByteArray(secretKey) }; + } + exports.box_keyPair_fromSecretKey = box_keyPair_fromSecretKey; + // low level + function _box_keypair(y, x) { + random_1._randomBytes(x, 32); + return scalarmult_1._scalarMult_base(y, x); + } + function _box_beforenm(k, y, x) { + var s = array_1.ByteArray(32); + scalarmult_1._scalarMult(s, x, y); + return salsa20_1._hsalsa20(k, core_1._0, s, salsa20_1._sigma); + } + + },{"./array":141,"./check":146,"./core":150,"./random":155,"./salsa20":156,"./scalarmult":157,"./secretbox":159}],146:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function checkLengths(k, n) { + if (k.length != 32 /* Key */) + throw new Error('bad key size'); + if (n.length != 24 /* Nonce */) + throw new Error('bad nonce size'); + } + exports.checkLengths = checkLengths; + function checkBoxLengths(pk, sk) { + if (pk.length != 32 /* PublicKey */) + throw new Error('bad public key size'); + if (sk.length != 32 /* SecretKey */) + throw new Error('bad secret key size'); + } + exports.checkBoxLengths = checkBoxLengths; + function checkArrayTypes() { + var arrays = []; + for (var _i = 0; _i < arguments.length; _i++) { + arrays[_i] = arguments[_i]; + } + for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) { + var array = arrays_1[_a]; + if (!(array instanceof Uint8Array)) { + throw new TypeError('unexpected type, use ByteArray'); + } + } + } + exports.checkArrayTypes = checkArrayTypes; + + },{}],147:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("../array"); + var validate_1 = require("../validate"); + var fromCharCode = String.fromCharCode; + function encodeUTF8(a) { + return decodeURIComponent(escape(fromCharCode.apply(undefined, a))); + } + exports.encodeUTF8 = encodeUTF8; + function decodeUTF8(s) { + if (typeof s !== 'string') + throw new TypeError('expected string'); + var d = unescape(encodeURIComponent(s)), b = array_1.ByteArray(d.length); + for (var i = 0; i < d.length; i++) { + b[i] = d.charCodeAt(i); + } + return b; + } + exports.decodeUTF8 = decodeUTF8; + function encodeBase64(a) { + return btoa(fromCharCode.apply(undefined, a)); + } + exports.encodeBase64 = encodeBase64; + function decodeBase64(s) { + validate_1.validateBase64(s); + var d = atob(s), b = array_1.ByteArray(d.length); + for (var i = 0; i < d.length; i++) { + b[i] = d.charCodeAt(i); + } + return b; + } + exports.decodeBase64 = decodeBase64; + function put_hb(h) { + return h + (h < 10 ? 48 : 87); + } + function encodeHex(a) { + var b = array_1.ByteArray(a.length << 1); + for (var i = 0, j = void 0; i < a.length; i++) { + j = i << 1; + b[j] = put_hb(a[i] >> 8); + b[j + 1] = put_hb(a[i] & 0xf); + } + return fromCharCode.apply(undefined, b); + } + exports.encodeHex = encodeHex; + function get_hb(s, i) { + var c = s.charCodeAt(i); + return c - (c < 58 ? 48 : c < 71 ? 55 : 87); + } + function decodeHex(s) { + validate_1.validateHex(s); + var a = array_1.ByteArray(s.length >> 1); + for (var i = 0; i < a.length; i += 2) { + a[i] = (get_hb(s, i) << 8) | get_hb(s, i + 1); + } + return a; + } + exports.decodeHex = decodeHex; + + },{"../array":141,"../validate":161}],148:[function(require,module,exports){ + "use strict"; + // Initialize PRNG if environment provides CSPRNG. + // If not, methods calling randombytes will throw. + Object.defineProperty(exports, "__esModule", { value: true }); + var QUOTE = 1 << 16; + function _randomBytes(x, n) { + for (var i = 0; i < n; i += QUOTE) { + crypto.getRandomValues(x.subarray(i, i + Math.min(n - i, QUOTE))); + } + } + exports._randomBytes = _randomBytes; + + },{}],149:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var tslib_1 = require("tslib"); + tslib_1.__exportStar(require("./server/convert"), exports); + + },{"./server/convert":147,"tslib":140}],150:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + function gf(init) { + var r = array_1.NumArray(16); + if (init) + for (var i = 0; i < init.length; i++) + r[i] = init[i]; + return r; + } + exports.gf = gf; + exports._0 = array_1.ByteArray(16); + exports._9 = array_1.ByteArray(32); + exports._9[0] = 9; + exports.gf0 = gf(); + exports.gf1 = gf([1]); + exports._121665 = gf([0xdb41, 1]); + exports.D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]); + exports.D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]); + exports.X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]); + exports.Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]); + exports.I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]); + function A(o, a, b) { + for (var i = 0; i < 16; i++) + o[i] = a[i] + b[i]; + } + exports.A = A; + function Z(o, a, b) { + for (var i = 0; i < 16; i++) + o[i] = a[i] - b[i]; + } + exports.Z = Z; + function M(o, a, b) { + var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; + v = a[0]; + t0 += v * b0; + t1 += v * b1; + t2 += v * b2; + t3 += v * b3; + t4 += v * b4; + t5 += v * b5; + t6 += v * b6; + t7 += v * b7; + t8 += v * b8; + t9 += v * b9; + t10 += v * b10; + t11 += v * b11; + t12 += v * b12; + t13 += v * b13; + t14 += v * b14; + t15 += v * b15; + v = a[1]; + t1 += v * b0; + t2 += v * b1; + t3 += v * b2; + t4 += v * b3; + t5 += v * b4; + t6 += v * b5; + t7 += v * b6; + t8 += v * b7; + t9 += v * b8; + t10 += v * b9; + t11 += v * b10; + t12 += v * b11; + t13 += v * b12; + t14 += v * b13; + t15 += v * b14; + t16 += v * b15; + v = a[2]; + t2 += v * b0; + t3 += v * b1; + t4 += v * b2; + t5 += v * b3; + t6 += v * b4; + t7 += v * b5; + t8 += v * b6; + t9 += v * b7; + t10 += v * b8; + t11 += v * b9; + t12 += v * b10; + t13 += v * b11; + t14 += v * b12; + t15 += v * b13; + t16 += v * b14; + t17 += v * b15; + v = a[3]; + t3 += v * b0; + t4 += v * b1; + t5 += v * b2; + t6 += v * b3; + t7 += v * b4; + t8 += v * b5; + t9 += v * b6; + t10 += v * b7; + t11 += v * b8; + t12 += v * b9; + t13 += v * b10; + t14 += v * b11; + t15 += v * b12; + t16 += v * b13; + t17 += v * b14; + t18 += v * b15; + v = a[4]; + t4 += v * b0; + t5 += v * b1; + t6 += v * b2; + t7 += v * b3; + t8 += v * b4; + t9 += v * b5; + t10 += v * b6; + t11 += v * b7; + t12 += v * b8; + t13 += v * b9; + t14 += v * b10; + t15 += v * b11; + t16 += v * b12; + t17 += v * b13; + t18 += v * b14; + t19 += v * b15; + v = a[5]; + t5 += v * b0; + t6 += v * b1; + t7 += v * b2; + t8 += v * b3; + t9 += v * b4; + t10 += v * b5; + t11 += v * b6; + t12 += v * b7; + t13 += v * b8; + t14 += v * b9; + t15 += v * b10; + t16 += v * b11; + t17 += v * b12; + t18 += v * b13; + t19 += v * b14; + t20 += v * b15; + v = a[6]; + t6 += v * b0; + t7 += v * b1; + t8 += v * b2; + t9 += v * b3; + t10 += v * b4; + t11 += v * b5; + t12 += v * b6; + t13 += v * b7; + t14 += v * b8; + t15 += v * b9; + t16 += v * b10; + t17 += v * b11; + t18 += v * b12; + t19 += v * b13; + t20 += v * b14; + t21 += v * b15; + v = a[7]; + t7 += v * b0; + t8 += v * b1; + t9 += v * b2; + t10 += v * b3; + t11 += v * b4; + t12 += v * b5; + t13 += v * b6; + t14 += v * b7; + t15 += v * b8; + t16 += v * b9; + t17 += v * b10; + t18 += v * b11; + t19 += v * b12; + t20 += v * b13; + t21 += v * b14; + t22 += v * b15; + v = a[8]; + t8 += v * b0; + t9 += v * b1; + t10 += v * b2; + t11 += v * b3; + t12 += v * b4; + t13 += v * b5; + t14 += v * b6; + t15 += v * b7; + t16 += v * b8; + t17 += v * b9; + t18 += v * b10; + t19 += v * b11; + t20 += v * b12; + t21 += v * b13; + t22 += v * b14; + t23 += v * b15; + v = a[9]; + t9 += v * b0; + t10 += v * b1; + t11 += v * b2; + t12 += v * b3; + t13 += v * b4; + t14 += v * b5; + t15 += v * b6; + t16 += v * b7; + t17 += v * b8; + t18 += v * b9; + t19 += v * b10; + t20 += v * b11; + t21 += v * b12; + t22 += v * b13; + t23 += v * b14; + t24 += v * b15; + v = a[10]; + t10 += v * b0; + t11 += v * b1; + t12 += v * b2; + t13 += v * b3; + t14 += v * b4; + t15 += v * b5; + t16 += v * b6; + t17 += v * b7; + t18 += v * b8; + t19 += v * b9; + t20 += v * b10; + t21 += v * b11; + t22 += v * b12; + t23 += v * b13; + t24 += v * b14; + t25 += v * b15; + v = a[11]; + t11 += v * b0; + t12 += v * b1; + t13 += v * b2; + t14 += v * b3; + t15 += v * b4; + t16 += v * b5; + t17 += v * b6; + t18 += v * b7; + t19 += v * b8; + t20 += v * b9; + t21 += v * b10; + t22 += v * b11; + t23 += v * b12; + t24 += v * b13; + t25 += v * b14; + t26 += v * b15; + v = a[12]; + t12 += v * b0; + t13 += v * b1; + t14 += v * b2; + t15 += v * b3; + t16 += v * b4; + t17 += v * b5; + t18 += v * b6; + t19 += v * b7; + t20 += v * b8; + t21 += v * b9; + t22 += v * b10; + t23 += v * b11; + t24 += v * b12; + t25 += v * b13; + t26 += v * b14; + t27 += v * b15; + v = a[13]; + t13 += v * b0; + t14 += v * b1; + t15 += v * b2; + t16 += v * b3; + t17 += v * b4; + t18 += v * b5; + t19 += v * b6; + t20 += v * b7; + t21 += v * b8; + t22 += v * b9; + t23 += v * b10; + t24 += v * b11; + t25 += v * b12; + t26 += v * b13; + t27 += v * b14; + t28 += v * b15; + v = a[14]; + t14 += v * b0; + t15 += v * b1; + t16 += v * b2; + t17 += v * b3; + t18 += v * b4; + t19 += v * b5; + t20 += v * b6; + t21 += v * b7; + t22 += v * b8; + t23 += v * b9; + t24 += v * b10; + t25 += v * b11; + t26 += v * b12; + t27 += v * b13; + t28 += v * b14; + t29 += v * b15; + v = a[15]; + t15 += v * b0; + t16 += v * b1; + t17 += v * b2; + t18 += v * b3; + t19 += v * b4; + t20 += v * b5; + t21 += v * b6; + t22 += v * b7; + t23 += v * b8; + t24 += v * b9; + t25 += v * b10; + t26 += v * b11; + t27 += v * b12; + t28 += v * b13; + t29 += v * b14; + t30 += v * b15; + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + // t15 left as is + // first car + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); + // second car + c = 1; + v = t0 + c + 65535; + c = Math.floor(v / 65536); + t0 = v - c * 65536; + v = t1 + c + 65535; + c = Math.floor(v / 65536); + t1 = v - c * 65536; + v = t2 + c + 65535; + c = Math.floor(v / 65536); + t2 = v - c * 65536; + v = t3 + c + 65535; + c = Math.floor(v / 65536); + t3 = v - c * 65536; + v = t4 + c + 65535; + c = Math.floor(v / 65536); + t4 = v - c * 65536; + v = t5 + c + 65535; + c = Math.floor(v / 65536); + t5 = v - c * 65536; + v = t6 + c + 65535; + c = Math.floor(v / 65536); + t6 = v - c * 65536; + v = t7 + c + 65535; + c = Math.floor(v / 65536); + t7 = v - c * 65536; + v = t8 + c + 65535; + c = Math.floor(v / 65536); + t8 = v - c * 65536; + v = t9 + c + 65535; + c = Math.floor(v / 65536); + t9 = v - c * 65536; + v = t10 + c + 65535; + c = Math.floor(v / 65536); + t10 = v - c * 65536; + v = t11 + c + 65535; + c = Math.floor(v / 65536); + t11 = v - c * 65536; + v = t12 + c + 65535; + c = Math.floor(v / 65536); + t12 = v - c * 65536; + v = t13 + c + 65535; + c = Math.floor(v / 65536); + t13 = v - c * 65536; + v = t14 + c + 65535; + c = Math.floor(v / 65536); + t14 = v - c * 65536; + v = t15 + c + 65535; + c = Math.floor(v / 65536); + t15 = v - c * 65536; + t0 += c - 1 + 37 * (c - 1); + o[0] = t0; + o[1] = t1; + o[2] = t2; + o[3] = t3; + o[4] = t4; + o[5] = t5; + o[6] = t6; + o[7] = t7; + o[8] = t8; + o[9] = t9; + o[10] = t10; + o[11] = t11; + o[12] = t12; + o[13] = t13; + o[14] = t14; + o[15] = t15; + } + exports.M = M; + function S(o, a) { + M(o, a, a); + } + exports.S = S; + + },{"./array":141}],151:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var verify_1 = require("./verify"); + var core_1 = require("./core"); + function set25519(r, a) { + for (var i = 0; i < 16; i++) + r[i] = a[i] | 0; + } + exports.set25519 = set25519; + function car25519(o) { + var i, v, c = 1; + for (i = 0; i < 16; i++) { + v = o[i] + c + 65535; + c = Math.floor(v / 65536); + o[i] = v - c * 65536; + } + o[0] += c - 1 + 37 * (c - 1); + } + function sel25519(p, q, b) { + var t, c = ~(b - 1); + for (var i = 0; i < 16; i++) { + t = c & (p[i] ^ q[i]); + p[i] ^= t; + q[i] ^= t; + } + } + exports.sel25519 = sel25519; + function pack25519(o, n) { + var m = core_1.gf(), t = core_1.gf(); + var i, j, b; + for (i = 0; i < 16; i++) + t[i] = n[i]; + car25519(t); + car25519(t); + car25519(t); + for (j = 0; j < 2; j++) { + m[0] = t[0] - 0xffed; + for (i = 1; i < 15; i++) { + m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1); + m[i - 1] &= 0xffff; + } + m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1); + b = (m[15] >> 16) & 1; + m[14] &= 0xffff; + sel25519(t, m, 1 - b); + } + for (i = 0; i < 16; i++) { + o[2 * i] = t[i] & 0xff; + o[2 * i + 1] = t[i] >> 8; + } + } + exports.pack25519 = pack25519; + function neq25519(a, b) { + var c = array_1.ByteArray(32), d = array_1.ByteArray(32); + pack25519(c, a); + pack25519(d, b); + return verify_1._verify_32(c, 0, d, 0); + } + exports.neq25519 = neq25519; + function par25519(a) { + var d = array_1.ByteArray(32); + pack25519(d, a); + return d[0] & 1; + } + exports.par25519 = par25519; + function unpack25519(o, n) { + for (var i = 0; i < 16; i++) + o[i] = n[2 * i] + (n[2 * i + 1] << 8); + o[15] &= 0x7fff; + } + exports.unpack25519 = unpack25519; + function inv25519(o, i) { + var c = core_1.gf(); + var a; + for (a = 0; a < 16; a++) + c[a] = i[a]; + for (a = 253; a >= 0; a--) { + core_1.S(c, c); + if (a !== 2 && a !== 4) + core_1.M(c, c, i); + } + for (a = 0; a < 16; a++) + o[a] = c[a]; + } + exports.inv25519 = inv25519; + + },{"./array":141,"./core":150,"./verify":162}],152:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var check_1 = require("./check"); + function hash(msg) { + check_1.checkArrayTypes(msg); + var h = array_1.ByteArray(64 /* Hash */); + _hash(h, msg, msg.length); + return h; + } + exports.hash = hash; + function _hash(out, m, n) { + var hh = array_1.IntArray(8), hl = array_1.IntArray(8), x = array_1.ByteArray(256); + var i, b = n; + hh[0] = 0x6a09e667; + hh[1] = 0xbb67ae85; + hh[2] = 0x3c6ef372; + hh[3] = 0xa54ff53a; + hh[4] = 0x510e527f; + hh[5] = 0x9b05688c; + hh[6] = 0x1f83d9ab; + hh[7] = 0x5be0cd19; + hl[0] = 0xf3bcc908; + hl[1] = 0x84caa73b; + hl[2] = 0xfe94f82b; + hl[3] = 0x5f1d36f1; + hl[4] = 0xade682d1; + hl[5] = 0x2b3e6c1f; + hl[6] = 0xfb41bd6b; + hl[7] = 0x137e2179; + _hashblocks_hl(hh, hl, m, n); + n %= 128; + for (i = 0; i < n; i++) + x[i] = m[b - n + i]; + x[n] = 128; + n = 256 - 128 * (n < 112 ? 1 : 0); + x[n - 9] = 0; + _ts64(x, n - 8, (b / 0x20000000) | 0, b << 3); + _hashblocks_hl(hh, hl, x, n); + for (i = 0; i < 8; i++) + _ts64(out, 8 * i, hh[i], hl[i]); + return 0; + } + exports._hash = _hash; + var _K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 + ]; + function _hashblocks_hl(hh, hl, m, n) { + var wh = array_1.IntArray(16), wl = array_1.IntArray(16); + var bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d; + var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + var pos = 0; + while (n >= 128) { + for (i = 0; i < 16; i++) { + j = 8 * i + pos; + wh[i] = (m[j + 0] << 24) | (m[j + 1] << 16) | (m[j + 2] << 8) | m[j + 3]; + wl[i] = (m[j + 4] << 24) | (m[j + 5] << 16) | (m[j + 6] << 8) | m[j + 7]; + } + for (i = 0; i < 80; i++) { + bh0 = ah0; + bh1 = ah1; + bh2 = ah2; + bh3 = ah3; + bh4 = ah4; + bh5 = ah5; + bh6 = ah6; + bh7 = ah7; + bl0 = al0; + bl1 = al1; + bl2 = al2; + bl3 = al3; + bl4 = al4; + bl5 = al5; + bl6 = al6; + bl7 = al7; + // add + h = ah7; + l = al7; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + // Sigma1 + h = ((ah4 >>> 14) | (al4 << (32 - 14))) ^ ((ah4 >>> 18) | (al4 << (32 - 18))) ^ ((al4 >>> (41 - 32)) | (ah4 << (32 - (41 - 32)))); + l = ((al4 >>> 14) | (ah4 << (32 - 14))) ^ ((al4 >>> 18) | (ah4 << (32 - 18))) ^ ((ah4 >>> (41 - 32)) | (al4 << (32 - (41 - 32)))); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // Ch + h = (ah4 & ah5) ^ (~ah4 & ah6); + l = (al4 & al5) ^ (~al4 & al6); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // K + h = _K[i * 2]; + l = _K[i * 2 + 1]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // w + h = wh[i % 16]; + l = wl[i % 16]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + th = c & 0xffff | d << 16; + tl = a & 0xffff | b << 16; + // add + h = th; + l = tl; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + // Sigma0 + h = ((ah0 >>> 28) | (al0 << (32 - 28))) ^ ((al0 >>> (34 - 32)) | (ah0 << (32 - (34 - 32)))) ^ ((al0 >>> (39 - 32)) | (ah0 << (32 - (39 - 32)))); + l = ((al0 >>> 28) | (ah0 << (32 - 28))) ^ ((ah0 >>> (34 - 32)) | (al0 << (32 - (34 - 32)))) ^ ((ah0 >>> (39 - 32)) | (al0 << (32 - (39 - 32)))); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // Maj + h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2); + l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + bh7 = (c & 0xffff) | (d << 16); + bl7 = (a & 0xffff) | (b << 16); + // add + h = bh3; + l = bl3; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = th; + l = tl; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + bh3 = (c & 0xffff) | (d << 16); + bl3 = (a & 0xffff) | (b << 16); + ah1 = bh0; + ah2 = bh1; + ah3 = bh2; + ah4 = bh3; + ah5 = bh4; + ah6 = bh5; + ah7 = bh6; + ah0 = bh7; + al1 = bl0; + al2 = bl1; + al3 = bl2; + al4 = bl3; + al5 = bl4; + al6 = bl5; + al7 = bl6; + al0 = bl7; + if (i % 16 === 15) { + for (j = 0; j < 16; j++) { + // add + h = wh[j]; + l = wl[j]; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = wh[(j + 9) % 16]; + l = wl[(j + 9) % 16]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // sigma0 + th = wh[(j + 1) % 16]; + tl = wl[(j + 1) % 16]; + h = ((th >>> 1) | (tl << (32 - 1))) ^ ((th >>> 8) | (tl << (32 - 8))) ^ (th >>> 7); + l = ((tl >>> 1) | (th << (32 - 1))) ^ ((tl >>> 8) | (th << (32 - 8))) ^ ((tl >>> 7) | (th << (32 - 7))); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + // sigma1 + th = wh[(j + 14) % 16]; + tl = wl[(j + 14) % 16]; + h = ((th >>> 19) | (tl << (32 - 19))) ^ ((tl >>> (61 - 32)) | (th << (32 - (61 - 32)))) ^ (th >>> 6); + l = ((tl >>> 19) | (th << (32 - 19))) ^ ((th >>> (61 - 32)) | (tl << (32 - (61 - 32)))) ^ ((tl >>> 6) | (th << (32 - 6))); + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + wh[j] = (c & 0xffff) | (d << 16); + wl[j] = (a & 0xffff) | (b << 16); + } + } + } + // add + h = ah0; + l = al0; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[0]; + l = hl[0]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[0] = ah0 = (c & 0xffff) | (d << 16); + hl[0] = al0 = (a & 0xffff) | (b << 16); + h = ah1; + l = al1; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[1]; + l = hl[1]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[1] = ah1 = (c & 0xffff) | (d << 16); + hl[1] = al1 = (a & 0xffff) | (b << 16); + h = ah2; + l = al2; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[2]; + l = hl[2]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[2] = ah2 = (c & 0xffff) | (d << 16); + hl[2] = al2 = (a & 0xffff) | (b << 16); + h = ah3; + l = al3; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[3]; + l = hl[3]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[3] = ah3 = (c & 0xffff) | (d << 16); + hl[3] = al3 = (a & 0xffff) | (b << 16); + h = ah4; + l = al4; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[4]; + l = hl[4]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[4] = ah4 = (c & 0xffff) | (d << 16); + hl[4] = al4 = (a & 0xffff) | (b << 16); + h = ah5; + l = al5; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[5]; + l = hl[5]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[5] = ah5 = (c & 0xffff) | (d << 16); + hl[5] = al5 = (a & 0xffff) | (b << 16); + h = ah6; + l = al6; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[6]; + l = hl[6]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[6] = ah6 = (c & 0xffff) | (d << 16); + hl[6] = al6 = (a & 0xffff) | (b << 16); + h = ah7; + l = al7; + a = l & 0xffff; + b = l >>> 16; + c = h & 0xffff; + d = h >>> 16; + h = hh[7]; + l = hl[7]; + a += l & 0xffff; + b += l >>> 16; + c += h & 0xffff; + d += h >>> 16; + b += a >>> 16; + c += b >>> 16; + d += c >>> 16; + hh[7] = ah7 = (c & 0xffff) | (d << 16); + hl[7] = al7 = (a & 0xffff) | (b << 16); + pos += 128; + n -= 128; + } + return n; + } + function _ts64(x, i, h, l) { + x[i] = (h >> 24) & 0xff; + x[i + 1] = (h >> 16) & 0xff; + x[i + 2] = (h >> 8) & 0xff; + x[i + 3] = h & 0xff; + x[i + 4] = (l >> 24) & 0xff; + x[i + 5] = (l >> 16) & 0xff; + x[i + 6] = (l >> 8) & 0xff; + x[i + 7] = l & 0xff; + } + + },{"./array":141,"./check":146}],153:[function(require,module,exports){ + "use strict"; + // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. + // Public domain. + // + // Implementation derived from TweetNaCl version 20140427. + // See for details: http://tweetnacl.cr.yp.to/ + // + // Ported to TypeScript in 2018 by K. + // + Object.defineProperty(exports, "__esModule", { value: true }); + var tslib_1 = require("tslib"); + tslib_1.__exportStar(require("./array"), exports); + tslib_1.__exportStar(require("./validate"), exports); + tslib_1.__exportStar(require("./convert"), exports); + tslib_1.__exportStar(require("./verify"), exports); + tslib_1.__exportStar(require("./random"), exports); + tslib_1.__exportStar(require("./scalarmult"), exports); + tslib_1.__exportStar(require("./secretbox"), exports); + tslib_1.__exportStar(require("./box"), exports); + tslib_1.__exportStar(require("./sign"), exports); + tslib_1.__exportStar(require("./hash"), exports); + tslib_1.__exportStar(require("./auth"), exports); + tslib_1.__exportStar(require("./blake2s"), exports); + tslib_1.__exportStar(require("./blake2b"), exports); + tslib_1.__exportStar(require("./sealedbox"), exports); + + },{"./array":141,"./auth":142,"./blake2b":143,"./blake2s":144,"./box":145,"./convert":149,"./hash":152,"./random":155,"./scalarmult":157,"./sealedbox":158,"./secretbox":159,"./sign":160,"./validate":161,"./verify":162,"tslib":140}],154:[function(require,module,exports){ + "use strict"; + /* + * Port of Andrew Moon's Poly1305-donna-16. Public domain. + * https://github.com/floodyberry/poly1305-donna + * + * Ported to TypeScript in 2018 by K. + */ + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + function poly1305_init(key) { + var r = array_1.HalfArray(10); + var pad = array_1.HalfArray(8); + var t0, t1, t2, t3, t4, t5, t6, t7; + t0 = key[0] & 0xff | (key[1] & 0xff) << 8; + r[0] = (t0) & 0x1fff; + t1 = key[2] & 0xff | (key[3] & 0xff) << 8; + r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff; + t2 = key[4] & 0xff | (key[5] & 0xff) << 8; + r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03; + t3 = key[6] & 0xff | (key[7] & 0xff) << 8; + r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff; + t4 = key[8] & 0xff | (key[9] & 0xff) << 8; + r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff; + r[5] = ((t4 >>> 1)) & 0x1ffe; + t5 = key[10] & 0xff | (key[11] & 0xff) << 8; + r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff; + t6 = key[12] & 0xff | (key[13] & 0xff) << 8; + r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81; + t7 = key[14] & 0xff | (key[15] & 0xff) << 8; + r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff; + r[9] = ((t7 >>> 5)) & 0x007f; + pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8; + pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8; + pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8; + pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8; + pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8; + pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8; + pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8; + pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8; + return { + buffer: array_1.ByteArray(16), + r: r, + h: array_1.HalfArray(10), + pad: pad, + leftover: 0, + fin: 0, + }; + } + exports.poly1305_init = poly1305_init; + ; + function poly1305_blocks(self, m, mpos, bytes) { + var hibit = self.fin ? 0 : (1 << 11); + var t0, t1, t2, t3, t4, t5, t6, t7, c; + var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9; + var h = self.h, r = self.r; + var h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3], h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7], h8 = h[8], h9 = h[9]; + var r0 = r[0], r1 = r[1], r2 = r[2], r3 = r[3], r4 = r[4], r5 = r[5], r6 = r[6], r7 = r[7], r8 = r[8], r9 = r[9]; + while (bytes >= 16) { + t0 = m[mpos + 0] & 0xff | (m[mpos + 1] & 0xff) << 8; + h0 += (t0) & 0x1fff; + t1 = m[mpos + 2] & 0xff | (m[mpos + 3] & 0xff) << 8; + h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff; + t2 = m[mpos + 4] & 0xff | (m[mpos + 5] & 0xff) << 8; + h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff; + t3 = m[mpos + 6] & 0xff | (m[mpos + 7] & 0xff) << 8; + h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff; + t4 = m[mpos + 8] & 0xff | (m[mpos + 9] & 0xff) << 8; + h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff; + h5 += ((t4 >>> 1)) & 0x1fff; + t5 = m[mpos + 10] & 0xff | (m[mpos + 11] & 0xff) << 8; + h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff; + t6 = m[mpos + 12] & 0xff | (m[mpos + 13] & 0xff) << 8; + h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff; + t7 = m[mpos + 14] & 0xff | (m[mpos + 15] & 0xff) << 8; + h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff; + h9 += ((t7 >>> 5)) | hibit; + c = 0; + d0 = c; + d0 += h0 * r0; + d0 += h1 * (5 * r9); + d0 += h2 * (5 * r8); + d0 += h3 * (5 * r7); + d0 += h4 * (5 * r6); + c = (d0 >>> 13); + d0 &= 0x1fff; + d0 += h5 * (5 * r5); + d0 += h6 * (5 * r4); + d0 += h7 * (5 * r3); + d0 += h8 * (5 * r2); + d0 += h9 * (5 * r1); + c += (d0 >>> 13); + d0 &= 0x1fff; + d1 = c; + d1 += h0 * r1; + d1 += h1 * r0; + d1 += h2 * (5 * r9); + d1 += h3 * (5 * r8); + d1 += h4 * (5 * r7); + c = (d1 >>> 13); + d1 &= 0x1fff; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r2); + c += (d1 >>> 13); + d1 &= 0x1fff; + d2 = c; + d2 += h0 * r2; + d2 += h1 * r1; + d2 += h2 * r0; + d2 += h3 * (5 * r9); + d2 += h4 * (5 * r8); + c = (d2 >>> 13); + d2 &= 0x1fff; + d2 += h5 * (5 * r7); + d2 += h6 * (5 * r6); + d2 += h7 * (5 * r5); + d2 += h8 * (5 * r4); + d2 += h9 * (5 * r3); + c += (d2 >>> 13); + d2 &= 0x1fff; + d3 = c; + d3 += h0 * r3; + d3 += h1 * r2; + d3 += h2 * r1; + d3 += h3 * r0; + d3 += h4 * (5 * r9); + c = (d3 >>> 13); + d3 &= 0x1fff; + d3 += h5 * (5 * r8); + d3 += h6 * (5 * r7); + d3 += h7 * (5 * r6); + d3 += h8 * (5 * r5); + d3 += h9 * (5 * r4); + c += (d3 >>> 13); + d3 &= 0x1fff; + d4 = c; + d4 += h0 * r4; + d4 += h1 * r3; + d4 += h2 * r2; + d4 += h3 * r1; + d4 += h4 * r0; + c = (d4 >>> 13); + d4 &= 0x1fff; + d4 += h5 * (5 * r9); + d4 += h6 * (5 * r8); + d4 += h7 * (5 * r7); + d4 += h8 * (5 * r6); + d4 += h9 * (5 * r5); + c += (d4 >>> 13); + d4 &= 0x1fff; + d5 = c; + d5 += h0 * r5; + d5 += h1 * r4; + d5 += h2 * r3; + d5 += h3 * r2; + d5 += h4 * r1; + c = (d5 >>> 13); + d5 &= 0x1fff; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c += (d5 >>> 13); + d5 &= 0x1fff; + d6 = c; + d6 += h0 * r6; + d6 += h1 * r5; + d6 += h2 * r4; + d6 += h3 * r3; + d6 += h4 * r2; + c = (d6 >>> 13); + d6 &= 0x1fff; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c += (d6 >>> 13); + d6 &= 0x1fff; + d7 = c; + d7 += h0 * r7; + d7 += h1 * r6; + d7 += h2 * r5; + d7 += h3 * r4; + d7 += h4 * r3; + c = (d7 >>> 13); + d7 &= 0x1fff; + d7 += h5 * r2; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c += (d7 >>> 13); + d7 &= 0x1fff; + d8 = c; + d8 += h0 * r8; + d8 += h1 * r7; + d8 += h2 * r6; + d8 += h3 * r5; + d8 += h4 * r4; + c = (d8 >>> 13); + d8 &= 0x1fff; + d8 += h5 * r3; + d8 += h6 * r2; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c += (d8 >>> 13); + d8 &= 0x1fff; + d9 = c; + d9 += h0 * r9; + d9 += h1 * r8; + d9 += h2 * r7; + d9 += h3 * r6; + d9 += h4 * r5; + c = (d9 >>> 13); + d9 &= 0x1fff; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r2; + d9 += h8 * r1; + d9 += h9 * r0; + c += (d9 >>> 13); + d9 &= 0x1fff; + c = (((c << 2) + c)) | 0; + c = (c + d0) | 0; + d0 = c & 0x1fff; + c = (c >>> 13); + d1 += c; + h0 = d0; + h1 = d1; + h2 = d2; + h3 = d3; + h4 = d4; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; + h[5] = h5; + h[6] = h6; + h[7] = h7; + h[8] = h8; + h[9] = h9; + } + exports.poly1305_blocks = poly1305_blocks; + ; + function poly1305_finish(self, mac, macpos) { + var g = array_1.HalfArray(10); + var c, mask, f, i; + var buffer = self.buffer, h = self.h, pad = self.pad, leftover = self.leftover; + if (leftover) { + i = leftover; + buffer[i++] = 1; + for (; i < 16; i++) + buffer[i] = 0; + self.fin = 1; + poly1305_blocks(self, buffer, 0, 16); + } + c = h[1] >>> 13; + h[1] &= 0x1fff; + for (i = 2; i < 10; i++) { + h[i] += c; + c = h[i] >>> 13; + h[i] &= 0x1fff; + } + h[0] += (c * 5); + c = h[0] >>> 13; + h[0] &= 0x1fff; + h[1] += c; + c = h[1] >>> 13; + h[1] &= 0x1fff; + h[2] += c; + g[0] = h[0] + 5; + c = g[0] >>> 13; + g[0] &= 0x1fff; + for (i = 1; i < 10; i++) { + g[i] = h[i] + c; + c = g[i] >>> 13; + g[i] &= 0x1fff; + } + g[9] -= (1 << 13); + mask = (c ^ 1) - 1; + for (i = 0; i < 10; i++) + g[i] &= mask; + mask = ~mask; + for (i = 0; i < 10; i++) + h[i] = (h[i] & mask) | g[i]; + h[0] = ((h[0]) | (h[1] << 13)) & 0xffff; + h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff; + h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff; + h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff; + h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff; + h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff; + h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff; + h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff; + f = h[0] + pad[0]; + h[0] = f & 0xffff; + for (i = 1; i < 8; i++) { + f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0; + h[i] = f & 0xffff; + } + mac[macpos + 0] = (h[0] >>> 0) & 0xff; + mac[macpos + 1] = (h[0] >>> 8) & 0xff; + mac[macpos + 2] = (h[1] >>> 0) & 0xff; + mac[macpos + 3] = (h[1] >>> 8) & 0xff; + mac[macpos + 4] = (h[2] >>> 0) & 0xff; + mac[macpos + 5] = (h[2] >>> 8) & 0xff; + mac[macpos + 6] = (h[3] >>> 0) & 0xff; + mac[macpos + 7] = (h[3] >>> 8) & 0xff; + mac[macpos + 8] = (h[4] >>> 0) & 0xff; + mac[macpos + 9] = (h[4] >>> 8) & 0xff; + mac[macpos + 10] = (h[5] >>> 0) & 0xff; + mac[macpos + 11] = (h[5] >>> 8) & 0xff; + mac[macpos + 12] = (h[6] >>> 0) & 0xff; + mac[macpos + 13] = (h[6] >>> 8) & 0xff; + mac[macpos + 14] = (h[7] >>> 0) & 0xff; + mac[macpos + 15] = (h[7] >>> 8) & 0xff; + } + exports.poly1305_finish = poly1305_finish; + ; + function poly1305_update(self, m, mpos, bytes) { + var i, want; + var buffer = self.buffer; + if (self.leftover) { + want = (16 - self.leftover); + if (want > bytes) + want = bytes; + for (i = 0; i < want; i++) + buffer[self.leftover + i] = m[mpos + i]; + bytes -= want; + mpos += want; + self.leftover += want; + if (self.leftover < 16) + return; + poly1305_blocks(self, buffer, 0, 16); + self.leftover = 0; + } + if (bytes >= 16) { + want = bytes - (bytes % 16); + poly1305_blocks(self, m, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (i = 0; i < bytes; i++) + buffer[self.leftover + i] = m[mpos + i]; + self.leftover += bytes; + } + } + exports.poly1305_update = poly1305_update; + + },{"./array":141}],155:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var random_1 = require("./server/random"); + exports._randomBytes = random_1._randomBytes; + function randomBytes(n) { + var b = array_1.ByteArray(n); + random_1._randomBytes(b, n); + return b; + } + exports.randomBytes = randomBytes; + + },{"./array":141,"./server/random":148}],156:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + function _salsa20(o, p, k, c) { + var j0 = c[0] & 0xff | (c[1] & 0xff) << 8 | (c[2] & 0xff) << 16 | (c[3] & 0xff) << 24, j1 = k[0] & 0xff | (k[1] & 0xff) << 8 | (k[2] & 0xff) << 16 | (k[3] & 0xff) << 24, j2 = k[4] & 0xff | (k[5] & 0xff) << 8 | (k[6] & 0xff) << 16 | (k[7] & 0xff) << 24, j3 = k[8] & 0xff | (k[9] & 0xff) << 8 | (k[10] & 0xff) << 16 | (k[11] & 0xff) << 24, j4 = k[12] & 0xff | (k[13] & 0xff) << 8 | (k[14] & 0xff) << 16 | (k[15] & 0xff) << 24, j5 = c[4] & 0xff | (c[5] & 0xff) << 8 | (c[6] & 0xff) << 16 | (c[7] & 0xff) << 24, j6 = p[0] & 0xff | (p[1] & 0xff) << 8 | (p[2] & 0xff) << 16 | (p[3] & 0xff) << 24, j7 = p[4] & 0xff | (p[5] & 0xff) << 8 | (p[6] & 0xff) << 16 | (p[7] & 0xff) << 24, j8 = p[8] & 0xff | (p[9] & 0xff) << 8 | (p[10] & 0xff) << 16 | (p[11] & 0xff) << 24, j9 = p[12] & 0xff | (p[13] & 0xff) << 8 | (p[14] & 0xff) << 16 | (p[15] & 0xff) << 24, j10 = c[8] & 0xff | (c[9] & 0xff) << 8 | (c[10] & 0xff) << 16 | (c[11] & 0xff) << 24, j11 = k[16] & 0xff | (k[17] & 0xff) << 8 | (k[18] & 0xff) << 16 | (k[19] & 0xff) << 24, j12 = k[20] & 0xff | (k[21] & 0xff) << 8 | (k[22] & 0xff) << 16 | (k[23] & 0xff) << 24, j13 = k[24] & 0xff | (k[25] & 0xff) << 8 | (k[26] & 0xff) << 16 | (k[27] & 0xff) << 24, j14 = k[28] & 0xff | (k[29] & 0xff) << 8 | (k[30] & 0xff) << 16 | (k[31] & 0xff) << 24, j15 = c[12] & 0xff | (c[13] & 0xff) << 8 | (c[14] & 0xff) << 16 | (c[15] & 0xff) << 24; + var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u; + for (var i = 0; i < 20; i += 2) { + u = x0 + x12 | 0; + x4 ^= u << 7 | u >>> (32 - 7); + u = x4 + x0 | 0; + x8 ^= u << 9 | u >>> (32 - 9); + u = x8 + x4 | 0; + x12 ^= u << 13 | u >>> (32 - 13); + u = x12 + x8 | 0; + x0 ^= u << 18 | u >>> (32 - 18); + u = x5 + x1 | 0; + x9 ^= u << 7 | u >>> (32 - 7); + u = x9 + x5 | 0; + x13 ^= u << 9 | u >>> (32 - 9); + u = x13 + x9 | 0; + x1 ^= u << 13 | u >>> (32 - 13); + u = x1 + x13 | 0; + x5 ^= u << 18 | u >>> (32 - 18); + u = x10 + x6 | 0; + x14 ^= u << 7 | u >>> (32 - 7); + u = x14 + x10 | 0; + x2 ^= u << 9 | u >>> (32 - 9); + u = x2 + x14 | 0; + x6 ^= u << 13 | u >>> (32 - 13); + u = x6 + x2 | 0; + x10 ^= u << 18 | u >>> (32 - 18); + u = x15 + x11 | 0; + x3 ^= u << 7 | u >>> (32 - 7); + u = x3 + x15 | 0; + x7 ^= u << 9 | u >>> (32 - 9); + u = x7 + x3 | 0; + x11 ^= u << 13 | u >>> (32 - 13); + u = x11 + x7 | 0; + x15 ^= u << 18 | u >>> (32 - 18); + u = x0 + x3 | 0; + x1 ^= u << 7 | u >>> (32 - 7); + u = x1 + x0 | 0; + x2 ^= u << 9 | u >>> (32 - 9); + u = x2 + x1 | 0; + x3 ^= u << 13 | u >>> (32 - 13); + u = x3 + x2 | 0; + x0 ^= u << 18 | u >>> (32 - 18); + u = x5 + x4 | 0; + x6 ^= u << 7 | u >>> (32 - 7); + u = x6 + x5 | 0; + x7 ^= u << 9 | u >>> (32 - 9); + u = x7 + x6 | 0; + x4 ^= u << 13 | u >>> (32 - 13); + u = x4 + x7 | 0; + x5 ^= u << 18 | u >>> (32 - 18); + u = x10 + x9 | 0; + x11 ^= u << 7 | u >>> (32 - 7); + u = x11 + x10 | 0; + x8 ^= u << 9 | u >>> (32 - 9); + u = x8 + x11 | 0; + x9 ^= u << 13 | u >>> (32 - 13); + u = x9 + x8 | 0; + x10 ^= u << 18 | u >>> (32 - 18); + u = x15 + x14 | 0; + x12 ^= u << 7 | u >>> (32 - 7); + u = x12 + x15 | 0; + x13 ^= u << 9 | u >>> (32 - 9); + u = x13 + x12 | 0; + x14 ^= u << 13 | u >>> (32 - 13); + u = x14 + x13 | 0; + x15 ^= u << 18 | u >>> (32 - 18); + } + x0 = x0 + j0 | 0; + x1 = x1 + j1 | 0; + x2 = x2 + j2 | 0; + x3 = x3 + j3 | 0; + x4 = x4 + j4 | 0; + x5 = x5 + j5 | 0; + x6 = x6 + j6 | 0; + x7 = x7 + j7 | 0; + x8 = x8 + j8 | 0; + x9 = x9 + j9 | 0; + x10 = x10 + j10 | 0; + x11 = x11 + j11 | 0; + x12 = x12 + j12 | 0; + x13 = x13 + j13 | 0; + x14 = x14 + j14 | 0; + x15 = x15 + j15 | 0; + o[0] = x0 >>> 0 & 0xff; + o[1] = x0 >>> 8 & 0xff; + o[2] = x0 >>> 16 & 0xff; + o[3] = x0 >>> 24 & 0xff; + o[4] = x1 >>> 0 & 0xff; + o[5] = x1 >>> 8 & 0xff; + o[6] = x1 >>> 16 & 0xff; + o[7] = x1 >>> 24 & 0xff; + o[8] = x2 >>> 0 & 0xff; + o[9] = x2 >>> 8 & 0xff; + o[10] = x2 >>> 16 & 0xff; + o[11] = x2 >>> 24 & 0xff; + o[12] = x3 >>> 0 & 0xff; + o[13] = x3 >>> 8 & 0xff; + o[14] = x3 >>> 16 & 0xff; + o[15] = x3 >>> 24 & 0xff; + o[16] = x4 >>> 0 & 0xff; + o[17] = x4 >>> 8 & 0xff; + o[18] = x4 >>> 16 & 0xff; + o[19] = x4 >>> 24 & 0xff; + o[20] = x5 >>> 0 & 0xff; + o[21] = x5 >>> 8 & 0xff; + o[22] = x5 >>> 16 & 0xff; + o[23] = x5 >>> 24 & 0xff; + o[24] = x6 >>> 0 & 0xff; + o[25] = x6 >>> 8 & 0xff; + o[26] = x6 >>> 16 & 0xff; + o[27] = x6 >>> 24 & 0xff; + o[28] = x7 >>> 0 & 0xff; + o[29] = x7 >>> 8 & 0xff; + o[30] = x7 >>> 16 & 0xff; + o[31] = x7 >>> 24 & 0xff; + o[32] = x8 >>> 0 & 0xff; + o[33] = x8 >>> 8 & 0xff; + o[34] = x8 >>> 16 & 0xff; + o[35] = x8 >>> 24 & 0xff; + o[36] = x9 >>> 0 & 0xff; + o[37] = x9 >>> 8 & 0xff; + o[38] = x9 >>> 16 & 0xff; + o[39] = x9 >>> 24 & 0xff; + o[40] = x10 >>> 0 & 0xff; + o[41] = x10 >>> 8 & 0xff; + o[42] = x10 >>> 16 & 0xff; + o[43] = x10 >>> 24 & 0xff; + o[44] = x11 >>> 0 & 0xff; + o[45] = x11 >>> 8 & 0xff; + o[46] = x11 >>> 16 & 0xff; + o[47] = x11 >>> 24 & 0xff; + o[48] = x12 >>> 0 & 0xff; + o[49] = x12 >>> 8 & 0xff; + o[50] = x12 >>> 16 & 0xff; + o[51] = x12 >>> 24 & 0xff; + o[52] = x13 >>> 0 & 0xff; + o[53] = x13 >>> 8 & 0xff; + o[54] = x13 >>> 16 & 0xff; + o[55] = x13 >>> 24 & 0xff; + o[56] = x14 >>> 0 & 0xff; + o[57] = x14 >>> 8 & 0xff; + o[58] = x14 >>> 16 & 0xff; + o[59] = x14 >>> 24 & 0xff; + o[60] = x15 >>> 0 & 0xff; + o[61] = x15 >>> 8 & 0xff; + o[62] = x15 >>> 16 & 0xff; + o[63] = x15 >>> 24 & 0xff; + } + exports._salsa20 = _salsa20; + function _hsalsa20(o, p, k, c) { + var j0 = c[0] & 0xff | (c[1] & 0xff) << 8 | (c[2] & 0xff) << 16 | (c[3] & 0xff) << 24, j1 = k[0] & 0xff | (k[1] & 0xff) << 8 | (k[2] & 0xff) << 16 | (k[3] & 0xff) << 24, j2 = k[4] & 0xff | (k[5] & 0xff) << 8 | (k[6] & 0xff) << 16 | (k[7] & 0xff) << 24, j3 = k[8] & 0xff | (k[9] & 0xff) << 8 | (k[10] & 0xff) << 16 | (k[11] & 0xff) << 24, j4 = k[12] & 0xff | (k[13] & 0xff) << 8 | (k[14] & 0xff) << 16 | (k[15] & 0xff) << 24, j5 = c[4] & 0xff | (c[5] & 0xff) << 8 | (c[6] & 0xff) << 16 | (c[7] & 0xff) << 24, j6 = p[0] & 0xff | (p[1] & 0xff) << 8 | (p[2] & 0xff) << 16 | (p[3] & 0xff) << 24, j7 = p[4] & 0xff | (p[5] & 0xff) << 8 | (p[6] & 0xff) << 16 | (p[7] & 0xff) << 24, j8 = p[8] & 0xff | (p[9] & 0xff) << 8 | (p[10] & 0xff) << 16 | (p[11] & 0xff) << 24, j9 = p[12] & 0xff | (p[13] & 0xff) << 8 | (p[14] & 0xff) << 16 | (p[15] & 0xff) << 24, j10 = c[8] & 0xff | (c[9] & 0xff) << 8 | (c[10] & 0xff) << 16 | (c[11] & 0xff) << 24, j11 = k[16] & 0xff | (k[17] & 0xff) << 8 | (k[18] & 0xff) << 16 | (k[19] & 0xff) << 24, j12 = k[20] & 0xff | (k[21] & 0xff) << 8 | (k[22] & 0xff) << 16 | (k[23] & 0xff) << 24, j13 = k[24] & 0xff | (k[25] & 0xff) << 8 | (k[26] & 0xff) << 16 | (k[27] & 0xff) << 24, j14 = k[28] & 0xff | (k[29] & 0xff) << 8 | (k[30] & 0xff) << 16 | (k[31] & 0xff) << 24, j15 = c[12] & 0xff | (c[13] & 0xff) << 8 | (c[14] & 0xff) << 16 | (c[15] & 0xff) << 24; + var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u; + for (var i = 0; i < 20; i += 2) { + u = x0 + x12 | 0; + x4 ^= u << 7 | u >>> (32 - 7); + u = x4 + x0 | 0; + x8 ^= u << 9 | u >>> (32 - 9); + u = x8 + x4 | 0; + x12 ^= u << 13 | u >>> (32 - 13); + u = x12 + x8 | 0; + x0 ^= u << 18 | u >>> (32 - 18); + u = x5 + x1 | 0; + x9 ^= u << 7 | u >>> (32 - 7); + u = x9 + x5 | 0; + x13 ^= u << 9 | u >>> (32 - 9); + u = x13 + x9 | 0; + x1 ^= u << 13 | u >>> (32 - 13); + u = x1 + x13 | 0; + x5 ^= u << 18 | u >>> (32 - 18); + u = x10 + x6 | 0; + x14 ^= u << 7 | u >>> (32 - 7); + u = x14 + x10 | 0; + x2 ^= u << 9 | u >>> (32 - 9); + u = x2 + x14 | 0; + x6 ^= u << 13 | u >>> (32 - 13); + u = x6 + x2 | 0; + x10 ^= u << 18 | u >>> (32 - 18); + u = x15 + x11 | 0; + x3 ^= u << 7 | u >>> (32 - 7); + u = x3 + x15 | 0; + x7 ^= u << 9 | u >>> (32 - 9); + u = x7 + x3 | 0; + x11 ^= u << 13 | u >>> (32 - 13); + u = x11 + x7 | 0; + x15 ^= u << 18 | u >>> (32 - 18); + u = x0 + x3 | 0; + x1 ^= u << 7 | u >>> (32 - 7); + u = x1 + x0 | 0; + x2 ^= u << 9 | u >>> (32 - 9); + u = x2 + x1 | 0; + x3 ^= u << 13 | u >>> (32 - 13); + u = x3 + x2 | 0; + x0 ^= u << 18 | u >>> (32 - 18); + u = x5 + x4 | 0; + x6 ^= u << 7 | u >>> (32 - 7); + u = x6 + x5 | 0; + x7 ^= u << 9 | u >>> (32 - 9); + u = x7 + x6 | 0; + x4 ^= u << 13 | u >>> (32 - 13); + u = x4 + x7 | 0; + x5 ^= u << 18 | u >>> (32 - 18); + u = x10 + x9 | 0; + x11 ^= u << 7 | u >>> (32 - 7); + u = x11 + x10 | 0; + x8 ^= u << 9 | u >>> (32 - 9); + u = x8 + x11 | 0; + x9 ^= u << 13 | u >>> (32 - 13); + u = x9 + x8 | 0; + x10 ^= u << 18 | u >>> (32 - 18); + u = x15 + x14 | 0; + x12 ^= u << 7 | u >>> (32 - 7); + u = x12 + x15 | 0; + x13 ^= u << 9 | u >>> (32 - 9); + u = x13 + x12 | 0; + x14 ^= u << 13 | u >>> (32 - 13); + u = x14 + x13 | 0; + x15 ^= u << 18 | u >>> (32 - 18); + } + o[0] = x0 >>> 0 & 0xff; + o[1] = x0 >>> 8 & 0xff; + o[2] = x0 >>> 16 & 0xff; + o[3] = x0 >>> 24 & 0xff; + o[4] = x5 >>> 0 & 0xff; + o[5] = x5 >>> 8 & 0xff; + o[6] = x5 >>> 16 & 0xff; + o[7] = x5 >>> 24 & 0xff; + o[8] = x10 >>> 0 & 0xff; + o[9] = x10 >>> 8 & 0xff; + o[10] = x10 >>> 16 & 0xff; + o[11] = x10 >>> 24 & 0xff; + o[12] = x15 >>> 0 & 0xff; + o[13] = x15 >>> 8 & 0xff; + o[14] = x15 >>> 16 & 0xff; + o[15] = x15 >>> 24 & 0xff; + o[16] = x6 >>> 0 & 0xff; + o[17] = x6 >>> 8 & 0xff; + o[18] = x6 >>> 16 & 0xff; + o[19] = x6 >>> 24 & 0xff; + o[20] = x7 >>> 0 & 0xff; + o[21] = x7 >>> 8 & 0xff; + o[22] = x7 >>> 16 & 0xff; + o[23] = x7 >>> 24 & 0xff; + o[24] = x8 >>> 0 & 0xff; + o[25] = x8 >>> 8 & 0xff; + o[26] = x8 >>> 16 & 0xff; + o[27] = x8 >>> 24 & 0xff; + o[28] = x9 >>> 0 & 0xff; + o[29] = x9 >>> 8 & 0xff; + o[30] = x9 >>> 16 & 0xff; + o[31] = x9 >>> 24 & 0xff; + } + exports._hsalsa20 = _hsalsa20; + exports._sigma = array_1.ByteArray([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); + // "expand 32-byte k" + function _stream_salsa20_xor(c, cpos, m, mpos, b, n, k) { + var z = array_1.ByteArray(16), x = array_1.ByteArray(64); + var u, i; + for (i = 0; i < 16; i++) + z[i] = 0; + for (i = 0; i < 8; i++) + z[i] = n[i]; + while (b >= 64) { + _salsa20(x, z, k, exports._sigma); + for (i = 0; i < 64; i++) + c[cpos + i] = m[mpos + i] ^ x[i]; + u = 1; + for (i = 8; i < 16; i++) { + u = u + (z[i] & 0xff) | 0; + z[i] = u & 0xff; + u >>>= 8; + } + b -= 64; + cpos += 64; + mpos += 64; + } + if (b > 0) { + _salsa20(x, z, k, exports._sigma); + for (i = 0; i < b; i++) + c[cpos + i] = m[mpos + i] ^ x[i]; + } + return 0; + } + function _stream_salsa20(c, cpos, b, n, k) { + var z = array_1.ByteArray(16), x = array_1.ByteArray(64); + var u, i; + for (i = 0; i < 16; i++) + z[i] = 0; + for (i = 0; i < 8; i++) + z[i] = n[i]; + while (b >= 64) { + _salsa20(x, z, k, exports._sigma); + for (i = 0; i < 64; i++) + c[cpos + i] = x[i]; + u = 1; + for (i = 8; i < 16; i++) { + u = u + (z[i] & 0xff) | 0; + z[i] = u & 0xff; + u >>>= 8; + } + b -= 64; + cpos += 64; + } + if (b > 0) { + _salsa20(x, z, k, exports._sigma); + for (i = 0; i < b; i++) + c[cpos + i] = x[i]; + } + return 0; + } + function _stream(c, cpos, d, n, k) { + var s = array_1.ByteArray(32), sn = array_1.ByteArray(8); + _hsalsa20(s, n, k, exports._sigma); + for (var i = 0; i < 8; i++) + sn[i] = n[i + 16]; + return _stream_salsa20(c, cpos, d, sn, s); + } + exports._stream = _stream; + function _stream_xor(c, cpos, m, mpos, d, n, k) { + var s = array_1.ByteArray(32), sn = array_1.ByteArray(8); + _hsalsa20(s, n, k, exports._sigma); + for (var i = 0; i < 8; i++) + sn[i] = n[i + 16]; + return _stream_salsa20_xor(c, cpos, m, mpos, d, sn, s); + } + exports._stream_xor = _stream_xor; + + },{"./array":141}],157:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var core_1 = require("./core"); + var curve25519_1 = require("./curve25519"); + var check_1 = require("./check"); + function scalarMult(n, p) { + check_1.checkArrayTypes(n, p); + if (n.length !== 32 /* Scalar */) + throw new Error('bad n size'); + if (p.length !== 32 /* GroupElement */) + throw new Error('bad p size'); + var q = array_1.ByteArray(32 /* GroupElement */); + _scalarMult(q, n, p); + return q; + } + exports.scalarMult = scalarMult; + function scalarMult_base(n) { + check_1.checkArrayTypes(n); + if (n.length !== 32 /* Scalar */) + throw new Error('bad n size'); + var q = array_1.ByteArray(32 /* GroupElement */); + _scalarMult_base(q, n); + return q; + } + exports.scalarMult_base = scalarMult_base; + // low level + function _scalarMult(q, n, p) { + var z = array_1.ByteArray(32); + var x = array_1.NumArray(80); + var a = core_1.gf(); + var b = core_1.gf(); + var c = core_1.gf(); + var d = core_1.gf(); + var e = core_1.gf(); + var f = core_1.gf(); + var r, i; + for (i = 0; i < 31; i++) + z[i] = n[i]; + z[31] = (n[31] & 127) | 64; + z[0] &= 248; + curve25519_1.unpack25519(x, p); + for (i = 0; i < 16; i++) { + b[i] = x[i]; + d[i] = a[i] = c[i] = 0; + } + a[0] = d[0] = 1; + for (i = 254; i >= 0; --i) { + r = (z[i >>> 3] >>> (i & 7)) & 1; + curve25519_1.sel25519(a, b, r); + curve25519_1.sel25519(c, d, r); + core_1.A(e, a, c); + core_1.Z(a, a, c); + core_1.A(c, b, d); + core_1.Z(b, b, d); + core_1.S(d, e); + core_1.S(f, a); + core_1.M(a, c, a); + core_1.M(c, b, e); + core_1.A(e, a, c); + core_1.Z(a, a, c); + core_1.S(b, a); + core_1.Z(c, d, f); + core_1.M(a, c, core_1._121665); + core_1.A(a, a, d); + core_1.M(c, c, a); + core_1.M(a, d, f); + core_1.M(d, b, x); + core_1.S(b, e); + curve25519_1.sel25519(a, b, r); + curve25519_1.sel25519(c, d, r); + } + for (i = 0; i < 16; i++) { + x[i + 16] = a[i]; + x[i + 32] = c[i]; + x[i + 48] = b[i]; + x[i + 64] = d[i]; + } + var x32 = x.subarray(32); + var x16 = x.subarray(16); + curve25519_1.inv25519(x32, x32); + core_1.M(x16, x16, x32); + curve25519_1.pack25519(q, x16); + return 0; + } + exports._scalarMult = _scalarMult; + function _scalarMult_base(q, n) { + return _scalarMult(q, n, core_1._9); + } + exports._scalarMult_base = _scalarMult_base; + + },{"./array":141,"./check":146,"./core":150,"./curve25519":151}],158:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var box_1 = require("./box"); + var blake2b_1 = require("./blake2b"); + function sealedbox(m, pk) { + var c = array_1.ByteArray(48 /* Overhead */ + m.length); + var ek = box_1.box_keyPair(); + c.set(ek.publicKey); + var nonce = nonce_gen(ek.publicKey, pk); + var boxed = box_1.box(m, nonce, pk, ek.secretKey); + c.set(boxed, ek.publicKey.length); + // clear secret key + for (var i = 0; i < ek.secretKey.length; i++) + ek.secretKey[i] = 0; + return c; + } + exports.sealedbox = sealedbox; + function sealedbox_open(c, pk, sk) { + if (c.length < 48 /* Overhead */) + return; + var epk = c.subarray(0, 32 /* PublicKey */); + var nonce = nonce_gen(epk, pk); + var boxData = c.subarray(32 /* PublicKey */); + return box_1.box_open(boxData, nonce, epk, sk); + } + exports.sealedbox_open = sealedbox_open; + function nonce_gen(pk1, pk2) { + var state = blake2b_1.blake2b_init(24 /* Nonce */); + blake2b_1.blake2b_update(state, pk1); + blake2b_1.blake2b_update(state, pk2); + return blake2b_1.blake2b_final(state); + } + + },{"./array":141,"./blake2b":143,"./box":145}],159:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var verify_1 = require("./verify"); + var salsa20_1 = require("./salsa20"); + var poly1305_1 = require("./poly1305"); + var check_1 = require("./check"); + function secretbox(msg, nonce, key) { + check_1.checkArrayTypes(msg, nonce, key); + check_1.checkLengths(key, nonce); + var m = array_1.ByteArray(32 /* Zero */ + msg.length); + var c = array_1.ByteArray(m.length); + for (var i = 0; i < msg.length; i++) + m[i + 32 /* Zero */] = msg[i]; + _secretbox(c, m, m.length, nonce, key); + return c.subarray(16 /* Overhead */); + } + exports.secretbox = secretbox; + function secretbox_open(box, nonce, key) { + check_1.checkArrayTypes(box, nonce, key); + check_1.checkLengths(key, nonce); + var c = array_1.ByteArray(16 /* Overhead */ + box.length); + var m = array_1.ByteArray(c.length); + for (var i = 0; i < box.length; i++) + c[i + 16 /* Overhead */] = box[i]; + if (c.length < 32 /* Zero */ || _secretbox_open(m, c, c.length, nonce, key) !== 0) + return; + return m.subarray(32 /* Zero */); + } + exports.secretbox_open = secretbox_open; + // low level + function _secretbox(c, m, d, n, k) { + if (d < 32) + return -1; + salsa20_1._stream_xor(c, 0, m, 0, d, n, k); + _onetimeauth(c, 16, c, 32, d - 32, c); + for (var i = 0; i < 16; i++) + c[i] = 0; + return 0; + } + function _secretbox_open(m, c, d, n, k) { + var x = array_1.ByteArray(32); + if (d < 32) + return -1; + salsa20_1._stream(x, 0, 32, n, k); + if (_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) + return -1; + salsa20_1._stream_xor(m, 0, c, 0, d, n, k); + for (var i = 0; i < 32; i++) + m[i] = 0; + return 0; + } + function _onetimeauth(out, outpos, m, mpos, n, k) { + var s = poly1305_1.poly1305_init(k); + poly1305_1.poly1305_update(s, m, mpos, n); + poly1305_1.poly1305_finish(s, out, outpos); + return 0; + } + exports._onetimeauth = _onetimeauth; + function _onetimeauth_verify(h, hpos, m, mpos, n, k) { + var x = array_1.ByteArray(16); + _onetimeauth(x, 0, m, mpos, n, k); + return verify_1._verify_16(h, hpos, x, 0); + } + + },{"./array":141,"./check":146,"./poly1305":154,"./salsa20":156,"./verify":162}],160:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var array_1 = require("./array"); + var verify_1 = require("./verify"); + var core_1 = require("./core"); + var random_1 = require("./random"); + var curve25519_1 = require("./curve25519"); + var hash_1 = require("./hash"); + var check_1 = require("./check"); + function sign(msg, secretKey) { + check_1.checkArrayTypes(msg, secretKey); + if (secretKey.length !== 64 /* SecretKey */) + throw new Error('bad secret key size'); + var signedMsg = array_1.ByteArray(64 /* Signature */ + msg.length); + _sign(signedMsg, msg, msg.length, secretKey); + return signedMsg; + } + exports.sign = sign; + function sign_open(signedMsg, publicKey) { + check_1.checkArrayTypes(signedMsg, publicKey); + if (publicKey.length !== 32 /* PublicKey */) + throw new Error('bad public key size'); + var tmp = array_1.ByteArray(signedMsg.length); + var mlen = _sign_open(tmp, signedMsg, signedMsg.length, publicKey); + if (mlen < 0) + return; + var m = array_1.ByteArray(mlen); + for (var i = 0; i < m.length; i++) + m[i] = tmp[i]; + return m; + } + exports.sign_open = sign_open; + function sign_detached(msg, secretKey) { + var signedMsg = sign(msg, secretKey); + var sig = array_1.ByteArray(64 /* Signature */); + for (var i = 0; i < sig.length; i++) + sig[i] = signedMsg[i]; + return sig; + } + exports.sign_detached = sign_detached; + function sign_detached_verify(msg, sig, publicKey) { + check_1.checkArrayTypes(msg, sig, publicKey); + if (sig.length !== 64 /* Signature */) + throw new Error('bad signature size'); + if (publicKey.length !== 32 /* PublicKey */) + throw new Error('bad public key size'); + var sm = array_1.ByteArray(64 /* Signature */ + msg.length); + var m = array_1.ByteArray(64 /* Signature */ + msg.length); + var i; + for (i = 0; i < 64 /* Signature */; i++) + sm[i] = sig[i]; + for (i = 0; i < msg.length; i++) + sm[i + 64 /* Signature */] = msg[i]; + return _sign_open(m, sm, sm.length, publicKey) >= 0; + } + exports.sign_detached_verify = sign_detached_verify; + function sign_keyPair() { + var pk = array_1.ByteArray(32 /* PublicKey */); + var sk = array_1.ByteArray(64 /* SecretKey */); + _sign_keypair(pk, sk, false); + return { publicKey: pk, secretKey: sk }; + } + exports.sign_keyPair = sign_keyPair; + function sign_keyPair_fromSecretKey(secretKey) { + check_1.checkArrayTypes(secretKey); + if (secretKey.length !== 64 /* SecretKey */) + throw new Error('bad secret key size'); + var pk = array_1.ByteArray(32 /* PublicKey */); + for (var i = 0; i < pk.length; i++) + pk[i] = secretKey[32 + i]; + return { publicKey: pk, secretKey: array_1.ByteArray(secretKey) }; + } + exports.sign_keyPair_fromSecretKey = sign_keyPair_fromSecretKey; + function sign_keyPair_fromSeed(seed) { + check_1.checkArrayTypes(seed); + if (seed.length !== 32 /* Seed */) + throw new Error('bad seed size'); + var pk = array_1.ByteArray(32 /* PublicKey */); + var sk = array_1.ByteArray(64 /* SecretKey */); + for (var i = 0; i < 32; i++) + sk[i] = seed[i]; + _sign_keypair(pk, sk, true); + return { publicKey: pk, secretKey: sk }; + } + exports.sign_keyPair_fromSeed = sign_keyPair_fromSeed; + // low level + function _sign_keypair(pk, sk, seeded) { + var d = array_1.ByteArray(64); + var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; + var i; + if (!seeded) + random_1._randomBytes(sk, 32); + hash_1._hash(d, sk, 32); + d[0] &= 248; + d[31] &= 127; + d[31] |= 64; + scalarbase(p, d); + pack(pk, p); + for (i = 0; i < 32; i++) + sk[i + 32] = pk[i]; + return 0; + } + // Note: difference from C - smlen returned, not passed as argument. + function _sign(sm, m, n, sk) { + var d = array_1.ByteArray(64), h = array_1.ByteArray(64), r = array_1.ByteArray(64); + var x = array_1.NumArray(64); + var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; + var i, j; + hash_1._hash(d, sk, 32); + d[0] &= 248; + d[31] &= 127; + d[31] |= 64; + var smlen = n + 64; + for (i = 0; i < n; i++) + sm[64 + i] = m[i]; + for (i = 0; i < 32; i++) + sm[32 + i] = d[32 + i]; + hash_1._hash(r, sm.subarray(32), n + 32); + reduce(r); + scalarbase(p, r); + pack(sm, p); + for (i = 32; i < 64; i++) + sm[i] = sk[i]; + hash_1._hash(h, sm, n + 64); + reduce(h); + for (i = 0; i < 64; i++) + x[i] = 0; + for (i = 0; i < 32; i++) + x[i] = r[i]; + for (i = 0; i < 32; i++) { + for (j = 0; j < 32; j++) { + x[i + j] += h[i] * d[j]; + } + } + modL(sm.subarray(32), x); + return smlen; + } + function _sign_open(m, sm, n, pk) { + var t = array_1.ByteArray(32), h = array_1.ByteArray(64); + var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()], q = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; + var i, mlen; + mlen = -1; + if (n < 64 || unpackneg(q, pk)) + return -1; + for (i = 0; i < n; i++) + m[i] = sm[i]; + for (i = 0; i < 32; i++) + m[i + 32] = pk[i]; + hash_1._hash(h, m, n); + reduce(h); + scalarmult(p, q, h); + scalarbase(q, sm.subarray(32)); + add(p, q); + pack(t, p); + n -= 64; + if (verify_1._verify_32(sm, 0, t, 0)) { + for (i = 0; i < n; i++) + m[i] = 0; + return -1; + } + for (i = 0; i < n; i++) + m[i] = sm[i + 64]; + mlen = n; + return mlen; + } + function scalarbase(p, s) { + var q = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; + curve25519_1.set25519(q[0], core_1.X); + curve25519_1.set25519(q[1], core_1.Y); + curve25519_1.set25519(q[2], core_1.gf1); + core_1.M(q[3], core_1.X, core_1.Y); + scalarmult(p, q, s); + } + exports.scalarbase = scalarbase; + function scalarmult(p, q, s) { + var b, i; + curve25519_1.set25519(p[0], core_1.gf0); + curve25519_1.set25519(p[1], core_1.gf1); + curve25519_1.set25519(p[2], core_1.gf1); + curve25519_1.set25519(p[3], core_1.gf0); + for (i = 255; i >= 0; --i) { + b = (s[(i / 8) | 0] >> (i & 7)) & 1; + cswap(p, q, b); + add(q, p); + add(p, p); + cswap(p, q, b); + } + } + exports.scalarmult = scalarmult; + function pack(r, p) { + var tx = core_1.gf(), ty = core_1.gf(), zi = core_1.gf(); + curve25519_1.inv25519(zi, p[2]); + core_1.M(tx, p[0], zi); + core_1.M(ty, p[1], zi); + curve25519_1.pack25519(r, ty); + r[31] ^= curve25519_1.par25519(tx) << 7; + } + function unpackneg(r, p) { + var t = core_1.gf(), chk = core_1.gf(), num = core_1.gf(), den = core_1.gf(), den2 = core_1.gf(), den4 = core_1.gf(), den6 = core_1.gf(); + curve25519_1.set25519(r[2], core_1.gf1); + curve25519_1.unpack25519(r[1], p); + core_1.S(num, r[1]); + core_1.M(den, num, core_1.D); + core_1.Z(num, num, r[2]); + core_1.A(den, r[2], den); + core_1.S(den2, den); + core_1.S(den4, den2); + core_1.M(den6, den4, den2); + core_1.M(t, den6, num); + core_1.M(t, t, den); + pow2523(t, t); + core_1.M(t, t, num); + core_1.M(t, t, den); + core_1.M(t, t, den); + core_1.M(r[0], t, den); + core_1.S(chk, r[0]); + core_1.M(chk, chk, den); + if (curve25519_1.neq25519(chk, num)) + core_1.M(r[0], r[0], core_1.I); + core_1.S(chk, r[0]); + core_1.M(chk, chk, den); + if (curve25519_1.neq25519(chk, num)) + return -1; + if (curve25519_1.par25519(r[0]) === (p[31] >> 7)) + core_1.Z(r[0], core_1.gf0, r[0]); + core_1.M(r[3], r[0], r[1]); + return 0; + } + function reduce(r) { + var x = array_1.NumArray(64); + var i; + for (i = 0; i < 64; i++) + x[i] = r[i]; + for (i = 0; i < 64; i++) + r[i] = 0; + modL(r, x); + } + var L = array_1.NumArray([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]); + function modL(r, x) { + var carry, i, j, k; + for (i = 63; i >= 32; --i) { + carry = 0; + for (j = i - 32, k = i - 12; j < k; ++j) { + x[j] += carry - 16 * x[i] * L[j - (i - 32)]; + carry = (x[j] + 128) >> 8; + x[j] -= carry * 256; + } + x[j] += carry; + x[i] = 0; + } + carry = 0; + for (j = 0; j < 32; j++) { + x[j] += carry - (x[31] >> 4) * L[j]; + carry = x[j] >> 8; + x[j] &= 255; + } + for (j = 0; j < 32; j++) + x[j] -= carry * L[j]; + for (i = 0; i < 32; i++) { + x[i + 1] += x[i] >> 8; + r[i] = x[i] & 255; + } + } + function add(p, q) { + var a = core_1.gf(), b = core_1.gf(), c = core_1.gf(), d = core_1.gf(), e = core_1.gf(), f = core_1.gf(), g = core_1.gf(), h = core_1.gf(), t = core_1.gf(); + core_1.Z(a, p[1], p[0]); + core_1.Z(t, q[1], q[0]); + core_1.M(a, a, t); + core_1.A(b, p[0], p[1]); + core_1.A(t, q[0], q[1]); + core_1.M(b, b, t); + core_1.M(c, p[3], q[3]); + core_1.M(c, c, core_1.D2); + core_1.M(d, p[2], q[2]); + core_1.A(d, d, d); + core_1.Z(e, b, a); + core_1.Z(f, d, c); + core_1.A(g, d, c); + core_1.A(h, b, a); + core_1.M(p[0], e, f); + core_1.M(p[1], h, g); + core_1.M(p[2], g, f); + core_1.M(p[3], e, h); + } + function cswap(p, q, b) { + for (var i = 0; i < 4; i++) { + curve25519_1.sel25519(p[i], q[i], b); + } + } + function pow2523(o, i) { + var c = core_1.gf(); + var a; + for (a = 0; a < 16; a++) + c[a] = i[a]; + for (a = 250; a >= 0; a--) { + core_1.S(c, c); + if (a !== 1) + core_1.M(c, c, i); + } + for (a = 0; a < 16; a++) + o[a] = c[a]; + } + + },{"./array":141,"./check":146,"./core":150,"./curve25519":151,"./hash":152,"./random":155,"./verify":162}],161:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function validateBase64(s) { + if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)) { + throw new TypeError('invalid base64 string'); + } + } + exports.validateBase64 = validateBase64; + function validateHex(s) { + if (!/^(?:[A-Fa-f0-9]{2})+$/.test(s)) { + throw new TypeError('invalid hex string'); + } + } + exports.validateHex = validateHex; + + },{}],162:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var check_1 = require("./check"); + function vn(x, xi, y, yi, n) { + var i, d = 0; + for (i = 0; i < n; i++) + d |= x[xi + i] ^ y[yi + i]; + return (1 & ((d - 1) >>> 8)) - 1; + } + function _verify_16(x, xi, y, yi) { + return vn(x, xi, y, yi, 16); + } + exports._verify_16 = _verify_16; + function _verify_32(x, xi, y, yi) { + return vn(x, xi, y, yi, 32); + } + exports._verify_32 = _verify_32; + function verify(x, y) { + check_1.checkArrayTypes(x, y); + // Zero length arguments are considered not equal + return x.length > 0 && y.length > 0 && + x.length == y.length && + vn(x, 0, y, 0, x.length) == 0; + } + exports.verify = verify; + + },{"./check":146}],163:[function(require,module,exports){ + (function (Buffer){(function (){ + // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri. + // Public domain. + (function(root, f) { + 'use strict'; + if (typeof module !== 'undefined' && module.exports) module.exports = f(); + else if (root.nacl) root.nacl.util = f(); + else { + root.nacl = {}; + root.nacl.util = f(); + } + }(this, function() { + 'use strict'; + + var util = {}; + + function validateBase64(s) { + if (!(/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s))) { + throw new TypeError('invalid encoding'); + } + } + + util.decodeUTF8 = function(s) { + if (typeof s !== 'string') throw new TypeError('expected string'); + var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length); + for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); + return b; + }; + + util.encodeUTF8 = function(arr) { + var i, s = []; + for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i])); + return decodeURIComponent(escape(s.join(''))); + }; + + if (typeof atob === 'undefined') { + // Node.js + + if (typeof Buffer.from !== 'undefined') { + // Node v6 and later + util.encodeBase64 = function (arr) { // v6 and later + return Buffer.from(arr).toString('base64'); + }; + + util.decodeBase64 = function (s) { + validateBase64(s); + return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0)); + }; + + } else { + // Node earlier than v6 + util.encodeBase64 = function (arr) { // v6 and later + return (new Buffer(arr)).toString('base64'); + }; + + util.decodeBase64 = function(s) { + validateBase64(s); + return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0)); + }; + } + + } else { + // Browsers + + util.encodeBase64 = function(arr) { + var i, s = [], len = arr.length; + for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i])); + return btoa(s.join('')); + }; + + util.decodeBase64 = function(s) { + validateBase64(s); + var i, d = atob(s), b = new Uint8Array(d.length); + for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); + return b; + }; + + } + + return util; + + })); + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":222}],164:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Deserializer = exports.defaultTypeResolver = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function defaultTypeResolver(sourceObject, knownTypes) { + if (sourceObject.__type != null) { + return knownTypes.get(sourceObject.__type); + } + } + exports.defaultTypeResolver = defaultTypeResolver; + var Deserializer = (function () { + function Deserializer() { + this.typeResolver = defaultTypeResolver; + this.errorHandler = helpers_1.logError; + this.deserializationStrategy = new Map([ + [type_descriptor_1.AnyT.ctor, helpers_1.identity], + [Number, deserializeDirectly], + [String, deserializeDirectly], + [Boolean, deserializeDirectly], + [Date, deserializeDate], + [ArrayBuffer, stringToArrayBuffer], + [DataView, stringToDataView], + [Array, convertAsArray], + [Set, convertAsSet], + [Map, convertAsMap], + [Float32Array, convertAsFloatArray], + [Float64Array, convertAsFloatArray], + [Uint8Array, convertAsUintArray], + [Uint8ClampedArray, convertAsUintArray], + [Uint16Array, convertAsUintArray], + [Uint32Array, convertAsUintArray], + ]); + } + Deserializer.prototype.setDeserializationStrategy = function (type, deserializer) { + this.deserializationStrategy.set(type, deserializer); + }; + Deserializer.prototype.setNameResolver = function (nameResolverCallback) { + this.nameResolver = nameResolverCallback; + }; + Deserializer.prototype.setTypeResolver = function (typeResolverCallback) { + if (typeof typeResolverCallback !== 'function') { + throw new TypeError('\'typeResolverCallback\' is not a function.'); + } + this.typeResolver = typeResolverCallback; + }; + Deserializer.prototype.getTypeResolver = function () { + return this.typeResolver; + }; + Deserializer.prototype.setErrorHandler = function (errorHandlerCallback) { + if (typeof errorHandlerCallback !== 'function') { + throw new TypeError('\'errorHandlerCallback\' is not a function.'); + } + this.errorHandler = errorHandlerCallback; + }; + Deserializer.prototype.getErrorHandler = function () { + return this.errorHandler; + }; + Deserializer.prototype.convertSingleValue = function (sourceObject, typeDescriptor, knownTypes, memberName, memberOptions) { + if (memberName === void 0) { memberName = 'object'; } + if (this.retrievePreserveNull(memberOptions) && sourceObject === null) { + return null; + } + else if (!helpers_1.isValueDefined(sourceObject)) { + return; + } + var deserializer = this.deserializationStrategy.get(typeDescriptor.ctor); + if (deserializer !== undefined) { + return deserializer(sourceObject, typeDescriptor, knownTypes, memberName, this, memberOptions); + } + if (typeof sourceObject === 'object') { + return convertAsObject(sourceObject, typeDescriptor, knownTypes, memberName, this); + } + var error = "Could not deserialize '" + memberName + "'; don't know how to deserialize type"; + if (typeDescriptor.hasFriendlyName()) { + error += " '" + typeDescriptor.ctor.name + "'"; + } + this.errorHandler(new TypeError(error + ".")); + }; + Deserializer.prototype.instantiateType = function (ctor) { + return new ctor(); + }; + Deserializer.prototype.mergeKnownTypes = function () { + var _this = this; + var knownTypeMaps = []; + for (var _i = 0; _i < arguments.length; _i++) { + knownTypeMaps[_i] = arguments[_i]; + } + var result = new Map(); + knownTypeMaps.forEach(function (knownTypes) { + knownTypes.forEach(function (ctor, name) { + if (_this.nameResolver === undefined) { + result.set(name, ctor); + } + else { + result.set(_this.nameResolver(ctor), ctor); + } + }); + }); + return result; + }; + Deserializer.prototype.createKnownTypesMap = function (knowTypes) { + var _this = this; + var map = new Map(); + knowTypes.forEach(function (ctor) { + if (_this.nameResolver === undefined) { + var knownTypeMeta = metadata_1.JsonObjectMetadata.getFromConstructor(ctor); + var customName = (knownTypeMeta === null || knownTypeMeta === void 0 ? void 0 : knownTypeMeta.isExplicitlyMarked) === true + ? knownTypeMeta.name + : null; + map.set(customName !== null && customName !== void 0 ? customName : ctor.name, ctor); + } + else { + map.set(_this.nameResolver(ctor), ctor); + } + }); + return map; + }; + Deserializer.prototype.retrievePreserveNull = function (memberOptions) { + return options_base_1.getOptionValue('preserveNull', options_base_1.mergeOptions(this.options, memberOptions)); + }; + return Deserializer; + }()); + exports.Deserializer = Deserializer; + function throwTypeMismatchError(targetType, expectedSourceType, actualSourceType, memberName) { + throw new TypeError("Could not deserialize " + memberName + " as " + targetType + ":" + + (" expected " + expectedSourceType + ", got " + actualSourceType + ".")); + } + function makeTypeErrorMessage(expectedType, actualType, memberName) { + var expectedTypeName = typeof expectedType === 'function' + ? helpers_1.nameof(expectedType) + : expectedType; + var actualTypeName = typeof actualType === 'function' ? helpers_1.nameof(actualType) : actualType; + return "Could not deserialize " + memberName + ": expected '" + expectedTypeName + "'," + + (" got '" + actualTypeName + "'."); + } + function srcTypeNameForDebug(sourceObject) { + return sourceObject == null ? 'undefined' : helpers_1.nameof(sourceObject.constructor); + } + function deserializeDirectly(sourceObject, typeDescriptor, knownTypes, objectName) { + if (sourceObject.constructor !== typeDescriptor.ctor) { + throw new TypeError(makeTypeErrorMessage(helpers_1.nameof(typeDescriptor.ctor), sourceObject.constructor, objectName)); + } + return sourceObject; + } + function convertAsObject(sourceObject, typeDescriptor, knownTypes, memberName, deserializer) { + if (typeof sourceObject !== 'object' || sourceObject === null) { + deserializer.getErrorHandler()(new TypeError("Cannot deserialize " + memberName + ": 'sourceObject' must be a defined object.")); + return undefined; + } + var expectedSelfType = typeDescriptor.ctor; + var sourceObjectMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(expectedSelfType); + var knownTypeConstructors = knownTypes; + var typeResolver = deserializer.getTypeResolver(); + if (sourceObjectMetadata !== undefined) { + sourceObjectMetadata.processDeferredKnownTypes(); + knownTypeConstructors = deserializer.mergeKnownTypes(knownTypeConstructors, deserializer.createKnownTypesMap(sourceObjectMetadata.knownTypes)); + if (sourceObjectMetadata.typeResolver != null) { + typeResolver = sourceObjectMetadata.typeResolver; + } + } + var typeFromTypeHint = typeResolver(sourceObject, knownTypeConstructors); + if (typeFromTypeHint != null) { + if (helpers_1.isSubtypeOf(typeFromTypeHint, expectedSelfType)) { + expectedSelfType = typeFromTypeHint; + sourceObjectMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(typeFromTypeHint); + if (sourceObjectMetadata !== undefined) { + knownTypeConstructors = deserializer.mergeKnownTypes(knownTypeConstructors, deserializer.createKnownTypesMap(sourceObjectMetadata.knownTypes)); + } + } + } + if ((sourceObjectMetadata === null || sourceObjectMetadata === void 0 ? void 0 : sourceObjectMetadata.isExplicitlyMarked) === true) { + var sourceMetadata_1 = sourceObjectMetadata; + var sourceObjectWithDeserializedProperties_1 = {}; + var classOptions_1 = options_base_1.mergeOptions(deserializer.options, sourceMetadata_1.options); + sourceMetadata_1.dataMembers.forEach(function (objMemberMetadata, propKey) { + var objMemberValue = sourceObject[propKey]; + var objMemberDebugName = helpers_1.nameof(sourceMetadata_1.classType) + "." + propKey; + var objMemberOptions = options_base_1.mergeOptions(classOptions_1, objMemberMetadata.options); + var revivedValue; + if (objMemberMetadata.deserializer != null) { + revivedValue = objMemberMetadata.deserializer(objMemberValue); + } + else if (objMemberMetadata.type == null) { + throw new TypeError("Cannot deserialize " + objMemberDebugName + " there is" + + " no constructor nor deserialization function to use."); + } + else { + revivedValue = deserializer.convertSingleValue(objMemberValue, objMemberMetadata.type(), knownTypeConstructors, objMemberDebugName, objMemberOptions); + } + if (helpers_1.isValueDefined(revivedValue) + || (deserializer.retrievePreserveNull(objMemberOptions) + && revivedValue === null)) { + sourceObjectWithDeserializedProperties_1[objMemberMetadata.key] = revivedValue; + } + else if (objMemberMetadata.isRequired === true) { + deserializer.getErrorHandler()(new TypeError("Missing required member '" + objMemberDebugName + "'.")); + } + }); + var targetObject = void 0; + if (typeof sourceObjectMetadata.initializerCallback === 'function') { + try { + targetObject = sourceObjectMetadata.initializerCallback(sourceObjectWithDeserializedProperties_1, sourceObject); + if (targetObject == null) { + throw new TypeError("Cannot deserialize " + memberName + ":" + + " 'initializer' function returned undefined/null" + + (", but '" + helpers_1.nameof(sourceObjectMetadata.classType) + "' was expected.")); + } + else if (!(targetObject instanceof sourceObjectMetadata.classType)) { + throw new TypeError("Cannot deserialize " + memberName + ":" + + ("'initializer' returned '" + helpers_1.nameof(targetObject.constructor) + "'") + + (", but '" + helpers_1.nameof(sourceObjectMetadata.classType) + "' was expected") + + (", and '" + helpers_1.nameof(targetObject.constructor) + "' is not a subtype of") + + (" '" + helpers_1.nameof(sourceObjectMetadata.classType) + "'")); + } + } + catch (e) { + deserializer.getErrorHandler()(e); + return undefined; + } + } + else { + targetObject = deserializer.instantiateType(expectedSelfType); + } + Object.assign(targetObject, sourceObjectWithDeserializedProperties_1); + var methodName = sourceObjectMetadata.onDeserializedMethodName; + if (methodName != null) { + if (typeof targetObject[methodName] === 'function') { + targetObject[methodName](); + } + else if (typeof targetObject.constructor[methodName] === 'function') { + targetObject.constructor[methodName](); + } + else { + deserializer.getErrorHandler()(new TypeError("onDeserialized callback" + + ("'" + helpers_1.nameof(sourceObjectMetadata.classType) + "." + methodName + "' is not a method."))); + } + } + return targetObject; + } + else { + var targetObject_1 = {}; + Object.keys(sourceObject).forEach(function (sourceKey) { + targetObject_1[sourceKey] = deserializer.convertSingleValue(sourceObject[sourceKey], new type_descriptor_1.ConcreteTypeDescriptor(sourceObject[sourceKey].constructor), knownTypes, sourceKey); + }); + return targetObject_1; + } + } + function convertAsArray(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor)) { + throw new TypeError("Could not deserialize " + memberName + " as Array: incorrect TypeDescriptor detected," + + ' please use proper annotation or function for this type'); + } + if (!Array.isArray(sourceObject)) { + deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(Array, sourceObject.constructor, memberName))); + return []; + } + if (typeDescriptor.elementType == null) { + deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Array: missing constructor reference of" + + " Array elements.")); + return []; + } + return sourceObject.map(function (element, i) { + try { + return deserializer.convertSingleValue(element, typeDescriptor.elementType, knownTypes, memberName + "[" + i + "]", memberOptions); + } + catch (e) { + deserializer.getErrorHandler()(e); + return undefined; + } + }); + } + function convertAsSet(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor)) { + throw new TypeError("Could not deserialize " + memberName + " as Set: incorrect TypeDescriptor detected," + + " please use proper annotation or function for this type"); + } + if (!Array.isArray(sourceObject)) { + deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(Array, sourceObject.constructor, memberName))); + return new Set(); + } + if (typeDescriptor.elementType == null) { + deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Set: missing constructor reference of" + + " Set elements.")); + return new Set(); + } + var resultSet = new Set(); + sourceObject.forEach(function (element, i) { + try { + resultSet.add(deserializer.convertSingleValue(element, typeDescriptor.elementType, knownTypes, memberName + "[" + i + "]", memberOptions)); + } + catch (e) { + deserializer.getErrorHandler()(e); + } + }); + return resultSet; + } + function isExpectedMapShape(source, expectedShape) { + return (expectedShape === 0 && Array.isArray(source)) + || (expectedShape === 1 && typeof source === 'object'); + } + function convertAsMap(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor)) { + throw new TypeError("Could not deserialize " + memberName + " as Map: incorrect TypeDescriptor detected," + + 'please use proper annotation or function for this type'); + } + var expectedShape = typeDescriptor.getCompleteOptions().shape; + if (!isExpectedMapShape(sourceObject, expectedShape)) { + var expectedType = expectedShape === 0 ? Array : Object; + deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(expectedType, sourceObject.constructor, memberName))); + return new Map(); + } + if (typeDescriptor.keyType == null) { + deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Map: missing key constructor.")); + return new Map(); + } + if (typeDescriptor.valueType == null) { + deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Map: missing value constructor.")); + return new Map(); + } + var keyMemberName = memberName + "[].key"; + var valueMemberName = memberName + "[].value"; + var resultMap = new Map(); + if (expectedShape === 1) { + Object.keys(sourceObject).forEach(function (key) { + try { + var resultKey = deserializer.convertSingleValue(key, typeDescriptor.keyType, knownTypes, keyMemberName, memberOptions); + if (helpers_1.isValueDefined(resultKey)) { + resultMap.set(resultKey, deserializer.convertSingleValue(sourceObject[key], typeDescriptor.valueType, knownTypes, valueMemberName, memberOptions)); + } + } + catch (e) { + deserializer.getErrorHandler()(e); + } + }); + } + else { + sourceObject.forEach(function (element) { + try { + var key = deserializer.convertSingleValue(element.key, typeDescriptor.keyType, knownTypes, keyMemberName, memberOptions); + if (helpers_1.isValueDefined(key)) { + resultMap.set(key, deserializer.convertSingleValue(element.value, typeDescriptor.valueType, knownTypes, valueMemberName, memberOptions)); + } + } + catch (e) { + deserializer.getErrorHandler()(e); + } + }); + } + return resultMap; + } + function deserializeDate(sourceObject, typeDescriptor, knownTypes, memberName) { + if (typeof sourceObject === 'number') { + var isInteger = sourceObject % 1 === 0; + if (!isInteger) { + throw new TypeError("Could not deserialize " + memberName + " as Date:" + + " expected an integer, got a number with decimal places."); + } + return new Date(sourceObject); + } + else if (typeof sourceObject === 'string') { + return new Date(sourceObject); + } + else if (sourceObject instanceof Date) { + return sourceObject; + } + else { + throwTypeMismatchError('Date', 'an ISO-8601 string', srcTypeNameForDebug(sourceObject), memberName); + } + } + function stringToArrayBuffer(sourceObject, typeDescriptor, knownTypes, memberName) { + if (typeof sourceObject !== 'string') { + throwTypeMismatchError('ArrayBuffer', 'a string source', srcTypeNameForDebug(sourceObject), memberName); + } + return createArrayBufferFromString(sourceObject); + } + function stringToDataView(sourceObject, typeDescriptor, knownTypes, memberName) { + if (typeof sourceObject !== 'string') { + throwTypeMismatchError('DataView', 'a string source', srcTypeNameForDebug(sourceObject), memberName); + } + return new DataView(createArrayBufferFromString(sourceObject)); + } + function createArrayBufferFromString(input) { + var buf = new ArrayBuffer(input.length * 2); + var bufView = new Uint16Array(buf); + for (var i = 0, strLen = input.length; i < strLen; i++) { + bufView[i] = input.charCodeAt(i); + } + return buf; + } + function convertAsFloatArray(sourceObject, typeDescriptor, knownTypes, memberName) { + var constructor = typeDescriptor.ctor; + if (Array.isArray(sourceObject) && sourceObject.every(function (elem) { return !isNaN(elem); })) { + return new constructor(sourceObject); + } + return throwTypeMismatchError(constructor.name, 'a numeric source array', srcTypeNameForDebug(sourceObject), memberName); + } + function convertAsUintArray(sourceObject, typeDescriptor, knownTypes, memberName) { + var constructor = typeDescriptor.ctor; + if (Array.isArray(sourceObject) && sourceObject.every(function (elem) { return !isNaN(elem); })) { + return new constructor(sourceObject.map(function (value) { return ~~value; })); + } + return throwTypeMismatchError(typeDescriptor.ctor.name, 'a numeric source array', srcTypeNameForDebug(sourceObject), memberName); + } + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],165:[function(require,module,exports){ + "use strict"; + var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.identity = exports.nameof = exports.isReflectMetadataSupported = exports.isInstanceOf = exports.isValueDefined = exports.logWarning = exports.logMessage = exports.logError = exports.isSubtypeOf = exports.parseToJSObject = exports.shouldOmitParseString = exports.isObject = exports.isTypeTypedArray = exports.isDirectlyDeserializableNativeType = exports.isDirectlySerializableNativeType = exports.MISSING_REFLECT_CONF_MSG = exports.LAZY_TYPE_EXPLANATION = void 0; + var type_descriptor_1 = require("./type-descriptor"); + exports.LAZY_TYPE_EXPLANATION = "If the type is not yet defined, for example due to circular references, add '() => ' before it. E.g. @jsonMember(() => Foo)"; + exports.MISSING_REFLECT_CONF_MSG = 'Make sure that you have both "experimentalDecorators"' + + ' and "emitDecoratorMetadata" enabled in your tsconfig.json'; + function isDirectlySerializableNativeType(type) { + return [Date, Number, String, Boolean].indexOf(type) !== -1; + } + exports.isDirectlySerializableNativeType = isDirectlySerializableNativeType; + function isDirectlyDeserializableNativeType(type) { + return [Number, String, Boolean].indexOf(type) !== -1; + } + exports.isDirectlyDeserializableNativeType = isDirectlyDeserializableNativeType; + function isTypeTypedArray(type) { + return [ + Float32Array, + Float64Array, + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + ].indexOf(type) !== -1; + } + exports.isTypeTypedArray = isTypeTypedArray; + function isObject(value) { + return typeof value === 'object'; + } + exports.isObject = isObject; + function shouldOmitParseString(jsonStr, expectedType) { + var expectsTypesSerializedAsStrings = expectedType === String + || expectedType === ArrayBuffer + || expectedType === DataView; + var hasQuotes = jsonStr.length >= 2 + && jsonStr[0] === '"' + && jsonStr[jsonStr.length - 1] === '"'; + if (expectedType === Date) { + var isNumber = !isNaN(Number(jsonStr.trim())); + return !hasQuotes && !isNumber; + } + return expectsTypesSerializedAsStrings && !hasQuotes; + } + exports.shouldOmitParseString = shouldOmitParseString; + function parseToJSObject(json, expectedType) { + if (typeof json !== 'string' || shouldOmitParseString(json, expectedType)) { + return json; + } + return JSON.parse(json); + } + exports.parseToJSObject = parseToJSObject; + function isSubtypeOf(A, B) { + return A === B || A.prototype instanceof B; + } + exports.isSubtypeOf = isSubtypeOf; + function logError(message) { + var optionalParams = []; + for (var _i = 1; _i < arguments.length; _i++) { + optionalParams[_i - 1] = arguments[_i]; + } + if (typeof console === 'object' && typeof console.error === 'function') { + console.error.apply(console, __spreadArrays([message], optionalParams)); + } + else if (typeof console === 'object' && typeof console.log === 'function') { + console.log.apply(console, __spreadArrays(["ERROR: " + message], optionalParams)); + } + } + exports.logError = logError; + function logMessage(message) { + var optionalParams = []; + for (var _i = 1; _i < arguments.length; _i++) { + optionalParams[_i - 1] = arguments[_i]; + } + if (typeof console === 'object' && typeof console.log === 'function') { + console.log.apply(console, __spreadArrays([message], optionalParams)); + } + } + exports.logMessage = logMessage; + function logWarning(message) { + var optionalParams = []; + for (var _i = 1; _i < arguments.length; _i++) { + optionalParams[_i - 1] = arguments[_i]; + } + if (typeof console === 'object' && typeof console.warn === 'function') { + console.warn.apply(console, __spreadArrays([message], optionalParams)); + } + else if (typeof console === 'object' && typeof console.log === 'function') { + console.log.apply(console, __spreadArrays(["WARNING: " + message], optionalParams)); + } + } + exports.logWarning = logWarning; + function isValueDefined(value) { + return !(typeof value === 'undefined' || value === null); + } + exports.isValueDefined = isValueDefined; + function isInstanceOf(value, constructor) { + if (constructor === type_descriptor_1.AnyT.ctor) { + return true; + } + else if (typeof value === 'number') { + return constructor === Number; + } + else if (typeof value === 'string') { + return constructor === String; + } + else if (typeof value === 'boolean') { + return constructor === Boolean; + } + else if (isObject(value)) { + return value instanceof constructor; + } + return false; + } + exports.isInstanceOf = isInstanceOf; + exports.isReflectMetadataSupported = typeof Reflect === 'object' && typeof Reflect.getMetadata === 'function'; + function nameof(fn) { + if (typeof fn.name === 'string') { + return fn.name; + } + return 'undefined'; + } + exports.nameof = nameof; + function identity(arg) { + return arg; + } + exports.identity = identity; + + },{"./type-descriptor":177}],166:[function(require,module,exports){ + "use strict"; + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var parser_1 = require("./parser"); + Object.defineProperty(exports, "TypedJSON", { enumerable: true, get: function () { return parser_1.TypedJSON; } }); + Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return parser_1.defaultTypeResolver; } }); + Object.defineProperty(exports, "defaultTypeEmitter", { enumerable: true, get: function () { return parser_1.defaultTypeEmitter; } }); + var metadata_1 = require("./metadata"); + Object.defineProperty(exports, "JsonObjectMetadata", { enumerable: true, get: function () { return metadata_1.JsonObjectMetadata; } }); + var json_object_1 = require("./json-object"); + Object.defineProperty(exports, "jsonObject", { enumerable: true, get: function () { return json_object_1.jsonObject; } }); + var json_member_1 = require("./json-member"); + Object.defineProperty(exports, "jsonMember", { enumerable: true, get: function () { return json_member_1.jsonMember; } }); + var json_array_member_1 = require("./json-array-member"); + Object.defineProperty(exports, "jsonArrayMember", { enumerable: true, get: function () { return json_array_member_1.jsonArrayMember; } }); + var json_set_member_1 = require("./json-set-member"); + Object.defineProperty(exports, "jsonSetMember", { enumerable: true, get: function () { return json_set_member_1.jsonSetMember; } }); + var json_map_member_1 = require("./json-map-member"); + Object.defineProperty(exports, "jsonMapMember", { enumerable: true, get: function () { return json_map_member_1.jsonMapMember; } }); + var to_json_1 = require("./to-json"); + Object.defineProperty(exports, "toJson", { enumerable: true, get: function () { return to_json_1.toJson; } }); + var type_descriptor_1 = require("./type-descriptor"); + Object.defineProperty(exports, "ArrayT", { enumerable: true, get: function () { return type_descriptor_1.ArrayT; } }); + Object.defineProperty(exports, "AnyT", { enumerable: true, get: function () { return type_descriptor_1.AnyT; } }); + Object.defineProperty(exports, "SetT", { enumerable: true, get: function () { return type_descriptor_1.SetT; } }); + Object.defineProperty(exports, "MapT", { enumerable: true, get: function () { return type_descriptor_1.MapT; } }); + Object.defineProperty(exports, "SetTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.SetTypeDescriptor; } }); + Object.defineProperty(exports, "ArrayTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.ArrayTypeDescriptor; } }); + Object.defineProperty(exports, "MapTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.MapTypeDescriptor; } }); + __exportStar(require("./types"), exports); + + },{"./json-array-member":167,"./json-map-member":168,"./json-member":169,"./json-object":170,"./json-set-member":171,"./metadata":172,"./parser":174,"./to-json":176,"./type-descriptor":177,"./types":178}],167:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.createArrayType = exports.jsonArrayMember = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function jsonArrayMember(maybeTypeThunk, options) { + if (options === void 0) { options = {}; } + return function (target, propKey) { + var _a; + var decoratorName = "@jsonArrayMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); + var typeThunk = type_descriptor_1.ensureTypeThunk(maybeTypeThunk, decoratorName); + var dimensions = options.dimensions == null ? 1 : options.dimensions; + if (!isNaN(dimensions) && dimensions < 1) { + helpers_1.logError(decoratorName + ": 'dimensions' option must be at least 1."); + return; + } + var reflectedType = helpers_1.isReflectMetadataSupported + ? Reflect.getMetadata('design:type', target, propKey) + : null; + if (reflectedType != null && reflectedType !== Array && reflectedType !== Object) { + helpers_1.logError(decoratorName + ": property is not an Array. " + helpers_1.MISSING_REFLECT_CONF_MSG); + return; + } + metadata_1.injectMetadataInformation(target, propKey, { + type: function () { return createArrayType(type_descriptor_1.ensureTypeDescriptor(typeThunk()), dimensions); }, + emitDefaultValue: options.emitDefaultValue, + isRequired: options.isRequired, + options: options_base_1.extractOptionBase(options), + key: propKey.toString(), + name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), + deserializer: options.deserializer, + serializer: options.serializer, + }); + }; + } + exports.jsonArrayMember = jsonArrayMember; + function createArrayType(elementType, dimensions) { + var type = new type_descriptor_1.ArrayTypeDescriptor(elementType); + for (var i = 1; i < dimensions; ++i) { + type = new type_descriptor_1.ArrayTypeDescriptor(type); + } + return type; + } + exports.createArrayType = createArrayType; + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],168:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.jsonMapMember = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function jsonMapMember(maybeKeyThunk, maybeValueThunk, options) { + if (options === void 0) { options = {}; } + return function (target, propKey) { + var _a; + var decoratorName = "@jsonMapMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); + var keyThunk = type_descriptor_1.ensureTypeThunk(maybeKeyThunk, decoratorName); + var valueThunk = type_descriptor_1.ensureTypeThunk(maybeValueThunk, decoratorName); + var reflectedType = helpers_1.isReflectMetadataSupported + ? Reflect.getMetadata('design:type', target, propKey) + : null; + if (reflectedType != null && reflectedType !== Map && reflectedType !== Object) { + helpers_1.logError(decoratorName + ": property is not a Map. " + helpers_1.MISSING_REFLECT_CONF_MSG); + return; + } + metadata_1.injectMetadataInformation(target, propKey, { + type: function () { return type_descriptor_1.MapT(keyThunk(), valueThunk(), { shape: options.shape }); }, + emitDefaultValue: options.emitDefaultValue, + isRequired: options.isRequired, + options: options_base_1.extractOptionBase(options), + key: propKey.toString(), + name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), + deserializer: options.deserializer, + serializer: options.serializer, + }); + }; + } + exports.jsonMapMember = jsonMapMember; + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],169:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.jsonMember = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function jsonMember(optionsOrPrototype, propertyKeyOrOptions) { + if (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') { + var property = propertyKeyOrOptions; + var prototype = optionsOrPrototype; + var decoratorName = "@jsonMember on " + helpers_1.nameof(prototype.constructor) + "." + String(property); + if (!helpers_1.isReflectMetadataSupported) { + helpers_1.logError(decoratorName + ": ReflectDecorators is required if the type is not explicitly provided with e.g. @jsonMember(Number)"); + return; + } + var reflectPropCtor = Reflect.getMetadata('design:type', prototype, property); + if (reflectPropCtor == null) { + helpers_1.logError(decoratorName + ": could not resolve detected property constructor at runtime. Potential solutions:\n - " + helpers_1.LAZY_TYPE_EXPLANATION + "\n - " + helpers_1.MISSING_REFLECT_CONF_MSG); + return; + } + var typeDescriptor_1 = type_descriptor_1.ensureTypeDescriptor(reflectPropCtor); + if (isSpecialPropertyType(decoratorName, typeDescriptor_1)) { + return; + } + metadata_1.injectMetadataInformation(prototype, property, { + type: function () { return typeDescriptor_1; }, + key: propertyKeyOrOptions.toString(), + name: propertyKeyOrOptions.toString(), + }); + return; + } + return jsonMemberDecoratorFactory(optionsOrPrototype, propertyKeyOrOptions); + } + exports.jsonMember = jsonMember; + function jsonMemberDecoratorFactory(optionsOrType, options) { + return function (target, property) { + var _a; + var decoratorName = "@jsonMember on " + helpers_1.nameof(target.constructor) + "." + String(property); + var typeThunk; + if (type_descriptor_1.isTypelike(optionsOrType) || type_descriptor_1.isTypeThunk(optionsOrType)) { + typeThunk = type_descriptor_1.ensureTypeThunk(optionsOrType, decoratorName); + } + else { + options = optionsOrType; + } + options = options !== null && options !== void 0 ? options : {}; + if (Object.prototype.hasOwnProperty.call(options, 'constructor')) { + if (typeThunk !== undefined) { + throw new Error('Cannot both define constructor option and type. Only one allowed.'); + } + if (!helpers_1.isValueDefined(options.constructor)) { + helpers_1.logError(decoratorName + ": cannot resolve specified property constructor at runtime. " + helpers_1.LAZY_TYPE_EXPLANATION); + return; + } + var newTypeDescriptor_1 = type_descriptor_1.ensureTypeDescriptor(options.constructor); + typeThunk = function () { return newTypeDescriptor_1; }; + if (helpers_1.isReflectMetadataSupported && !helpers_1.isSubtypeOf(newTypeDescriptor_1.ctor, Reflect.getMetadata('design:type', target, property))) { + helpers_1.logWarning(decoratorName + ": detected property type does not match" + + " 'constructor' option."); + } + } + else if (typeThunk !== undefined) { + } + else if (helpers_1.isReflectMetadataSupported) { + var reflectCtor_1 = Reflect.getMetadata('design:type', target, property); + if (reflectCtor_1 == null) { + helpers_1.logError(decoratorName + ": cannot resolve detected property constructor at runtime. " + helpers_1.LAZY_TYPE_EXPLANATION); + return; + } + typeThunk = function () { return type_descriptor_1.ensureTypeDescriptor(reflectCtor_1); }; + } + else if (options.deserializer === undefined) { + helpers_1.logError(decoratorName + ": Cannot determine type"); + return; + } + var typeToTest = typeThunk === null || typeThunk === void 0 ? void 0 : typeThunk(); + if (typeToTest !== undefined && isSpecialPropertyType(decoratorName, typeToTest)) { + return; + } + metadata_1.injectMetadataInformation(target, property, { + type: typeThunk === undefined + ? undefined + : function () { return type_descriptor_1.ensureTypeDescriptor(typeThunk()); }, + emitDefaultValue: options.emitDefaultValue, + isRequired: options.isRequired, + options: options_base_1.extractOptionBase(options), + key: property.toString(), + name: (_a = options.name) !== null && _a !== void 0 ? _a : property.toString(), + deserializer: options.deserializer, + serializer: options.serializer, + }); + }; + } + function isConstructorEqual(type, constructor) { + return type instanceof type_descriptor_1.TypeDescriptor ? type.ctor === constructor : type === constructor; + } + function isSpecialPropertyType(decoratorName, typeDescriptor) { + if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor) + && isConstructorEqual(typeDescriptor, Array)) { + helpers_1.logError(decoratorName + ": property is an Array. Use the jsonArrayMember decorator to" + + " serialize this property."); + return true; + } + if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor) && isConstructorEqual(typeDescriptor, Set)) { + helpers_1.logError(decoratorName + ": property is a Set. Use the jsonSetMember decorator to" + + " serialize this property."); + return true; + } + if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor) && isConstructorEqual(typeDescriptor, Map)) { + helpers_1.logError(decoratorName + ": property is a Map. Use the jsonMapMember decorator to" + + " serialize this property."); + return true; + } + return false; + } + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],170:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.jsonObject = void 0; + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + function jsonObject(optionsOrTarget) { + var options; + if (typeof optionsOrTarget === 'function') { + options = {}; + } + else { + options = optionsOrTarget !== null && optionsOrTarget !== void 0 ? optionsOrTarget : {}; + } + function decorator(target) { + var objectMetadata = metadata_1.JsonObjectMetadata.ensurePresentInPrototype(target.prototype); + objectMetadata.isExplicitlyMarked = true; + objectMetadata.onDeserializedMethodName = options.onDeserialized; + objectMetadata.beforeSerializationMethodName = options.beforeSerialization; + if (options.typeResolver != null) { + objectMetadata.typeResolver = options.typeResolver; + } + if (options.typeHintEmitter != null) { + objectMetadata.typeHintEmitter = options.typeHintEmitter; + } + objectMetadata.initializerCallback = options.initializer; + if (options.name != null) { + objectMetadata.name = options.name; + } + var optionsBase = options_base_1.extractOptionBase(options); + if (optionsBase !== undefined) { + objectMetadata.options = optionsBase; + } + if (options.knownTypes != null) { + options.knownTypes + .filter(function (knownType) { return Boolean(knownType); }) + .forEach(function (knownType) { return objectMetadata.knownTypes.add(knownType); }); + } + } + if (typeof optionsOrTarget === 'function') { + decorator(optionsOrTarget); + } + else { + return decorator; + } + } + exports.jsonObject = jsonObject; + + },{"./metadata":172,"./options-base":173}],171:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.jsonSetMember = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function jsonSetMember(maybeTypeThunk, options) { + if (options === void 0) { options = {}; } + return function (target, propKey) { + var _a; + var decoratorName = "@jsonSetMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); + var typeThunk = type_descriptor_1.ensureTypeThunk(maybeTypeThunk, decoratorName); + var reflectedType = helpers_1.isReflectMetadataSupported + ? Reflect.getMetadata('design:type', target, propKey) + : null; + if (reflectedType != null && reflectedType !== Set && reflectedType !== Object) { + helpers_1.logError(decoratorName + ": property is not a Set. " + helpers_1.MISSING_REFLECT_CONF_MSG); + return; + } + metadata_1.injectMetadataInformation(target, propKey, { + type: function () { return type_descriptor_1.SetT(typeThunk()); }, + emitDefaultValue: options.emitDefaultValue, + isRequired: options.isRequired, + options: options_base_1.extractOptionBase(options), + key: propKey.toString(), + name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), + deserializer: options.deserializer, + serializer: options.serializer, + }); + }; + } + exports.jsonSetMember = jsonSetMember; + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],172:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.injectMetadataInformation = exports.JsonObjectMetadata = exports.METADATA_FIELD_KEY = void 0; + var helpers_1 = require("./helpers"); + exports.METADATA_FIELD_KEY = '__typedJsonJsonObjectMetadataInformation__'; + var JsonObjectMetadata = (function () { + function JsonObjectMetadata(classType) { + this.dataMembers = new Map(); + this.knownTypes = new Set(); + this.knownTypesDeferred = []; + this.isExplicitlyMarked = false; + this.isHandledWithoutAnnotation = false; + this.classType = classType; + } + JsonObjectMetadata.getJsonObjectName = function (ctor) { + var metadata = JsonObjectMetadata.getFromConstructor(ctor); + return metadata === undefined ? helpers_1.nameof(ctor) : helpers_1.nameof(metadata.classType); + }; + JsonObjectMetadata.getFromConstructor = function (ctor) { + var prototype = ctor.prototype; + if (prototype == null) { + return; + } + var metadata; + if (Object.prototype.hasOwnProperty.call(prototype, exports.METADATA_FIELD_KEY)) { + metadata = prototype[exports.METADATA_FIELD_KEY]; + } + if ((metadata === null || metadata === void 0 ? void 0 : metadata.isExplicitlyMarked) === true) { + return metadata; + } + if (JsonObjectMetadata.doesHandleWithoutAnnotation(ctor)) { + var primitiveMeta = new JsonObjectMetadata(ctor); + primitiveMeta.isExplicitlyMarked = true; + return primitiveMeta; + } + }; + JsonObjectMetadata.ensurePresentInPrototype = function (prototype) { + if (Object.prototype.hasOwnProperty.call(prototype, exports.METADATA_FIELD_KEY)) { + return prototype[exports.METADATA_FIELD_KEY]; + } + var objectMetadata = new JsonObjectMetadata(prototype.constructor); + var parentMetadata = prototype[exports.METADATA_FIELD_KEY]; + if (parentMetadata !== undefined) { + parentMetadata.dataMembers.forEach(function (memberMetadata, propKey) { + objectMetadata.dataMembers.set(propKey, memberMetadata); + }); + parentMetadata.knownTypes.forEach(function (knownType) { + objectMetadata.knownTypes.add(knownType); + }); + objectMetadata.typeResolver = parentMetadata.typeResolver; + objectMetadata.typeHintEmitter = parentMetadata.typeHintEmitter; + } + Object.defineProperty(prototype, exports.METADATA_FIELD_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: objectMetadata, + }); + return objectMetadata; + }; + JsonObjectMetadata.getKnownTypeNameFromType = function (constructor) { + var metadata = JsonObjectMetadata.getFromConstructor(constructor); + return metadata === undefined ? helpers_1.nameof(constructor) : helpers_1.nameof(metadata.classType); + }; + JsonObjectMetadata.doesHandleWithoutAnnotation = function (ctor) { + return helpers_1.isDirectlySerializableNativeType(ctor) || helpers_1.isTypeTypedArray(ctor) + || ctor === DataView || ctor === ArrayBuffer; + }; + JsonObjectMetadata.prototype.processDeferredKnownTypes = function () { + var _this = this; + this.knownTypesDeferred.forEach(function (typeThunk) { + typeThunk().getTypes().forEach(function (ctor) { return _this.knownTypes.add(ctor); }); + }); + this.knownTypesDeferred = []; + }; + return JsonObjectMetadata; + }()); + exports.JsonObjectMetadata = JsonObjectMetadata; + function injectMetadataInformation(prototype, propKey, metadata) { + var decoratorName = "@jsonMember on " + helpers_1.nameof(prototype.constructor) + "." + String(propKey); + if (typeof prototype === 'function') { + helpers_1.logError(decoratorName + ": cannot use a static property."); + return; + } + if (typeof prototype[propKey] === 'function') { + helpers_1.logError(decoratorName + ": cannot use a method property."); + return; + } + if (metadata == null + || (metadata.type === undefined && metadata.deserializer === undefined)) { + helpers_1.logError(decoratorName + ": JsonMemberMetadata has unknown type."); + return; + } + var objectMetadata = JsonObjectMetadata.ensurePresentInPrototype(prototype); + if (metadata.deserializer === undefined) { + objectMetadata.knownTypesDeferred.push(metadata.type); + } + Object.keys(metadata) + .forEach(function (key) { return (metadata[key] === undefined) && delete metadata[key]; }); + objectMetadata.dataMembers.set(metadata.name, metadata); + } + exports.injectMetadataInformation = injectMetadataInformation; + + },{"./helpers":165}],173:[function(require,module,exports){ + "use strict"; + var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.mergeOptions = exports.getOptionValue = exports.getDefaultOptionOf = exports.extractOptionBase = void 0; + var kAllOptions = [ + 'preserveNull', + ]; + function extractOptionBase(from) { + var options = Object.keys(from) + .filter(function (key) { return kAllOptions.indexOf(key) > -1; }) + .reduce(function (obj, key) { + obj[key] = from[key]; + return obj; + }, {}); + return Object.keys(options).length > 0 ? options : undefined; + } + exports.extractOptionBase = extractOptionBase; + function getDefaultOptionOf(key) { + switch (key) { + case 'preserveNull': + return false; + } + return null; + } + exports.getDefaultOptionOf = getDefaultOptionOf; + function getOptionValue(key, options) { + if (options != null && options[key] != null) { + return options[key]; + } + return getDefaultOptionOf(key); + } + exports.getOptionValue = getOptionValue; + function mergeOptions(existing, moreSpecific) { + return moreSpecific == null + ? existing + : __assign(__assign({}, existing), moreSpecific); + } + exports.mergeOptions = mergeOptions; + + },{}],174:[function(require,module,exports){ + "use strict"; + var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.TypedJSON = exports.defaultTypeEmitter = exports.defaultTypeResolver = void 0; + var deserializer_1 = require("./deserializer"); + Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return deserializer_1.defaultTypeResolver; } }); + var helpers_1 = require("./helpers"); + var json_array_member_1 = require("./json-array-member"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var serializer_1 = require("./serializer"); + Object.defineProperty(exports, "defaultTypeEmitter", { enumerable: true, get: function () { return serializer_1.defaultTypeEmitter; } }); + var type_descriptor_1 = require("./type-descriptor"); + var TypedJSON = (function () { + function TypedJSON(rootConstructor, settings) { + this.serializer = new serializer_1.Serializer(); + this.deserializer = new deserializer_1.Deserializer(); + this.globalKnownTypes = []; + this.indent = 0; + var rootMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(rootConstructor); + if (rootMetadata === undefined + || (!rootMetadata.isExplicitlyMarked && !rootMetadata.isHandledWithoutAnnotation)) { + throw new TypeError('The TypedJSON root data type must have the @jsonObject decorator used.'); + } + this.nameResolver = function (ctor) { return helpers_1.nameof(ctor); }; + this.rootConstructor = rootConstructor; + this.errorHandler = function (error) { return helpers_1.logError(error); }; + this.config(settings); + } + TypedJSON.parse = function (object, rootType, settings) { + return new TypedJSON(rootType, settings).parse(object); + }; + TypedJSON.parseAsArray = function (object, elementType, settings, dimensions) { + return new TypedJSON(elementType, settings).parseAsArray(object, dimensions); + }; + TypedJSON.parseAsSet = function (object, elementType, settings) { + return new TypedJSON(elementType, settings).parseAsSet(object); + }; + TypedJSON.parseAsMap = function (object, keyType, valueType, settings) { + return new TypedJSON(valueType, settings).parseAsMap(object, keyType); + }; + TypedJSON.toPlainJson = function (object, rootType, settings) { + return new TypedJSON(rootType, settings).toPlainJson(object); + }; + TypedJSON.toPlainArray = function (object, elementType, dimensions, settings) { + return new TypedJSON(elementType, settings).toPlainArray(object, dimensions); + }; + TypedJSON.toPlainSet = function (object, elementType, settings) { + return new TypedJSON(elementType, settings).toPlainSet(object); + }; + TypedJSON.toPlainMap = function (object, keyCtor, valueCtor, settings) { + return new TypedJSON(valueCtor, settings).toPlainMap(object, keyCtor); + }; + TypedJSON.stringify = function (object, rootType, settings) { + return new TypedJSON(rootType, settings).stringify(object); + }; + TypedJSON.stringifyAsArray = function (object, elementType, dimensions, settings) { + return new TypedJSON(elementType, settings).stringifyAsArray(object, dimensions); + }; + TypedJSON.stringifyAsSet = function (object, elementType, settings) { + return new TypedJSON(elementType, settings).stringifyAsSet(object); + }; + TypedJSON.stringifyAsMap = function (object, keyCtor, valueCtor, settings) { + return new TypedJSON(valueCtor, settings).stringifyAsMap(object, keyCtor); + }; + TypedJSON.setGlobalConfig = function (config) { + Object.assign(this._globalConfig, config); + }; + TypedJSON.mapType = function (type, converters) { + if (this._globalConfig.mappedTypes == null) { + this._globalConfig.mappedTypes = new Map(); + } + this._globalConfig.mappedTypes.set(type, converters); + }; + TypedJSON.prototype.config = function (settings) { + var _this = this; + settings = __assign(__assign({}, TypedJSON._globalConfig), settings); + if (settings.knownTypes != null + && TypedJSON._globalConfig.knownTypes != null) { + settings.knownTypes = Array.from(new Set(settings.knownTypes.concat(TypedJSON._globalConfig.knownTypes))); + } + var options = options_base_1.extractOptionBase(settings); + this.serializer.options = options; + this.deserializer.options = options; + if (settings.errorHandler != null) { + this.errorHandler = settings.errorHandler; + this.deserializer.setErrorHandler(settings.errorHandler); + this.serializer.setErrorHandler(settings.errorHandler); + } + if (settings.replacer != null) { + this.replacer = settings.replacer; + } + if (settings.typeResolver != null) { + this.deserializer.setTypeResolver(settings.typeResolver); + } + if (settings.typeHintEmitter != null) { + this.serializer.setTypeHintEmitter(settings.typeHintEmitter); + } + if (settings.indent != null) { + this.indent = settings.indent; + } + if (settings.mappedTypes != null) { + settings.mappedTypes.forEach(function (upDown, type) { + _this.setSerializationStrategies(type, upDown); + }); + } + if (settings.nameResolver != null) { + this.nameResolver = settings.nameResolver; + this.deserializer.setNameResolver(settings.nameResolver); + } + if (settings.knownTypes != null) { + settings.knownTypes.forEach(function (knownType, i) { + if (typeof knownType === 'undefined' || knownType === null) { + helpers_1.logWarning("TypedJSON.config: 'knownTypes' contains an undefined/null value" + + (" (element " + i + ").")); + } + }); + this.globalKnownTypes = settings.knownTypes; + } + }; + TypedJSON.prototype.mapType = function (type, converters) { + this.setSerializationStrategies(type, converters); + }; + TypedJSON.prototype.parse = function (object) { + var _this = this; + var json = helpers_1.parseToJSObject(object, this.rootConstructor); + var rootMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(this.rootConstructor); + var result; + var knownTypes = new Map(); + this.globalKnownTypes.filter(function (ktc) { return ktc; }).forEach(function (knownTypeCtor) { + knownTypes.set(_this.nameResolver(knownTypeCtor), knownTypeCtor); + }); + if (rootMetadata !== undefined) { + rootMetadata.processDeferredKnownTypes(); + rootMetadata.knownTypes.forEach(function (knownTypeCtor) { + knownTypes.set(_this.nameResolver(knownTypeCtor), knownTypeCtor); + }); + } + try { + result = this.deserializer.convertSingleValue(json, type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), knownTypes); + } + catch (e) { + this.errorHandler(e); + } + return result; + }; + TypedJSON.prototype.parseAsArray = function (object, dimensions) { + if (dimensions === void 0) { dimensions = 1; } + var json = helpers_1.parseToJSObject(object, Array); + return this.deserializer.convertSingleValue(json, json_array_member_1.createArrayType(type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), dimensions), this._mapKnownTypes(this.globalKnownTypes)); + }; + TypedJSON.prototype.parseAsSet = function (object) { + var json = helpers_1.parseToJSObject(object, Set); + return this.deserializer.convertSingleValue(json, type_descriptor_1.SetT(this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); + }; + TypedJSON.prototype.parseAsMap = function (object, keyConstructor) { + var json = helpers_1.parseToJSObject(object, Map); + return this.deserializer.convertSingleValue(json, type_descriptor_1.MapT(keyConstructor, this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); + }; + TypedJSON.prototype.toPlainJson = function (object) { + try { + return this.serializer.convertSingleValue(object, type_descriptor_1.ensureTypeDescriptor(this.rootConstructor)); + } + catch (e) { + this.errorHandler(e); + } + }; + TypedJSON.prototype.toPlainArray = function (object, dimensions) { + if (dimensions === void 0) { dimensions = 1; } + try { + return this.serializer.convertSingleValue(object, json_array_member_1.createArrayType(type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), dimensions)); + } + catch (e) { + this.errorHandler(e); + } + }; + TypedJSON.prototype.toPlainSet = function (object) { + try { + return this.serializer.convertSingleValue(object, type_descriptor_1.SetT(this.rootConstructor)); + } + catch (e) { + this.errorHandler(e); + } + }; + TypedJSON.prototype.toPlainMap = function (object, keyConstructor) { + try { + return this.serializer.convertSingleValue(object, type_descriptor_1.MapT(keyConstructor, this.rootConstructor)); + } + catch (e) { + this.errorHandler(e); + } + }; + TypedJSON.prototype.stringify = function (object) { + var result = this.toPlainJson(object); + if (result === undefined) { + return ''; + } + return JSON.stringify(result, this.replacer, this.indent); + }; + TypedJSON.prototype.stringifyAsArray = function (object, dimensions) { + return JSON.stringify(this.toPlainArray(object, dimensions), this.replacer, this.indent); + }; + TypedJSON.prototype.stringifyAsSet = function (object) { + return JSON.stringify(this.toPlainSet(object), this.replacer, this.indent); + }; + TypedJSON.prototype.stringifyAsMap = function (object, keyConstructor) { + return JSON.stringify(this.toPlainMap(object, keyConstructor), this.replacer, this.indent); + }; + TypedJSON.prototype._mapKnownTypes = function (constructors) { + var _this = this; + var map = new Map(); + constructors.filter(function (ctor) { return ctor; }).forEach(function (ctor) { return map.set(_this.nameResolver(ctor), ctor); }); + return map; + }; + TypedJSON.prototype.setSerializationStrategies = function (type, converters) { + if (converters.deserializer != null) { + this.deserializer.setDeserializationStrategy(type, function (value) { + return converters.deserializer(value); + }); + } + if (converters.serializer != null) { + this.serializer.setSerializationStrategy(type, function (value) { + return converters.serializer(value); + }); + } + }; + TypedJSON._globalConfig = {}; + return TypedJSON; + }()); + exports.TypedJSON = TypedJSON; + + },{"./deserializer":164,"./helpers":165,"./json-array-member":167,"./metadata":172,"./options-base":173,"./serializer":175,"./type-descriptor":177}],175:[function(require,module,exports){ + "use strict"; + var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Serializer = exports.defaultTypeEmitter = void 0; + var helpers_1 = require("./helpers"); + var metadata_1 = require("./metadata"); + var options_base_1 = require("./options-base"); + var type_descriptor_1 = require("./type-descriptor"); + function defaultTypeEmitter(targetObject, sourceObject, expectedSourceType, sourceTypeMetadata) { + var _a; + if (sourceObject.constructor !== expectedSourceType) { + targetObject.__type = (_a = sourceTypeMetadata === null || sourceTypeMetadata === void 0 ? void 0 : sourceTypeMetadata.name) !== null && _a !== void 0 ? _a : helpers_1.nameof(sourceObject.constructor); + } + } + exports.defaultTypeEmitter = defaultTypeEmitter; + var Serializer = (function () { + function Serializer() { + this.typeHintEmitter = defaultTypeEmitter; + this.errorHandler = helpers_1.logError; + this.serializationStrategy = new Map([ + [type_descriptor_1.AnyT.ctor, helpers_1.identity], + [Date, helpers_1.identity], + [Number, helpers_1.identity], + [String, helpers_1.identity], + [Boolean, helpers_1.identity], + [ArrayBuffer, convertAsArrayBuffer], + [DataView, convertAsDataView], + [Array, convertAsArray], + [Set, convertAsSet], + [Map, convertAsMap], + [Float32Array, convertAsTypedArray], + [Float64Array, convertAsTypedArray], + [Int8Array, convertAsTypedArray], + [Uint8Array, convertAsTypedArray], + [Uint8ClampedArray, convertAsTypedArray], + [Int16Array, convertAsTypedArray], + [Uint16Array, convertAsTypedArray], + [Int32Array, convertAsTypedArray], + [Uint32Array, convertAsTypedArray], + ]); + } + Serializer.prototype.setSerializationStrategy = function (type, serializer) { + this.serializationStrategy.set(type, serializer); + }; + Serializer.prototype.setTypeHintEmitter = function (typeEmitterCallback) { + if (typeof typeEmitterCallback !== 'function') { + throw new TypeError('\'typeEmitterCallback\' is not a function.'); + } + this.typeHintEmitter = typeEmitterCallback; + }; + Serializer.prototype.getTypeHintEmitter = function () { + return this.typeHintEmitter; + }; + Serializer.prototype.setErrorHandler = function (errorHandlerCallback) { + if (typeof errorHandlerCallback !== 'function') { + throw new TypeError('\'errorHandlerCallback\' is not a function.'); + } + this.errorHandler = errorHandlerCallback; + }; + Serializer.prototype.getErrorHandler = function () { + return this.errorHandler; + }; + Serializer.prototype.retrievePreserveNull = function (memberOptions) { + return options_base_1.getOptionValue('preserveNull', options_base_1.mergeOptions(this.options, memberOptions)); + }; + Serializer.prototype.convertSingleValue = function (sourceObject, typeDescriptor, memberName, memberOptions) { + if (memberName === void 0) { memberName = 'object'; } + if (this.retrievePreserveNull(memberOptions) && sourceObject === null) { + return null; + } + if (!helpers_1.isValueDefined(sourceObject)) { + return; + } + if (!helpers_1.isInstanceOf(sourceObject, typeDescriptor.ctor)) { + var expectedName = helpers_1.nameof(typeDescriptor.ctor); + var actualName = helpers_1.nameof(sourceObject.constructor); + this.errorHandler(new TypeError("Could not serialize '" + memberName + "': expected '" + expectedName + "'," + + (" got '" + actualName + "'."))); + return; + } + var serializer = this.serializationStrategy.get(typeDescriptor.ctor); + if (serializer !== undefined) { + return serializer(sourceObject, typeDescriptor, memberName, this, memberOptions); + } + if (typeof sourceObject === 'object') { + return convertAsObject(sourceObject, typeDescriptor, memberName, this, memberOptions); + } + var error = "Could not serialize '" + memberName + "'; don't know how to serialize type"; + if (typeDescriptor.hasFriendlyName()) { + error += " '" + typeDescriptor.ctor.name + "'"; + } + this.errorHandler(new TypeError(error + ".")); + }; + return Serializer; + }()); + exports.Serializer = Serializer; + function convertAsObject(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { + var sourceTypeMetadata; + var targetObject; + var typeHintEmitter = serializer.getTypeHintEmitter(); + if (sourceObject.constructor !== typeDescriptor.ctor + && sourceObject instanceof typeDescriptor.ctor) { + sourceTypeMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(sourceObject.constructor); + } + else { + sourceTypeMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(typeDescriptor.ctor); + } + if (sourceTypeMetadata === undefined) { + targetObject = __assign({}, sourceObject); + } + else { + var beforeSerializationMethodName = sourceTypeMetadata.beforeSerializationMethodName; + if (beforeSerializationMethodName != null) { + if (typeof sourceObject[beforeSerializationMethodName] === 'function') { + sourceObject[beforeSerializationMethodName](); + } + else if (typeof sourceObject.constructor[beforeSerializationMethodName] + === 'function') { + sourceObject.constructor[beforeSerializationMethodName](); + } + else { + serializer.getErrorHandler()(new TypeError("beforeSerialization callback '" + + (helpers_1.nameof(sourceTypeMetadata.classType) + "." + beforeSerializationMethodName) + + "' is not a method.")); + } + } + var sourceMeta_1 = sourceTypeMetadata; + targetObject = {}; + var classOptions_1 = options_base_1.mergeOptions(serializer.options, sourceMeta_1.options); + if (sourceMeta_1.typeHintEmitter != null) { + typeHintEmitter = sourceMeta_1.typeHintEmitter; + } + sourceMeta_1.dataMembers.forEach(function (objMemberMetadata) { + var objMemberOptions = options_base_1.mergeOptions(classOptions_1, objMemberMetadata.options); + var serialized; + if (objMemberMetadata.serializer != null) { + serialized = objMemberMetadata.serializer(sourceObject[objMemberMetadata.key]); + } + else if (objMemberMetadata.type == null) { + throw new TypeError("Could not serialize " + objMemberMetadata.name + ", there is" + + " no constructor nor serialization function to use."); + } + else { + serialized = serializer.convertSingleValue(sourceObject[objMemberMetadata.key], objMemberMetadata.type(), helpers_1.nameof(sourceMeta_1.classType) + "." + objMemberMetadata.key, objMemberOptions); + } + if ((serializer.retrievePreserveNull(objMemberOptions) && serialized === null) + || helpers_1.isValueDefined(serialized)) { + targetObject[objMemberMetadata.name] = serialized; + } + }); + } + typeHintEmitter(targetObject, sourceObject, typeDescriptor.ctor, sourceTypeMetadata); + return targetObject; + } + function convertAsArray(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor)) { + throw new TypeError("Could not serialize " + memberName + " as Array: incorrect TypeDescriptor detected, please" + + ' use proper annotation or function for this type'); + } + if (typeDescriptor.elementType == null) { + throw new TypeError("Could not serialize " + memberName + " as Array: missing element type definition."); + } + sourceObject.forEach(function (element, i) { + if (!(serializer.retrievePreserveNull(memberOptions) && element === null) + && !helpers_1.isInstanceOf(element, typeDescriptor.elementType.ctor)) { + var expectedTypeName = helpers_1.nameof(typeDescriptor.elementType.ctor); + var actualTypeName = element && helpers_1.nameof(element.constructor); + throw new TypeError("Could not serialize " + memberName + "[" + i + "]:" + + (" expected '" + expectedTypeName + "', got '" + actualTypeName + "'.")); + } + }); + return sourceObject.map(function (element, i) { + return serializer.convertSingleValue(element, typeDescriptor.elementType, memberName + "[" + i + "]", memberOptions); + }); + } + function convertAsSet(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor)) { + throw new TypeError("Could not serialize " + memberName + " as Set: incorrect TypeDescriptor detected, please" + + ' use proper annotation or function for this type'); + } + if (typeDescriptor.elementType == null) { + throw new TypeError("Could not serialize " + memberName + " as Set: missing element type definition."); + } + memberName += '[]'; + var resultArray = []; + sourceObject.forEach(function (element) { + var resultElement = serializer.convertSingleValue(element, typeDescriptor.elementType, memberName, memberOptions); + if (!helpers_1.isValueDefined(element) || helpers_1.isValueDefined(resultElement)) { + resultArray.push(resultElement); + } + }); + return resultArray; + } + function convertAsMap(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { + if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor)) { + throw new TypeError("Could not serialize " + memberName + " as Map: incorrect TypeDescriptor detected, please" + + ' use proper annotation or function for this type'); + } + if (typeDescriptor.valueType == null) { + throw new TypeError("Could not serialize " + memberName + " as Map: missing value type definition."); + } + if (typeDescriptor.keyType == null) { + throw new TypeError("Could not serialize " + memberName + " as Map: missing key type definition."); + } + var keyMemberName = memberName + "[].key"; + var valueMemberName = memberName + "[].value"; + var resultShape = typeDescriptor.getCompleteOptions().shape; + var result = resultShape === 1 ? {} : []; + var preserveNull = serializer.retrievePreserveNull(memberOptions); + sourceObject.forEach(function (value, key) { + var resultKeyValuePairObj = { + key: serializer.convertSingleValue(key, typeDescriptor.keyType, keyMemberName, memberOptions), + value: serializer.convertSingleValue(value, typeDescriptor.valueType, valueMemberName, memberOptions), + }; + var keyDefined = helpers_1.isValueDefined(resultKeyValuePairObj.key); + var valueDefined = (resultKeyValuePairObj.value === null && preserveNull) + || helpers_1.isValueDefined(resultKeyValuePairObj.value); + if (keyDefined && valueDefined) { + if (resultShape === 1) { + result[resultKeyValuePairObj.key] = resultKeyValuePairObj.value; + } + else { + result.push(resultKeyValuePairObj); + } + } + }); + return result; + } + function convertAsTypedArray(sourceObject) { + return Array.from(sourceObject); + } + function convertAsArrayBuffer(buffer) { + return Array.from(new Uint16Array(buffer)) + .map(function (charCode) { return String.fromCharCode(charCode); }).join(''); + } + function convertAsDataView(dataView) { + return convertAsArrayBuffer(dataView.buffer); + } + + },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],176:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.toJson = void 0; + var parser_1 = require("./parser"); + function toJson(optionsOrTarget) { + if (typeof optionsOrTarget === 'function') { + toJsonDecorator(optionsOrTarget, {}); + return; + } + return function (target) { + toJsonDecorator(target, optionsOrTarget); + }; + } + exports.toJson = toJson; + function toJsonDecorator(target, options) { + if (options.overwrite !== true && target.prototype.toJSON !== undefined) { + throw new Error(target.name + " already has toJSON defined!"); + } + target.prototype.toJSON = function toJSON() { + return parser_1.TypedJSON.toPlainJson(this, Object.getPrototypeOf(this).constructor); + }; + } + + },{"./parser":174}],177:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ensureTypeThunk = exports.ensureTypeDescriptor = exports.isTypeThunk = exports.isTypelike = exports.AnyT = exports.MapT = exports.MapTypeDescriptor = exports.SetT = exports.SetTypeDescriptor = exports.ArrayT = exports.ArrayTypeDescriptor = exports.GenericTypeDescriptor = exports.ConcreteTypeDescriptor = exports.TypeDescriptor = void 0; + var helpers_1 = require("./helpers"); + var TypeDescriptor = (function () { + function TypeDescriptor(ctor) { + this.ctor = ctor; + } + TypeDescriptor.prototype.getTypes = function () { + return [this.ctor]; + }; + TypeDescriptor.prototype.hasFriendlyName = function () { + return this.ctor.name !== 'Object'; + }; + return TypeDescriptor; + }()); + exports.TypeDescriptor = TypeDescriptor; + var ConcreteTypeDescriptor = (function (_super) { + __extends(ConcreteTypeDescriptor, _super); + function ConcreteTypeDescriptor(ctor) { + return _super.call(this, ctor) || this; + } + return ConcreteTypeDescriptor; + }(TypeDescriptor)); + exports.ConcreteTypeDescriptor = ConcreteTypeDescriptor; + var GenericTypeDescriptor = (function (_super) { + __extends(GenericTypeDescriptor, _super); + function GenericTypeDescriptor(ctor) { + return _super.call(this, ctor) || this; + } + return GenericTypeDescriptor; + }(TypeDescriptor)); + exports.GenericTypeDescriptor = GenericTypeDescriptor; + var ArrayTypeDescriptor = (function (_super) { + __extends(ArrayTypeDescriptor, _super); + function ArrayTypeDescriptor(elementType) { + var _this = _super.call(this, Array) || this; + _this.elementType = elementType; + return _this; + } + ArrayTypeDescriptor.prototype.getTypes = function () { + return _super.prototype.getTypes.call(this).concat(this.elementType.getTypes()); + }; + return ArrayTypeDescriptor; + }(GenericTypeDescriptor)); + exports.ArrayTypeDescriptor = ArrayTypeDescriptor; + function ArrayT(elementType) { + return new ArrayTypeDescriptor(ensureTypeDescriptor(elementType)); + } + exports.ArrayT = ArrayT; + var SetTypeDescriptor = (function (_super) { + __extends(SetTypeDescriptor, _super); + function SetTypeDescriptor(elementType) { + var _this = _super.call(this, Set) || this; + _this.elementType = elementType; + return _this; + } + SetTypeDescriptor.prototype.getTypes = function () { + return _super.prototype.getTypes.call(this).concat(this.elementType.getTypes()); + }; + return SetTypeDescriptor; + }(GenericTypeDescriptor)); + exports.SetTypeDescriptor = SetTypeDescriptor; + function SetT(elementType) { + return new SetTypeDescriptor(ensureTypeDescriptor(elementType)); + } + exports.SetT = SetT; + var MapTypeDescriptor = (function (_super) { + __extends(MapTypeDescriptor, _super); + function MapTypeDescriptor(keyType, valueType, options) { + var _this = _super.call(this, Map) || this; + _this.keyType = keyType; + _this.valueType = valueType; + _this.options = options; + return _this; + } + MapTypeDescriptor.prototype.getTypes = function () { + return _super.prototype.getTypes.call(this).concat(this.keyType.getTypes(), this.valueType.getTypes()); + }; + MapTypeDescriptor.prototype.getCompleteOptions = function () { + var _a, _b; + return { + shape: (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.shape) !== null && _b !== void 0 ? _b : 0, + }; + }; + return MapTypeDescriptor; + }(GenericTypeDescriptor)); + exports.MapTypeDescriptor = MapTypeDescriptor; + function MapT(keyType, valueType, options) { + return new MapTypeDescriptor(ensureTypeDescriptor(keyType), ensureTypeDescriptor(valueType), options); + } + exports.MapT = MapT; + exports.AnyT = new ConcreteTypeDescriptor(function () { return undefined; }); + function isTypelike(type) { + return type != null && (typeof type === 'function' || type instanceof TypeDescriptor); + } + exports.isTypelike = isTypelike; + function isTypeThunk(candidate) { + return typeof candidate === 'function' && candidate.name === ''; + } + exports.isTypeThunk = isTypeThunk; + function ensureTypeDescriptor(type) { + return type instanceof TypeDescriptor ? type : new ConcreteTypeDescriptor(type); + } + exports.ensureTypeDescriptor = ensureTypeDescriptor; + function ensureTypeThunk(typeThunkOrSerializable, decoratorName) { + if (typeThunkOrSerializable == null) { + throw new Error("No type given on " + decoratorName + ". " + helpers_1.LAZY_TYPE_EXPLANATION); + } + if (isTypeThunk(typeThunkOrSerializable)) { + return typeThunkOrSerializable; + } + return function () { return typeThunkOrSerializable; }; + } + exports.ensureTypeThunk = ensureTypeThunk; + + },{"./helpers":165}],178:[function(require,module,exports){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + },{}],179:[function(require,module,exports){ + (function (global){(function (){ + + /** + * Module exports. + */ + + module.exports = deprecate; + + /** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + + function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; + } + + /** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + + function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; + } + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{}],180:[function(require,module,exports){ + (function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.WHATWGFetch = {}))); + }(this, (function (exports) { 'use strict'; + + var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof self !== 'undefined' && self) || + (typeof global !== 'undefined' && global); + + var support = { + searchParams: 'URLSearchParams' in global, + iterable: 'Symbol' in global && 'iterator' in Symbol, + blob: + 'FileReader' in global && + 'Blob' in global && + (function() { + try { + new Blob(); + return true + } catch (e) { + return false + } + })(), + formData: 'FormData' in global, + arrayBuffer: 'ArrayBuffer' in global + }; + + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj) + } + + if (support.arrayBuffer) { + var viewClasses = [ + '[object Int8Array]', + '[object Uint8Array]', + '[object Uint8ClampedArray]', + '[object Int16Array]', + '[object Uint16Array]', + '[object Int32Array]', + '[object Uint32Array]', + '[object Float32Array]', + '[object Float64Array]' + ]; + + var isArrayBufferView = + ArrayBuffer.isView || + function(obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + }; + } + + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { + throw new TypeError('Invalid character in header field name: "' + name + '"') + } + return name.toLowerCase() + } + + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value); + } + return value + } + + // Build a destructive iterator for the value list + function iteratorFor(items) { + var iterator = { + next: function() { + var value = items.shift(); + return {done: value === undefined, value: value} + } + }; + + if (support.iterable) { + iterator[Symbol.iterator] = function() { + return iterator + }; + } + + return iterator + } + + function Headers(headers) { + this.map = {}; + + if (headers instanceof Headers) { + headers.forEach(function(value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function(header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name) { + this.append(name, headers[name]); + }, this); + } + } + + Headers.prototype.append = function(name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ', ' + value : value; + }; + + Headers.prototype['delete'] = function(name) { + delete this.map[normalizeName(name)]; + }; + + Headers.prototype.get = function(name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null + }; + + Headers.prototype.has = function(name) { + return this.map.hasOwnProperty(normalizeName(name)) + }; + + Headers.prototype.set = function(name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; + + Headers.prototype.forEach = function(callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; + + Headers.prototype.keys = function() { + var items = []; + this.forEach(function(value, name) { + items.push(name); + }); + return iteratorFor(items) + }; + + Headers.prototype.values = function() { + var items = []; + this.forEach(function(value) { + items.push(value); + }); + return iteratorFor(items) + }; + + Headers.prototype.entries = function() { + var items = []; + this.forEach(function(value, name) { + items.push([name, value]); + }); + return iteratorFor(items) + }; + + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } + + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')) + } + body.bodyUsed = true; + } + + function fileReaderReady(reader) { + return new Promise(function(resolve, reject) { + reader.onload = function() { + resolve(reader.result); + }; + reader.onerror = function() { + reject(reader.error); + }; + }) + } + + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise + } + + function readBlobAsText(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise + } + + function readArrayBufferAsText(buf) { + var view = new Uint8Array(buf); + var chars = new Array(view.length); + + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } + return chars.join('') + } + + function bufferClone(buf) { + if (buf.slice) { + return buf.slice(0) + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer + } + } + + function Body() { + this.bodyUsed = false; + + this._initBody = function(body) { + /* + fetch-mock wraps the Response object in an ES6 Proxy to + provide useful test harness features such as flush. However, on + ES5 browsers without fetch or Proxy support pollyfills must be used; + the proxy-pollyfill is unable to proxy an attribute unless it exists + on the object before the Proxy is created. This change ensures + Response.bodyUsed exists on the instance, while maintaining the + semantic of setting Request.bodyUsed in the constructor before + _initBody is called. + */ + this.bodyUsed = this.bodyUsed; + this._bodyInit = body; + if (!body) { + this._bodyText = ''; + } else if (typeof body === 'string') { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + // IE 10-11 can't handle a DataView body. + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8'); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + } + }; + + if (support.blob) { + this.blob = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob') + } else { + return Promise.resolve(new Blob([this._bodyText])) + } + }; + + this.arrayBuffer = function() { + if (this._bodyArrayBuffer) { + var isConsumed = consumed(this); + if (isConsumed) { + return isConsumed + } + if (ArrayBuffer.isView(this._bodyArrayBuffer)) { + return Promise.resolve( + this._bodyArrayBuffer.buffer.slice( + this._bodyArrayBuffer.byteOffset, + this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength + ) + ) + } else { + return Promise.resolve(this._bodyArrayBuffer) + } + } else { + return this.blob().then(readBlobAsArrayBuffer) + } + }; + } + + this.text = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text') + } else { + return Promise.resolve(this._bodyText) + } + }; + + if (support.formData) { + this.formData = function() { + return this.text().then(decode) + }; + } + + this.json = function() { + return this.text().then(JSON.parse) + }; + + return this + } + + // HTTP methods whose capitalization should be normalized + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; + + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method + } + + function Request(input, options) { + if (!(this instanceof Request)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') + } + + options = options || {}; + var body = options.body; + + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } + + this.credentials = options.credentials || this.credentials || 'same-origin'; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || 'GET'); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; + + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests') + } + this._initBody(body); + + if (this.method === 'GET' || this.method === 'HEAD') { + if (options.cache === 'no-store' || options.cache === 'no-cache') { + // Search for a '_' parameter in the query string + var reParamSearch = /([?&])_=[^&]*/; + if (reParamSearch.test(this.url)) { + // If it already exists then set the value with the current time + this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); + } else { + // Otherwise add a new '_' parameter to the end with the current time + var reQueryString = /\?/; + this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); + } + } + } + } + + Request.prototype.clone = function() { + return new Request(this, {body: this._bodyInit}) + }; + + function decode(body) { + var form = new FormData(); + body + .trim() + .split('&') + .forEach(function(bytes) { + if (bytes) { + var split = bytes.split('='); + var name = split.shift().replace(/\+/g, ' '); + var value = split.join('=').replace(/\+/g, ' '); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form + } + + function parseHeaders(rawHeaders) { + var headers = new Headers(); + // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); + // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill + // https://github.com/github/fetch/issues/748 + // https://github.com/zloirock/core-js/issues/751 + preProcessedHeaders + .split('\r') + .map(function(header) { + return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header + }) + .forEach(function(line) { + var parts = line.split(':'); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(':').trim(); + headers.append(key, value); + } + }); + return headers + } + + Body.call(Request.prototype); + + function Response(bodyInit, options) { + if (!(this instanceof Response)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') + } + if (!options) { + options = {}; + } + + this.type = 'default'; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = options.statusText === undefined ? '' : '' + options.statusText; + this.headers = new Headers(options.headers); + this.url = options.url || ''; + this._initBody(bodyInit); + } + + Body.call(Response.prototype); + + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + }; + + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}); + response.type = 'error'; + return response + }; + + var redirectStatuses = [301, 302, 303, 307, 308]; + + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } + + return new Response(null, {status: status, headers: {location: url}}) + }; + + exports.DOMException = global.DOMException; + try { + new exports.DOMException(); + } catch (err) { + exports.DOMException = function(message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; + exports.DOMException.prototype = Object.create(Error.prototype); + exports.DOMException.prototype.constructor = exports.DOMException; + } + + function fetch(input, init) { + return new Promise(function(resolve, reject) { + var request = new Request(input, init); + + if (request.signal && request.signal.aborted) { + return reject(new exports.DOMException('Aborted', 'AbortError')) + } + + var xhr = new XMLHttpRequest(); + + function abortXhr() { + xhr.abort(); + } + + xhr.onload = function() { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || '') + }; + options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); + var body = 'response' in xhr ? xhr.response : xhr.responseText; + setTimeout(function() { + resolve(new Response(body, options)); + }, 0); + }; + + xhr.onerror = function() { + setTimeout(function() { + reject(new TypeError('Network request failed')); + }, 0); + }; + + xhr.ontimeout = function() { + setTimeout(function() { + reject(new TypeError('Network request failed')); + }, 0); + }; + + xhr.onabort = function() { + setTimeout(function() { + reject(new exports.DOMException('Aborted', 'AbortError')); + }, 0); + }; + + function fixUrl(url) { + try { + return url === '' && global.location.href ? global.location.href : url + } catch (e) { + return url + } + } + + xhr.open(request.method, fixUrl(request.url), true); + + if (request.credentials === 'include') { + xhr.withCredentials = true; + } else if (request.credentials === 'omit') { + xhr.withCredentials = false; + } + + if ('responseType' in xhr) { + if (support.blob) { + xhr.responseType = 'blob'; + } else if ( + support.arrayBuffer && + request.headers.get('Content-Type') && + request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 + ) { + xhr.responseType = 'arraybuffer'; + } + } + + if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { + Object.getOwnPropertyNames(init.headers).forEach(function(name) { + xhr.setRequestHeader(name, normalizeValue(init.headers[name])); + }); + } else { + request.headers.forEach(function(value, name) { + xhr.setRequestHeader(name, value); + }); + } + + if (request.signal) { + request.signal.addEventListener('abort', abortXhr); + + xhr.onreadystatechange = function() { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener('abort', abortXhr); + } + }; + } + + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); + }) + } + + fetch.polyfill = true; + + if (!global.fetch) { + global.fetch = fetch; + global.Headers = Headers; + global.Request = Request; + global.Response = Response; + } + + exports.Headers = Headers; + exports.Request = Request; + exports.Response = Response; + exports.fetch = fetch; + + Object.defineProperty(exports, '__esModule', { value: true }); + + }))); + + },{}],181:[function(require,module,exports){ + "use strict"; + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + __exportStar(require("./services"), exports); + __exportStar(require("./lib"), exports); + var Conversions_1 = require("./lib/Conversions"); + Object.defineProperty(exports, "base64to16", { enumerable: true, get: function () { return Conversions_1.base64to16; } }); + Object.defineProperty(exports, "encodeBase16", { enumerable: true, get: function () { return Conversions_1.encodeBase16; } }); + Object.defineProperty(exports, "decodeBase16", { enumerable: true, get: function () { return Conversions_1.decodeBase16; } }); + Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return Conversions_1.encodeBase64; } }); + Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return Conversions_1.decodeBase64; } }); + + },{"./lib":194,"./lib/Conversions":186,"./services":198}],182:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.URef = exports.AccessRights = exports.KeyValue = exports.AccountHash = exports.KeyVariant = exports.CLValue = exports.CLTypedAndToBytesHelper = exports.CLTypeHelper = exports.OptionType = exports.MapValue = exports.PublicKey = exports.Tuple3 = exports.Tuple2 = exports.Tuple1 = exports.List = exports.fromBytesByCLType = exports.StringValue = exports.Unit = exports.U512 = exports.U128 = exports.I64 = exports.U64 = exports.I32 = exports.U32 = exports.U8 = exports.Bool = exports.Result = exports.FromBytesError = exports.SimpleType = exports.staticImplements = exports.CLTypedAndToBytes = void 0; + var bytes_1 = require("@ethersproject/bytes"); + var byterepr_1 = require("./byterepr"); + var bignumber_1 = require("@ethersproject/bignumber"); + var Conversions_1 = require("./Conversions"); + var option_1 = require("./option"); + var Contracts_1 = require("./Contracts"); + var Keys_1 = require("./Keys"); + var typedjson_1 = require("typedjson"); + var ED25519_PUBLIC_KEY_LENGTH = 32; + var SECP256K1_PUBLIC_KEY_LENGTH = 33; + var CLTypedAndToBytes = /** @class */ (function () { + function CLTypedAndToBytes() { + } + CLTypedAndToBytes.prototype.clTypeEncoded = function () { + return CLTypeHelper.toBytesHelper(this.clType()); + }; + return CLTypedAndToBytes; + }()); + exports.CLTypedAndToBytes = CLTypedAndToBytes; + function staticImplements() { + // @ts-ignore + return function (constructor) { + // @ts-ignore + }; + } + exports.staticImplements = staticImplements; + var ED25519_TAG = 1; + var SECP256K1_TAG = 2; + var SimpleType; + (function (SimpleType) { + SimpleType[SimpleType["Bool"] = 0] = "Bool"; + SimpleType[SimpleType["I32"] = 1] = "I32"; + SimpleType[SimpleType["I64"] = 2] = "I64"; + SimpleType[SimpleType["U8"] = 3] = "U8"; + SimpleType[SimpleType["U32"] = 4] = "U32"; + SimpleType[SimpleType["U64"] = 5] = "U64"; + SimpleType[SimpleType["U128"] = 6] = "U128"; + SimpleType[SimpleType["U256"] = 7] = "U256"; + SimpleType[SimpleType["U512"] = 8] = "U512"; + SimpleType[SimpleType["Unit"] = 9] = "Unit"; + SimpleType[SimpleType["String"] = 10] = "String"; + SimpleType[SimpleType["Key"] = 11] = "Key"; + SimpleType[SimpleType["URef"] = 12] = "URef"; + SimpleType[SimpleType["PublicKey"] = 22] = "PublicKey"; + })(SimpleType = exports.SimpleType || (exports.SimpleType = {})); + var ComplexType; + (function (ComplexType) { + ComplexType[ComplexType["Option"] = 13] = "Option"; + ComplexType[ComplexType["List"] = 14] = "List"; + ComplexType[ComplexType["ByteArray"] = 15] = "ByteArray"; + ComplexType[ComplexType["Result"] = 16] = "Result"; + ComplexType[ComplexType["Map"] = 17] = "Map"; + ComplexType[ComplexType["Tuple1"] = 18] = "Tuple1"; + ComplexType[ComplexType["Tuple2"] = 19] = "Tuple2"; + ComplexType[ComplexType["Tuple3"] = 20] = "Tuple3"; + ComplexType[ComplexType["Any"] = 21] = "Any"; + })(ComplexType || (ComplexType = {})); + /** + * Enum representing possible results of deserialization. + */ + var FromBytesError; + (function (FromBytesError) { + /** + * Last operation was a success + */ + FromBytesError[FromBytesError["Ok"] = 0] = "Ok"; + /** + * Early end of stream + */ + FromBytesError[FromBytesError["EarlyEndOfStream"] = 1] = "EarlyEndOfStream"; + /** + * Unexpected data encountered while decoding byte stream + */ + FromBytesError[FromBytesError["FormattingError"] = 2] = "FormattingError"; + })(FromBytesError = exports.FromBytesError || (exports.FromBytesError = {})); + /** + * Class representing a result of an operation that might have failed. Can contain either a value + * resulting from a successful completion of a calculation, or an error. Similar to `Result` in Rust + * or `Either` in Haskell. + */ + var Result = /** @class */ (function () { + /** + * Creates new Result with value + * @param value value (success) or null (error) + * @param error FromBytesError code + * @param rem Remaining input stream + */ + function Result(val, rem, error) { + this.val = val; + this.rem = rem; + this.error = error; + } + Result.Err = function (errorCode) { + return new Result(null, null, errorCode); + }; + Result.Ok = function (val, rem) { + return new Result(val, rem, FromBytesError.Ok); + }; + Result.prototype.remainder = function () { + if (this.rem === null) { + throw new Error("Don't have remainder"); + } + return this.rem; + }; + /** + * Assumes that reference wrapper contains a value and then returns it + */ + Result.prototype.value = function () { + if (!this.hasValue()) { + throw new Error("Don't have value"); + } + return this.val; + }; + /** + * Checks if given Result contains a value + */ + Result.prototype.hasValue = function () { + return this.val !== null; + }; + /** + * Checks if error value is set. + * + * Truth also implies !hasValue(), false value implies hasValue() + */ + Result.prototype.hasError = function () { + return this.error !== FromBytesError.Ok; + }; + return Result; + }()); + exports.Result = Result; + var Bool = /** @class */ (function (_super) { + __extends(Bool, _super); + function Bool(val) { + var _this = _super.call(this) || this; + _this.val = val; + return _this; + } + Bool_1 = Bool; + Bool.prototype.toBytes = function () { + return new Uint8Array([this.val ? 1 : 0]); + }; + Bool.prototype.clType = function () { + return SimpleType.Bool; + }; + Bool.fromBytes = function (bytes) { + if (bytes.length === 0) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + if (bytes[0] === 1) { + return Result.Ok(new Bool_1(true), bytes.subarray(1)); + } + else if (bytes[0] === 0) { + return Result.Ok(new Bool_1(false), bytes.subarray(1)); + } + else { + return Result.Err(FromBytesError.FormattingError); + } + }; + var Bool_1; + Bool = Bool_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Boolean]) + ], Bool); + return Bool; + }(CLTypedAndToBytes)); + exports.Bool = Bool; + var NumberCoder = /** @class */ (function (_super) { + __extends(NumberCoder, _super); + function NumberCoder(bitSize, signed, value) { + var _this = _super.call(this) || this; + _this.toBytes = function () { + return byterepr_1.toBytesNumber(_this.bitSize, _this.signed, _this.val); + }; + _this.name = (signed ? 'i' : 'u') + bitSize; + _this.bitSize = bitSize; + _this.signed = signed; + _this.val = bignumber_1.BigNumber.from(value); + return _this; + } + return NumberCoder; + }(CLTypedAndToBytes)); + var U8 = /** @class */ (function (_super) { + __extends(U8, _super); + function U8(u8) { + return _super.call(this, 8, false, u8) || this; + } + U8_1 = U8; + U8.prototype.clType = function () { + return SimpleType.U8; + }; + U8.fromBytes = function (bytes) { + if (bytes.length === 0) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + return Result.Ok(new U8_1(bytes[0]), bytes.subarray(1)); + }; + var U8_1; + U8 = U8_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Number]) + ], U8); + return U8; + }(NumberCoder)); + exports.U8 = U8; + var U32 = /** @class */ (function (_super) { + __extends(U32, _super); + function U32(n) { + return _super.call(this, 32, false, n) || this; + } + U32_1 = U32; + U32.prototype.clType = function () { + return SimpleType.U32; + }; + U32.fromBytes = function (bytes) { + if (bytes.length < 4) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var u32Bytes = Buffer.from(bytes.subarray(0, 4)); + var u32 = u32Bytes.readUInt32LE(0); + return Result.Ok(new U32_1(u32), bytes.subarray(4)); + }; + var U32_1; + U32 = U32_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Number]) + ], U32); + return U32; + }(NumberCoder)); + exports.U32 = U32; + var I32 = /** @class */ (function (_super) { + __extends(I32, _super); + function I32(n) { + return _super.call(this, 32, true, n) || this; + } + I32_1 = I32; + I32.prototype.clType = function () { + return SimpleType.I32; + }; + I32.fromBytes = function (bytes) { + if (bytes.length < 4) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var i32Bytes = Buffer.from(bytes.subarray(0, 4)); + var i32 = i32Bytes.readInt32LE(0); + return Result.Ok(new I32_1(i32), bytes.subarray(4)); + }; + var I32_1; + I32 = I32_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Number]) + ], I32); + return I32; + }(NumberCoder)); + exports.I32 = I32; + var U64 = /** @class */ (function (_super) { + __extends(U64, _super); + function U64(n) { + return _super.call(this, 64, false, n) || this; + } + U64_1 = U64; + U64.prototype.clType = function () { + return SimpleType.U64; + }; + U64.fromBytes = function (bytes) { + var tmp = Uint8Array.from(bytes); + if (bytes.length < 8) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var u64Bytes = tmp.subarray(0, 8); + var rem = tmp.subarray(8); + return Result.Ok(new U64_1(bignumber_1.BigNumber.from(u64Bytes.reverse())), rem); + }; + var U64_1; + U64 = U64_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Object]) + ], U64); + return U64; + }(NumberCoder)); + exports.U64 = U64; + var I64 = /** @class */ (function (_super) { + __extends(I64, _super); + function I64(n) { + return _super.call(this, 64, true, n) || this; + } + I64_1 = I64; + I64.prototype.clType = function () { + return SimpleType.I64; + }; + I64.fromBytes = function (bytes) { + if (bytes.length < 8) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var tmp = Uint8Array.from(bytes); + var i64Bytes = tmp.subarray(0, 8); + var rem = tmp.subarray(8); + return Result.Ok(new I64_1(bignumber_1.BigNumber.from(i64Bytes.reverse()).fromTwos(64)), rem); + }; + var I64_1; + I64 = I64_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Object]) + ], I64); + return I64; + }(NumberCoder)); + exports.I64 = I64; + var U128 = /** @class */ (function (_super) { + __extends(U128, _super); + function U128(n) { + return _super.call(this, 128, false, n) || this; + } + U128.prototype.clType = function () { + return SimpleType.U128; + }; + U128.fromBytes = function (bytes) { + return fromBytesBigInt(bytes, 128); + }; + U128 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Object]) + ], U128); + return U128; + }(NumberCoder)); + exports.U128 = U128; + var U256 = /** @class */ (function (_super) { + __extends(U256, _super); + function U256(n) { + return _super.call(this, 256, false, n) || this; + } + U256.prototype.clType = function () { + return SimpleType.U256; + }; + U256.fromBytes = function (bytes) { + return fromBytesBigInt(bytes, 256); + }; + U256 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Object]) + ], U256); + return U256; + }(NumberCoder)); + var U512 = /** @class */ (function (_super) { + __extends(U512, _super); + function U512(n) { + return _super.call(this, 512, false, n) || this; + } + U512.prototype.clType = function () { + return SimpleType.U512; + }; + U512.fromBytes = function (bytes) { + return fromBytesBigInt(bytes, 512); + }; + U512 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Object]) + ], U512); + return U512; + }(NumberCoder)); + exports.U512 = U512; + var Unit = /** @class */ (function (_super) { + __extends(Unit, _super); + function Unit() { + return _super !== null && _super.apply(this, arguments) || this; + } + Unit_1 = Unit; + Unit.prototype.clType = function () { + return SimpleType.Unit; + }; + Unit.prototype.toBytes = function () { + return Uint8Array.from([]); + }; + Unit.fromBytes = function (bytes) { + return Result.Ok(new Unit_1(), bytes); + }; + var Unit_1; + Unit = Unit_1 = __decorate([ + staticImplements() + ], Unit); + return Unit; + }(CLTypedAndToBytes)); + exports.Unit = Unit; + var StringValue = /** @class */ (function (_super) { + __extends(StringValue, _super); + function StringValue(val) { + var _this = _super.call(this) || this; + _this.val = val; + _this.toBytes = function () { + return byterepr_1.toBytesString(_this.val); + }; + return _this; + } + StringValue_1 = StringValue; + StringValue.prototype.clType = function () { + return SimpleType.String; + }; + StringValue.fromBytes = function (bytes) { + var res = U32.fromBytes(bytes); + if (res.hasError()) { + return Result.Err(res.error); + } + var len = res.value().val.toNumber(); + var str = Buffer.from(res.remainder().subarray(0, len)).toString('utf8'); + return Result.Ok(new StringValue_1(str), res.remainder().subarray(len)); + }; + var StringValue_1; + StringValue = StringValue_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [String]) + ], StringValue); + return StringValue; + }(CLTypedAndToBytes)); + exports.StringValue = StringValue; + exports.fromBytesByCLType = function (type, bytes) { + if (type instanceof ListType) { + return List.fromBytes(type, bytes); + } + else if (type instanceof Tuple1Type) { + return Tuple1.fromBytes(type, bytes); + } + else if (type instanceof Tuple2Type) { + return Tuple2.fromBytes(type, bytes); + } + else if (type instanceof Tuple3Type) { + return Tuple3.fromBytes(type, bytes); + } + else if (type instanceof ByteArrayType) { + return ByteArrayValue.fromBytes(bytes); + } + else if (type instanceof MapType) { + return MapValue.fromBytes(type, bytes); + } + else if (type instanceof OptionType) { + return option_1.Option.fromBytes(type, bytes); + } + else { + return fromBytesSimpleType(type, bytes); + } + }; + var fromBytesSimpleType = function (simpleType, bytes) { + var innerRes; + switch (simpleType) { + case SimpleType.Bool: + innerRes = Bool.fromBytes(bytes); + break; + case SimpleType.I32: + innerRes = I32.fromBytes(bytes); + break; + case SimpleType.I64: + innerRes = I64.fromBytes(bytes); + break; + case SimpleType.U8: + innerRes = U8.fromBytes(bytes); + break; + case SimpleType.U32: + innerRes = U32.fromBytes(bytes); + break; + case SimpleType.U64: + innerRes = U64.fromBytes(bytes); + break; + case SimpleType.U128: + innerRes = U128.fromBytes(bytes); + break; + case SimpleType.U256: + innerRes = U256.fromBytes(bytes); + break; + case SimpleType.U512: + innerRes = U512.fromBytes(bytes); + break; + case SimpleType.Unit: + innerRes = Unit.fromBytes(bytes); + break; + case SimpleType.String: + innerRes = StringValue.fromBytes(bytes); + break; + case SimpleType.Key: + innerRes = KeyValue.fromBytes(bytes); + break; + case SimpleType.URef: + innerRes = URef.fromBytes(bytes); + break; + case SimpleType.PublicKey: + innerRes = PublicKey.fromBytes(bytes); + break; + default: + innerRes = Result.Err(FromBytesError.FormattingError); + break; + } + if (innerRes.hasError()) { + return Result.Err(innerRes.error); + } + else { + return Result.Ok(innerRes.value(), innerRes.remainder()); + } + }; + var List = /** @class */ (function (_super) { + __extends(List, _super); + function List(vec) { + var _this = _super.call(this) || this; + _this.vec = vec; + if (vec.length === 0) { + throw new Error("Can't create instance for empty list"); + } + return _this; + } + List.prototype.clType = function () { + return CLTypeHelper.list(this.vec[0].clType()); + }; + List.prototype.toBytes = function () { + return byterepr_1.toBytesVecT(this.vec); + }; + List.fromBytes = function (type, bytes) { + var u32Res = U32.fromBytes(bytes); + if (u32Res.hasError()) { + return Result.Err(u32Res.error); + } + var size = u32Res.value().val.toNumber(); + var vec = []; + var remainder = u32Res.remainder(); + for (var i = 0; i < size; i++) { + var v = exports.fromBytesByCLType(type.innerType, remainder); + if (v.hasError()) { + return Result.Err(v.error); + } + vec.push(v.value()); + remainder = v.remainder(); + } + return Result.Ok(new List(vec), remainder); + }; + return List; + }(CLTypedAndToBytes)); + exports.List = List; + var Tuple1 = /** @class */ (function (_super) { + __extends(Tuple1, _super); + function Tuple1(v0) { + var _this = _super.call(this) || this; + _this.v0 = v0; + return _this; + } + Tuple1.prototype.toBytes = function () { + return this.v0.toBytes(); + }; + Tuple1.prototype.clType = function () { + return CLTypeHelper.tuple1(this.v0.clType()); + }; + Tuple1.fromBytes = function (type, bytes) { + var innerRes = exports.fromBytesByCLType(type.t0, bytes); + if (innerRes.hasError()) { + return Result.Err(innerRes.error); + } + var tuple = new Tuple1(innerRes.value()); + return Result.Ok(tuple, innerRes.remainder()); + }; + return Tuple1; + }(CLTypedAndToBytes)); + exports.Tuple1 = Tuple1; + var Tuple2 = /** @class */ (function (_super) { + __extends(Tuple2, _super); + function Tuple2(v0, v1) { + var _this = _super.call(this) || this; + _this.v0 = v0; + _this.v1 = v1; + return _this; + } + Tuple2.prototype.toBytes = function () { + return bytes_1.concat([this.v0.toBytes(), this.v1.toBytes()]); + }; + Tuple2.prototype.clType = function () { + return CLTypeHelper.tuple2(this.v0.clType(), this.v1.clType()); + }; + Tuple2.fromBytes = function (type, bytes) { + var t0Res = exports.fromBytesByCLType(type.t0, bytes); + if (t0Res.hasError()) { + return Result.Err(t0Res.error); + } + var t1Res = exports.fromBytesByCLType(type.t1, t0Res.remainder()); + if (t1Res.hasError()) { + return Result.Err(t1Res.error); + } + var tuple = new Tuple2(t0Res.value(), t1Res.value()); + return Result.Ok(tuple, t1Res.remainder()); + }; + return Tuple2; + }(CLTypedAndToBytes)); + exports.Tuple2 = Tuple2; + var Tuple3 = /** @class */ (function (_super) { + __extends(Tuple3, _super); + function Tuple3(v0, v1, v2) { + var _this = _super.call(this) || this; + _this.v0 = v0; + _this.v1 = v1; + _this.v2 = v2; + return _this; + } + Tuple3.prototype.clType = function () { + return CLTypeHelper.tuple3(this.v0.clType(), this.v1.clType(), this.v2.clType()); + }; + Tuple3.prototype.toBytes = function () { + return bytes_1.concat([this.v0.toBytes(), this.v1.toBytes(), this.v2.toBytes()]); + }; + Tuple3.fromBytes = function (type, bytes) { + var t0Res = exports.fromBytesByCLType(type.t0, bytes); + if (t0Res.hasError()) { + return Result.Err(t0Res.error); + } + var t1Res = exports.fromBytesByCLType(type.t1, t0Res.remainder()); + if (t1Res.hasError()) { + return Result.Err(t1Res.error); + } + var t2Res = exports.fromBytesByCLType(type.t2, t1Res.remainder()); + if (t2Res.hasError()) { + return Result.Err(t2Res.error); + } + var tuple = new Tuple3(t0Res.value(), t1Res.value(), t2Res.value()); + return Result.Ok(tuple, t2Res.remainder()); + }; + return Tuple3; + }(CLTypedAndToBytes)); + exports.Tuple3 = Tuple3; + var PublicKey = /** @class */ (function (_super) { + __extends(PublicKey, _super); + function PublicKey(rawPublicKey, tag) { + var _this = _super.call(this) || this; + _this.rawPublicKey = rawPublicKey; + _this.tag = tag; + return _this; + } + PublicKey_1 = PublicKey; + PublicKey.prototype.clType = function () { + return SimpleType.PublicKey; + }; + PublicKey.prototype.toBytes = function () { + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesBytesArray(this.rawPublicKey) + ]); + }; + PublicKey.prototype.toAccountHex = function () { + var accountHash; + switch (this.tag) { + case ED25519_TAG: + accountHash = '01' + Conversions_1.encodeBase16(this.rawPublicKey); + break; + case SECP256K1_TAG: + accountHash = '02' + Conversions_1.encodeBase16(this.rawPublicKey); + break; + default: + throw new Error('Unsupported type of public key'); + } + return accountHash; + }; + PublicKey.prototype.isEd25519 = function () { + return this.tag === ED25519_TAG; + }; + PublicKey.prototype.isSecp256K1 = function () { + return this.tag === SECP256K1_TAG; + }; + PublicKey.prototype.toAccountHash = function () { + var algorithmIdentifier = this.signatureAlgorithm(); + var separator = Buffer.from([0]); + var prefix = Buffer.concat([ + Buffer.from(algorithmIdentifier.toLowerCase()), + separator + ]); + if (this.rawPublicKey.length === 0) { + return Buffer.from([]); + } + else { + return Contracts_1.byteHash(Buffer.concat([prefix, Buffer.from(this.rawPublicKey)])); + } + }; + PublicKey.fromEd25519 = function (publicKey) { + return new PublicKey_1(publicKey, ED25519_TAG); + }; + PublicKey.fromSecp256K1 = function (publicKey) { + return new PublicKey_1(publicKey, SECP256K1_TAG); + }; + PublicKey.from = function (publicKey, signatureAlgorithm) { + switch (signatureAlgorithm) { + case Keys_1.SignatureAlgorithm.Ed25519: + return PublicKey_1.fromEd25519(publicKey); + case Keys_1.SignatureAlgorithm.Secp256K1: + return PublicKey_1.fromSecp256K1(publicKey); + default: + throw new Error('Unsupported type of public key'); + } + }; + /** + * Tries to decode PublicKey from its hex-representation. + * The hex format should be as produced by PublicKey.toAccountHex + * @param publicKeyHex + */ + PublicKey.fromHex = function (publicKeyHex) { + if (publicKeyHex.length < 2) { + throw new Error('asymmetric key error: too short'); + } + var publicKeyHexBytes = Conversions_1.decodeBase16(publicKeyHex); + switch (publicKeyHexBytes[0]) { + case 1: + return PublicKey_1.fromEd25519(publicKeyHexBytes.subarray(1)); + case 2: + return PublicKey_1.fromSecp256K1(publicKeyHexBytes.subarray(1)); + default: + throw new Error('Unsupported type of public key'); + } + }; + PublicKey.prototype.signatureAlgorithm = function () { + switch (this.tag) { + case ED25519_TAG: + return Keys_1.SignatureAlgorithm.Ed25519; + case SECP256K1_TAG: + return Keys_1.SignatureAlgorithm.Secp256K1; + default: + throw new Error('Unsupported type of public key'); + } + }; + /** Deserializes a `PublicKey` from an array of bytes. */ + PublicKey.fromBytes = function (bytes) { + if (bytes.length < 1) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var variant = bytes[0]; + var currentPos = 1; + var expectedPublicKeySize; + switch (variant) { + case ED25519_TAG: + expectedPublicKeySize = ED25519_PUBLIC_KEY_LENGTH; + break; + case SECP256K1_TAG: + expectedPublicKeySize = SECP256K1_PUBLIC_KEY_LENGTH; + break; + default: + return Result.Err(FromBytesError.FormattingError); + } + var publicKeyBytes = bytes.subarray(currentPos, currentPos + expectedPublicKeySize); + currentPos += expectedPublicKeySize; + var publicKey = new PublicKey_1(publicKeyBytes, variant); + return Result.Ok(publicKey, bytes.subarray(currentPos)); + }; + var PublicKey_1; + PublicKey = PublicKey_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Uint8Array, Number]) + ], PublicKey); + return PublicKey; + }(CLTypedAndToBytes)); + exports.PublicKey = PublicKey; + var MapValue = /** @class */ (function (_super) { + __extends(MapValue, _super); + function MapValue(v) { + var _this = _super.call(this) || this; + _this.v = v; + return _this; + } + MapValue.prototype.toBytes = function () { + var kvBytes = this.v.map(function (vv) { + return bytes_1.concat([vv.key.toBytes(), vv.value.toBytes()]); + }); + kvBytes.splice(0, 0, byterepr_1.toBytesU32(this.v.length)); + return bytes_1.concat(kvBytes); + }; + MapValue.prototype.clType = function () { + return new MapType(this.v[0].key.clType(), this.v[0].value.clType()); + }; + MapValue.fromBytes = function (type, bytes) { + var u32Res = U32.fromBytes(bytes); + if (u32Res.hasError()) { + return Result.Err(u32Res.error); + } + var size = u32Res.value().val.toNumber(); + var vec = []; + var remainder = u32Res.remainder(); + for (var i = 0; i < size; i++) { + var keyRes = exports.fromBytesByCLType(type.keyType, remainder); + if (keyRes.hasError()) { + return Result.Err(keyRes.error); + } + remainder = keyRes.remainder(); + var valueRes = exports.fromBytesByCLType(type.valueType, remainder); + if (valueRes.hasError()) { + return Result.Err(valueRes.error); + } + remainder = valueRes.remainder(); + vec.push({ key: keyRes.value(), value: valueRes.value() }); + } + return Result.Ok(new MapValue(vec), remainder); + }; + return MapValue; + }(CLTypedAndToBytes)); + exports.MapValue = MapValue; + var ByteArrayValue = /** @class */ (function (_super) { + __extends(ByteArrayValue, _super); + function ByteArrayValue(rawBytes) { + var _this = _super.call(this) || this; + _this.rawBytes = rawBytes; + return _this; + } + ByteArrayValue_1 = ByteArrayValue; + ByteArrayValue.prototype.clType = function () { + return CLTypeHelper.byteArray(this.rawBytes.length); + }; + ByteArrayValue.prototype.toBytes = function () { + return byterepr_1.toBytesBytesArray(this.rawBytes); + }; + ByteArrayValue.fromBytes = function (bytes) { + var b = new ByteArrayValue_1(bytes.subarray(0, 32)); + return Result.Ok(b, bytes.subarray(32)); + }; + var ByteArrayValue_1; + ByteArrayValue = ByteArrayValue_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Uint8Array]) + ], ByteArrayValue); + return ByteArrayValue; + }(CLTypedAndToBytes)); + var fromBytesBigInt = function (bytes, bitSize) { + var byteSize = bitSize / 8; + if (bytes.length < 1) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var tmp = Uint8Array.from(bytes); + var n = tmp[0]; + if (n > byteSize) { + return Result.Err(FromBytesError.FormattingError); + } + if (n + 1 > bytes.length) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var bigIntBytes; + if (n === 0) { + bigIntBytes = [0]; + } + else { + bigIntBytes = tmp.subarray(1, 1 + n); + } + var rem = tmp.subarray(1 + n); + if (bitSize === 128) { + return Result.Ok(new U128(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); + } + else if (bitSize === 256) { + return Result.Ok(new U256(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); + } + else if (bitSize === 512) { + return Result.Ok(new U512(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); + } + else { + return Result.Err(FromBytesError.FormattingError); + } + }; + var OptionType = /** @class */ (function () { + function OptionType(innerType) { + this.innerType = innerType; + this.tag = ComplexType.Option; + } + OptionType.prototype.toJSON = function () { + var _c; + var innerTypeInJSON = clTypeToJSON(this.innerType); + return _c = {}, + _c[OptionType.TypeId] = innerTypeInJSON, + _c; + }; + OptionType.TypeId = 'Option'; + return OptionType; + }()); + exports.OptionType = OptionType; + var ListType = /** @class */ (function () { + function ListType(innerType) { + this.tag = ComplexType.List; + this.innerType = innerType; + } + ListType.prototype.toJSON = function () { + var _c; + var innerTypeInJSON = clTypeToJSON(this.innerType); + return _c = {}, + _c[ListType.TypeId] = innerTypeInJSON, + _c; + }; + ListType.TypeId = 'List'; + return ListType; + }()); + var ByteArrayType = /** @class */ (function () { + function ByteArrayType(size) { + this.size = size; + this.tag = ComplexType.ByteArray; + } + ByteArrayType.prototype.toJSON = function () { + var _c; + return _c = {}, + _c[ByteArrayType.TypeId] = this.size, + _c; + }; + ByteArrayType.TypeId = 'ByteArray'; + return ByteArrayType; + }()); + var MapType = /** @class */ (function () { + function MapType(keyType, valueType) { + this.keyType = keyType; + this.valueType = valueType; + this.tag = ComplexType.Map; + } + MapType.prototype.toJSON = function () { + var _c; + return _c = {}, + _c[MapType.TypeId] = { + key: clTypeToJSON(this.keyType), + value: clTypeToJSON(this.valueType) + }, + _c; + }; + MapType.TypeId = 'Map'; + return MapType; + }()); + var Tuple1Type = /** @class */ (function () { + function Tuple1Type(t0) { + this.t0 = t0; + this.tag = ComplexType.Tuple1; + } + Tuple1Type.prototype.toJSON = function () { + var _c; + var t0TypeInJSON = clTypeToJSON(this.t0); + return _c = {}, + _c[Tuple1Type.TypeId] = t0TypeInJSON, + _c; + }; + Tuple1Type.TypeId = 'Tuple1'; + return Tuple1Type; + }()); + var Tuple2Type = /** @class */ (function () { + function Tuple2Type(t0, t1) { + this.t0 = t0; + this.t1 = t1; + this.tag = ComplexType.Tuple2; + } + Tuple2Type.prototype.toJSON = function () { + var _c; + var t0TypeInJSON = clTypeToJSON(this.t0); + var t1TypeInJSON = clTypeToJSON(this.t1); + return _c = {}, + _c[Tuple2Type.TypeId] = [t0TypeInJSON, t1TypeInJSON], + _c; + }; + Tuple2Type.TypeId = 'Tuple2'; + return Tuple2Type; + }()); + var Tuple3Type = /** @class */ (function () { + function Tuple3Type(t0, t1, t2) { + this.t0 = t0; + this.t1 = t1; + this.t2 = t2; + this.tag = ComplexType.Tuple3; + } + Tuple3Type.prototype.toJSON = function () { + var _c; + var t0TypeInJSON = clTypeToJSON(this.t0); + var t1TypeInJSON = clTypeToJSON(this.t1); + var t2TypeInJSON = clTypeToJSON(this.t2); + return _c = {}, + _c[Tuple3Type.TypeId] = [t0TypeInJSON, t1TypeInJSON, t2TypeInJSON], + _c; + }; + Tuple3Type.TypeId = 'Tuple3'; + return Tuple3Type; + }()); + var CLTypeHelper = /** @class */ (function () { + function CLTypeHelper() { + } + CLTypeHelper.u8 = function () { + return SimpleType.U8; + }; + CLTypeHelper.u32 = function () { + return SimpleType.U32; + }; + CLTypeHelper.u64 = function () { + return SimpleType.U64; + }; + CLTypeHelper.u128 = function () { + return SimpleType.U128; + }; + CLTypeHelper.u256 = function () { + return SimpleType.U256; + }; + CLTypeHelper.u512 = function () { + return SimpleType.U512; + }; + CLTypeHelper.i32 = function () { + return SimpleType.I32; + }; + CLTypeHelper.i64 = function () { + return SimpleType.I64; + }; + CLTypeHelper.bool = function () { + return SimpleType.Bool; + }; + CLTypeHelper.unit = function () { + return SimpleType.Unit; + }; + CLTypeHelper.string = function () { + return SimpleType.String; + }; + CLTypeHelper.key = function () { + return SimpleType.Key; + }; + CLTypeHelper.publicKey = function () { + return SimpleType.PublicKey; + }; + CLTypeHelper.uRef = function () { + return SimpleType.URef; + }; + CLTypeHelper.option = function (innerType) { + return new OptionType(innerType); + }; + CLTypeHelper.list = function (innerType) { + return new ListType(innerType); + }; + CLTypeHelper.byteArray = function (len) { + return new ByteArrayType(len); + }; + CLTypeHelper.map = function (keyType, valueType) { + return new MapType(keyType, valueType); + }; + CLTypeHelper.tuple1 = function (t0) { + return new Tuple1Type(t0); + }; + CLTypeHelper.tuple2 = function (t0, t1) { + return new Tuple2Type(t0, t1); + }; + CLTypeHelper.tuple3 = function (t0, t1, t2) { + return new Tuple3Type(t0, t1, t2); + }; + CLTypeHelper.fromBytes = function (bytes) { + if (bytes.length < 1) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var tag = bytes[0]; + var rem = bytes.subarray(1); + switch (tag) { + case SimpleType.Bool: + case SimpleType.I32: + case SimpleType.I64: + case SimpleType.U8: + case SimpleType.U32: + case SimpleType.U64: + case SimpleType.U256: + case SimpleType.U512: + case SimpleType.Unit: + case SimpleType.String: + case SimpleType.Key: + case SimpleType.URef: + case SimpleType.PublicKey: + return Result.Ok(tag, rem); + case ComplexType.Option: { + // 1 inner type + var innerTypeRes = CLTypeHelper.fromBytes(rem); + if (innerTypeRes.hasError()) { + return Result.Err(innerTypeRes.error); + } + return Result.Ok(CLTypeHelper.option(innerTypeRes.value()), innerTypeRes.remainder()); + } + case ComplexType.List: { + // 1 inner type + var innerTypeRes = CLTypeHelper.fromBytes(rem); + if (innerTypeRes.hasError()) { + return Result.Err(innerTypeRes.error); + } + return Result.Ok(CLTypeHelper.list(innerTypeRes.value()), innerTypeRes.remainder()); + } + case ComplexType.ByteArray: { + // size of bytes + var sizeRes = U32.fromBytes(rem); + if (sizeRes.hasError()) { + return Result.Err(sizeRes.error); + } + return Result.Ok(CLTypeHelper.byteArray(sizeRes.value().val.toNumber()), sizeRes.remainder()); + } + case ComplexType.Result: + // todo(abner) support Result + throw new Error('Result type is unsupported now'); + case ComplexType.Map: { + // type of key + var keyTypeRes = CLTypeHelper.fromBytes(rem); + if (keyTypeRes.hasError()) { + return Result.Err(keyTypeRes.error); + } + var valueTypeRes = CLTypeHelper.fromBytes(keyTypeRes.remainder()); + if (valueTypeRes.hasError()) { + return Result.Err(valueTypeRes.error); + } + return Result.Ok(CLTypeHelper.map(keyTypeRes.value(), valueTypeRes.value()), valueTypeRes.remainder()); + } + case ComplexType.Tuple1: { + // 1 inner type + var innerTypeRes = CLTypeHelper.fromBytes(rem); + if (innerTypeRes.hasError()) { + return Result.Err(innerTypeRes.error); + } + return Result.Ok(CLTypeHelper.tuple1(innerTypeRes.value()), innerTypeRes.remainder()); + } + case ComplexType.Tuple2: { + // 2 inner types + var innerType1Res = CLTypeHelper.fromBytes(rem); + if (innerType1Res.hasError()) { + return Result.Err(innerType1Res.error); + } + var innerType2Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); + if (innerType2Res.hasError()) { + return Result.Err(innerType2Res.error); + } + return Result.Ok(CLTypeHelper.tuple2(innerType1Res.value(), innerType2Res.value()), innerType2Res.remainder()); + } + case ComplexType.Tuple3: { + // 3 inner types + var innerType1Res = CLTypeHelper.fromBytes(rem); + if (innerType1Res.hasError()) { + return Result.Err(innerType1Res.error); + } + var innerType2Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); + if (innerType2Res.hasError()) { + return Result.Err(innerType2Res.error); + } + var innerType3Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); + if (innerType3Res.hasError()) { + return Result.Err(innerType3Res.error); + } + return Result.Ok(CLTypeHelper.tuple3(innerType1Res.value(), innerType2Res.value(), innerType3Res.value()), innerType3Res.remainder()); + } + case ComplexType.Any: + // todo(abner) support Any + throw new Error('Any type is unsupported now'); + default: + return Result.Err(FromBytesError.FormattingError); + } + }; + CLTypeHelper.toBytesHelper = function (type) { + if (type instanceof ListType) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.innerType) + ]); + } + else if (type instanceof Tuple1Type) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.t0) + ]); + } + else if (type instanceof Tuple2Type) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.t0), + CLTypeHelper.toBytesHelper(type.t1) + ]); + } + else if (type instanceof Tuple3Type) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.t0), + CLTypeHelper.toBytesHelper(type.t1), + CLTypeHelper.toBytesHelper(type.t2) + ]); + } + else if (type instanceof ByteArrayType) { + return bytes_1.concat([Uint8Array.from([type.tag]), byterepr_1.toBytesU32(type.size)]); + } + else if (type instanceof MapType) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.keyType), + CLTypeHelper.toBytesHelper(type.valueType) + ]); + } + else if (type instanceof OptionType) { + return bytes_1.concat([ + Uint8Array.from([type.tag]), + CLTypeHelper.toBytesHelper(type.innerType) + ]); + } + else { + switch (type) { + case SimpleType.Bool: + case SimpleType.I32: + case SimpleType.I64: + case SimpleType.U8: + case SimpleType.U32: + case SimpleType.U64: + case SimpleType.U128: + case SimpleType.U256: + case SimpleType.U512: + case SimpleType.Unit: + case SimpleType.String: + case SimpleType.Key: + case SimpleType.URef: + case SimpleType.PublicKey: + return Uint8Array.from([type]); + default: + throw new Error('Wrong type'); + } + } + }; + return CLTypeHelper; + }()); + exports.CLTypeHelper = CLTypeHelper; + var CLTypedAndToBytesHelper = /** @class */ (function () { + function CLTypedAndToBytesHelper() { + } + CLTypedAndToBytesHelper.list = function (vec) { + // todo(abner) implement fromEmptyList + return new List(vec); + }; + CLTypedAndToBytesHelper.tuple1 = function (t0) { + return new Tuple1(t0); + }; + CLTypedAndToBytesHelper.tuple2 = function (t0, t1) { + return new Tuple2(t0, t1); + }; + CLTypedAndToBytesHelper.tuple3 = function (t0, t1, t2) { + return new Tuple3(t0, t1, t2); + }; + CLTypedAndToBytesHelper.option = function (t, innerType) { + return new option_1.Option(t, innerType); + }; + CLTypedAndToBytesHelper.map = function (mapEntries) { + return new MapValue(mapEntries); + }; + CLTypedAndToBytesHelper.publicKey = function (publicKey) { + return PublicKey.fromEd25519(publicKey); + }; + CLTypedAndToBytesHelper.bytes = function (bytes) { + return new ByteArrayValue(bytes); + }; + CLTypedAndToBytesHelper.bool = function (b) { + return new Bool(b); + }; + CLTypedAndToBytesHelper.u8 = function (u8) { + return new U8(u8); + }; + CLTypedAndToBytesHelper.u32 = function (u32) { + return new U32(u32); + }; + CLTypedAndToBytesHelper.i32 = function (i32) { + return new I32(i32); + }; + CLTypedAndToBytesHelper.u64 = function (u64) { + return new U64(u64); + }; + CLTypedAndToBytesHelper.i64 = function (i64) { + return new I64(i64); + }; + CLTypedAndToBytesHelper.u128 = function (u128) { + return new U128(u128); + }; + CLTypedAndToBytesHelper.u256 = function (u256) { + return new U256(u256); + }; + CLTypedAndToBytesHelper.u512 = function (u512) { + return new U512(u512); + }; + CLTypedAndToBytesHelper.unit = function () { + return new Unit(); + }; + CLTypedAndToBytesHelper.string = function (x) { + return new StringValue(x); + }; + return CLTypedAndToBytesHelper; + }()); + exports.CLTypedAndToBytesHelper = CLTypedAndToBytesHelper; + function toJSONSimpleType(type) { + switch (type) { + case SimpleType.Bool: + return 'Bool'; + case SimpleType.I32: + return 'I32'; + case SimpleType.I64: + return 'I64'; + case SimpleType.U8: + return 'U8'; + case SimpleType.U32: + return 'U32'; + case SimpleType.U64: + return 'U64'; + case SimpleType.U128: + return 'U128'; + case SimpleType.U256: + return 'U256'; + case SimpleType.U512: + return 'U512'; + case SimpleType.Unit: + return 'Unit'; + case SimpleType.String: + return 'String'; + case SimpleType.Key: + return 'Key'; + case SimpleType.URef: + return 'URef'; + case SimpleType.PublicKey: + return 'PublicKey'; + } + } + function jsonToSimpleType(str) { + switch (str) { + case 'Bool': + return SimpleType.Bool; + case 'I32': + return SimpleType.I32; + case 'I64': + return SimpleType.I64; + case 'U8': + return SimpleType.U8; + case 'U32': + return SimpleType.U32; + case 'U64': + return SimpleType.U64; + case 'U128': + return SimpleType.U128; + case 'U256': + return SimpleType.U256; + case 'U512': + return SimpleType.U512; + case 'Unit': + return SimpleType.Unit; + case 'String': + return SimpleType.String; + case 'Key': + return SimpleType.Key; + case 'URef': + return SimpleType.URef; + case 'PublicKey': + return SimpleType.PublicKey; + default: + throw new Error("The type " + str + " is not supported"); + } + } + var clTypeToJSON = function (type) { + if (type instanceof ListType || + type instanceof Tuple1Type || + type instanceof Tuple2Type || + type instanceof Tuple3Type || + type instanceof ByteArrayType || + type instanceof MapType || + type instanceof OptionType) { + return type.toJSON(); + } + else { + return toJSONSimpleType(type); + } + }; + var jsonToCLType = function (json) { + if (typeof json === typeof 'str') { + return jsonToSimpleType(json); + } + else if (typeof json === typeof {}) { + if (ListType.TypeId in json) { + var innerType = jsonToCLType(json[ListType.TypeId]); + return CLTypeHelper.list(innerType); + } + else if (Tuple1Type.TypeId in json) { + var t0Type = jsonToCLType(json[Tuple1Type.TypeId][0]); + return CLTypeHelper.tuple1(t0Type); + } + else if (Tuple2Type.TypeId in json) { + var innerTypes = json[Tuple2Type.TypeId]; + var t0Type = jsonToCLType(innerTypes[0]); + var t1Type = jsonToCLType(innerTypes[1]); + return CLTypeHelper.tuple2(t0Type, t1Type); + } + else if (Tuple3Type.TypeId in json) { + var innerTypes = json[Tuple2Type.TypeId]; + var t0Type = jsonToCLType(innerTypes[0]); + var t1Type = jsonToCLType(innerTypes[1]); + var t2Type = jsonToCLType(innerTypes[2]); + return CLTypeHelper.tuple3(t0Type, t1Type, t2Type); + } + else if (ByteArrayType.TypeId in json) { + var size = json[ByteArrayType.TypeId]; + return CLTypeHelper.byteArray(size); + } + else if (OptionType.TypeId in json) { + var innerType = jsonToCLType(json[OptionType.TypeId]); + return CLTypeHelper.option(innerType); + } + else if (MapType.TypeId in json) { + var keyType = jsonToCLType(json[MapType.TypeId].key); + var valueType = jsonToCLType(json[MapType.TypeId].value); + return CLTypeHelper.map(keyType, valueType); + } + else { + throw new Error("The type " + json + " is not supported"); + } + } + else { + throw new Error("The type " + json + " is not supported"); + } + }; + function deserializeCLValue(_a, _b) { + var v = exports.fromBytesByCLType(_a.clType, Conversions_1.decodeBase16(_a.bytes)); + var ret = CLValue.fromT(v.value()); + return ret; + } + /** + * A Casper value, i.e. a value which can be stored and manipulated by smart contracts. + * + * It holds the underlying data as a type-erased, serialized array of bytes and also holds the + * [[CLType]] of the underlying data as a separate member. + */ + var CLValue = /** @class */ (function () { + /** + * Please use static methodsto constructs a new `CLValue` + */ + function CLValue(value, clType) { + this.value = value; + this.clType = clType; + this.bytes = Conversions_1.encodeBase16(this.value.toBytes()); + } + CLValue_1 = CLValue; + CLValue.prototype.clValueBytes = function () { + return this.value.toBytes(); + }; + CLValue.fromT = function (v) { + return new CLValue_1(v, v.clType()); + }; + /** + * Serializes a `CLValue` into an array of bytes. + */ + CLValue.prototype.toBytes = function () { + return bytes_1.concat([ + byterepr_1.toBytesArrayU8(this.clValueBytes()), + CLTypeHelper.toBytesHelper(this.clType) + ]); + }; + CLValue.fromBytes = function (bytes) { + var bytesRes = ByteArrayValue.fromBytes(bytes); + if (bytesRes.hasError()) { + return Result.Err(bytesRes.error); + } + var clTypeRes = CLTypeHelper.fromBytes(bytesRes.remainder()); + if (clTypeRes.hasError()) { + return Result.Err(clTypeRes.error); + } + var v = exports.fromBytesByCLType(clTypeRes.value(), bytesRes.value().rawBytes); + var clValue = new CLValue_1(v.value(), clTypeRes.value()); + return Result.Ok(clValue, clTypeRes.remainder()); + }; + CLValue.prototype.reconstruct = function () { + var v = exports.fromBytesByCLType(this.clType, Conversions_1.decodeBase16(this.bytes)); + if (v.hasError()) { + throw new Error('Failed to deserialize CLValue'); + } + this.value = v.value(); + }; + CLValue.list = function (vec) { + return CLValue_1.fromT(new List(vec)); + }; + CLValue.tuple1 = function (t0) { + return CLValue_1.fromT(new Tuple1(t0)); + }; + CLValue.tuple2 = function (t0, t1) { + return CLValue_1.fromT(new Tuple2(t0, t1)); + }; + CLValue.tuple3 = function (t0, t1, t2) { + return CLValue_1.fromT(new Tuple3(t0, t1, t2)); + }; + CLValue.option = function (t, innerType) { + return CLValue_1.fromT(new option_1.Option(t, innerType)); + }; + CLValue.map = function (mapEntries) { + return CLValue_1.fromT(new MapValue(mapEntries)); + }; + CLValue.publicKey = function (publicKey) { + return CLValue_1.fromT(publicKey); + }; + CLValue.byteArray = function (bytes) { + return CLValue_1.fromT(new ByteArrayValue(bytes)); + }; + CLValue.prototype.isBigNumber = function () { + return (this.clType === SimpleType.U8 || + this.clType === SimpleType.I32 || + this.clType === SimpleType.I64 || + this.clType === SimpleType.U32 || + this.clType === SimpleType.U64 || + this.clType === SimpleType.U128 || + this.clType === SimpleType.U256 || + this.clType === SimpleType.U512); + }; + CLValue.prototype.asBigNumber = function () { + if (this.isBigNumber()) { + var numberCoder = this.value; + return bignumber_1.BigNumber.from(numberCoder.val); + } + else { + throw new Error('The CLValue is not an instance of BigNumber'); + } + }; + CLValue.prototype.isBoolean = function () { + return this.clType === SimpleType.Bool; + }; + CLValue.prototype.asBoolean = function () { + if (!this.isBoolean()) { + throw new Error('The CLValue is not an instance of Boolean'); + } + return this.value.val; + }; + CLValue.prototype.isString = function () { + return this.clType === SimpleType.String; + }; + CLValue.prototype.asString = function () { + if (!this.isString()) { + throw new Error('The CLValue is not an instance of String'); + } + return this.value.val; + }; + CLValue.prototype.isPublicKey = function () { + return this.clType === SimpleType.PublicKey; + }; + CLValue.prototype.asPublicKey = function () { + if (!this.isPublicKey()) { + throw new Error('The CLValue is not an instance of PublicKey'); + } + return this.value; + }; + CLValue.prototype.isKey = function () { + return this.clType === SimpleType.Key; + }; + CLValue.prototype.asKey = function () { + if (!this.isKey()) { + throw new Error('The CLValue is not an instance of Key'); + } + return this.value; + }; + CLValue.prototype.isURef = function () { + return this.clType === SimpleType.URef; + }; + CLValue.prototype.asURef = function () { + if (!this.isURef()) { + throw new Error('The CLValue is not an instance of URef'); + } + return this.value; + }; + CLValue.prototype.isBytesArray = function () { + return this.clType instanceof ByteArrayType; + }; + CLValue.prototype.asBytesArray = function () { + if (!this.isBytesArray()) { + throw new Error('The CLValue is not an instance of BytesArray'); + } + return this.value.toBytes(); + }; + CLValue.prototype.isOption = function () { + return this.clType instanceof OptionType; + }; + CLValue.prototype.asOption = function () { + if (!this.isOption()) { + throw new Error('The CLValue is not an instance of Option'); + } + return this.value; + }; + CLValue.prototype.isList = function () { + return this.clType instanceof ListType; + }; + CLValue.prototype.asList = function () { + if (!this.isList()) { + throw new Error('The CLValue is not an instance of List'); + } + var innerType = this.clType; + var list = List.fromBytes(innerType, this.clValueBytes()); + if (list.hasError()) { + throw new Error('The CLValue can not be parsed to list.'); + } + return list.value().vec.map(function (e) { return CLValue_1.fromT(e); }); + }; + var CLValue_1; + CLValue.bool = function (b) { + return CLValue_1.fromT(new Bool(b)); + }; + CLValue.u8 = function (u8) { + return CLValue_1.fromT(new U8(u8)); + }; + CLValue.u32 = function (u32) { + return CLValue_1.fromT(new U32(u32)); + }; + CLValue.i32 = function (i32) { + return CLValue_1.fromT(new I32(i32)); + }; + CLValue.u64 = function (u64) { + return CLValue_1.fromT(new U64(u64)); + }; + CLValue.i64 = function (i64) { + return CLValue_1.fromT(new I64(i64)); + }; + CLValue.u128 = function (u128) { + return CLValue_1.fromT(new U128(u128)); + }; + CLValue.u256 = function (u256) { + return CLValue_1.fromT(new U256(u256)); + }; + CLValue.u512 = function (u512) { + return CLValue_1.fromT(new U512(u512)); + }; + CLValue.unit = function () { + return CLValue_1.fromT(new Unit()); + }; + CLValue.string = function (x) { + return CLValue_1.fromT(new StringValue(x)); + }; + CLValue.key = function (key) { + return CLValue_1.fromT(key); + }; + CLValue.uref = function (uRef) { + return CLValue_1.fromT(uRef); + }; + CLValue.stringList = function (strings) { + var v = CLTypedAndToBytesHelper.list(strings.map(function (s) { return CLTypedAndToBytesHelper.string(s); })); + return new CLValue_1(v, CLTypeHelper.list(SimpleType.String)); + }; + __decorate([ + typedjson_1.jsonMember({ + name: 'cl_type', + serializer: clTypeToJSON, + deserializer: jsonToCLType + }), + __metadata("design:type", Object) + ], CLValue.prototype, "clType", void 0); + __decorate([ + typedjson_1.jsonMember({ + constructor: String + }), + __metadata("design:type", String) + ], CLValue.prototype, "bytes", void 0); + __decorate([ + typedjson_1.jsonMember({ + serializer: function (_) { return 'null'; }, + deserializer: function (_) { return null; } + }), + __metadata("design:type", Object) + ], CLValue.prototype, "parsed", void 0); + CLValue = CLValue_1 = __decorate([ + typedjson_1.jsonObject({ + initializer: function (a, b) { return deserializeCLValue(a, b); } + }), + __metadata("design:paramtypes", [CLTypedAndToBytes, Object]) + ], CLValue); + return CLValue; + }()); + exports.CLValue = CLValue; + var KeyVariant; + (function (KeyVariant) { + /** The Account variant */ + KeyVariant[KeyVariant["ACCOUNT_ID"] = 0] = "ACCOUNT_ID"; + /** The Hash variant */ + KeyVariant[KeyVariant["HASH_ID"] = 1] = "HASH_ID"; + /** The URef variant */ + KeyVariant[KeyVariant["UREF_ID"] = 2] = "UREF_ID"; + // todo(abner) support the new introduced variants + /** The Transfer variant */ + // TRANSFER_ID = 3, + // DEPLOY_INFO_ID = 4, + // ERA_INFO_ID = 5 + })(KeyVariant = exports.KeyVariant || (exports.KeyVariant = {})); + /// The length in bytes of a [`AccountHash`]. + var ACCOUNT_HASH_LENGTH = 32; + /** A cryptographic public key. */ + var AccountHash = /** @class */ (function (_super) { + __extends(AccountHash, _super); + /** + * Constructs a new `AccountHash`. + * + * @param bytes The bytes constituting the public key. + */ + function AccountHash(bytes) { + var _this = _super.call(this) || this; + _this.bytes = bytes; + return _this; + } + AccountHash_1 = AccountHash; + /** Serializes a `AccountHash` into an array of bytes. */ + AccountHash.prototype.toBytes = function () { + return this.bytes; + }; + AccountHash.prototype.clType = function () { + return CLTypeHelper.byteArray(ACCOUNT_HASH_LENGTH); + }; + AccountHash.fromBytes = function (bytes) { + if (bytes.length < ACCOUNT_HASH_LENGTH) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var accountHashBytes = bytes.subarray(0, ACCOUNT_HASH_LENGTH); + var accountHash = new AccountHash_1(accountHashBytes); + return Result.Ok(accountHash, bytes.subarray(ACCOUNT_HASH_LENGTH)); + }; + var AccountHash_1; + AccountHash = AccountHash_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Uint8Array]) + ], AccountHash); + return AccountHash; + }(CLTypedAndToBytes)); + exports.AccountHash = AccountHash; + /** + * The type under which data (e.g. [[CLValue]]s, smart contracts, user accounts) + * are indexed on the network. + */ + var KeyValue = /** @class */ (function (_super) { + __extends(KeyValue, _super); + function KeyValue() { + return _super !== null && _super.apply(this, arguments) || this; + } + KeyValue_1 = KeyValue; + KeyValue.prototype.isHash = function () { + return this.variant === KeyVariant.HASH_ID; + }; + KeyValue.prototype.isURef = function () { + return this.variant === KeyVariant.UREF_ID; + }; + KeyValue.prototype.isAccount = function () { + return this.variant === KeyVariant.ACCOUNT_ID; + }; + /** Creates a `Key` from a given [[URef]]. */ + KeyValue.fromURef = function (uref) { + var key = new KeyValue_1(); + key.variant = KeyVariant.UREF_ID; + key.uRef = uref; + return key; + }; + /** Creates a `Key` from a given hash. */ + KeyValue.fromHash = function (hash) { + var key = new KeyValue_1(); + key.variant = KeyVariant.HASH_ID; + key.hash = hash; + return key; + }; + /** Creates a `Key` from a [[]] representing an account. */ + KeyValue.fromAccount = function (account) { + var key = new KeyValue_1(); + key.variant = KeyVariant.ACCOUNT_ID; + key.account = account; + return key; + }; + KeyValue.prototype.clType = function () { + return SimpleType.Key; + }; + /** Serializes a `Key` into an array of bytes. */ + KeyValue.prototype.toBytes = function () { + if (this.variant === KeyVariant.ACCOUNT_ID) { + return bytes_1.concat([Uint8Array.from([this.variant]), this.account.toBytes()]); + } + else if (this.variant === KeyVariant.HASH_ID) { + return bytes_1.concat([Uint8Array.from([this.variant]), this.hash]); + } + else if (this.variant === KeyVariant.UREF_ID) { + return bytes_1.concat([Uint8Array.from([this.variant]), this.uRef.toBytes()]); + } + else { + throw new Error('Unknown variant'); + } + }; + KeyValue.fromBytes = function (bytes) { + if (bytes.length < 1) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var tag = bytes[0]; + var currentPos = 1; + if (tag === KeyVariant.HASH_ID) { + var hashBytes = bytes.subarray(currentPos, 32 + currentPos); + currentPos += 32; + var key = KeyValue_1.fromHash(hashBytes); + return Result.Ok(key, bytes.subarray(currentPos)); + } + else if (tag === KeyVariant.UREF_ID) { + var urefBytes = bytes.subarray(1); + var urefResult = URef.fromBytes(urefBytes); + if (urefResult.hasError()) { + return Result.Err(urefResult.error); + } + var key = KeyValue_1.fromURef(urefResult.value()); + return Result.Ok(key, urefResult.remainder()); + } + else if (tag === KeyVariant.ACCOUNT_ID) { + var accountHashBytes = bytes.subarray(1); + var accountHashResult = AccountHash.fromBytes(accountHashBytes); + if (accountHashResult.hasError()) { + return Result.Err(accountHashResult.error); + } + var key = KeyValue_1.fromAccount(accountHashResult.value()); + return Result.Ok(key, accountHashResult.remainder()); + } + else { + return Result.Err(FromBytesError.FormattingError); + } + }; + var KeyValue_1; + KeyValue = KeyValue_1 = __decorate([ + staticImplements() + ], KeyValue); + return KeyValue; + }(CLTypedAndToBytes)); + exports.KeyValue = KeyValue; + var FORMATTED_STRING_PREFIX = 'uref-'; + /** + * Length of [[URef]] address field. + * @internal + */ + var UREF_ADDR_LENGTH = 32; + /** + * Length of [[ACCESS_RIGHT]] field. + * @internal + */ + var ACCESS_RIGHT_LENGTH = 1; + var UREF_BYTES_LENGTH = UREF_ADDR_LENGTH + ACCESS_RIGHT_LENGTH; + var AccessRights; + (function (AccessRights) { + // No permissions + AccessRights[AccessRights["None"] = 0] = "None"; + // Permission to read the value under the associated [[URef]]. + AccessRights[AccessRights["READ"] = 1] = "READ"; + // Permission to write a value under the associated [[URef]]. + AccessRights[AccessRights["WRITE"] = 2] = "WRITE"; + // Permission to add to the value under the associated [[URef]]. + AccessRights[AccessRights["ADD"] = 4] = "ADD"; + // Permission to read or write the value under the associated [[URef]]. + AccessRights[AccessRights["READ_WRITE"] = 3] = "READ_WRITE"; + // Permission to read or add to the value under the associated [[URef]]. + AccessRights[AccessRights["READ_ADD"] = 5] = "READ_ADD"; + // Permission to add to, or write the value under the associated [[URef]]. + AccessRights[AccessRights["ADD_WRITE"] = 6] = "ADD_WRITE"; + // Permission to read, add to, or write the value under the associated [[URef]]. + AccessRights[AccessRights["READ_ADD_WRITE"] = 7] = "READ_ADD_WRITE"; + })(AccessRights = exports.AccessRights || (exports.AccessRights = {})); + var URef = /** @class */ (function (_super) { + __extends(URef, _super); + /** + * Constructs new instance of URef. + * @param uRefAddr Bytes representing address of the URef. + * @param accessRights Access rights flag. Use [[AccessRights.NONE]] to indicate no permissions. + */ + function URef(uRefAddr, accessRights) { + var _this = _super.call(this) || this; + _this.uRefAddr = uRefAddr; + _this.accessRights = accessRights; + if (_this.uRefAddr.byteLength !== 32) { + throw new Error('The length of URefAddr should be 32'); + } + return _this; + } + URef_1 = URef; + /** + * Parses a casper-client supported string formatted argument into a `URef`. + */ + URef.fromFormattedStr = function (input) { + if (!input.startsWith(FORMATTED_STRING_PREFIX)) { + throw new Error("prefix is not 'uref-'"); + } + var parts = input.substring(FORMATTED_STRING_PREFIX.length).split('-', 2); + if (parts.length !== 2) { + throw new Error('no access rights as suffix'); + } + var addr = Conversions_1.decodeBase16(parts[0]); + var accessRight = parseInt(parts[1], 8); + return new URef_1(addr, accessRight); + }; + URef.prototype.toFormattedStr = function () { + return [ + FORMATTED_STRING_PREFIX, + Conversions_1.encodeBase16(this.uRefAddr), + this.accessRights.toString(8) + ].join('-'); + }; + /** + * Serializes the URef into an array of bytes that represents it in the Casper serialization + * format. + */ + URef.prototype.toBytes = function () { + return bytes_1.concat([this.uRefAddr, Uint8Array.from([this.accessRights])]); + }; + URef.prototype.clType = function () { + return CLTypeHelper.uRef(); + }; + URef.fromBytes = function (bytes) { + if (bytes.length < UREF_BYTES_LENGTH) { + return Result.Err(FromBytesError.EarlyEndOfStream); + } + var urefBytes = bytes.subarray(0, UREF_ADDR_LENGTH); + var accessRights = bytes[UREF_BYTES_LENGTH - 1]; + var uref = new URef_1(urefBytes, accessRights); + return Result.Ok(uref, bytes.subarray(UREF_BYTES_LENGTH)); + }; + var URef_1; + URef = URef_1 = __decorate([ + staticImplements(), + __metadata("design:paramtypes", [Uint8Array, Number]) + ], URef); + return URef; + }(CLTypedAndToBytes)); + exports.URef = URef; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./Contracts":185,"./Conversions":186,"./Keys":188,"./byterepr":193,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"buffer":266,"typedjson":166}],183:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.CasperClient = void 0; + var services_1 = require("../services"); + var index_1 = require("./index"); + var Conversions_1 = require("./Conversions"); + var Keys_1 = require("./Keys"); + var CasperHDKey_1 = require("./CasperHDKey"); + var bignumber_1 = require("@ethersproject/bignumber"); + var CasperClient = /** @class */ (function () { + function CasperClient(nodeUrl) { + this.nodeClient = new services_1.CasperServiceByJsonRPC(nodeUrl); + } + /** + * Generate new key pair. + * @param algo Currently we support Ed25519 and Secp256K1. + */ + CasperClient.prototype.newKeyPair = function (algo) { + switch (algo) { + case Keys_1.SignatureAlgorithm.Ed25519: + return index_1.Keys.Ed25519.new(); + case Keys_1.SignatureAlgorithm.Secp256K1: + return index_1.Keys.Secp256K1.new(); + default: + throw new Error('Invalid signature algorithm'); + } + }; + /** + * Load private key from file + * + * @param path the path to the publicKey file + * @param algo the signature algorithm of the file + */ + CasperClient.prototype.loadPublicKeyFromFile = function (path, algo) { + switch (algo) { + case Keys_1.SignatureAlgorithm.Ed25519: + return index_1.Keys.Ed25519.parsePublicKeyFile(path); + case Keys_1.SignatureAlgorithm.Secp256K1: + return index_1.Keys.Secp256K1.parsePublicKeyFile(path); + default: + throw new Error('Invalid signature algorithm'); + } + }; + /** + * Load private key + * @param path the path to the private key file + */ + CasperClient.prototype.loadPrivateKeyFromFile = function (path, algo) { + switch (algo) { + case Keys_1.SignatureAlgorithm.Ed25519: + return index_1.Keys.Ed25519.parsePrivateKeyFile(path); + case Keys_1.SignatureAlgorithm.Secp256K1: + return index_1.Keys.Secp256K1.parsePrivateKeyFile(path); + default: + throw new Error('Invalid signature algorithm'); + } + }; + /** + * Load private key file to restore keyPair + * + * @param path The path to the private key + * @param algo + */ + CasperClient.prototype.loadKeyPairFromPrivateFile = function (path, algo) { + switch (algo) { + case Keys_1.SignatureAlgorithm.Ed25519: + return index_1.Keys.Ed25519.loadKeyPairFromPrivateFile(path); + case Keys_1.SignatureAlgorithm.Secp256K1: + return index_1.Keys.Secp256K1.loadKeyPairFromPrivateFile(path); + default: + throw new Error('Invalid signature algorithm'); + } + }; + /** + * Create a new hierarchical deterministic wallet, supporting bip32 protocol + * + * @param seed The seed buffer for parent key + */ + CasperClient.prototype.newHdWallet = function (seed) { + return CasperHDKey_1.CasperHDKey.fromMasterSeed(seed); + }; + /** + * Compute public key from private Key. + * @param privateKey + */ + CasperClient.prototype.privateToPublicKey = function (privateKey, algo) { + switch (algo) { + case Keys_1.SignatureAlgorithm.Ed25519: + return index_1.Keys.Ed25519.privateToPublicKey(privateKey); + case Keys_1.SignatureAlgorithm.Secp256K1: + return index_1.Keys.Secp256K1.privateToPublicKey(privateKey); + default: + throw new Error('Invalid signature algorithm'); + } + }; + /** + * Construct a unsigned Deploy object + * + * @param deployParams Parameters for deploy + * @param session + * @param payment + */ + CasperClient.prototype.makeDeploy = function (deployParams, session, payment) { + return index_1.DeployUtil.makeDeploy(deployParams, session, payment); + }; + /** + * Sign the deploy with the specified signKeyPair + * @param deploy unsigned Deploy object + * @param signKeyPair the keypair to sign the Deploy object + */ + CasperClient.prototype.signDeploy = function (deploy, signKeyPair) { + return index_1.DeployUtil.signDeploy(deploy, signKeyPair); + }; + /** + * Send deploy to network + * @param signedDeploy Signed deploy object + */ + CasperClient.prototype.putDeploy = function (signedDeploy) { + return this.nodeClient.deploy(signedDeploy).then(function (it) { return it.deploy_hash; }); + }; + /** + * convert the deploy object to json + * @param deploy + */ + CasperClient.prototype.deployToJson = function (deploy) { + return index_1.DeployUtil.deployToJson(deploy); + }; + /** + * Convert the json to deploy object + * + * @param json + */ + CasperClient.prototype.deployFromJson = function (json) { + return index_1.DeployUtil.deployFromJson(json); + }; + /** + * Construct the deploy for transfer purpose + * + * @param deployParams + * @param session + * @param payment + */ + CasperClient.prototype.makeTransferDeploy = function (deployParams, session, payment) { + if (!session.isTransfer()) { + throw new Error('The session is not a Transfer ExecutableDeployItem'); + } + return this.makeDeploy(deployParams, session, payment); + }; + /** + * Get the balance of public key + */ + CasperClient.prototype.balanceOfByPublicKey = function (publicKey) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, this.balanceOfByAccountHash(Conversions_1.encodeBase16(publicKey.toAccountHash()))]; + }); + }); + }; + /** + * Get the balance by account hash + */ + CasperClient.prototype.balanceOfByAccountHash = function (accountHashStr) { + return __awaiter(this, void 0, void 0, function () { + var stateRootHash, balanceUref, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 4, , 5]); + return [4 /*yield*/, this.nodeClient + .getLatestBlockInfo() + .then(function (it) { var _a; return (_a = it.block) === null || _a === void 0 ? void 0 : _a.header.state_root_hash; })]; + case 1: + stateRootHash = _a.sent(); + // Find the balance Uref and cache it if we don't have it. + if (!stateRootHash) { + return [2 /*return*/, bignumber_1.BigNumber.from(0)]; + } + return [4 /*yield*/, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(stateRootHash, accountHashStr)]; + case 2: + balanceUref = _a.sent(); + if (!balanceUref) { + return [2 /*return*/, bignumber_1.BigNumber.from(0)]; + } + return [4 /*yield*/, this.nodeClient.getAccountBalance(stateRootHash, balanceUref)]; + case 3: return [2 /*return*/, _a.sent()]; + case 4: + e_1 = _a.sent(); + return [2 /*return*/, bignumber_1.BigNumber.from(0)]; + case 5: return [2 /*return*/]; + } + }); + }); + }; + /** + * Get deploy by hash from RPC. + * @param deployHash + * @returns Tuple of Deploy and raw RPC response. + */ + CasperClient.prototype.getDeploy = function (deployHash) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.nodeClient + .getDeployInfo(deployHash) + .then(function (result) { + return [index_1.DeployUtil.deployFromJson(result), result]; + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + /** + * Get the main purse uref for the specified publicKey + * @param publicKey + */ + CasperClient.prototype.getAccountMainPurseUref = function (publicKey) { + return __awaiter(this, void 0, void 0, function () { + var stateRootHash, balanceUref; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.nodeClient + .getLatestBlockInfo() + .then(function (it) { var _a; return (_a = it.block) === null || _a === void 0 ? void 0 : _a.header.state_root_hash; })]; + case 1: + stateRootHash = _a.sent(); + if (!stateRootHash) { + return [2 /*return*/, null]; + } + return [4 /*yield*/, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(stateRootHash, Conversions_1.encodeBase16(publicKey.toAccountHash()))]; + case 2: + balanceUref = _a.sent(); + return [2 /*return*/, balanceUref]; + } + }); + }); + }; + return CasperClient; + }()); + exports.CasperClient = CasperClient; + + },{"../services":198,"./CasperHDKey":184,"./Conversions":186,"./Keys":188,"./index":194,"@ethersproject/bignumber":4}],184:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.CasperHDKey = void 0; + var hdkey_1 = require("ethereum-cryptography/hdkey"); + var sha256_1 = require("ethereum-cryptography/sha256"); + var Keys_1 = require("./Keys"); + var CasperHDKey = /** @class */ (function () { + function CasperHDKey(hdKey) { + this.hdKey = hdKey; + // Registered at https://github.com/satoshilabs/slips/blob/master/slip-0044.md + this.bip44Index = 506; + } + // see https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#path-levels + CasperHDKey.prototype.bip44Path = function (index) { + return [ + 'm', + "44'", + this.bip44Index + "'", + "0'", + "0", + "" + index // child account index + ].join('/'); + }; + /** + * Generate HDKey from master seed + * @param seed + */ + CasperHDKey.fromMasterSeed = function (seed) { + return new CasperHDKey(hdkey_1.HDKey.fromMasterSeed(Buffer.from(seed))); + }; + CasperHDKey.prototype.publicKey = function () { + return this.hdKey.publicKey; + }; + CasperHDKey.prototype.privateKey = function () { + return this.hdKey.privateKey; + }; + CasperHDKey.prototype.privateExtendedKey = function () { + return this.hdKey.privateExtendedKey; + }; + CasperHDKey.prototype.publicExtendedKey = function () { + return this.hdKey.publicExtendedKey; + }; + /** + * Derive the child key basing the path + * @param path + */ + CasperHDKey.prototype.derive = function (path) { + var secpKeyPair = this.hdKey.derive(path); + return new Keys_1.Secp256K1(new Uint8Array(secpKeyPair.publicKey), new Uint8Array(secpKeyPair.privateKey)); + }; + /** + * Derive child key basing the bip44 protocol + * @param index the index of child key + */ + CasperHDKey.prototype.deriveIndex = function (index) { + return this.derive(this.bip44Path(index)); + }; + /** + * Generate the signature for the message by using the key + * @param msg The message to sign + */ + CasperHDKey.prototype.sign = function (msg) { + return this.hdKey.sign(sha256_1.sha256(Buffer.from(msg))); + }; + /** + * Verify the signature + * @param signature the signature generated for the msg + * @param msg the raw message + */ + CasperHDKey.prototype.verify = function (signature, msg) { + return this.hdKey.verify(sha256_1.sha256(Buffer.from(msg)), Buffer.from(signature)); + }; + /** + * Get the JSON representation of the wallet + */ + CasperHDKey.prototype.toJSON = function () { + return this.hdKey.toJSON(); + }; + return CasperHDKey; + }()); + exports.CasperHDKey = CasperHDKey; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./Keys":188,"buffer":266,"ethereum-cryptography/hdkey":73,"ethereum-cryptography/sha256":75}],185:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }); + var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Transfer = exports.Faucet = exports.BoundContract = exports.Contract = exports.byteHash = void 0; + var blakejs_1 = __importDefault(require("blakejs")); + var fs = __importStar(require("fs")); + var DeployUtil = __importStar(require("./DeployUtil")); + var DeployUtil_1 = require("./DeployUtil"); + var RuntimeArgs_1 = require("./RuntimeArgs"); + var CLValue_1 = require("./CLValue"); + // https://www.npmjs.com/package/tweetnacl-ts + // https://github.com/dcposch/blakejs + /** + * Use blake2b to compute hash of ByteArray + * + * @param x + */ + function byteHash(x) { + return blakejs_1.default.blake2b(x, null, 32); + } + exports.byteHash = byteHash; + var Contract = /** @class */ (function () { + /** + * + * @param sessionPath + * @param paymentPath the path of payment contract file, set it undefined if you want use standard payment + */ + function Contract(sessionPath, paymentPath) { + this.sessionWasm = fs.readFileSync(sessionPath); + if (!paymentPath) { + this.paymentWasm = Buffer.from(''); + } + else { + this.paymentWasm = fs.readFileSync(paymentPath); + } + } + /** + * Generate the Deploy message for this contract + * + * @param args Arguments + * @param paymentAmount + * @param accountPublicKey + * @param signingKeyPair key pair to sign the deploy + * @param chainName + */ + Contract.prototype.deploy = function (args, paymentAmount, accountPublicKey, signingKeyPair, chainName) { + var session = DeployUtil_1.ExecutableDeployItem.newModuleBytes(this.sessionWasm, args); + var paymentArgs = RuntimeArgs_1.RuntimeArgs.fromMap({ + amount: CLValue_1.CLValue.u512(paymentAmount.toString()) + }); + var payment = DeployUtil_1.ExecutableDeployItem.newModuleBytes(this.paymentWasm, paymentArgs); + var deploy = DeployUtil.makeDeploy(new DeployUtil_1.DeployParams(accountPublicKey, chainName), session, payment); + return DeployUtil.signDeploy(deploy, signingKeyPair); + }; + return Contract; + }()); + exports.Contract = Contract; + /** + * Always use the same account for deploying and signing. + */ + var BoundContract = /** @class */ (function () { + function BoundContract(contract, contractKeyPair) { + this.contract = contract; + this.contractKeyPair = contractKeyPair; + } + BoundContract.prototype.deploy = function (args, paymentAmount, chainName) { + return this.contract.deploy(args, paymentAmount, this.contractKeyPair.publicKey, this.contractKeyPair, chainName); + }; + return BoundContract; + }()); + exports.BoundContract = BoundContract; + var Faucet = /** @class */ (function () { + function Faucet() { + } + /** + * Arguments for Faucet smart contract + * + * @param accountPublicKeyHash the public key hash that want to be funded + */ + Faucet.args = function (accountPublicKeyHash) { + var accountKey = CLValue_1.KeyValue.fromAccount(new CLValue_1.AccountHash(accountPublicKeyHash)); + return RuntimeArgs_1.RuntimeArgs.fromMap({ + account: CLValue_1.CLValue.key(accountKey) + }); + }; + return Faucet; + }()); + exports.Faucet = Faucet; + var Transfer = /** @class */ (function () { + function Transfer() { + } + /** + * Arguments for Transfer smart contract + * + * @param accountPublicKeyHash the target account to transfer tokens + * @param amount the amount of tokens to transfer + */ + Transfer.args = function (accountPublicKeyHash, amount) { + var account = CLValue_1.CLValue.key(CLValue_1.KeyValue.fromAccount(new CLValue_1.AccountHash(accountPublicKeyHash))); + return RuntimeArgs_1.RuntimeArgs.fromMap({ + account: account, + amount: CLValue_1.CLValue.u512(amount.toString()) + }); + }; + return Transfer; + }()); + exports.Transfer = Transfer; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./CLValue":182,"./DeployUtil":187,"./RuntimeArgs":189,"blakejs":43,"buffer":266,"fs":199}],186:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.decodeBase16 = exports.encodeBase16 = exports.base64to16 = void 0; + var tweetnacl_util_1 = require("tweetnacl-util"); + // https://nodejs.org/api/buffer.html + var tweetnacl_util_2 = require("tweetnacl-util"); + Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return tweetnacl_util_2.encodeBase64; } }); + Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return tweetnacl_util_2.decodeBase64; } }); + /** + * Convert base64 encoded string to base16 encoded string + * + * @param base64 base64 encoded string + */ + function base64to16(base64) { + return encodeBase16(tweetnacl_util_1.decodeBase64(base64)); + } + exports.base64to16 = base64to16; + /** + * Encode Uint8Array into string using Base-16 encoding. + */ + function encodeBase16(bytes) { + return Buffer.from(bytes).toString('hex'); + } + exports.encodeBase16 = encodeBase16; + /** + * Decode Base-16 encoded string and returns Uint8Array of bytes. + * + * @param base16String base16 encoded string + */ + function decodeBase16(base16String) { + return new Uint8Array(Buffer.from(base16String, 'hex')); + } + exports.decodeBase16 = decodeBase16; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266,"tweetnacl-util":163}],187:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.deployToBytes = exports.validateDeploy = exports.deploySizeInBytes = exports.addArgToDeploy = exports.deployFromJson = exports.deployToJson = exports.standardPayment = exports.setSignature = exports.signDeploy = exports.makeDeploy = exports.DeployParams = exports.ContractType = exports.serializeApprovals = exports.serializeBody = exports.serializeHeader = exports.Deploy = exports.ExecutableDeployItem = exports.Transfer = exports.StoredVersionedContractByHash = exports.StoredVersionedContractByName = exports.StoredContractByName = exports.StoredContractByHash = exports.ModuleBytes = exports.Approval = exports.DeployHeader = exports.UniqAddress = exports.dehumanizerTTL = exports.humanizerTTL = void 0; + /** + * Util methods for making Deploy message + * + * @packageDocumentation + */ + var bytes_1 = require("@ethersproject/bytes"); + var blakejs_1 = __importDefault(require("blakejs")); + var option_1 = require("./option"); + var Conversions_1 = require("./Conversions"); + var humanize_duration_1 = __importDefault(require("humanize-duration")); + var CLValue_1 = require("./CLValue"); + var byterepr_1 = require("./byterepr"); + var RuntimeArgs_1 = require("./RuntimeArgs"); + // import JSBI from 'jsbi'; + var index_1 = require("./index"); + var Keys_1 = require("./Keys"); + var bignumber_1 = require("@ethersproject/bignumber"); + var typedjson_1 = require("typedjson"); + var tweetnacl_ts_1 = require("tweetnacl-ts"); + var ts_results_1 = require("ts-results"); + var shortEnglishHumanizer = humanize_duration_1.default.humanizer({ + spacer: '', + serialComma: false, + conjunction: ' ', + delimiter: ' ', + language: 'shortEn', + languages: { + // https://docs.rs/humantime/2.0.1/humantime/fn.parse_duration.html + shortEn: { + d: function () { return 'day'; }, + h: function () { return 'h'; }, + m: function () { return 'm'; }, + s: function () { return 's'; }, + ms: function () { return 'ms'; } + } + } + }); + var byteArrayJsonSerializer = function (bytes) { + return Conversions_1.encodeBase16(bytes); + }; + var byteArrayJsonDeserializer = function (str) { + return Conversions_1.decodeBase16(str); + }; + /** + * Returns a humanizer duration + * @param ttl in milliseconds + */ + exports.humanizerTTL = function (ttl) { + return shortEnglishHumanizer(ttl); + }; + /** + * Returns duration in ms + * @param ttl in humanized string + */ + exports.dehumanizerTTL = function (ttl) { + var dehumanizeUnit = function (s) { + if (s.includes('ms')) { + return Number(s.replace('ms', '')); + } + if (s.includes('s') && !s.includes('m')) { + return Number(s.replace('s', '')) * 1000; + } + if (s.includes('m') && !s.includes('s')) { + return Number(s.replace('m', '')) * 60 * 1000; + } + if (s.includes('h')) { + return Number(s.replace('h', '')) * 60 * 60 * 1000; + } + if (s.includes('day')) { + return Number(s.replace('day', '')) * 24 * 60 * 60 * 1000; + } + throw Error('Unsuported TTL unit'); + }; + return ttl + .split(' ') + .map(dehumanizeUnit) + .reduce(function (acc, val) { return (acc += val); }); + }; + var UniqAddress = /** @class */ (function () { + /** + * Constructs UniqAddress + * @param publicKey PublicKey instance + * @param transferId BigNumberish value (can be also string representing number). Max U64. + */ + function UniqAddress(publicKey, transferId) { + if (!(publicKey instanceof CLValue_1.PublicKey)) { + throw new Error('publicKey is not an instance of PublicKey'); + } + var bigNum = bignumber_1.BigNumber.from(transferId); + if (bigNum.gt('18446744073709551615')) { + throw new Error('transferId max value is U64'); + } + this.transferId = bigNum; + this.publicKey = publicKey; + } + /** + * Returns string in format "accountHex-transferIdHex" + * @param ttl in humanized string + */ + UniqAddress.prototype.toString = function () { + return this.publicKey.toAccountHex() + "-" + this.transferId.toHexString(); + }; + /** + * Builds UniqAddress from string + * @param value value returned from UniqAddress.toString() + */ + UniqAddress.fromString = function (value) { + var _a = value.split('-'), accountHex = _a[0], transferHex = _a[1]; + var publicKey = CLValue_1.PublicKey.fromHex(accountHex); + return new UniqAddress(publicKey, transferHex); + }; + return UniqAddress; + }()); + exports.UniqAddress = UniqAddress; + var DeployHeader = /** @class */ (function () { + /** + * The header portion of a Deploy + * + * @param account The account within which the deploy will be run. + * @param timestamp When the deploy was created. + * @param ttl How long the deploy will stay valid. + * @param gasPrice Price per gas unit for this deploy. + * @param bodyHash Hash of the Wasm code. + * @param dependencies Other deploys that have to be run before this one. + * @param chainName Which chain the deploy is supposed to be run on. + */ + function DeployHeader(account, timestamp, ttl, gasPrice, bodyHash, dependencies, chainName) { + this.account = account; + this.timestamp = timestamp; + this.ttl = ttl; + this.gasPrice = gasPrice; + this.bodyHash = bodyHash; + this.dependencies = dependencies; + this.chainName = chainName; + } + DeployHeader.prototype.toBytes = function () { + return bytes_1.concat([ + this.account.toBytes(), + byterepr_1.toBytesU64(this.timestamp), + byterepr_1.toBytesU64(this.ttl), + byterepr_1.toBytesU64(this.gasPrice), + byterepr_1.toBytesDeployHash(this.bodyHash), + byterepr_1.toBytesVecT(this.dependencies.map(function (d) { return new DeployHash(d); })), + byterepr_1.toBytesString(this.chainName) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ + serializer: function (account) { + return account.toAccountHex(); + }, + deserializer: function (hexStr) { + return CLValue_1.PublicKey.fromHex(hexStr); + } + }), + __metadata("design:type", CLValue_1.PublicKey) + ], DeployHeader.prototype, "account", void 0); + __decorate([ + typedjson_1.jsonMember({ + serializer: function (n) { return new Date(n).toISOString(); }, + deserializer: function (s) { return Date.parse(s); } + }), + __metadata("design:type", Number) + ], DeployHeader.prototype, "timestamp", void 0); + __decorate([ + typedjson_1.jsonMember({ + serializer: exports.humanizerTTL, + deserializer: exports.dehumanizerTTL + }), + __metadata("design:type", Number) + ], DeployHeader.prototype, "ttl", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: Number, name: 'gas_price' }), + __metadata("design:type", Number) + ], DeployHeader.prototype, "gasPrice", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'body_hash', + serializer: byteArrayJsonSerializer, + deserializer: byteArrayJsonDeserializer + }), + __metadata("design:type", Uint8Array) + ], DeployHeader.prototype, "bodyHash", void 0); + __decorate([ + typedjson_1.jsonArrayMember(tweetnacl_ts_1.ByteArray, { + serializer: function (value) { + return value.map(function (it) { return byteArrayJsonSerializer(it); }); + }, + deserializer: function (json) { + return json.map(function (it) { return byteArrayJsonDeserializer(it); }); + } + }), + __metadata("design:type", Array) + ], DeployHeader.prototype, "dependencies", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'chain_name', constructor: String }), + __metadata("design:type", String) + ], DeployHeader.prototype, "chainName", void 0); + DeployHeader = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [CLValue_1.PublicKey, Number, Number, Number, Uint8Array, Array, String]) + ], DeployHeader); + return DeployHeader; + }()); + exports.DeployHeader = DeployHeader; + /** + * The cryptographic hash of a Deploy. + */ + var DeployHash = /** @class */ (function () { + function DeployHash(hash) { + this.hash = hash; + } + DeployHash.prototype.toBytes = function () { + return byterepr_1.toBytesDeployHash(this.hash); + }; + return DeployHash; + }()); + /** + * A struct containing a signature and the public key of the signer. + */ + var Approval = /** @class */ (function () { + function Approval() { + } + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], Approval.prototype, "signer", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], Approval.prototype, "signature", void 0); + Approval = __decorate([ + typedjson_1.jsonObject + ], Approval); + return Approval; + }()); + exports.Approval = Approval; + var ExecutableDeployItemInternal = /** @class */ (function () { + function ExecutableDeployItemInternal() { + } + ExecutableDeployItemInternal.prototype.getArgByName = function (name) { + return this.args.args.get(name); + }; + ExecutableDeployItemInternal.prototype.setArg = function (name, value) { + this.args.args.set(name, value); + }; + return ExecutableDeployItemInternal; + }()); + var desRA = function (arr) { + var raSerializer = new typedjson_1.TypedJSON(RuntimeArgs_1.RuntimeArgs); + var value = { + args: arr + }; + return raSerializer.parse(value); + }; + var serRA = function (ra) { + var raSerializer = new typedjson_1.TypedJSON(RuntimeArgs_1.RuntimeArgs); + var json = raSerializer.toPlainJson(ra); + return Object.values(json)[0]; + }; + var ModuleBytes = /** @class */ (function (_super) { + __extends(ModuleBytes, _super); + function ModuleBytes(moduleBytes, args) { + var _this = _super.call(this) || this; + _this.tag = 0; + _this.moduleBytes = moduleBytes; + _this.args = args; + return _this; + } + ModuleBytes.prototype.toBytes = function () { + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesArrayU8(this.moduleBytes), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ + name: 'module_bytes', + serializer: byteArrayJsonSerializer, + deserializer: byteArrayJsonDeserializer + }), + __metadata("design:type", Uint8Array) + ], ModuleBytes.prototype, "moduleBytes", void 0); + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], ModuleBytes.prototype, "args", void 0); + ModuleBytes = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [Uint8Array, RuntimeArgs_1.RuntimeArgs]) + ], ModuleBytes); + return ModuleBytes; + }(ExecutableDeployItemInternal)); + exports.ModuleBytes = ModuleBytes; + var StoredContractByHash = /** @class */ (function (_super) { + __extends(StoredContractByHash, _super); + function StoredContractByHash(hash, entryPoint, args) { + var _this = _super.call(this) || this; + _this.tag = 1; + _this.entryPoint = entryPoint; + _this.args = args; + _this.hash = hash; + return _this; + } + StoredContractByHash.prototype.toBytes = function () { + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesBytesArray(this.hash), + byterepr_1.toBytesString(this.entryPoint), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ + serializer: byteArrayJsonSerializer, + deserializer: byteArrayJsonDeserializer + }), + __metadata("design:type", Uint8Array) + ], StoredContractByHash.prototype, "hash", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'entry_point', + constructor: String + }), + __metadata("design:type", String) + ], StoredContractByHash.prototype, "entryPoint", void 0); + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], StoredContractByHash.prototype, "args", void 0); + StoredContractByHash = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [Uint8Array, String, RuntimeArgs_1.RuntimeArgs]) + ], StoredContractByHash); + return StoredContractByHash; + }(ExecutableDeployItemInternal)); + exports.StoredContractByHash = StoredContractByHash; + var StoredContractByName = /** @class */ (function (_super) { + __extends(StoredContractByName, _super); + function StoredContractByName(name, entryPoint, args) { + var _this = _super.call(this) || this; + _this.tag = 2; + _this.name = name; + _this.entryPoint = entryPoint; + _this.args = args; + return _this; + } + StoredContractByName.prototype.toBytes = function () { + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesString(this.name), + byterepr_1.toBytesString(this.entryPoint), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], StoredContractByName.prototype, "name", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'entry_point', + constructor: String + }), + __metadata("design:type", String) + ], StoredContractByName.prototype, "entryPoint", void 0); + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], StoredContractByName.prototype, "args", void 0); + StoredContractByName = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [String, String, RuntimeArgs_1.RuntimeArgs]) + ], StoredContractByName); + return StoredContractByName; + }(ExecutableDeployItemInternal)); + exports.StoredContractByName = StoredContractByName; + var StoredVersionedContractByName = /** @class */ (function (_super) { + __extends(StoredVersionedContractByName, _super); + function StoredVersionedContractByName(name, version, entryPoint, args) { + var _this = _super.call(this) || this; + _this.tag = 4; + _this.name = name; + _this.version = version; + _this.entryPoint = entryPoint; + _this.args = args; + return _this; + } + StoredVersionedContractByName.prototype.toBytes = function () { + var serializedVersion; + if (this.version === null) { + serializedVersion = new option_1.Option(null, CLValue_1.CLTypeHelper.u32()); + } + else { + serializedVersion = new option_1.Option(new CLValue_1.U32(this.version)); + } + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesString(this.name), + serializedVersion.toBytes(), + byterepr_1.toBytesString(this.entryPoint), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], StoredVersionedContractByName.prototype, "name", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: Number, preserveNull: true }), + __metadata("design:type", Object) + ], StoredVersionedContractByName.prototype, "version", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'entry_point', constructor: String }), + __metadata("design:type", String) + ], StoredVersionedContractByName.prototype, "entryPoint", void 0); + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], StoredVersionedContractByName.prototype, "args", void 0); + StoredVersionedContractByName = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [String, Object, String, RuntimeArgs_1.RuntimeArgs]) + ], StoredVersionedContractByName); + return StoredVersionedContractByName; + }(ExecutableDeployItemInternal)); + exports.StoredVersionedContractByName = StoredVersionedContractByName; + var StoredVersionedContractByHash = /** @class */ (function (_super) { + __extends(StoredVersionedContractByHash, _super); + function StoredVersionedContractByHash(hash, version, entryPoint, args) { + var _this = _super.call(this) || this; + _this.tag = 3; + _this.hash = hash; + _this.version = version; + _this.entryPoint = entryPoint; + _this.args = args; + return _this; + } + StoredVersionedContractByHash.prototype.toBytes = function () { + var serializedVersion; + if (this.version === null) { + serializedVersion = new option_1.Option(null, CLValue_1.CLTypeHelper.u32()); + } + else { + serializedVersion = new option_1.Option(new CLValue_1.U32(this.version)); + } + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesBytesArray(this.hash), + serializedVersion.toBytes(), + byterepr_1.toBytesString(this.entryPoint), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ + serializer: byteArrayJsonSerializer, + deserializer: byteArrayJsonDeserializer + }), + __metadata("design:type", Uint8Array) + ], StoredVersionedContractByHash.prototype, "hash", void 0); + __decorate([ + typedjson_1.jsonMember({ + constructor: Number, + preserveNull: true + }), + __metadata("design:type", Object) + ], StoredVersionedContractByHash.prototype, "version", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'entry_point', + constructor: String + }), + __metadata("design:type", String) + ], StoredVersionedContractByHash.prototype, "entryPoint", void 0); + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], StoredVersionedContractByHash.prototype, "args", void 0); + StoredVersionedContractByHash = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [Uint8Array, Object, String, RuntimeArgs_1.RuntimeArgs]) + ], StoredVersionedContractByHash); + return StoredVersionedContractByHash; + }(ExecutableDeployItemInternal)); + exports.StoredVersionedContractByHash = StoredVersionedContractByHash; + var Transfer = /** @class */ (function (_super) { + __extends(Transfer, _super); + /** + * Constructor for Transfer deploy item. + * @param amount The number of motes to transfer + * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex + * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ + * transfer will be used as the source purse + * @param id user-defined transfer id + */ + function Transfer(args) { + var _this = _super.call(this) || this; + _this.tag = 5; + _this.args = args; + return _this; + } + Transfer.prototype.toBytes = function () { + return bytes_1.concat([ + Uint8Array.from([this.tag]), + byterepr_1.toBytesBytesArray(this.args.toBytes()) + ]); + }; + __decorate([ + typedjson_1.jsonMember({ + deserializer: desRA, + serializer: serRA + }), + __metadata("design:type", RuntimeArgs_1.RuntimeArgs) + ], Transfer.prototype, "args", void 0); + Transfer = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [RuntimeArgs_1.RuntimeArgs]) + ], Transfer); + return Transfer; + }(ExecutableDeployItemInternal)); + exports.Transfer = Transfer; + var ExecutableDeployItem = /** @class */ (function () { + function ExecutableDeployItem() { + } + ExecutableDeployItem_1 = ExecutableDeployItem; + ExecutableDeployItem.prototype.toBytes = function () { + if (this.isModuleBytes()) { + return this.moduleBytes.toBytes(); + } + else if (this.isStoredContractByHash()) { + return this.storedContractByHash.toBytes(); + } + else if (this.isStoredContractByName()) { + return this.storedContractByName.toBytes(); + } + else if (this.isStoredVersionContractByHash()) { + return this.storedVersionedContractByHash.toBytes(); + } + else if (this.isStoredVersionContractByName()) { + return this.storedVersionedContractByName.toBytes(); + } + else if (this.isTransfer()) { + return this.transfer.toBytes(); + } + throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); + }; + ExecutableDeployItem.prototype.getArgByName = function (name) { + if (this.isModuleBytes()) { + return this.moduleBytes.getArgByName(name); + } + else if (this.isStoredContractByHash()) { + return this.storedContractByHash.getArgByName(name); + } + else if (this.isStoredContractByName()) { + return this.storedContractByName.getArgByName(name); + } + else if (this.isStoredVersionContractByHash()) { + return this.storedVersionedContractByHash.getArgByName(name); + } + else if (this.isStoredVersionContractByName()) { + return this.storedVersionedContractByName.getArgByName(name); + } + else if (this.isTransfer()) { + return this.transfer.getArgByName(name); + } + throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); + }; + ExecutableDeployItem.prototype.setArg = function (name, value) { + if (this.isModuleBytes()) { + return this.moduleBytes.setArg(name, value); + } + else if (this.isStoredContractByHash()) { + return this.storedContractByHash.setArg(name, value); + } + else if (this.isStoredContractByName()) { + return this.storedContractByName.setArg(name, value); + } + else if (this.isStoredVersionContractByHash()) { + return this.storedVersionedContractByHash.setArg(name, value); + } + else if (this.isStoredVersionContractByName()) { + return this.storedVersionedContractByName.setArg(name, value); + } + else if (this.isTransfer()) { + return this.transfer.setArg(name, value); + } + throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); + }; + ExecutableDeployItem.fromExecutableDeployItemInternal = function (item) { + var res = new ExecutableDeployItem_1(); + switch (item.tag) { + case 0: + res.moduleBytes = item; + break; + case 1: + res.storedContractByHash = item; + break; + case 2: + res.storedContractByName = item; + break; + case 3: + res.storedVersionedContractByHash = item; + break; + case 4: + res.storedVersionedContractByName = item; + break; + case 5: + res.transfer = item; + break; + } + return res; + }; + ExecutableDeployItem.newModuleBytes = function (moduleBytes, args) { + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new ModuleBytes(moduleBytes, args)); + }; + ExecutableDeployItem.newStoredContractByHash = function (hash, entryPoint, args) { + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredContractByHash(hash, entryPoint, args)); + }; + ExecutableDeployItem.newStoredContractByName = function (name, entryPoint, args) { + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredContractByName(name, entryPoint, args)); + }; + ExecutableDeployItem.newStoredVersionContractByHash = function (hash, version, entryPoint, args) { + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredVersionedContractByHash(hash, version, entryPoint, args)); + }; + ExecutableDeployItem.newStoredVersionContractByName = function (name, version, entryPoint, args) { + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredVersionedContractByName(name, version, entryPoint, args)); + }; + /** + * Constructor for Transfer deploy item. + * @param amount The number of motes to transfer + * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex + * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ + * transfer will be used as the source purse + * @param id user-defined transfer id. This parameter is required. + */ + ExecutableDeployItem.newTransfer = function (amount, target, sourcePurse, id) { + if (sourcePurse === void 0) { sourcePurse = null; } + var runtimeArgs = RuntimeArgs_1.RuntimeArgs.fromMap({}); + runtimeArgs.insert('amount', CLValue_1.CLValue.u512(amount)); + if (sourcePurse) { + runtimeArgs.insert('source', CLValue_1.CLValue.uref(sourcePurse)); + } + if (target instanceof index_1.URef) { + runtimeArgs.insert('target', CLValue_1.CLValue.uref(target)); + } + else if (target instanceof CLValue_1.PublicKey) { + runtimeArgs.insert('target', CLValue_1.CLValue.byteArray(target.toAccountHash())); + } + else { + throw new Error('Please specify target'); + } + if (id === undefined) { + throw new Error('transfer-id missing in new transfer.'); + } + else { + runtimeArgs.insert('id', CLValue_1.CLValue.option(CLValue_1.CLTypedAndToBytesHelper.u64(id), CLValue_1.CLTypeHelper.u64())); + } + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new Transfer(runtimeArgs)); + }; + // TODO: Abstract the logic of this and newTransfer so there won't be so much redundancy. + /** + * Constructor for Transfer deploy item without obligatory transfer-id. + * @param amount The number of motes to transfer + * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex + * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ + * transfer will be used as the source purse + * @param id user-defined transfer id. This parameter is optional. + */ + ExecutableDeployItem.newTransferWithOptionalTransferId = function (amount, target, sourcePurse, id) { + var runtimeArgs = RuntimeArgs_1.RuntimeArgs.fromMap({}); + runtimeArgs.insert('amount', CLValue_1.CLValue.u512(amount)); + if (sourcePurse) { + runtimeArgs.insert('source', CLValue_1.CLValue.uref(sourcePurse)); + } + if (target instanceof index_1.URef) { + runtimeArgs.insert('target', CLValue_1.CLValue.uref(target)); + } + else if (target instanceof CLValue_1.PublicKey) { + runtimeArgs.insert('target', CLValue_1.CLValue.byteArray(target.toAccountHash())); + } + else { + throw new Error('Please specify target'); + } + if (id !== undefined && id !== null) { + runtimeArgs.insert('id', CLValue_1.CLValue.option(CLValue_1.CLTypedAndToBytesHelper.u64(id), CLValue_1.CLTypeHelper.u64())); + } + else { + runtimeArgs.insert('id', CLValue_1.CLValue.option(null, CLValue_1.CLTypeHelper.u64())); + } + return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new Transfer(runtimeArgs)); + }; + /** + * Constructor for Transfer deploy item using UniqAddress. + * @param source PublicKey of source account + * @param target UniqAddress of target account + * @param amount The number of motes to transfer + * @param paymentAmount the number of motes paying to execution engine + * @param chainName Name of the chain, to avoid the `Deploy` from being accidentally or maliciously included in a different chain. + * @param gasPrice Conversion rate between the cost of Wasm opcodes and the motes sent by the payment code. + * @param ttl Time that the `Deploy` will remain valid for, in milliseconds. The default value is 1800000, which is 30 minutes + * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ + * transfer will be used as the source purse + */ + ExecutableDeployItem.newTransferToUniqAddress = function (source, target, amount, paymentAmount, chainName, gasPrice, ttl, sourcePurse) { + if (gasPrice === void 0) { gasPrice = 1; } + if (ttl === void 0) { ttl = 1800000; } + var deployParams = new index_1.DeployUtil.DeployParams(source, chainName, gasPrice, ttl); + var payment = index_1.DeployUtil.standardPayment(paymentAmount); + var session = index_1.DeployUtil.ExecutableDeployItem.newTransfer(amount, target.publicKey, sourcePurse, target.transferId); + return index_1.DeployUtil.makeDeploy(deployParams, session, payment); + }; + ExecutableDeployItem.prototype.isModuleBytes = function () { + return !!this.moduleBytes; + }; + ExecutableDeployItem.prototype.asModuleBytes = function () { + return this.moduleBytes; + }; + ExecutableDeployItem.prototype.isStoredContractByHash = function () { + return !!this.storedContractByHash; + }; + ExecutableDeployItem.prototype.asStoredContractByHash = function () { + return this.storedContractByHash; + }; + ExecutableDeployItem.prototype.isStoredContractByName = function () { + return !!this.storedContractByName; + }; + ExecutableDeployItem.prototype.asStoredContractByName = function () { + return this.storedContractByName; + }; + ExecutableDeployItem.prototype.isStoredVersionContractByName = function () { + return !!this.storedVersionedContractByName; + }; + ExecutableDeployItem.prototype.asStoredVersionContractByName = function () { + return this.storedVersionedContractByName; + }; + ExecutableDeployItem.prototype.isStoredVersionContractByHash = function () { + return !!this.storedVersionedContractByHash; + }; + ExecutableDeployItem.prototype.asStoredVersionContractByHash = function () { + return this.storedVersionedContractByHash; + }; + ExecutableDeployItem.prototype.isTransfer = function () { + return !!this.transfer; + }; + ExecutableDeployItem.prototype.asTransfer = function () { + return this.transfer; + }; + var ExecutableDeployItem_1; + __decorate([ + typedjson_1.jsonMember({ + name: 'ModuleBytes', + constructor: ModuleBytes + }), + __metadata("design:type", ModuleBytes) + ], ExecutableDeployItem.prototype, "moduleBytes", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'StoredContractByHash', + constructor: StoredContractByHash + }), + __metadata("design:type", StoredContractByHash) + ], ExecutableDeployItem.prototype, "storedContractByHash", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'StoredContractByName', + constructor: StoredContractByName + }), + __metadata("design:type", StoredContractByName) + ], ExecutableDeployItem.prototype, "storedContractByName", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'StoredVersionedContractByHash', + constructor: StoredVersionedContractByHash + }), + __metadata("design:type", StoredVersionedContractByHash) + ], ExecutableDeployItem.prototype, "storedVersionedContractByHash", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'StoredVersionedContractByName', + constructor: StoredVersionedContractByName + }), + __metadata("design:type", StoredVersionedContractByName) + ], ExecutableDeployItem.prototype, "storedVersionedContractByName", void 0); + __decorate([ + typedjson_1.jsonMember({ + name: 'Transfer', + constructor: Transfer + }), + __metadata("design:type", Transfer) + ], ExecutableDeployItem.prototype, "transfer", void 0); + ExecutableDeployItem = ExecutableDeployItem_1 = __decorate([ + typedjson_1.jsonObject + ], ExecutableDeployItem); + return ExecutableDeployItem; + }()); + exports.ExecutableDeployItem = ExecutableDeployItem; + /** + * A deploy containing a smart contract along with the requester's signature(s). + */ + var Deploy = /** @class */ (function () { + /** + * + * @param hash The DeployHash identifying this Deploy + * @param header The deployHeader + * @param payment The ExecutableDeployItem for payment code. + * @param session the ExecutableDeployItem for session code. + * @param approvals An array of signature and public key of the signers, who approve this deploy + */ + function Deploy(hash, header, payment, session, approvals) { + this.approvals = approvals; + this.session = session; + this.payment = payment; + this.header = header; + this.hash = hash; + } + Deploy.prototype.isTransfer = function () { + return this.session.isTransfer(); + }; + Deploy.prototype.isStandardPayment = function () { + var _a; + if (this.payment.isModuleBytes()) { + return ((_a = this.payment.asModuleBytes()) === null || _a === void 0 ? void 0 : _a.moduleBytes.length) === 0; + } + return false; + }; + __decorate([ + typedjson_1.jsonMember({ + serializer: byteArrayJsonSerializer, + deserializer: byteArrayJsonDeserializer + }), + __metadata("design:type", Uint8Array) + ], Deploy.prototype, "hash", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: DeployHeader }), + __metadata("design:type", DeployHeader) + ], Deploy.prototype, "header", void 0); + __decorate([ + typedjson_1.jsonMember({ + constructor: ExecutableDeployItem + }), + __metadata("design:type", ExecutableDeployItem) + ], Deploy.prototype, "payment", void 0); + __decorate([ + typedjson_1.jsonMember({ + constructor: ExecutableDeployItem + }), + __metadata("design:type", ExecutableDeployItem) + ], Deploy.prototype, "session", void 0); + __decorate([ + typedjson_1.jsonArrayMember(Approval), + __metadata("design:type", Array) + ], Deploy.prototype, "approvals", void 0); + Deploy = __decorate([ + typedjson_1.jsonObject, + __metadata("design:paramtypes", [Uint8Array, + DeployHeader, + ExecutableDeployItem, + ExecutableDeployItem, Array]) + ], Deploy); + return Deploy; + }()); + exports.Deploy = Deploy; + /** + * Serialize deployHeader into a array of bytes + * @param deployHeader + */ + exports.serializeHeader = function (deployHeader) { + return deployHeader.toBytes(); + }; + /** + * Serialize deployBody into a array of bytes + * @param payment + * @param session + */ + exports.serializeBody = function (payment, session) { + return bytes_1.concat([payment.toBytes(), session.toBytes()]); + }; + exports.serializeApprovals = function (approvals) { + var len = byterepr_1.toBytesU32(approvals.length); + var bytes = bytes_1.concat(approvals.map(function (approval) { + return bytes_1.concat([ + Uint8Array.from(Buffer.from(approval.signer, 'hex')), + Uint8Array.from(Buffer.from(approval.signature, 'hex')) + ]); + })); + return bytes_1.concat([len, bytes]); + }; + /** + * Supported contract type + */ + var ContractType; + (function (ContractType) { + ContractType["WASM"] = "WASM"; + ContractType["Hash"] = "Hash"; + ContractType["Name"] = "Name"; + })(ContractType = exports.ContractType || (exports.ContractType = {})); + var DeployParams = /** @class */ (function () { + /** + * Container for `Deploy` construction options. + * @param accountPublicKey + * @param chainName Name of the chain, to avoid the `Deploy` from being accidentally or maliciously included in a different chain. + * @param gasPrice Conversion rate between the cost of Wasm opcodes and the motes sent by the payment code. + * @param ttl Time that the `Deploy` will remain valid for, in milliseconds. The default value is 1800000, which is 30 minutes + * @param dependencies Hex-encoded `Deploy` hashes of deploys which must be executed before this one. + * @param timestamp If `timestamp` is empty, the current time will be used. Note that timestamp is UTC, not local. + */ + function DeployParams(accountPublicKey, chainName, gasPrice, ttl, dependencies, timestamp) { + if (gasPrice === void 0) { gasPrice = 1; } + if (ttl === void 0) { ttl = 1800000; } + if (dependencies === void 0) { dependencies = []; } + this.accountPublicKey = accountPublicKey; + this.chainName = chainName; + this.gasPrice = gasPrice; + this.ttl = ttl; + this.dependencies = dependencies; + this.timestamp = timestamp; + this.dependencies = dependencies.filter(function (d) { + return dependencies.filter(function (t) { return Conversions_1.encodeBase16(d) === Conversions_1.encodeBase16(t); }).length < 2; + }); + if (!timestamp) { + this.timestamp = Date.now(); + } + } + return DeployParams; + }()); + exports.DeployParams = DeployParams; + /** + * Makes Deploy message + */ + function makeDeploy(deployParam, session, payment) { + var serializedBody = exports.serializeBody(payment, session); + var bodyHash = blakejs_1.default.blake2b(serializedBody, null, 32); + var header = new DeployHeader(deployParam.accountPublicKey, deployParam.timestamp, deployParam.ttl, deployParam.gasPrice, bodyHash, deployParam.dependencies, deployParam.chainName); + var serializedHeader = exports.serializeHeader(header); + var deployHash = blakejs_1.default.blake2b(serializedHeader, null, 32); + return new Deploy(deployHash, header, payment, session, []); + } + exports.makeDeploy = makeDeploy; + /** + * Uses the provided key pair to sign the Deploy message + * + * @param deploy + * @param signingKey the keyPair to sign deploy + */ + exports.signDeploy = function (deploy, signingKey) { + var approval = new Approval(); + var signature = signingKey.sign(deploy.hash); + approval.signer = signingKey.accountHex(); + switch (signingKey.signatureAlgorithm) { + case Keys_1.SignatureAlgorithm.Ed25519: + approval.signature = index_1.Keys.Ed25519.accountHex(signature); + break; + case Keys_1.SignatureAlgorithm.Secp256K1: + approval.signature = index_1.Keys.Secp256K1.accountHex(signature); + break; + } + deploy.approvals.push(approval); + return deploy; + }; + /** + * Sets the already generated Ed25519 signature for the Deploy message + * + * @param deploy + * @param sig the Ed25519 signature + * @param publicKey the public key used to generate the Ed25519 signature + */ + exports.setSignature = function (deploy, sig, publicKey) { + var approval = new Approval(); + approval.signer = publicKey.toAccountHex(); + switch (publicKey.signatureAlgorithm()) { + case Keys_1.SignatureAlgorithm.Ed25519: + approval.signature = index_1.Keys.Ed25519.accountHex(sig); + break; + case Keys_1.SignatureAlgorithm.Secp256K1: + approval.signature = index_1.Keys.Secp256K1.accountHex(sig); + break; + } + deploy.approvals.push(approval); + return deploy; + }; + /** + * Standard payment code. + * + * @param paymentAmount the number of motes paying to execution engine + */ + exports.standardPayment = function (paymentAmount) { + var paymentArgs = RuntimeArgs_1.RuntimeArgs.fromMap({ + amount: CLValue_1.CLValue.u512(paymentAmount.toString()) + }); + return ExecutableDeployItem.newModuleBytes(Uint8Array.from([]), paymentArgs); + }; + /** + * Convert the deploy object to json + * + * @param deploy + */ + exports.deployToJson = function (deploy) { + var serializer = new typedjson_1.TypedJSON(Deploy); + return { + deploy: serializer.toPlainJson(deploy) + }; + }; + /** + * Convert the json to deploy object + * + * @param json + */ + exports.deployFromJson = function (json) { + var serializer = new typedjson_1.TypedJSON(Deploy); + var deploy = serializer.parse(json.deploy); + if (deploy !== undefined && exports.validateDeploy(deploy).ok) { + return deploy; + } + return undefined; + }; + exports.addArgToDeploy = function (deploy, name, value) { + if (deploy.approvals.length !== 0) { + throw Error('Can not add argument to already signed deploy.'); + } + var deployParams = new index_1.DeployUtil.DeployParams(deploy.header.account, deploy.header.chainName, deploy.header.gasPrice, deploy.header.ttl, deploy.header.dependencies, deploy.header.timestamp); + var session = deploy.session; + session.setArg(name, value); + return makeDeploy(deployParams, session, deploy.payment); + }; + exports.deploySizeInBytes = function (deploy) { + var hashSize = deploy.hash.length; + var bodySize = exports.serializeBody(deploy.payment, deploy.session).length; + var headerSize = exports.serializeHeader(deploy.header).length; + var approvalsSize = deploy.approvals + .map(function (approval) { + return (approval.signature.length + approval.signer.length) / 2; + }) + .reduce(function (a, b) { return a + b; }, 0); + return hashSize + headerSize + bodySize + approvalsSize; + }; + exports.validateDeploy = function (deploy) { + var serializedBody = exports.serializeBody(deploy.payment, deploy.session); + var bodyHash = blakejs_1.default.blake2b(serializedBody, null, 32); + if (!arrayEquals(deploy.header.bodyHash, bodyHash)) { + return ts_results_1.Err("Invalid deploy: bodyHash missmatch. Expected: " + bodyHash + ", \n got: " + deploy.header.bodyHash + "."); + } + var serializedHeader = exports.serializeHeader(deploy.header); + var deployHash = blakejs_1.default.blake2b(serializedHeader, null, 32); + if (!arrayEquals(deploy.hash, deployHash)) { + return ts_results_1.Err("Invalid deploy: hash missmatch. Expected: " + deployHash + ", \n got: " + deploy.hash + "."); + } + // TODO: Verify included signatures. + return ts_results_1.Ok(deploy); + }; + var arrayEquals = function (a, b) { + return a.length === b.length && a.every(function (val, index) { return val === b[index]; }); + }; + exports.deployToBytes = function (deploy) { + return bytes_1.concat([ + exports.serializeHeader(deploy.header), + deploy.hash, + exports.serializeBody(deploy.payment, deploy.session), + exports.serializeApprovals(deploy.approvals) + ]); + }; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./CLValue":182,"./Conversions":186,"./Keys":188,"./RuntimeArgs":189,"./byterepr":193,"./index":194,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"blakejs":43,"buffer":266,"humanize-duration":96,"ts-results":136,"tweetnacl-ts":153,"typedjson":166}],188:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }); + var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Secp256K1 = exports.Ed25519 = exports.AsymmetricKey = exports.readBase64WithPEM = exports.SignatureAlgorithm = void 0; + var fs = __importStar(require("fs")); + var nacl = __importStar(require("tweetnacl-ts")); + var tweetnacl_util_1 = require("tweetnacl-util"); + var index_1 = require("../index"); + var index_2 = require("../lib/index"); + var Contracts_1 = require("./Contracts"); + var eccrypto_1 = __importDefault(require("eccrypto")); + var secp256k1 = __importStar(require("ethereum-cryptography/secp256k1")); + var key_encoder_1 = __importDefault(require("key-encoder")); + var sha256_1 = require("ethereum-cryptography/sha256"); + var keyEncoder = new key_encoder_1.default('secp256k1'); + var ED25519_PEM_SECRET_KEY_TAG = 'PRIVATE KEY'; + var ED25519_PEM_PUBLIC_KEY_TAG = 'PUBLIC KEY'; + /** + * Supported types of Asymmetric Key algorithm + */ + var SignatureAlgorithm; + (function (SignatureAlgorithm) { + SignatureAlgorithm["Ed25519"] = "ed25519"; + SignatureAlgorithm["Secp256K1"] = "secp256k1"; + })(SignatureAlgorithm = exports.SignatureAlgorithm || (exports.SignatureAlgorithm = {})); + function accountHashHelper(signatureAlgorithm, publicKey) { + var separator = Buffer.from([0]); + var prefix = Buffer.concat([Buffer.from(signatureAlgorithm), separator]); + if (publicKey.length === 0) { + return Buffer.from([]); + } + else { + return Contracts_1.byteHash(Buffer.concat([prefix, Buffer.from(publicKey)])); + } + } + /** + * Get rid of PEM frames, skips header `-----BEGIN PUBLIC KEY-----` + * and footer `-----END PUBLIC KEY-----` + * + * Example PEM: + * + * ``` + * -----BEGIN PUBLIC KEY-----\r\n + * MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEj1fgdbpNbt06EY/8C+wbBXq6VvG+vCVD\r\n + * Nl74LvVAmXfpdzCWFKbdrnIlX3EFDxkd9qpk35F/kLcqV3rDn/u3dg==\r\n + * -----END PUBLIC KEY-----\r\n + * ``` + * + */ + function readBase64WithPEM(content) { + var base64 = content + // there are two kinks of line-endings, CRLF(\r\n) and LF(\n) + // we need handle both + .split(/\r?\n/) + .filter(function (x) { return !x.startsWith('---'); }) + .join('') + // remove the line-endings in the end of content + .trim(); + return tweetnacl_util_1.decodeBase64(base64); + } + exports.readBase64WithPEM = readBase64WithPEM; + var AsymmetricKey = /** @class */ (function () { + function AsymmetricKey(publicKey, privateKey, signatureAlgorithm) { + this.publicKey = index_2.PublicKey.from(publicKey, signatureAlgorithm); + this.privateKey = privateKey; + this.signatureAlgorithm = signatureAlgorithm; + } + /** + * Compute a unique hash from the algorithm name(Ed25519 here) and a public key, used for accounts. + */ + AsymmetricKey.prototype.accountHash = function () { + return this.publicKey.toAccountHash(); + }; + /** + * Get the account hex + */ + AsymmetricKey.prototype.accountHex = function () { + return this.publicKey.toAccountHex(); + }; + AsymmetricKey.prototype.toPem = function (tag, content) { + // prettier-ignore + return "-----BEGIN " + tag + "-----\n" + + (content + "\n") + + ("-----END " + tag + "-----\n"); + }; + return AsymmetricKey; + }()); + exports.AsymmetricKey = AsymmetricKey; + // Based on SignatureAlgorithm.scala + var Ed25519 = /** @class */ (function (_super) { + __extends(Ed25519, _super); + function Ed25519(keyPair) { + return _super.call(this, keyPair.publicKey, keyPair.secretKey, SignatureAlgorithm.Ed25519) || this; + } + /** + * Generating a new Ed25519 key pair + */ + Ed25519.new = function () { + return new Ed25519(nacl.sign_keyPair()); + }; + /** + * Generate the accountHex for the Ed25519 public key + * @param publicKey + */ + Ed25519.accountHex = function (publicKey) { + return '01' + index_1.encodeBase16(publicKey); + }; + /** + * Parse the key pair from publicKey file and privateKey file + * @param publicKeyPath path of public key file + * @param privateKeyPath path of private key file + */ + Ed25519.parseKeyFiles = function (publicKeyPath, privateKeyPath) { + var publicKey = Ed25519.parsePublicKeyFile(publicKeyPath); + var privateKey = Ed25519.parsePrivateKeyFile(privateKeyPath); + // nacl expects that the private key will contain both. + return new Ed25519({ + publicKey: publicKey, + secretKey: Buffer.concat([privateKey, publicKey]) + }); + }; + /** + * Generate the accountHash for the Ed25519 public key + * @param publicKey + */ + Ed25519.accountHash = function (publicKey) { + return accountHashHelper(SignatureAlgorithm.Ed25519, publicKey); + }; + /** + * Construct keyPair from a public key and private key + * @param publicKey + * @param privateKey + */ + Ed25519.parseKeyPair = function (publicKey, privateKey) { + var publ = Ed25519.parsePublicKey(publicKey); + var priv = Ed25519.parsePrivateKey(privateKey); + // nacl expects that the private key will contain both. + var secr = new Uint8Array(publ.length + priv.length); + secr.set(priv); + secr.set(publ, priv.length); + return new Ed25519({ + publicKey: publ, + secretKey: secr + }); + }; + Ed25519.parsePrivateKeyFile = function (path) { + return Ed25519.parsePrivateKey(Ed25519.readBase64File(path)); + }; + Ed25519.parsePublicKeyFile = function (path) { + return Ed25519.parsePublicKey(Ed25519.readBase64File(path)); + }; + Ed25519.parsePrivateKey = function (bytes) { + return Ed25519.parseKey(bytes, 0, 32); + }; + Ed25519.parsePublicKey = function (bytes) { + return Ed25519.parseKey(bytes, 32, 64); + }; + Ed25519.readBase64WithPEM = function (content) { + return readBase64WithPEM(content); + }; + /** + * Read the Base64 content of a file, get rid of PEM frames. + * + * @param path the path of file to read from + */ + Ed25519.readBase64File = function (path) { + var content = fs.readFileSync(path).toString(); + return Ed25519.readBase64WithPEM(content); + }; + Ed25519.parseKey = function (bytes, from, to) { + var len = bytes.length; + // prettier-ignore + var key = (len === 32) ? bytes : + (len === 64) ? Buffer.from(bytes).slice(from, to) : + (len > 32 && len < 64) ? Buffer.from(bytes).slice(len % 32) : + null; + if (key == null || key.length !== 32) { + throw Error("Unexpected key length: " + len); + } + return key; + }; + /** + * Export the private key encoded in pem + */ + Ed25519.prototype.exportPrivateKeyInPem = function () { + // prettier-ignore + var derPrefix = Buffer.from([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]); + var encoded = index_1.encodeBase64(Buffer.concat([ + derPrefix, + Buffer.from(Ed25519.parsePrivateKey(this.privateKey)) + ])); + return this.toPem(ED25519_PEM_SECRET_KEY_TAG, encoded); + }; + /** + * Expect the public key encoded in pem + */ + Ed25519.prototype.exportPublicKeyInPem = function () { + // prettier-ignore + var derPrefix = Buffer.from([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]); + var encoded = index_1.encodeBase64(Buffer.concat([derPrefix, Buffer.from(this.publicKey.rawPublicKey)])); + return this.toPem(ED25519_PEM_PUBLIC_KEY_TAG, encoded); + }; + /** + * Sign the message by using the keyPair + * @param msg + */ + Ed25519.prototype.sign = function (msg) { + return nacl.sign_detached(msg, this.privateKey); + }; + /** + * Verify the signature along with the raw message + * @param signature + * @param msg + */ + Ed25519.prototype.verify = function (signature, msg) { + return nacl.sign_detached_verify(msg, signature, this.publicKey.rawPublicKey); + }; + /** + * Derive public key from private key + * @param privateKey + */ + Ed25519.privateToPublicKey = function (privateKey) { + if (privateKey.length === 64 /* SecretKey */) { + return nacl.sign_keyPair_fromSecretKey(privateKey).publicKey; + } + else { + return nacl.sign_keyPair_fromSeed(privateKey).publicKey; + } + }; + /** + * Restore Ed25519 keyPair from private key file + * @param privateKeyPath + */ + Ed25519.loadKeyPairFromPrivateFile = function (privateKeyPath) { + var privateKey = Ed25519.parsePrivateKeyFile(privateKeyPath); + var publicKey = Ed25519.privateToPublicKey(privateKey); + return Ed25519.parseKeyPair(publicKey, privateKey); + }; + return Ed25519; + }(AsymmetricKey)); + exports.Ed25519 = Ed25519; + var Secp256K1 = /** @class */ (function (_super) { + __extends(Secp256K1, _super); + function Secp256K1(publicKey, privateKey) { + return _super.call(this, publicKey, privateKey, SignatureAlgorithm.Secp256K1) || this; + } + /** + * Generating a new Secp256K1 key pair + */ + Secp256K1.new = function () { + var privateKey = eccrypto_1.default.generatePrivate(); + var publicKey = Uint8Array.from(eccrypto_1.default.getPublicCompressed(privateKey)); + return new Secp256K1(publicKey, privateKey); + }; + /** + * Parse the key pair from publicKey file and privateKey file + * @param publicKeyPath path of public key file + * @param privateKeyPath path of private key file + */ + Secp256K1.parseKeyFiles = function (publicKeyPath, privateKeyPath) { + var publicKey = Secp256K1.parsePublicKeyFile(publicKeyPath); + var privateKey = Secp256K1.parsePrivateKeyFile(privateKeyPath); + return new Secp256K1(publicKey, privateKey); + }; + /** + * Generate the accountHash for the Secp256K1 public key + * @param publicKey + */ + Secp256K1.accountHash = function (publicKey) { + return accountHashHelper(SignatureAlgorithm.Secp256K1, publicKey); + }; + /** + * Generate the accountHex for the Secp256K1 public key + * @param publicKey + */ + Secp256K1.accountHex = function (publicKey) { + return '02' + index_1.encodeBase16(publicKey); + }; + /** + * Construct keyPair from public key and private key + * @param publicKey + * @param privateKey + * @param originalFormat the format of the public/private key + */ + Secp256K1.parseKeyPair = function (publicKey, privateKey, originalFormat) { + var publ = Secp256K1.parsePublicKey(publicKey, originalFormat); + var priv = Secp256K1.parsePrivateKey(privateKey, originalFormat); + // nacl expects that the private key will contain both. + return new Secp256K1(publ, priv); + }; + Secp256K1.parsePrivateKeyFile = function (path) { + return Secp256K1.parsePrivateKey(Secp256K1.readBase64File(path)); + }; + Secp256K1.parsePublicKeyFile = function (path) { + return Secp256K1.parsePublicKey(Secp256K1.readBase64File(path)); + }; + Secp256K1.parsePrivateKey = function (bytes, originalFormat) { + if (originalFormat === void 0) { originalFormat = 'der'; } + var rawKeyHex; + if (originalFormat === 'der') { + rawKeyHex = keyEncoder.encodePrivate(Buffer.from(bytes), 'der', 'raw'); + } + else { + rawKeyHex = index_1.encodeBase16(bytes); + } + var privateKey = Buffer.from(rawKeyHex, 'hex'); + return privateKey; + }; + Secp256K1.parsePublicKey = function (bytes, originalFormat) { + if (originalFormat === void 0) { originalFormat = 'der'; } + var rawKeyHex; + if (originalFormat === 'der') { + rawKeyHex = keyEncoder.encodePublic(Buffer.from(bytes), 'der', 'raw'); + } + else { + rawKeyHex = index_1.encodeBase16(bytes); + } + var publicKey = Uint8Array.from(Buffer.from(rawKeyHex, 'hex')); + return publicKey; + }; + Secp256K1.readBase64WithPEM = function (content) { + return readBase64WithPEM(content); + }; + /** + * Read the Base64 content of a file, get rid of PEM frames. + * + * @param path the path of file to read from + */ + Secp256K1.readBase64File = function (path) { + var content = fs.readFileSync(path).toString(); + return Secp256K1.readBase64WithPEM(content); + }; + /** + * Export the private key encoded in pem + */ + Secp256K1.prototype.exportPrivateKeyInPem = function () { + return keyEncoder.encodePrivate(index_1.encodeBase16(this.privateKey), 'raw', 'pem'); + }; + /** + * Expect the public key encoded in pem + */ + Secp256K1.prototype.exportPublicKeyInPem = function () { + return keyEncoder.encodePublic(index_1.encodeBase16(this.publicKey.rawPublicKey), 'raw', 'pem'); + }; + /** + * Sign the message by using the keyPair + * @param msg + */ + Secp256K1.prototype.sign = function (msg) { + var res = secp256k1.ecdsaSign(sha256_1.sha256(Buffer.from(msg)), this.privateKey); + return res.signature; + }; + /** + * Verify the signature along with the raw message + * @param signature + * @param msg + */ + Secp256K1.prototype.verify = function (signature, msg) { + return secp256k1.ecdsaVerify(signature, sha256_1.sha256(Buffer.from(msg)), this.publicKey.rawPublicKey); + }; + /** + * Derive public key from private key + * @param privateKey + */ + Secp256K1.privateToPublicKey = function (privateKey) { + return secp256k1.publicKeyCreate(privateKey, true); + }; + /** + * Restore Secp256K1 keyPair from private key file + * @param privateKeyPath a path to file of the private key + */ + Secp256K1.loadKeyPairFromPrivateFile = function (privateKeyPath) { + var privateKey = Secp256K1.parsePrivateKeyFile(privateKeyPath); + var publicKey = Secp256K1.privateToPublicKey(privateKey); + return Secp256K1.parseKeyPair(publicKey, privateKey, 'raw'); + }; + /** + * From hdKey derive a child Secp256K1 key + * @param hdKey + * @param index + */ + Secp256K1.deriveIndex = function (hdKey, index) { + return hdKey.deriveIndex(index); + }; + return Secp256K1; + }(AsymmetricKey)); + exports.Secp256K1 = Secp256K1; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"../index":181,"../lib/index":194,"./Contracts":185,"buffer":266,"eccrypto":55,"ethereum-cryptography/secp256k1":80,"ethereum-cryptography/sha256":75,"fs":199,"key-encoder":100,"tweetnacl-ts":153,"tweetnacl-util":163}],189:[function(require,module,exports){ + "use strict"; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.RuntimeArgs = exports.NamedArg = void 0; + /** + * Implements a collection of runtime arguments. + */ + var byterepr_1 = require("./byterepr"); + var CLValue_1 = require("./CLValue"); + var bytes_1 = require("@ethersproject/bytes"); + var typedjson_1 = require("typedjson"); + var NamedArg = /** @class */ (function () { + function NamedArg(name, value) { + this.name = name; + this.value = value; + } + NamedArg.prototype.toBytes = function () { + var name = byterepr_1.toBytesString(this.name); + var value = this.value.toBytes(); + return bytes_1.concat([name, value]); + }; + NamedArg.fromBytes = function (bytes) { + var nameRes = CLValue_1.StringValue.fromBytes(bytes); + if (nameRes.hasError()) { + return CLValue_1.Result.Err(nameRes.error); + } + var clValueRes = CLValue_1.CLValue.fromBytes(nameRes.remainder()); + if (clValueRes.hasError()) { + return CLValue_1.Result.Err(clValueRes.error); + } + return CLValue_1.Result.Ok(new NamedArg(nameRes.value().val, clValueRes.value()), clValueRes.remainder()); + }; + return NamedArg; + }()); + exports.NamedArg = NamedArg; + var desRA = function (_arr) { + var clValueSerializer = new typedjson_1.TypedJSON(CLValue_1.CLValue); + return new Map(Array.from(_arr, function (_a) { + var key = _a[0], value = _a[1]; + return [key, clValueSerializer.parse(value)]; + })); + }; + var serRA = function (map) { + var clValueSerializer = new typedjson_1.TypedJSON(CLValue_1.CLValue); + return Array.from(map, function (_a) { + var key = _a[0], value = _a[1]; + return [ + key, + clValueSerializer.toPlainJson(value) + ]; + }); + }; + var RuntimeArgs = /** @class */ (function () { + function RuntimeArgs(args) { + this.args = args; + } + RuntimeArgs_1 = RuntimeArgs; + RuntimeArgs.fromMap = function (args) { + var map = new Map(Object.keys(args).map(function (k) { return [k, args[k]]; })); + return new RuntimeArgs_1(map); + }; + RuntimeArgs.fromNamedArgs = function (namedArgs) { + var args = namedArgs.reduce(function (pre, cur) { + pre[cur.name] = cur.value; + return pre; + }, {}); + return RuntimeArgs_1.fromMap(args); + }; + RuntimeArgs.prototype.insert = function (key, value) { + this.args.set(key, value); + }; + RuntimeArgs.prototype.toBytes = function () { + var vec = Array.from(this.args.entries()).map(function (a) { + return new NamedArg(a[0], a[1]); + }); + return byterepr_1.toBytesVecT(vec); + }; + RuntimeArgs.fromBytes = function (bytes) { + var sizeRes = CLValue_1.U32.fromBytes(bytes); + if (sizeRes.hasError()) { + return CLValue_1.Result.Err(sizeRes.error); + } + var size = sizeRes.value().val.toNumber(); + var remainBytes = sizeRes.remainder(); + var res = []; + for (var i = 0; i < size; i++) { + var namedArgRes = NamedArg.fromBytes(remainBytes); + if (namedArgRes.hasError()) { + return CLValue_1.Result.Err(namedArgRes.error); + } + res.push(namedArgRes.value()); + remainBytes = namedArgRes.remainder(); + } + return CLValue_1.Result.Ok(RuntimeArgs_1.fromNamedArgs(res), remainBytes); + }; + var RuntimeArgs_1; + __decorate([ + typedjson_1.jsonMember({ + serializer: serRA, + deserializer: desRA + }), + __metadata("design:type", Map) + ], RuntimeArgs.prototype, "args", void 0); + RuntimeArgs = RuntimeArgs_1 = __decorate([ + typedjson_1.jsonObject(), + __metadata("design:paramtypes", [Map]) + ], RuntimeArgs); + return RuntimeArgs; + }()); + exports.RuntimeArgs = RuntimeArgs; + + },{"./CLValue":182,"./byterepr":193,"@ethersproject/bytes":6,"typedjson":166}],190:[function(require,module,exports){ + (function (Buffer){(function (){ + "use strict"; + /** + * Functions to convert data to the FFI + * @packageDocumentation + */ + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Args = exports.UInt64Arg = exports.PublicKeyArg = exports.ByteSequenceArg = exports.ByteArrayArg = void 0; + /** + * Help function to serialize size + * + * @param size + * @constructor + */ + var Size = function (size) { + var buffer = Buffer.alloc(4); + buffer.writeInt32LE(size, 0); + return buffer; + }; + /** + * `Array[Byte]` serializes as follows: + * 1) your array of bytes + * + * So for `[1,2,3,4,5,6]` it serializes to`[1, 2, 3, 4, 5, 6]` + * + * @param bytes + */ + exports.ByteArrayArg = function (bytes) { + return Buffer.from(bytes); + }; + /** + * Serialize ByteArray + * + * `Seq[Byte]` serializes as follows: + * 1) length of the array as 4 bytes + * 2) your array of bytes + * + * So for `[1,2,3,4,5,6]` it serializes to`[6, 0, 0, 0, 1, 2, 3, 4, 5, 6]` + */ + exports.ByteSequenceArg = function (bytes) { + return Buffer.concat([Size(bytes.length), bytes].map(Buffer.from)); + }; + /** + * Serialize public key + * + * A public key is the same as array but it's expected to be 32 bytes long exactly. + * It's `[u8; 32]` (32 element byte array) but serializes to `(32.toBytes() ++ array.toBytes())` + * We serialize 32(literally, number 32) to 4 bytes instead of 1 byte, little endianness. + * This is how`111..11` public key looks like when serialized: + * [32, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + */ + exports.PublicKeyArg = exports.ByteArrayArg; + /** + * Serialize UINT64 + * + * @param value + */ + exports.UInt64Arg = function (value) { + var u64Buffer = Buffer.alloc(8); + u64Buffer.writeBigUInt64LE(value, 0); + return u64Buffer; + }; + /** + * Combine multiple arguments. + * + * so, what you want to send is`Vec(PublicKey, u64)`: + * • `PublicKey` serializes to`byte array of the key`, + * • `u64` serializes to`8 byte array`, + * + * so, what we have is(for example): + * `Vec([32, 0, 0, 0, {public key bytes}], [1, 2, 3, 4, 0, 0, 0, 0])` + * + * Which gives us: + * `[2, 0, 0, 0` - for the number of elements in the external vector + * `32, 0, 0, 0, 1, 1, …` - public key + * `8, 0, 0, 0, ` - for the number of bytes in the second element of the vector. + * That was serialized `u64` (`[1, 2, 3, 4, 0, 0, 0, 0]`) + * `1, 2, 3, 4, 0, 0, 0, 0]` + */ + function Args() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var arrays = [Size(args.length)].concat(args.map(exports.ByteSequenceArg)); + return Buffer.concat(arrays.map(Buffer.from)); + } + exports.Args = Args; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266}],191:[function(require,module,exports){ + "use strict"; + /** + * Provide methods to communicate with [CasperLabs Signer Extension](https://github.com/CasperLabs/signer). + * Works only on browser. + * + * @packageDocumentation + */ + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.signTestDeploy = exports.getToSignMessageID = exports.createTestAccount = exports.createNewVault = exports.resetExistingVault = exports.hasCreatedVault = exports.forceDisconnect = exports.forceConnection = exports.disconnectFromSite = exports.sign = exports.getActivePublicKey = exports.getSelectedPublicKeyBase64 = exports.sendConnectionRequest = exports.isConnected = exports.getVersion = void 0; + /** + * Returns Signer version + */ + exports.getVersion = function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, window.casperlabsHelper.getVersion()]; + case 1: return [2 /*return*/, _b.sent()]; + case 2: + _a = _b.sent(); + return [2 /*return*/, "<1.0.0"]; + case 3: return [2 /*return*/]; + } + }); + }); }; + /** + * Check whether CasperLabs Signer extension is connected + */ + exports.isConnected = function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, window.casperlabsHelper.isConnected()]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); }; + /** + * Attempt connection to Signer + */ + exports.sendConnectionRequest = function () { + return window.casperlabsHelper.requestConnection(); + }; + /** + * Return base64 encoded public key of user current selected account. + * + * @throws Error if haven't connected to CasperLabs Signer browser extension. + */ + exports.getSelectedPublicKeyBase64 = function () { + return window.casperlabsHelper.getSelectedPublicKeyBase64(); + }; + /** + * Retrieve the active public key. + * + * @returns {string} Hex-encoded public key with algorithm prefix. + */ + exports.getActivePublicKey = function () { + return window.casperlabsHelper.getActivePublicKey(); + }; + /** + * Send Deploy in JSON format message to Signer plugin to sign. + * + * @param deploy deploy in JSON format + * @param sourcePublicKeyHex public key in hex format with algorithm prefix. Used to sign the deploy + * @param targetPublicKeyHex public key in hex format with algorithm prefix. Used to display hex-formatted address on the UI + * + * @throws Error if haven't connected to CasperLabs Signer browser extension. + * @throws Error if sourcePublicKeyHex is not the same as the key that Signer used to sign the message + * @throws Error if targetPublicKeyHex is not the same as the key that is used as target in deploy. + */ + exports.sign = function (deploy, sourcePublicKey, targetPublicKey) { + return window.casperlabsHelper.sign(deploy, sourcePublicKey, targetPublicKey); + }; + /* + * Forces Signer to disconnect from the currently open site. + */ + exports.disconnectFromSite = function () { + return window.casperlabsHelper.disconnectFromSite(); + }; + exports.forceConnection = function () { + return window.signerTestingHelper.forceConnection(); + }; + exports.forceDisconnect = function () { + return window.signerTestingHelper.forceDisconnect(); + }; + exports.hasCreatedVault = function () { + return window.signerTestingHelper.hasCreatedVault(); + }; + exports.resetExistingVault = function () { + return window.signerTestingHelper.resetExistingVault(); + }; + exports.createNewVault = function (password) { + return window.signerTestingHelper.createNewVault(password); + }; + exports.createTestAccount = function (name, privateKey) { + return window.signerTestingHelper.createTestAccount(name, privateKey); + }; + exports.getToSignMessageID = function () { + return window.signerTestingHelper.getToSignMessageID(); + }; + exports.signTestDeploy = function (msgId) { + return window.signerTestingHelper.signTestDeploy(msgId); + }; + + },{}],192:[function(require,module,exports){ + "use strict"; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.StoredValue = exports.ContractMetadataJson = exports.EraInfoJson = exports.SeigniorageAllocation = exports.DeployInfoJson = exports.TransferJson = void 0; + var typedjson_1 = require("typedjson"); + var CLValue_1 = require("./CLValue"); + var NamedKey = /** @class */ (function () { + function NamedKey() { + } + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], NamedKey.prototype, "name", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], NamedKey.prototype, "key", void 0); + NamedKey = __decorate([ + typedjson_1.jsonObject + ], NamedKey); + return NamedKey; + }()); + var AssociatedKey = /** @class */ (function () { + function AssociatedKey() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'account_hash', constructor: String }), + __metadata("design:type", String) + ], AssociatedKey.prototype, "accountHash", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: Number }), + __metadata("design:type", Number) + ], AssociatedKey.prototype, "weight", void 0); + AssociatedKey = __decorate([ + typedjson_1.jsonObject + ], AssociatedKey); + return AssociatedKey; + }()); + var ActionThresholds = /** @class */ (function () { + function ActionThresholds() { + } + __decorate([ + typedjson_1.jsonMember({ constructor: Number }), + __metadata("design:type", Number) + ], ActionThresholds.prototype, "deployment", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'key_management', constructor: Number }), + __metadata("design:type", Number) + ], ActionThresholds.prototype, "keyManagement", void 0); + ActionThresholds = __decorate([ + typedjson_1.jsonObject + ], ActionThresholds); + return ActionThresholds; + }()); + /** + * Structure representing a user's account, stored in global state. + */ + var AccountJson = /** @class */ (function () { + function AccountJson() { + } + AccountJson.prototype.accountHash = function () { + return this._accountHash; + }; + __decorate([ + typedjson_1.jsonMember({ name: 'account_hash', constructor: String }), + __metadata("design:type", String) + ], AccountJson.prototype, "_accountHash", void 0); + __decorate([ + typedjson_1.jsonArrayMember(NamedKey, { name: 'named_keys' }), + __metadata("design:type", Array) + ], AccountJson.prototype, "namedKeys", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'main_purse', constructor: String }), + __metadata("design:type", String) + ], AccountJson.prototype, "mainPurse", void 0); + __decorate([ + typedjson_1.jsonArrayMember(AssociatedKey, { name: 'associated_keys' }), + __metadata("design:type", Array) + ], AccountJson.prototype, "associatedKeys", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'action_thresholds', constructor: ActionThresholds }), + __metadata("design:type", ActionThresholds) + ], AccountJson.prototype, "actionThresholds", void 0); + AccountJson = __decorate([ + typedjson_1.jsonObject + ], AccountJson); + return AccountJson; + }()); + var TransferJson = /** @class */ (function () { + function TransferJson() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'deploy_hash', constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "deployHash", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "from", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "source", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "target", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "amount", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], TransferJson.prototype, "gas", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String, preserveNull: true }), + __metadata("design:type", Object) + ], TransferJson.prototype, "id", void 0); + TransferJson = __decorate([ + typedjson_1.jsonObject + ], TransferJson); + return TransferJson; + }()); + exports.TransferJson = TransferJson; + var DeployInfoJson = /** @class */ (function () { + function DeployInfoJson() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'deploy_hash', constructor: String }), + __metadata("design:type", String) + ], DeployInfoJson.prototype, "deployHash", void 0); + __decorate([ + typedjson_1.jsonArrayMember(String), + __metadata("design:type", Array) + ], DeployInfoJson.prototype, "transfers", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], DeployInfoJson.prototype, "from", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], DeployInfoJson.prototype, "source", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], DeployInfoJson.prototype, "gas", void 0); + DeployInfoJson = __decorate([ + typedjson_1.jsonObject + ], DeployInfoJson); + return DeployInfoJson; + }()); + exports.DeployInfoJson = DeployInfoJson; + /** + * Info about a seigniorage allocation for a validator + */ + var Validator = /** @class */ (function () { + function Validator() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'validator_public_key', constructor: String }), + __metadata("design:type", String) + ], Validator.prototype, "validatorPublicKey", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], Validator.prototype, "amount", void 0); + Validator = __decorate([ + typedjson_1.jsonObject + ], Validator); + return Validator; + }()); + /** + * Info about a seigniorage allocation for a delegator + */ + var Delegator = /** @class */ (function () { + function Delegator() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'delegator_public_key', constructor: String }), + __metadata("design:type", String) + ], Delegator.prototype, "delegatorPublicKey", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'validator_public_key', constructor: String }), + __metadata("design:type", String) + ], Delegator.prototype, "validatorPublicKey", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], Delegator.prototype, "amount", void 0); + Delegator = __decorate([ + typedjson_1.jsonObject + ], Delegator); + return Delegator; + }()); + /** + * Information about a seigniorage allocation + */ + var SeigniorageAllocation = /** @class */ (function () { + function SeigniorageAllocation() { + } + __decorate([ + typedjson_1.jsonMember({ constructor: Validator }), + __metadata("design:type", Validator) + ], SeigniorageAllocation.prototype, "Validator", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: Delegator }), + __metadata("design:type", Delegator) + ], SeigniorageAllocation.prototype, "Delegator", void 0); + SeigniorageAllocation = __decorate([ + typedjson_1.jsonObject + ], SeigniorageAllocation); + return SeigniorageAllocation; + }()); + exports.SeigniorageAllocation = SeigniorageAllocation; + /** + * Auction metadata. Intended to be recorded at each era. + */ + var EraInfoJson = /** @class */ (function () { + function EraInfoJson() { + } + __decorate([ + typedjson_1.jsonArrayMember(SeigniorageAllocation, { name: 'seigniorage_allocations' }), + __metadata("design:type", Array) + ], EraInfoJson.prototype, "seigniorageAllocations", void 0); + EraInfoJson = __decorate([ + typedjson_1.jsonObject + ], EraInfoJson); + return EraInfoJson; + }()); + exports.EraInfoJson = EraInfoJson; + /** + * Contract metadata. + */ + var ContractMetadataJson = /** @class */ (function () { + function ContractMetadataJson() { + } + __decorate([ + typedjson_1.jsonMember({ name: 'contract_package_hash', constructor: String }), + __metadata("design:type", String) + ], ContractMetadataJson.prototype, "contractPackageHash", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'contract_wasm_hash', constructor: String }), + __metadata("design:type", String) + ], ContractMetadataJson.prototype, "contractWasmHash", void 0); + __decorate([ + typedjson_1.jsonMember({ name: 'protocol_version', constructor: String }), + __metadata("design:type", String) + ], ContractMetadataJson.prototype, "protocolVersion", void 0); + ContractMetadataJson = __decorate([ + typedjson_1.jsonObject + ], ContractMetadataJson); + return ContractMetadataJson; + }()); + exports.ContractMetadataJson = ContractMetadataJson; + var StoredValue = /** @class */ (function () { + function StoredValue() { + } + __decorate([ + typedjson_1.jsonMember({ constructor: CLValue_1.CLValue }), + __metadata("design:type", CLValue_1.CLValue) + ], StoredValue.prototype, "CLValue", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: AccountJson }), + __metadata("design:type", AccountJson) + ], StoredValue.prototype, "Account", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], StoredValue.prototype, "ContractWASM", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: ContractMetadataJson }), + __metadata("design:type", ContractMetadataJson) + ], StoredValue.prototype, "Contract", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: String }), + __metadata("design:type", String) + ], StoredValue.prototype, "ContractPackage", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: TransferJson }), + __metadata("design:type", TransferJson) + ], StoredValue.prototype, "Transfer", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: DeployInfoJson }), + __metadata("design:type", DeployInfoJson) + ], StoredValue.prototype, "DeployInfo", void 0); + __decorate([ + typedjson_1.jsonMember({ constructor: EraInfoJson }), + __metadata("design:type", EraInfoJson) + ], StoredValue.prototype, "EraInfo", void 0); + StoredValue = __decorate([ + typedjson_1.jsonObject + ], StoredValue); + return StoredValue; + }()); + exports.StoredValue = StoredValue; + + },{"./CLValue":182,"typedjson":166}],193:[function(require,module,exports){ + (function (Buffer){(function (){ + // migrate from casper-types/bytesrepr.rs + // https://github.com/CasperLabs/casper-node/blob/4b9f01463845120f6c428a08e108da67b448abb1/types/src/bytesrepr.rs + 'use strict'; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.toBytesStringList = exports.toBytesVecT = exports.toBytesBytesArray = exports.toBytesArrayU8 = exports.toBytesString = exports.toBytesU512 = exports.toBytesDeployHash = exports.toBytesU256 = exports.toBytesU128 = exports.toBytesI64 = exports.toBytesU64 = exports.toBytesU32 = exports.toBytesI32 = exports.toBytesU8 = exports.toBytesNumber = void 0; + var bignumber_1 = require("@ethersproject/bignumber"); + var constants_1 = require("@ethersproject/constants"); + var bytes_1 = require("@ethersproject/bytes"); + var CLValue_1 = require("./CLValue"); + /** + * Convert number to bytes + */ + exports.toBytesNumber = function (bitSize, signed, value) { + var v = bignumber_1.BigNumber.from(value); + // Check bounds are safe for encoding + var maxUintValue = constants_1.MaxUint256.mask(bitSize); + if (signed) { + var bounds = maxUintValue.mask(bitSize - 1); // 1 bit for signed + if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { + throw new Error('value out-of-bounds, value: ' + value); + } + } + else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(bitSize))) { + throw new Error('value out-of-bounds, value: ' + value); + } + v = v.toTwos(bitSize).mask(bitSize); + var bytes = bytes_1.arrayify(v); + if (v.gte(0)) { + // for positive number, we had to deal with paddings + if (bitSize > 64) { + // for u128, u256, u512, we have to and append extra byte for length + return bytes_1.concat([bytes, Uint8Array.from([bytes.length])]).reverse(); + } + else { + // for other types, we have to add padding 0s + var byteLength = bitSize / 8; + return bytes_1.concat([ + bytes.reverse(), + new Uint8Array(byteLength - bytes.length) + ]); + } + } + else { + return bytes.reverse(); + } + }; + /** + * Converts `u8` to little endian. + */ + function toBytesU8(u8) { + return exports.toBytesNumber(8, false, u8); + } + exports.toBytesU8 = toBytesU8; + /** + * Converts `i32` to little endian. + */ + function toBytesI32(i32) { + return exports.toBytesNumber(32, true, i32); + } + exports.toBytesI32 = toBytesI32; + /** + * Converts `u32` to little endian. + */ + function toBytesU32(u32) { + return exports.toBytesNumber(32, false, u32); + } + exports.toBytesU32 = toBytesU32; + /** + * Converts `u64` to little endian. + */ + function toBytesU64(u64) { + return exports.toBytesNumber(64, false, u64); + } + exports.toBytesU64 = toBytesU64; + /** + * Converts `i64` to little endian. + */ + function toBytesI64(i64) { + return exports.toBytesNumber(64, true, i64); + } + exports.toBytesI64 = toBytesI64; + /** + * Converts `u128` to little endian. + */ + function toBytesU128(u128) { + return exports.toBytesNumber(128, false, u128); + } + exports.toBytesU128 = toBytesU128; + /** + * Converts `u256` to little endian. + */ + function toBytesU256(u256) { + return exports.toBytesNumber(256, false, u256); + } + exports.toBytesU256 = toBytesU256; + function toBytesDeployHash(deployHash) { + return toBytesBytesArray(deployHash); + } + exports.toBytesDeployHash = toBytesDeployHash; + /** + * Converts `u512` to little endian. + */ + function toBytesU512(u512) { + return exports.toBytesNumber(512, false, u512); + } + exports.toBytesU512 = toBytesU512; + /** + * Serializes a string into an array of bytes. + */ + function toBytesString(str) { + var arr = Uint8Array.from(Buffer.from(str)); + return bytes_1.concat([toBytesU32(arr.byteLength), arr]); + } + exports.toBytesString = toBytesString; + /** + * Serializes an array of u8, equal to Vec in rust. + */ + function toBytesArrayU8(arr) { + return bytes_1.concat([toBytesU32(arr.length), arr]); + } + exports.toBytesArrayU8 = toBytesArrayU8; + /** + * Serializes an byteArray, equal to [u8;n] in rust. + */ + function toBytesBytesArray(arr) { + return arr; + } + exports.toBytesBytesArray = toBytesBytesArray; + /** + * Serializes a vector of values of type `T` into an array of bytes. + */ + function toBytesVecT(vec) { + var valueByteList = vec.map(function (e) { return e.toBytes(); }); + valueByteList.splice(0, 0, toBytesU32(vec.length)); + return bytes_1.concat(valueByteList); + } + exports.toBytesVecT = toBytesVecT; + /** + * Serializes a list of strings into an array of bytes. + */ + function toBytesStringList(arr) { + return toBytesVecT(arr.map(function (e) { return CLValue_1.CLValue.string(e); })); + } + exports.toBytesStringList = toBytesStringList; + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./CLValue":182,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"@ethersproject/constants":10,"buffer":266}],194:[function(require,module,exports){ + "use strict"; + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }); + var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Signer = exports.DeployUtil = exports.Serialization = exports.Keys = exports.Contracts = void 0; + var Contracts = __importStar(require("./Contracts")); + exports.Contracts = Contracts; + var DeployUtil = __importStar(require("./DeployUtil")); + exports.DeployUtil = DeployUtil; + var Keys = __importStar(require("./Keys")); + exports.Keys = Keys; + var Serialization = __importStar(require("./Serialization")); + exports.Serialization = Serialization; + var Signer = __importStar(require("./Signer")); + exports.Signer = Signer; + __exportStar(require("./CLValue"), exports); + __exportStar(require("./RuntimeArgs"), exports); + __exportStar(require("./CasperClient"), exports); + __exportStar(require("./option"), exports); + + },{"./CLValue":182,"./CasperClient":183,"./Contracts":185,"./DeployUtil":187,"./Keys":188,"./RuntimeArgs":189,"./Serialization":190,"./Signer":191,"./option":195}],195:[function(require,module,exports){ + "use strict"; + var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Option = void 0; + // copy from https://github.com/CasperLabs/casper-node/blob/master/smart_contracts/contract_as/assembly/option.ts + var CLValue_1 = require("./CLValue"); + var bytes_1 = require("@ethersproject/bytes"); + var OPTION_TAG_NONE = 0; + var OPTION_TAG_SOME = 1; + // TODO: explore Option (without interfaces to constrain T with, is it practical?) + /** + * A class representing an optional value, i.e. it might contain either a value of some type or + * no value at all. Similar to Rust's `Option` or Haskell's `Maybe`. + */ + var Option = /** @class */ (function (_super) { + __extends(Option, _super); + /** + * Constructs a new option containing the value of `CLTypedAndToBytes`. `t` can be `null`, which + * indicates no value. + */ + function Option(t, innerType) { + var _this = _super.call(this) || this; + _this.t = t; + if (t === null) { + if (!innerType) { + throw new Error('You had to assign innerType for None'); + } + _this.innerType = innerType; + } + else { + _this.innerType = t.clType(); + } + return _this; + } + /** + * Checks whether the `Option` contains no value. + * + * @returns True if the `Option` has no value. + */ + Option.prototype.isNone = function () { + return this.t === null; + }; + /** + * Checks whether the `Option` contains a value. + * + * @returns True if the `Option` has some value. + */ + Option.prototype.isSome = function () { + return this.t !== null; + }; + /** + * Extract value. + * + * @returns CLValue if the `Option` has some value. + */ + Option.prototype.getSome = function () { + if (!this.isSome()) { + throw new Error('Value is None'); + } + return CLValue_1.CLValue.fromT(this.t); + }; + /** + * Serializes the `Option` into an array of bytes. + */ + Option.prototype.toBytes = function () { + if (this.t === null) { + return Uint8Array.from([OPTION_TAG_NONE]); + } + return bytes_1.concat([Uint8Array.from([OPTION_TAG_SOME]), this.t.toBytes()]); + }; + Option.prototype.clType = function () { + return CLValue_1.CLTypeHelper.option(this.innerType); + }; + Option.fromBytes = function (type, bytes) { + var u8Res = CLValue_1.U8.fromBytes(bytes); + if (u8Res.hasError()) { + return CLValue_1.Result.Err(u8Res.error); + } + var optionTag = u8Res.value().val.toNumber(); + if (optionTag === OPTION_TAG_NONE) { + return CLValue_1.Result.Ok(new Option(null, type.innerType), u8Res.remainder()); + } + else if (optionTag === OPTION_TAG_SOME) { + var innerValueRes = CLValue_1.fromBytesByCLType(type.innerType, u8Res.remainder()); + if (innerValueRes.hasError()) { + return CLValue_1.Result.Err(innerValueRes.error); + } + return CLValue_1.Result.Ok(new Option(innerValueRes.value(), type.innerType), innerValueRes.remainder()); + } + else { + return CLValue_1.Result.Err(CLValue_1.FromBytesError.FormattingError); + } + }; + return Option; + }(CLValue_1.CLTypedAndToBytes)); + exports.Option = Option; + + },{"./CLValue":182,"@ethersproject/bytes":6}],196:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.BalanceServiceByJsonRPC = void 0; + var BalanceServiceByJsonRPC = /** @class */ (function () { + function BalanceServiceByJsonRPC(casperService) { + this.casperService = casperService; + this.balanceUrefs = new Map(); + } + /** + * Query balance for the specified account + * + * It will cache balance URef values for accounts so that on subsequent queries, + * it only takes 1 state query not 4 to get the value. + * @param blockHashBase16 + * @param publicKey + */ + BalanceServiceByJsonRPC.prototype.getAccountBalance = function (blockHashBase16, publicKey) { + return __awaiter(this, void 0, void 0, function () { + var stateRootHash, balanceUref, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 5, , 6]); + return [4 /*yield*/, this.casperService.getStateRootHash(blockHashBase16)]; + case 1: + stateRootHash = _a.sent(); + balanceUref = this.balanceUrefs.get(publicKey.toAccountHex()); + if (!!balanceUref) return [3 /*break*/, 3]; + return [4 /*yield*/, this.casperService.getAccountBalanceUrefByPublicKey(stateRootHash, publicKey)]; + case 2: + balanceUref = _a.sent(); + if (balanceUref) { + this.balanceUrefs.set(publicKey.toAccountHex(), balanceUref); + } + _a.label = 3; + case 3: + if (!balanceUref) { + return [2 /*return*/, undefined]; + } + return [4 /*yield*/, this.casperService.getAccountBalance(stateRootHash, balanceUref)]; + case 4: return [2 /*return*/, _a.sent()]; + case 5: + e_1 = _a.sent(); + return [2 /*return*/, undefined]; + case 6: return [2 /*return*/]; + } + }); + }); + }; + return BalanceServiceByJsonRPC; + }()); + exports.BalanceServiceByJsonRPC = BalanceServiceByJsonRPC; + + },{}],197:[function(require,module,exports){ + "use strict"; + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.CasperServiceByJsonRPC = void 0; + var client_js_1 = require("@open-rpc/client-js"); + var __1 = require(".."); + var DeployUtil_1 = require("../lib/DeployUtil"); + var typedjson_1 = require("typedjson"); + var StoredValue_1 = require("../lib/StoredValue"); + var bignumber_1 = require("@ethersproject/bignumber"); + var CasperServiceByJsonRPC = /** @class */ (function () { + function CasperServiceByJsonRPC(url) { + var transport = new client_js_1.HTTPTransport(url); + var requestManager = new client_js_1.RequestManager([transport]); + this.client = new client_js_1.Client(requestManager); + } + /** + * Get information about a single deploy by hash. + * + * @param deployHashBase16 + */ + CasperServiceByJsonRPC.prototype.getDeployInfo = function (deployHashBase16) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'info_get_deploy', + params: { + deploy_hash: deployHashBase16 + } + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getBlockInfo = function (blockHashBase16) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'chain_get_block', + params: { + block_identifier: { + Hash: blockHashBase16 + } + } + }).then(function (res) { + if (res.block !== null && res.block.hash !== blockHashBase16) { + throw new Error("Returned block does not have a matching hash."); + } + return res; + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getBlockInfoByHeight = function (height) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'chain_get_block', + params: { + block_identifier: { + Height: height + } + } + }).then(function (res) { + if (res.block !== null && res.block.header.height !== height) { + throw new Error("Returned block does not have a matching height."); + } + return res; + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getLatestBlockInfo = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'chain_get_block' + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getPeers = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'info_get_peers' + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getStatus = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'info_get_status' + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getValidatorsInfo = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'state_get_auction_info' + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + /** + * Get the reference to the balance so we can cache it. + */ + CasperServiceByJsonRPC.prototype.getAccountBalanceUrefByPublicKeyHash = function (stateRootHash, accountHash) { + return __awaiter(this, void 0, void 0, function () { + var account; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.getBlockState(stateRootHash, 'account-hash-' + accountHash, []).then(function (res) { return res.Account; })]; + case 1: + account = _a.sent(); + return [2 /*return*/, account.mainPurse]; + } + }); + }); + }; + /** + * Get the reference to the balance so we can cache it. + */ + CasperServiceByJsonRPC.prototype.getAccountBalanceUrefByPublicKey = function (stateRootHash, publicKey) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, this.getAccountBalanceUrefByPublicKeyHash(stateRootHash, __1.encodeBase16(publicKey.toAccountHash()))]; + }); + }); + }; + CasperServiceByJsonRPC.prototype.getAccountBalance = function (stateRootHash, balanceUref) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client + .request({ + method: 'state_get_balance', + params: { + state_root_hash: stateRootHash, + purse_uref: balanceUref + } + }) + .then(function (res) { return bignumber_1.BigNumber.from(res.balance_value); })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.getStateRootHash = function (blockHashBase16) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client + .request({ + method: 'chain_get_state_root_hash', + params: { + block_hash: blockHashBase16 + } + }) + .then(function (res) { return res.state_root_hash; })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + /** + * get global state item + * @param stateRootHash + * @param key + * @param path + */ + CasperServiceByJsonRPC.prototype.getBlockState = function (stateRootHash, key, path) { + return __awaiter(this, void 0, void 0, function () { + var res, storedValueJson, serializer, storedValue; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.client.request({ + method: 'state_get_item', + params: { + state_root_hash: stateRootHash, + key: key, + path: path + } + })]; + case 1: + res = _a.sent(); + if (res.error) { + return [2 /*return*/, res]; + } + else { + storedValueJson = res.stored_value; + serializer = new typedjson_1.TypedJSON(StoredValue_1.StoredValue); + storedValue = serializer.parse(storedValueJson); + return [2 /*return*/, storedValue]; + } + return [2 /*return*/]; + } + }); + }); + }; + CasperServiceByJsonRPC.prototype.deploy = function (signedDeploy) { + return __awaiter(this, void 0, void 0, function () { + var oneMegaByte, size; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + oneMegaByte = 1048576; + size = __1.DeployUtil.deploySizeInBytes(signedDeploy); + if (size > oneMegaByte) { + throw Error("Deploy can not be send, because it's too large: " + size + " bytes. " + + "Max size is 1 megabyte."); + } + return [4 /*yield*/, this.client.request({ + method: 'account_put_deploy', + params: DeployUtil_1.deployToJson(signedDeploy) + })]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); + }); + }; + return CasperServiceByJsonRPC; + }()); + exports.CasperServiceByJsonRPC = CasperServiceByJsonRPC; + + },{"..":181,"../lib/DeployUtil":187,"../lib/StoredValue":192,"@ethersproject/bignumber":4,"@open-rpc/client-js":18,"typedjson":166}],198:[function(require,module,exports){ + "use strict"; + var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + __exportStar(require("./CasperServiceByJsonRPC"), exports); + __exportStar(require("./BalanceServiceByJsonRPC"), exports); + + },{"./BalanceServiceByJsonRPC":196,"./CasperServiceByJsonRPC":197}],199:[function(require,module,exports){ + + },{}],200:[function(require,module,exports){ + arguments[4][26][0].apply(exports,arguments) + },{"./asn1/api":201,"./asn1/base":203,"./asn1/constants":207,"./asn1/decoders":209,"./asn1/encoders":212,"bn.js":214,"dup":26}],201:[function(require,module,exports){ + arguments[4][27][0].apply(exports,arguments) + },{"./decoders":209,"./encoders":212,"dup":27,"inherits":335}],202:[function(require,module,exports){ + arguments[4][28][0].apply(exports,arguments) + },{"../base/reporter":205,"dup":28,"inherits":335,"safer-buffer":365}],203:[function(require,module,exports){ + arguments[4][29][0].apply(exports,arguments) + },{"./buffer":202,"./node":204,"./reporter":205,"dup":29}],204:[function(require,module,exports){ + arguments[4][30][0].apply(exports,arguments) + },{"../base/buffer":202,"../base/reporter":205,"dup":30,"minimalistic-assert":339}],205:[function(require,module,exports){ + arguments[4][31][0].apply(exports,arguments) + },{"dup":31,"inherits":335}],206:[function(require,module,exports){ + arguments[4][32][0].apply(exports,arguments) + },{"dup":32}],207:[function(require,module,exports){ + arguments[4][33][0].apply(exports,arguments) + },{"./der":206,"dup":33}],208:[function(require,module,exports){ + arguments[4][34][0].apply(exports,arguments) + },{"../base/buffer":202,"../base/node":204,"../constants/der":206,"bn.js":214,"dup":34,"inherits":335}],209:[function(require,module,exports){ + arguments[4][35][0].apply(exports,arguments) + },{"./der":208,"./pem":210,"dup":35}],210:[function(require,module,exports){ + arguments[4][36][0].apply(exports,arguments) + },{"./der":208,"dup":36,"inherits":335,"safer-buffer":365}],211:[function(require,module,exports){ + arguments[4][37][0].apply(exports,arguments) + },{"../base/node":204,"../constants/der":206,"dup":37,"inherits":335,"safer-buffer":365}],212:[function(require,module,exports){ + arguments[4][38][0].apply(exports,arguments) + },{"./der":211,"./pem":213,"dup":38}],213:[function(require,module,exports){ + arguments[4][39][0].apply(exports,arguments) + },{"./der":211,"dup":39,"inherits":335}],214:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],215:[function(require,module,exports){ + (function (global){(function (){ + 'use strict'; + + var objectAssign = require('object-assign'); + + // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js + // original notice: + + /*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + function compare(a, b) { + if (a === b) { + return 0; + } + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; + } + function isBuffer(b) { + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { + return global.Buffer.isBuffer(b); + } + return !!(b != null && b._isBuffer); + } + + // based on node assert, original notice: + // NB: The URL to the CommonJS spec is kept just for tradition. + // node-assert has evolved a lot since then, both in API and behavior. + + // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 + // + // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! + // + // Originally from narwhal.js (http://narwhaljs.org) + // Copyright (c) 2009 Thomas Robinson <280north.com> + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the 'Software'), to + // deal in the Software without restriction, including without limitation the + // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + // sell copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in + // all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + var util = require('util/'); + var hasOwn = Object.prototype.hasOwnProperty; + var pSlice = Array.prototype.slice; + var functionsHaveNames = (function () { + return function foo() {}.name === 'foo'; + }()); + function pToString (obj) { + return Object.prototype.toString.call(obj); + } + function isView(arrbuf) { + if (isBuffer(arrbuf)) { + return false; + } + if (typeof global.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; + } + // 1. The assert module provides functions that throw + // AssertionError's when particular conditions are not met. The + // assert module must conform to the following interface. + + var assert = module.exports = ok; + + // 2. The AssertionError is defined in assert. + // new assert.AssertionError({ message: message, + // actual: actual, + // expected: expected }) + + var regex = /\s*function\s+([^\(\s]*)\s*/; + // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js + function getName(func) { + if (!util.isFunction(func)) { + return; + } + if (functionsHaveNames) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; + } + assert.AssertionError = function AssertionError(options) { + this.name = 'AssertionError'; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + if (options.message) { + this.message = options.message; + this.generatedMessage = false; + } else { + this.message = getMessage(this); + this.generatedMessage = true; + } + var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } else { + // non v8 browsers so we can have a stacktrace + var err = new Error(); + if (err.stack) { + var out = err.stack; + + // try to strip useless frames + var fn_name = getName(stackStartFunction); + var idx = out.indexOf('\n' + fn_name); + if (idx >= 0) { + // once we have located the function frame + // we need to strip out everything before it (and its line) + var next_line = out.indexOf('\n', idx + 1); + out = out.substring(next_line + 1); + } + + this.stack = out; + } + } + }; + + // assert.AssertionError instanceof Error + util.inherits(assert.AssertionError, Error); + + function truncate(s, n) { + if (typeof s === 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } + } + function inspect(something) { + if (functionsHaveNames || !util.isFunction(something)) { + return util.inspect(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; + } + function getMessage(self) { + return truncate(inspect(self.actual), 128) + ' ' + + self.operator + ' ' + + truncate(inspect(self.expected), 128); + } + + // At present only the three keys mentioned above are used and + // understood by the spec. Implementations or sub modules can pass + // other keys to the AssertionError's constructor - they will be + // ignored. + + // 3. All of the following functions must throw an AssertionError + // when a corresponding condition is not met, with a message that + // may be undefined if not provided. All assertion methods provide + // both the actual and expected values to the assertion error for + // display purposes. + + function fail(actual, expected, message, operator, stackStartFunction) { + throw new assert.AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); + } + + // EXTENSION! allows for well behaved errors defined elsewhere. + assert.fail = fail; + + // 4. Pure assertion tests whether a value is truthy, as determined + // by !!guard. + // assert.ok(guard, message_opt); + // This statement is equivalent to assert.equal(true, !!guard, + // message_opt);. To test strictly for the value true, use + // assert.strictEqual(true, guard, message_opt);. + + function ok(value, message) { + if (!value) fail(value, true, message, '==', assert.ok); + } + assert.ok = ok; + + // 5. The equality assertion tests shallow, coercive equality with + // ==. + // assert.equal(actual, expected, message_opt); + + assert.equal = function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', assert.equal); + }; + + // 6. The non-equality assertion tests for whether two objects are not equal + // with != assert.notEqual(actual, expected, message_opt); + + assert.notEqual = function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', assert.notEqual); + } + }; + + // 7. The equivalence assertion tests a deep equality relation. + // assert.deepEqual(actual, expected, message_opt); + + assert.deepEqual = function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'deepEqual', assert.deepEqual); + } + }; + + assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); + } + }; + + function _deepEqual(actual, expected, strict, memos) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (isBuffer(actual) && isBuffer(expected)) { + return compare(actual, expected) === 0; + + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (util.isDate(actual) && util.isDate(expected)) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (util.isRegExp(actual) && util.isRegExp(expected)) { + return actual.source === expected.source && + actual.global === expected.global && + actual.multiline === expected.multiline && + actual.lastIndex === expected.lastIndex && + actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ((actual === null || typeof actual !== 'object') && + (expected === null || typeof expected !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), + new Uint8Array(expected.buffer)) === 0; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else if (isBuffer(actual) !== isBuffer(expected)) { + return false; + } else { + memos = memos || {actual: [], expected: []}; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); + } + } + + function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; + } + + function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) + return false; + // if one is a primitive, the other must be same + if (util.isPrimitive(a) || util.isPrimitive(b)) + return a === b; + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) + return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b, strict); + } + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length !== kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] !== kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; + } + return true; + } + + // 8. The non-equivalence assertion tests for any deep inequality. + // assert.notDeepEqual(actual, expected, message_opt); + + assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); + } + }; + + assert.notDeepStrictEqual = notDeepStrictEqual; + function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } + } + + + // 9. The strict equality assertion tests strict equality, as determined by ===. + // assert.strictEqual(actual, expected, message_opt); + + assert.strictEqual = function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', assert.strictEqual); + } + }; + + // 10. The strict non-equality assertion tests for strict inequality, as + // determined by !==. assert.notStrictEqual(actual, expected, message_opt); + + assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', assert.notStrictEqual); + } + }; + + function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (Object.prototype.toString.call(expected) == '[object RegExp]') { + return expected.test(actual); + } + + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; + } + + function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; + } + + function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + actual = _tryBlock(block); + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail(actual, expected, 'Missing expected exception' + message); + } + + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && util.isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if ((isUnwantedException && + userProvidedMessage && + expectedException(actual, expected)) || + isUnexpectedException) { + fail(actual, expected, 'Got unwanted exception' + message); + } + + if ((shouldThrow && actual && expected && + !expectedException(actual, expected)) || (!shouldThrow && actual)) { + throw actual; + } + } + + // 11. Expected to throw an error: + // assert.throws(block, Error_opt, message_opt); + + assert.throws = function(block, /*optional*/error, /*optional*/message) { + _throws(true, block, error, message); + }; + + // EXTENSION! This is annoying to write outside this module. + assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); + }; + + assert.ifError = function(err) { if (err) throw err; }; + + // Expose a strict only variant of assert + function strict(value, message) { + if (!value) fail(value, true, message, '==', strict); + } + assert.strict = objectAssign(strict, assert, { + equal: assert.strictEqual, + deepEqual: assert.deepStrictEqual, + notEqual: assert.notStrictEqual, + notDeepEqual: assert.notDeepStrictEqual + }); + assert.strict.strict = assert.strict; + + var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + if (hasOwn.call(obj, key)) keys.push(key); + } + return keys; + }; + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"object-assign":341,"util/":218}],216:[function(require,module,exports){ + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; + } else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } + + },{}],217:[function(require,module,exports){ + module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; + } + },{}],218:[function(require,module,exports){ + (function (process,global){(function (){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var formatRegExp = /%[sdj%]/g; + exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; + }; + + + // Mark that a method should not be used. + // Returns a modified function which warns once by default. + // If --no-deprecation is set, then it is a no-op. + exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; + }; + + + var debugs = {}; + var debugEnviron; + exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; + }; + + + /** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ + /* legacy: obj, showHidden, depth, colors*/ + function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); + } + exports.inspect = inspect; + + + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics + inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] + }; + + // Don't use 'blue' not visible on cmd.exe + inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' + }; + + + function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } + } + + + function stylizeNoColor(str, styleType) { + return str; + } + + + function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; + } + + + function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); + } + + + function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); + } + + + function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; + } + + + function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; + } + + + function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; + } + + + function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; + } + + + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { + return Array.isArray(ar); + } + exports.isArray = isArray; + + function isBoolean(arg) { + return typeof arg === 'boolean'; + } + exports.isBoolean = isBoolean; + + function isNull(arg) { + return arg === null; + } + exports.isNull = isNull; + + function isNullOrUndefined(arg) { + return arg == null; + } + exports.isNullOrUndefined = isNullOrUndefined; + + function isNumber(arg) { + return typeof arg === 'number'; + } + exports.isNumber = isNumber; + + function isString(arg) { + return typeof arg === 'string'; + } + exports.isString = isString; + + function isSymbol(arg) { + return typeof arg === 'symbol'; + } + exports.isSymbol = isSymbol; + + function isUndefined(arg) { + return arg === void 0; + } + exports.isUndefined = isUndefined; + + function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; + } + exports.isRegExp = isRegExp; + + function isObject(arg) { + return typeof arg === 'object' && arg !== null; + } + exports.isObject = isObject; + + function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; + } + exports.isDate = isDate; + + function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); + } + exports.isError = isError; + + function isFunction(arg) { + return typeof arg === 'function'; + } + exports.isFunction = isFunction; + + function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; + } + exports.isPrimitive = isPrimitive; + + exports.isBuffer = require('./support/isBuffer'); + + function objectToString(o) { + return Object.prototype.toString.call(o); + } + + + function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); + } + + + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + + // 26 Feb 16:19:34 + function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); + } + + + // log is just a thin wrapper to console.log that prepends a timestamp + exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); + }; + + + /** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ + exports.inherits = require('inherits'); + + exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; + }; + + function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"./support/isBuffer":217,"_process":353,"inherits":216}],219:[function(require,module,exports){ + 'use strict' + + exports.byteLength = byteLength + exports.toByteArray = toByteArray + exports.fromByteArray = fromByteArray + + var lookup = [] + var revLookup = [] + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i + } + + // Support decoding URL-safe base64 strings, as Node.js does. + // See: https://en.wikipedia.org/wiki/Base64#URL_applications + revLookup['-'.charCodeAt(0)] = 62 + revLookup['_'.charCodeAt(0)] = 63 + + function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] + } + + // base64 is 4/3 + up to two characters of the original data + function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen + } + + function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen + } + + function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr + } + + function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] + } + + function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') + } + + function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') + } + + },{}],220:[function(require,module,exports){ + (function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } + + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; + + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } + } + + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + // 24-bits chunks + var off = 0; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } + + this._strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; + + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + this._strip(); + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } + + BN.prototype._move = function _move (dest) { + move(dest, this); + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } + + function inspect () { + return (this.red ? ''; + } + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; + + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); + + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; + + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position < res.length) { + res[position++] = carry; + + while (position < res.length) { + res[position++] = 0; + } + } + }; + + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; + } + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] >>> wbit) & 0x01; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this._strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this._strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this._strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this._strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this._strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this._strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out._strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out._strip(); + } + + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out._strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this._strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this._strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this._strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this._strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this._strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this._strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return isNegNum ? -acc : acc; + }; + + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + this._strip(); + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this._strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; + })(typeof module === 'undefined' || module, this); + + },{"buffer":222}],221:[function(require,module,exports){ + arguments[4][46][0].apply(exports,arguments) + },{"crypto":222,"dup":46}],222:[function(require,module,exports){ + arguments[4][199][0].apply(exports,arguments) + },{"dup":199}],223:[function(require,module,exports){ + // based on the aes implimentation in triple sec + // https://github.com/keybase/triplesec + // which is in turn based on the one from crypto-js + // https://code.google.com/p/crypto-js/ + + var Buffer = require('safe-buffer').Buffer + + function asUInt32Array (buf) { + if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) + + var len = (buf.length / 4) | 0 + var out = new Array(len) + + for (var i = 0; i < len; i++) { + out[i] = buf.readUInt32BE(i * 4) + } + + return out + } + + function scrubVec (v) { + for (var i = 0; i < v.length; v++) { + v[i] = 0 + } + } + + function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) { + var SUB_MIX0 = SUB_MIX[0] + var SUB_MIX1 = SUB_MIX[1] + var SUB_MIX2 = SUB_MIX[2] + var SUB_MIX3 = SUB_MIX[3] + + var s0 = M[0] ^ keySchedule[0] + var s1 = M[1] ^ keySchedule[1] + var s2 = M[2] ^ keySchedule[2] + var s3 = M[3] ^ keySchedule[3] + var t0, t1, t2, t3 + var ksRow = 4 + + for (var round = 1; round < nRounds; round++) { + t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++] + t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++] + t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++] + t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++] + s0 = t0 + s1 = t1 + s2 = t2 + s3 = t3 + } + + t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] + t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] + t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] + t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] + t0 = t0 >>> 0 + t1 = t1 >>> 0 + t2 = t2 >>> 0 + t3 = t3 >>> 0 + + return [t0, t1, t2, t3] + } + + // AES constants + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] + var G = (function () { + // Compute double table + var d = new Array(256) + for (var j = 0; j < 256; j++) { + if (j < 128) { + d[j] = j << 1 + } else { + d[j] = (j << 1) ^ 0x11b + } + } + + var SBOX = [] + var INV_SBOX = [] + var SUB_MIX = [[], [], [], []] + var INV_SUB_MIX = [[], [], [], []] + + // Walk GF(2^8) + var x = 0 + var xi = 0 + for (var i = 0; i < 256; ++i) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 + SBOX[x] = sx + INV_SBOX[sx] = x + + // Compute multiplication + var x2 = d[x] + var x4 = d[x2] + var x8 = d[x4] + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100) + SUB_MIX[0][x] = (t << 24) | (t >>> 8) + SUB_MIX[1][x] = (t << 16) | (t >>> 16) + SUB_MIX[2][x] = (t << 8) | (t >>> 24) + SUB_MIX[3][x] = t + + // Compute inv sub bytes, inv mix columns tables + t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) + INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) + INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) + INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) + INV_SUB_MIX[3][sx] = t + + if (x === 0) { + x = xi = 1 + } else { + x = x2 ^ d[d[d[x8 ^ x2]]] + xi ^= d[d[xi]] + } + } + + return { + SBOX: SBOX, + INV_SBOX: INV_SBOX, + SUB_MIX: SUB_MIX, + INV_SUB_MIX: INV_SUB_MIX + } + })() + + function AES (key) { + this._key = asUInt32Array(key) + this._reset() + } + + AES.blockSize = 4 * 4 + AES.keySize = 256 / 8 + AES.prototype.blockSize = AES.blockSize + AES.prototype.keySize = AES.keySize + AES.prototype._reset = function () { + var keyWords = this._key + var keySize = keyWords.length + var nRounds = keySize + 6 + var ksRows = (nRounds + 1) * 4 + + var keySchedule = [] + for (var k = 0; k < keySize; k++) { + keySchedule[k] = keyWords[k] + } + + for (k = keySize; k < ksRows; k++) { + var t = keySchedule[k - 1] + + if (k % keySize === 0) { + t = (t << 8) | (t >>> 24) + t = + (G.SBOX[t >>> 24] << 24) | + (G.SBOX[(t >>> 16) & 0xff] << 16) | + (G.SBOX[(t >>> 8) & 0xff] << 8) | + (G.SBOX[t & 0xff]) + + t ^= RCON[(k / keySize) | 0] << 24 + } else if (keySize > 6 && k % keySize === 4) { + t = + (G.SBOX[t >>> 24] << 24) | + (G.SBOX[(t >>> 16) & 0xff] << 16) | + (G.SBOX[(t >>> 8) & 0xff] << 8) | + (G.SBOX[t & 0xff]) + } + + keySchedule[k] = keySchedule[k - keySize] ^ t + } + + var invKeySchedule = [] + for (var ik = 0; ik < ksRows; ik++) { + var ksR = ksRows - ik + var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)] + + if (ik < 4 || ksR <= 4) { + invKeySchedule[ik] = tt + } else { + invKeySchedule[ik] = + G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ + G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^ + G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^ + G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]] + } + } + + this._nRounds = nRounds + this._keySchedule = keySchedule + this._invKeySchedule = invKeySchedule + } + + AES.prototype.encryptBlockRaw = function (M) { + M = asUInt32Array(M) + return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds) + } + + AES.prototype.encryptBlock = function (M) { + var out = this.encryptBlockRaw(M) + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0], 0) + buf.writeUInt32BE(out[1], 4) + buf.writeUInt32BE(out[2], 8) + buf.writeUInt32BE(out[3], 12) + return buf + } + + AES.prototype.decryptBlock = function (M) { + M = asUInt32Array(M) + + // swap + var m1 = M[1] + M[1] = M[3] + M[3] = m1 + + var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds) + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0], 0) + buf.writeUInt32BE(out[3], 4) + buf.writeUInt32BE(out[2], 8) + buf.writeUInt32BE(out[1], 12) + return buf + } + + AES.prototype.scrub = function () { + scrubVec(this._keySchedule) + scrubVec(this._invKeySchedule) + scrubVec(this._key) + } + + module.exports.AES = AES + + },{"safe-buffer":364}],224:[function(require,module,exports){ + var aes = require('./aes') + var Buffer = require('safe-buffer').Buffer + var Transform = require('cipher-base') + var inherits = require('inherits') + var GHASH = require('./ghash') + var xor = require('buffer-xor') + var incr32 = require('./incr32') + + function xorTest (a, b) { + var out = 0 + if (a.length !== b.length) out++ + + var len = Math.min(a.length, b.length) + for (var i = 0; i < len; ++i) { + out += (a[i] ^ b[i]) + } + + return out + } + + function calcIv (self, iv, ck) { + if (iv.length === 12) { + self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]) + return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]) + } + var ghash = new GHASH(ck) + var len = iv.length + var toPad = len % 16 + ghash.update(iv) + if (toPad) { + toPad = 16 - toPad + ghash.update(Buffer.alloc(toPad, 0)) + } + ghash.update(Buffer.alloc(8, 0)) + var ivBits = len * 8 + var tail = Buffer.alloc(8) + tail.writeUIntBE(ivBits, 0, 8) + ghash.update(tail) + self._finID = ghash.state + var out = Buffer.from(self._finID) + incr32(out) + return out + } + function StreamCipher (mode, key, iv, decrypt) { + Transform.call(this) + + var h = Buffer.alloc(4, 0) + + this._cipher = new aes.AES(key) + var ck = this._cipher.encryptBlock(h) + this._ghash = new GHASH(ck) + iv = calcIv(this, iv, ck) + + this._prev = Buffer.from(iv) + this._cache = Buffer.allocUnsafe(0) + this._secCache = Buffer.allocUnsafe(0) + this._decrypt = decrypt + this._alen = 0 + this._len = 0 + this._mode = mode + + this._authTag = null + this._called = false + } + + inherits(StreamCipher, Transform) + + StreamCipher.prototype._update = function (chunk) { + if (!this._called && this._alen) { + var rump = 16 - (this._alen % 16) + if (rump < 16) { + rump = Buffer.alloc(rump, 0) + this._ghash.update(rump) + } + } + + this._called = true + var out = this._mode.encrypt(this, chunk) + if (this._decrypt) { + this._ghash.update(chunk) + } else { + this._ghash.update(out) + } + this._len += chunk.length + return out + } + + StreamCipher.prototype._final = function () { + if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data') + + var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID)) + if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data') + + this._authTag = tag + this._cipher.scrub() + } + + StreamCipher.prototype.getAuthTag = function getAuthTag () { + if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state') + + return this._authTag + } + + StreamCipher.prototype.setAuthTag = function setAuthTag (tag) { + if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state') + + this._authTag = tag + } + + StreamCipher.prototype.setAAD = function setAAD (buf) { + if (this._called) throw new Error('Attempting to set AAD in unsupported state') + + this._ghash.update(buf) + this._alen += buf.length + } + + module.exports = StreamCipher + + },{"./aes":223,"./ghash":228,"./incr32":229,"buffer-xor":265,"cipher-base":267,"inherits":335,"safe-buffer":364}],225:[function(require,module,exports){ + var ciphers = require('./encrypter') + var deciphers = require('./decrypter') + var modes = require('./modes/list.json') + + function getCiphers () { + return Object.keys(modes) + } + + exports.createCipher = exports.Cipher = ciphers.createCipher + exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv + exports.createDecipher = exports.Decipher = deciphers.createDecipher + exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv + exports.listCiphers = exports.getCiphers = getCiphers + + },{"./decrypter":226,"./encrypter":227,"./modes/list.json":237}],226:[function(require,module,exports){ + var AuthCipher = require('./authCipher') + var Buffer = require('safe-buffer').Buffer + var MODES = require('./modes') + var StreamCipher = require('./streamCipher') + var Transform = require('cipher-base') + var aes = require('./aes') + var ebtk = require('evp_bytestokey') + var inherits = require('inherits') + + function Decipher (mode, key, iv) { + Transform.call(this) + + this._cache = new Splitter() + this._last = void 0 + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._mode = mode + this._autopadding = true + } + + inherits(Decipher, Transform) + + Decipher.prototype._update = function (data) { + this._cache.add(data) + var chunk + var thing + var out = [] + while ((chunk = this._cache.get(this._autopadding))) { + thing = this._mode.decrypt(this, chunk) + out.push(thing) + } + return Buffer.concat(out) + } + + Decipher.prototype._final = function () { + var chunk = this._cache.flush() + if (this._autopadding) { + return unpad(this._mode.decrypt(this, chunk)) + } else if (chunk) { + throw new Error('data not multiple of block length') + } + } + + Decipher.prototype.setAutoPadding = function (setTo) { + this._autopadding = !!setTo + return this + } + + function Splitter () { + this.cache = Buffer.allocUnsafe(0) + } + + Splitter.prototype.add = function (data) { + this.cache = Buffer.concat([this.cache, data]) + } + + Splitter.prototype.get = function (autoPadding) { + var out + if (autoPadding) { + if (this.cache.length > 16) { + out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + } else { + if (this.cache.length >= 16) { + out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + } + + return null + } + + Splitter.prototype.flush = function () { + if (this.cache.length) return this.cache + } + + function unpad (last) { + var padded = last[15] + if (padded < 1 || padded > 16) { + throw new Error('unable to decrypt data') + } + var i = -1 + while (++i < padded) { + if (last[(i + (16 - padded))] !== padded) { + throw new Error('unable to decrypt data') + } + } + if (padded === 16) return + + return last.slice(0, 16 - padded) + } + + function createDecipheriv (suite, password, iv) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + if (typeof iv === 'string') iv = Buffer.from(iv) + if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) + + if (typeof password === 'string') password = Buffer.from(password) + if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) + + if (config.type === 'stream') { + return new StreamCipher(config.module, password, iv, true) + } else if (config.type === 'auth') { + return new AuthCipher(config.module, password, iv, true) + } + + return new Decipher(config.module, password, iv) + } + + function createDecipher (suite, password) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + var keys = ebtk(password, false, config.key, config.iv) + return createDecipheriv(suite, keys.key, keys.iv) + } + + exports.createDecipher = createDecipher + exports.createDecipheriv = createDecipheriv + + },{"./aes":223,"./authCipher":224,"./modes":236,"./streamCipher":239,"cipher-base":267,"evp_bytestokey":304,"inherits":335,"safe-buffer":364}],227:[function(require,module,exports){ + var MODES = require('./modes') + var AuthCipher = require('./authCipher') + var Buffer = require('safe-buffer').Buffer + var StreamCipher = require('./streamCipher') + var Transform = require('cipher-base') + var aes = require('./aes') + var ebtk = require('evp_bytestokey') + var inherits = require('inherits') + + function Cipher (mode, key, iv) { + Transform.call(this) + + this._cache = new Splitter() + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._mode = mode + this._autopadding = true + } + + inherits(Cipher, Transform) + + Cipher.prototype._update = function (data) { + this._cache.add(data) + var chunk + var thing + var out = [] + + while ((chunk = this._cache.get())) { + thing = this._mode.encrypt(this, chunk) + out.push(thing) + } + + return Buffer.concat(out) + } + + var PADDING = Buffer.alloc(16, 0x10) + + Cipher.prototype._final = function () { + var chunk = this._cache.flush() + if (this._autopadding) { + chunk = this._mode.encrypt(this, chunk) + this._cipher.scrub() + return chunk + } + + if (!chunk.equals(PADDING)) { + this._cipher.scrub() + throw new Error('data not multiple of block length') + } + } + + Cipher.prototype.setAutoPadding = function (setTo) { + this._autopadding = !!setTo + return this + } + + function Splitter () { + this.cache = Buffer.allocUnsafe(0) + } + + Splitter.prototype.add = function (data) { + this.cache = Buffer.concat([this.cache, data]) + } + + Splitter.prototype.get = function () { + if (this.cache.length > 15) { + var out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + return null + } + + Splitter.prototype.flush = function () { + var len = 16 - this.cache.length + var padBuff = Buffer.allocUnsafe(len) + + var i = -1 + while (++i < len) { + padBuff.writeUInt8(len, i) + } + + return Buffer.concat([this.cache, padBuff]) + } + + function createCipheriv (suite, password, iv) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + if (typeof password === 'string') password = Buffer.from(password) + if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) + + if (typeof iv === 'string') iv = Buffer.from(iv) + if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) + + if (config.type === 'stream') { + return new StreamCipher(config.module, password, iv) + } else if (config.type === 'auth') { + return new AuthCipher(config.module, password, iv) + } + + return new Cipher(config.module, password, iv) + } + + function createCipher (suite, password) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + var keys = ebtk(password, false, config.key, config.iv) + return createCipheriv(suite, keys.key, keys.iv) + } + + exports.createCipheriv = createCipheriv + exports.createCipher = createCipher + + },{"./aes":223,"./authCipher":224,"./modes":236,"./streamCipher":239,"cipher-base":267,"evp_bytestokey":304,"inherits":335,"safe-buffer":364}],228:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + var ZEROES = Buffer.alloc(16, 0) + + function toArray (buf) { + return [ + buf.readUInt32BE(0), + buf.readUInt32BE(4), + buf.readUInt32BE(8), + buf.readUInt32BE(12) + ] + } + + function fromArray (out) { + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0] >>> 0, 0) + buf.writeUInt32BE(out[1] >>> 0, 4) + buf.writeUInt32BE(out[2] >>> 0, 8) + buf.writeUInt32BE(out[3] >>> 0, 12) + return buf + } + + function GHASH (key) { + this.h = key + this.state = Buffer.alloc(16, 0) + this.cache = Buffer.allocUnsafe(0) + } + + // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html + // by Juho Vähä-Herttua + GHASH.prototype.ghash = function (block) { + var i = -1 + while (++i < block.length) { + this.state[i] ^= block[i] + } + this._multiply() + } + + GHASH.prototype._multiply = function () { + var Vi = toArray(this.h) + var Zi = [0, 0, 0, 0] + var j, xi, lsbVi + var i = -1 + while (++i < 128) { + xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0 + if (xi) { + // Z_i+1 = Z_i ^ V_i + Zi[0] ^= Vi[0] + Zi[1] ^= Vi[1] + Zi[2] ^= Vi[2] + Zi[3] ^= Vi[3] + } + + // Store the value of LSB(V_i) + lsbVi = (Vi[3] & 1) !== 0 + + // V_i+1 = V_i >> 1 + for (j = 3; j > 0; j--) { + Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31) + } + Vi[0] = Vi[0] >>> 1 + + // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R + if (lsbVi) { + Vi[0] = Vi[0] ^ (0xe1 << 24) + } + } + this.state = fromArray(Zi) + } + + GHASH.prototype.update = function (buf) { + this.cache = Buffer.concat([this.cache, buf]) + var chunk + while (this.cache.length >= 16) { + chunk = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + this.ghash(chunk) + } + } + + GHASH.prototype.final = function (abl, bl) { + if (this.cache.length) { + this.ghash(Buffer.concat([this.cache, ZEROES], 16)) + } + + this.ghash(fromArray([0, abl, 0, bl])) + return this.state + } + + module.exports = GHASH + + },{"safe-buffer":364}],229:[function(require,module,exports){ + function incr32 (iv) { + var len = iv.length + var item + while (len--) { + item = iv.readUInt8(len) + if (item === 255) { + iv.writeUInt8(0, len) + } else { + item++ + iv.writeUInt8(item, len) + break + } + } + } + module.exports = incr32 + + },{}],230:[function(require,module,exports){ + var xor = require('buffer-xor') + + exports.encrypt = function (self, block) { + var data = xor(block, self._prev) + + self._prev = self._cipher.encryptBlock(data) + return self._prev + } + + exports.decrypt = function (self, block) { + var pad = self._prev + + self._prev = block + var out = self._cipher.decryptBlock(block) + + return xor(out, pad) + } + + },{"buffer-xor":265}],231:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + var xor = require('buffer-xor') + + function encryptStart (self, data, decrypt) { + var len = data.length + var out = xor(data, self._cache) + self._cache = self._cache.slice(len) + self._prev = Buffer.concat([self._prev, decrypt ? data : out]) + return out + } + + exports.encrypt = function (self, data, decrypt) { + var out = Buffer.allocUnsafe(0) + var len + + while (data.length) { + if (self._cache.length === 0) { + self._cache = self._cipher.encryptBlock(self._prev) + self._prev = Buffer.allocUnsafe(0) + } + + if (self._cache.length <= data.length) { + len = self._cache.length + out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]) + data = data.slice(len) + } else { + out = Buffer.concat([out, encryptStart(self, data, decrypt)]) + break + } + } + + return out + } + + },{"buffer-xor":265,"safe-buffer":364}],232:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + + function encryptByte (self, byteParam, decrypt) { + var pad + var i = -1 + var len = 8 + var out = 0 + var bit, value + while (++i < len) { + pad = self._cipher.encryptBlock(self._prev) + bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0 + value = pad[0] ^ bit + out += ((value & 0x80) >> (i % 8)) + self._prev = shiftIn(self._prev, decrypt ? bit : value) + } + return out + } + + function shiftIn (buffer, value) { + var len = buffer.length + var i = -1 + var out = Buffer.allocUnsafe(buffer.length) + buffer = Buffer.concat([buffer, Buffer.from([value])]) + + while (++i < len) { + out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) + } + + return out + } + + exports.encrypt = function (self, chunk, decrypt) { + var len = chunk.length + var out = Buffer.allocUnsafe(len) + var i = -1 + + while (++i < len) { + out[i] = encryptByte(self, chunk[i], decrypt) + } + + return out + } + + },{"safe-buffer":364}],233:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + + function encryptByte (self, byteParam, decrypt) { + var pad = self._cipher.encryptBlock(self._prev) + var out = pad[0] ^ byteParam + + self._prev = Buffer.concat([ + self._prev.slice(1), + Buffer.from([decrypt ? byteParam : out]) + ]) + + return out + } + + exports.encrypt = function (self, chunk, decrypt) { + var len = chunk.length + var out = Buffer.allocUnsafe(len) + var i = -1 + + while (++i < len) { + out[i] = encryptByte(self, chunk[i], decrypt) + } + + return out + } + + },{"safe-buffer":364}],234:[function(require,module,exports){ + var xor = require('buffer-xor') + var Buffer = require('safe-buffer').Buffer + var incr32 = require('../incr32') + + function getBlock (self) { + var out = self._cipher.encryptBlockRaw(self._prev) + incr32(self._prev) + return out + } + + var blockSize = 16 + exports.encrypt = function (self, chunk) { + var chunkNum = Math.ceil(chunk.length / blockSize) + var start = self._cache.length + self._cache = Buffer.concat([ + self._cache, + Buffer.allocUnsafe(chunkNum * blockSize) + ]) + for (var i = 0; i < chunkNum; i++) { + var out = getBlock(self) + var offset = start + i * blockSize + self._cache.writeUInt32BE(out[0], offset + 0) + self._cache.writeUInt32BE(out[1], offset + 4) + self._cache.writeUInt32BE(out[2], offset + 8) + self._cache.writeUInt32BE(out[3], offset + 12) + } + var pad = self._cache.slice(0, chunk.length) + self._cache = self._cache.slice(chunk.length) + return xor(chunk, pad) + } + + },{"../incr32":229,"buffer-xor":265,"safe-buffer":364}],235:[function(require,module,exports){ + exports.encrypt = function (self, block) { + return self._cipher.encryptBlock(block) + } + + exports.decrypt = function (self, block) { + return self._cipher.decryptBlock(block) + } + + },{}],236:[function(require,module,exports){ + var modeModules = { + ECB: require('./ecb'), + CBC: require('./cbc'), + CFB: require('./cfb'), + CFB8: require('./cfb8'), + CFB1: require('./cfb1'), + OFB: require('./ofb'), + CTR: require('./ctr'), + GCM: require('./ctr') + } + + var modes = require('./list.json') + + for (var key in modes) { + modes[key].module = modeModules[modes[key].mode] + } + + module.exports = modes + + },{"./cbc":230,"./cfb":231,"./cfb1":232,"./cfb8":233,"./ctr":234,"./ecb":235,"./list.json":237,"./ofb":238}],237:[function(require,module,exports){ + module.exports={ + "aes-128-ecb": { + "cipher": "AES", + "key": 128, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-192-ecb": { + "cipher": "AES", + "key": 192, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-256-ecb": { + "cipher": "AES", + "key": 256, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-128-cbc": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-192-cbc": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-256-cbc": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes128": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes192": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes256": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-128-cfb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-192-cfb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-256-cfb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-128-cfb8": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-192-cfb8": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-256-cfb8": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-128-cfb1": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-192-cfb1": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-256-cfb1": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-128-ofb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-192-ofb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-256-ofb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-128-ctr": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-192-ctr": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-256-ctr": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-128-gcm": { + "cipher": "AES", + "key": 128, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-192-gcm": { + "cipher": "AES", + "key": 192, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-256-gcm": { + "cipher": "AES", + "key": 256, + "iv": 12, + "mode": "GCM", + "type": "auth" + } + } + + },{}],238:[function(require,module,exports){ + (function (Buffer){(function (){ + var xor = require('buffer-xor') + + function getBlock (self) { + self._prev = self._cipher.encryptBlock(self._prev) + return self._prev + } + + exports.encrypt = function (self, chunk) { + while (self._cache.length < chunk.length) { + self._cache = Buffer.concat([self._cache, getBlock(self)]) + } + + var pad = self._cache.slice(0, chunk.length) + self._cache = self._cache.slice(chunk.length) + return xor(chunk, pad) + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266,"buffer-xor":265}],239:[function(require,module,exports){ + var aes = require('./aes') + var Buffer = require('safe-buffer').Buffer + var Transform = require('cipher-base') + var inherits = require('inherits') + + function StreamCipher (mode, key, iv, decrypt) { + Transform.call(this) + + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._cache = Buffer.allocUnsafe(0) + this._secCache = Buffer.allocUnsafe(0) + this._decrypt = decrypt + this._mode = mode + } + + inherits(StreamCipher, Transform) + + StreamCipher.prototype._update = function (chunk) { + return this._mode.encrypt(this, chunk, this._decrypt) + } + + StreamCipher.prototype._final = function () { + this._cipher.scrub() + } + + module.exports = StreamCipher + + },{"./aes":223,"cipher-base":267,"inherits":335,"safe-buffer":364}],240:[function(require,module,exports){ + var DES = require('browserify-des') + var aes = require('browserify-aes/browser') + var aesModes = require('browserify-aes/modes') + var desModes = require('browserify-des/modes') + var ebtk = require('evp_bytestokey') + + function createCipher (suite, password) { + suite = suite.toLowerCase() + + var keyLen, ivLen + if (aesModes[suite]) { + keyLen = aesModes[suite].key + ivLen = aesModes[suite].iv + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8 + ivLen = desModes[suite].iv + } else { + throw new TypeError('invalid suite type') + } + + var keys = ebtk(password, false, keyLen, ivLen) + return createCipheriv(suite, keys.key, keys.iv) + } + + function createDecipher (suite, password) { + suite = suite.toLowerCase() + + var keyLen, ivLen + if (aesModes[suite]) { + keyLen = aesModes[suite].key + ivLen = aesModes[suite].iv + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8 + ivLen = desModes[suite].iv + } else { + throw new TypeError('invalid suite type') + } + + var keys = ebtk(password, false, keyLen, ivLen) + return createDecipheriv(suite, keys.key, keys.iv) + } + + function createCipheriv (suite, key, iv) { + suite = suite.toLowerCase() + if (aesModes[suite]) return aes.createCipheriv(suite, key, iv) + if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite }) + + throw new TypeError('invalid suite type') + } + + function createDecipheriv (suite, key, iv) { + suite = suite.toLowerCase() + if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv) + if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true }) + + throw new TypeError('invalid suite type') + } + + function getCiphers () { + return Object.keys(desModes).concat(aes.getCiphers()) + } + + exports.createCipher = exports.Cipher = createCipher + exports.createCipheriv = exports.Cipheriv = createCipheriv + exports.createDecipher = exports.Decipher = createDecipher + exports.createDecipheriv = exports.Decipheriv = createDecipheriv + exports.listCiphers = exports.getCiphers = getCiphers + + },{"browserify-aes/browser":225,"browserify-aes/modes":236,"browserify-des":241,"browserify-des/modes":242,"evp_bytestokey":304}],241:[function(require,module,exports){ + var CipherBase = require('cipher-base') + var des = require('des.js') + var inherits = require('inherits') + var Buffer = require('safe-buffer').Buffer + + var modes = { + 'des-ede3-cbc': des.CBC.instantiate(des.EDE), + 'des-ede3': des.EDE, + 'des-ede-cbc': des.CBC.instantiate(des.EDE), + 'des-ede': des.EDE, + 'des-cbc': des.CBC.instantiate(des.DES), + 'des-ecb': des.DES + } + modes.des = modes['des-cbc'] + modes.des3 = modes['des-ede3-cbc'] + module.exports = DES + inherits(DES, CipherBase) + function DES (opts) { + CipherBase.call(this) + var modeName = opts.mode.toLowerCase() + var mode = modes[modeName] + var type + if (opts.decrypt) { + type = 'decrypt' + } else { + type = 'encrypt' + } + var key = opts.key + if (!Buffer.isBuffer(key)) { + key = Buffer.from(key) + } + if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { + key = Buffer.concat([key, key.slice(0, 8)]) + } + var iv = opts.iv + if (!Buffer.isBuffer(iv)) { + iv = Buffer.from(iv) + } + this._des = mode.create({ + key: key, + iv: iv, + type: type + }) + } + DES.prototype._update = function (data) { + return Buffer.from(this._des.update(data)) + } + DES.prototype._final = function () { + return Buffer.from(this._des.final()) + } + + },{"cipher-base":267,"des.js":275,"inherits":335,"safe-buffer":364}],242:[function(require,module,exports){ + exports['des-ecb'] = { + key: 8, + iv: 0 + } + exports['des-cbc'] = exports.des = { + key: 8, + iv: 8 + } + exports['des-ede3-cbc'] = exports.des3 = { + key: 24, + iv: 8 + } + exports['des-ede3'] = { + key: 24, + iv: 0 + } + exports['des-ede-cbc'] = { + key: 16, + iv: 8 + } + exports['des-ede'] = { + key: 16, + iv: 0 + } + + },{}],243:[function(require,module,exports){ + (function (Buffer){(function (){ + var BN = require('bn.js') + var randomBytes = require('randombytes') + + function blind (priv) { + var r = getr(priv) + var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() + return { blinder: blinder, unblinder: r.invm(priv.modulus) } + } + + function getr (priv) { + var len = priv.modulus.byteLength() + var r + do { + r = new BN(randomBytes(len)) + } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) + return r + } + + function crt (msg, priv) { + var blinds = blind(priv) + var len = priv.modulus.byteLength() + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) + var c1 = blinded.toRed(BN.mont(priv.prime1)) + var c2 = blinded.toRed(BN.mont(priv.prime2)) + var qinv = priv.coefficient + var p = priv.prime1 + var q = priv.prime2 + var m1 = c1.redPow(priv.exponent1).fromRed() + var m2 = c2.redPow(priv.exponent2).fromRed() + var h = m1.isub(m2).imul(qinv).umod(p).imul(q) + return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) + } + crt.getr = getr + + module.exports = crt + + }).call(this)}).call(this,require("buffer").Buffer) + },{"bn.js":220,"buffer":266,"randombytes":361}],244:[function(require,module,exports){ + module.exports = require('./browser/algorithms.json') + + },{"./browser/algorithms.json":245}],245:[function(require,module,exports){ + module.exports={ + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } + } + + },{}],246:[function(require,module,exports){ + module.exports={ + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" + } + + },{}],247:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + var createHash = require('create-hash') + var stream = require('readable-stream') + var inherits = require('inherits') + var sign = require('./sign') + var verify = require('./verify') + + var algorithms = require('./algorithms.json') + Object.keys(algorithms).forEach(function (key) { + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') + algorithms[key.toLowerCase()] = algorithms[key] + }) + + function Sign (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hashType = data.hash + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign + } + inherits(Sign, stream.Writable) + + Sign.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() + } + + Sign.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this + } + + Sign.prototype.sign = function signMethod (key, enc) { + this.end() + var hash = this._hash.digest() + var sig = sign(hash, key, this._hashType, this._signType, this._tag) + + return enc ? sig.toString(enc) : sig + } + + function Verify (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign + } + inherits(Verify, stream.Writable) + + Verify.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() + } + + Verify.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this + } + + Verify.prototype.verify = function verifyMethod (key, sig, enc) { + if (typeof sig === 'string') sig = Buffer.from(sig, enc) + + this.end() + var hash = this._hash.digest() + return verify(sig, hash, key, this._signType, this._tag) + } + + function createSign (algorithm) { + return new Sign(algorithm) + } + + function createVerify (algorithm) { + return new Verify(algorithm) + } + + module.exports = { + Sign: createSign, + Verify: createVerify, + createSign: createSign, + createVerify: createVerify + } + + },{"./algorithms.json":245,"./sign":248,"./verify":249,"create-hash":270,"inherits":335,"readable-stream":264,"safe-buffer":364}],248:[function(require,module,exports){ + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js + var Buffer = require('safe-buffer').Buffer + var createHmac = require('create-hmac') + var crt = require('browserify-rsa') + var EC = require('elliptic').ec + var BN = require('bn.js') + var parseKeys = require('parse-asn1') + var curves = require('./curves.json') + + function sign (hash, key, hashType, signType, tag) { + var priv = parseKeys(key) + if (priv.curve) { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + return ecSign(hash, priv) + } else if (priv.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong private key type') + return dsaSign(hash, priv, hashType) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + } + hash = Buffer.concat([tag, hash]) + var len = priv.modulus.byteLength() + var pad = [0, 1] + while (hash.length + pad.length + 1 < len) pad.push(0xff) + pad.push(0x00) + var i = -1 + while (++i < hash.length) pad.push(hash[i]) + + var out = crt(pad, priv) + return out + } + + function ecSign (hash, priv) { + var curveId = curves[priv.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) + + var curve = new EC(curveId) + var key = curve.keyFromPrivate(priv.privateKey) + var out = key.sign(hash) + + return Buffer.from(out.toDER()) + } + + function dsaSign (hash, priv, algo) { + var x = priv.params.priv_key + var p = priv.params.p + var q = priv.params.q + var g = priv.params.g + var r = new BN(0) + var k + var H = bits2int(hash, q).mod(q) + var s = false + var kv = getKey(x, q, hash, algo) + while (s === false) { + k = makeKey(q, kv, algo) + r = makeR(g, k, p, q) + s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + if (s.cmpn(0) === 0) { + s = false + r = new BN(0) + } + } + return toDER(r, s) + } + + function toDER (r, s) { + r = r.toArray() + s = s.toArray() + + // Pad values + if (r[0] & 0x80) r = [0].concat(r) + if (s[0] & 0x80) s = [0].concat(s) + + var total = r.length + s.length + 4 + var res = [0x30, total, 0x02, r.length] + res = res.concat(r, [0x02, s.length], s) + return Buffer.from(res) + } + + function getKey (x, q, hash, algo) { + x = Buffer.from(x.toArray()) + if (x.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - x.length) + x = Buffer.concat([zeros, x]) + } + var hlen = hash.length + var hbits = bits2octets(hash, q) + var v = Buffer.alloc(hlen) + v.fill(1) + var k = Buffer.alloc(hlen) + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + return { k: k, v: v } + } + + function bits2int (obits, q) { + var bits = new BN(obits) + var shift = (obits.length << 3) - q.bitLength() + if (shift > 0) bits.ishrn(shift) + return bits + } + + function bits2octets (bits, q) { + bits = bits2int(bits, q) + bits = bits.mod(q) + var out = Buffer.from(bits.toArray()) + if (out.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - out.length) + out = Buffer.concat([zeros, out]) + } + return out + } + + function makeKey (q, kv, algo) { + var t + var k + + do { + t = Buffer.alloc(0) + + while (t.length * 8 < q.bitLength()) { + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + t = Buffer.concat([t, kv.v]) + } + + k = bits2int(t, q) + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + } while (k.cmp(q) !== -1) + + return k + } + + function makeR (g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) + } + + module.exports = sign + module.exports.getKey = getKey + module.exports.makeKey = makeKey + + },{"./curves.json":246,"bn.js":220,"browserify-rsa":243,"create-hmac":272,"elliptic":286,"parse-asn1":346,"safe-buffer":364}],249:[function(require,module,exports){ + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js + var Buffer = require('safe-buffer').Buffer + var BN = require('bn.js') + var EC = require('elliptic').ec + var parseKeys = require('parse-asn1') + var curves = require('./curves.json') + + function verify (sig, hash, key, signType, tag) { + var pub = parseKeys(key) + if (pub.type === 'ec') { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + return ecVerify(sig, hash, pub) + } else if (pub.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong public key type') + return dsaVerify(sig, hash, pub) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + } + hash = Buffer.concat([tag, hash]) + var len = pub.modulus.byteLength() + var pad = [1] + var padNum = 0 + while (hash.length + pad.length + 2 < len) { + pad.push(0xff) + padNum++ + } + pad.push(0x00) + var i = -1 + while (++i < hash.length) { + pad.push(hash[i]) + } + pad = Buffer.from(pad) + var red = BN.mont(pub.modulus) + sig = new BN(sig).toRed(red) + + sig = sig.redPow(new BN(pub.publicExponent)) + sig = Buffer.from(sig.fromRed().toArray()) + var out = padNum < 8 ? 1 : 0 + len = Math.min(sig.length, pad.length) + if (sig.length !== pad.length) out = 1 + + i = -1 + while (++i < len) out |= sig[i] ^ pad[i] + return out === 0 + } + + function ecVerify (sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + + var curve = new EC(curveId) + var pubkey = pub.data.subjectPrivateKey.data + + return curve.verify(hash, sig, pubkey) + } + + function dsaVerify (sig, hash, pub) { + var p = pub.data.p + var q = pub.data.q + var g = pub.data.g + var y = pub.data.pub_key + var unpacked = parseKeys.signature.decode(sig, 'der') + var s = unpacked.s + var r = unpacked.r + checkValue(s, q) + checkValue(r, q) + var montp = BN.mont(p) + var w = s.invm(q) + var v = g.toRed(montp) + .redPow(new BN(hash).mul(w).mod(q)) + .fromRed() + .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) + .mod(p) + .mod(q) + return v.cmp(r) === 0 + } + + function checkValue (b, q) { + if (b.cmpn(0) <= 0) throw new Error('invalid sig') + if (b.cmp(q) >= q) throw new Error('invalid sig') + } + + module.exports = verify + + },{"./curves.json":246,"bn.js":220,"elliptic":286,"parse-asn1":346,"safe-buffer":364}],250:[function(require,module,exports){ + arguments[4][106][0].apply(exports,arguments) + },{"dup":106}],251:[function(require,module,exports){ + arguments[4][107][0].apply(exports,arguments) + },{"./_stream_readable":253,"./_stream_writable":255,"_process":353,"dup":107,"inherits":335}],252:[function(require,module,exports){ + arguments[4][108][0].apply(exports,arguments) + },{"./_stream_transform":254,"dup":108,"inherits":335}],253:[function(require,module,exports){ + arguments[4][109][0].apply(exports,arguments) + },{"../errors":250,"./_stream_duplex":251,"./internal/streams/async_iterator":256,"./internal/streams/buffer_list":257,"./internal/streams/destroy":258,"./internal/streams/from":260,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],254:[function(require,module,exports){ + arguments[4][110][0].apply(exports,arguments) + },{"../errors":250,"./_stream_duplex":251,"dup":110,"inherits":335}],255:[function(require,module,exports){ + arguments[4][111][0].apply(exports,arguments) + },{"../errors":250,"./_stream_duplex":251,"./internal/streams/destroy":258,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],256:[function(require,module,exports){ + arguments[4][112][0].apply(exports,arguments) + },{"./end-of-stream":259,"_process":353,"dup":112}],257:[function(require,module,exports){ + arguments[4][113][0].apply(exports,arguments) + },{"buffer":266,"dup":113,"util":222}],258:[function(require,module,exports){ + arguments[4][114][0].apply(exports,arguments) + },{"_process":353,"dup":114}],259:[function(require,module,exports){ + arguments[4][115][0].apply(exports,arguments) + },{"../../../errors":250,"dup":115}],260:[function(require,module,exports){ + arguments[4][116][0].apply(exports,arguments) + },{"dup":116}],261:[function(require,module,exports){ + arguments[4][117][0].apply(exports,arguments) + },{"../../../errors":250,"./end-of-stream":259,"dup":117}],262:[function(require,module,exports){ + arguments[4][118][0].apply(exports,arguments) + },{"../../../errors":250,"dup":118}],263:[function(require,module,exports){ + arguments[4][119][0].apply(exports,arguments) + },{"dup":119,"events":303}],264:[function(require,module,exports){ + arguments[4][120][0].apply(exports,arguments) + },{"./lib/_stream_duplex.js":251,"./lib/_stream_passthrough.js":252,"./lib/_stream_readable.js":253,"./lib/_stream_transform.js":254,"./lib/_stream_writable.js":255,"./lib/internal/streams/end-of-stream.js":259,"./lib/internal/streams/pipeline.js":261,"dup":120}],265:[function(require,module,exports){ + (function (Buffer){(function (){ + module.exports = function xor (a, b) { + var length = Math.min(a.length, b.length) + var buffer = new Buffer(length) + + for (var i = 0; i < length; ++i) { + buffer[i] = a[i] ^ b[i] + } + + return buffer + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"buffer":266}],266:[function(require,module,exports){ + (function (Buffer){(function (){ + /*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + /* eslint-disable no-proto */ + + 'use strict' + + var base64 = require('base64-js') + var ieee754 = require('ieee754') + + exports.Buffer = Buffer + exports.SlowBuffer = SlowBuffer + exports.INSPECT_MAX_BYTES = 50 + + var K_MAX_LENGTH = 0x7fffffff + exports.kMaxLength = K_MAX_LENGTH + + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ + Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + + if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) + } + + function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } + } + + Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } + }) + + Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } + }) + + function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf + } + + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) + } + + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) + } + + Buffer.poolSize = 8192 // not used by this implementation + + function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) + } + + // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: + // https://github.com/feross/buffer/pull/148 + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + + function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + } + + function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) + } + + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) + } + + function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) + } + + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) + } + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) + } + + function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf + } + + function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf + } + + function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf + } + + function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } + } + + function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 + } + + function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) + } + + Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false + } + + Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + } + + Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } + } + + Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer + } + + function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } + } + Buffer.byteLength = byteLength + + function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } + } + + // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) + // to detect a Buffer instance. It's not possible to use `instanceof Buffer` + // reliably in a browserify context because there could be multiple different + // copies of the 'buffer' package in use. This method works even for Buffer + // instances that were created from another copy of the `buffer` package. + // See: https://github.com/feross/buffer/issues/154 + Buffer.prototype._isBuffer = true + + function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i + } + + Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this + } + + Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this + } + + Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this + } + + Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) + } + + Buffer.prototype.toLocaleString = Buffer.prototype.toString + + Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 + } + + Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' + } + + Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + } + + // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') + } + + function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 + } + + Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 + } + + Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) + } + + Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) + } + + function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i + } + + function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + } + + function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) + } + + function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) + } + + function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) + } + + function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + } + + Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } + } + + Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } + } + + function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } + } + + function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) + } + + // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + var MAX_ARGUMENTS_LENGTH = 0x1000 + + function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res + } + + function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret + } + + function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret + } + + function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out + } + + function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res + } + + Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf + } + + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') + } + + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val + } + + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val + } + + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] + } + + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) + } + + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] + } + + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) + } + + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) + } + + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) + } + + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) + } + + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) + } + + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) + } + + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) + } + + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) + } + + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) + } + + function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + } + + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 + } + + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 + } + + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 + } + + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 + } + + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 + } + + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 + } + + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 + } + + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 + } + + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 + } + + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 + } + + function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') + } + + function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 + } + + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) + } + + function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) + } + + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len + } + + // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this + } + + // HELPER FUNCTIONS + // ================ + + var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + + function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str + } + + function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) + } + + function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes + } + + function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray + } + + function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray + } + + function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) + } + + function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i + } + + // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass + // the `instanceof` check but they should be treated as of that type. + // See: https://github.com/feross/buffer/issues/166 + function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) + } + function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"base64-js":219,"buffer":266,"ieee754":334}],267:[function(require,module,exports){ + arguments[4][50][0].apply(exports,arguments) + },{"dup":50,"inherits":335,"safe-buffer":364,"stream":374,"string_decoder":389}],268:[function(require,module,exports){ + (function (Buffer){(function (){ + var elliptic = require('elliptic') + var BN = require('bn.js') + + module.exports = function createECDH (curve) { + return new ECDH(curve) + } + + var aliases = { + secp256k1: { + name: 'secp256k1', + byteLength: 32 + }, + secp224r1: { + name: 'p224', + byteLength: 28 + }, + prime256v1: { + name: 'p256', + byteLength: 32 + }, + prime192v1: { + name: 'p192', + byteLength: 24 + }, + ed25519: { + name: 'ed25519', + byteLength: 32 + }, + secp384r1: { + name: 'p384', + byteLength: 48 + }, + secp521r1: { + name: 'p521', + byteLength: 66 + } + } + + aliases.p224 = aliases.secp224r1 + aliases.p256 = aliases.secp256r1 = aliases.prime256v1 + aliases.p192 = aliases.secp192r1 = aliases.prime192v1 + aliases.p384 = aliases.secp384r1 + aliases.p521 = aliases.secp521r1 + + function ECDH (curve) { + this.curveType = aliases[curve] + if (!this.curveType) { + this.curveType = { + name: curve + } + } + this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap + this.keys = void 0 + } + + ECDH.prototype.generateKeys = function (enc, format) { + this.keys = this.curve.genKeyPair() + return this.getPublicKey(enc, format) + } + + ECDH.prototype.computeSecret = function (other, inenc, enc) { + inenc = inenc || 'utf8' + if (!Buffer.isBuffer(other)) { + other = new Buffer(other, inenc) + } + var otherPub = this.curve.keyFromPublic(other).getPublic() + var out = otherPub.mul(this.keys.getPrivate()).getX() + return formatReturnValue(out, enc, this.curveType.byteLength) + } + + ECDH.prototype.getPublicKey = function (enc, format) { + var key = this.keys.getPublic(format === 'compressed', true) + if (format === 'hybrid') { + if (key[key.length - 1] % 2) { + key[0] = 7 + } else { + key[0] = 6 + } + } + return formatReturnValue(key, enc) + } + + ECDH.prototype.getPrivateKey = function (enc) { + return formatReturnValue(this.keys.getPrivate(), enc) + } + + ECDH.prototype.setPublicKey = function (pub, enc) { + enc = enc || 'utf8' + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc) + } + this.keys._importPublic(pub) + return this + } + + ECDH.prototype.setPrivateKey = function (priv, enc) { + enc = enc || 'utf8' + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc) + } + + var _priv = new BN(priv) + _priv = _priv.toString(16) + this.keys = this.curve.genKeyPair() + this.keys._importPrivate(_priv) + return this + } + + function formatReturnValue (bn, enc, len) { + if (!Array.isArray(bn)) { + bn = bn.toArray() + } + var buf = new Buffer(bn) + if (len && buf.length < len) { + var zeros = new Buffer(len - buf.length) + zeros.fill(0) + buf = Buffer.concat([zeros, buf]) + } + if (!enc) { + return buf + } else { + return buf.toString(enc) + } + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"bn.js":269,"buffer":266,"elliptic":286}],269:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],270:[function(require,module,exports){ + arguments[4][51][0].apply(exports,arguments) + },{"cipher-base":267,"dup":51,"inherits":335,"md5.js":336,"ripemd160":363,"sha.js":367}],271:[function(require,module,exports){ + arguments[4][52][0].apply(exports,arguments) + },{"dup":52,"md5.js":336}],272:[function(require,module,exports){ + arguments[4][53][0].apply(exports,arguments) + },{"./legacy":273,"cipher-base":267,"create-hash/md5":271,"dup":53,"inherits":335,"ripemd160":363,"safe-buffer":364,"sha.js":367}],273:[function(require,module,exports){ + arguments[4][54][0].apply(exports,arguments) + },{"cipher-base":267,"dup":54,"inherits":335,"safe-buffer":364}],274:[function(require,module,exports){ + 'use strict' + + exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') + exports.createHash = exports.Hash = require('create-hash') + exports.createHmac = exports.Hmac = require('create-hmac') + + var algos = require('browserify-sign/algos') + var algoKeys = Object.keys(algos) + var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys) + exports.getHashes = function () { + return hashes + } + + var p = require('pbkdf2') + exports.pbkdf2 = p.pbkdf2 + exports.pbkdf2Sync = p.pbkdf2Sync + + var aes = require('browserify-cipher') + + exports.Cipher = aes.Cipher + exports.createCipher = aes.createCipher + exports.Cipheriv = aes.Cipheriv + exports.createCipheriv = aes.createCipheriv + exports.Decipher = aes.Decipher + exports.createDecipher = aes.createDecipher + exports.Decipheriv = aes.Decipheriv + exports.createDecipheriv = aes.createDecipheriv + exports.getCiphers = aes.getCiphers + exports.listCiphers = aes.listCiphers + + var dh = require('diffie-hellman') + + exports.DiffieHellmanGroup = dh.DiffieHellmanGroup + exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup + exports.getDiffieHellman = dh.getDiffieHellman + exports.createDiffieHellman = dh.createDiffieHellman + exports.DiffieHellman = dh.DiffieHellman + + var sign = require('browserify-sign') + + exports.createSign = sign.createSign + exports.Sign = sign.Sign + exports.createVerify = sign.createVerify + exports.Verify = sign.Verify + + exports.createECDH = require('create-ecdh') + + var publicEncrypt = require('public-encrypt') + + exports.publicEncrypt = publicEncrypt.publicEncrypt + exports.privateEncrypt = publicEncrypt.privateEncrypt + exports.publicDecrypt = publicEncrypt.publicDecrypt + exports.privateDecrypt = publicEncrypt.privateDecrypt + + // the least I can do is make error messages for the rest of the node.js/crypto api. + // ;[ + // 'createCredentials' + // ].forEach(function (name) { + // exports[name] = function () { + // throw new Error([ + // 'sorry, ' + name + ' is not implemented yet', + // 'we accept pull requests', + // 'https://github.com/crypto-browserify/crypto-browserify' + // ].join('\n')) + // } + // }) + + var rf = require('randomfill') + + exports.randomFill = rf.randomFill + exports.randomFillSync = rf.randomFillSync + + exports.createCredentials = function () { + throw new Error([ + 'sorry, createCredentials is not implemented yet', + 'we accept pull requests', + 'https://github.com/crypto-browserify/crypto-browserify' + ].join('\n')) + } + + exports.constants = { + 'DH_CHECK_P_NOT_SAFE_PRIME': 2, + 'DH_CHECK_P_NOT_PRIME': 1, + 'DH_UNABLE_TO_CHECK_GENERATOR': 4, + 'DH_NOT_SUITABLE_GENERATOR': 8, + 'NPN_ENABLED': 1, + 'ALPN_ENABLED': 1, + 'RSA_PKCS1_PADDING': 1, + 'RSA_SSLV23_PADDING': 2, + 'RSA_NO_PADDING': 3, + 'RSA_PKCS1_OAEP_PADDING': 4, + 'RSA_X931_PADDING': 5, + 'RSA_PKCS1_PSS_PADDING': 6, + 'POINT_CONVERSION_COMPRESSED': 2, + 'POINT_CONVERSION_UNCOMPRESSED': 4, + 'POINT_CONVERSION_HYBRID': 6 + } + + },{"browserify-cipher":240,"browserify-sign":247,"browserify-sign/algos":244,"create-ecdh":268,"create-hash":270,"create-hmac":272,"diffie-hellman":281,"pbkdf2":347,"public-encrypt":354,"randombytes":361,"randomfill":362}],275:[function(require,module,exports){ + 'use strict'; + + exports.utils = require('./des/utils'); + exports.Cipher = require('./des/cipher'); + exports.DES = require('./des/des'); + exports.CBC = require('./des/cbc'); + exports.EDE = require('./des/ede'); + + },{"./des/cbc":276,"./des/cipher":277,"./des/des":278,"./des/ede":279,"./des/utils":280}],276:[function(require,module,exports){ + 'use strict'; + + var assert = require('minimalistic-assert'); + var inherits = require('inherits'); + + var proto = {}; + + function CBCState(iv) { + assert.equal(iv.length, 8, 'Invalid IV length'); + + this.iv = new Array(8); + for (var i = 0; i < this.iv.length; i++) + this.iv[i] = iv[i]; + } + + function instantiate(Base) { + function CBC(options) { + Base.call(this, options); + this._cbcInit(); + } + inherits(CBC, Base); + + var keys = Object.keys(proto); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + CBC.prototype[key] = proto[key]; + } + + CBC.create = function create(options) { + return new CBC(options); + }; + + return CBC; + } + + exports.instantiate = instantiate; + + proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; + }; + + proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + + var iv = state.iv; + if (this.type === 'encrypt') { + for (var i = 0; i < this.blockSize; i++) + iv[i] ^= inp[inOff + i]; + + superProto._update.call(this, iv, 0, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + iv[i] = out[outOff + i]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + out[outOff + i] ^= iv[i]; + + for (var i = 0; i < this.blockSize; i++) + iv[i] = inp[inOff + i]; + } + }; + + },{"inherits":335,"minimalistic-assert":339}],277:[function(require,module,exports){ + 'use strict'; + + var assert = require('minimalistic-assert'); + + function Cipher(options) { + this.options = options; + + this.type = this.options.type; + this.blockSize = 8; + this._init(); + + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; + } + module.exports = Cipher; + + Cipher.prototype._init = function _init() { + // Might be overrided + }; + + Cipher.prototype.update = function update(data) { + if (data.length === 0) + return []; + + if (this.type === 'decrypt') + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); + }; + + Cipher.prototype._buffer = function _buffer(data, off) { + // Append data to buffer + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i = 0; i < min; i++) + this.buffer[this.bufferOff + i] = data[off + i]; + this.bufferOff += min; + + // Shift next + return min; + }; + + Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; + }; + + Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; + var out = new Array(count * this.blockSize); + + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); + + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } + + // Write blocks + var max = data.length - ((data.length - inputOff) % this.blockSize); + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } + + // Queue rest + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; + + return out; + }; + + Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); + + // TODO(indutny): optimize it, this is far from optimal + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } + + // Buffer rest of the input + inputOff += this._buffer(data, inputOff); + + return out; + }; + + Cipher.prototype.final = function final(buffer) { + var first; + if (buffer) + first = this.update(buffer); + + var last; + if (this.type === 'encrypt') + last = this._finalEncrypt(); + else + last = this._finalDecrypt(); + + if (first) + return first.concat(last); + else + return last; + }; + + Cipher.prototype._pad = function _pad(buffer, off) { + if (off === 0) + return false; + + while (off < buffer.length) + buffer[off++] = 0; + + return true; + }; + + Cipher.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; + }; + + Cipher.prototype._unpad = function _unpad(buffer) { + return buffer; + }; + + Cipher.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); + + return this._unpad(out); + }; + + },{"minimalistic-assert":339}],278:[function(require,module,exports){ + 'use strict'; + + var assert = require('minimalistic-assert'); + var inherits = require('inherits'); + + var utils = require('./utils'); + var Cipher = require('./cipher'); + + function DESState() { + this.tmp = new Array(2); + this.keys = null; + } + + function DES(options) { + Cipher.call(this, options); + + var state = new DESState(); + this._desState = state; + + this.deriveKeys(state, options.key); + } + inherits(DES, Cipher); + module.exports = DES; + + DES.create = function create(options) { + return new DES(options); + }; + + var shiftTable = [ + 1, 1, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 1 + ]; + + DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); + + assert.equal(key.length, this.blockSize, 'Invalid key length'); + + var kL = utils.readUInt32BE(key, 0); + var kR = utils.readUInt32BE(key, 4); + + utils.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i = 0; i < state.keys.length; i += 2) { + var shift = shiftTable[i >>> 1]; + kL = utils.r28shl(kL, shift); + kR = utils.r28shl(kR, shift); + utils.pc2(kL, kR, state.keys, i); + } + }; + + DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; + + var l = utils.readUInt32BE(inp, inOff); + var r = utils.readUInt32BE(inp, inOff + 4); + + // Initial Permutation + utils.ip(l, r, state.tmp, 0); + l = state.tmp[0]; + r = state.tmp[1]; + + if (this.type === 'encrypt') + this._encrypt(state, l, r, state.tmp, 0); + else + this._decrypt(state, l, r, state.tmp, 0); + + l = state.tmp[0]; + r = state.tmp[1]; + + utils.writeUInt32BE(out, l, outOff); + utils.writeUInt32BE(out, r, outOff + 4); + }; + + DES.prototype._pad = function _pad(buffer, off) { + var value = buffer.length - off; + for (var i = off; i < buffer.length; i++) + buffer[i] = value; + + return true; + }; + + DES.prototype._unpad = function _unpad(buffer) { + var pad = buffer[buffer.length - 1]; + for (var i = buffer.length - pad; i < buffer.length; i++) + assert.equal(buffer[i], pad); + + return buffer.slice(0, buffer.length - pad); + }; + + DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l = lStart; + var r = rStart; + + // Apply f() x16 times + for (var i = 0; i < state.keys.length; i += 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(r, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = r; + r = (l ^ f) >>> 0; + l = t; + } + + // Reverse Initial Permutation + utils.rip(r, l, out, off); + }; + + DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l = rStart; + var r = lStart; + + // Apply f() x16 times + for (var i = state.keys.length - 2; i >= 0; i -= 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(l, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = l; + l = (r ^ f) >>> 0; + r = t; + } + + // Reverse Initial Permutation + utils.rip(l, r, out, off); + }; + + },{"./cipher":277,"./utils":280,"inherits":335,"minimalistic-assert":339}],279:[function(require,module,exports){ + 'use strict'; + + var assert = require('minimalistic-assert'); + var inherits = require('inherits'); + + var Cipher = require('./cipher'); + var DES = require('./des'); + + function EDEState(type, key) { + assert.equal(key.length, 24, 'Invalid key length'); + + var k1 = key.slice(0, 8); + var k2 = key.slice(8, 16); + var k3 = key.slice(16, 24); + + if (type === 'encrypt') { + this.ciphers = [ + DES.create({ type: 'encrypt', key: k1 }), + DES.create({ type: 'decrypt', key: k2 }), + DES.create({ type: 'encrypt', key: k3 }) + ]; + } else { + this.ciphers = [ + DES.create({ type: 'decrypt', key: k3 }), + DES.create({ type: 'encrypt', key: k2 }), + DES.create({ type: 'decrypt', key: k1 }) + ]; + } + } + + function EDE(options) { + Cipher.call(this, options); + + var state = new EDEState(this.type, this.options.key); + this._edeState = state; + } + inherits(EDE, Cipher); + + module.exports = EDE; + + EDE.create = function create(options) { + return new EDE(options); + }; + + EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; + + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); + }; + + EDE.prototype._pad = DES.prototype._pad; + EDE.prototype._unpad = DES.prototype._unpad; + + },{"./cipher":277,"./des":278,"inherits":335,"minimalistic-assert":339}],280:[function(require,module,exports){ + 'use strict'; + + exports.readUInt32BE = function readUInt32BE(bytes, off) { + var res = (bytes[0 + off] << 24) | + (bytes[1 + off] << 16) | + (bytes[2 + off] << 8) | + bytes[3 + off]; + return res >>> 0; + }; + + exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { + bytes[0 + off] = value >>> 24; + bytes[1 + off] = (value >>> 16) & 0xff; + bytes[2 + off] = (value >>> 8) & 0xff; + bytes[3 + off] = value & 0xff; + }; + + exports.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + } + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + + exports.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 0; i < 4; i++) { + for (var j = 24; j >= 0; j -= 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + for (var i = 4; i < 8; i++) { + for (var j = 24; j >= 0; j -= 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + + exports.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + // 7, 15, 23, 31, 39, 47, 55, 63 + // 6, 14, 22, 30, 39, 47, 55, 63 + // 5, 13, 21, 29, 39, 47, 55, 63 + // 4, 12, 20, 28 + for (var i = 7; i >= 5; i--) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + + // 1, 9, 17, 25, 33, 41, 49, 57 + // 2, 10, 18, 26, 34, 42, 50, 58 + // 3, 11, 19, 27, 35, 43, 51, 59 + // 36, 44, 52, 60 + for (var i = 1; i <= 3; i++) { + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + + exports.r28shl = function r28shl(num, shift) { + return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); + }; + + var pc2table = [ + // inL => outL + 14, 11, 17, 4, 27, 23, 25, 0, + 13, 22, 7, 18, 5, 9, 16, 24, + 2, 20, 12, 21, 1, 8, 15, 26, + + // inR => outR + 15, 4, 25, 19, 9, 1, 26, 16, + 5, 11, 23, 8, 12, 7, 17, 0, + 22, 3, 10, 14, 6, 20, 27, 24 + ]; + + exports.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + var len = pc2table.length >>> 1; + for (var i = 0; i < len; i++) { + outL <<= 1; + outL |= (inL >>> pc2table[i]) & 0x1; + } + for (var i = len; i < pc2table.length; i++) { + outR <<= 1; + outR |= (inR >>> pc2table[i]) & 0x1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + + exports.expand = function expand(r, out, off) { + var outL = 0; + var outR = 0; + + outL = ((r & 1) << 5) | (r >>> 27); + for (var i = 23; i >= 15; i -= 4) { + outL <<= 6; + outL |= (r >>> i) & 0x3f; + } + for (var i = 11; i >= 3; i -= 4) { + outR |= (r >>> i) & 0x3f; + outR <<= 6; + } + outR |= ((r & 0x1f) << 1) | (r >>> 31); + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + + var sTable = [ + 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, + 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, + 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, + 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, + + 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, + 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, + 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, + 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, + + 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, + 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, + 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, + 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, + + 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, + 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, + 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, + 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, + + 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, + 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, + 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, + 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, + + 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, + 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, + 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, + 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, + + 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, + 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, + 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, + 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, + + 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, + 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, + 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, + 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 + ]; + + exports.substitute = function substitute(inL, inR) { + var out = 0; + for (var i = 0; i < 4; i++) { + var b = (inL >>> (18 - i * 6)) & 0x3f; + var sb = sTable[i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + for (var i = 0; i < 4; i++) { + var b = (inR >>> (18 - i * 6)) & 0x3f; + var sb = sTable[4 * 0x40 + i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + return out >>> 0; + }; + + var permuteTable = [ + 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, + 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 + ]; + + exports.permute = function permute(num) { + var out = 0; + for (var i = 0; i < permuteTable.length; i++) { + out <<= 1; + out |= (num >>> permuteTable[i]) & 0x1; + } + return out >>> 0; + }; + + exports.padSplit = function padSplit(num, size, group) { + var str = num.toString(2); + while (str.length < size) + str = '0' + str; + + var out = []; + for (var i = 0; i < size; i += group) + out.push(str.slice(i, i + group)); + return out.join(' '); + }; + + },{}],281:[function(require,module,exports){ + (function (Buffer){(function (){ + var generatePrime = require('./lib/generatePrime') + var primes = require('./lib/primes.json') + + var DH = require('./lib/dh') + + function getDiffieHellman (mod) { + var prime = new Buffer(primes[mod].prime, 'hex') + var gen = new Buffer(primes[mod].gen, 'hex') + + return new DH(prime, gen) + } + + var ENCODINGS = { + 'binary': true, 'hex': true, 'base64': true + } + + function createDiffieHellman (prime, enc, generator, genc) { + if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { + return createDiffieHellman(prime, 'binary', enc, generator) + } + + enc = enc || 'binary' + genc = genc || 'binary' + generator = generator || new Buffer([2]) + + if (!Buffer.isBuffer(generator)) { + generator = new Buffer(generator, genc) + } + + if (typeof prime === 'number') { + return new DH(generatePrime(prime, generator), generator, true) + } + + if (!Buffer.isBuffer(prime)) { + prime = new Buffer(prime, enc) + } + + return new DH(prime, generator, true) + } + + exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman + exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./lib/dh":282,"./lib/generatePrime":283,"./lib/primes.json":284,"buffer":266}],282:[function(require,module,exports){ + (function (Buffer){(function (){ + var BN = require('bn.js'); + var MillerRabin = require('miller-rabin'); + var millerRabin = new MillerRabin(); + var TWENTYFOUR = new BN(24); + var ELEVEN = new BN(11); + var TEN = new BN(10); + var THREE = new BN(3); + var SEVEN = new BN(7); + var primes = require('./generatePrime'); + var randomBytes = require('randombytes'); + module.exports = DH; + + function setPublicKey(pub, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc); + } + this._pub = new BN(pub); + return this; + } + + function setPrivateKey(priv, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc); + } + this._priv = new BN(priv); + return this; + } + + var primeCache = {}; + function checkPrime(prime, generator) { + var gen = generator.toString('hex'); + var hex = [gen, prime.toString(16)].join('_'); + if (hex in primeCache) { + return primeCache[hex]; + } + var error = 0; + + if (prime.isEven() || + !primes.simpleSieve || + !primes.fermatTest(prime) || + !millerRabin.test(prime)) { + //not a prime so +1 + error += 1; + + if (gen === '02' || gen === '05') { + // we'd be able to check the generator + // it would fail so +8 + error += 8; + } else { + //we wouldn't be able to test the generator + // so +4 + error += 4; + } + primeCache[hex] = error; + return error; + } + if (!millerRabin.test(prime.shrn(1))) { + //not a safe prime + error += 2; + } + var rem; + switch (gen) { + case '02': + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + // unsuidable generator + error += 8; + } + break; + case '05': + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + // prime mod 10 needs to equal 3 or 7 + error += 8; + } + break; + default: + error += 4; + } + primeCache[hex] = error; + return error; + } + + function DH(prime, generator, malleable) { + this.setGenerator(generator); + this.__prime = new BN(prime); + this._prime = BN.mont(this.__prime); + this._primeLen = prime.length; + this._pub = undefined; + this._priv = undefined; + this._primeCode = undefined; + if (malleable) { + this.setPublicKey = setPublicKey; + this.setPrivateKey = setPrivateKey; + } else { + this._primeCode = 8; + } + } + Object.defineProperty(DH.prototype, 'verifyError', { + enumerable: true, + get: function () { + if (typeof this._primeCode !== 'number') { + this._primeCode = checkPrime(this.__prime, this.__gen); + } + return this._primeCode; + } + }); + DH.prototype.generateKeys = function () { + if (!this._priv) { + this._priv = new BN(randomBytes(this._primeLen)); + } + this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); + return this.getPublicKey(); + }; + + DH.prototype.computeSecret = function (other) { + other = new BN(other); + other = other.toRed(this._prime); + var secret = other.redPow(this._priv).fromRed(); + var out = new Buffer(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer(prime.length - out.length); + front.fill(0); + out = Buffer.concat([front, out]); + } + return out; + }; + + DH.prototype.getPublicKey = function getPublicKey(enc) { + return formatReturnValue(this._pub, enc); + }; + + DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue(this._priv, enc); + }; + + DH.prototype.getPrime = function (enc) { + return formatReturnValue(this.__prime, enc); + }; + + DH.prototype.getGenerator = function (enc) { + return formatReturnValue(this._gen, enc); + }; + + DH.prototype.setGenerator = function (gen, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(gen)) { + gen = new Buffer(gen, enc); + } + this.__gen = gen; + this._gen = new BN(gen); + return this; + }; + + function formatReturnValue(bn, enc) { + var buf = new Buffer(bn.toArray()); + if (!enc) { + return buf; + } else { + return buf.toString(enc); + } + } + + }).call(this)}).call(this,require("buffer").Buffer) + },{"./generatePrime":283,"bn.js":285,"buffer":266,"miller-rabin":337,"randombytes":361}],283:[function(require,module,exports){ + var randomBytes = require('randombytes'); + module.exports = findPrime; + findPrime.simpleSieve = simpleSieve; + findPrime.fermatTest = fermatTest; + var BN = require('bn.js'); + var TWENTYFOUR = new BN(24); + var MillerRabin = require('miller-rabin'); + var millerRabin = new MillerRabin(); + var ONE = new BN(1); + var TWO = new BN(2); + var FIVE = new BN(5); + var SIXTEEN = new BN(16); + var EIGHT = new BN(8); + var TEN = new BN(10); + var THREE = new BN(3); + var SEVEN = new BN(7); + var ELEVEN = new BN(11); + var FOUR = new BN(4); + var TWELVE = new BN(12); + var primes = null; + + function _getPrimes() { + if (primes !== null) + return primes; + + var limit = 0x100000; + var res = []; + res[0] = 2; + for (var i = 1, k = 3; k < limit; k += 2) { + var sqrt = Math.ceil(Math.sqrt(k)); + for (var j = 0; j < i && res[j] <= sqrt; j++) + if (k % res[j] === 0) + break; + + if (i !== j && res[j] <= sqrt) + continue; + + res[i++] = k; + } + primes = res; + return res; + } + + function simpleSieve(p) { + var primes = _getPrimes(); + + for (var i = 0; i < primes.length; i++) + if (p.modn(primes[i]) === 0) { + if (p.cmpn(primes[i]) === 0) { + return true; + } else { + return false; + } + } + + return true; + } + + function fermatTest(p) { + var red = BN.mont(p); + return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; + } + + function findPrime(bits, gen) { + if (bits < 16) { + // this is what openssl does + if (gen === 2 || gen === 5) { + return new BN([0x8c, 0x7b]); + } else { + return new BN([0x8c, 0x27]); + } + } + gen = new BN(gen); + + var num, n2; + + while (true) { + num = new BN(randomBytes(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n2 = num.shrn(1); + if (simpleSieve(n2) && simpleSieve(num) && + fermatTest(n2) && fermatTest(num) && + millerRabin.test(n2) && millerRabin.test(num)) { + return num; + } + } + + } + + },{"bn.js":285,"miller-rabin":337,"randombytes":361}],284:[function(require,module,exports){ + module.exports={ + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } + } + },{}],285:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],286:[function(require,module,exports){ + arguments[4][56][0].apply(exports,arguments) + },{"../package.json":302,"./elliptic/curve":289,"./elliptic/curves":292,"./elliptic/ec":293,"./elliptic/eddsa":296,"./elliptic/utils":300,"brorand":221,"dup":56}],287:[function(require,module,exports){ + arguments[4][57][0].apply(exports,arguments) + },{"../utils":300,"bn.js":301,"dup":57}],288:[function(require,module,exports){ + arguments[4][58][0].apply(exports,arguments) + },{"../utils":300,"./base":287,"bn.js":301,"dup":58,"inherits":335}],289:[function(require,module,exports){ + arguments[4][59][0].apply(exports,arguments) + },{"./base":287,"./edwards":288,"./mont":290,"./short":291,"dup":59}],290:[function(require,module,exports){ + arguments[4][60][0].apply(exports,arguments) + },{"../utils":300,"./base":287,"bn.js":301,"dup":60,"inherits":335}],291:[function(require,module,exports){ + arguments[4][61][0].apply(exports,arguments) + },{"../utils":300,"./base":287,"bn.js":301,"dup":61,"inherits":335}],292:[function(require,module,exports){ + arguments[4][62][0].apply(exports,arguments) + },{"./curve":289,"./precomputed/secp256k1":299,"./utils":300,"dup":62,"hash.js":321}],293:[function(require,module,exports){ + arguments[4][63][0].apply(exports,arguments) + },{"../curves":292,"../utils":300,"./key":294,"./signature":295,"bn.js":301,"brorand":221,"dup":63,"hmac-drbg":333}],294:[function(require,module,exports){ + arguments[4][64][0].apply(exports,arguments) + },{"../utils":300,"bn.js":301,"dup":64}],295:[function(require,module,exports){ + arguments[4][65][0].apply(exports,arguments) + },{"../utils":300,"bn.js":301,"dup":65}],296:[function(require,module,exports){ + arguments[4][66][0].apply(exports,arguments) + },{"../curves":292,"../utils":300,"./key":297,"./signature":298,"dup":66,"hash.js":321}],297:[function(require,module,exports){ + arguments[4][67][0].apply(exports,arguments) + },{"../utils":300,"dup":67}],298:[function(require,module,exports){ + arguments[4][68][0].apply(exports,arguments) + },{"../utils":300,"bn.js":301,"dup":68}],299:[function(require,module,exports){ + arguments[4][69][0].apply(exports,arguments) + },{"dup":69}],300:[function(require,module,exports){ + arguments[4][70][0].apply(exports,arguments) + },{"bn.js":301,"dup":70,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],301:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],302:[function(require,module,exports){ + module.exports={ + "_from": "elliptic@^6.5.3", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/browserify/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "elliptic@^6.5.3", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "^6.5.3", + "saveSpec": null, + "fetchSpec": "^6.5.3" + }, + "_requiredBy": [ + "/browserify/browserify-sign", + "/browserify/create-ecdh" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_shasum": "da37cebd31e79a1367e941b592ed1fbebd58abbb", + "_spec": "elliptic@^6.5.3", + "_where": "/usr/local/lib/node_modules/browserify/node_modules/browserify-sign", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "bundleDependencies": false, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "deprecated": false, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" + } + + },{}],303:[function(require,module,exports){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + 'use strict'; + + var R = typeof Reflect === 'object' ? Reflect : null + var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + + var ReflectOwnKeys + if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys + } else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; + } else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; + } + + function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); + } + + var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; + } + + function EventEmitter() { + EventEmitter.init.call(this); + } + module.exports = EventEmitter; + module.exports.once = once; + + // Backwards-compat with node 0.10.x + EventEmitter.EventEmitter = EventEmitter; + + EventEmitter.prototype._events = undefined; + EventEmitter.prototype._eventsCount = 0; + EventEmitter.prototype._maxListeners = undefined; + + // By default EventEmitters will print a warning if more than 10 listeners are + // added to it. This is a useful default which helps finding memory leaks. + var defaultMaxListeners = 10; + + function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + } + + Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } + }); + + EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; + }; + + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; + }; + + function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; + } + + EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); + }; + + EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; + }; + + function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + checkListener(listener); + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; + } + + EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); + }; + + EventEmitter.prototype.on = EventEmitter.prototype.addListener; + + EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + + function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } + } + + function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; + } + + EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; + }; + + EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + + // Emits a 'removeListener' event if and only if the listener was removed. + EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + + EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + + EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + + function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); + } + + EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); + }; + + EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); + }; + + EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } + }; + + EventEmitter.prototype.listenerCount = listenerCount; + function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; + } + + EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; + }; + + function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; + } + + function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); + } + + function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; + } + + function once(emitter, name) { + return new Promise(function (resolve, reject) { + function errorListener(err) { + emitter.removeListener(name, resolver); + reject(err); + } + + function resolver() { + if (typeof emitter.removeListener === 'function') { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; + + eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); + if (name !== 'error') { + addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); + } + }); + } + + function addErrorHandlerIfEventEmitter(emitter, handler, flags) { + if (typeof emitter.on === 'function') { + eventTargetAgnosticAddListener(emitter, 'error', handler, flags); + } + } + + function eventTargetAgnosticAddListener(emitter, name, listener, flags) { + if (typeof emitter.on === 'function') { + if (flags.once) { + emitter.once(name, listener); + } else { + emitter.on(name, listener); + } + } else if (typeof emitter.addEventListener === 'function') { + // EventTarget does not have `error` event semantics like Node + // EventEmitters, we do not listen for `error` events here. + emitter.addEventListener(name, function wrapListener(arg) { + // IE does not have builtin `{ once: true }` support so we + // have to do it manually. + if (flags.once) { + emitter.removeEventListener(name, wrapListener); + } + listener(arg); + }); + } else { + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); + } + } + + },{}],304:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + var MD5 = require('md5.js') + + /* eslint-disable camelcase */ + function EVP_BytesToKey (password, salt, keyBits, ivLen) { + if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') + if (salt) { + if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') + if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + } + + var keyLen = keyBits / 8 + var key = Buffer.alloc(keyLen) + var iv = Buffer.alloc(ivLen || 0) + var tmp = Buffer.alloc(0) + + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5() + hash.update(tmp) + hash.update(password) + if (salt) hash.update(salt) + tmp = hash.digest() + + var used = 0 + + if (keyLen > 0) { + var keyStart = key.length - keyLen + used = Math.min(keyLen, tmp.length) + tmp.copy(key, keyStart, 0, used) + keyLen -= used + } + + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen + var length = Math.min(ivLen, tmp.length - used) + tmp.copy(iv, ivStart, used, used + length) + ivLen -= length + } + } + + tmp.fill(0) + return { key: key, iv: iv } + } + + module.exports = EVP_BytesToKey + + },{"md5.js":336,"safe-buffer":364}],305:[function(require,module,exports){ + arguments[4][82][0].apply(exports,arguments) + },{"dup":82,"inherits":335,"readable-stream":320,"safe-buffer":364}],306:[function(require,module,exports){ + arguments[4][106][0].apply(exports,arguments) + },{"dup":106}],307:[function(require,module,exports){ + arguments[4][107][0].apply(exports,arguments) + },{"./_stream_readable":309,"./_stream_writable":311,"_process":353,"dup":107,"inherits":335}],308:[function(require,module,exports){ + arguments[4][108][0].apply(exports,arguments) + },{"./_stream_transform":310,"dup":108,"inherits":335}],309:[function(require,module,exports){ + arguments[4][109][0].apply(exports,arguments) + },{"../errors":306,"./_stream_duplex":307,"./internal/streams/async_iterator":312,"./internal/streams/buffer_list":313,"./internal/streams/destroy":314,"./internal/streams/from":316,"./internal/streams/state":318,"./internal/streams/stream":319,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],310:[function(require,module,exports){ + arguments[4][110][0].apply(exports,arguments) + },{"../errors":306,"./_stream_duplex":307,"dup":110,"inherits":335}],311:[function(require,module,exports){ + arguments[4][111][0].apply(exports,arguments) + },{"../errors":306,"./_stream_duplex":307,"./internal/streams/destroy":314,"./internal/streams/state":318,"./internal/streams/stream":319,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],312:[function(require,module,exports){ + arguments[4][112][0].apply(exports,arguments) + },{"./end-of-stream":315,"_process":353,"dup":112}],313:[function(require,module,exports){ + arguments[4][113][0].apply(exports,arguments) + },{"buffer":266,"dup":113,"util":222}],314:[function(require,module,exports){ + arguments[4][114][0].apply(exports,arguments) + },{"_process":353,"dup":114}],315:[function(require,module,exports){ + arguments[4][115][0].apply(exports,arguments) + },{"../../../errors":306,"dup":115}],316:[function(require,module,exports){ + arguments[4][116][0].apply(exports,arguments) + },{"dup":116}],317:[function(require,module,exports){ + arguments[4][117][0].apply(exports,arguments) + },{"../../../errors":306,"./end-of-stream":315,"dup":117}],318:[function(require,module,exports){ + arguments[4][118][0].apply(exports,arguments) + },{"../../../errors":306,"dup":118}],319:[function(require,module,exports){ + arguments[4][119][0].apply(exports,arguments) + },{"dup":119,"events":303}],320:[function(require,module,exports){ + arguments[4][120][0].apply(exports,arguments) + },{"./lib/_stream_duplex.js":307,"./lib/_stream_passthrough.js":308,"./lib/_stream_readable.js":309,"./lib/_stream_transform.js":310,"./lib/_stream_writable.js":311,"./lib/internal/streams/end-of-stream.js":315,"./lib/internal/streams/pipeline.js":317,"dup":120}],321:[function(require,module,exports){ + arguments[4][83][0].apply(exports,arguments) + },{"./hash/common":322,"./hash/hmac":323,"./hash/ripemd":324,"./hash/sha":325,"./hash/utils":332,"dup":83}],322:[function(require,module,exports){ + arguments[4][84][0].apply(exports,arguments) + },{"./utils":332,"dup":84,"minimalistic-assert":339}],323:[function(require,module,exports){ + arguments[4][85][0].apply(exports,arguments) + },{"./utils":332,"dup":85,"minimalistic-assert":339}],324:[function(require,module,exports){ + arguments[4][86][0].apply(exports,arguments) + },{"./common":322,"./utils":332,"dup":86}],325:[function(require,module,exports){ + arguments[4][87][0].apply(exports,arguments) + },{"./sha/1":326,"./sha/224":327,"./sha/256":328,"./sha/384":329,"./sha/512":330,"dup":87}],326:[function(require,module,exports){ + arguments[4][88][0].apply(exports,arguments) + },{"../common":322,"../utils":332,"./common":331,"dup":88}],327:[function(require,module,exports){ + arguments[4][89][0].apply(exports,arguments) + },{"../utils":332,"./256":328,"dup":89}],328:[function(require,module,exports){ + arguments[4][90][0].apply(exports,arguments) + },{"../common":322,"../utils":332,"./common":331,"dup":90,"minimalistic-assert":339}],329:[function(require,module,exports){ + arguments[4][91][0].apply(exports,arguments) + },{"../utils":332,"./512":330,"dup":91}],330:[function(require,module,exports){ + arguments[4][92][0].apply(exports,arguments) + },{"../common":322,"../utils":332,"dup":92,"minimalistic-assert":339}],331:[function(require,module,exports){ + arguments[4][93][0].apply(exports,arguments) + },{"../utils":332,"dup":93}],332:[function(require,module,exports){ + arguments[4][94][0].apply(exports,arguments) + },{"dup":94,"inherits":335,"minimalistic-assert":339}],333:[function(require,module,exports){ + arguments[4][95][0].apply(exports,arguments) + },{"dup":95,"hash.js":321,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],334:[function(require,module,exports){ + /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ + exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) + } + + exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 + } + + },{}],335:[function(require,module,exports){ + arguments[4][97][0].apply(exports,arguments) + },{"dup":97}],336:[function(require,module,exports){ + arguments[4][102][0].apply(exports,arguments) + },{"dup":102,"hash-base":305,"inherits":335,"safe-buffer":364}],337:[function(require,module,exports){ + var bn = require('bn.js'); + var brorand = require('brorand'); + + function MillerRabin(rand) { + this.rand = rand || new brorand.Rand(); + } + module.exports = MillerRabin; + + MillerRabin.create = function create(rand) { + return new MillerRabin(rand); + }; + + MillerRabin.prototype._randbelow = function _randbelow(n) { + var len = n.bitLength(); + var min_bytes = Math.ceil(len / 8); + + // Generage random bytes until a number less than n is found. + // This ensures that 0..n-1 have an equal probability of being selected. + do + var a = new bn(this.rand.generate(min_bytes)); + while (a.cmp(n) >= 0); + + return a; + }; + + MillerRabin.prototype._randrange = function _randrange(start, stop) { + // Generate a random number greater than or equal to start and less than stop. + var size = stop.sub(start); + return start.add(this._randbelow(size)); + }; + + MillerRabin.prototype.test = function test(n, k, cb) { + var len = n.bitLength(); + var red = bn.mont(n); + var rone = new bn(1).toRed(red); + + if (!k) + k = Math.max(1, (len / 48) | 0); + + // Find d and s, (n - 1) = (2 ^ s) * d; + var n1 = n.subn(1); + for (var s = 0; !n1.testn(s); s++) {} + var d = n.shrn(s); + + var rn1 = n1.toRed(red); + + var prime = true; + for (; k > 0; k--) { + var a = this._randrange(new bn(2), n1); + if (cb) + cb(a); + + var x = a.toRed(red).redPow(d); + if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) + continue; + + for (var i = 1; i < s; i++) { + x = x.redSqr(); + + if (x.cmp(rone) === 0) + return false; + if (x.cmp(rn1) === 0) + break; + } + + if (i === s) + return false; + } + + return prime; + }; + + MillerRabin.prototype.getDivisor = function getDivisor(n, k) { + var len = n.bitLength(); + var red = bn.mont(n); + var rone = new bn(1).toRed(red); + + if (!k) + k = Math.max(1, (len / 48) | 0); + + // Find d and s, (n - 1) = (2 ^ s) * d; + var n1 = n.subn(1); + for (var s = 0; !n1.testn(s); s++) {} + var d = n.shrn(s); + + var rn1 = n1.toRed(red); + + for (; k > 0; k--) { + var a = this._randrange(new bn(2), n1); + + var g = n.gcd(a); + if (g.cmpn(1) !== 0) + return g; + + var x = a.toRed(red).redPow(d); + if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) + continue; + + for (var i = 1; i < s; i++) { + x = x.redSqr(); + + if (x.cmp(rone) === 0) + return x.fromRed().subn(1).gcd(n); + if (x.cmp(rn1) === 0) + break; + } + + if (i === s) { + x = x.redSqr(); + return x.fromRed().subn(1).gcd(n); + } + } + + return false; + }; + + },{"bn.js":338,"brorand":221}],338:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],339:[function(require,module,exports){ + arguments[4][103][0].apply(exports,arguments) + },{"dup":103}],340:[function(require,module,exports){ + arguments[4][104][0].apply(exports,arguments) + },{"dup":104}],341:[function(require,module,exports){ + /* + object-assign + (c) Sindre Sorhus + @license MIT + */ + + 'use strict'; + /* eslint-disable no-unused-vars */ + var getOwnPropertySymbols = Object.getOwnPropertySymbols; + var hasOwnProperty = Object.prototype.hasOwnProperty; + var propIsEnumerable = Object.prototype.propertyIsEnumerable; + + function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); + } + + function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } + } + + module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; + }; + + },{}],342:[function(require,module,exports){ + module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", + "2.16.840.1.101.3.4.1.2": "aes-128-cbc", + "2.16.840.1.101.3.4.1.3": "aes-128-ofb", + "2.16.840.1.101.3.4.1.4": "aes-128-cfb", + "2.16.840.1.101.3.4.1.21": "aes-192-ecb", + "2.16.840.1.101.3.4.1.22": "aes-192-cbc", + "2.16.840.1.101.3.4.1.23": "aes-192-ofb", + "2.16.840.1.101.3.4.1.24": "aes-192-cfb", + "2.16.840.1.101.3.4.1.41": "aes-256-ecb", + "2.16.840.1.101.3.4.1.42": "aes-256-cbc", + "2.16.840.1.101.3.4.1.43": "aes-256-ofb", + "2.16.840.1.101.3.4.1.44": "aes-256-cfb" + } + },{}],343:[function(require,module,exports){ + // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js + // Fedor, you are amazing. + 'use strict' + + var asn1 = require('asn1.js') + + exports.certificate = require('./certificate') + + var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('modulus').int(), + this.key('publicExponent').int(), + this.key('privateExponent').int(), + this.key('prime1').int(), + this.key('prime2').int(), + this.key('exponent1').int(), + this.key('exponent2').int(), + this.key('coefficient').int() + ) + }) + exports.RSAPrivateKey = RSAPrivateKey + + var RSAPublicKey = asn1.define('RSAPublicKey', function () { + this.seq().obj( + this.key('modulus').int(), + this.key('publicExponent').int() + ) + }) + exports.RSAPublicKey = RSAPublicKey + + var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) + }) + exports.PublicKey = PublicKey + + var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('none').null_().optional(), + this.key('curve').objid().optional(), + this.key('params').seq().obj( + this.key('p').int(), + this.key('q').int(), + this.key('g').int() + ).optional() + ) + }) + + var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { + this.seq().obj( + this.key('version').int(), + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPrivateKey').octstr() + ) + }) + exports.PrivateKey = PrivateKeyInfo + var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { + this.seq().obj( + this.key('algorithm').seq().obj( + this.key('id').objid(), + this.key('decrypt').seq().obj( + this.key('kde').seq().obj( + this.key('id').objid(), + this.key('kdeparams').seq().obj( + this.key('salt').octstr(), + this.key('iters').int() + ) + ), + this.key('cipher').seq().obj( + this.key('algo').objid(), + this.key('iv').octstr() + ) + ) + ), + this.key('subjectPrivateKey').octstr() + ) + }) + + exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + + var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('p').int(), + this.key('q').int(), + this.key('g').int(), + this.key('pub_key').int(), + this.key('priv_key').int() + ) + }) + exports.DSAPrivateKey = DSAPrivateKey + + exports.DSAparam = asn1.define('DSAparam', function () { + this.int() + }) + + var ECPrivateKey = asn1.define('ECPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('privateKey').octstr(), + this.key('parameters').optional().explicit(0).use(ECParameters), + this.key('publicKey').optional().explicit(1).bitstr() + ) + }) + exports.ECPrivateKey = ECPrivateKey + + var ECParameters = asn1.define('ECParameters', function () { + this.choice({ + namedCurve: this.objid() + }) + }) + + exports.signature = asn1.define('signature', function () { + this.seq().obj( + this.key('r').int(), + this.key('s').int() + ) + }) + + },{"./certificate":344,"asn1.js":200}],344:[function(require,module,exports){ + // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js + // thanks to @Rantanen + + 'use strict' + + var asn = require('asn1.js') + + var Time = asn.define('Time', function () { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }) + }) + + var AttributeTypeValue = asn.define('AttributeTypeValue', function () { + this.seq().obj( + this.key('type').objid(), + this.key('value').any() + ) + }) + + var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('parameters').optional(), + this.key('curve').objid().optional() + ) + }) + + var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) + }) + + var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { + this.setof(AttributeTypeValue) + }) + + var RDNSequence = asn.define('RDNSequence', function () { + this.seqof(RelativeDistinguishedName) + }) + + var Name = asn.define('Name', function () { + this.choice({ + rdnSequence: this.use(RDNSequence) + }) + }) + + var Validity = asn.define('Validity', function () { + this.seq().obj( + this.key('notBefore').use(Time), + this.key('notAfter').use(Time) + ) + }) + + var Extension = asn.define('Extension', function () { + this.seq().obj( + this.key('extnID').objid(), + this.key('critical').bool().def(false), + this.key('extnValue').octstr() + ) + }) + + var TBSCertificate = asn.define('TBSCertificate', function () { + this.seq().obj( + this.key('version').explicit(0).int().optional(), + this.key('serialNumber').int(), + this.key('signature').use(AlgorithmIdentifier), + this.key('issuer').use(Name), + this.key('validity').use(Validity), + this.key('subject').use(Name), + this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), + this.key('issuerUniqueID').implicit(1).bitstr().optional(), + this.key('subjectUniqueID').implicit(2).bitstr().optional(), + this.key('extensions').explicit(3).seqof(Extension).optional() + ) + }) + + var X509Certificate = asn.define('X509Certificate', function () { + this.seq().obj( + this.key('tbsCertificate').use(TBSCertificate), + this.key('signatureAlgorithm').use(AlgorithmIdentifier), + this.key('signatureValue').bitstr() + ) + }) + + module.exports = X509Certificate + + },{"asn1.js":200}],345:[function(require,module,exports){ + // adapted from https://github.com/apatil/pemstrip + var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m + var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m + var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m + var evp = require('evp_bytestokey') + var ciphers = require('browserify-aes') + var Buffer = require('safe-buffer').Buffer + module.exports = function (okey, password) { + var key = okey.toString() + var match = key.match(findProc) + var decrypted + if (!match) { + var match2 = key.match(fullRegex) + decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') + } else { + var suite = 'aes' + match[1] + var iv = Buffer.from(match[2], 'hex') + var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key + var out = [] + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + decrypted = Buffer.concat(out) + } + var tag = key.match(startRegex)[1] + return { + tag: tag, + data: decrypted + } + } + + },{"browserify-aes":225,"evp_bytestokey":304,"safe-buffer":364}],346:[function(require,module,exports){ + var asn1 = require('./asn1') + var aesid = require('./aesid.json') + var fixProc = require('./fixProc') + var ciphers = require('browserify-aes') + var compat = require('pbkdf2') + var Buffer = require('safe-buffer').Buffer + module.exports = parseKeys + + function parseKeys (buffer) { + var password + if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { + password = buffer.passphrase + buffer = buffer.key + } + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer) + } + + var stripped = fixProc(buffer, password) + + var type = stripped.tag + var data = stripped.data + var subtype, ndata + switch (type) { + case 'CERTIFICATE': + ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo + // falls through + case 'PUBLIC KEY': + if (!ndata) { + ndata = asn1.PublicKey.decode(data, 'der') + } + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') + case '1.2.840.10045.2.1': + ndata.subjectPrivateKey = ndata.subjectPublicKey + return { + type: 'ec', + data: ndata + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') + return { + type: 'dsa', + data: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'ENCRYPTED PRIVATE KEY': + data = asn1.EncryptedPrivateKey.decode(data, 'der') + data = decrypt(data, password) + // falls through + case 'PRIVATE KEY': + ndata = asn1.PrivateKey.decode(data, 'der') + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') + case '1.2.840.10045.2.1': + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') + return { + type: 'dsa', + params: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'RSA PUBLIC KEY': + return asn1.RSAPublicKey.decode(data, 'der') + case 'RSA PRIVATE KEY': + return asn1.RSAPrivateKey.decode(data, 'der') + case 'DSA PRIVATE KEY': + return { + type: 'dsa', + params: asn1.DSAPrivateKey.decode(data, 'der') + } + case 'EC PRIVATE KEY': + data = asn1.ECPrivateKey.decode(data, 'der') + return { + curve: data.parameters.value, + privateKey: data.privateKey + } + default: throw new Error('unknown key type ' + type) + } + } + parseKeys.signature = asn1.signature + function decrypt (data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) + var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] + var iv = data.algorithm.decrypt.cipher.iv + var cipherText = data.subjectPrivateKey + var keylen = parseInt(algo.split('-')[1], 10) / 8 + var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') + var cipher = ciphers.createDecipheriv(algo, key, iv) + var out = [] + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + return Buffer.concat(out) + } + + },{"./aesid.json":342,"./asn1":343,"./fixProc":345,"browserify-aes":225,"pbkdf2":347,"safe-buffer":364}],347:[function(require,module,exports){ + exports.pbkdf2 = require('./lib/async') + exports.pbkdf2Sync = require('./lib/sync') + + },{"./lib/async":348,"./lib/sync":351}],348:[function(require,module,exports){ + (function (global){(function (){ + var Buffer = require('safe-buffer').Buffer + + var checkParameters = require('./precondition') + var defaultEncoding = require('./default-encoding') + var sync = require('./sync') + var toBuffer = require('./to-buffer') + + var ZERO_BUF + var subtle = global.crypto && global.crypto.subtle + var toBrowser = { + sha: 'SHA-1', + 'sha-1': 'SHA-1', + sha1: 'SHA-1', + sha256: 'SHA-256', + 'sha-256': 'SHA-256', + sha384: 'SHA-384', + 'sha-384': 'SHA-384', + 'sha-512': 'SHA-512', + sha512: 'SHA-512' + } + var checks = [] + function checkNative (algo) { + if (global.process && !global.process.browser) { + return Promise.resolve(false) + } + if (!subtle || !subtle.importKey || !subtle.deriveBits) { + return Promise.resolve(false) + } + if (checks[algo] !== undefined) { + return checks[algo] + } + ZERO_BUF = ZERO_BUF || Buffer.alloc(8) + var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo) + .then(function () { + return true + }).catch(function () { + return false + }) + checks[algo] = prom + return prom + } + var nextTick + function getNextTick () { + if (nextTick) { + return nextTick + } + if (global.process && global.process.nextTick) { + nextTick = global.process.nextTick + } else if (global.queueMicrotask) { + nextTick = global.queueMicrotask + } else if (global.setImmediate) { + nextTick = global.setImmediate + } else { + nextTick = global.setTimeout + } + return nextTick + } + function browserPbkdf2 (password, salt, iterations, length, algo) { + return subtle.importKey( + 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits'] + ).then(function (key) { + return subtle.deriveBits({ + name: 'PBKDF2', + salt: salt, + iterations: iterations, + hash: { + name: algo + } + }, key, length << 3) + }).then(function (res) { + return Buffer.from(res) + }) + } + + function resolvePromise (promise, callback) { + promise.then(function (out) { + getNextTick()(function () { + callback(null, out) + }) + }, function (e) { + getNextTick()(function () { + callback(e) + }) + }) + } + module.exports = function (password, salt, iterations, keylen, digest, callback) { + if (typeof digest === 'function') { + callback = digest + digest = undefined + } + + digest = digest || 'sha1' + var algo = toBrowser[digest.toLowerCase()] + + if (!algo || typeof global.Promise !== 'function') { + getNextTick()(function () { + var out + try { + out = sync(password, salt, iterations, keylen, digest) + } catch (e) { + return callback(e) + } + callback(null, out) + }) + return + } + + checkParameters(iterations, keylen) + password = toBuffer(password, defaultEncoding, 'Password') + salt = toBuffer(salt, defaultEncoding, 'Salt') + if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2') + + resolvePromise(checkNative(algo).then(function (resp) { + if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo) + + return sync(password, salt, iterations, keylen, digest) + }), callback) + } + + }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"./default-encoding":349,"./precondition":350,"./sync":351,"./to-buffer":352,"safe-buffer":364}],349:[function(require,module,exports){ + (function (process,global){(function (){ + var defaultEncoding + /* istanbul ignore next */ + if (global.process && global.process.browser) { + defaultEncoding = 'utf-8' + } else if (global.process && global.process.version) { + var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10) + + defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary' + } else { + defaultEncoding = 'utf-8' + } + module.exports = defaultEncoding + + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"_process":353}],350:[function(require,module,exports){ + var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs + + module.exports = function (iterations, keylen) { + if (typeof iterations !== 'number') { + throw new TypeError('Iterations not a number') + } + + if (iterations < 0) { + throw new TypeError('Bad iterations') + } + + if (typeof keylen !== 'number') { + throw new TypeError('Key length not a number') + } + + if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */ + throw new TypeError('Bad key length') + } + } + + },{}],351:[function(require,module,exports){ + var md5 = require('create-hash/md5') + var RIPEMD160 = require('ripemd160') + var sha = require('sha.js') + var Buffer = require('safe-buffer').Buffer + + var checkParameters = require('./precondition') + var defaultEncoding = require('./default-encoding') + var toBuffer = require('./to-buffer') + + var ZEROS = Buffer.alloc(128) + var sizes = { + md5: 16, + sha1: 20, + sha224: 28, + sha256: 32, + sha384: 48, + sha512: 64, + rmd160: 20, + ripemd160: 20 + } + + function Hmac (alg, key, saltLen) { + var hash = getDigest(alg) + var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 + + if (key.length > blocksize) { + key = hash(key) + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]) + var opad = Buffer.allocUnsafe(blocksize + sizes[alg]) + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + + var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4) + ipad.copy(ipad1, 0, 0, blocksize) + this.ipad1 = ipad1 + this.ipad2 = ipad + this.opad = opad + this.alg = alg + this.blocksize = blocksize + this.hash = hash + this.size = sizes[alg] + } + + Hmac.prototype.run = function (data, ipad) { + data.copy(ipad, this.blocksize) + var h = this.hash(ipad) + h.copy(this.opad, this.blocksize) + return this.hash(this.opad) + } + + function getDigest (alg) { + function shaFunc (data) { + return sha(alg).update(data).digest() + } + function rmd160Func (data) { + return new RIPEMD160().update(data).digest() + } + + if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func + if (alg === 'md5') return md5 + return shaFunc + } + + function pbkdf2 (password, salt, iterations, keylen, digest) { + checkParameters(iterations, keylen) + password = toBuffer(password, defaultEncoding, 'Password') + salt = toBuffer(salt, defaultEncoding, 'Salt') + + digest = digest || 'sha1' + + var hmac = new Hmac(digest, password, salt.length) + + var DK = Buffer.allocUnsafe(keylen) + var block1 = Buffer.allocUnsafe(salt.length + 4) + salt.copy(block1, 0, 0, salt.length) + + var destPos = 0 + var hLen = sizes[digest] + var l = Math.ceil(keylen / hLen) + + for (var i = 1; i <= l; i++) { + block1.writeUInt32BE(i, salt.length) + + var T = hmac.run(block1, hmac.ipad1) + var U = T + + for (var j = 1; j < iterations; j++) { + U = hmac.run(U, hmac.ipad2) + for (var k = 0; k < hLen; k++) T[k] ^= U[k] + } + + T.copy(DK, destPos) + destPos += hLen + } + + return DK + } + + module.exports = pbkdf2 + + },{"./default-encoding":349,"./precondition":350,"./to-buffer":352,"create-hash/md5":271,"ripemd160":363,"safe-buffer":364,"sha.js":367}],352:[function(require,module,exports){ + var Buffer = require('safe-buffer').Buffer + + module.exports = function (thing, encoding, name) { + if (Buffer.isBuffer(thing)) { + return thing + } else if (typeof thing === 'string') { + return Buffer.from(thing, encoding) + } else if (ArrayBuffer.isView(thing)) { + return Buffer.from(thing.buffer) + } else { + throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView') + } + } + + },{"safe-buffer":364}],353:[function(require,module,exports){ + // shim for using process in browser + var process = module.exports = {}; + + // cached from whatever global is present so that test runners that stub it + // don't break things. But we need to wrap it in a try catch in case it is + // wrapped in strict mode code which doesn't define any globals. It's inside a + // function because try/catches deoptimize in certain engines. + + var cachedSetTimeout; + var cachedClearTimeout; + + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); + } + (function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } + } ()) + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + process.prependListener = noop; + process.prependOnceListener = noop; + + process.listeners = function (name) { return [] } + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { return '/' }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function() { return 0; }; + + },{}],354:[function(require,module,exports){ + exports.publicEncrypt = require('./publicEncrypt') + exports.privateDecrypt = require('./privateDecrypt') + + exports.privateEncrypt = function privateEncrypt (key, buf) { + return exports.publicEncrypt(key, buf, true) + } + + exports.publicDecrypt = function publicDecrypt (key, buf) { + return exports.privateDecrypt(key, buf, true) + } + + },{"./privateDecrypt":357,"./publicEncrypt":358}],355:[function(require,module,exports){ + var createHash = require('create-hash') + var Buffer = require('safe-buffer').Buffer + + module.exports = function (seed, len) { + var t = Buffer.alloc(0) + var i = 0 + var c + while (t.length < len) { + c = i2ops(i++) + t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]) + } + return t.slice(0, len) + } + + function i2ops (c) { + var out = Buffer.allocUnsafe(4) + out.writeUInt32BE(c, 0) + return out + } + + },{"create-hash":270,"safe-buffer":364}],356:[function(require,module,exports){ + arguments[4][45][0].apply(exports,arguments) + },{"buffer":222,"dup":45}],357:[function(require,module,exports){ + var parseKeys = require('parse-asn1') + var mgf = require('./mgf') + var xor = require('./xor') + var BN = require('bn.js') + var crt = require('browserify-rsa') + var createHash = require('create-hash') + var withPublic = require('./withPublic') + var Buffer = require('safe-buffer').Buffer + + module.exports = function privateDecrypt (privateKey, enc, reverse) { + var padding + if (privateKey.padding) { + padding = privateKey.padding + } else if (reverse) { + padding = 1 + } else { + padding = 4 + } + + var key = parseKeys(privateKey) + var k = key.modulus.byteLength() + if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) { + throw new Error('decryption error') + } + var msg + if (reverse) { + msg = withPublic(new BN(enc), key) + } else { + msg = crt(enc, key) + } + var zBuffer = Buffer.alloc(k - msg.length) + msg = Buffer.concat([zBuffer, msg], k) + if (padding === 4) { + return oaep(key, msg) + } else if (padding === 1) { + return pkcs1(key, msg, reverse) + } else if (padding === 3) { + return msg + } else { + throw new Error('unknown padding') + } + } + + function oaep (key, msg) { + var k = key.modulus.byteLength() + var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() + var hLen = iHash.length + if (msg[0] !== 0) { + throw new Error('decryption error') + } + var maskedSeed = msg.slice(1, hLen + 1) + var maskedDb = msg.slice(hLen + 1) + var seed = xor(maskedSeed, mgf(maskedDb, hLen)) + var db = xor(maskedDb, mgf(seed, k - hLen - 1)) + if (compare(iHash, db.slice(0, hLen))) { + throw new Error('decryption error') + } + var i = hLen + while (db[i] === 0) { + i++ + } + if (db[i++] !== 1) { + throw new Error('decryption error') + } + return db.slice(i) + } + + function pkcs1 (key, msg, reverse) { + var p1 = msg.slice(0, 2) + var i = 2 + var status = 0 + while (msg[i++] !== 0) { + if (i >= msg.length) { + status++ + break + } + } + var ps = msg.slice(2, i - 1) + + if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) { + status++ + } + if (ps.length < 8) { + status++ + } + if (status) { + throw new Error('decryption error') + } + return msg.slice(i) + } + function compare (a, b) { + a = Buffer.from(a) + b = Buffer.from(b) + var dif = 0 + var len = a.length + if (a.length !== b.length) { + dif++ + len = Math.min(a.length, b.length) + } + var i = -1 + while (++i < len) { + dif += (a[i] ^ b[i]) + } + return dif + } + + },{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,"safe-buffer":364}],358:[function(require,module,exports){ + var parseKeys = require('parse-asn1') + var randomBytes = require('randombytes') + var createHash = require('create-hash') + var mgf = require('./mgf') + var xor = require('./xor') + var BN = require('bn.js') + var withPublic = require('./withPublic') + var crt = require('browserify-rsa') + var Buffer = require('safe-buffer').Buffer + + module.exports = function publicEncrypt (publicKey, msg, reverse) { + var padding + if (publicKey.padding) { + padding = publicKey.padding + } else if (reverse) { + padding = 1 + } else { + padding = 4 + } + var key = parseKeys(publicKey) + var paddedMsg + if (padding === 4) { + paddedMsg = oaep(key, msg) + } else if (padding === 1) { + paddedMsg = pkcs1(key, msg, reverse) + } else if (padding === 3) { + paddedMsg = new BN(msg) + if (paddedMsg.cmp(key.modulus) >= 0) { + throw new Error('data too long for modulus') + } + } else { + throw new Error('unknown padding') + } + if (reverse) { + return crt(paddedMsg, key) + } else { + return withPublic(paddedMsg, key) + } + } + + function oaep (key, msg) { + var k = key.modulus.byteLength() + var mLen = msg.length + var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() + var hLen = iHash.length + var hLen2 = 2 * hLen + if (mLen > k - hLen2 - 2) { + throw new Error('message too long') + } + var ps = Buffer.alloc(k - mLen - hLen2 - 2) + var dblen = k - hLen - 1 + var seed = randomBytes(hLen) + var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen)) + var maskedSeed = xor(seed, mgf(maskedDb, hLen)) + return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k)) + } + function pkcs1 (key, msg, reverse) { + var mLen = msg.length + var k = key.modulus.byteLength() + if (mLen > k - 11) { + throw new Error('message too long') + } + var ps + if (reverse) { + ps = Buffer.alloc(k - mLen - 3, 0xff) + } else { + ps = nonZero(k - mLen - 3) + } + return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k)) + } + function nonZero (len) { + var out = Buffer.allocUnsafe(len) + var i = 0 + var cache = randomBytes(len * 2) + var cur = 0 + var num + while (i < len) { + if (cur === cache.length) { + cache = randomBytes(len * 2) + cur = 0 + } + num = cache[cur++] + if (num) { + out[i++] = num + } + } + return out + } + + },{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,"randombytes":361,"safe-buffer":364}],359:[function(require,module,exports){ + var BN = require('bn.js') + var Buffer = require('safe-buffer').Buffer + + function withPublic (paddedMsg, key) { + return Buffer.from(paddedMsg + .toRed(BN.mont(key.modulus)) + .redPow(new BN(key.publicExponent)) + .fromRed() + .toArray()) + } + + module.exports = withPublic + + },{"bn.js":356,"safe-buffer":364}],360:[function(require,module,exports){ + module.exports = function xor (a, b) { + var len = a.length + var i = -1 + while (++i < len) { + a[i] ^= b[i] + } + return a + } + + },{}],361:[function(require,module,exports){ + arguments[4][105][0].apply(exports,arguments) + },{"_process":353,"dup":105,"safe-buffer":364}],362:[function(require,module,exports){ + (function (process,global){(function (){ + 'use strict' + + function oldBrowser () { + throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') + } + var safeBuffer = require('safe-buffer') + var randombytes = require('randombytes') + var Buffer = safeBuffer.Buffer + var kBufferMaxLength = safeBuffer.kMaxLength + var crypto = global.crypto || global.msCrypto + var kMaxUint32 = Math.pow(2, 32) - 1 + function assertOffset (offset, length) { + if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare + throw new TypeError('offset must be a number') + } + + if (offset > kMaxUint32 || offset < 0) { + throw new TypeError('offset must be a uint32') + } + + if (offset > kBufferMaxLength || offset > length) { + throw new RangeError('offset out of range') + } + } + + function assertSize (size, offset, length) { + if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare + throw new TypeError('size must be a number') + } + + if (size > kMaxUint32 || size < 0) { + throw new TypeError('size must be a uint32') + } + + if (size + offset > length || size > kBufferMaxLength) { + throw new RangeError('buffer too small') + } + } + if ((crypto && crypto.getRandomValues) || !process.browser) { + exports.randomFill = randomFill + exports.randomFillSync = randomFillSync + } else { + exports.randomFill = oldBrowser + exports.randomFillSync = oldBrowser + } + function randomFill (buf, offset, size, cb) { + if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array') + } + + if (typeof offset === 'function') { + cb = offset + offset = 0 + size = buf.length + } else if (typeof size === 'function') { + cb = size + size = buf.length - offset + } else if (typeof cb !== 'function') { + throw new TypeError('"cb" argument must be a function') + } + assertOffset(offset, buf.length) + assertSize(size, offset, buf.length) + return actualFill(buf, offset, size, cb) + } + + function actualFill (buf, offset, size, cb) { + if (process.browser) { + var ourBuf = buf.buffer + var uint = new Uint8Array(ourBuf, offset, size) + crypto.getRandomValues(uint) + if (cb) { + process.nextTick(function () { + cb(null, buf) + }) + return + } + return buf + } + if (cb) { + randombytes(size, function (err, bytes) { + if (err) { + return cb(err) + } + bytes.copy(buf, offset) + cb(null, buf) + }) + return + } + var bytes = randombytes(size) + bytes.copy(buf, offset) + return buf + } + function randomFillSync (buf, offset, size) { + if (typeof offset === 'undefined') { + offset = 0 + } + if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array') + } + + assertOffset(offset, buf.length) + + if (size === undefined) size = buf.length - offset + + assertSize(size, offset, buf.length) + + return actualFill(buf, offset, size) + } + + }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{"_process":353,"randombytes":361,"safe-buffer":364}],363:[function(require,module,exports){ + arguments[4][121][0].apply(exports,arguments) + },{"buffer":266,"dup":121,"hash-base":305,"inherits":335}],364:[function(require,module,exports){ + arguments[4][122][0].apply(exports,arguments) + },{"buffer":266,"dup":122}],365:[function(require,module,exports){ + arguments[4][123][0].apply(exports,arguments) + },{"_process":353,"buffer":266,"dup":123}],366:[function(require,module,exports){ + arguments[4][127][0].apply(exports,arguments) + },{"dup":127,"safe-buffer":364}],367:[function(require,module,exports){ + arguments[4][128][0].apply(exports,arguments) + },{"./sha":368,"./sha1":369,"./sha224":370,"./sha256":371,"./sha384":372,"./sha512":373,"dup":128}],368:[function(require,module,exports){ + arguments[4][129][0].apply(exports,arguments) + },{"./hash":366,"dup":129,"inherits":335,"safe-buffer":364}],369:[function(require,module,exports){ + arguments[4][130][0].apply(exports,arguments) + },{"./hash":366,"dup":130,"inherits":335,"safe-buffer":364}],370:[function(require,module,exports){ + arguments[4][131][0].apply(exports,arguments) + },{"./hash":366,"./sha256":371,"dup":131,"inherits":335,"safe-buffer":364}],371:[function(require,module,exports){ + arguments[4][132][0].apply(exports,arguments) + },{"./hash":366,"dup":132,"inherits":335,"safe-buffer":364}],372:[function(require,module,exports){ + arguments[4][133][0].apply(exports,arguments) + },{"./hash":366,"./sha512":373,"dup":133,"inherits":335,"safe-buffer":364}],373:[function(require,module,exports){ + arguments[4][134][0].apply(exports,arguments) + },{"./hash":366,"dup":134,"inherits":335,"safe-buffer":364}],374:[function(require,module,exports){ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + module.exports = Stream; + + var EE = require('events').EventEmitter; + var inherits = require('inherits'); + + inherits(Stream, EE); + Stream.Readable = require('readable-stream/lib/_stream_readable.js'); + Stream.Writable = require('readable-stream/lib/_stream_writable.js'); + Stream.Duplex = require('readable-stream/lib/_stream_duplex.js'); + Stream.Transform = require('readable-stream/lib/_stream_transform.js'); + Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js'); + Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js') + Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js') + + // Backwards-compat with node 0.4.x + Stream.Stream = Stream; + + + + // old-style streams. Note that the pipe method (the only relevant + // part of this class) is overridden in the Readable class. + + function Stream() { + EE.call(this); + } + + Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; + }; + + },{"events":303,"inherits":335,"readable-stream/lib/_stream_duplex.js":376,"readable-stream/lib/_stream_passthrough.js":377,"readable-stream/lib/_stream_readable.js":378,"readable-stream/lib/_stream_transform.js":379,"readable-stream/lib/_stream_writable.js":380,"readable-stream/lib/internal/streams/end-of-stream.js":384,"readable-stream/lib/internal/streams/pipeline.js":386}],375:[function(require,module,exports){ + arguments[4][106][0].apply(exports,arguments) + },{"dup":106}],376:[function(require,module,exports){ + arguments[4][107][0].apply(exports,arguments) + },{"./_stream_readable":378,"./_stream_writable":380,"_process":353,"dup":107,"inherits":335}],377:[function(require,module,exports){ + arguments[4][108][0].apply(exports,arguments) + },{"./_stream_transform":379,"dup":108,"inherits":335}],378:[function(require,module,exports){ + arguments[4][109][0].apply(exports,arguments) + },{"../errors":375,"./_stream_duplex":376,"./internal/streams/async_iterator":381,"./internal/streams/buffer_list":382,"./internal/streams/destroy":383,"./internal/streams/from":385,"./internal/streams/state":387,"./internal/streams/stream":388,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],379:[function(require,module,exports){ + arguments[4][110][0].apply(exports,arguments) + },{"../errors":375,"./_stream_duplex":376,"dup":110,"inherits":335}],380:[function(require,module,exports){ + arguments[4][111][0].apply(exports,arguments) + },{"../errors":375,"./_stream_duplex":376,"./internal/streams/destroy":383,"./internal/streams/state":387,"./internal/streams/stream":388,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],381:[function(require,module,exports){ + arguments[4][112][0].apply(exports,arguments) + },{"./end-of-stream":384,"_process":353,"dup":112}],382:[function(require,module,exports){ + arguments[4][113][0].apply(exports,arguments) + },{"buffer":266,"dup":113,"util":222}],383:[function(require,module,exports){ + arguments[4][114][0].apply(exports,arguments) + },{"_process":353,"dup":114}],384:[function(require,module,exports){ + arguments[4][115][0].apply(exports,arguments) + },{"../../../errors":375,"dup":115}],385:[function(require,module,exports){ + arguments[4][116][0].apply(exports,arguments) + },{"dup":116}],386:[function(require,module,exports){ + arguments[4][117][0].apply(exports,arguments) + },{"../../../errors":375,"./end-of-stream":384,"dup":117}],387:[function(require,module,exports){ + arguments[4][118][0].apply(exports,arguments) + },{"../../../errors":375,"dup":118}],388:[function(require,module,exports){ + arguments[4][119][0].apply(exports,arguments) + },{"dup":119,"events":303}],389:[function(require,module,exports){ + arguments[4][135][0].apply(exports,arguments) + },{"dup":135,"safe-buffer":364}],390:[function(require,module,exports){ + arguments[4][179][0].apply(exports,arguments) + },{"dup":179}]},{},[181])(181) + }); + \ No newline at end of file From 569dbc2e0ad879345e039b5538f8bf60f7d95875 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Sun, 18 Jul 2021 17:25:23 +0100 Subject: [PATCH 10/22] extension wip --- .../pages/bounty_detail/casper_extension.js | 52 +++++++++++++++++-- app/dashboard/templates/bounty/details2.html | 3 +- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 392d1499abf..2b2bb73f459 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -2,10 +2,56 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const amount = vm.fulfillment_context.amount; const token_name = vm.bounty.token_name; + + const { CasperClient, DeployUtil, PublicKey, Signer } = casper; + const casperClient = new CasperClient('http://3.142.224.108:7777/rpc'); + + const isConnected = await Signer.isConnected(); + + if (!isConnected) { + try { + Signer.sendConnectionRequest(); + } catch (e) { + _alert({ message: gettext('Please download or enable CasperLabs Signer extension.') }, 'danger'); + } + } + + const selectedAddress = await Signer.getActivePublicKey(); + + const paymentAmount = 10000; + const id = fulfillment_id; + const ttl = 1800000; + const fromPublicKey = PublicKey.fromHex(selectedAddress); + const toPublicKey = PublicKey.fromHex(to_address); - let selectedAddress; - - console.log(casper); + let deployParams = new DeployUtil.DeployParams(fromPublicKey, 'casper', ttl); + + const session = DeployUtil.ExecutableDeployItem.newTransfer( + amount * 10 ** vm.decimals, + toPublicKey, + fromPublicKey, + id + ); + + const payment = DeployUtil.standardPayment(paymentAmount); + const deploy = DeployUtil.makeDeploy(deployParams, session, payment); + + console.log(deploy); + + const signedDeploy = await Signer.sign(deploy, fromPublicKey, toPublicKey); + + console.log(signedDeploy); + + try { + const txHash = await casperClient.putDeploy(signedDeploy); + + console.log(txHash); + // callback(null, selectedAddress, txHash); + } catch (e) { + modal.closeModal(); + _alert({ message: `${e.title} - ${e.description}` }, 'danger'); + console.log(e); + } function callback(error, from_address, txn) { if (error) { diff --git a/app/dashboard/templates/bounty/details2.html b/app/dashboard/templates/bounty/details2.html index 8d9be726e84..90d65fc81b8 100644 --- a/app/dashboard/templates/bounty/details2.html +++ b/app/dashboard/templates/bounty/details2.html @@ -1159,7 +1159,8 @@

{{ noscript.keywords }}

{% elif web3_type == 'casper_ext' %} - + + {% elif web3_type == 'fiat' %} From 4907b8079949d47cc7e3fe4bdccb5fb1f73d8535 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Sun, 18 Jul 2021 22:59:11 +0100 Subject: [PATCH 11/22] validate cspr addresses --- app/assets/v2/js/pages/new_bounty.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index 5be0d117d73..576307aceeb 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -161,6 +161,16 @@ Vue.mixin({ break; } + case '270895': { + // casper + let addr = vm.form.funderAddress; + + if (!addr.toLowerCase().startsWith('01') && !addr.toLowerCase().startsWith('02')) { + isValid = false; + } + break; + } + // include validation for other chains here } From b5802659038e009af1641331a6bdd20507bc2ab5 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Mon, 19 Jul 2021 11:50:39 +0100 Subject: [PATCH 12/22] add address + tx urls --- app/assets/v2/js/pages/bounty_details2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/v2/js/pages/bounty_details2.js b/app/assets/v2/js/pages/bounty_details2.js index 71a565bfe2d..b924dc68ef7 100644 --- a/app/assets/v2/js/pages/bounty_details2.js +++ b/app/assets/v2/js/pages/bounty_details2.js @@ -166,6 +166,10 @@ Vue.mixin({ url = `https://tzkt.io/${txn}`; break; + case 'CSPR': + url = `https://casperstats.io/tx/${txn}`; + break; + default: url = `https://etherscan.io/tx/${txn}`; @@ -244,6 +248,10 @@ Vue.mixin({ url = `https://tzkt.io/${address}/operations/`; break; + case 'CSPR': + url = `https://casperstats.io/address/${address}`; + break; + default: url = `https://etherscan.io/address/${address}`; } From 25afd209706849b033618b784163b14a35118169 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Mon, 19 Jul 2021 11:56:59 +0100 Subject: [PATCH 13/22] finish casper extension --- .../v2/js/pages/bounty_detail/casper_extension.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 2b2bb73f459..2e62451bbbd 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -36,21 +36,15 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const payment = DeployUtil.standardPayment(paymentAmount); const deploy = DeployUtil.makeDeploy(deployParams, session, payment); - console.log(deploy); - const signedDeploy = await Signer.sign(deploy, fromPublicKey, toPublicKey); - console.log(signedDeploy); - try { - const txHash = await casperClient.putDeploy(signedDeploy); + const deployHash = await casperClient.putDeploy(signedDeploy); - console.log(txHash); - // callback(null, selectedAddress, txHash); + callback(null, selectedAddress, deployHash); } catch (e) { modal.closeModal(); - _alert({ message: `${e.title} - ${e.description}` }, 'danger'); - console.log(e); + callback(err); } function callback(error, from_address, txn) { From 63f721aeee0f6ddd158db58419ae1247ba5761d0 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Mon, 19 Jul 2021 12:00:51 +0100 Subject: [PATCH 14/22] minify svg & js sdk --- app/assets/v2/images/chains/casper.svg | 60 +- app/assets/v2/js/lib/casper/casper_js_sdk.js | 45845 +---------------- 2 files changed, 2 insertions(+), 45903 deletions(-) diff --git a/app/assets/v2/images/chains/casper.svg b/app/assets/v2/images/chains/casper.svg index f933898a830..2b7301558a4 100644 --- a/app/assets/v2/images/chains/casper.svg +++ b/app/assets/v2/images/chains/casper.svg @@ -1,59 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/app/assets/v2/js/lib/casper/casper_js_sdk.js b/app/assets/v2/js/lib/casper/casper_js_sdk.js index f138ed99920..fc647d386c6 100644 --- a/app/assets/v2/js/lib/casper/casper_js_sdk.js +++ b/app/assets/v2/js/lib/casper/casper_js_sdk.js @@ -1,45844 +1 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.casper = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { - if (arguments[0] === 10) { - if (!_warnedToStringRadix) { - _warnedToStringRadix = true; - logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); - } - } - else if (arguments[0] === 16) { - logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } - else { - logger.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } - } - return toBN(this).toString(10); - }; - BigNumber.prototype.toHexString = function () { - return this._hex; - }; - BigNumber.prototype.toJSON = function (key) { - return { type: "BigNumber", hex: this.toHexString() }; - }; - BigNumber.from = function (value) { - if (value instanceof BigNumber) { - return value; - } - if (typeof (value) === "string") { - if (value.match(/^-?0x[0-9a-f]+$/i)) { - return new BigNumber(_constructorGuard, toHex(value)); - } - if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN(value))); - } - return logger.throwArgumentError("invalid BigNumber string", "value", value); - } - if (typeof (value) === "number") { - if (value % 1) { - throwFault("underflow", "BigNumber.from", value); - } - if (value >= MAX_SAFE || value <= -MAX_SAFE) { - throwFault("overflow", "BigNumber.from", value); - } - return BigNumber.from(String(value)); - } - var anyValue = value; - if (typeof (anyValue) === "bigint") { - return BigNumber.from(anyValue.toString()); - } - if (bytes_1.isBytes(anyValue)) { - return BigNumber.from(bytes_1.hexlify(anyValue)); - } - if (anyValue) { - // Hexable interface (takes piority) - if (anyValue.toHexString) { - var hex = anyValue.toHexString(); - if (typeof (hex) === "string") { - return BigNumber.from(hex); - } - } - else { - // For now, handle legacy JSON-ified values (goes away in v6) - var hex = anyValue._hex; - // New-form JSON - if (hex == null && anyValue.type === "BigNumber") { - hex = anyValue.hex; - } - if (typeof (hex) === "string") { - if (bytes_1.isHexString(hex) || (hex[0] === "-" && bytes_1.isHexString(hex.substring(1)))) { - return BigNumber.from(hex); - } - } - } - } - return logger.throwArgumentError("invalid BigNumber value", "value", value); - }; - BigNumber.isBigNumber = function (value) { - return !!(value && value._isBigNumber); - }; - return BigNumber; - }()); - exports.BigNumber = BigNumber; - // Normalize the hex string - function toHex(value) { - // For BN, call on the hex string - if (typeof (value) !== "string") { - return toHex(value.toString(16)); - } - // If negative, prepend the negative sign to the normalized positive value - if (value[0] === "-") { - // Strip off the negative sign - value = value.substring(1); - // Cannot have mulitple negative signs (e.g. "--0x04") - if (value[0] === "-") { - logger.throwArgumentError("invalid hex", "value", value); - } - // Call toHex on the positive component - value = toHex(value); - // Do not allow "-0x00" - if (value === "0x00") { - return value; - } - // Negate the value - return "-" + value; - } - // Add a "0x" prefix if missing - if (value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - // Normalize zero - if (value === "0x") { - return "0x00"; - } - // Make the string even length - if (value.length % 2) { - value = "0x0" + value.substring(2); - } - // Trim to smallest even-length string - while (value.length > 4 && value.substring(0, 4) === "0x00") { - value = "0x" + value.substring(4); - } - return value; - } - function toBigNumber(value) { - return BigNumber.from(toHex(value)); - } - function toBN(value) { - var hex = BigNumber.from(value).toHexString(); - if (hex[0] === "-") { - return (new BN("-" + hex.substring(3), 16)); - } - return new BN(hex.substring(2), 16); - } - function throwFault(fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value != null) { - params.value = value; - } - return logger.throwError(fault, logger_1.Logger.errors.NUMERIC_FAULT, params); - } - // value should have no prefix - function _base36To16(value) { - return (new BN(value, 36)).toString(16); - } - exports._base36To16 = _base36To16; - // value should have no prefix - function _base16To36(value) { - return (new BN(value, 16)).toString(36); - } - exports._base16To36 = _base16To36; - - },{"./_version":1,"@ethersproject/bytes":6,"@ethersproject/logger":13,"bn.js":45}],3:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.FixedNumber = exports.FixedFormat = exports.parseFixed = exports.formatFixed = void 0; - var bytes_1 = require("@ethersproject/bytes"); - var logger_1 = require("@ethersproject/logger"); - var _version_1 = require("./_version"); - var logger = new logger_1.Logger(_version_1.version); - var bignumber_1 = require("./bignumber"); - var _constructorGuard = {}; - var Zero = bignumber_1.BigNumber.from(0); - var NegativeOne = bignumber_1.BigNumber.from(-1); - function throwFault(message, fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value !== undefined) { - params.value = value; - } - return logger.throwError(message, logger_1.Logger.errors.NUMERIC_FAULT, params); - } - // Constant to pull zeros from for multipliers - var zeros = "0"; - while (zeros.length < 256) { - zeros += zeros; - } - // Returns a string "1" followed by decimal "0"s - function getMultiplier(decimals) { - if (typeof (decimals) !== "number") { - try { - decimals = bignumber_1.BigNumber.from(decimals).toNumber(); - } - catch (e) { } - } - if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { - return ("1" + zeros.substring(0, decimals)); - } - return logger.throwArgumentError("invalid decimal size", "decimals", decimals); - } - function formatFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - // Make sure wei is a big number (convert as necessary) - value = bignumber_1.BigNumber.from(value); - var negative = value.lt(Zero); - if (negative) { - value = value.mul(NegativeOne); - } - var fraction = value.mod(multiplier).toString(); - while (fraction.length < multiplier.length - 1) { - fraction = "0" + fraction; - } - // Strip training 0 - fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; - var whole = value.div(multiplier).toString(); - value = whole + "." + fraction; - if (negative) { - value = "-" + value; - } - return value; - } - exports.formatFixed = formatFixed; - function parseFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { - logger.throwArgumentError("invalid decimal value", "value", value); - } - if (multiplier.length - 1 === 0) { - return bignumber_1.BigNumber.from(value); - } - // Is it negative? - var negative = (value.substring(0, 1) === "-"); - if (negative) { - value = value.substring(1); - } - if (value === ".") { - logger.throwArgumentError("missing value", "value", value); - } - // Split it into a whole and fractional part - var comps = value.split("."); - if (comps.length > 2) { - logger.throwArgumentError("too many decimal points", "value", value); - } - var whole = comps[0], fraction = comps[1]; - if (!whole) { - whole = "0"; - } - if (!fraction) { - fraction = "0"; - } - // Prevent underflow - if (fraction.length > multiplier.length - 1) { - throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); - } - // Fully pad the string with zeros to get to wei - while (fraction.length < multiplier.length - 1) { - fraction += "0"; - } - var wholeValue = bignumber_1.BigNumber.from(whole); - var fractionValue = bignumber_1.BigNumber.from(fraction); - var wei = (wholeValue.mul(multiplier)).add(fractionValue); - if (negative) { - wei = wei.mul(NegativeOne); - } - return wei; - } - exports.parseFixed = parseFixed; - var FixedFormat = /** @class */ (function () { - function FixedFormat(constructorGuard, signed, width, decimals) { - if (constructorGuard !== _constructorGuard) { - logger.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new FixedFormat" - }); - } - this.signed = signed; - this.width = width; - this.decimals = decimals; - this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); - this._multiplier = getMultiplier(decimals); - Object.freeze(this); - } - FixedFormat.from = function (value) { - if (value instanceof FixedFormat) { - return value; - } - var signed = true; - var width = 128; - var decimals = 18; - if (typeof (value) === "string") { - if (value === "fixed") { - // defaults... - } - else if (value === "ufixed") { - signed = false; - } - else if (value != null) { - var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); - if (!match) { - logger.throwArgumentError("invalid fixed format", "format", value); - } - signed = (match[1] !== "u"); - width = parseInt(match[2]); - decimals = parseInt(match[3]); - } - } - else if (value) { - var check = function (key, type, defaultValue) { - if (value[key] == null) { - return defaultValue; - } - if (typeof (value[key]) !== type) { - logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); - } - return value[key]; - }; - signed = check("signed", "boolean", signed); - width = check("width", "number", width); - decimals = check("decimals", "number", decimals); - } - if (width % 8) { - logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); - } - if (decimals > 80) { - logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); - } - return new FixedFormat(_constructorGuard, signed, width, decimals); - }; - return FixedFormat; - }()); - exports.FixedFormat = FixedFormat; - var FixedNumber = /** @class */ (function () { - function FixedNumber(constructorGuard, hex, value, format) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, FixedNumber); - if (constructorGuard !== _constructorGuard) { - logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new FixedFormat" - }); - } - this.format = format; - this._hex = hex; - this._value = value; - this._isFixedNumber = true; - Object.freeze(this); - } - FixedNumber.prototype._checkFormat = function (other) { - if (this.format.name !== other.format.name) { - logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); - } - }; - FixedNumber.prototype.addUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.subUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.mulUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); - }; - FixedNumber.prototype.divUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.floor = function () { - var comps = this.toString().split("."); - var result = FixedNumber.from(comps[0], this.format); - var hasFraction = !comps[1].match(/^(0*)$/); - if (this.isNegative() && hasFraction) { - result = result.subUnsafe(ONE); - } - return result; - }; - FixedNumber.prototype.ceiling = function () { - var comps = this.toString().split("."); - var result = FixedNumber.from(comps[0], this.format); - var hasFraction = !comps[1].match(/^(0*)$/); - if (!this.isNegative() && hasFraction) { - result = result.addUnsafe(ONE); - } - return result; - }; - // @TODO: Support other rounding algorithms - FixedNumber.prototype.round = function (decimals) { - if (decimals == null) { - decimals = 0; - } - // If we are already in range, we're done - var comps = this.toString().split("."); - if (decimals < 0 || decimals > 80 || (decimals % 1)) { - logger.throwArgumentError("invalid decimal count", "decimals", decimals); - } - if (comps[1].length <= decimals) { - return this; - } - var factor = FixedNumber.from("1" + zeros.substring(0, decimals)); - return this.mulUnsafe(factor).addUnsafe(BUMP).floor().divUnsafe(factor); - }; - FixedNumber.prototype.isZero = function () { - return (this._value === "0.0"); - }; - FixedNumber.prototype.isNegative = function () { - return (this._value[0] === "-"); - }; - FixedNumber.prototype.toString = function () { return this._value; }; - FixedNumber.prototype.toHexString = function (width) { - if (width == null) { - return this._hex; - } - if (width % 8) { - logger.throwArgumentError("invalid byte width", "width", width); - } - var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); - return bytes_1.hexZeroPad(hex, width / 8); - }; - FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; - FixedNumber.prototype.toFormat = function (format) { - return FixedNumber.fromString(this._value, format); - }; - FixedNumber.fromValue = function (value, decimals, format) { - // If decimals looks more like a format, and there is no format, shift the parameters - if (format == null && decimals != null && !bignumber_1.isBigNumberish(decimals)) { - format = decimals; - decimals = null; - } - if (decimals == null) { - decimals = 0; - } - if (format == null) { - format = "fixed"; - } - return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); - }; - FixedNumber.fromString = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - var numeric = parseFixed(value, fixedFormat.decimals); - if (!fixedFormat.signed && numeric.lt(Zero)) { - throwFault("unsigned value cannot be negative", "overflow", "value", value); - } - var hex = null; - if (fixedFormat.signed) { - hex = numeric.toTwos(fixedFormat.width).toHexString(); - } - else { - hex = numeric.toHexString(); - hex = bytes_1.hexZeroPad(hex, fixedFormat.width / 8); - } - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.fromBytes = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - if (bytes_1.arrayify(value).length > fixedFormat.width / 8) { - throw new Error("overflow"); - } - var numeric = bignumber_1.BigNumber.from(value); - if (fixedFormat.signed) { - numeric = numeric.fromTwos(fixedFormat.width); - } - var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.from = function (value, format) { - if (typeof (value) === "string") { - return FixedNumber.fromString(value, format); - } - if (bytes_1.isBytes(value)) { - return FixedNumber.fromBytes(value, format); - } - try { - return FixedNumber.fromValue(value, 0, format); - } - catch (error) { - // Allow NUMERIC_FAULT to bubble up - if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) { - throw error; - } - } - return logger.throwArgumentError("invalid FixedNumber value", "value", value); - }; - FixedNumber.isFixedNumber = function (value) { - return !!(value && value._isFixedNumber); - }; - return FixedNumber; - }()); - exports.FixedNumber = FixedNumber; - var ONE = FixedNumber.from(1); - var BUMP = FixedNumber.from("0.5"); - - },{"./_version":1,"./bignumber":2,"@ethersproject/bytes":6,"@ethersproject/logger":13}],4:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports._base36To16 = exports._base16To36 = exports.parseFixed = exports.FixedNumber = exports.FixedFormat = exports.formatFixed = exports.BigNumber = void 0; - var bignumber_1 = require("./bignumber"); - Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } }); - var fixednumber_1 = require("./fixednumber"); - Object.defineProperty(exports, "formatFixed", { enumerable: true, get: function () { return fixednumber_1.formatFixed; } }); - Object.defineProperty(exports, "FixedFormat", { enumerable: true, get: function () { return fixednumber_1.FixedFormat; } }); - Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return fixednumber_1.FixedNumber; } }); - Object.defineProperty(exports, "parseFixed", { enumerable: true, get: function () { return fixednumber_1.parseFixed; } }); - // Internal methods used by address - var bignumber_2 = require("./bignumber"); - Object.defineProperty(exports, "_base16To36", { enumerable: true, get: function () { return bignumber_2._base16To36; } }); - Object.defineProperty(exports, "_base36To16", { enumerable: true, get: function () { return bignumber_2._base36To16; } }); - - },{"./bignumber":2,"./fixednumber":3}],5:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = void 0; - exports.version = "bytes/5.1.0"; - - },{}],6:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.joinSignature = exports.splitSignature = exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = void 0; - var logger_1 = require("@ethersproject/logger"); - var _version_1 = require("./_version"); - var logger = new logger_1.Logger(_version_1.version); - /////////////////////////////// - function isHexable(value) { - return !!(value.toHexString); - } - function addSlice(array) { - if (array.slice) { - return array; - } - array.slice = function () { - var args = Array.prototype.slice.call(arguments); - return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); - }; - return array; - } - function isBytesLike(value) { - return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); - } - exports.isBytesLike = isBytesLike; - function isBytes(value) { - if (value == null) { - return false; - } - if (value.constructor === Uint8Array) { - return true; - } - if (typeof (value) === "string") { - return false; - } - if (value.length == null) { - return false; - } - for (var i = 0; i < value.length; i++) { - var v = value[i]; - if (typeof (v) !== "number" || v < 0 || v >= 256 || (v % 1)) { - return false; - } - } - return true; - } - exports.isBytes = isBytes; - function arrayify(value, options) { - if (!options) { - options = {}; - } - if (typeof (value) === "number") { - logger.checkSafeUint53(value, "invalid arrayify value"); - var result = []; - while (value) { - result.unshift(value & 0xff); - value = parseInt(String(value / 256)); - } - if (result.length === 0) { - result.push(0); - } - return addSlice(new Uint8Array(result)); - } - if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if (isHexable(value)) { - value = value.toHexString(); - } - if (isHexString(value)) { - var hex = value.substring(2); - if (hex.length % 2) { - if (options.hexPad === "left") { - hex = "0x0" + hex.substring(2); - } - else if (options.hexPad === "right") { - hex += "0"; - } - else { - logger.throwArgumentError("hex data is odd-length", "value", value); - } - } - var result = []; - for (var i = 0; i < hex.length; i += 2) { - result.push(parseInt(hex.substring(i, i + 2), 16)); - } - return addSlice(new Uint8Array(result)); - } - if (isBytes(value)) { - return addSlice(new Uint8Array(value)); - } - return logger.throwArgumentError("invalid arrayify value", "value", value); - } - exports.arrayify = arrayify; - function concat(items) { - var objects = items.map(function (item) { return arrayify(item); }); - var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0); - var result = new Uint8Array(length); - objects.reduce(function (offset, object) { - result.set(object, offset); - return offset + object.length; - }, 0); - return addSlice(result); - } - exports.concat = concat; - function stripZeros(value) { - var result = arrayify(value); - if (result.length === 0) { - return result; - } - // Find the first non-zero entry - var start = 0; - while (start < result.length && result[start] === 0) { - start++; - } - // If we started with zeros, strip them - if (start) { - result = result.slice(start); - } - return result; - } - exports.stripZeros = stripZeros; - function zeroPad(value, length) { - value = arrayify(value); - if (value.length > length) { - logger.throwArgumentError("value out of range", "value", arguments[0]); - } - var result = new Uint8Array(length); - result.set(value, length - value.length); - return addSlice(result); - } - exports.zeroPad = zeroPad; - function isHexString(value, length) { - if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { - return false; - } - if (length && value.length !== 2 + 2 * length) { - return false; - } - return true; - } - exports.isHexString = isHexString; - var HexCharacters = "0123456789abcdef"; - function hexlify(value, options) { - if (!options) { - options = {}; - } - if (typeof (value) === "number") { - logger.checkSafeUint53(value, "invalid hexlify value"); - var hex = ""; - while (value) { - hex = HexCharacters[value & 0x0f] + hex; - value = Math.floor(value / 16); - } - if (hex.length) { - if (hex.length % 2) { - hex = "0" + hex; - } - return "0x" + hex; - } - return "0x00"; - } - if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if (isHexable(value)) { - return value.toHexString(); - } - if (isHexString(value)) { - if (value.length % 2) { - if (options.hexPad === "left") { - value = "0x0" + value.substring(2); - } - else if (options.hexPad === "right") { - value += "0"; - } - else { - logger.throwArgumentError("hex data is odd-length", "value", value); - } - } - return value.toLowerCase(); - } - if (isBytes(value)) { - var result = "0x"; - for (var i = 0; i < value.length; i++) { - var v = value[i]; - result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; - } - return result; - } - return logger.throwArgumentError("invalid hexlify value", "value", value); - } - exports.hexlify = hexlify; - /* - function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { - if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { - return "0x0" + value.substring(2); - } - return value; - } - */ - function hexDataLength(data) { - if (typeof (data) !== "string") { - data = hexlify(data); - } - else if (!isHexString(data) || (data.length % 2)) { - return null; - } - return (data.length - 2) / 2; - } - exports.hexDataLength = hexDataLength; - function hexDataSlice(data, offset, endOffset) { - if (typeof (data) !== "string") { - data = hexlify(data); - } - else if (!isHexString(data) || (data.length % 2)) { - logger.throwArgumentError("invalid hexData", "value", data); - } - offset = 2 + 2 * offset; - if (endOffset != null) { - return "0x" + data.substring(offset, 2 + 2 * endOffset); - } - return "0x" + data.substring(offset); - } - exports.hexDataSlice = hexDataSlice; - function hexConcat(items) { - var result = "0x"; - items.forEach(function (item) { - result += hexlify(item).substring(2); - }); - return result; - } - exports.hexConcat = hexConcat; - function hexValue(value) { - var trimmed = hexStripZeros(hexlify(value, { hexPad: "left" })); - if (trimmed === "0x") { - return "0x0"; - } - return trimmed; - } - exports.hexValue = hexValue; - function hexStripZeros(value) { - if (typeof (value) !== "string") { - value = hexlify(value); - } - if (!isHexString(value)) { - logger.throwArgumentError("invalid hex string", "value", value); - } - value = value.substring(2); - var offset = 0; - while (offset < value.length && value[offset] === "0") { - offset++; - } - return "0x" + value.substring(offset); - } - exports.hexStripZeros = hexStripZeros; - function hexZeroPad(value, length) { - if (typeof (value) !== "string") { - value = hexlify(value); - } - else if (!isHexString(value)) { - logger.throwArgumentError("invalid hex string", "value", value); - } - if (value.length > 2 * length + 2) { - logger.throwArgumentError("value out of range", "value", arguments[1]); - } - while (value.length < 2 * length + 2) { - value = "0x0" + value.substring(2); - } - return value; - } - exports.hexZeroPad = hexZeroPad; - function splitSignature(signature) { - var result = { - r: "0x", - s: "0x", - _vs: "0x", - recoveryParam: 0, - v: 0 - }; - if (isBytesLike(signature)) { - var bytes = arrayify(signature); - if (bytes.length !== 65) { - logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); - } - // Get the r, s and v - result.r = hexlify(bytes.slice(0, 32)); - result.s = hexlify(bytes.slice(32, 64)); - result.v = bytes[64]; - // Allow a recid to be used as the v - if (result.v < 27) { - if (result.v === 0 || result.v === 1) { - result.v += 27; - } - else { - logger.throwArgumentError("signature invalid v byte", "signature", signature); - } - } - // Compute recoveryParam from v - result.recoveryParam = 1 - (result.v % 2); - // Compute _vs from recoveryParam and s - if (result.recoveryParam) { - bytes[32] |= 0x80; - } - result._vs = hexlify(bytes.slice(32, 64)); - } - else { - result.r = signature.r; - result.s = signature.s; - result.v = signature.v; - result.recoveryParam = signature.recoveryParam; - result._vs = signature._vs; - // If the _vs is available, use it to populate missing s, v and recoveryParam - // and verify non-missing s, v and recoveryParam - if (result._vs != null) { - var vs_1 = zeroPad(arrayify(result._vs), 32); - result._vs = hexlify(vs_1); - // Set or check the recid - var recoveryParam = ((vs_1[0] >= 128) ? 1 : 0); - if (result.recoveryParam == null) { - result.recoveryParam = recoveryParam; - } - else if (result.recoveryParam !== recoveryParam) { - logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); - } - // Set or check the s - vs_1[0] &= 0x7f; - var s = hexlify(vs_1); - if (result.s == null) { - result.s = s; - } - else if (result.s !== s) { - logger.throwArgumentError("signature v mismatch _vs", "signature", signature); - } - } - // Use recid and v to populate each other - if (result.recoveryParam == null) { - if (result.v == null) { - logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature); - } - else if (result.v === 0 || result.v === 1) { - result.recoveryParam = result.v; - } - else { - result.recoveryParam = 1 - (result.v % 2); - } - } - else { - if (result.v == null) { - result.v = 27 + result.recoveryParam; - } - else if (result.recoveryParam !== (1 - (result.v % 2))) { - logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature); - } - } - if (result.r == null || !isHexString(result.r)) { - logger.throwArgumentError("signature missing or invalid r", "signature", signature); - } - else { - result.r = hexZeroPad(result.r, 32); - } - if (result.s == null || !isHexString(result.s)) { - logger.throwArgumentError("signature missing or invalid s", "signature", signature); - } - else { - result.s = hexZeroPad(result.s, 32); - } - var vs = arrayify(result.s); - if (vs[0] >= 128) { - logger.throwArgumentError("signature s out of range", "signature", signature); - } - if (result.recoveryParam) { - vs[0] |= 0x80; - } - var _vs = hexlify(vs); - if (result._vs) { - if (!isHexString(result._vs)) { - logger.throwArgumentError("signature invalid _vs", "signature", signature); - } - result._vs = hexZeroPad(result._vs, 32); - } - // Set or check the _vs - if (result._vs == null) { - result._vs = _vs; - } - else if (result._vs !== _vs) { - logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature); - } - } - return result; - } - exports.splitSignature = splitSignature; - function joinSignature(signature) { - signature = splitSignature(signature); - return hexlify(concat([ - signature.r, - signature.s, - (signature.recoveryParam ? "0x1c" : "0x1b") - ])); - } - exports.joinSignature = joinSignature; - - },{"./_version":5,"@ethersproject/logger":13}],7:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.AddressZero = void 0; - exports.AddressZero = "0x0000000000000000000000000000000000000000"; - - },{}],8:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = void 0; - var bignumber_1 = require("@ethersproject/bignumber"); - var NegativeOne = ( /*#__PURE__*/bignumber_1.BigNumber.from(-1)); - exports.NegativeOne = NegativeOne; - var Zero = ( /*#__PURE__*/bignumber_1.BigNumber.from(0)); - exports.Zero = Zero; - var One = ( /*#__PURE__*/bignumber_1.BigNumber.from(1)); - exports.One = One; - var Two = ( /*#__PURE__*/bignumber_1.BigNumber.from(2)); - exports.Two = Two; - var WeiPerEther = ( /*#__PURE__*/bignumber_1.BigNumber.from("1000000000000000000")); - exports.WeiPerEther = WeiPerEther; - var MaxUint256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); - exports.MaxUint256 = MaxUint256; - - },{"@ethersproject/bignumber":4}],9:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.HashZero = void 0; - exports.HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; - - },{}],10:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.EtherSymbol = exports.HashZero = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.AddressZero = void 0; - var addresses_1 = require("./addresses"); - Object.defineProperty(exports, "AddressZero", { enumerable: true, get: function () { return addresses_1.AddressZero; } }); - var bignumbers_1 = require("./bignumbers"); - Object.defineProperty(exports, "NegativeOne", { enumerable: true, get: function () { return bignumbers_1.NegativeOne; } }); - Object.defineProperty(exports, "Zero", { enumerable: true, get: function () { return bignumbers_1.Zero; } }); - Object.defineProperty(exports, "One", { enumerable: true, get: function () { return bignumbers_1.One; } }); - Object.defineProperty(exports, "Two", { enumerable: true, get: function () { return bignumbers_1.Two; } }); - Object.defineProperty(exports, "WeiPerEther", { enumerable: true, get: function () { return bignumbers_1.WeiPerEther; } }); - Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return bignumbers_1.MaxUint256; } }); - var hashes_1 = require("./hashes"); - Object.defineProperty(exports, "HashZero", { enumerable: true, get: function () { return hashes_1.HashZero; } }); - var strings_1 = require("./strings"); - Object.defineProperty(exports, "EtherSymbol", { enumerable: true, get: function () { return strings_1.EtherSymbol; } }); - - },{"./addresses":7,"./bignumbers":8,"./hashes":9,"./strings":11}],11:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.EtherSymbol = void 0; - // NFKC (composed) // (decomposed) - exports.EtherSymbol = "\u039e"; // "\uD835\uDF63"; - - },{}],12:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = void 0; - exports.version = "logger/5.1.0"; - - },{}],13:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Logger = exports.ErrorCode = exports.LogLevel = void 0; - var _permanentCensorErrors = false; - var _censorErrors = false; - var LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 }; - var _logLevel = LogLevels["default"]; - var _version_1 = require("./_version"); - var _globalLogger = null; - function _checkNormalize() { - try { - var missing_1 = []; - // Make sure all forms of normalization are supported - ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) { - try { - if ("test".normalize(form) !== "test") { - throw new Error("bad normalize"); - } - ; - } - catch (error) { - missing_1.push(form); - } - }); - if (missing_1.length) { - throw new Error("missing " + missing_1.join(", ")); - } - if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { - throw new Error("broken implementation"); - } - } - catch (error) { - return error.message; - } - return null; - } - var _normalizeError = _checkNormalize(); - var LogLevel; - (function (LogLevel) { - LogLevel["DEBUG"] = "DEBUG"; - LogLevel["INFO"] = "INFO"; - LogLevel["WARNING"] = "WARNING"; - LogLevel["ERROR"] = "ERROR"; - LogLevel["OFF"] = "OFF"; - })(LogLevel = exports.LogLevel || (exports.LogLevel = {})); - var ErrorCode; - (function (ErrorCode) { - /////////////////// - // Generic Errors - // Unknown Error - ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR"; - // Not Implemented - ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; - // Unsupported Operation - // - operation - ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION"; - // Network Error (i.e. Ethereum Network, such as an invalid chain ID) - // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown) - ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR"; - // Some sort of bad response from the server - ErrorCode["SERVER_ERROR"] = "SERVER_ERROR"; - // Timeout - ErrorCode["TIMEOUT"] = "TIMEOUT"; - /////////////////// - // Operational Errors - // Buffer Overrun - ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN"; - // Numeric Fault - // - operation: the operation being executed - // - fault: the reason this faulted - ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT"; - /////////////////// - // Argument Errors - // Missing new operator to an object - // - name: The name of the class - ErrorCode["MISSING_NEW"] = "MISSING_NEW"; - // Invalid argument (e.g. value is incompatible with type) to a function: - // - argument: The argument name that was invalid - // - value: The value of the argument - ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT"; - // Missing argument to a function: - // - count: The number of arguments received - // - expectedCount: The number of arguments expected - ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT"; - // Too many arguments - // - count: The number of arguments received - // - expectedCount: The number of arguments expected - ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT"; - /////////////////// - // Blockchain Errors - // Call exception - // - transaction: the transaction - // - address?: the contract address - // - args?: The arguments passed into the function - // - method?: The Solidity method signature - // - errorSignature?: The EIP848 error signature - // - errorArgs?: The EIP848 error parameters - // - reason: The reason (only for EIP848 "Error(string)") - ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION"; - // Insufficien funds (< value + gasLimit * gasPrice) - // - transaction: the transaction attempted - ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS"; - // Nonce has already been used - // - transaction: the transaction attempted - ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED"; - // The replacement fee for the transaction is too low - // - transaction: the transaction attempted - ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED"; - // The gas limit could not be estimated - // - transaction: the transaction passed to estimateGas - ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT"; - })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {})); - ; - var Logger = /** @class */ (function () { - function Logger(version) { - Object.defineProperty(this, "version", { - enumerable: true, - value: version, - writable: false - }); - } - Logger.prototype._log = function (logLevel, args) { - var level = logLevel.toLowerCase(); - if (LogLevels[level] == null) { - this.throwArgumentError("invalid log level name", "logLevel", logLevel); - } - if (_logLevel > LogLevels[level]) { - return; - } - console.log.apply(console, args); - }; - Logger.prototype.debug = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.DEBUG, args); - }; - Logger.prototype.info = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.INFO, args); - }; - Logger.prototype.warn = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.WARNING, args); - }; - Logger.prototype.makeError = function (message, code, params) { - // Errors are being censored - if (_censorErrors) { - return this.makeError("censored error", code, {}); - } - if (!code) { - code = Logger.errors.UNKNOWN_ERROR; - } - if (!params) { - params = {}; - } - var messageDetails = []; - Object.keys(params).forEach(function (key) { - try { - messageDetails.push(key + "=" + JSON.stringify(params[key])); - } - catch (error) { - messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); - } - }); - messageDetails.push("code=" + code); - messageDetails.push("version=" + this.version); - var reason = message; - if (messageDetails.length) { - message += " (" + messageDetails.join(", ") + ")"; - } - // @TODO: Any?? - var error = new Error(message); - error.reason = reason; - error.code = code; - Object.keys(params).forEach(function (key) { - error[key] = params[key]; - }); - return error; - }; - Logger.prototype.throwError = function (message, code, params) { - throw this.makeError(message, code, params); - }; - Logger.prototype.throwArgumentError = function (message, name, value) { - return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { - argument: name, - value: value - }); - }; - Logger.prototype.assert = function (condition, message, code, params) { - if (!!condition) { - return; - } - this.throwError(message, code, params); - }; - Logger.prototype.assertArgument = function (condition, message, name, value) { - if (!!condition) { - return; - } - this.throwArgumentError(message, name, value); - }; - Logger.prototype.checkNormalize = function (message) { - if (message == null) { - message = "platform missing String.prototype.normalize"; - } - if (_normalizeError) { - this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { - operation: "String.prototype.normalize", form: _normalizeError - }); - } - }; - Logger.prototype.checkSafeUint53 = function (value, message) { - if (typeof (value) !== "number") { - return; - } - if (message == null) { - message = "value not safe"; - } - if (value < 0 || value >= 0x1fffffffffffff) { - this.throwError(message, Logger.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "out-of-safe-range", - value: value - }); - } - if (value % 1) { - this.throwError(message, Logger.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "non-integer", - value: value - }); - } - }; - Logger.prototype.checkArgumentCount = function (count, expectedCount, message) { - if (message) { - message = ": " + message; - } - else { - message = ""; - } - if (count < expectedCount) { - this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { - count: count, - expectedCount: expectedCount - }); - } - if (count > expectedCount) { - this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { - count: count, - expectedCount: expectedCount - }); - } - }; - Logger.prototype.checkNew = function (target, kind) { - if (target === Object || target == null) { - this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger.prototype.checkAbstract = function (target, kind) { - if (target === kind) { - this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); - } - else if (target === Object || target == null) { - this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger.globalLogger = function () { - if (!_globalLogger) { - _globalLogger = new Logger(_version_1.version); - } - return _globalLogger; - }; - Logger.setCensorship = function (censorship, permanent) { - if (!censorship && permanent) { - this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - if (_permanentCensorErrors) { - if (!censorship) { - return; - } - this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - _censorErrors = !!censorship; - _permanentCensorErrors = !!permanent; - }; - Logger.setLogLevel = function (logLevel) { - var level = LogLevels[logLevel.toLowerCase()]; - if (level == null) { - Logger.globalLogger().warn("invalid log level - " + logLevel); - return; - } - _logLevel = level; - }; - Logger.from = function (version) { - return new Logger(version); - }; - Logger.errors = ErrorCode; - Logger.levels = LogLevel; - return Logger; - }()); - exports.Logger = Logger; - - },{"./_version":12}],14:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - /** - * OpenRPC Client JS is a browser-compatible JSON-RPC client with multiple transports and - * multiple request managers to enable features like round-robin or fallback-by-position. - * - * @example - * ```typescript - * import { RequestManager, HTTPTransport, Client } from '@open-rpc/client-js'; - * const transport = new HTTPTransport('http://localhost:3333'); - * const client = new Client(new RequestManager([transport])); - * const result = await client.request({method: 'addition', params: [2, 2]}); - * // => { jsonrpc: '2.0', id: 1, result: 4 } - * ``` - * - */ - var Client = /** @class */ (function () { - function Client(requestManager) { - this.requestManager = requestManager; - } - /** - * Initiates [[RequestManager.startBatch]] in order to build a batch call. - * - * Subsequent calls to [[Client.request]] will be added to the batch. Once [[Client.stopBatch]] is called, the - * promises for the [[Client.request]] will then be resolved. If the [[RequestManager]] already has a batch in - * progress, this method is a noop. - * - * @example - * myClient.startBatch(); - * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); - * myClient.request({method: "foo", params: ["baz"]}).then(() => console.log('foobaz')); - * myClient.stopBatch(); - */ - Client.prototype.startBatch = function () { - return this.requestManager.startBatch(); - }; - /** - * Initiates [[RequestManager.stopBatch]] in order to finalize and send the batch to the underlying transport. - * - * [[Client.stopBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For - * that reason, [[Client.startBatch]] MUST be called before [[Client.stopBatch]]. - * - * @example - * myClient.startBatch(); - * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); - * myClient.request({method: "foo", params: ["baz"]}).then(() => console.log('foobaz')); - * myClient.stopBatch(); - */ - Client.prototype.stopBatch = function () { - return this.requestManager.stopBatch(); - }; - /** - * A JSON-RPC call is represented by sending a Request object to a Server. - * - * @param requestObject.method A String containing the name of the method to be invoked. Method names that begin with the word rpc - * followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions and - * MUST NOT be used for anything else. - * @param requestObject.params A Structured value that holds the parameter values to be used during the invocation of the method. - * - * @example - * myClient.request({method: "foo", params: ["bar"]}).then(() => console.log('foobar')); - */ - Client.prototype.request = function (requestObject, timeout) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!this.requestManager.connectPromise) return [3 /*break*/, 2]; - return [4 /*yield*/, this.requestManager.connectPromise]; - case 1: - _a.sent(); - _a.label = 2; - case 2: return [2 /*return*/, this.requestManager.request(requestObject, false, timeout)]; - } - }); - }); - }; - Client.prototype.notify = function (requestObject) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!this.requestManager.connectPromise) return [3 /*break*/, 2]; - return [4 /*yield*/, this.requestManager.connectPromise]; - case 1: - _a.sent(); - _a.label = 2; - case 2: return [2 /*return*/, this.requestManager.request(requestObject, true, null)]; - } - }); - }); - }; - Client.prototype.onNotification = function (callback) { - this.requestManager.requestChannel.addListener("notification", callback); - }; - Client.prototype.onError = function (callback) { - this.requestManager.requestChannel.addListener("error", callback); - }; - /** - * Close connection - */ - Client.prototype.close = function () { - this.requestManager.close(); - }; - return Client; - }()); - exports.default = Client; - - },{}],15:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.convertJSONToRPCError = exports.JSONRPCError = exports.ERR_UNKNOWN = exports.ERR_MISSIING_ID = exports.ERR_TIMEOUT = void 0; - exports.ERR_TIMEOUT = 7777; - exports.ERR_MISSIING_ID = 7878; - exports.ERR_UNKNOWN = 7979; - var JSONRPCError = /** @class */ (function (_super) { - __extends(JSONRPCError, _super); - function JSONRPCError(message, code, data) { - var _newTarget = this.constructor; - var _this = _super.call(this, message) || this; - _this.message = message; - _this.code = code; - _this.data = data; - Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain: see https://github.com/open-rpc/client-js/issues/209 - return _this; - } - return JSONRPCError; - }(Error)); - exports.JSONRPCError = JSONRPCError; - exports.convertJSONToRPCError = function (payload) { - if (payload.error) { - var _a = payload.error, message = _a.message, code = _a.code, data = _a.data; - return new JSONRPCError(message, code, data); - } - return new JSONRPCError("Unknown error", exports.ERR_UNKNOWN, payload); - }; - - },{}],16:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.getNotifications = exports.getBatchRequests = exports.isNotification = void 0; - exports.isNotification = function (data) { - return (data.request.id === undefined || data.request.id === null); - }; - exports.getBatchRequests = function (data) { - if (data instanceof Array) { - return data.filter(function (datum) { - var id = datum.request.request.id; - return id !== null && id !== undefined; - }).map(function (batchRequest) { - return batchRequest.request; - }); - } - return []; - }; - exports.getNotifications = function (data) { - if (data instanceof Array) { - return data.filter(function (datum) { - return exports.isNotification(datum.request); - }).map(function (batchRequest) { - return batchRequest.request; - }); - } - if (exports.isNotification(data)) { - return [data]; - } - return []; - }; - - },{}],17:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var events_1 = require("events"); - /* - ** Naive Request Manager, only use 1st transport. - * A more complex request manager could try each transport. - * If a transport fails, or times out, move on to the next. - */ - var RequestManager = /** @class */ (function () { - function RequestManager(transports) { - this.batch = []; - this.batchStarted = false; - this.lastId = -1; - this.transports = transports; - this.requests = {}; - this.connectPromise = this.connect(); - this.requestChannel = new events_1.EventEmitter(); - } - RequestManager.prototype.connect = function () { - var _this = this; - return Promise.all(this.transports.map(function (transport) { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - transport.subscribe("error", this.handleError.bind(this)); - transport.subscribe("notification", this.handleNotification.bind(this)); - return [4 /*yield*/, transport.connect()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); })); - }; - RequestManager.prototype.getPrimaryTransport = function () { - return this.transports[0]; - }; - RequestManager.prototype.request = function (requestObject, notification, timeout) { - if (notification === void 0) { notification = false; } - return __awaiter(this, void 0, void 0, function () { - var internalID, id, payload, result; - var _this = this; - return __generator(this, function (_a) { - internalID = (++this.lastId).toString(); - id = notification ? null : internalID; - payload = { request: this.makeRequest(requestObject.method, requestObject.params || [], id), internalID: internalID }; - if (this.batchStarted) { - result = new Promise(function (resolve, reject) { - _this.batch.push({ resolve: resolve, reject: reject, request: payload }); - }); - return [2 /*return*/, result]; - } - return [2 /*return*/, this.getPrimaryTransport().sendData(payload, timeout)]; - }); - }); - }; - RequestManager.prototype.close = function () { - this.requestChannel.removeAllListeners(); - this.transports.forEach(function (transport) { - transport.unsubscribe(); - transport.close(); - }); - }; - /** - * Begins a batch call by setting the [[RequestManager.batchStarted]] flag to `true`. - * - * [[RequestManager.batch]] is a singleton - only one batch can exist at a given time, per [[RequestManager]]. - * - */ - RequestManager.prototype.startBatch = function () { - this.batchStarted = true; - }; - RequestManager.prototype.stopBatch = function () { - if (this.batchStarted === false) { - throw new Error("cannot end that which has never started"); - } - if (this.batch.length === 0) { - this.batchStarted = false; - return; - } - this.getPrimaryTransport().sendData(this.batch); - this.batch = []; - this.batchStarted = false; - }; - RequestManager.prototype.makeRequest = function (method, params, id) { - if (id) { - return { jsonrpc: "2.0", id: id, method: method, params: params }; - } - return { jsonrpc: "2.0", method: method, params: params }; - }; - RequestManager.prototype.handleError = function (data) { - this.requestChannel.emit("error", data); - }; - RequestManager.prototype.handleNotification = function (data) { - this.requestChannel.emit("notification", data); - }; - return RequestManager; - }()); - exports.default = RequestManager; - - },{"events":303}],18:[function(require,module,exports){ - "use strict"; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.PostMessageIframeTransport = exports.PostMessageWindowTransport = exports.JSONRPCError = exports.WebSocketTransport = exports.EventEmitterTransport = exports.HTTPTransport = exports.RequestManager = exports.Client = void 0; - var RequestManager_1 = __importDefault(require("./RequestManager")); - exports.RequestManager = RequestManager_1.default; - var EventEmitterTransport_1 = __importDefault(require("./transports/EventEmitterTransport")); - exports.EventEmitterTransport = EventEmitterTransport_1.default; - var HTTPTransport_1 = __importDefault(require("./transports/HTTPTransport")); - exports.HTTPTransport = HTTPTransport_1.default; - var WebSocketTransport_1 = __importDefault(require("./transports/WebSocketTransport")); - exports.WebSocketTransport = WebSocketTransport_1.default; - var PostMessageWindowTransport_1 = __importDefault(require("./transports/PostMessageWindowTransport")); - exports.PostMessageWindowTransport = PostMessageWindowTransport_1.default; - var PostMessageIframeTransport_1 = __importDefault(require("./transports/PostMessageIframeTransport")); - exports.PostMessageIframeTransport = PostMessageIframeTransport_1.default; - var Error_1 = require("./Error"); - Object.defineProperty(exports, "JSONRPCError", { enumerable: true, get: function () { return Error_1.JSONRPCError; } }); - var Client_1 = __importDefault(require("./Client")); - exports.Client = Client_1.default; - exports.default = Client_1.default; - - },{"./Client":14,"./Error":15,"./RequestManager":17,"./transports/EventEmitterTransport":19,"./transports/HTTPTransport":20,"./transports/PostMessageIframeTransport":21,"./transports/PostMessageWindowTransport":22,"./transports/WebSocketTransport":25}],19:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); - var Transport_1 = require("./Transport"); - var Request_1 = require("../Request"); - var Error_1 = require("../Error"); - var EventEmitterTransport = /** @class */ (function (_super) { - __extends(EventEmitterTransport, _super); - function EventEmitterTransport(destEmitter, reqUri, resUri) { - var _this = _super.call(this) || this; - _this.connection = destEmitter; - _this.reqUri = reqUri; - _this.resUri = resUri; - return _this; - } - EventEmitterTransport.prototype.connect = function () { - var _this = this; - this.connection.on(this.resUri, function (data) { - _this.transportRequestManager.resolveResponse(data); - }); - return Promise.resolve(); - }; - EventEmitterTransport.prototype.sendData = function (data, timeout) { - if (timeout === void 0) { timeout = null; } - var prom = this.transportRequestManager.addRequest(data, timeout); - var notifications = Request_1.getNotifications(data); - var parsedData = this.parseData(data); - try { - this.connection.emit(this.reqUri, parsedData); - this.transportRequestManager.settlePendingRequest(notifications); - return prom; - } - catch (e) { - var responseErr = new Error_1.JSONRPCError(e.message, Error_1.ERR_UNKNOWN, e); - this.transportRequestManager.settlePendingRequest(notifications, responseErr); - return Promise.reject(responseErr); - } - }; - EventEmitterTransport.prototype.close = function () { - this.connection.removeAllListeners(); - }; - return EventEmitterTransport; - }(Transport_1.Transport)); - exports.default = EventEmitterTransport; - - },{"../Error":15,"../Request":16,"./Transport":23}],20:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.HTTPTransport = void 0; - var isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); - var Transport_1 = require("./Transport"); - var Request_1 = require("../Request"); - var Error_1 = require("../Error"); - var HTTPTransport = /** @class */ (function (_super) { - __extends(HTTPTransport, _super); - function HTTPTransport(uri, options) { - var _this = _super.call(this) || this; - _this.onlyNotifications = function (data) { - if (data instanceof Array) { - return data.every(function (datum) { return datum.request.request.id === null || datum.request.request.id === undefined; }); - } - return (data.request.id === null || data.request.id === undefined); - }; - _this.uri = uri; - _this.credentials = options && options.credentials; - _this.headers = HTTPTransport.setupHeaders(options && options.headers); - return _this; - } - HTTPTransport.prototype.connect = function () { - return Promise.resolve(); - }; - HTTPTransport.prototype.sendData = function (data, timeout) { - if (timeout === void 0) { timeout = null; } - return __awaiter(this, void 0, void 0, function () { - var prom, notifications, batch, result, body, responseErr, e_1, responseErr; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - prom = this.transportRequestManager.addRequest(data, timeout); - notifications = Request_1.getNotifications(data); - batch = Request_1.getBatchRequests(data); - _a.label = 1; - case 1: - _a.trys.push([1, 4, , 5]); - return [4 /*yield*/, isomorphic_fetch_1.default(this.uri, { - method: "POST", - headers: this.headers, - body: JSON.stringify(this.parseData(data)), - credentials: this.credentials, - })]; - case 2: - result = _a.sent(); - // requirements are that notifications are successfully sent - this.transportRequestManager.settlePendingRequest(notifications); - if (this.onlyNotifications(data)) { - return [2 /*return*/, Promise.resolve()]; - } - return [4 /*yield*/, result.text()]; - case 3: - body = _a.sent(); - responseErr = this.transportRequestManager.resolveResponse(body); - if (responseErr) { - // requirements are that batch requuests are successfully resolved - // this ensures that individual requests within the batch request are settled - this.transportRequestManager.settlePendingRequest(batch, responseErr); - return [2 /*return*/, Promise.reject(responseErr)]; - } - return [3 /*break*/, 5]; - case 4: - e_1 = _a.sent(); - responseErr = new Error_1.JSONRPCError(e_1.message, Error_1.ERR_UNKNOWN, e_1); - this.transportRequestManager.settlePendingRequest(notifications, responseErr); - this.transportRequestManager.settlePendingRequest(Request_1.getBatchRequests(data), responseErr); - return [2 /*return*/, Promise.reject(responseErr)]; - case 5: return [2 /*return*/, prom]; - } - }); - }); - }; - // tslint:disable-next-line:no-empty - HTTPTransport.prototype.close = function () { }; - HTTPTransport.setupHeaders = function (headerOptions) { - var headers = new Headers(headerOptions); - // Overwrite header options to ensure correct content type. - headers.set("Content-Type", "application/json"); - return headers; - }; - return HTTPTransport; - }(Transport_1.Transport)); - exports.HTTPTransport = HTTPTransport; - exports.default = HTTPTransport; - - },{"../Error":15,"../Request":16,"./Transport":23,"isomorphic-fetch":98}],21:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var Transport_1 = require("./Transport"); - var PostMessageIframeTransport = /** @class */ (function (_super) { - __extends(PostMessageIframeTransport, _super); - function PostMessageIframeTransport(uri) { - var _this = _super.call(this) || this; - _this.messageHandler = function (ev) { - _this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); - }; - _this.uri = uri; - _this.postMessageID = "post-message-transport-" + Math.random(); - return _this; - } - PostMessageIframeTransport.prototype.createWindow = function (uri) { - var _this = this; - return new Promise(function (resolve, reject) { - var frame; - var iframe = document.createElement("iframe"); - iframe.setAttribute("id", _this.postMessageID); - iframe.setAttribute("width", "0px"); - iframe.setAttribute("height", "0px"); - iframe.setAttribute("style", "visiblity:hidden;border:none;outline:none;"); - iframe.addEventListener("load", function () { - resolve(frame); - }); - iframe.setAttribute("src", uri); - window.document.body.appendChild(iframe); - frame = iframe.contentWindow; - }); - }; - PostMessageIframeTransport.prototype.connect = function () { - var _this = this; - var urlRegex = /^(http|https):\/\/.*$/; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!urlRegex.test(this.uri)) { - reject(new Error("Bad URI")); - } - _a = this; - return [4 /*yield*/, this.createWindow(this.uri)]; - case 1: - _a.frame = _b.sent(); - window.addEventListener("message", this.messageHandler); - resolve(); - return [2 /*return*/]; - } - }); - }); }); - }; - PostMessageIframeTransport.prototype.sendData = function (data, timeout) { - if (timeout === void 0) { timeout = 5000; } - return __awaiter(this, void 0, void 0, function () { - var prom; - return __generator(this, function (_a) { - prom = this.transportRequestManager.addRequest(data, null); - if (this.frame) { - this.frame.postMessage(data.request, "*"); - } - return [2 /*return*/, prom]; - }); - }); - }; - PostMessageIframeTransport.prototype.close = function () { - var el = document.getElementById(this.postMessageID); - el === null || el === void 0 ? void 0 : el.remove(); - window.removeEventListener("message", this.messageHandler); - }; - return PostMessageIframeTransport; - }(Transport_1.Transport)); - exports.default = PostMessageIframeTransport; - - },{"./Transport":23}],22:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var Transport_1 = require("./Transport"); - var openPopup = function (url) { - var width = 400; - var height = window.screen.height; - var left = 0; - var top = 0; - return window.open(url, "inspector:popup", "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",resizable,scrollbars=yes,status=1"); - }; - var PostMessageTransport = /** @class */ (function (_super) { - __extends(PostMessageTransport, _super); - function PostMessageTransport(uri) { - var _this = _super.call(this) || this; - _this.messageHandler = function (ev) { - _this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); - }; - _this.uri = uri; - _this.postMessageID = "post-message-transport-" + Math.random(); - return _this; - } - PostMessageTransport.prototype.createWindow = function (uri) { - return new Promise(function (resolve, reject) { - var frame; - frame = openPopup(uri); - setTimeout(function () { - resolve(frame); - }, 3000); - }); - }; - PostMessageTransport.prototype.connect = function () { - var _this = this; - var urlRegex = /^(http|https):\/\/.*$/; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!urlRegex.test(this.uri)) { - reject(new Error("Bad URI")); - } - _a = this; - return [4 /*yield*/, this.createWindow(this.uri)]; - case 1: - _a.frame = _b.sent(); - window.addEventListener("message", this.messageHandler); - resolve(); - return [2 /*return*/]; - } - }); - }); }); - }; - PostMessageTransport.prototype.sendData = function (data, timeout) { - if (timeout === void 0) { timeout = 5000; } - return __awaiter(this, void 0, void 0, function () { - var prom; - return __generator(this, function (_a) { - prom = this.transportRequestManager.addRequest(data, null); - if (this.frame) { - this.frame.postMessage(data.request, this.uri); - } - return [2 /*return*/, prom]; - }); - }); - }; - PostMessageTransport.prototype.close = function () { - if (this.frame) { - window.removeEventListener("message", this.messageHandler); - this.frame.close(); - } - }; - return PostMessageTransport; - }(Transport_1.Transport)); - exports.default = PostMessageTransport; - - },{"./Transport":23}],23:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Transport = void 0; - var TransportRequestManager_1 = require("./TransportRequestManager"); - var Transport = /** @class */ (function () { - function Transport() { - this.transportRequestManager = new TransportRequestManager_1.TransportRequestManager(); - // add a noop for the error event to not require handling the error event - // tslint:disable-next-line:no-empty - this.transportRequestManager.transportEventChannel.on("error", function () { }); - } - Transport.prototype.subscribe = function (event, handler) { - this.transportRequestManager.transportEventChannel.addListener(event, handler); - }; - Transport.prototype.unsubscribe = function (event, handler) { - if (!event) { - return this.transportRequestManager.transportEventChannel.removeAllListeners(); - } - if (event && handler) { - this.transportRequestManager.transportEventChannel.removeListener(event, handler); - } - }; - Transport.prototype.parseData = function (data) { - if (data instanceof Array) { - return data.map(function (batch) { return batch.request.request; }); - } - return data.request; - }; - return Transport; - }()); - exports.Transport = Transport; - - },{"./TransportRequestManager":24}],24:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.TransportRequestManager = void 0; - var events_1 = require("events"); - var Error_1 = require("../Error"); - var TransportRequestManager = /** @class */ (function () { - function TransportRequestManager() { - this.pendingRequest = {}; - this.pendingBatchRequest = {}; - this.transportEventChannel = new events_1.EventEmitter(); - } - TransportRequestManager.prototype.addRequest = function (data, timeout) { - this.transportEventChannel.emit("pending", data); - if (data instanceof Array) { - this.addBatchReq(data, timeout); - return Promise.resolve(); - } - return this.addReq(data.internalID, timeout); - }; - TransportRequestManager.prototype.settlePendingRequest = function (request, error) { - var _this = this; - request.forEach(function (req) { - var resolver = _this.pendingRequest[req.internalID]; - delete _this.pendingBatchRequest[req.internalID]; - if (resolver === undefined) { - return; - } - if (error) { - resolver.reject(error); - return; - } - resolver.resolve(); - }); - }; - TransportRequestManager.prototype.resolveResponse = function (payload, emitError) { - if (emitError === void 0) { emitError = true; } - var data = payload; - try { - data = JSON.parse(payload); - if (this.checkJSONRPC(data) === false) { - return; // ignore messages that are not conforming to JSON-RPC - } - if (data instanceof Array) { - return this.resolveBatch(data, emitError); - } - return this.resolveRes(data, emitError); - } - catch (e) { - var err = new Error_1.JSONRPCError("Bad response format", Error_1.ERR_UNKNOWN, payload); - if (emitError) { - this.transportEventChannel.emit("error", err); - } - return err; - } - }; - TransportRequestManager.prototype.addBatchReq = function (batches, timeout) { - var _this = this; - batches.forEach(function (batch) { - var resolve = batch.resolve, reject = batch.reject; - var internalID = batch.request.internalID; - _this.pendingBatchRequest[internalID] = true; - _this.pendingRequest[internalID] = { resolve: resolve, reject: reject }; - }); - return Promise.resolve(); - }; - TransportRequestManager.prototype.addReq = function (id, timeout) { - var _this = this; - return new Promise(function (resolve, reject) { - if (timeout !== null && timeout) { - _this.setRequestTimeout(id, timeout, reject); - } - _this.pendingRequest[id] = { resolve: resolve, reject: reject }; - }); - }; - TransportRequestManager.prototype.checkJSONRPC = function (data) { - var payload = [data]; - if (data instanceof Array) { - payload = data; - } - return payload.every(function (datum) { return (datum.result !== undefined || datum.error !== undefined || datum.method !== undefined); }); - }; - TransportRequestManager.prototype.processResult = function (payload, prom) { - if (payload.error) { - var err = Error_1.convertJSONToRPCError(payload); - prom.reject(err); - return; - } - prom.resolve(payload.result); - }; - TransportRequestManager.prototype.resolveBatch = function (payload, emitError) { - var _this = this; - var results = payload.map(function (datum) { - return _this.resolveRes(datum, emitError); - }); - var errors = results.filter(function (result) { return result; }); - if (errors.length > 0) { - return errors[0]; - } - return undefined; - }; - TransportRequestManager.prototype.resolveRes = function (data, emitError) { - var id = data.id, error = data.error; - var status = this.pendingRequest[id]; - if (status) { - delete this.pendingRequest[id]; - this.processResult(data, status); - this.transportEventChannel.emit("response", data); - return; - } - if (id === undefined && error === undefined) { - this.transportEventChannel.emit("notification", data); - return; - } - var err; - if (error) { - err = Error_1.convertJSONToRPCError(data); - } - if (emitError && error && err) { - this.transportEventChannel.emit("error", err); - } - return err; - }; - TransportRequestManager.prototype.setRequestTimeout = function (id, timeout, reject) { - var _this = this; - setTimeout(function () { - delete _this.pendingRequest[id]; - reject(new Error_1.JSONRPCError("Request timeout request took longer than " + timeout + " ms to resolve", Error_1.ERR_TIMEOUT)); - }, timeout); - }; - return TransportRequestManager; - }()); - exports.TransportRequestManager = TransportRequestManager; - - },{"../Error":15,"events":303}],25:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var isomorphic_ws_1 = __importDefault(require("isomorphic-ws")); - var Transport_1 = require("./Transport"); - var Request_1 = require("../Request"); - var Error_1 = require("../Error"); - var WebSocketTransport = /** @class */ (function (_super) { - __extends(WebSocketTransport, _super); - function WebSocketTransport(uri) { - var _this = _super.call(this) || this; - _this.uri = uri; - _this.connection = new isomorphic_ws_1.default(uri); - return _this; - } - WebSocketTransport.prototype.connect = function () { - var _this = this; - return new Promise(function (resolve, reject) { - var cb = function () { - _this.connection.removeEventListener("open", cb); - resolve(); - }; - _this.connection.addEventListener("open", cb); - _this.connection.addEventListener("message", function (message) { - var data = message.data; - _this.transportRequestManager.resolveResponse(data); - }); - }); - }; - WebSocketTransport.prototype.sendData = function (data, timeout) { - if (timeout === void 0) { timeout = 5000; } - return __awaiter(this, void 0, void 0, function () { - var prom, notifications; - var _this = this; - return __generator(this, function (_a) { - prom = this.transportRequestManager.addRequest(data, timeout); - notifications = Request_1.getNotifications(data); - this.connection.send(JSON.stringify(this.parseData(data)), function (err) { - if (err) { - var jsonError = new Error_1.JSONRPCError(err.message, Error_1.ERR_UNKNOWN, err); - _this.transportRequestManager.settlePendingRequest(notifications, jsonError); - _this.transportRequestManager.settlePendingRequest(Request_1.getBatchRequests(data), jsonError); - prom = Promise.reject(jsonError); - } - _this.transportRequestManager.settlePendingRequest(notifications); - }); - return [2 /*return*/, prom]; - }); - }); - }; - WebSocketTransport.prototype.close = function () { - this.connection.close(); - }; - return WebSocketTransport; - }(Transport_1.Transport)); - exports.default = WebSocketTransport; - - },{"../Error":15,"../Request":16,"./Transport":23,"isomorphic-ws":99}],26:[function(require,module,exports){ - 'use strict'; - - const asn1 = exports; - - asn1.bignum = require('bn.js'); - - asn1.define = require('./asn1/api').define; - asn1.base = require('./asn1/base'); - asn1.constants = require('./asn1/constants'); - asn1.decoders = require('./asn1/decoders'); - asn1.encoders = require('./asn1/encoders'); - - },{"./asn1/api":27,"./asn1/base":29,"./asn1/constants":33,"./asn1/decoders":35,"./asn1/encoders":38,"bn.js":45}],27:[function(require,module,exports){ - 'use strict'; - - const encoders = require('./encoders'); - const decoders = require('./decoders'); - const inherits = require('inherits'); - - const api = exports; - - api.define = function define(name, body) { - return new Entity(name, body); - }; - - function Entity(name, body) { - this.name = name; - this.body = body; - - this.decoders = {}; - this.encoders = {}; - } - - Entity.prototype._createNamed = function createNamed(Base) { - const name = this.name; - - function Generated(entity) { - this._initNamed(entity, name); - } - inherits(Generated, Base); - Generated.prototype._initNamed = function _initNamed(entity, name) { - Base.call(this, entity, name); - }; - - return new Generated(this); - }; - - Entity.prototype._getDecoder = function _getDecoder(enc) { - enc = enc || 'der'; - // Lazily create decoder - if (!this.decoders.hasOwnProperty(enc)) - this.decoders[enc] = this._createNamed(decoders[enc]); - return this.decoders[enc]; - }; - - Entity.prototype.decode = function decode(data, enc, options) { - return this._getDecoder(enc).decode(data, options); - }; - - Entity.prototype._getEncoder = function _getEncoder(enc) { - enc = enc || 'der'; - // Lazily create encoder - if (!this.encoders.hasOwnProperty(enc)) - this.encoders[enc] = this._createNamed(encoders[enc]); - return this.encoders[enc]; - }; - - Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { - return this._getEncoder(enc).encode(data, reporter); - }; - - },{"./decoders":35,"./encoders":38,"inherits":97}],28:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - const Reporter = require('../base/reporter').Reporter; - const Buffer = require('safer-buffer').Buffer; - - function DecoderBuffer(base, options) { - Reporter.call(this, options); - if (!Buffer.isBuffer(base)) { - this.error('Input not Buffer'); - return; - } - - this.base = base; - this.offset = 0; - this.length = base.length; - } - inherits(DecoderBuffer, Reporter); - exports.DecoderBuffer = DecoderBuffer; - - DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { - if (data instanceof DecoderBuffer) { - return true; - } - - // Or accept compatible API - const isCompatible = typeof data === 'object' && - Buffer.isBuffer(data.base) && - data.constructor.name === 'DecoderBuffer' && - typeof data.offset === 'number' && - typeof data.length === 'number' && - typeof data.save === 'function' && - typeof data.restore === 'function' && - typeof data.isEmpty === 'function' && - typeof data.readUInt8 === 'function' && - typeof data.skip === 'function' && - typeof data.raw === 'function'; - - return isCompatible; - }; - - DecoderBuffer.prototype.save = function save() { - return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; - }; - - DecoderBuffer.prototype.restore = function restore(save) { - // Return skipped data - const res = new DecoderBuffer(this.base); - res.offset = save.offset; - res.length = this.offset; - - this.offset = save.offset; - Reporter.prototype.restore.call(this, save.reporter); - - return res; - }; - - DecoderBuffer.prototype.isEmpty = function isEmpty() { - return this.offset === this.length; - }; - - DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { - if (this.offset + 1 <= this.length) - return this.base.readUInt8(this.offset++, true); - else - return this.error(fail || 'DecoderBuffer overrun'); - }; - - DecoderBuffer.prototype.skip = function skip(bytes, fail) { - if (!(this.offset + bytes <= this.length)) - return this.error(fail || 'DecoderBuffer overrun'); - - const res = new DecoderBuffer(this.base); - - // Share reporter state - res._reporterState = this._reporterState; - - res.offset = this.offset; - res.length = this.offset + bytes; - this.offset += bytes; - return res; - }; - - DecoderBuffer.prototype.raw = function raw(save) { - return this.base.slice(save ? save.offset : this.offset, this.length); - }; - - function EncoderBuffer(value, reporter) { - if (Array.isArray(value)) { - this.length = 0; - this.value = value.map(function(item) { - if (!EncoderBuffer.isEncoderBuffer(item)) - item = new EncoderBuffer(item, reporter); - this.length += item.length; - return item; - }, this); - } else if (typeof value === 'number') { - if (!(0 <= value && value <= 0xff)) - return reporter.error('non-byte EncoderBuffer value'); - this.value = value; - this.length = 1; - } else if (typeof value === 'string') { - this.value = value; - this.length = Buffer.byteLength(value); - } else if (Buffer.isBuffer(value)) { - this.value = value; - this.length = value.length; - } else { - return reporter.error('Unsupported type: ' + typeof value); - } - } - exports.EncoderBuffer = EncoderBuffer; - - EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { - if (data instanceof EncoderBuffer) { - return true; - } - - // Or accept compatible API - const isCompatible = typeof data === 'object' && - data.constructor.name === 'EncoderBuffer' && - typeof data.length === 'number' && - typeof data.join === 'function'; - - return isCompatible; - }; - - EncoderBuffer.prototype.join = function join(out, offset) { - if (!out) - out = Buffer.alloc(this.length); - if (!offset) - offset = 0; - - if (this.length === 0) - return out; - - if (Array.isArray(this.value)) { - this.value.forEach(function(item) { - item.join(out, offset); - offset += item.length; - }); - } else { - if (typeof this.value === 'number') - out[offset] = this.value; - else if (typeof this.value === 'string') - out.write(this.value, offset); - else if (Buffer.isBuffer(this.value)) - this.value.copy(out, offset); - offset += this.length; - } - - return out; - }; - - },{"../base/reporter":31,"inherits":97,"safer-buffer":123}],29:[function(require,module,exports){ - 'use strict'; - - const base = exports; - - base.Reporter = require('./reporter').Reporter; - base.DecoderBuffer = require('./buffer').DecoderBuffer; - base.EncoderBuffer = require('./buffer').EncoderBuffer; - base.Node = require('./node'); - - },{"./buffer":28,"./node":30,"./reporter":31}],30:[function(require,module,exports){ - 'use strict'; - - const Reporter = require('../base/reporter').Reporter; - const EncoderBuffer = require('../base/buffer').EncoderBuffer; - const DecoderBuffer = require('../base/buffer').DecoderBuffer; - const assert = require('minimalistic-assert'); - - // Supported tags - const tags = [ - 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', - 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', - 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', - 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr' - ]; - - // Public methods list - const methods = [ - 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', - 'any', 'contains' - ].concat(tags); - - // Overrided methods list - const overrided = [ - '_peekTag', '_decodeTag', '_use', - '_decodeStr', '_decodeObjid', '_decodeTime', - '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', - - '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', - '_encodeNull', '_encodeInt', '_encodeBool' - ]; - - function Node(enc, parent, name) { - const state = {}; - this._baseState = state; - - state.name = name; - state.enc = enc; - - state.parent = parent || null; - state.children = null; - - // State - state.tag = null; - state.args = null; - state.reverseArgs = null; - state.choice = null; - state.optional = false; - state.any = false; - state.obj = false; - state.use = null; - state.useDecoder = null; - state.key = null; - state['default'] = null; - state.explicit = null; - state.implicit = null; - state.contains = null; - - // Should create new instance on each method - if (!state.parent) { - state.children = []; - this._wrap(); - } - } - module.exports = Node; - - const stateProps = [ - 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', - 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', - 'implicit', 'contains' - ]; - - Node.prototype.clone = function clone() { - const state = this._baseState; - const cstate = {}; - stateProps.forEach(function(prop) { - cstate[prop] = state[prop]; - }); - const res = new this.constructor(cstate.parent); - res._baseState = cstate; - return res; - }; - - Node.prototype._wrap = function wrap() { - const state = this._baseState; - methods.forEach(function(method) { - this[method] = function _wrappedMethod() { - const clone = new this.constructor(this); - state.children.push(clone); - return clone[method].apply(clone, arguments); - }; - }, this); - }; - - Node.prototype._init = function init(body) { - const state = this._baseState; - - assert(state.parent === null); - body.call(this); - - // Filter children - state.children = state.children.filter(function(child) { - return child._baseState.parent === this; - }, this); - assert.equal(state.children.length, 1, 'Root node can have only one child'); - }; - - Node.prototype._useArgs = function useArgs(args) { - const state = this._baseState; - - // Filter children and args - const children = args.filter(function(arg) { - return arg instanceof this.constructor; - }, this); - args = args.filter(function(arg) { - return !(arg instanceof this.constructor); - }, this); - - if (children.length !== 0) { - assert(state.children === null); - state.children = children; - - // Replace parent to maintain backward link - children.forEach(function(child) { - child._baseState.parent = this; - }, this); - } - if (args.length !== 0) { - assert(state.args === null); - state.args = args; - state.reverseArgs = args.map(function(arg) { - if (typeof arg !== 'object' || arg.constructor !== Object) - return arg; - - const res = {}; - Object.keys(arg).forEach(function(key) { - if (key == (key | 0)) - key |= 0; - const value = arg[key]; - res[value] = key; - }); - return res; - }); - } - }; - - // - // Overrided methods - // - - overrided.forEach(function(method) { - Node.prototype[method] = function _overrided() { - const state = this._baseState; - throw new Error(method + ' not implemented for encoding: ' + state.enc); - }; - }); - - // - // Public methods - // - - tags.forEach(function(tag) { - Node.prototype[tag] = function _tagMethod() { - const state = this._baseState; - const args = Array.prototype.slice.call(arguments); - - assert(state.tag === null); - state.tag = tag; - - this._useArgs(args); - - return this; - }; - }); - - Node.prototype.use = function use(item) { - assert(item); - const state = this._baseState; - - assert(state.use === null); - state.use = item; - - return this; - }; - - Node.prototype.optional = function optional() { - const state = this._baseState; - - state.optional = true; - - return this; - }; - - Node.prototype.def = function def(val) { - const state = this._baseState; - - assert(state['default'] === null); - state['default'] = val; - state.optional = true; - - return this; - }; - - Node.prototype.explicit = function explicit(num) { - const state = this._baseState; - - assert(state.explicit === null && state.implicit === null); - state.explicit = num; - - return this; - }; - - Node.prototype.implicit = function implicit(num) { - const state = this._baseState; - - assert(state.explicit === null && state.implicit === null); - state.implicit = num; - - return this; - }; - - Node.prototype.obj = function obj() { - const state = this._baseState; - const args = Array.prototype.slice.call(arguments); - - state.obj = true; - - if (args.length !== 0) - this._useArgs(args); - - return this; - }; - - Node.prototype.key = function key(newKey) { - const state = this._baseState; - - assert(state.key === null); - state.key = newKey; - - return this; - }; - - Node.prototype.any = function any() { - const state = this._baseState; - - state.any = true; - - return this; - }; - - Node.prototype.choice = function choice(obj) { - const state = this._baseState; - - assert(state.choice === null); - state.choice = obj; - this._useArgs(Object.keys(obj).map(function(key) { - return obj[key]; - })); - - return this; - }; - - Node.prototype.contains = function contains(item) { - const state = this._baseState; - - assert(state.use === null); - state.contains = item; - - return this; - }; - - // - // Decoding - // - - Node.prototype._decode = function decode(input, options) { - const state = this._baseState; - - // Decode root node - if (state.parent === null) - return input.wrapResult(state.children[0]._decode(input, options)); - - let result = state['default']; - let present = true; - - let prevKey = null; - if (state.key !== null) - prevKey = input.enterKey(state.key); - - // Check if tag is there - if (state.optional) { - let tag = null; - if (state.explicit !== null) - tag = state.explicit; - else if (state.implicit !== null) - tag = state.implicit; - else if (state.tag !== null) - tag = state.tag; - - if (tag === null && !state.any) { - // Trial and Error - const save = input.save(); - try { - if (state.choice === null) - this._decodeGeneric(state.tag, input, options); - else - this._decodeChoice(input, options); - present = true; - } catch (e) { - present = false; - } - input.restore(save); - } else { - present = this._peekTag(input, tag, state.any); - - if (input.isError(present)) - return present; - } - } - - // Push object on stack - let prevObj; - if (state.obj && present) - prevObj = input.enterObject(); - - if (present) { - // Unwrap explicit values - if (state.explicit !== null) { - const explicit = this._decodeTag(input, state.explicit); - if (input.isError(explicit)) - return explicit; - input = explicit; - } - - const start = input.offset; - - // Unwrap implicit and normal values - if (state.use === null && state.choice === null) { - let save; - if (state.any) - save = input.save(); - const body = this._decodeTag( - input, - state.implicit !== null ? state.implicit : state.tag, - state.any - ); - if (input.isError(body)) - return body; - - if (state.any) - result = input.raw(save); - else - input = body; - } - - if (options && options.track && state.tag !== null) - options.track(input.path(), start, input.length, 'tagged'); - - if (options && options.track && state.tag !== null) - options.track(input.path(), input.offset, input.length, 'content'); - - // Select proper method for tag - if (state.any) { - // no-op - } else if (state.choice === null) { - result = this._decodeGeneric(state.tag, input, options); - } else { - result = this._decodeChoice(input, options); - } - - if (input.isError(result)) - return result; - - // Decode children - if (!state.any && state.choice === null && state.children !== null) { - state.children.forEach(function decodeChildren(child) { - // NOTE: We are ignoring errors here, to let parser continue with other - // parts of encoded data - child._decode(input, options); - }); - } - - // Decode contained/encoded by schema, only in bit or octet strings - if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { - const data = new DecoderBuffer(result); - result = this._getUse(state.contains, input._reporterState.obj) - ._decode(data, options); - } - } - - // Pop object - if (state.obj && present) - result = input.leaveObject(prevObj); - - // Set key - if (state.key !== null && (result !== null || present === true)) - input.leaveKey(prevKey, state.key, result); - else if (prevKey !== null) - input.exitKey(prevKey); - - return result; - }; - - Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { - const state = this._baseState; - - if (tag === 'seq' || tag === 'set') - return null; - if (tag === 'seqof' || tag === 'setof') - return this._decodeList(input, tag, state.args[0], options); - else if (/str$/.test(tag)) - return this._decodeStr(input, tag, options); - else if (tag === 'objid' && state.args) - return this._decodeObjid(input, state.args[0], state.args[1], options); - else if (tag === 'objid') - return this._decodeObjid(input, null, null, options); - else if (tag === 'gentime' || tag === 'utctime') - return this._decodeTime(input, tag, options); - else if (tag === 'null_') - return this._decodeNull(input, options); - else if (tag === 'bool') - return this._decodeBool(input, options); - else if (tag === 'objDesc') - return this._decodeStr(input, tag, options); - else if (tag === 'int' || tag === 'enum') - return this._decodeInt(input, state.args && state.args[0], options); - - if (state.use !== null) { - return this._getUse(state.use, input._reporterState.obj) - ._decode(input, options); - } else { - return input.error('unknown tag: ' + tag); - } - }; - - Node.prototype._getUse = function _getUse(entity, obj) { - - const state = this._baseState; - // Create altered use decoder if implicit is set - state.useDecoder = this._use(entity, obj); - assert(state.useDecoder._baseState.parent === null); - state.useDecoder = state.useDecoder._baseState.children[0]; - if (state.implicit !== state.useDecoder._baseState.implicit) { - state.useDecoder = state.useDecoder.clone(); - state.useDecoder._baseState.implicit = state.implicit; - } - return state.useDecoder; - }; - - Node.prototype._decodeChoice = function decodeChoice(input, options) { - const state = this._baseState; - let result = null; - let match = false; - - Object.keys(state.choice).some(function(key) { - const save = input.save(); - const node = state.choice[key]; - try { - const value = node._decode(input, options); - if (input.isError(value)) - return false; - - result = { type: key, value: value }; - match = true; - } catch (e) { - input.restore(save); - return false; - } - return true; - }, this); - - if (!match) - return input.error('Choice not matched'); - - return result; - }; - - // - // Encoding - // - - Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { - return new EncoderBuffer(data, this.reporter); - }; - - Node.prototype._encode = function encode(data, reporter, parent) { - const state = this._baseState; - if (state['default'] !== null && state['default'] === data) - return; - - const result = this._encodeValue(data, reporter, parent); - if (result === undefined) - return; - - if (this._skipDefault(result, reporter, parent)) - return; - - return result; - }; - - Node.prototype._encodeValue = function encode(data, reporter, parent) { - const state = this._baseState; - - // Decode root node - if (state.parent === null) - return state.children[0]._encode(data, reporter || new Reporter()); - - let result = null; - - // Set reporter to share it with a child class - this.reporter = reporter; - - // Check if data is there - if (state.optional && data === undefined) { - if (state['default'] !== null) - data = state['default']; - else - return; - } - - // Encode children first - let content = null; - let primitive = false; - if (state.any) { - // Anything that was given is translated to buffer - result = this._createEncoderBuffer(data); - } else if (state.choice) { - result = this._encodeChoice(data, reporter); - } else if (state.contains) { - content = this._getUse(state.contains, parent)._encode(data, reporter); - primitive = true; - } else if (state.children) { - content = state.children.map(function(child) { - if (child._baseState.tag === 'null_') - return child._encode(null, reporter, data); - - if (child._baseState.key === null) - return reporter.error('Child should have a key'); - const prevKey = reporter.enterKey(child._baseState.key); - - if (typeof data !== 'object') - return reporter.error('Child expected, but input is not object'); - - const res = child._encode(data[child._baseState.key], reporter, data); - reporter.leaveKey(prevKey); - - return res; - }, this).filter(function(child) { - return child; - }); - content = this._createEncoderBuffer(content); - } else { - if (state.tag === 'seqof' || state.tag === 'setof') { - // TODO(indutny): this should be thrown on DSL level - if (!(state.args && state.args.length === 1)) - return reporter.error('Too many args for : ' + state.tag); - - if (!Array.isArray(data)) - return reporter.error('seqof/setof, but data is not Array'); - - const child = this.clone(); - child._baseState.implicit = null; - content = this._createEncoderBuffer(data.map(function(item) { - const state = this._baseState; - - return this._getUse(state.args[0], data)._encode(item, reporter); - }, child)); - } else if (state.use !== null) { - result = this._getUse(state.use, parent)._encode(data, reporter); - } else { - content = this._encodePrimitive(state.tag, data); - primitive = true; - } - } - - // Encode data itself - if (!state.any && state.choice === null) { - const tag = state.implicit !== null ? state.implicit : state.tag; - const cls = state.implicit === null ? 'universal' : 'context'; - - if (tag === null) { - if (state.use === null) - reporter.error('Tag could be omitted only for .use()'); - } else { - if (state.use === null) - result = this._encodeComposite(tag, primitive, cls, content); - } - } - - // Wrap in explicit - if (state.explicit !== null) - result = this._encodeComposite(state.explicit, false, 'context', result); - - return result; - }; - - Node.prototype._encodeChoice = function encodeChoice(data, reporter) { - const state = this._baseState; - - const node = state.choice[data.type]; - if (!node) { - assert( - false, - data.type + ' not found in ' + - JSON.stringify(Object.keys(state.choice))); - } - return node._encode(data.value, reporter); - }; - - Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { - const state = this._baseState; - - if (/str$/.test(tag)) - return this._encodeStr(data, tag); - else if (tag === 'objid' && state.args) - return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); - else if (tag === 'objid') - return this._encodeObjid(data, null, null); - else if (tag === 'gentime' || tag === 'utctime') - return this._encodeTime(data, tag); - else if (tag === 'null_') - return this._encodeNull(); - else if (tag === 'int' || tag === 'enum') - return this._encodeInt(data, state.args && state.reverseArgs[0]); - else if (tag === 'bool') - return this._encodeBool(data); - else if (tag === 'objDesc') - return this._encodeStr(data, tag); - else - throw new Error('Unsupported tag: ' + tag); - }; - - Node.prototype._isNumstr = function isNumstr(str) { - return /^[0-9 ]*$/.test(str); - }; - - Node.prototype._isPrintstr = function isPrintstr(str) { - return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); - }; - - },{"../base/buffer":28,"../base/reporter":31,"minimalistic-assert":103}],31:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - - function Reporter(options) { - this._reporterState = { - obj: null, - path: [], - options: options || {}, - errors: [] - }; - } - exports.Reporter = Reporter; - - Reporter.prototype.isError = function isError(obj) { - return obj instanceof ReporterError; - }; - - Reporter.prototype.save = function save() { - const state = this._reporterState; - - return { obj: state.obj, pathLen: state.path.length }; - }; - - Reporter.prototype.restore = function restore(data) { - const state = this._reporterState; - - state.obj = data.obj; - state.path = state.path.slice(0, data.pathLen); - }; - - Reporter.prototype.enterKey = function enterKey(key) { - return this._reporterState.path.push(key); - }; - - Reporter.prototype.exitKey = function exitKey(index) { - const state = this._reporterState; - - state.path = state.path.slice(0, index - 1); - }; - - Reporter.prototype.leaveKey = function leaveKey(index, key, value) { - const state = this._reporterState; - - this.exitKey(index); - if (state.obj !== null) - state.obj[key] = value; - }; - - Reporter.prototype.path = function path() { - return this._reporterState.path.join('/'); - }; - - Reporter.prototype.enterObject = function enterObject() { - const state = this._reporterState; - - const prev = state.obj; - state.obj = {}; - return prev; - }; - - Reporter.prototype.leaveObject = function leaveObject(prev) { - const state = this._reporterState; - - const now = state.obj; - state.obj = prev; - return now; - }; - - Reporter.prototype.error = function error(msg) { - let err; - const state = this._reporterState; - - const inherited = msg instanceof ReporterError; - if (inherited) { - err = msg; - } else { - err = new ReporterError(state.path.map(function(elem) { - return '[' + JSON.stringify(elem) + ']'; - }).join(''), msg.message || msg, msg.stack); - } - - if (!state.options.partial) - throw err; - - if (!inherited) - state.errors.push(err); - - return err; - }; - - Reporter.prototype.wrapResult = function wrapResult(result) { - const state = this._reporterState; - if (!state.options.partial) - return result; - - return { - result: this.isError(result) ? null : result, - errors: state.errors - }; - }; - - function ReporterError(path, msg) { - this.path = path; - this.rethrow(msg); - } - inherits(ReporterError, Error); - - ReporterError.prototype.rethrow = function rethrow(msg) { - this.message = msg + ' at: ' + (this.path || '(shallow)'); - if (Error.captureStackTrace) - Error.captureStackTrace(this, ReporterError); - - if (!this.stack) { - try { - // IE only adds stack when thrown - throw new Error(this.message); - } catch (e) { - this.stack = e.stack; - } - } - return this; - }; - - },{"inherits":97}],32:[function(require,module,exports){ - 'use strict'; - - // Helper - function reverse(map) { - const res = {}; - - Object.keys(map).forEach(function(key) { - // Convert key to integer if it is stringified - if ((key | 0) == key) - key = key | 0; - - const value = map[key]; - res[value] = key; - }); - - return res; - } - - exports.tagClass = { - 0: 'universal', - 1: 'application', - 2: 'context', - 3: 'private' - }; - exports.tagClassByName = reverse(exports.tagClass); - - exports.tag = { - 0x00: 'end', - 0x01: 'bool', - 0x02: 'int', - 0x03: 'bitstr', - 0x04: 'octstr', - 0x05: 'null_', - 0x06: 'objid', - 0x07: 'objDesc', - 0x08: 'external', - 0x09: 'real', - 0x0a: 'enum', - 0x0b: 'embed', - 0x0c: 'utf8str', - 0x0d: 'relativeOid', - 0x10: 'seq', - 0x11: 'set', - 0x12: 'numstr', - 0x13: 'printstr', - 0x14: 't61str', - 0x15: 'videostr', - 0x16: 'ia5str', - 0x17: 'utctime', - 0x18: 'gentime', - 0x19: 'graphstr', - 0x1a: 'iso646str', - 0x1b: 'genstr', - 0x1c: 'unistr', - 0x1d: 'charstr', - 0x1e: 'bmpstr' - }; - exports.tagByName = reverse(exports.tag); - - },{}],33:[function(require,module,exports){ - 'use strict'; - - const constants = exports; - - // Helper - constants._reverse = function reverse(map) { - const res = {}; - - Object.keys(map).forEach(function(key) { - // Convert key to integer if it is stringified - if ((key | 0) == key) - key = key | 0; - - const value = map[key]; - res[value] = key; - }); - - return res; - }; - - constants.der = require('./der'); - - },{"./der":32}],34:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - - const bignum = require('bn.js'); - const DecoderBuffer = require('../base/buffer').DecoderBuffer; - const Node = require('../base/node'); - - // Import DER constants - const der = require('../constants/der'); - - function DERDecoder(entity) { - this.enc = 'der'; - this.name = entity.name; - this.entity = entity; - - // Construct base tree - this.tree = new DERNode(); - this.tree._init(entity.body); - } - module.exports = DERDecoder; - - DERDecoder.prototype.decode = function decode(data, options) { - if (!DecoderBuffer.isDecoderBuffer(data)) { - data = new DecoderBuffer(data, options); - } - - return this.tree._decode(data, options); - }; - - // Tree methods - - function DERNode(parent) { - Node.call(this, 'der', parent); - } - inherits(DERNode, Node); - - DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { - if (buffer.isEmpty()) - return false; - - const state = buffer.save(); - const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); - if (buffer.isError(decodedTag)) - return decodedTag; - - buffer.restore(state); - - return decodedTag.tag === tag || decodedTag.tagStr === tag || - (decodedTag.tagStr + 'of') === tag || any; - }; - - DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { - const decodedTag = derDecodeTag(buffer, - 'Failed to decode tag of "' + tag + '"'); - if (buffer.isError(decodedTag)) - return decodedTag; - - let len = derDecodeLen(buffer, - decodedTag.primitive, - 'Failed to get length of "' + tag + '"'); - - // Failure - if (buffer.isError(len)) - return len; - - if (!any && - decodedTag.tag !== tag && - decodedTag.tagStr !== tag && - decodedTag.tagStr + 'of' !== tag) { - return buffer.error('Failed to match tag: "' + tag + '"'); - } - - if (decodedTag.primitive || len !== null) - return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); - - // Indefinite length... find END tag - const state = buffer.save(); - const res = this._skipUntilEnd( - buffer, - 'Failed to skip indefinite length body: "' + this.tag + '"'); - if (buffer.isError(res)) - return res; - - len = buffer.offset - state.offset; - buffer.restore(state); - return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); - }; - - DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { - for (;;) { - const tag = derDecodeTag(buffer, fail); - if (buffer.isError(tag)) - return tag; - const len = derDecodeLen(buffer, tag.primitive, fail); - if (buffer.isError(len)) - return len; - - let res; - if (tag.primitive || len !== null) - res = buffer.skip(len); - else - res = this._skipUntilEnd(buffer, fail); - - // Failure - if (buffer.isError(res)) - return res; - - if (tag.tagStr === 'end') - break; - } - }; - - DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, - options) { - const result = []; - while (!buffer.isEmpty()) { - const possibleEnd = this._peekTag(buffer, 'end'); - if (buffer.isError(possibleEnd)) - return possibleEnd; - - const res = decoder.decode(buffer, 'der', options); - if (buffer.isError(res) && possibleEnd) - break; - result.push(res); - } - return result; - }; - - DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { - if (tag === 'bitstr') { - const unused = buffer.readUInt8(); - if (buffer.isError(unused)) - return unused; - return { unused: unused, data: buffer.raw() }; - } else if (tag === 'bmpstr') { - const raw = buffer.raw(); - if (raw.length % 2 === 1) - return buffer.error('Decoding of string type: bmpstr length mismatch'); - - let str = ''; - for (let i = 0; i < raw.length / 2; i++) { - str += String.fromCharCode(raw.readUInt16BE(i * 2)); - } - return str; - } else if (tag === 'numstr') { - const numstr = buffer.raw().toString('ascii'); - if (!this._isNumstr(numstr)) { - return buffer.error('Decoding of string type: ' + - 'numstr unsupported characters'); - } - return numstr; - } else if (tag === 'octstr') { - return buffer.raw(); - } else if (tag === 'objDesc') { - return buffer.raw(); - } else if (tag === 'printstr') { - const printstr = buffer.raw().toString('ascii'); - if (!this._isPrintstr(printstr)) { - return buffer.error('Decoding of string type: ' + - 'printstr unsupported characters'); - } - return printstr; - } else if (/str$/.test(tag)) { - return buffer.raw().toString(); - } else { - return buffer.error('Decoding of string type: ' + tag + ' unsupported'); - } - }; - - DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { - let result; - const identifiers = []; - let ident = 0; - let subident = 0; - while (!buffer.isEmpty()) { - subident = buffer.readUInt8(); - ident <<= 7; - ident |= subident & 0x7f; - if ((subident & 0x80) === 0) { - identifiers.push(ident); - ident = 0; - } - } - if (subident & 0x80) - identifiers.push(ident); - - const first = (identifiers[0] / 40) | 0; - const second = identifiers[0] % 40; - - if (relative) - result = identifiers; - else - result = [first, second].concat(identifiers.slice(1)); - - if (values) { - let tmp = values[result.join(' ')]; - if (tmp === undefined) - tmp = values[result.join('.')]; - if (tmp !== undefined) - result = tmp; - } - - return result; - }; - - DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { - const str = buffer.raw().toString(); - - let year; - let mon; - let day; - let hour; - let min; - let sec; - if (tag === 'gentime') { - year = str.slice(0, 4) | 0; - mon = str.slice(4, 6) | 0; - day = str.slice(6, 8) | 0; - hour = str.slice(8, 10) | 0; - min = str.slice(10, 12) | 0; - sec = str.slice(12, 14) | 0; - } else if (tag === 'utctime') { - year = str.slice(0, 2) | 0; - mon = str.slice(2, 4) | 0; - day = str.slice(4, 6) | 0; - hour = str.slice(6, 8) | 0; - min = str.slice(8, 10) | 0; - sec = str.slice(10, 12) | 0; - if (year < 70) - year = 2000 + year; - else - year = 1900 + year; - } else { - return buffer.error('Decoding ' + tag + ' time is not supported yet'); - } - - return Date.UTC(year, mon - 1, day, hour, min, sec, 0); - }; - - DERNode.prototype._decodeNull = function decodeNull() { - return null; - }; - - DERNode.prototype._decodeBool = function decodeBool(buffer) { - const res = buffer.readUInt8(); - if (buffer.isError(res)) - return res; - else - return res !== 0; - }; - - DERNode.prototype._decodeInt = function decodeInt(buffer, values) { - // Bigint, return as it is (assume big endian) - const raw = buffer.raw(); - let res = new bignum(raw); - - if (values) - res = values[res.toString(10)] || res; - - return res; - }; - - DERNode.prototype._use = function use(entity, obj) { - if (typeof entity === 'function') - entity = entity(obj); - return entity._getDecoder('der').tree; - }; - - // Utility methods - - function derDecodeTag(buf, fail) { - let tag = buf.readUInt8(fail); - if (buf.isError(tag)) - return tag; - - const cls = der.tagClass[tag >> 6]; - const primitive = (tag & 0x20) === 0; - - // Multi-octet tag - load - if ((tag & 0x1f) === 0x1f) { - let oct = tag; - tag = 0; - while ((oct & 0x80) === 0x80) { - oct = buf.readUInt8(fail); - if (buf.isError(oct)) - return oct; - - tag <<= 7; - tag |= oct & 0x7f; - } - } else { - tag &= 0x1f; - } - const tagStr = der.tag[tag]; - - return { - cls: cls, - primitive: primitive, - tag: tag, - tagStr: tagStr - }; - } - - function derDecodeLen(buf, primitive, fail) { - let len = buf.readUInt8(fail); - if (buf.isError(len)) - return len; - - // Indefinite form - if (!primitive && len === 0x80) - return null; - - // Definite form - if ((len & 0x80) === 0) { - // Short form - return len; - } - - // Long form - const num = len & 0x7f; - if (num > 4) - return buf.error('length octect is too long'); - - len = 0; - for (let i = 0; i < num; i++) { - len <<= 8; - const j = buf.readUInt8(fail); - if (buf.isError(j)) - return j; - len |= j; - } - - return len; - } - - },{"../base/buffer":28,"../base/node":30,"../constants/der":32,"bn.js":45,"inherits":97}],35:[function(require,module,exports){ - 'use strict'; - - const decoders = exports; - - decoders.der = require('./der'); - decoders.pem = require('./pem'); - - },{"./der":34,"./pem":36}],36:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - const Buffer = require('safer-buffer').Buffer; - - const DERDecoder = require('./der'); - - function PEMDecoder(entity) { - DERDecoder.call(this, entity); - this.enc = 'pem'; - } - inherits(PEMDecoder, DERDecoder); - module.exports = PEMDecoder; - - PEMDecoder.prototype.decode = function decode(data, options) { - const lines = data.toString().split(/[\r\n]+/g); - - const label = options.label.toUpperCase(); - - const re = /^-----(BEGIN|END) ([^-]+)-----$/; - let start = -1; - let end = -1; - for (let i = 0; i < lines.length; i++) { - const match = lines[i].match(re); - if (match === null) - continue; - - if (match[2] !== label) - continue; - - if (start === -1) { - if (match[1] !== 'BEGIN') - break; - start = i; - } else { - if (match[1] !== 'END') - break; - end = i; - break; - } - } - if (start === -1 || end === -1) - throw new Error('PEM section not found for: ' + label); - - const base64 = lines.slice(start + 1, end).join(''); - // Remove excessive symbols - base64.replace(/[^a-z0-9+/=]+/gi, ''); - - const input = Buffer.from(base64, 'base64'); - return DERDecoder.prototype.decode.call(this, input, options); - }; - - },{"./der":34,"inherits":97,"safer-buffer":123}],37:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - const Buffer = require('safer-buffer').Buffer; - const Node = require('../base/node'); - - // Import DER constants - const der = require('../constants/der'); - - function DEREncoder(entity) { - this.enc = 'der'; - this.name = entity.name; - this.entity = entity; - - // Construct base tree - this.tree = new DERNode(); - this.tree._init(entity.body); - } - module.exports = DEREncoder; - - DEREncoder.prototype.encode = function encode(data, reporter) { - return this.tree._encode(data, reporter).join(); - }; - - // Tree methods - - function DERNode(parent) { - Node.call(this, 'der', parent); - } - inherits(DERNode, Node); - - DERNode.prototype._encodeComposite = function encodeComposite(tag, - primitive, - cls, - content) { - const encodedTag = encodeTag(tag, primitive, cls, this.reporter); - - // Short form - if (content.length < 0x80) { - const header = Buffer.alloc(2); - header[0] = encodedTag; - header[1] = content.length; - return this._createEncoderBuffer([ header, content ]); - } - - // Long form - // Count octets required to store length - let lenOctets = 1; - for (let i = content.length; i >= 0x100; i >>= 8) - lenOctets++; - - const header = Buffer.alloc(1 + 1 + lenOctets); - header[0] = encodedTag; - header[1] = 0x80 | lenOctets; - - for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) - header[i] = j & 0xff; - - return this._createEncoderBuffer([ header, content ]); - }; - - DERNode.prototype._encodeStr = function encodeStr(str, tag) { - if (tag === 'bitstr') { - return this._createEncoderBuffer([ str.unused | 0, str.data ]); - } else if (tag === 'bmpstr') { - const buf = Buffer.alloc(str.length * 2); - for (let i = 0; i < str.length; i++) { - buf.writeUInt16BE(str.charCodeAt(i), i * 2); - } - return this._createEncoderBuffer(buf); - } else if (tag === 'numstr') { - if (!this._isNumstr(str)) { - return this.reporter.error('Encoding of string type: numstr supports ' + - 'only digits and space'); - } - return this._createEncoderBuffer(str); - } else if (tag === 'printstr') { - if (!this._isPrintstr(str)) { - return this.reporter.error('Encoding of string type: printstr supports ' + - 'only latin upper and lower case letters, ' + - 'digits, space, apostrophe, left and rigth ' + - 'parenthesis, plus sign, comma, hyphen, ' + - 'dot, slash, colon, equal sign, ' + - 'question mark'); - } - return this._createEncoderBuffer(str); - } else if (/str$/.test(tag)) { - return this._createEncoderBuffer(str); - } else if (tag === 'objDesc') { - return this._createEncoderBuffer(str); - } else { - return this.reporter.error('Encoding of string type: ' + tag + - ' unsupported'); - } - }; - - DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { - if (typeof id === 'string') { - if (!values) - return this.reporter.error('string objid given, but no values map found'); - if (!values.hasOwnProperty(id)) - return this.reporter.error('objid not found in values map'); - id = values[id].split(/[\s.]+/g); - for (let i = 0; i < id.length; i++) - id[i] |= 0; - } else if (Array.isArray(id)) { - id = id.slice(); - for (let i = 0; i < id.length; i++) - id[i] |= 0; - } - - if (!Array.isArray(id)) { - return this.reporter.error('objid() should be either array or string, ' + - 'got: ' + JSON.stringify(id)); - } - - if (!relative) { - if (id[1] >= 40) - return this.reporter.error('Second objid identifier OOB'); - id.splice(0, 2, id[0] * 40 + id[1]); - } - - // Count number of octets - let size = 0; - for (let i = 0; i < id.length; i++) { - let ident = id[i]; - for (size++; ident >= 0x80; ident >>= 7) - size++; - } - - const objid = Buffer.alloc(size); - let offset = objid.length - 1; - for (let i = id.length - 1; i >= 0; i--) { - let ident = id[i]; - objid[offset--] = ident & 0x7f; - while ((ident >>= 7) > 0) - objid[offset--] = 0x80 | (ident & 0x7f); - } - - return this._createEncoderBuffer(objid); - }; - - function two(num) { - if (num < 10) - return '0' + num; - else - return num; - } - - DERNode.prototype._encodeTime = function encodeTime(time, tag) { - let str; - const date = new Date(time); - - if (tag === 'gentime') { - str = [ - two(date.getUTCFullYear()), - two(date.getUTCMonth() + 1), - two(date.getUTCDate()), - two(date.getUTCHours()), - two(date.getUTCMinutes()), - two(date.getUTCSeconds()), - 'Z' - ].join(''); - } else if (tag === 'utctime') { - str = [ - two(date.getUTCFullYear() % 100), - two(date.getUTCMonth() + 1), - two(date.getUTCDate()), - two(date.getUTCHours()), - two(date.getUTCMinutes()), - two(date.getUTCSeconds()), - 'Z' - ].join(''); - } else { - this.reporter.error('Encoding ' + tag + ' time is not supported yet'); - } - - return this._encodeStr(str, 'octstr'); - }; - - DERNode.prototype._encodeNull = function encodeNull() { - return this._createEncoderBuffer(''); - }; - - DERNode.prototype._encodeInt = function encodeInt(num, values) { - if (typeof num === 'string') { - if (!values) - return this.reporter.error('String int or enum given, but no values map'); - if (!values.hasOwnProperty(num)) { - return this.reporter.error('Values map doesn\'t contain: ' + - JSON.stringify(num)); - } - num = values[num]; - } - - // Bignum, assume big endian - if (typeof num !== 'number' && !Buffer.isBuffer(num)) { - const numArray = num.toArray(); - if (!num.sign && numArray[0] & 0x80) { - numArray.unshift(0); - } - num = Buffer.from(numArray); - } - - if (Buffer.isBuffer(num)) { - let size = num.length; - if (num.length === 0) - size++; - - const out = Buffer.alloc(size); - num.copy(out); - if (num.length === 0) - out[0] = 0; - return this._createEncoderBuffer(out); - } - - if (num < 0x80) - return this._createEncoderBuffer(num); - - if (num < 0x100) - return this._createEncoderBuffer([0, num]); - - let size = 1; - for (let i = num; i >= 0x100; i >>= 8) - size++; - - const out = new Array(size); - for (let i = out.length - 1; i >= 0; i--) { - out[i] = num & 0xff; - num >>= 8; - } - if(out[0] & 0x80) { - out.unshift(0); - } - - return this._createEncoderBuffer(Buffer.from(out)); - }; - - DERNode.prototype._encodeBool = function encodeBool(value) { - return this._createEncoderBuffer(value ? 0xff : 0); - }; - - DERNode.prototype._use = function use(entity, obj) { - if (typeof entity === 'function') - entity = entity(obj); - return entity._getEncoder('der').tree; - }; - - DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { - const state = this._baseState; - let i; - if (state['default'] === null) - return false; - - const data = dataBuffer.join(); - if (state.defaultBuffer === undefined) - state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); - - if (data.length !== state.defaultBuffer.length) - return false; - - for (i=0; i < data.length; i++) - if (data[i] !== state.defaultBuffer[i]) - return false; - - return true; - }; - - // Utility methods - - function encodeTag(tag, primitive, cls, reporter) { - let res; - - if (tag === 'seqof') - tag = 'seq'; - else if (tag === 'setof') - tag = 'set'; - - if (der.tagByName.hasOwnProperty(tag)) - res = der.tagByName[tag]; - else if (typeof tag === 'number' && (tag | 0) === tag) - res = tag; - else - return reporter.error('Unknown tag: ' + tag); - - if (res >= 0x1f) - return reporter.error('Multi-octet tag encoding unsupported'); - - if (!primitive) - res |= 0x20; - - res |= (der.tagClassByName[cls || 'universal'] << 6); - - return res; - } - - },{"../base/node":30,"../constants/der":32,"inherits":97,"safer-buffer":123}],38:[function(require,module,exports){ - 'use strict'; - - const encoders = exports; - - encoders.der = require('./der'); - encoders.pem = require('./pem'); - - },{"./der":37,"./pem":39}],39:[function(require,module,exports){ - 'use strict'; - - const inherits = require('inherits'); - - const DEREncoder = require('./der'); - - function PEMEncoder(entity) { - DEREncoder.call(this, entity); - this.enc = 'pem'; - } - inherits(PEMEncoder, DEREncoder); - module.exports = PEMEncoder; - - PEMEncoder.prototype.encode = function encode(data, options) { - const buf = DEREncoder.prototype.encode.call(this, data); - - const p = buf.toString('base64'); - const out = [ '-----BEGIN ' + options.label + '-----' ]; - for (let i = 0; i < p.length; i += 64) - out.push(p.slice(i, i + 64)); - out.push('-----END ' + options.label + '-----'); - return out.join('\n'); - }; - - },{"./der":37,"inherits":97}],40:[function(require,module,exports){ - 'use strict' - // base-x encoding / decoding - // Copyright (c) 2018 base-x contributors - // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) - // Distributed under the MIT software license, see the accompanying - // file LICENSE or http://www.opensource.org/licenses/mit-license.php. - // @ts-ignore - var _Buffer = require('safe-buffer').Buffer - function base (ALPHABET) { - if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } - var BASE_MAP = new Uint8Array(256) - for (var j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } - for (var i = 0; i < ALPHABET.length; i++) { - var x = ALPHABET.charAt(i) - var xc = x.charCodeAt(0) - if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } - BASE_MAP[xc] = i - } - var BASE = ALPHABET.length - var LEADER = ALPHABET.charAt(0) - var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - function encode (source) { - if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } - if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } - if (source.length === 0) { return '' } - // Skip & count leading zeroes. - var zeroes = 0 - var length = 0 - var pbegin = 0 - var pend = source.length - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++ - zeroes++ - } - // Allocate enough space in big-endian base58 representation. - var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - var b58 = new Uint8Array(size) - // Process the bytes. - while (pbegin !== pend) { - var carry = source[pbegin] - // Apply "b58 = b58 * 256 + ch". - var i = 0 - for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { - carry += (256 * b58[it1]) >>> 0 - b58[it1] = (carry % BASE) >>> 0 - carry = (carry / BASE) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - pbegin++ - } - // Skip leading zeroes in base58 result. - var it2 = size - length - while (it2 !== size && b58[it2] === 0) { - it2++ - } - // Translate the result into a string. - var str = LEADER.repeat(zeroes) - for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } - return str - } - function decodeUnsafe (source) { - if (typeof source !== 'string') { throw new TypeError('Expected String') } - if (source.length === 0) { return _Buffer.alloc(0) } - var psz = 0 - // Skip leading spaces. - if (source[psz] === ' ') { return } - // Skip and count leading '1's. - var zeroes = 0 - var length = 0 - while (source[psz] === LEADER) { - zeroes++ - psz++ - } - // Allocate enough space in big-endian base256 representation. - var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - var b256 = new Uint8Array(size) - // Process the characters. - while (source[psz]) { - // Decode character - var carry = BASE_MAP[source.charCodeAt(psz)] - // Invalid character - if (carry === 255) { return } - var i = 0 - for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { - carry += (BASE * b256[it3]) >>> 0 - b256[it3] = (carry % 256) >>> 0 - carry = (carry / 256) >>> 0 - } - if (carry !== 0) { throw new Error('Non-zero carry') } - length = i - psz++ - } - // Skip trailing spaces. - if (source[psz] === ' ') { return } - // Skip leading zeroes in b256. - var it4 = size - length - while (it4 !== size && b256[it4] === 0) { - it4++ - } - var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) - vch.fill(0x00, 0, zeroes) - var j = zeroes - while (it4 !== size) { - vch[j++] = b256[it4++] - } - return vch - } - function decode (string) { - var buffer = decodeUnsafe(string) - if (buffer) { return buffer } - throw new Error('Non-base' + BASE + ' character') - } - return { - encode: encode, - decodeUnsafe: decodeUnsafe, - decode: decode - } - } - module.exports = base - - },{"safe-buffer":122}],41:[function(require,module,exports){ - // Blake2B in pure Javascript - // Adapted from the reference implementation in RFC7693 - // Ported to Javascript by DC - https://github.com/dcposch - - var util = require('./util') - - // 64-bit unsigned addition - // Sets v[a,a+1] += v[b,b+1] - // v should be a Uint32Array - function ADD64AA (v, a, b) { - var o0 = v[a] + v[b] - var o1 = v[a + 1] + v[b + 1] - if (o0 >= 0x100000000) { - o1++ - } - v[a] = o0 - v[a + 1] = o1 - } - - // 64-bit unsigned addition - // Sets v[a,a+1] += b - // b0 is the low 32 bits of b, b1 represents the high 32 bits - function ADD64AC (v, a, b0, b1) { - var o0 = v[a] + b0 - if (b0 < 0) { - o0 += 0x100000000 - } - var o1 = v[a + 1] + b1 - if (o0 >= 0x100000000) { - o1++ - } - v[a] = o0 - v[a + 1] = o1 - } - - // Little-endian byte access - function B2B_GET32 (arr, i) { - return (arr[i] ^ - (arr[i + 1] << 8) ^ - (arr[i + 2] << 16) ^ - (arr[i + 3] << 24)) - } - - // G Mixing function - // The ROTRs are inlined for speed - function B2B_G (a, b, c, d, ix, iy) { - var x0 = m[ix] - var x1 = m[ix + 1] - var y0 = m[iy] - var y1 = m[iy + 1] - - ADD64AA(v, a, b) // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s - ADD64AC(v, a, x0, x1) // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits - - // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits - var xor0 = v[d] ^ v[a] - var xor1 = v[d + 1] ^ v[a + 1] - v[d] = xor1 - v[d + 1] = xor0 - - ADD64AA(v, c, d) - - // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits - xor0 = v[b] ^ v[c] - xor1 = v[b + 1] ^ v[c + 1] - v[b] = (xor0 >>> 24) ^ (xor1 << 8) - v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8) - - ADD64AA(v, a, b) - ADD64AC(v, a, y0, y1) - - // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits - xor0 = v[d] ^ v[a] - xor1 = v[d + 1] ^ v[a + 1] - v[d] = (xor0 >>> 16) ^ (xor1 << 16) - v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16) - - ADD64AA(v, c, d) - - // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits - xor0 = v[b] ^ v[c] - xor1 = v[b + 1] ^ v[c + 1] - v[b] = (xor1 >>> 31) ^ (xor0 << 1) - v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1) - } - - // Initialization Vector - var BLAKE2B_IV32 = new Uint32Array([ - 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, - 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, - 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, - 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 - ]) - - var SIGMA8 = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, - 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, - 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, - 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, - 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, - 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, - 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, - 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, - 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 - ] - - // These are offsets into a uint64 buffer. - // Multiply them all by 2 to make them offsets into a uint32 buffer, - // because this is Javascript and we don't have uint64s - var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })) - - // Compression function. 'last' flag indicates last block. - // Note we're representing 16 uint64s as 32 uint32s - var v = new Uint32Array(32) - var m = new Uint32Array(32) - function blake2bCompress (ctx, last) { - var i = 0 - - // init work variables - for (i = 0; i < 16; i++) { - v[i] = ctx.h[i] - v[i + 16] = BLAKE2B_IV32[i] - } - - // low 64 bits of offset - v[24] = v[24] ^ ctx.t - v[25] = v[25] ^ (ctx.t / 0x100000000) - // high 64 bits not supported, offset may not be higher than 2**53-1 - - // last block flag set ? - if (last) { - v[28] = ~v[28] - v[29] = ~v[29] - } - - // get little-endian words - for (i = 0; i < 32; i++) { - m[i] = B2B_GET32(ctx.b, 4 * i) - } - - // twelve rounds of mixing - // uncomment the DebugPrint calls to log the computation - // and match the RFC sample documentation - // util.debugPrint(' m[16]', m, 64) - for (i = 0; i < 12; i++) { - // util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64) - B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]) - B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]) - B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]) - B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]) - B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]) - B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]) - B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]) - B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]) - } - // util.debugPrint(' (i=12) v[16]', v, 64) - - for (i = 0; i < 16; i++) { - ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16] - } - // util.debugPrint('h[8]', ctx.h, 64) - } - - // Creates a BLAKE2b hashing context - // Requires an output length between 1 and 64 bytes - // Takes an optional Uint8Array key - function blake2bInit (outlen, key) { - if (outlen === 0 || outlen > 64) { - throw new Error('Illegal output length, expected 0 < length <= 64') - } - if (key && key.length > 64) { - throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64') - } - - // state, 'param block' - var ctx = { - b: new Uint8Array(128), - h: new Uint32Array(16), - t: 0, // input count - c: 0, // pointer within buffer - outlen: outlen // output length in bytes - } - - // initialize hash state - for (var i = 0; i < 16; i++) { - ctx.h[i] = BLAKE2B_IV32[i] - } - var keylen = key ? key.length : 0 - ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen - - // key the hash, if applicable - if (key) { - blake2bUpdate(ctx, key) - // at the end - ctx.c = 128 - } - - return ctx - } - - // Updates a BLAKE2b streaming hash - // Requires hash context and Uint8Array (byte array) - function blake2bUpdate (ctx, input) { - for (var i = 0; i < input.length; i++) { - if (ctx.c === 128) { // buffer full ? - ctx.t += ctx.c // add counters - blake2bCompress(ctx, false) // compress (not last) - ctx.c = 0 // counter to zero - } - ctx.b[ctx.c++] = input[i] - } - } - - // Completes a BLAKE2b streaming hash - // Returns a Uint8Array containing the message digest - function blake2bFinal (ctx) { - ctx.t += ctx.c // mark last block offset - - while (ctx.c < 128) { // fill up with zeros - ctx.b[ctx.c++] = 0 - } - blake2bCompress(ctx, true) // final block flag = 1 - - // little endian convert and store - var out = new Uint8Array(ctx.outlen) - for (var i = 0; i < ctx.outlen; i++) { - out[i] = ctx.h[i >> 2] >> (8 * (i & 3)) - } - return out - } - - // Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array - // - // Returns a n-byte Uint8Array - // - // Parameters: - // - input - the input bytes, as a string, Buffer or Uint8Array - // - key - optional key Uint8Array, up to 64 bytes - // - outlen - optional output length in bytes, default 64 - function blake2b (input, key, outlen) { - // preprocess inputs - outlen = outlen || 64 - input = util.normalizeInput(input) - - // do the math - var ctx = blake2bInit(outlen, key) - blake2bUpdate(ctx, input) - return blake2bFinal(ctx) - } - - // Computes the BLAKE2B hash of a string or byte array - // - // Returns an n-byte hash in hex, all lowercase - // - // Parameters: - // - input - the input bytes, as a string, Buffer, or Uint8Array - // - key - optional key Uint8Array, up to 64 bytes - // - outlen - optional output length in bytes, default 64 - function blake2bHex (input, key, outlen) { - var output = blake2b(input, key, outlen) - return util.toHex(output) - } - - module.exports = { - blake2b: blake2b, - blake2bHex: blake2bHex, - blake2bInit: blake2bInit, - blake2bUpdate: blake2bUpdate, - blake2bFinal: blake2bFinal - } - - },{"./util":44}],42:[function(require,module,exports){ - // BLAKE2s hash function in pure Javascript - // Adapted from the reference implementation in RFC7693 - // Ported to Javascript by DC - https://github.com/dcposch - - var util = require('./util') - - // Little-endian byte access. - // Expects a Uint8Array and an index - // Returns the little-endian uint32 at v[i..i+3] - function B2S_GET32 (v, i) { - return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24) - } - - // Mixing function G. - function B2S_G (a, b, c, d, x, y) { - v[a] = v[a] + v[b] + x - v[d] = ROTR32(v[d] ^ v[a], 16) - v[c] = v[c] + v[d] - v[b] = ROTR32(v[b] ^ v[c], 12) - v[a] = v[a] + v[b] + y - v[d] = ROTR32(v[d] ^ v[a], 8) - v[c] = v[c] + v[d] - v[b] = ROTR32(v[b] ^ v[c], 7) - } - - // 32-bit right rotation - // x should be a uint32 - // y must be between 1 and 31, inclusive - function ROTR32 (x, y) { - return (x >>> y) ^ (x << (32 - y)) - } - - // Initialization Vector. - var BLAKE2S_IV = new Uint32Array([ - 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, - 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19]) - - var SIGMA = new Uint8Array([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, - 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, - 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, - 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, - 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, - 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, - 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, - 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, - 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]) - - // Compression function. "last" flag indicates last block - var v = new Uint32Array(16) - var m = new Uint32Array(16) - function blake2sCompress (ctx, last) { - var i = 0 - for (i = 0; i < 8; i++) { // init work variables - v[i] = ctx.h[i] - v[i + 8] = BLAKE2S_IV[i] - } - - v[12] ^= ctx.t // low 32 bits of offset - v[13] ^= (ctx.t / 0x100000000) // high 32 bits - if (last) { // last block flag set ? - v[14] = ~v[14] - } - - for (i = 0; i < 16; i++) { // get little-endian words - m[i] = B2S_GET32(ctx.b, 4 * i) - } - - // ten rounds of mixing - // uncomment the DebugPrint calls to log the computation - // and match the RFC sample documentation - // util.debugPrint(' m[16]', m, 32) - for (i = 0; i < 10; i++) { - // util.debugPrint(' (i=' + i + ') v[16]', v, 32) - B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]) - B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]) - B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]) - B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]) - B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]) - B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]) - B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]) - B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]) - } - // util.debugPrint(' (i=10) v[16]', v, 32) - - for (i = 0; i < 8; i++) { - ctx.h[i] ^= v[i] ^ v[i + 8] - } - // util.debugPrint('h[8]', ctx.h, 32) - } - - // Creates a BLAKE2s hashing context - // Requires an output length between 1 and 32 bytes - // Takes an optional Uint8Array key - function blake2sInit (outlen, key) { - if (!(outlen > 0 && outlen <= 32)) { - throw new Error('Incorrect output length, should be in [1, 32]') - } - var keylen = key ? key.length : 0 - if (key && !(keylen > 0 && keylen <= 32)) { - throw new Error('Incorrect key length, should be in [1, 32]') - } - - var ctx = { - h: new Uint32Array(BLAKE2S_IV), // hash state - b: new Uint32Array(64), // input block - c: 0, // pointer within block - t: 0, // input count - outlen: outlen // output length in bytes - } - ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen - - if (keylen > 0) { - blake2sUpdate(ctx, key) - ctx.c = 64 // at the end - } - - return ctx - } - - // Updates a BLAKE2s streaming hash - // Requires hash context and Uint8Array (byte array) - function blake2sUpdate (ctx, input) { - for (var i = 0; i < input.length; i++) { - if (ctx.c === 64) { // buffer full ? - ctx.t += ctx.c // add counters - blake2sCompress(ctx, false) // compress (not last) - ctx.c = 0 // counter to zero - } - ctx.b[ctx.c++] = input[i] - } - } - - // Completes a BLAKE2s streaming hash - // Returns a Uint8Array containing the message digest - function blake2sFinal (ctx) { - ctx.t += ctx.c // mark last block offset - while (ctx.c < 64) { // fill up with zeros - ctx.b[ctx.c++] = 0 - } - blake2sCompress(ctx, true) // final block flag = 1 - - // little endian convert and store - var out = new Uint8Array(ctx.outlen) - for (var i = 0; i < ctx.outlen; i++) { - out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xFF - } - return out - } - - // Computes the BLAKE2S hash of a string or byte array, and returns a Uint8Array - // - // Returns a n-byte Uint8Array - // - // Parameters: - // - input - the input bytes, as a string, Buffer, or Uint8Array - // - key - optional key Uint8Array, up to 32 bytes - // - outlen - optional output length in bytes, default 64 - function blake2s (input, key, outlen) { - // preprocess inputs - outlen = outlen || 32 - input = util.normalizeInput(input) - - // do the math - var ctx = blake2sInit(outlen, key) - blake2sUpdate(ctx, input) - return blake2sFinal(ctx) - } - - // Computes the BLAKE2S hash of a string or byte array - // - // Returns an n-byte hash in hex, all lowercase - // - // Parameters: - // - input - the input bytes, as a string, Buffer, or Uint8Array - // - key - optional key Uint8Array, up to 32 bytes - // - outlen - optional output length in bytes, default 64 - function blake2sHex (input, key, outlen) { - var output = blake2s(input, key, outlen) - return util.toHex(output) - } - - module.exports = { - blake2s: blake2s, - blake2sHex: blake2sHex, - blake2sInit: blake2sInit, - blake2sUpdate: blake2sUpdate, - blake2sFinal: blake2sFinal - } - - },{"./util":44}],43:[function(require,module,exports){ - var b2b = require('./blake2b') - var b2s = require('./blake2s') - - module.exports = { - blake2b: b2b.blake2b, - blake2bHex: b2b.blake2bHex, - blake2bInit: b2b.blake2bInit, - blake2bUpdate: b2b.blake2bUpdate, - blake2bFinal: b2b.blake2bFinal, - blake2s: b2s.blake2s, - blake2sHex: b2s.blake2sHex, - blake2sInit: b2s.blake2sInit, - blake2sUpdate: b2s.blake2sUpdate, - blake2sFinal: b2s.blake2sFinal - } - - },{"./blake2b":41,"./blake2s":42}],44:[function(require,module,exports){ - (function (Buffer){(function (){ - var ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array' - - // For convenience, let people hash a string, not just a Uint8Array - function normalizeInput (input) { - var ret - if (input instanceof Uint8Array) { - ret = input - } else if (input instanceof Buffer) { - ret = new Uint8Array(input) - } else if (typeof (input) === 'string') { - ret = new Uint8Array(Buffer.from(input, 'utf8')) - } else { - throw new Error(ERROR_MSG_INPUT) - } - return ret - } - - // Converts a Uint8Array to a hexadecimal string - // For example, toHex([255, 0, 255]) returns "ff00ff" - function toHex (bytes) { - return Array.prototype.map.call(bytes, function (n) { - return (n < 16 ? '0' : '') + n.toString(16) - }).join('') - } - - // Converts any value in [0...2^32-1] to an 8-character hex string - function uint32ToHex (val) { - return (0x100000000 + val).toString(16).substring(1) - } - - // For debugging: prints out hash state in the same format as the RFC - // sample computation exactly, so that you can diff - function debugPrint (label, arr, size) { - var msg = '\n' + label + ' = ' - for (var i = 0; i < arr.length; i += 2) { - if (size === 32) { - msg += uint32ToHex(arr[i]).toUpperCase() - msg += ' ' - msg += uint32ToHex(arr[i + 1]).toUpperCase() - } else if (size === 64) { - msg += uint32ToHex(arr[i + 1]).toUpperCase() - msg += uint32ToHex(arr[i]).toUpperCase() - } else throw new Error('Invalid size ' + size) - if (i % 6 === 4) { - msg += '\n' + new Array(label.length + 4).join(' ') - } else if (i < arr.length - 2) { - msg += ' ' - } - } - console.log(msg) - } - - // For performance testing: generates N bytes of input, hashes M times - // Measures and prints MB/second hash performance each time - function testSpeed (hashFn, N, M) { - var startMs = new Date().getTime() - - var input = new Uint8Array(N) - for (var i = 0; i < N; i++) { - input[i] = i % 256 - } - var genMs = new Date().getTime() - console.log('Generated random input in ' + (genMs - startMs) + 'ms') - startMs = genMs - - for (i = 0; i < M; i++) { - var hashHex = hashFn(input) - var hashMs = new Date().getTime() - var ms = hashMs - startMs - startMs = hashMs - console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...') - console.log(Math.round(N / (1 << 20) / (ms / 1000) * 100) / 100 + ' MB PER SECOND') - } - } - - module.exports = { - normalizeInput: normalizeInput, - toHex: toHex, - debugPrint: debugPrint, - testSpeed: testSpeed - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266}],45:[function(require,module,exports){ - (function (module, exports) { - 'use strict'; - - // Utils - function assert (val, msg) { - if (!val) throw new Error(msg || 'Assertion failed'); - } - - // Could use `inherits` module, but don't want to move from single file - // architecture yet. - function inherits (ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - - // BN - - function BN (number, base, endian) { - if (BN.isBN(number)) { - return number; - } - - this.negative = 0; - this.words = null; - this.length = 0; - - // Reduction context - this.red = null; - - if (number !== null) { - if (base === 'le' || base === 'be') { - endian = base; - base = 10; - } - - this._init(number || 0, base || 10, endian || 'be'); - } - } - if (typeof module === 'object') { - module.exports = BN; - } else { - exports.BN = BN; - } - - BN.BN = BN; - BN.wordSize = 26; - - var Buffer; - try { - if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { - Buffer = window.Buffer; - } else { - Buffer = require('buffer').Buffer; - } - } catch (e) { - } - - BN.isBN = function isBN (num) { - if (num instanceof BN) { - return true; - } - - return num !== null && typeof num === 'object' && - num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); - }; - - BN.max = function max (left, right) { - if (left.cmp(right) > 0) return left; - return right; - }; - - BN.min = function min (left, right) { - if (left.cmp(right) < 0) return left; - return right; - }; - - BN.prototype._init = function init (number, base, endian) { - if (typeof number === 'number') { - return this._initNumber(number, base, endian); - } - - if (typeof number === 'object') { - return this._initArray(number, base, endian); - } - - if (base === 'hex') { - base = 16; - } - assert(base === (base | 0) && base >= 2 && base <= 36); - - number = number.toString().replace(/\s+/g, ''); - var start = 0; - if (number[0] === '-') { - start++; - this.negative = 1; - } - - if (start < number.length) { - if (base === 16) { - this._parseHex(number, start, endian); - } else { - this._parseBase(number, base, start); - if (endian === 'le') { - this._initArray(this.toArray(), base, endian); - } - } - } - }; - - BN.prototype._initNumber = function _initNumber (number, base, endian) { - if (number < 0) { - this.negative = 1; - number = -number; - } - if (number < 0x4000000) { - this.words = [ number & 0x3ffffff ]; - this.length = 1; - } else if (number < 0x10000000000000) { - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff - ]; - this.length = 2; - } else { - assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff, - 1 - ]; - this.length = 3; - } - - if (endian !== 'le') return; - - // Reverse the bytes - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initArray = function _initArray (number, base, endian) { - // Perhaps a Uint8Array - assert(typeof number.length === 'number'); - if (number.length <= 0) { - this.words = [ 0 ]; - this.length = 1; - return this; - } - - this.length = Math.ceil(number.length / 3); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - var off = 0; - if (endian === 'be') { - for (i = number.length - 1, j = 0; i >= 0; i -= 3) { - w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } else if (endian === 'le') { - for (i = 0, j = 0; i < number.length; i += 3) { - w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } - return this.strip(); - }; - - function parseHex4Bits (string, index) { - var c = string.charCodeAt(index); - // 'A' - 'F' - if (c >= 65 && c <= 70) { - return c - 55; - // 'a' - 'f' - } else if (c >= 97 && c <= 102) { - return c - 87; - // '0' - '9' - } else { - return (c - 48) & 0xf; - } - } - - function parseHexByte (string, lowerBound, index) { - var r = parseHex4Bits(string, index); - if (index - 1 >= lowerBound) { - r |= parseHex4Bits(string, index - 1) << 4; - } - return r; - } - - BN.prototype._parseHex = function _parseHex (number, start, endian) { - // Create possibly bigger array to ensure that it fits the number - this.length = Math.ceil((number.length - start) / 6); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - // 24-bits chunks - var off = 0; - var j = 0; - - var w; - if (endian === 'be') { - for (i = number.length - 1; i >= start; i -= 2) { - w = parseHexByte(number, start, i) << off; - this.words[j] |= w & 0x3ffffff; - if (off >= 18) { - off -= 18; - j += 1; - this.words[j] |= w >>> 26; - } else { - off += 8; - } - } - } else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { - w = parseHexByte(number, start, i) << off; - this.words[j] |= w & 0x3ffffff; - if (off >= 18) { - off -= 18; - j += 1; - this.words[j] |= w >>> 26; - } else { - off += 8; - } - } - } - - this.strip(); - }; - - function parseBase (str, start, end, mul) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r *= mul; - - // 'a' - if (c >= 49) { - r += c - 49 + 0xa; - - // 'A' - } else if (c >= 17) { - r += c - 17 + 0xa; - - // '0' - '9' - } else { - r += c; - } - } - return r; - } - - BN.prototype._parseBase = function _parseBase (number, base, start) { - // Initialize as zero - this.words = [ 0 ]; - this.length = 1; - - // Find length of limb in base - for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { - limbLen++; - } - limbLen--; - limbPow = (limbPow / base) | 0; - - var total = number.length - start; - var mod = total % limbLen; - var end = Math.min(total, total - mod) + start; - - var word = 0; - for (var i = start; i < end; i += limbLen) { - word = parseBase(number, i, i + limbLen, base); - - this.imuln(limbPow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - if (mod !== 0) { - var pow = 1; - word = parseBase(number, i, number.length, base); - - for (i = 0; i < mod; i++) { - pow *= base; - } - - this.imuln(pow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - this.strip(); - }; - - BN.prototype.copy = function copy (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - dest.words[i] = this.words[i]; - } - dest.length = this.length; - dest.negative = this.negative; - dest.red = this.red; - }; - - BN.prototype.clone = function clone () { - var r = new BN(null); - this.copy(r); - return r; - }; - - BN.prototype._expand = function _expand (size) { - while (this.length < size) { - this.words[this.length++] = 0; - } - return this; - }; - - // Remove leading `0` from `this` - BN.prototype.strip = function strip () { - while (this.length > 1 && this.words[this.length - 1] === 0) { - this.length--; - } - return this._normSign(); - }; - - BN.prototype._normSign = function _normSign () { - // -0 = 0 - if (this.length === 1 && this.words[0] === 0) { - this.negative = 0; - } - return this; - }; - - BN.prototype.inspect = function inspect () { - return (this.red ? ''; - }; - - /* - - var zeros = []; - var groupSizes = []; - var groupBases = []; - - var s = ''; - var i = -1; - while (++i < BN.wordSize) { - zeros[i] = s; - s += '0'; - } - groupSizes[0] = 0; - groupSizes[1] = 0; - groupBases[0] = 0; - groupBases[1] = 0; - var base = 2 - 1; - while (++base < 36 + 1) { - var groupSize = 0; - var groupBase = 1; - while (groupBase < (1 << BN.wordSize) / base) { - groupBase *= base; - groupSize += 1; - } - groupSizes[base] = groupSize; - groupBases[base] = groupBase; - } - - */ - - var zeros = [ - '', - '0', - '00', - '000', - '0000', - '00000', - '000000', - '0000000', - '00000000', - '000000000', - '0000000000', - '00000000000', - '000000000000', - '0000000000000', - '00000000000000', - '000000000000000', - '0000000000000000', - '00000000000000000', - '000000000000000000', - '0000000000000000000', - '00000000000000000000', - '000000000000000000000', - '0000000000000000000000', - '00000000000000000000000', - '000000000000000000000000', - '0000000000000000000000000' - ]; - - var groupSizes = [ - 0, 0, - 25, 16, 12, 11, 10, 9, 8, - 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5 - ]; - - var groupBases = [ - 0, 0, - 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, - 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, - 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, - 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, - 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 - ]; - - BN.prototype.toString = function toString (base, padding) { - base = base || 10; - padding = padding | 0 || 1; - - var out; - if (base === 16 || base === 'hex') { - out = ''; - var off = 0; - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = this.words[i]; - var word = (((w << off) | carry) & 0xffffff).toString(16); - carry = (w >>> (24 - off)) & 0xffffff; - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - } - if (carry !== 0) { - out = carry.toString(16) + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - if (base === (base | 0) && base >= 2 && base <= 36) { - // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); - var groupSize = groupSizes[base]; - // var groupBase = Math.pow(base, groupSize); - var groupBase = groupBases[base]; - out = ''; - var c = this.clone(); - c.negative = 0; - while (!c.isZero()) { - var r = c.modn(groupBase).toString(base); - c = c.idivn(groupBase); - - if (!c.isZero()) { - out = zeros[groupSize - r.length] + r + out; - } else { - out = r + out; - } - } - if (this.isZero()) { - out = '0' + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - assert(false, 'Base should be between 2 and 36'); - }; - - BN.prototype.toNumber = function toNumber () { - var ret = this.words[0]; - if (this.length === 2) { - ret += this.words[1] * 0x4000000; - } else if (this.length === 3 && this.words[2] === 0x01) { - // NOTE: at this stage it is known that the top bit is set - ret += 0x10000000000000 + (this.words[1] * 0x4000000); - } else if (this.length > 2) { - assert(false, 'Number can only safely store up to 53 bits'); - } - return (this.negative !== 0) ? -ret : ret; - }; - - BN.prototype.toJSON = function toJSON () { - return this.toString(16); - }; - - BN.prototype.toBuffer = function toBuffer (endian, length) { - assert(typeof Buffer !== 'undefined'); - return this.toArrayLike(Buffer, endian, length); - }; - - BN.prototype.toArray = function toArray (endian, length) { - return this.toArrayLike(Array, endian, length); - }; - - BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { - var byteLength = this.byteLength(); - var reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, 'byte array longer than desired length'); - assert(reqLength > 0, 'Requested array length <= 0'); - - this.strip(); - var littleEndian = endian === 'le'; - var res = new ArrayType(reqLength); - - var b, i; - var q = this.clone(); - if (!littleEndian) { - // Assume big-endian - for (i = 0; i < reqLength - byteLength; i++) { - res[i] = 0; - } - - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[reqLength - i - 1] = b; - } - } else { - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[i] = b; - } - - for (; i < reqLength; i++) { - res[i] = 0; - } - } - - return res; - }; - - if (Math.clz32) { - BN.prototype._countBits = function _countBits (w) { - return 32 - Math.clz32(w); - }; - } else { - BN.prototype._countBits = function _countBits (w) { - var t = w; - var r = 0; - if (t >= 0x1000) { - r += 13; - t >>>= 13; - } - if (t >= 0x40) { - r += 7; - t >>>= 7; - } - if (t >= 0x8) { - r += 4; - t >>>= 4; - } - if (t >= 0x02) { - r += 2; - t >>>= 2; - } - return r + t; - }; - } - - BN.prototype._zeroBits = function _zeroBits (w) { - // Short-cut - if (w === 0) return 26; - - var t = w; - var r = 0; - if ((t & 0x1fff) === 0) { - r += 13; - t >>>= 13; - } - if ((t & 0x7f) === 0) { - r += 7; - t >>>= 7; - } - if ((t & 0xf) === 0) { - r += 4; - t >>>= 4; - } - if ((t & 0x3) === 0) { - r += 2; - t >>>= 2; - } - if ((t & 0x1) === 0) { - r++; - } - return r; - }; - - // Return number of used bits in a BN - BN.prototype.bitLength = function bitLength () { - var w = this.words[this.length - 1]; - var hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }; - - function toBitArray (num) { - var w = new Array(num.bitLength()); - - for (var bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0; - var wbit = bit % 26; - - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - - return w; - } - - // Number of trailing zero bits - BN.prototype.zeroBits = function zeroBits () { - if (this.isZero()) return 0; - - var r = 0; - for (var i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - r += b; - if (b !== 26) break; - } - return r; - }; - - BN.prototype.byteLength = function byteLength () { - return Math.ceil(this.bitLength() / 8); - }; - - BN.prototype.toTwos = function toTwos (width) { - if (this.negative !== 0) { - return this.abs().inotn(width).iaddn(1); - } - return this.clone(); - }; - - BN.prototype.fromTwos = function fromTwos (width) { - if (this.testn(width - 1)) { - return this.notn(width).iaddn(1).ineg(); - } - return this.clone(); - }; - - BN.prototype.isNeg = function isNeg () { - return this.negative !== 0; - }; - - // Return negative clone of `this` - BN.prototype.neg = function neg () { - return this.clone().ineg(); - }; - - BN.prototype.ineg = function ineg () { - if (!this.isZero()) { - this.negative ^= 1; - } - - return this; - }; - - // Or `num` with `this` in-place - BN.prototype.iuor = function iuor (num) { - while (this.length < num.length) { - this.words[this.length++] = 0; - } - - for (var i = 0; i < num.length; i++) { - this.words[i] = this.words[i] | num.words[i]; - } - - return this.strip(); - }; - - BN.prototype.ior = function ior (num) { - assert((this.negative | num.negative) === 0); - return this.iuor(num); - }; - - // Or `num` with `this` - BN.prototype.or = function or (num) { - if (this.length > num.length) return this.clone().ior(num); - return num.clone().ior(this); - }; - - BN.prototype.uor = function uor (num) { - if (this.length > num.length) return this.clone().iuor(num); - return num.clone().iuor(this); - }; - - // And `num` with `this` in-place - BN.prototype.iuand = function iuand (num) { - // b = min-length(num, this) - var b; - if (this.length > num.length) { - b = num; - } else { - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = this.words[i] & num.words[i]; - } - - this.length = b.length; - - return this.strip(); - }; - - BN.prototype.iand = function iand (num) { - assert((this.negative | num.negative) === 0); - return this.iuand(num); - }; - - // And `num` with `this` - BN.prototype.and = function and (num) { - if (this.length > num.length) return this.clone().iand(num); - return num.clone().iand(this); - }; - - BN.prototype.uand = function uand (num) { - if (this.length > num.length) return this.clone().iuand(num); - return num.clone().iuand(this); - }; - - // Xor `num` with `this` in-place - BN.prototype.iuxor = function iuxor (num) { - // a.length > b.length - var a; - var b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = a.words[i] ^ b.words[i]; - } - - if (this !== a) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = a.length; - - return this.strip(); - }; - - BN.prototype.ixor = function ixor (num) { - assert((this.negative | num.negative) === 0); - return this.iuxor(num); - }; - - // Xor `num` with `this` - BN.prototype.xor = function xor (num) { - if (this.length > num.length) return this.clone().ixor(num); - return num.clone().ixor(this); - }; - - BN.prototype.uxor = function uxor (num) { - if (this.length > num.length) return this.clone().iuxor(num); - return num.clone().iuxor(this); - }; - - // Not ``this`` with ``width`` bitwidth - BN.prototype.inotn = function inotn (width) { - assert(typeof width === 'number' && width >= 0); - - var bytesNeeded = Math.ceil(width / 26) | 0; - var bitsLeft = width % 26; - - // Extend the buffer with leading zeroes - this._expand(bytesNeeded); - - if (bitsLeft > 0) { - bytesNeeded--; - } - - // Handle complete words - for (var i = 0; i < bytesNeeded; i++) { - this.words[i] = ~this.words[i] & 0x3ffffff; - } - - // Handle the residue - if (bitsLeft > 0) { - this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); - } - - // And remove leading zeroes - return this.strip(); - }; - - BN.prototype.notn = function notn (width) { - return this.clone().inotn(width); - }; - - // Set `bit` of `this` - BN.prototype.setn = function setn (bit, val) { - assert(typeof bit === 'number' && bit >= 0); - - var off = (bit / 26) | 0; - var wbit = bit % 26; - - this._expand(off + 1); - - if (val) { - this.words[off] = this.words[off] | (1 << wbit); - } else { - this.words[off] = this.words[off] & ~(1 << wbit); - } - - return this.strip(); - }; - - // Add `num` to `this` in-place - BN.prototype.iadd = function iadd (num) { - var r; - - // negative + positive - if (this.negative !== 0 && num.negative === 0) { - this.negative = 0; - r = this.isub(num); - this.negative ^= 1; - return this._normSign(); - - // positive + negative - } else if (this.negative === 0 && num.negative !== 0) { - num.negative = 0; - r = this.isub(num); - num.negative = 1; - return r._normSign(); - } - - // a.length > b.length - var a, b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) + (b.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - - this.length = a.length; - if (carry !== 0) { - this.words[this.length] = carry; - this.length++; - // Copy the rest of the words - } else if (a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - return this; - }; - - // Add `num` to `this` - BN.prototype.add = function add (num) { - var res; - if (num.negative !== 0 && this.negative === 0) { - num.negative = 0; - res = this.sub(num); - num.negative ^= 1; - return res; - } else if (num.negative === 0 && this.negative !== 0) { - this.negative = 0; - res = num.sub(this); - this.negative = 1; - return res; - } - - if (this.length > num.length) return this.clone().iadd(num); - - return num.clone().iadd(this); - }; - - // Subtract `num` from `this` in-place - BN.prototype.isub = function isub (num) { - // this - (-num) = this + num - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - num.negative = 1; - return r._normSign(); - - // -this - num = -(this + num) - } else if (this.negative !== 0) { - this.negative = 0; - this.iadd(num); - this.negative = 1; - return this._normSign(); - } - - // At this point both numbers are positive - var cmp = this.cmp(num); - - // Optimization - zeroify - if (cmp === 0) { - this.negative = 0; - this.length = 1; - this.words[0] = 0; - return this; - } - - // a > b - var a, b; - if (cmp > 0) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) - (b.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - - // Copy rest of the words - if (carry === 0 && i < a.length && a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = Math.max(this.length, i); - - if (a !== this) { - this.negative = 1; - } - - return this.strip(); - }; - - // Subtract `num` from `this` - BN.prototype.sub = function sub (num) { - return this.clone().isub(num); - }; - - function smallMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - var len = (self.length + num.length) | 0; - out.length = len; - len = (len - 1) | 0; - - // Peel one iteration (compiler can't do it, because of code complexity) - var a = self.words[0] | 0; - var b = num.words[0] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - var carry = (r / 0x4000000) | 0; - out.words[0] = lo; - - for (var k = 1; k < len; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = carry >>> 26; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = (k - j) | 0; - a = self.words[i] | 0; - b = num.words[j] | 0; - r = a * b + rword; - ncarry += (r / 0x4000000) | 0; - rword = r & 0x3ffffff; - } - out.words[k] = rword | 0; - carry = ncarry | 0; - } - if (carry !== 0) { - out.words[k] = carry | 0; - } else { - out.length--; - } - - return out.strip(); - } - - // TODO(indutny): it may be reasonable to omit it for users who don't need - // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit - // multiplication (like elliptic secp256k1). - var comb10MulTo = function comb10MulTo (self, num, out) { - var a = self.words; - var b = num.words; - var o = out.words; - var c = 0; - var lo; - var mid; - var hi; - var a0 = a[0] | 0; - var al0 = a0 & 0x1fff; - var ah0 = a0 >>> 13; - var a1 = a[1] | 0; - var al1 = a1 & 0x1fff; - var ah1 = a1 >>> 13; - var a2 = a[2] | 0; - var al2 = a2 & 0x1fff; - var ah2 = a2 >>> 13; - var a3 = a[3] | 0; - var al3 = a3 & 0x1fff; - var ah3 = a3 >>> 13; - var a4 = a[4] | 0; - var al4 = a4 & 0x1fff; - var ah4 = a4 >>> 13; - var a5 = a[5] | 0; - var al5 = a5 & 0x1fff; - var ah5 = a5 >>> 13; - var a6 = a[6] | 0; - var al6 = a6 & 0x1fff; - var ah6 = a6 >>> 13; - var a7 = a[7] | 0; - var al7 = a7 & 0x1fff; - var ah7 = a7 >>> 13; - var a8 = a[8] | 0; - var al8 = a8 & 0x1fff; - var ah8 = a8 >>> 13; - var a9 = a[9] | 0; - var al9 = a9 & 0x1fff; - var ah9 = a9 >>> 13; - var b0 = b[0] | 0; - var bl0 = b0 & 0x1fff; - var bh0 = b0 >>> 13; - var b1 = b[1] | 0; - var bl1 = b1 & 0x1fff; - var bh1 = b1 >>> 13; - var b2 = b[2] | 0; - var bl2 = b2 & 0x1fff; - var bh2 = b2 >>> 13; - var b3 = b[3] | 0; - var bl3 = b3 & 0x1fff; - var bh3 = b3 >>> 13; - var b4 = b[4] | 0; - var bl4 = b4 & 0x1fff; - var bh4 = b4 >>> 13; - var b5 = b[5] | 0; - var bl5 = b5 & 0x1fff; - var bh5 = b5 >>> 13; - var b6 = b[6] | 0; - var bl6 = b6 & 0x1fff; - var bh6 = b6 >>> 13; - var b7 = b[7] | 0; - var bl7 = b7 & 0x1fff; - var bh7 = b7 >>> 13; - var b8 = b[8] | 0; - var bl8 = b8 & 0x1fff; - var bh8 = b8 >>> 13; - var b9 = b[9] | 0; - var bl9 = b9 & 0x1fff; - var bh9 = b9 >>> 13; - - out.negative = self.negative ^ num.negative; - out.length = 19; - /* k = 0 */ - lo = Math.imul(al0, bl0); - mid = Math.imul(al0, bh0); - mid = (mid + Math.imul(ah0, bl0)) | 0; - hi = Math.imul(ah0, bh0); - var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; - w0 &= 0x3ffffff; - /* k = 1 */ - lo = Math.imul(al1, bl0); - mid = Math.imul(al1, bh0); - mid = (mid + Math.imul(ah1, bl0)) | 0; - hi = Math.imul(ah1, bh0); - lo = (lo + Math.imul(al0, bl1)) | 0; - mid = (mid + Math.imul(al0, bh1)) | 0; - mid = (mid + Math.imul(ah0, bl1)) | 0; - hi = (hi + Math.imul(ah0, bh1)) | 0; - var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; - w1 &= 0x3ffffff; - /* k = 2 */ - lo = Math.imul(al2, bl0); - mid = Math.imul(al2, bh0); - mid = (mid + Math.imul(ah2, bl0)) | 0; - hi = Math.imul(ah2, bh0); - lo = (lo + Math.imul(al1, bl1)) | 0; - mid = (mid + Math.imul(al1, bh1)) | 0; - mid = (mid + Math.imul(ah1, bl1)) | 0; - hi = (hi + Math.imul(ah1, bh1)) | 0; - lo = (lo + Math.imul(al0, bl2)) | 0; - mid = (mid + Math.imul(al0, bh2)) | 0; - mid = (mid + Math.imul(ah0, bl2)) | 0; - hi = (hi + Math.imul(ah0, bh2)) | 0; - var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; - w2 &= 0x3ffffff; - /* k = 3 */ - lo = Math.imul(al3, bl0); - mid = Math.imul(al3, bh0); - mid = (mid + Math.imul(ah3, bl0)) | 0; - hi = Math.imul(ah3, bh0); - lo = (lo + Math.imul(al2, bl1)) | 0; - mid = (mid + Math.imul(al2, bh1)) | 0; - mid = (mid + Math.imul(ah2, bl1)) | 0; - hi = (hi + Math.imul(ah2, bh1)) | 0; - lo = (lo + Math.imul(al1, bl2)) | 0; - mid = (mid + Math.imul(al1, bh2)) | 0; - mid = (mid + Math.imul(ah1, bl2)) | 0; - hi = (hi + Math.imul(ah1, bh2)) | 0; - lo = (lo + Math.imul(al0, bl3)) | 0; - mid = (mid + Math.imul(al0, bh3)) | 0; - mid = (mid + Math.imul(ah0, bl3)) | 0; - hi = (hi + Math.imul(ah0, bh3)) | 0; - var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; - w3 &= 0x3ffffff; - /* k = 4 */ - lo = Math.imul(al4, bl0); - mid = Math.imul(al4, bh0); - mid = (mid + Math.imul(ah4, bl0)) | 0; - hi = Math.imul(ah4, bh0); - lo = (lo + Math.imul(al3, bl1)) | 0; - mid = (mid + Math.imul(al3, bh1)) | 0; - mid = (mid + Math.imul(ah3, bl1)) | 0; - hi = (hi + Math.imul(ah3, bh1)) | 0; - lo = (lo + Math.imul(al2, bl2)) | 0; - mid = (mid + Math.imul(al2, bh2)) | 0; - mid = (mid + Math.imul(ah2, bl2)) | 0; - hi = (hi + Math.imul(ah2, bh2)) | 0; - lo = (lo + Math.imul(al1, bl3)) | 0; - mid = (mid + Math.imul(al1, bh3)) | 0; - mid = (mid + Math.imul(ah1, bl3)) | 0; - hi = (hi + Math.imul(ah1, bh3)) | 0; - lo = (lo + Math.imul(al0, bl4)) | 0; - mid = (mid + Math.imul(al0, bh4)) | 0; - mid = (mid + Math.imul(ah0, bl4)) | 0; - hi = (hi + Math.imul(ah0, bh4)) | 0; - var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; - w4 &= 0x3ffffff; - /* k = 5 */ - lo = Math.imul(al5, bl0); - mid = Math.imul(al5, bh0); - mid = (mid + Math.imul(ah5, bl0)) | 0; - hi = Math.imul(ah5, bh0); - lo = (lo + Math.imul(al4, bl1)) | 0; - mid = (mid + Math.imul(al4, bh1)) | 0; - mid = (mid + Math.imul(ah4, bl1)) | 0; - hi = (hi + Math.imul(ah4, bh1)) | 0; - lo = (lo + Math.imul(al3, bl2)) | 0; - mid = (mid + Math.imul(al3, bh2)) | 0; - mid = (mid + Math.imul(ah3, bl2)) | 0; - hi = (hi + Math.imul(ah3, bh2)) | 0; - lo = (lo + Math.imul(al2, bl3)) | 0; - mid = (mid + Math.imul(al2, bh3)) | 0; - mid = (mid + Math.imul(ah2, bl3)) | 0; - hi = (hi + Math.imul(ah2, bh3)) | 0; - lo = (lo + Math.imul(al1, bl4)) | 0; - mid = (mid + Math.imul(al1, bh4)) | 0; - mid = (mid + Math.imul(ah1, bl4)) | 0; - hi = (hi + Math.imul(ah1, bh4)) | 0; - lo = (lo + Math.imul(al0, bl5)) | 0; - mid = (mid + Math.imul(al0, bh5)) | 0; - mid = (mid + Math.imul(ah0, bl5)) | 0; - hi = (hi + Math.imul(ah0, bh5)) | 0; - var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; - w5 &= 0x3ffffff; - /* k = 6 */ - lo = Math.imul(al6, bl0); - mid = Math.imul(al6, bh0); - mid = (mid + Math.imul(ah6, bl0)) | 0; - hi = Math.imul(ah6, bh0); - lo = (lo + Math.imul(al5, bl1)) | 0; - mid = (mid + Math.imul(al5, bh1)) | 0; - mid = (mid + Math.imul(ah5, bl1)) | 0; - hi = (hi + Math.imul(ah5, bh1)) | 0; - lo = (lo + Math.imul(al4, bl2)) | 0; - mid = (mid + Math.imul(al4, bh2)) | 0; - mid = (mid + Math.imul(ah4, bl2)) | 0; - hi = (hi + Math.imul(ah4, bh2)) | 0; - lo = (lo + Math.imul(al3, bl3)) | 0; - mid = (mid + Math.imul(al3, bh3)) | 0; - mid = (mid + Math.imul(ah3, bl3)) | 0; - hi = (hi + Math.imul(ah3, bh3)) | 0; - lo = (lo + Math.imul(al2, bl4)) | 0; - mid = (mid + Math.imul(al2, bh4)) | 0; - mid = (mid + Math.imul(ah2, bl4)) | 0; - hi = (hi + Math.imul(ah2, bh4)) | 0; - lo = (lo + Math.imul(al1, bl5)) | 0; - mid = (mid + Math.imul(al1, bh5)) | 0; - mid = (mid + Math.imul(ah1, bl5)) | 0; - hi = (hi + Math.imul(ah1, bh5)) | 0; - lo = (lo + Math.imul(al0, bl6)) | 0; - mid = (mid + Math.imul(al0, bh6)) | 0; - mid = (mid + Math.imul(ah0, bl6)) | 0; - hi = (hi + Math.imul(ah0, bh6)) | 0; - var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; - w6 &= 0x3ffffff; - /* k = 7 */ - lo = Math.imul(al7, bl0); - mid = Math.imul(al7, bh0); - mid = (mid + Math.imul(ah7, bl0)) | 0; - hi = Math.imul(ah7, bh0); - lo = (lo + Math.imul(al6, bl1)) | 0; - mid = (mid + Math.imul(al6, bh1)) | 0; - mid = (mid + Math.imul(ah6, bl1)) | 0; - hi = (hi + Math.imul(ah6, bh1)) | 0; - lo = (lo + Math.imul(al5, bl2)) | 0; - mid = (mid + Math.imul(al5, bh2)) | 0; - mid = (mid + Math.imul(ah5, bl2)) | 0; - hi = (hi + Math.imul(ah5, bh2)) | 0; - lo = (lo + Math.imul(al4, bl3)) | 0; - mid = (mid + Math.imul(al4, bh3)) | 0; - mid = (mid + Math.imul(ah4, bl3)) | 0; - hi = (hi + Math.imul(ah4, bh3)) | 0; - lo = (lo + Math.imul(al3, bl4)) | 0; - mid = (mid + Math.imul(al3, bh4)) | 0; - mid = (mid + Math.imul(ah3, bl4)) | 0; - hi = (hi + Math.imul(ah3, bh4)) | 0; - lo = (lo + Math.imul(al2, bl5)) | 0; - mid = (mid + Math.imul(al2, bh5)) | 0; - mid = (mid + Math.imul(ah2, bl5)) | 0; - hi = (hi + Math.imul(ah2, bh5)) | 0; - lo = (lo + Math.imul(al1, bl6)) | 0; - mid = (mid + Math.imul(al1, bh6)) | 0; - mid = (mid + Math.imul(ah1, bl6)) | 0; - hi = (hi + Math.imul(ah1, bh6)) | 0; - lo = (lo + Math.imul(al0, bl7)) | 0; - mid = (mid + Math.imul(al0, bh7)) | 0; - mid = (mid + Math.imul(ah0, bl7)) | 0; - hi = (hi + Math.imul(ah0, bh7)) | 0; - var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; - w7 &= 0x3ffffff; - /* k = 8 */ - lo = Math.imul(al8, bl0); - mid = Math.imul(al8, bh0); - mid = (mid + Math.imul(ah8, bl0)) | 0; - hi = Math.imul(ah8, bh0); - lo = (lo + Math.imul(al7, bl1)) | 0; - mid = (mid + Math.imul(al7, bh1)) | 0; - mid = (mid + Math.imul(ah7, bl1)) | 0; - hi = (hi + Math.imul(ah7, bh1)) | 0; - lo = (lo + Math.imul(al6, bl2)) | 0; - mid = (mid + Math.imul(al6, bh2)) | 0; - mid = (mid + Math.imul(ah6, bl2)) | 0; - hi = (hi + Math.imul(ah6, bh2)) | 0; - lo = (lo + Math.imul(al5, bl3)) | 0; - mid = (mid + Math.imul(al5, bh3)) | 0; - mid = (mid + Math.imul(ah5, bl3)) | 0; - hi = (hi + Math.imul(ah5, bh3)) | 0; - lo = (lo + Math.imul(al4, bl4)) | 0; - mid = (mid + Math.imul(al4, bh4)) | 0; - mid = (mid + Math.imul(ah4, bl4)) | 0; - hi = (hi + Math.imul(ah4, bh4)) | 0; - lo = (lo + Math.imul(al3, bl5)) | 0; - mid = (mid + Math.imul(al3, bh5)) | 0; - mid = (mid + Math.imul(ah3, bl5)) | 0; - hi = (hi + Math.imul(ah3, bh5)) | 0; - lo = (lo + Math.imul(al2, bl6)) | 0; - mid = (mid + Math.imul(al2, bh6)) | 0; - mid = (mid + Math.imul(ah2, bl6)) | 0; - hi = (hi + Math.imul(ah2, bh6)) | 0; - lo = (lo + Math.imul(al1, bl7)) | 0; - mid = (mid + Math.imul(al1, bh7)) | 0; - mid = (mid + Math.imul(ah1, bl7)) | 0; - hi = (hi + Math.imul(ah1, bh7)) | 0; - lo = (lo + Math.imul(al0, bl8)) | 0; - mid = (mid + Math.imul(al0, bh8)) | 0; - mid = (mid + Math.imul(ah0, bl8)) | 0; - hi = (hi + Math.imul(ah0, bh8)) | 0; - var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; - w8 &= 0x3ffffff; - /* k = 9 */ - lo = Math.imul(al9, bl0); - mid = Math.imul(al9, bh0); - mid = (mid + Math.imul(ah9, bl0)) | 0; - hi = Math.imul(ah9, bh0); - lo = (lo + Math.imul(al8, bl1)) | 0; - mid = (mid + Math.imul(al8, bh1)) | 0; - mid = (mid + Math.imul(ah8, bl1)) | 0; - hi = (hi + Math.imul(ah8, bh1)) | 0; - lo = (lo + Math.imul(al7, bl2)) | 0; - mid = (mid + Math.imul(al7, bh2)) | 0; - mid = (mid + Math.imul(ah7, bl2)) | 0; - hi = (hi + Math.imul(ah7, bh2)) | 0; - lo = (lo + Math.imul(al6, bl3)) | 0; - mid = (mid + Math.imul(al6, bh3)) | 0; - mid = (mid + Math.imul(ah6, bl3)) | 0; - hi = (hi + Math.imul(ah6, bh3)) | 0; - lo = (lo + Math.imul(al5, bl4)) | 0; - mid = (mid + Math.imul(al5, bh4)) | 0; - mid = (mid + Math.imul(ah5, bl4)) | 0; - hi = (hi + Math.imul(ah5, bh4)) | 0; - lo = (lo + Math.imul(al4, bl5)) | 0; - mid = (mid + Math.imul(al4, bh5)) | 0; - mid = (mid + Math.imul(ah4, bl5)) | 0; - hi = (hi + Math.imul(ah4, bh5)) | 0; - lo = (lo + Math.imul(al3, bl6)) | 0; - mid = (mid + Math.imul(al3, bh6)) | 0; - mid = (mid + Math.imul(ah3, bl6)) | 0; - hi = (hi + Math.imul(ah3, bh6)) | 0; - lo = (lo + Math.imul(al2, bl7)) | 0; - mid = (mid + Math.imul(al2, bh7)) | 0; - mid = (mid + Math.imul(ah2, bl7)) | 0; - hi = (hi + Math.imul(ah2, bh7)) | 0; - lo = (lo + Math.imul(al1, bl8)) | 0; - mid = (mid + Math.imul(al1, bh8)) | 0; - mid = (mid + Math.imul(ah1, bl8)) | 0; - hi = (hi + Math.imul(ah1, bh8)) | 0; - lo = (lo + Math.imul(al0, bl9)) | 0; - mid = (mid + Math.imul(al0, bh9)) | 0; - mid = (mid + Math.imul(ah0, bl9)) | 0; - hi = (hi + Math.imul(ah0, bh9)) | 0; - var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; - w9 &= 0x3ffffff; - /* k = 10 */ - lo = Math.imul(al9, bl1); - mid = Math.imul(al9, bh1); - mid = (mid + Math.imul(ah9, bl1)) | 0; - hi = Math.imul(ah9, bh1); - lo = (lo + Math.imul(al8, bl2)) | 0; - mid = (mid + Math.imul(al8, bh2)) | 0; - mid = (mid + Math.imul(ah8, bl2)) | 0; - hi = (hi + Math.imul(ah8, bh2)) | 0; - lo = (lo + Math.imul(al7, bl3)) | 0; - mid = (mid + Math.imul(al7, bh3)) | 0; - mid = (mid + Math.imul(ah7, bl3)) | 0; - hi = (hi + Math.imul(ah7, bh3)) | 0; - lo = (lo + Math.imul(al6, bl4)) | 0; - mid = (mid + Math.imul(al6, bh4)) | 0; - mid = (mid + Math.imul(ah6, bl4)) | 0; - hi = (hi + Math.imul(ah6, bh4)) | 0; - lo = (lo + Math.imul(al5, bl5)) | 0; - mid = (mid + Math.imul(al5, bh5)) | 0; - mid = (mid + Math.imul(ah5, bl5)) | 0; - hi = (hi + Math.imul(ah5, bh5)) | 0; - lo = (lo + Math.imul(al4, bl6)) | 0; - mid = (mid + Math.imul(al4, bh6)) | 0; - mid = (mid + Math.imul(ah4, bl6)) | 0; - hi = (hi + Math.imul(ah4, bh6)) | 0; - lo = (lo + Math.imul(al3, bl7)) | 0; - mid = (mid + Math.imul(al3, bh7)) | 0; - mid = (mid + Math.imul(ah3, bl7)) | 0; - hi = (hi + Math.imul(ah3, bh7)) | 0; - lo = (lo + Math.imul(al2, bl8)) | 0; - mid = (mid + Math.imul(al2, bh8)) | 0; - mid = (mid + Math.imul(ah2, bl8)) | 0; - hi = (hi + Math.imul(ah2, bh8)) | 0; - lo = (lo + Math.imul(al1, bl9)) | 0; - mid = (mid + Math.imul(al1, bh9)) | 0; - mid = (mid + Math.imul(ah1, bl9)) | 0; - hi = (hi + Math.imul(ah1, bh9)) | 0; - var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; - w10 &= 0x3ffffff; - /* k = 11 */ - lo = Math.imul(al9, bl2); - mid = Math.imul(al9, bh2); - mid = (mid + Math.imul(ah9, bl2)) | 0; - hi = Math.imul(ah9, bh2); - lo = (lo + Math.imul(al8, bl3)) | 0; - mid = (mid + Math.imul(al8, bh3)) | 0; - mid = (mid + Math.imul(ah8, bl3)) | 0; - hi = (hi + Math.imul(ah8, bh3)) | 0; - lo = (lo + Math.imul(al7, bl4)) | 0; - mid = (mid + Math.imul(al7, bh4)) | 0; - mid = (mid + Math.imul(ah7, bl4)) | 0; - hi = (hi + Math.imul(ah7, bh4)) | 0; - lo = (lo + Math.imul(al6, bl5)) | 0; - mid = (mid + Math.imul(al6, bh5)) | 0; - mid = (mid + Math.imul(ah6, bl5)) | 0; - hi = (hi + Math.imul(ah6, bh5)) | 0; - lo = (lo + Math.imul(al5, bl6)) | 0; - mid = (mid + Math.imul(al5, bh6)) | 0; - mid = (mid + Math.imul(ah5, bl6)) | 0; - hi = (hi + Math.imul(ah5, bh6)) | 0; - lo = (lo + Math.imul(al4, bl7)) | 0; - mid = (mid + Math.imul(al4, bh7)) | 0; - mid = (mid + Math.imul(ah4, bl7)) | 0; - hi = (hi + Math.imul(ah4, bh7)) | 0; - lo = (lo + Math.imul(al3, bl8)) | 0; - mid = (mid + Math.imul(al3, bh8)) | 0; - mid = (mid + Math.imul(ah3, bl8)) | 0; - hi = (hi + Math.imul(ah3, bh8)) | 0; - lo = (lo + Math.imul(al2, bl9)) | 0; - mid = (mid + Math.imul(al2, bh9)) | 0; - mid = (mid + Math.imul(ah2, bl9)) | 0; - hi = (hi + Math.imul(ah2, bh9)) | 0; - var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; - w11 &= 0x3ffffff; - /* k = 12 */ - lo = Math.imul(al9, bl3); - mid = Math.imul(al9, bh3); - mid = (mid + Math.imul(ah9, bl3)) | 0; - hi = Math.imul(ah9, bh3); - lo = (lo + Math.imul(al8, bl4)) | 0; - mid = (mid + Math.imul(al8, bh4)) | 0; - mid = (mid + Math.imul(ah8, bl4)) | 0; - hi = (hi + Math.imul(ah8, bh4)) | 0; - lo = (lo + Math.imul(al7, bl5)) | 0; - mid = (mid + Math.imul(al7, bh5)) | 0; - mid = (mid + Math.imul(ah7, bl5)) | 0; - hi = (hi + Math.imul(ah7, bh5)) | 0; - lo = (lo + Math.imul(al6, bl6)) | 0; - mid = (mid + Math.imul(al6, bh6)) | 0; - mid = (mid + Math.imul(ah6, bl6)) | 0; - hi = (hi + Math.imul(ah6, bh6)) | 0; - lo = (lo + Math.imul(al5, bl7)) | 0; - mid = (mid + Math.imul(al5, bh7)) | 0; - mid = (mid + Math.imul(ah5, bl7)) | 0; - hi = (hi + Math.imul(ah5, bh7)) | 0; - lo = (lo + Math.imul(al4, bl8)) | 0; - mid = (mid + Math.imul(al4, bh8)) | 0; - mid = (mid + Math.imul(ah4, bl8)) | 0; - hi = (hi + Math.imul(ah4, bh8)) | 0; - lo = (lo + Math.imul(al3, bl9)) | 0; - mid = (mid + Math.imul(al3, bh9)) | 0; - mid = (mid + Math.imul(ah3, bl9)) | 0; - hi = (hi + Math.imul(ah3, bh9)) | 0; - var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; - w12 &= 0x3ffffff; - /* k = 13 */ - lo = Math.imul(al9, bl4); - mid = Math.imul(al9, bh4); - mid = (mid + Math.imul(ah9, bl4)) | 0; - hi = Math.imul(ah9, bh4); - lo = (lo + Math.imul(al8, bl5)) | 0; - mid = (mid + Math.imul(al8, bh5)) | 0; - mid = (mid + Math.imul(ah8, bl5)) | 0; - hi = (hi + Math.imul(ah8, bh5)) | 0; - lo = (lo + Math.imul(al7, bl6)) | 0; - mid = (mid + Math.imul(al7, bh6)) | 0; - mid = (mid + Math.imul(ah7, bl6)) | 0; - hi = (hi + Math.imul(ah7, bh6)) | 0; - lo = (lo + Math.imul(al6, bl7)) | 0; - mid = (mid + Math.imul(al6, bh7)) | 0; - mid = (mid + Math.imul(ah6, bl7)) | 0; - hi = (hi + Math.imul(ah6, bh7)) | 0; - lo = (lo + Math.imul(al5, bl8)) | 0; - mid = (mid + Math.imul(al5, bh8)) | 0; - mid = (mid + Math.imul(ah5, bl8)) | 0; - hi = (hi + Math.imul(ah5, bh8)) | 0; - lo = (lo + Math.imul(al4, bl9)) | 0; - mid = (mid + Math.imul(al4, bh9)) | 0; - mid = (mid + Math.imul(ah4, bl9)) | 0; - hi = (hi + Math.imul(ah4, bh9)) | 0; - var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; - w13 &= 0x3ffffff; - /* k = 14 */ - lo = Math.imul(al9, bl5); - mid = Math.imul(al9, bh5); - mid = (mid + Math.imul(ah9, bl5)) | 0; - hi = Math.imul(ah9, bh5); - lo = (lo + Math.imul(al8, bl6)) | 0; - mid = (mid + Math.imul(al8, bh6)) | 0; - mid = (mid + Math.imul(ah8, bl6)) | 0; - hi = (hi + Math.imul(ah8, bh6)) | 0; - lo = (lo + Math.imul(al7, bl7)) | 0; - mid = (mid + Math.imul(al7, bh7)) | 0; - mid = (mid + Math.imul(ah7, bl7)) | 0; - hi = (hi + Math.imul(ah7, bh7)) | 0; - lo = (lo + Math.imul(al6, bl8)) | 0; - mid = (mid + Math.imul(al6, bh8)) | 0; - mid = (mid + Math.imul(ah6, bl8)) | 0; - hi = (hi + Math.imul(ah6, bh8)) | 0; - lo = (lo + Math.imul(al5, bl9)) | 0; - mid = (mid + Math.imul(al5, bh9)) | 0; - mid = (mid + Math.imul(ah5, bl9)) | 0; - hi = (hi + Math.imul(ah5, bh9)) | 0; - var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; - w14 &= 0x3ffffff; - /* k = 15 */ - lo = Math.imul(al9, bl6); - mid = Math.imul(al9, bh6); - mid = (mid + Math.imul(ah9, bl6)) | 0; - hi = Math.imul(ah9, bh6); - lo = (lo + Math.imul(al8, bl7)) | 0; - mid = (mid + Math.imul(al8, bh7)) | 0; - mid = (mid + Math.imul(ah8, bl7)) | 0; - hi = (hi + Math.imul(ah8, bh7)) | 0; - lo = (lo + Math.imul(al7, bl8)) | 0; - mid = (mid + Math.imul(al7, bh8)) | 0; - mid = (mid + Math.imul(ah7, bl8)) | 0; - hi = (hi + Math.imul(ah7, bh8)) | 0; - lo = (lo + Math.imul(al6, bl9)) | 0; - mid = (mid + Math.imul(al6, bh9)) | 0; - mid = (mid + Math.imul(ah6, bl9)) | 0; - hi = (hi + Math.imul(ah6, bh9)) | 0; - var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; - w15 &= 0x3ffffff; - /* k = 16 */ - lo = Math.imul(al9, bl7); - mid = Math.imul(al9, bh7); - mid = (mid + Math.imul(ah9, bl7)) | 0; - hi = Math.imul(ah9, bh7); - lo = (lo + Math.imul(al8, bl8)) | 0; - mid = (mid + Math.imul(al8, bh8)) | 0; - mid = (mid + Math.imul(ah8, bl8)) | 0; - hi = (hi + Math.imul(ah8, bh8)) | 0; - lo = (lo + Math.imul(al7, bl9)) | 0; - mid = (mid + Math.imul(al7, bh9)) | 0; - mid = (mid + Math.imul(ah7, bl9)) | 0; - hi = (hi + Math.imul(ah7, bh9)) | 0; - var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; - w16 &= 0x3ffffff; - /* k = 17 */ - lo = Math.imul(al9, bl8); - mid = Math.imul(al9, bh8); - mid = (mid + Math.imul(ah9, bl8)) | 0; - hi = Math.imul(ah9, bh8); - lo = (lo + Math.imul(al8, bl9)) | 0; - mid = (mid + Math.imul(al8, bh9)) | 0; - mid = (mid + Math.imul(ah8, bl9)) | 0; - hi = (hi + Math.imul(ah8, bh9)) | 0; - var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; - w17 &= 0x3ffffff; - /* k = 18 */ - lo = Math.imul(al9, bl9); - mid = Math.imul(al9, bh9); - mid = (mid + Math.imul(ah9, bl9)) | 0; - hi = Math.imul(ah9, bh9); - var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; - w18 &= 0x3ffffff; - o[0] = w0; - o[1] = w1; - o[2] = w2; - o[3] = w3; - o[4] = w4; - o[5] = w5; - o[6] = w6; - o[7] = w7; - o[8] = w8; - o[9] = w9; - o[10] = w10; - o[11] = w11; - o[12] = w12; - o[13] = w13; - o[14] = w14; - o[15] = w15; - o[16] = w16; - o[17] = w17; - o[18] = w18; - if (c !== 0) { - o[19] = c; - out.length++; - } - return out; - }; - - // Polyfill comb - if (!Math.imul) { - comb10MulTo = smallMulTo; - } - - function bigMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - out.length = self.length + num.length; - - var carry = 0; - var hncarry = 0; - for (var k = 0; k < out.length - 1; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = hncarry; - hncarry = 0; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = k - j; - var a = self.words[i] | 0; - var b = num.words[j] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; - lo = (lo + rword) | 0; - rword = lo & 0x3ffffff; - ncarry = (ncarry + (lo >>> 26)) | 0; - - hncarry += ncarry >>> 26; - ncarry &= 0x3ffffff; - } - out.words[k] = rword; - carry = ncarry; - ncarry = hncarry; - } - if (carry !== 0) { - out.words[k] = carry; - } else { - out.length--; - } - - return out.strip(); - } - - function jumboMulTo (self, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self, num, out); - } - - BN.prototype.mulTo = function mulTo (num, out) { - var res; - var len = this.length + num.length; - if (this.length === 10 && num.length === 10) { - res = comb10MulTo(this, num, out); - } else if (len < 63) { - res = smallMulTo(this, num, out); - } else if (len < 1024) { - res = bigMulTo(this, num, out); - } else { - res = jumboMulTo(this, num, out); - } - - return res; - }; - - // Cooley-Tukey algorithm for FFT - // slightly revisited to rely on looping instead of recursion - - function FFTM (x, y) { - this.x = x; - this.y = y; - } - - FFTM.prototype.makeRBT = function makeRBT (N) { - var t = new Array(N); - var l = BN.prototype._countBits(N) - 1; - for (var i = 0; i < N; i++) { - t[i] = this.revBin(i, l, N); - } - - return t; - }; - - // Returns binary-reversed representation of `x` - FFTM.prototype.revBin = function revBin (x, l, N) { - if (x === 0 || x === N - 1) return x; - - var rb = 0; - for (var i = 0; i < l; i++) { - rb |= (x & 1) << (l - i - 1); - x >>= 1; - } - - return rb; - }; - - // Performs "tweedling" phase, therefore 'emulating' - // behaviour of the recursive algorithm - FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) { - rtws[i] = rws[rbt[i]]; - itws[i] = iws[rbt[i]]; - } - }; - - FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - - for (var s = 1; s < N; s <<= 1) { - var l = s << 1; - - var rtwdf = Math.cos(2 * Math.PI / l); - var itwdf = Math.sin(2 * Math.PI / l); - - for (var p = 0; p < N; p += l) { - var rtwdf_ = rtwdf; - var itwdf_ = itwdf; - - for (var j = 0; j < s; j++) { - var re = rtws[p + j]; - var ie = itws[p + j]; - - var ro = rtws[p + j + s]; - var io = itws[p + j + s]; - - var rx = rtwdf_ * ro - itwdf_ * io; - - io = rtwdf_ * io + itwdf_ * ro; - ro = rx; - - rtws[p + j] = re + ro; - itws[p + j] = ie + io; - - rtws[p + j + s] = re - ro; - itws[p + j + s] = ie - io; - - /* jshint maxdepth : false */ - if (j !== l) { - rx = rtwdf * rtwdf_ - itwdf * itwdf_; - - itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; - rtwdf_ = rx; - } - } - } - } - }; - - FFTM.prototype.guessLen13b = function guessLen13b (n, m) { - var N = Math.max(m, n) | 1; - var odd = N & 1; - var i = 0; - for (N = N / 2 | 0; N; N = N >>> 1) { - i++; - } - - return 1 << i + 1 + odd; - }; - - FFTM.prototype.conjugate = function conjugate (rws, iws, N) { - if (N <= 1) return; - - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - - rws[i] = rws[N - i - 1]; - rws[N - i - 1] = t; - - t = iws[i]; - - iws[i] = -iws[N - i - 1]; - iws[N - i - 1] = -t; - } - }; - - FFTM.prototype.normalize13b = function normalize13b (ws, N) { - var carry = 0; - for (var i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + - Math.round(ws[2 * i] / N) + - carry; - - ws[i] = w & 0x3ffffff; - - if (w < 0x4000000) { - carry = 0; - } else { - carry = w / 0x4000000 | 0; - } - } - - return ws; - }; - - FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { - var carry = 0; - for (var i = 0; i < len; i++) { - carry = carry + (ws[i] | 0); - - rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; - rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; - } - - // Pad with zeroes - for (i = 2 * len; i < N; ++i) { - rws[i] = 0; - } - - assert(carry === 0); - assert((carry & ~0x1fff) === 0); - }; - - FFTM.prototype.stub = function stub (N) { - var ph = new Array(N); - for (var i = 0; i < N; i++) { - ph[i] = 0; - } - - return ph; - }; - - FFTM.prototype.mulp = function mulp (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length); - - var rbt = this.makeRBT(N); - - var _ = this.stub(N); - - var rws = new Array(N); - var rwst = new Array(N); - var iwst = new Array(N); - - var nrws = new Array(N); - var nrwst = new Array(N); - var niwst = new Array(N); - - var rmws = out.words; - rmws.length = N; - - this.convert13b(x.words, x.length, rws, N); - this.convert13b(y.words, y.length, nrws, N); - - this.transform(rws, _, rwst, iwst, N, rbt); - this.transform(nrws, _, nrwst, niwst, N, rbt); - - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; - rwst[i] = rx; - } - - this.conjugate(rwst, iwst, N); - this.transform(rwst, iwst, rmws, _, N, rbt); - this.conjugate(rmws, _, N); - this.normalize13b(rmws, N); - - out.negative = x.negative ^ y.negative; - out.length = x.length + y.length; - return out.strip(); - }; - - // Multiply `this` by `num` - BN.prototype.mul = function mul (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return this.mulTo(num, out); - }; - - // Multiply employing FFT - BN.prototype.mulf = function mulf (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return jumboMulTo(this, num, out); - }; - - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; - - BN.prototype.imuln = function imuln (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - - // Carry - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num; - var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); - carry >>= 26; - carry += (w / 0x4000000) | 0; - // NOTE: lo is 27bit maximum - carry += lo >>> 26; - this.words[i] = lo & 0x3ffffff; - } - - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - - return this; - }; - - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; - - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; - - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; - - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } - - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; - - res = res.mul(q); - } - } - - return res; - }; - - // Shift-left in-place - BN.prototype.iushln = function iushln (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); - var i; - - if (r !== 0) { - var carry = 0; - - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask; - var c = ((this.words[i] | 0) - newCarry) << r; - this.words[i] = c | carry; - carry = newCarry >>> (26 - r); - } - - if (carry) { - this.words[i] = carry; - this.length++; - } - } - - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } - - for (i = 0; i < s; i++) { - this.words[i] = 0; - } - - this.length += s; - } - - return this.strip(); - }; - - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; - - // Shift-right in-place - // NOTE: `hint` is a lowest bit before trailing zeroes - // NOTE: if `extended` is present - it will be filled with destroyed bits - BN.prototype.iushrn = function iushrn (bits, hint, extended) { - assert(typeof bits === 'number' && bits >= 0); - var h; - if (hint) { - h = (hint - (hint % 26)) / 26; - } else { - h = 0; - } - - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; - - h -= s; - h = Math.max(0, h); - - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } - - if (s === 0) { - // No-op, we should not move anything at all - } else if (this.length > s) { - this.length -= s; - for (i = 0; i < this.length; i++) { - this.words[i] = this.words[i + s]; - } - } else { - this.words[0] = 0; - this.length = 1; - } - - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - this.words[i] = (carry << (26 - r)) | (word >>> r); - carry = word & mask; - } - - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } - - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } - - return this.strip(); - }; - - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; - - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; - - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; - - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; - - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; - - // Test if n bit is set - BN.prototype.testn = function testn (bit) { - assert(typeof bit === 'number' && bit >= 0); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; - - // Check bit and return - var w = this.words[s]; - - return !!(w & q); - }; - - // Return only lowers bits of number (in-place) - BN.prototype.imaskn = function imaskn (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - - assert(this.negative === 0, 'imaskn works only with positive numbers'); - - if (this.length <= s) { - return this; - } - - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); - - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } - - return this.strip(); - }; - - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; - - // Add plain number `num` to `this` - BN.prototype.iaddn = function iaddn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.isubn(-num); - - // Possible sign change - if (this.negative !== 0) { - if (this.length === 1 && (this.words[0] | 0) < num) { - this.words[0] = num - (this.words[0] | 0); - this.negative = 0; - return this; - } - - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } - - // Add without checks - return this._iaddn(num); - }; - - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; - - // Carry - for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { - this.words[i] -= 0x4000000; - if (i === this.length - 1) { - this.words[i + 1] = 1; - } else { - this.words[i + 1]++; - } - } - this.length = Math.max(this.length, i + 1); - - return this; - }; - - // Subtract plain number `num` from `this` - BN.prototype.isubn = function isubn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.iaddn(-num); - - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } - - this.words[0] -= num; - - if (this.length === 1 && this.words[0] < 0) { - this.words[0] = -this.words[0]; - this.negative = 1; - } else { - // Carry - for (var i = 0; i < this.length && this.words[i] < 0; i++) { - this.words[i] += 0x4000000; - this.words[i + 1] -= 1; - } - } - - return this.strip(); - }; - - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; - - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; - - BN.prototype.iabs = function iabs () { - this.negative = 0; - - return this; - }; - - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; - - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; - - this._expand(len); - - var w; - var carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - w -= right & 0x3ffffff; - carry = (w >> 26) - ((right / 0x4000000) | 0); - this.words[i + shift] = w & 0x3ffffff; - } - for (; i < this.length - shift; i++) { - w = (this.words[i + shift] | 0) + carry; - carry = w >> 26; - this.words[i + shift] = w & 0x3ffffff; - } - - if (carry === 0) return this.strip(); - - // Subtraction overflow - assert(carry === -1); - carry = 0; - for (i = 0; i < this.length; i++) { - w = -(this.words[i] | 0) + carry; - carry = w >> 26; - this.words[i] = w & 0x3ffffff; - } - this.negative = 1; - - return this.strip(); - }; - - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; - - var a = this.clone(); - var b = num; - - // Normalize - var bhi = b.words[b.length - 1] | 0; - var bhiBits = this._countBits(bhi); - shift = 26 - bhiBits; - if (shift !== 0) { - b = b.ushln(shift); - a.iushln(shift); - bhi = b.words[b.length - 1] | 0; - } - - // Initialize quotient - var m = a.length - b.length; - var q; - - if (mode !== 'mod') { - q = new BN(null); - q.length = m + 1; - q.words = new Array(q.length); - for (var i = 0; i < q.length; i++) { - q.words[i] = 0; - } - } - - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } - - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); - - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); - - a._ishlnsubmul(b, qj, j); - while (a.negative !== 0) { - qj--; - a.negative = 0; - a._ishlnsubmul(b, 1, j); - if (!a.isZero()) { - a.negative ^= 1; - } - } - if (q) { - q.words[j] = qj; - } - } - if (q) { - q.strip(); - } - a.strip(); - - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } - - return { - div: q || null, - mod: a - }; - }; - - // NOTE: 1) `mode` can be set to `mod` to request mod only, - // to `div` to request div only, or be absent to - // request both div & mod - // 2) `positive` is true if unsigned mod is requested - BN.prototype.divmod = function divmod (num, mode, positive) { - assert(!num.isZero()); - - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } - - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } - - return { - div: div, - mod: mod - }; - } - - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - return { - div: div, - mod: res.mod - }; - } - - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } - - return { - div: res.div, - mod: mod - }; - } - - // Both numbers are positive at this point - - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } - - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } - - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } - - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } - - return this._wordDiv(num, mode); - }; - - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; - - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; - - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; - - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); - - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; - - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); - - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; - - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; - - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; - - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } - - return acc; - }; - - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); - - var carry = 0; - for (var i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 0x4000000; - this.words[i] = (w / num) | 0; - carry = w % num; - } - - return this.strip(); - }; - - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; - - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var x = this; - var y = p.clone(); - - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } - - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); - - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); - - var g = 0; - - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } - - var yp = y.clone(); - var xp = x.clone(); - - while (!x.isZero()) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - x.iushrn(i); - while (i-- > 0) { - if (A.isOdd() || B.isOdd()) { - A.iadd(yp); - B.isub(xp); - } - - A.iushrn(1); - B.iushrn(1); - } - } - - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - y.iushrn(j); - while (j-- > 0) { - if (C.isOdd() || D.isOdd()) { - C.iadd(yp); - D.isub(xp); - } - - C.iushrn(1); - D.iushrn(1); - } - } - - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } - - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; - - // This is reduced incarnation of the binary EEA - // above, designated to invert members of the - // _prime_ fields F(p) at a maximal speed - BN.prototype._invmp = function _invmp (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var a = this; - var b = p.clone(); - - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } - - var x1 = new BN(1); - var x2 = new BN(0); - - var delta = b.clone(); - - while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - a.iushrn(i); - while (i-- > 0) { - if (x1.isOdd()) { - x1.iadd(delta); - } - - x1.iushrn(1); - } - } - - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - b.iushrn(j); - while (j-- > 0) { - if (x2.isOdd()) { - x2.iadd(delta); - } - - x2.iushrn(1); - } - } - - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } - - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } - - if (res.cmpn(0) < 0) { - res.iadd(p); - } - - return res; - }; - - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; - - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } - - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } - - var r = a.cmp(b); - if (r < 0) { - // Swap `a` and `b` to make `a` always bigger than `b` - var t = a; - a = b; - b = t; - } else if (r === 0 || b.cmpn(1) === 0) { - break; - } - - a.isub(b); - } while (true); - - return b.iushln(shift); - }; - - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; - - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; - - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; - - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; - - // Increment at the bit position in-line - BN.prototype.bincn = function bincn (bit) { - assert(typeof bit === 'number'); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } - - // Add bit and propagate, if needed - var carry = q; - for (var i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - w += carry; - carry = w >>> 26; - w &= 0x3ffffff; - this.words[i] = w; - } - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - return this; - }; - - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; - - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; - - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - - this.strip(); - - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } - - assert(num <= 0x3ffffff, 'Number is too big'); - - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Compare two numbers and return: - // 1 - if `this` > `num` - // 0 - if `this` == `num` - // -1 - if `this` < `num` - BN.prototype.cmp = function cmp (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Unsigned comparison - BN.prototype.ucmp = function ucmp (num) { - // At this point both numbers have the same sign - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; - - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; - - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; - - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; - - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; - - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; - - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; - - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; - - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; - - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; - - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; - - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; - - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; - - BN.prototype.toRed = function toRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - assert(this.negative === 0, 'red works only with positives'); - return ctx.convertTo(this)._forceRed(ctx); - }; - - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; - - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; - - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; - - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; - - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; - - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; - - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; - - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; - - BN.prototype.redMul = function redMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.mul(this, num); - }; - - BN.prototype.redIMul = function redIMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.imul(this, num); - }; - - BN.prototype.redSqr = function redSqr () { - assert(this.red, 'redSqr works only with red numbers'); - this.red._verify1(this); - return this.red.sqr(this); - }; - - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; - - // Square root over p - BN.prototype.redSqrt = function redSqrt () { - assert(this.red, 'redSqrt works only with red numbers'); - this.red._verify1(this); - return this.red.sqrt(this); - }; - - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; - - // Return negative clone of `this` % `red modulo` - BN.prototype.redNeg = function redNeg () { - assert(this.red, 'redNeg works only with red numbers'); - this.red._verify1(this); - return this.red.neg(this); - }; - - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; - - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - - // Pseudo-Mersenne prime - function MPrime (name, p) { - // P = 2 ^ N - K - this.name = name; - this.p = new BN(p, 16); - this.n = this.p.bitLength(); - this.k = new BN(1).iushln(this.n).isub(this.p); - - this.tmp = this._tmp(); - } - - MPrime.prototype._tmp = function _tmp () { - var tmp = new BN(null); - tmp.words = new Array(Math.ceil(this.n / 13)); - return tmp; - }; - - MPrime.prototype.ireduce = function ireduce (num) { - // Assumes that `num` is less than `P^2` - // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) - var r = num; - var rlen; - - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); - - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - if (cmp === 0) { - r.words[0] = 0; - r.length = 1; - } else if (cmp > 0) { - r.isub(this.p); - } else { - if (r.strip !== undefined) { - // r is BN v4 instance - r.strip(); - } else { - // r is BN v5 instance - r._strip(); - } - } - - return r; - }; - - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); - }; - - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); - }; - - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); - - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; - - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; - - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } - - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; - - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; - } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; - } else { - input.length -= 9; - } - }; - - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; - - // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 - var lo = 0; - for (var i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - lo += w * 0x3d1; - num.words[i] = lo & 0x3ffffff; - lo = w * 0x40 + ((lo / 0x4000000) | 0); - } - - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; - } - } - return num; - }; - - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); - - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); - - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); - } - inherits(P25519, MPrime); - - P25519.prototype.imulK = function imulK (num) { - // K = 0x13 - var carry = 0; - for (var i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 0x13 + carry; - var lo = hi & 0x3ffffff; - hi >>>= 26; - - num.words[i] = lo; - carry = hi; - } - if (carry !== 0) { - num.words[num.length++] = carry; - } - return num; - }; - - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; - - var prime; - if (name === 'k256') { - prime = new K256(); - } else if (name === 'p224') { - prime = new P224(); - } else if (name === 'p192') { - prime = new P192(); - } else if (name === 'p25519') { - prime = new P25519(); - } else { - throw new Error('Unknown prime ' + name); - } - primes[name] = prime; - - return prime; - }; - - // - // Base reduction engine - // - function Red (m) { - if (typeof m === 'string') { - var prime = BN._prime(m); - this.m = prime.p; - this.prime = prime; - } else { - assert(m.gtn(1), 'modulus must be greater than 1'); - this.m = m; - this.prime = null; - } - } - - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; - - Red.prototype._verify2 = function _verify2 (a, b) { - assert((a.negative | b.negative) === 0, 'red works only with positives'); - assert(a.red && a.red === b.red, - 'red works only with red numbers'); - }; - - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(this); - }; - - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); - } - - return this.m.sub(a)._forceRed(this); - }; - - Red.prototype.add = function add (a, b) { - this._verify2(a, b); - - var res = a.add(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.iadd = function iadd (a, b) { - this._verify2(a, b); - - var res = a.iadd(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res; - }; - - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); - - var res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); - - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res; - }; - - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); - }; - - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; - - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); - }; - - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); - }; - - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); - }; - - Red.prototype.sqrt = function sqrt (a) { - if (a.isZero()) return a.clone(); - - var mod3 = this.m.andln(3); - assert(mod3 % 2 === 1); - - // Fast case - if (mod3 === 3) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - - // Tonelli-Shanks algorithm (Totally unoptimized and slow) - // - // Find Q and S, that Q * 2 ^ S = (P - 1) - var q = this.m.subn(1); - var s = 0; - while (!q.isZero() && q.andln(1) === 0) { - s++; - q.iushrn(1); - } - assert(!q.isZero()); - - var one = new BN(1).toRed(this); - var nOne = one.redNeg(); - - // Find quadratic non-residue - // NOTE: Max is such because of generalized Riemann hypothesis. - var lpow = this.m.subn(1).iushrn(1); - var z = this.m.bitLength(); - z = new BN(2 * z * z).toRed(this); - - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } - - var c = this.pow(z, q); - var r = this.pow(a, q.addn(1).iushrn(1)); - var t = this.pow(a, q); - var m = s; - while (t.cmp(one) !== 0) { - var tmp = t; - for (var i = 0; tmp.cmp(one) !== 0; i++) { - tmp = tmp.redSqr(); - } - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } - - return r; - }; - - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); - } else { - return this.imod(inv); - } - }; - - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - - var windowSize = 4; - var wnd = new Array(1 << windowSize); - wnd[0] = new BN(1).toRed(this); - wnd[1] = a; - for (var i = 2; i < wnd.length; i++) { - wnd[i] = this.mul(wnd[i - 1], a); - } - - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; - } - - for (i = num.length - 1; i >= 0; i--) { - var word = num.words[i]; - for (var j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if (res !== wnd[0]) { - res = this.sqr(res); - } - - if (bit === 0 && current === 0) { - currentLen = 0; - continue; - } - - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; - } - start = 26; - } - - return res; - }; - - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); - - return r === num ? r.clone() : r; - }; - - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; - }; - - // - // Montgomery method engine - // - - BN.mont = function mont (num) { - return new Mont(num); - }; - - function Mont (m) { - Red.call(this, m); - - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); - } - - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); - - this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); - this.minv = this.minv.umod(this.r); - this.minv = this.r.sub(this.minv); - } - inherits(Mont, Red); - - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; - - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; - }; - - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } - - var t = a.imul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - - var t = a.mul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.invm = function invm (a) { - // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }; - })(typeof module === 'undefined' || module, this); - - },{"buffer":222}],46:[function(require,module,exports){ - var r; - - module.exports = function rand(len) { - if (!r) - r = new Rand(null); - - return r.generate(len); - }; - - function Rand(rand) { - this.rand = rand; - } - module.exports.Rand = Rand; - - Rand.prototype.generate = function generate(len) { - return this._rand(len); - }; - - // Emulate crypto API using randy - Rand.prototype._rand = function _rand(n) { - if (this.rand.getBytes) - return this.rand.getBytes(n); - - var res = new Uint8Array(n); - for (var i = 0; i < res.length; i++) - res[i] = this.rand.getByte(); - return res; - }; - - if (typeof self === 'object') { - if (self.crypto && self.crypto.getRandomValues) { - // Modern browsers - Rand.prototype._rand = function _rand(n) { - var arr = new Uint8Array(n); - self.crypto.getRandomValues(arr); - return arr; - }; - } else if (self.msCrypto && self.msCrypto.getRandomValues) { - // IE - Rand.prototype._rand = function _rand(n) { - var arr = new Uint8Array(n); - self.msCrypto.getRandomValues(arr); - return arr; - }; - - // Safari's WebWorkers do not have `crypto` - } else if (typeof window === 'object') { - // Old junk - Rand.prototype._rand = function() { - throw new Error('Not implemented yet'); - }; - } - } else { - // Node.js or Web worker with no crypto support - try { - var crypto = require('crypto'); - if (typeof crypto.randomBytes !== 'function') - throw new Error('Not supported'); - - Rand.prototype._rand = function _rand(n) { - return crypto.randomBytes(n); - }; - } catch (e) { - } - } - - },{"crypto":222}],47:[function(require,module,exports){ - var basex = require('base-x') - var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' - - module.exports = basex(ALPHABET) - - },{"base-x":40}],48:[function(require,module,exports){ - 'use strict' - - var base58 = require('bs58') - var Buffer = require('safe-buffer').Buffer - - module.exports = function (checksumFn) { - // Encode a buffer as a base58-check encoded string - function encode (payload) { - var checksum = checksumFn(payload) - - return base58.encode(Buffer.concat([ - payload, - checksum - ], payload.length + 4)) - } - - function decodeRaw (buffer) { - var payload = buffer.slice(0, -4) - var checksum = buffer.slice(-4) - var newChecksum = checksumFn(payload) - - if (checksum[0] ^ newChecksum[0] | - checksum[1] ^ newChecksum[1] | - checksum[2] ^ newChecksum[2] | - checksum[3] ^ newChecksum[3]) return - - return payload - } - - // Decode a base58-check encoded string to a buffer, no result if checksum is wrong - function decodeUnsafe (string) { - var buffer = base58.decodeUnsafe(string) - if (!buffer) return - - return decodeRaw(buffer) - } - - function decode (string) { - var buffer = base58.decode(string) - var payload = decodeRaw(buffer, checksumFn) - if (!payload) throw new Error('Invalid checksum') - return payload - } - - return { - encode: encode, - decode: decode, - decodeUnsafe: decodeUnsafe - } - } - - },{"bs58":47,"safe-buffer":122}],49:[function(require,module,exports){ - 'use strict' - - var createHash = require('create-hash') - var bs58checkBase = require('./base') - - // SHA256(SHA256(buffer)) - function sha256x2 (buffer) { - var tmp = createHash('sha256').update(buffer).digest() - return createHash('sha256').update(tmp).digest() - } - - module.exports = bs58checkBase(sha256x2) - - },{"./base":48,"create-hash":51}],50:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - var Transform = require('stream').Transform - var StringDecoder = require('string_decoder').StringDecoder - var inherits = require('inherits') - - function CipherBase (hashMode) { - Transform.call(this) - this.hashMode = typeof hashMode === 'string' - if (this.hashMode) { - this[hashMode] = this._finalOrDigest - } else { - this.final = this._finalOrDigest - } - if (this._final) { - this.__final = this._final - this._final = null - } - this._decoder = null - this._encoding = null - } - inherits(CipherBase, Transform) - - CipherBase.prototype.update = function (data, inputEnc, outputEnc) { - if (typeof data === 'string') { - data = Buffer.from(data, inputEnc) - } - - var outData = this._update(data) - if (this.hashMode) return this - - if (outputEnc) { - outData = this._toString(outData, outputEnc) - } - - return outData - } - - CipherBase.prototype.setAutoPadding = function () {} - CipherBase.prototype.getAuthTag = function () { - throw new Error('trying to get auth tag in unsupported state') - } - - CipherBase.prototype.setAuthTag = function () { - throw new Error('trying to set auth tag in unsupported state') - } - - CipherBase.prototype.setAAD = function () { - throw new Error('trying to set aad in unsupported state') - } - - CipherBase.prototype._transform = function (data, _, next) { - var err - try { - if (this.hashMode) { - this._update(data) - } else { - this.push(this._update(data)) - } - } catch (e) { - err = e - } finally { - next(err) - } - } - CipherBase.prototype._flush = function (done) { - var err - try { - this.push(this.__final()) - } catch (e) { - err = e - } - - done(err) - } - CipherBase.prototype._finalOrDigest = function (outputEnc) { - var outData = this.__final() || Buffer.alloc(0) - if (outputEnc) { - outData = this._toString(outData, outputEnc, true) - } - return outData - } - - CipherBase.prototype._toString = function (value, enc, fin) { - if (!this._decoder) { - this._decoder = new StringDecoder(enc) - this._encoding = enc - } - - if (this._encoding !== enc) throw new Error('can\'t switch encodings') - - var out = this._decoder.write(value) - if (fin) { - out += this._decoder.end() - } - - return out - } - - module.exports = CipherBase - - },{"inherits":97,"safe-buffer":122,"stream":374,"string_decoder":389}],51:[function(require,module,exports){ - 'use strict' - var inherits = require('inherits') - var MD5 = require('md5.js') - var RIPEMD160 = require('ripemd160') - var sha = require('sha.js') - var Base = require('cipher-base') - - function Hash (hash) { - Base.call(this, 'digest') - - this._hash = hash - } - - inherits(Hash, Base) - - Hash.prototype._update = function (data) { - this._hash.update(data) - } - - Hash.prototype._final = function () { - return this._hash.digest() - } - - module.exports = function createHash (alg) { - alg = alg.toLowerCase() - if (alg === 'md5') return new MD5() - if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160() - - return new Hash(sha(alg)) - } - - },{"cipher-base":50,"inherits":97,"md5.js":102,"ripemd160":121,"sha.js":128}],52:[function(require,module,exports){ - var MD5 = require('md5.js') - - module.exports = function (buffer) { - return new MD5().update(buffer).digest() - } - - },{"md5.js":102}],53:[function(require,module,exports){ - 'use strict' - var inherits = require('inherits') - var Legacy = require('./legacy') - var Base = require('cipher-base') - var Buffer = require('safe-buffer').Buffer - var md5 = require('create-hash/md5') - var RIPEMD160 = require('ripemd160') - - var sha = require('sha.js') - - var ZEROS = Buffer.alloc(128) - - function Hmac (alg, key) { - Base.call(this, 'digest') - if (typeof key === 'string') { - key = Buffer.from(key) - } - - var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 - - this._alg = alg - this._key = key - if (key.length > blocksize) { - var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) - key = hash.update(key).digest() - } else if (key.length < blocksize) { - key = Buffer.concat([key, ZEROS], blocksize) - } - - var ipad = this._ipad = Buffer.allocUnsafe(blocksize) - var opad = this._opad = Buffer.allocUnsafe(blocksize) - - for (var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) - this._hash.update(ipad) - } - - inherits(Hmac, Base) - - Hmac.prototype._update = function (data) { - this._hash.update(data) - } - - Hmac.prototype._final = function () { - var h = this._hash.digest() - var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg) - return hash.update(this._opad).update(h).digest() - } - - module.exports = function createHmac (alg, key) { - alg = alg.toLowerCase() - if (alg === 'rmd160' || alg === 'ripemd160') { - return new Hmac('rmd160', key) - } - if (alg === 'md5') { - return new Legacy(md5, key) - } - return new Hmac(alg, key) - } - - },{"./legacy":54,"cipher-base":50,"create-hash/md5":52,"inherits":97,"ripemd160":121,"safe-buffer":122,"sha.js":128}],54:[function(require,module,exports){ - 'use strict' - var inherits = require('inherits') - var Buffer = require('safe-buffer').Buffer - - var Base = require('cipher-base') - - var ZEROS = Buffer.alloc(128) - var blocksize = 64 - - function Hmac (alg, key) { - Base.call(this, 'digest') - if (typeof key === 'string') { - key = Buffer.from(key) - } - - this._alg = alg - this._key = key - - if (key.length > blocksize) { - key = alg(key) - } else if (key.length < blocksize) { - key = Buffer.concat([key, ZEROS], blocksize) - } - - var ipad = this._ipad = Buffer.allocUnsafe(blocksize) - var opad = this._opad = Buffer.allocUnsafe(blocksize) - - for (var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - - this._hash = [ipad] - } - - inherits(Hmac, Base) - - Hmac.prototype._update = function (data) { - this._hash.push(data) - } - - Hmac.prototype._final = function () { - var h = this._alg(Buffer.concat(this._hash)) - return this._alg(Buffer.concat([this._opad, h])) - } - module.exports = Hmac - - },{"cipher-base":50,"inherits":97,"safe-buffer":122}],55:[function(require,module,exports){ - (function (global,Buffer){(function (){ - "use strict"; - - var EC = require("elliptic").ec; - - var ec = new EC("secp256k1"); - var browserCrypto = global.crypto || global.msCrypto || {}; - var subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; - - var nodeCrypto = require('crypto'); - - const EC_GROUP_ORDER = Buffer.from('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 'hex'); - const ZERO32 = Buffer.alloc(32, 0); - - function assert(condition, message) { - if (!condition) { - throw new Error(message || "Assertion failed"); - } - } - - function isScalar (x) { - return Buffer.isBuffer(x) && x.length === 32; - } - - function isValidPrivateKey(privateKey) { - if (!isScalar(privateKey)) - { - return false; - } - return privateKey.compare(ZERO32) > 0 && // > 0 - privateKey.compare(EC_GROUP_ORDER) < 0; // < G - } - - // Compare two buffers in constant time to prevent timing attacks. - function equalConstTime(b1, b2) { - if (b1.length !== b2.length) { - return false; - } - var res = 0; - for (var i = 0; i < b1.length; i++) { - res |= b1[i] ^ b2[i]; // jshint ignore:line - } - return res === 0; - } - - /* This must check if we're in the browser or - not, since the functions are different and does - not convert using browserify */ - function randomBytes(size) { - var arr = new Uint8Array(size); - if (typeof browserCrypto.getRandomValues === 'undefined') { - return Buffer.from(nodeCrypto.randomBytes(size)); - } else { - browserCrypto.getRandomValues(arr); - } - return Buffer.from(arr); - } - - function sha512(msg) { - return new Promise(function(resolve) { - var hash = nodeCrypto.createHash('sha512'); - var result = hash.update(msg).digest(); - resolve(new Uint8Array(result)); - }); - } - - function getAes(op) { - return function(iv, key, data) { - return new Promise(function(resolve) { - if (subtle) { - var importAlgorithm = {name: "AES-CBC"}; - var keyp = subtle.importKey("raw", key, importAlgorithm, false, [op]); - return keyp.then(function(cryptoKey) { - var encAlgorithm = {name: "AES-CBC", iv: iv}; - return subtle[op](encAlgorithm, cryptoKey, data); - }).then(function(result) { - resolve(Buffer.from(new Uint8Array(result))); - }); - } else { - if (op === 'encrypt') { - var cipher = nodeCrypto.createCipheriv('aes-256-cbc', key, iv); - let firstChunk = cipher.update(data); - let secondChunk = cipher.final(); - resolve(Buffer.concat([firstChunk, secondChunk])); - } - else if (op === 'decrypt') { - var decipher = nodeCrypto.createDecipheriv('aes-256-cbc', key, iv); - let firstChunk = decipher.update(data); - let secondChunk = decipher.final(); - resolve(Buffer.concat([firstChunk, secondChunk])); - } - } - }); - }; - } - - var aesCbcEncrypt = getAes("encrypt"); - var aesCbcDecrypt = getAes("decrypt"); - - function hmacSha256Sign(key, msg) { - return new Promise(function(resolve) { - var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key)); - hmac.update(msg); - var result = hmac.digest(); - resolve(result); - }); - } - - function hmacSha256Verify(key, msg, sig) { - return new Promise(function(resolve) { - var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key)); - hmac.update(msg); - var expectedSig = hmac.digest(); - resolve(equalConstTime(expectedSig, sig)); - }); - } - - /** - * Generate a new valid private key. Will use the window.crypto or window.msCrypto as source - * depending on your browser. - * @return {Buffer} A 32-byte private key. - * @function - */ - exports.generatePrivate = function () { - var privateKey = randomBytes(32); - while (!isValidPrivateKey(privateKey)) { - privateKey = randomBytes(32); - } - return privateKey; - }; - - var getPublic = exports.getPublic = function(privateKey) { - // This function has sync API so we throw an error immediately. - assert(privateKey.length === 32, "Bad private key"); - assert(isValidPrivateKey(privateKey), "Bad private key"); - // XXX(Kagami): `elliptic.utils.encode` returns array for every - // encoding except `hex`. - return Buffer.from(ec.keyFromPrivate(privateKey).getPublic("arr")); - }; - - /** - * Get compressed version of public key. - */ - var getPublicCompressed = exports.getPublicCompressed = function(privateKey) { // jshint ignore:line - assert(privateKey.length === 32, "Bad private key"); - assert(isValidPrivateKey(privateKey), "Bad private key"); - // See https://github.com/wanderer/secp256k1-node/issues/46 - let compressed = true; - return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, "arr")); - }; - - // NOTE(Kagami): We don't use promise shim in Browser implementation - // because it's supported natively in new browsers (see - // ) and we can use only new browsers - // because of the WebCryptoAPI (see - // ). - exports.sign = function(privateKey, msg) { - return new Promise(function(resolve) { - assert(privateKey.length === 32, "Bad private key"); - assert(isValidPrivateKey(privateKey), "Bad private key"); - assert(msg.length > 0, "Message should not be empty"); - assert(msg.length <= 32, "Message is too long"); - resolve(Buffer.from(ec.sign(msg, privateKey, {canonical: true}).toDER())); - }); - }; - - exports.verify = function(publicKey, msg, sig) { - return new Promise(function(resolve, reject) { - assert(publicKey.length === 65 || publicKey.length === 33, "Bad public key"); - if (publicKey.length === 65) - { - assert(publicKey[0] === 4, "Bad public key"); - } - if (publicKey.length === 33) - { - assert(publicKey[0] === 2 || publicKey[0] === 3, "Bad public key"); - } - assert(msg.length > 0, "Message should not be empty"); - assert(msg.length <= 32, "Message is too long"); - if (ec.verify(msg, sig, publicKey)) { - resolve(null); - } else { - reject(new Error("Bad signature")); - } - }); - }; - - var derive = exports.derive = function(privateKeyA, publicKeyB) { - return new Promise(function(resolve) { - assert(Buffer.isBuffer(privateKeyA), "Bad private key"); - assert(Buffer.isBuffer(publicKeyB), "Bad public key"); - assert(privateKeyA.length === 32, "Bad private key"); - assert(isValidPrivateKey(privateKeyA), "Bad private key"); - assert(publicKeyB.length === 65 || publicKeyB.length === 33, "Bad public key"); - if (publicKeyB.length === 65) - { - assert(publicKeyB[0] === 4, "Bad public key"); - } - if (publicKeyB.length === 33) - { - assert(publicKeyB[0] === 2 || publicKeyB[0] === 3, "Bad public key"); - } - var keyA = ec.keyFromPrivate(privateKeyA); - var keyB = ec.keyFromPublic(publicKeyB); - var Px = keyA.derive(keyB.getPublic()); // BN instance - resolve(Buffer.from(Px.toArray())); - }); - }; - - exports.encrypt = function(publicKeyTo, msg, opts) { - opts = opts || {}; - // Tmp variables to save context from flat promises; - var iv, ephemPublicKey, ciphertext, macKey; - return new Promise(function(resolve) { - var ephemPrivateKey = opts.ephemPrivateKey || randomBytes(32); - // There is a very unlikely possibility that it is not a valid key - while(!isValidPrivateKey(ephemPrivateKey)) - { - ephemPrivateKey = opts.ephemPrivateKey || randomBytes(32); - } - ephemPublicKey = getPublic(ephemPrivateKey); - resolve(derive(ephemPrivateKey, publicKeyTo)); - }).then(function(Px) { - return sha512(Px); - }).then(function(hash) { - iv = opts.iv || randomBytes(16); - var encryptionKey = hash.slice(0, 32); - macKey = hash.slice(32); - return aesCbcEncrypt(iv, encryptionKey, msg); - }).then(function(data) { - ciphertext = data; - var dataToMac = Buffer.concat([iv, ephemPublicKey, ciphertext]); - return hmacSha256Sign(macKey, dataToMac); - }).then(function(mac) { - return { - iv: iv, - ephemPublicKey: ephemPublicKey, - ciphertext: ciphertext, - mac: mac, - }; - }); - }; - - exports.decrypt = function(privateKey, opts) { - // Tmp variable to save context from flat promises; - var encryptionKey; - return derive(privateKey, opts.ephemPublicKey).then(function(Px) { - return sha512(Px); - }).then(function(hash) { - encryptionKey = hash.slice(0, 32); - var macKey = hash.slice(32); - var dataToMac = Buffer.concat([ - opts.iv, - opts.ephemPublicKey, - opts.ciphertext - ]); - return hmacSha256Verify(macKey, dataToMac, opts.mac); - }).then(function(macGood) { - assert(macGood, "Bad MAC"); - return aesCbcDecrypt(opts.iv, encryptionKey, opts.ciphertext); - }).then(function(msg) { - return Buffer.from(new Uint8Array(msg)); - }); - }; - - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) - },{"buffer":266,"crypto":274,"elliptic":56}],56:[function(require,module,exports){ - 'use strict'; - - var elliptic = exports; - - elliptic.version = require('../package.json').version; - elliptic.utils = require('./elliptic/utils'); - elliptic.rand = require('brorand'); - elliptic.curve = require('./elliptic/curve'); - elliptic.curves = require('./elliptic/curves'); - - // Protocols - elliptic.ec = require('./elliptic/ec'); - elliptic.eddsa = require('./elliptic/eddsa'); - - },{"../package.json":71,"./elliptic/curve":59,"./elliptic/curves":62,"./elliptic/ec":63,"./elliptic/eddsa":66,"./elliptic/utils":70,"brorand":46}],57:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - var utils = require('../utils'); - var getNAF = utils.getNAF; - var getJSF = utils.getJSF; - var assert = utils.assert; - - function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); - - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); - - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); - - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); - - this._bitLength = this.n ? this.n.bitLength() : 0; - - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; - } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); - } - } - module.exports = BaseCurve; - - BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); - }; - - BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); - }; - - BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); - - var naf = getNAF(k, 1, this._bitLength); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; - - // Translate into more windowed form - var repr = []; - var j; - var nafW; - for (j = 0; j < naf.length; j += doubles.step) { - nafW = 0; - for (var l = j + doubles.step - 1; l >= j; l--) - nafW = (nafW << 1) + naf[l]; - repr.push(nafW); - } - - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (j = 0; j < repr.length; j++) { - nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); - }; - - BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; - - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; - - // Get NAF form - var naf = getNAF(k, w, this._bitLength); - - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var l = 0; i >= 0 && naf[i] === 0; i--) - l++; - if (i >= 0) - l++; - acc = acc.dblp(l); - - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; - }; - - BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; - - // Fill all arrays - var max = 0; - var i; - var j; - var p; - for (i = 0; i < len; i++) { - p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } - - // Comb small window NAFs - for (i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); - naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } - - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b], /* 7 */ - ]; - - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } - - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3, /* 1 1 */ - ]; - - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; - - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } - - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (i = max; i >= 0; i--) { - var k = 0; - - while (i >= 0) { - var zero = true; - for (j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; - - for (j = 0; j < len; j++) { - var z = tmp[j]; - p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); - - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (i = 0; i < len; i++) - wnd[i] = null; - - if (jacobianResult) - return acc; - else - return acc.toP(); - }; - - function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; - } - BaseCurve.BasePoint = BasePoint; - - BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); - }; - - BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); - }; - - BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); - - var len = this.p.byteLength(); - - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); - - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); - - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); - } - throw new Error('Unknown point format'); - }; - - BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); - }; - - BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); - - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); - - return [ 0x04 ].concat(x, this.getY().toArray('be', len)); - }; - - BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); - }; - - BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; - - var precomputed = { - doubles: null, - naf: null, - beta: null, - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; - - return this; - }; - - BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; - - var doubles = this.precomputed.doubles; - if (!doubles) - return false; - - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); - }; - - BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); - } - return { - step: step, - points: doubles, - }; - }; - - BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res, - }; - }; - - BasePoint.prototype._getBeta = function _getBeta() { - return null; - }; - - BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; - }; - - },{"../utils":70,"bn.js":45}],58:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var BN = require('bn.js'); - var inherits = require('inherits'); - var Base = require('./base'); - - var assert = utils.assert; - - function EdwardsCurve(conf) { - // NOTE: Important as we are creating point in Base.call() - this.twisted = (conf.a | 0) !== 1; - this.mOneA = this.twisted && (conf.a | 0) === -1; - this.extended = this.mOneA; - - Base.call(this, 'edwards', conf); - - this.a = new BN(conf.a, 16).umod(this.red.m); - this.a = this.a.toRed(this.red); - this.c = new BN(conf.c, 16).toRed(this.red); - this.c2 = this.c.redSqr(); - this.d = new BN(conf.d, 16).toRed(this.red); - this.dd = this.d.redAdd(this.d); - - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; - } - inherits(EdwardsCurve, Base); - module.exports = EdwardsCurve; - - EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); - else - return this.a.redMul(num); - }; - - EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); - }; - - // Just for compatibility with Short curve - EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); - }; - - EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var x2 = x.redSqr(); - var rhs = this.c2.redSub(this.a.redMul(x2)); - var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); - }; - - EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); - - // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) - var y2 = y.redSqr(); - var lhs = y2.redSub(this.c2); - var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); - var x2 = lhs.redMul(rhs.redInvm()); - - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } - - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); - - return this.point(x, y); - }; - - EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; - - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); - - var x2 = point.x.redSqr(); - var y2 = point.y.redSqr(); - var lhs = x2.redMul(this.a).redAdd(y2); - var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - - return lhs.cmp(rhs) === 0; - }; - - function Point(curve, x, y, z, t) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && y === null && z === null) { - this.x = this.curve.zero; - this.y = this.curve.one; - this.z = this.curve.one; - this.t = this.curve.zero; - this.zOne = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = z ? new BN(z, 16) : this.curve.one; - this.t = t && new BN(t, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - if (this.t && !this.t.red) - this.t = this.t.toRed(this.curve.red); - this.zOne = this.z === this.curve.one; - - // Use extended coordinates - if (this.curve.extended && !this.t) { - this.t = this.x.redMul(this.y); - if (!this.zOne) - this.t = this.t.redMul(this.z.redInvm()); - } - } - } - inherits(Point, Base.BasePoint); - - EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); - }; - - EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); - }; - - Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); - }; - - Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; - }; - - Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.x.cmpn(0) === 0 && - (this.y.cmp(this.z) === 0 || - (this.zOne && this.y.cmp(this.curve.c) === 0)); - }; - - Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S - - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = 2 * Z1^2 - var c = this.z.redSqr(); - c = c.redIAdd(c); - // D = a * A - var d = this.curve._mulA(a); - // E = (X1 + Y1)^2 - A - B - var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); - // G = D + B - var g = d.redAdd(b); - // F = G - C - var f = g.redSub(c); - // H = D - B - var h = d.redSub(b); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); - }; - - Point.prototype._projDbl = function _projDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #doubling-dbl-2008-bbjlp - // #doubling-dbl-2007-bl - // and others - // Generally 3M + 4S or 2M + 4S - - // B = (X1 + Y1)^2 - var b = this.x.redAdd(this.y).redSqr(); - // C = X1^2 - var c = this.x.redSqr(); - // D = Y1^2 - var d = this.y.redSqr(); - - var nx; - var ny; - var nz; - var e; - var h; - var j; - if (this.curve.twisted) { - // E = a * C - e = this.curve._mulA(c); - // F = E + D - var f = e.redAdd(d); - if (this.zOne) { - // X3 = (B - C - D) * (F - 2) - nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F^2 - 2 * F - nz = f.redSqr().redSub(f).redSub(f); - } else { - // H = Z1^2 - h = this.z.redSqr(); - // J = F - 2 * H - j = f.redSub(h).redISub(h); - // X3 = (B-C-D)*J - nx = b.redSub(c).redISub(d).redMul(j); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F * J - nz = f.redMul(j); - } - } else { - // E = C + D - e = c.redAdd(d); - // H = (c * Z1)^2 - h = this.curve._mulC(this.z).redSqr(); - // J = E - 2 * H - j = e.redSub(h).redSub(h); - // X3 = c * (B - E) * J - nx = this.curve._mulC(b.redISub(e)).redMul(j); - // Y3 = c * E * (C - D) - ny = this.curve._mulC(e).redMul(c.redISub(d)); - // Z3 = E * J - nz = e.redMul(j); - } - return this.curve.point(nx, ny, nz); - }; - - Point.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; - - // Double in extended coordinates - if (this.curve.extended) - return this._extDbl(); - else - return this._projDbl(); - }; - - Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M - - // A = (Y1 - X1) * (Y2 - X2) - var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); - // B = (Y1 + X1) * (Y2 + X2) - var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); - // C = T1 * k * T2 - var c = this.t.redMul(this.curve.dd).redMul(p.t); - // D = Z1 * 2 * Z2 - var d = this.z.redMul(p.z.redAdd(p.z)); - // E = B - A - var e = b.redSub(a); - // F = D - C - var f = d.redSub(c); - // G = D + C - var g = d.redAdd(c); - // H = B + A - var h = b.redAdd(a); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); - }; - - Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S - - // A = Z1 * Z2 - var a = this.z.redMul(p.z); - // B = A^2 - var b = a.redSqr(); - // C = X1 * X2 - var c = this.x.redMul(p.x); - // D = Y1 * Y2 - var d = this.y.redMul(p.y); - // E = d * C * D - var e = this.curve.d.redMul(c).redMul(d); - // F = B - E - var f = b.redSub(e); - // G = B + E - var g = b.redAdd(e); - // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) - var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); - var nx = a.redMul(f).redMul(tmp); - var ny; - var nz; - if (this.curve.twisted) { - // Y3 = A * G * (D - a * C) - ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); - // Z3 = F * G - nz = f.redMul(g); - } else { - // Y3 = A * G * (D - C) - ny = a.redMul(g).redMul(d.redSub(c)); - // Z3 = c * F * G - nz = this.curve._mulC(f).redMul(g); - } - return this.curve.point(nx, ny, nz); - }; - - Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; - - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); - }; - - Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); - }; - - Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); - }; - - Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); - }; - - Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; - - // Normalize coordinates - var zi = this.z.redInvm(); - this.x = this.x.redMul(zi); - this.y = this.y.redMul(zi); - if (this.t) - this.t = this.t.redMul(zi); - this.z = this.curve.one; - this.zOne = true; - return this; - }; - - Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); - }; - - Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); - }; - - Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); - }; - - Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; - }; - - Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; - - var xc = x.clone(); - var t = this.curve.redN.redMul(this.z); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } - }; - - // Compatibility with BaseCurve - Point.prototype.toP = Point.prototype.normalize; - Point.prototype.mixedAdd = Point.prototype.add; - - },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],59:[function(require,module,exports){ - 'use strict'; - - var curve = exports; - - curve.base = require('./base'); - curve.short = require('./short'); - curve.mont = require('./mont'); - curve.edwards = require('./edwards'); - - },{"./base":57,"./edwards":58,"./mont":60,"./short":61}],60:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - var inherits = require('inherits'); - var Base = require('./base'); - - var utils = require('../utils'); - - function MontCurve(conf) { - Base.call(this, 'mont', conf); - - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.i4 = new BN(4).toRed(this.red).redInvm(); - this.two = new BN(2).toRed(this.red); - this.a24 = this.i4.redMul(this.a.redAdd(this.two)); - } - inherits(MontCurve, Base); - module.exports = MontCurve; - - MontCurve.prototype.validate = function validate(point) { - var x = point.normalize().x; - var x2 = x.redSqr(); - var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); - var y = rhs.redSqrt(); - - return y.redSqr().cmp(rhs) === 0; - }; - - function Point(curve, x, z) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && z === null) { - this.x = this.curve.one; - this.z = this.curve.zero; - } else { - this.x = new BN(x, 16); - this.z = new BN(z, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - } - } - inherits(Point, Base.BasePoint); - - MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); - }; - - MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); - }; - - MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); - }; - - Point.prototype.precompute = function precompute() { - // No-op - }; - - Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); - }; - - Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); - }; - - Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; - }; - - Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; - }; - - Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A - - // A = X1 + Z1 - var a = this.x.redAdd(this.z); - // AA = A^2 - var aa = a.redSqr(); - // B = X1 - Z1 - var b = this.x.redSub(this.z); - // BB = B^2 - var bb = b.redSqr(); - // C = AA - BB - var c = aa.redSub(bb); - // X3 = AA * BB - var nx = aa.redMul(bb); - // Z3 = C * (BB + A24 * C) - var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); - return this.curve.point(nx, nz); - }; - - Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); - }; - - Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A - - // A = X2 + Z2 - var a = this.x.redAdd(this.z); - // B = X2 - Z2 - var b = this.x.redSub(this.z); - // C = X3 + Z3 - var c = p.x.redAdd(p.z); - // D = X3 - Z3 - var d = p.x.redSub(p.z); - // DA = D * A - var da = d.redMul(a); - // CB = C * B - var cb = c.redMul(b); - // X5 = Z1 * (DA + CB)^2 - var nx = diff.z.redMul(da.redAdd(cb).redSqr()); - // Z5 = X1 * (DA - CB)^2 - var nz = diff.x.redMul(da.redISub(cb).redSqr()); - return this.curve.point(nx, nz); - }; - - Point.prototype.mul = function mul(k) { - var t = k.clone(); - var a = this; // (N / 2) * Q + Q - var b = this.curve.point(null, null); // (N / 2) * Q - var c = this; // Q - - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); - - for (var i = bits.length - 1; i >= 0; i--) { - if (bits[i] === 0) { - // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q - a = a.diffAdd(b, c); - // N * Q = 2 * ((N / 2) * Q + Q)) - b = b.dbl(); - } else { - // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) - b = a.diffAdd(b, c); - // N * Q + Q = 2 * ((N / 2) * Q + Q) - a = a.dbl(); - } - } - return b; - }; - - Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); - }; - - Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); - }; - - Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; - }; - - Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; - }; - - Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); - - return this.x.fromRed(); - }; - - },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],61:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var BN = require('bn.js'); - var inherits = require('inherits'); - var Base = require('./base'); - - var assert = utils.assert; - - function ShortCurve(conf) { - Base.call(this, 'short', conf); - - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); - - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); - } - inherits(ShortCurve, Base); - module.exports = ShortCurve; - - ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; - - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); - } - } - - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16), - }; - }); - } else { - basis = this._getEndoBasis(lambda); - } - - return { - beta: beta, - lambda: lambda, - basis: basis, - }; - }; - - ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); - - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; - }; - - ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); - - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; - - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); - - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; - - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; - - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } - - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } - - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 }, - ]; - }; - - ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; - - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); - - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); - - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; - }; - - ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); - }; - - ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; - - var x = point.x; - var y = point.y; - - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; - }; - - ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); - - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); - } - - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; - } - return res; - }; - - function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } - } - inherits(Point, Base.BasePoint); - - ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); - }; - - ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); - }; - - Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; - - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; - - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul), - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul), - }, - }; - } - return beta; - }; - - Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; - - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1), - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1), - }, - } ]; - }; - - Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; - - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } - - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)), - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)), - }, - }; - return res; - }; - - Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; - }; - - Point.prototype.isInfinity = function isInfinity() { - return this.inf; - }; - - Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; - - // P + O = P - if (p.inf) - return this; - - // P + P = 2P - if (this.eq(p)) - return this.dbl(); - - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); - - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); - - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); - }; - - Point.prototype.dbl = function dbl() { - if (this.inf) - return this; - - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); - - var a = this.curve.a; - - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); - }; - - Point.prototype.getX = function getX() { - return this.x.fromRed(); - }; - - Point.prototype.getY = function getY() { - return this.y.fromRed(); - }; - - Point.prototype.mul = function mul(k) { - k = new BN(k, 16); - if (this.isInfinity()) - return this; - else if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); - }; - - Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); - }; - - Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); - }; - - Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); - }; - - Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; - - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate), - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate), - }, - }; - } - return res; - }; - - Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); - - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; - }; - - function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; - } - inherits(JPoint, Base.BasePoint); - - ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); - }; - - JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); - - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); - - return this.curve.point(ax, ay); - }; - - JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); - }; - - JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; - - // P + O = P - if (p.isInfinity()) - return this; - - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); - - // P + O = P - if (p.isInfinity()) - return this; - - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); - - var i; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (i = 0; i < pow; i++) - r = r.dbl(); - return r; - } - - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; - - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - // Reuse results - var jyd = jy.redAdd(jy); - for (i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); - - jx = nx; - jz = nz; - jyd = dny; - } - - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); - }; - - JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; - - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); - }; - - JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); - - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A - - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); - - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); - - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S - - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; - - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); - - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); - - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); - - return this.curve.jpoint(nx, ny, nz); - }; - - JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); - - return this.curve._wnafMul(this, k); - }; - - JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); - - if (this === p) - return true; - - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; - - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; - }; - - JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; - - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } - }; - - JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; - }; - - JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; - }; - - },{"../utils":70,"./base":57,"bn.js":45,"inherits":97}],62:[function(require,module,exports){ - 'use strict'; - - var curves = exports; - - var hash = require('hash.js'); - var curve = require('./curve'); - var utils = require('./utils'); - - var assert = utils.assert; - - function PresetCurve(options) { - if (options.type === 'short') - this.curve = new curve.short(options); - else if (options.type === 'edwards') - this.curve = new curve.edwards(options); - else - this.curve = new curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; - - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); - } - curves.PresetCurve = PresetCurve; - - function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve, - }); - return curve; - }, - }); - } - - defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811', - ], - }); - - defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34', - ], - }); - - defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5', - ], - }); - - defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f', - ], - }); - - defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650', - ], - }); - - defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '1', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9', - ], - }); - - defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658', - ], - }); - - var pre; - try { - pre = require('./precomputed/secp256k1'); - } catch (e) { - pre = undefined; - } - - defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3', - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15', - }, - ], - - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre, - ], - }); - - },{"./curve":59,"./precomputed/secp256k1":69,"./utils":70,"hash.js":83}],63:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - var HmacDRBG = require('hmac-drbg'); - var utils = require('../utils'); - var curves = require('../curves'); - var rand = require('brorand'); - var assert = utils.assert; - - var KeyPair = require('./key'); - var Signature = require('./signature'); - - function EC(options) { - if (!(this instanceof EC)) - return new EC(options); - - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(Object.prototype.hasOwnProperty.call(curves, options), - 'Unknown curve ' + options); - - options = curves[options]; - } - - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof curves.PresetCurve) - options = { curve: options }; - - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; - - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); - - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; - } - module.exports = EC; - - EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); - }; - - EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); - }; - - EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); - }; - - EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; - - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - entropy: options.entropy || rand(this.hash.hmacStrength), - entropyEnc: options.entropy && options.entropyEnc || 'utf8', - nonce: this.n.toArray(), - }); - - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - for (;;) { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; - - priv.iaddn(1); - return this.keyFromPrivate(priv); - } - }; - - EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; - }; - - EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; - - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); - - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); - - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); - - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - }); - - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); - - for (var iter = 0; ; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; - - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; - - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; - - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; - - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); - - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } - - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); - } - }; - - EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); - - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; - - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); - var p; - - if (!this.curve._maxwellTrick) { - p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - return p.getX().umod(this.n).cmp(r) === 0; - } - - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); - }; - - EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); - - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; - - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); - - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); - - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); - - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); - }; - - EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; - - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; - } - - if (Qprime.eq(Q)) - return i; - } - throw new Error('Unable to find valid recovery factor'); - }; - - },{"../curves":62,"../utils":70,"./key":64,"./signature":65,"bn.js":45,"brorand":46,"hmac-drbg":95}],64:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - var utils = require('../utils'); - var assert = utils.assert; - - function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); - } - module.exports = KeyPair; - - KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc, - }); - }; - - KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - - return new KeyPair(ec, { - priv: priv, - privEnc: enc, - }); - }; - - KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); - - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; - - return { result: true, reason: null }; - }; - - KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; - } - - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); - - if (!enc) - return this.pub; - - return this.pub.encode(enc, compact); - }; - - KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); - else - return this.priv; - }; - - KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); - }; - - KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - // Montgomery points only have an `x` coordinate. - // Weierstrass/Edwards points on the other hand have both `x` and - // `y` coordinates. - if (this.ec.curve.type === 'mont') { - assert(key.x, 'Need x coordinate'); - } else if (this.ec.curve.type === 'short' || - this.ec.curve.type === 'edwards') { - assert(key.x && key.y, 'Need both x and y coordinate'); - } - this.pub = this.ec.curve.point(key.x, key.y); - return; - } - this.pub = this.ec.curve.decodePoint(key, enc); - }; - - // ECDH - KeyPair.prototype.derive = function derive(pub) { - if(!pub.validate()) { - assert(pub.validate(), 'public point not validated'); - } - return pub.mul(this.priv).getX(); - }; - - // ECDSA - KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); - }; - - KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); - }; - - KeyPair.prototype.inspect = function inspect() { - return ''; - }; - - },{"../utils":70,"bn.js":45}],65:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - - var utils = require('../utils'); - var assert = utils.assert; - - function Signature(options, enc) { - if (options instanceof Signature) - return options; - - if (this._importDER(options, enc)) - return; - - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; - } - module.exports = Signature; - - function Position() { - this.place = 0; - } - - function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - - // Indefinite length or overflow - if (octetLen === 0 || octetLen > 4) { - return false; - } - - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - val >>>= 0; - } - - // Leading zeroes - if (val <= 0x7f) { - return false; - } - - p.place = off; - return val; - } - - function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); - } - - Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if (len === false) { - return false; - } - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - if (rlen === false) { - return false; - } - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (slen === false) { - return false; - } - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0) { - if (r[1] & 0x80) { - r = r.slice(1); - } else { - // Leading zeroes - return false; - } - } - if (s[0] === 0) { - if (s[1] & 0x80) { - s = s.slice(1); - } else { - // Leading zeroes - return false; - } - } - - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; - - return true; - }; - - function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); - } - - Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); - - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); - - r = rmPadding(r); - s = rmPadding(s); - - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); - }; - - },{"../utils":70,"bn.js":45}],66:[function(require,module,exports){ - 'use strict'; - - var hash = require('hash.js'); - var curves = require('../curves'); - var utils = require('../utils'); - var assert = utils.assert; - var parseBytes = utils.parseBytes; - var KeyPair = require('./key'); - var Signature = require('./signature'); - - function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); - - if (!(this instanceof EDDSA)) - return new EDDSA(curve); - - curve = curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); - - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; - } - - module.exports = EDDSA; - - /** - * @param {Array|String} message - message bytes - * @param {Array|String|KeyPair} secret - secret bytes or a keypair - * @returns {Signature} - signature - */ - EDDSA.prototype.sign = function sign(message, secret) { - message = parseBytes(message); - var key = this.keyFromSecret(secret); - var r = this.hashInt(key.messagePrefix(), message); - var R = this.g.mul(r); - var Rencoded = this.encodePoint(R); - var s_ = this.hashInt(Rencoded, key.pubBytes(), message) - .mul(key.priv()); - var S = r.add(s_).umod(this.curve.n); - return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); - }; - - /** - * @param {Array} message - message bytes - * @param {Array|String|Signature} sig - sig bytes - * @param {Array|String|Point|KeyPair} pub - public key - * @returns {Boolean} - true if public key matches sig of message - */ - EDDSA.prototype.verify = function verify(message, sig, pub) { - message = parseBytes(message); - sig = this.makeSignature(sig); - var key = this.keyFromPublic(pub); - var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); - var SG = this.g.mul(sig.S()); - var RplusAh = sig.R().add(key.pub().mul(h)); - return RplusAh.eq(SG); - }; - - EDDSA.prototype.hashInt = function hashInt() { - var hash = this.hash(); - for (var i = 0; i < arguments.length; i++) - hash.update(arguments[i]); - return utils.intFromLE(hash.digest()).umod(this.curve.n); - }; - - EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); - }; - - EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); - }; - - EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); - }; - - /** - * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 - * - * EDDSA defines methods for encoding and decoding points and integers. These are - * helper convenience methods, that pass along to utility functions implied - * parameters. - * - */ - EDDSA.prototype.encodePoint = function encodePoint(point) { - var enc = point.getY().toArray('le', this.encodingLength); - enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; - return enc; - }; - - EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); - - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); - }; - - EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); - }; - - EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); - }; - - EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; - }; - - },{"../curves":62,"../utils":70,"./key":67,"./signature":68,"hash.js":83}],67:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var assert = utils.assert; - var parseBytes = utils.parseBytes; - var cachedProperty = utils.cachedProperty; - - /** - * @param {EDDSA} eddsa - instance - * @param {Object} params - public/private key parameters - * - * @param {Array} [params.secret] - secret seed bytes - * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) - * @param {Array} [params.pub] - public key point encoded as bytes - * - */ - function KeyPair(eddsa, params) { - this.eddsa = eddsa; - this._secret = parseBytes(params.secret); - if (eddsa.isPoint(params.pub)) - this._pub = params.pub; - else - this._pubBytes = parseBytes(params.pub); - } - - KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); - }; - - KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); - }; - - KeyPair.prototype.secret = function secret() { - return this._secret; - }; - - cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); - }); - - cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); - }); - - cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; - - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; - - return a; - }); - - cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); - }); - - cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); - }); - - cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); - }); - - KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); - }; - - KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); - }; - - KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); - }; - - KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); - }; - - module.exports = KeyPair; - - },{"../utils":70}],68:[function(require,module,exports){ - 'use strict'; - - var BN = require('bn.js'); - var utils = require('../utils'); - var assert = utils.assert; - var cachedProperty = utils.cachedProperty; - var parseBytes = utils.parseBytes; - - /** - * @param {EDDSA} eddsa - eddsa instance - * @param {Array|Object} sig - - * @param {Array|Point} [sig.R] - R point as Point or bytes - * @param {Array|bn} [sig.S] - S scalar as bn or bytes - * @param {Array} [sig.Rencoded] - R point encoded - * @param {Array} [sig.Sencoded] - S scalar encoded - */ - function Signature(eddsa, sig) { - this.eddsa = eddsa; - - if (typeof sig !== 'object') - sig = parseBytes(sig); - - if (Array.isArray(sig)) { - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength), - }; - } - - assert(sig.R && sig.S, 'Signature without R or S'); - - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; - - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; - } - - cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); - }); - - cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); - }); - - cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); - }); - - cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); - }); - - Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); - }; - - Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); - }; - - module.exports = Signature; - - },{"../utils":70,"bn.js":45}],69:[function(require,module,exports){ - module.exports = { - doubles: { - step: 4, - points: [ - [ - 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', - 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', - ], - [ - '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', - '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', - ], - [ - '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', - 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', - ], - [ - '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', - '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', - ], - [ - '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', - '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', - ], - [ - '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', - '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', - ], - [ - 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', - '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', - ], - [ - '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', - 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', - ], - [ - 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', - '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', - ], - [ - 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', - 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', - ], - [ - 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', - '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', - ], - [ - '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', - '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', - ], - [ - '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', - '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', - ], - [ - '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', - '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', - ], - [ - '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', - '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', - ], - [ - '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', - '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', - ], - [ - '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', - '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', - ], - [ - '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', - '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', - ], - [ - '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', - 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', - ], - [ - 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', - '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', - ], - [ - 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', - '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', - ], - [ - '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', - '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', - ], - [ - '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', - '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', - ], - [ - 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', - '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', - ], - [ - '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', - 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', - ], - [ - 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', - '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', - ], - [ - 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', - 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', - ], - [ - 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', - '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', - ], - [ - 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', - 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', - ], - [ - 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', - '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', - ], - [ - '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', - 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', - ], - [ - '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', - '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', - ], - [ - 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', - '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', - ], - [ - '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', - 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', - ], - [ - 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', - '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', - ], - [ - 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', - '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', - ], - [ - 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', - 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', - ], - [ - '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', - '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', - ], - [ - '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', - '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', - ], - [ - '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', - 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', - ], - [ - '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', - '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', - ], - [ - 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', - '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', - ], - [ - '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', - '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', - ], - [ - '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', - 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', - ], - [ - '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', - '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', - ], - [ - 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', - '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', - ], - [ - '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', - 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', - ], - [ - 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', - 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', - ], - [ - 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', - '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', - ], - [ - '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', - 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', - ], - [ - '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', - 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', - ], - [ - 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', - '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', - ], - [ - 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', - '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', - ], - [ - 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', - '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', - ], - [ - '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', - 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', - ], - [ - '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', - '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', - ], - [ - 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', - 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', - ], - [ - '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', - 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', - ], - [ - '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', - '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', - ], - [ - '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', - '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', - ], - [ - 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', - 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', - ], - [ - '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', - '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', - ], - [ - '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', - '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', - ], - [ - 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', - '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', - ], - [ - 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', - 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', - ], - ], - }, - naf: { - wnd: 7, - points: [ - [ - 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', - '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', - ], - [ - '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', - 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', - ], - [ - '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', - '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', - ], - [ - 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', - 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', - ], - [ - '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', - 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', - ], - [ - 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', - 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', - ], - [ - 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', - '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', - ], - [ - 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', - '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', - ], - [ - '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', - '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', - ], - [ - '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', - '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', - ], - [ - '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', - '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', - ], - [ - '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', - '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', - ], - [ - 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', - 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', - ], - [ - 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', - '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', - ], - [ - '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', - 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', - ], - [ - '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', - 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', - ], - [ - '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', - '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', - ], - [ - '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', - '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', - ], - [ - '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', - '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', - ], - [ - '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', - 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', - ], - [ - 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', - 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', - ], - [ - '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', - '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', - ], - [ - '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', - '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', - ], - [ - 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', - 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', - ], - [ - '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', - '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', - ], - [ - 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', - 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', - ], - [ - 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', - 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', - ], - [ - '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', - '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', - ], - [ - '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', - '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', - ], - [ - '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', - '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', - ], - [ - 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', - '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', - ], - [ - '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', - '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', - ], - [ - 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', - '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', - ], - [ - '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', - 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', - ], - [ - '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', - 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', - ], - [ - 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', - 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', - ], - [ - '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', - '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', - ], - [ - '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', - 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', - ], - [ - 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', - 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', - ], - [ - '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', - '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', - ], - [ - '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', - 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', - ], - [ - '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', - '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', - ], - [ - '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', - 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', - ], - [ - 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', - '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', - ], - [ - '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', - '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', - ], - [ - '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', - 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', - ], - [ - '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', - 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', - ], - [ - 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', - 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', - ], - [ - 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', - 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', - ], - [ - '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', - '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', - ], - [ - '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', - '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', - ], - [ - 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', - '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', - ], - [ - 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', - 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', - ], - [ - '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', - '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', - ], - [ - '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', - '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', - ], - [ - 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', - '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', - ], - [ - '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', - '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', - ], - [ - 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', - 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', - ], - [ - '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', - 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', - ], - [ - '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', - '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', - ], - [ - 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', - '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', - ], - [ - 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', - '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', - ], - [ - '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', - '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', - ], - [ - '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', - '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', - ], - [ - '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', - 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', - ], - [ - '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', - 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', - ], - [ - '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', - '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', - ], - [ - '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', - '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', - ], - [ - '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', - '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', - ], - [ - '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', - 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', - ], - [ - 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', - 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', - ], - [ - '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', - 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', - ], - [ - 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', - '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', - ], - [ - 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', - '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', - ], - [ - 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', - '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', - ], - [ - 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', - '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', - ], - [ - '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', - 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', - ], - [ - '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', - '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', - ], - [ - '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', - 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', - ], - [ - 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', - 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', - ], - [ - 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', - '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', - ], - [ - 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', - 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', - ], - [ - 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', - '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', - ], - [ - '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', - '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', - ], - [ - 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', - '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', - ], - [ - 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', - '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', - ], - [ - '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', - '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', - ], - [ - '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', - 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', - ], - [ - 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', - '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', - ], - [ - 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', - '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', - ], - [ - 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', - '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', - ], - [ - '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', - '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', - ], - [ - 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', - 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', - ], - [ - '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', - 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', - ], - [ - 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', - 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', - ], - [ - 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', - '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', - ], - [ - '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', - 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', - ], - [ - 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', - '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', - ], - [ - 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', - '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', - ], - [ - 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', - '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', - ], - [ - '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', - 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', - ], - [ - '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', - 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', - ], - [ - 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', - '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', - ], - [ - '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', - 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', - ], - [ - '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', - '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', - ], - [ - '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', - 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', - ], - [ - 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', - 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', - ], - [ - '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', - 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', - ], - [ - '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', - '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', - ], - [ - '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', - 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', - ], - [ - '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', - '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', - ], - [ - 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', - 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', - ], - [ - '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', - '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', - ], - [ - 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', - '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', - ], - [ - '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', - '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', - ], - [ - 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', - 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', - ], - [ - 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', - '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', - ], - [ - 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', - 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', - ], - [ - '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', - 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', - ], - [ - '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', - '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', - ], - [ - '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', - 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', - ], - [ - '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', - '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', - ], - [ - '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', - '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', - ], - [ - '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', - 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', - ], - [ - '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', - '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', - ], - [ - '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', - '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', - ], - [ - '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', - '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', - ], - ], - }, - }; - - },{}],70:[function(require,module,exports){ - 'use strict'; - - var utils = exports; - var BN = require('bn.js'); - var minAssert = require('minimalistic-assert'); - var minUtils = require('minimalistic-crypto-utils'); - - utils.assert = minAssert; - utils.toArray = minUtils.toArray; - utils.zero2 = minUtils.zero2; - utils.toHex = minUtils.toHex; - utils.encode = minUtils.encode; - - // Represent num in a w-NAF form - function getNAF(num, w, bits) { - var naf = new Array(Math.max(num.bitLength(), bits) + 1); - naf.fill(0); - - var ws = 1 << (w + 1); - var k = num.clone(); - - for (var i = 0; i < naf.length; i++) { - var z; - var mod = k.andln(ws - 1); - if (k.isOdd()) { - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); - } else { - z = 0; - } - - naf[i] = z; - k.iushrn(1); - } - - return naf; - } - utils.getNAF = getNAF; - - // Represent k1, k2 in a Joint Sparse Form - function getJSF(k1, k2) { - var jsf = [ - [], - [], - ]; - - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - var m8; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; - } else { - m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; - } - jsf[0].push(u1); - - var u2; - if ((m24 & 1) === 0) { - u2 = 0; - } else { - m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; - } - jsf[1].push(u2); - - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); - } - - return jsf; - } - utils.getJSF = getJSF; - - function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); - }; - } - utils.cachedProperty = cachedProperty; - - function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; - } - utils.parseBytes = parseBytes; - - function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); - } - utils.intFromLE = intFromLE; - - - },{"bn.js":45,"minimalistic-assert":103,"minimalistic-crypto-utils":104}],71:[function(require,module,exports){ - module.exports={ - "_args": [ - [ - "elliptic@6.5.4", - "/Users/apple/casper" - ] - ], - "_from": "elliptic@6.5.4", - "_id": "elliptic@6.5.4", - "_inBundle": false, - "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "_location": "/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "elliptic@6.5.4", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "6.5.4", - "saveSpec": null, - "fetchSpec": "6.5.4" - }, - "_requiredBy": [ - "/browserify-sign", - "/create-ecdh", - "/eccrypto", - "/eccrypto/secp256k1", - "/key-encoder", - "/secp256k1" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "_spec": "6.5.4", - "_where": "/Users/apple/casper", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - }, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^2.0.2", - "coveralls": "^3.1.0", - "eslint": "^7.6.0", - "grunt": "^1.2.1", - "grunt-browserify": "^5.3.0", - "grunt-cli": "^1.3.2", - "grunt-contrib-connect": "^3.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^5.0.0", - "grunt-mocha-istanbul": "^5.0.2", - "grunt-saucelabs": "^9.0.1", - "istanbul": "^0.4.5", - "mocha": "^8.0.1" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.5.4" - } - - },{}],72:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function createHashFunction(hashConstructor) { - return function (msg) { - var hash = hashConstructor(); - hash.update(msg); - return Buffer.from(hash.digest()); - }; - } - exports.createHashFunction = createHashFunction; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266}],73:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var hdkey = require("./vendor/hdkey-without-crypto"); - exports.HDKey = hdkey; - - },{"./vendor/hdkey-without-crypto":78}],74:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var Ripemd160 = require("hash.js/lib/hash/ripemd").ripemd160; - var hash_utils_1 = require("../hash-utils"); - exports.ripemd160 = hash_utils_1.createHashFunction(function () { return new Ripemd160(); }); - - },{"../hash-utils":72,"hash.js/lib/hash/ripemd":86}],75:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var Sha256Hash = require("hash.js/lib/hash/sha/256"); - var hash_utils_1 = require("../hash-utils"); - exports.sha256 = hash_utils_1.createHashFunction(function () { return new Sha256Hash(); }); - - },{"../hash-utils":72,"hash.js/lib/hash/sha/256":90}],76:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var ripemd160_1 = require("../ripemd160"); - var sha256_1 = require("../sha256"); - exports.createHmac = require("create-hmac"); - exports.randomBytes = require("randombytes"); - var Hash = /** @class */ (function () { - function Hash(hashFunction) { - this.hashFunction = hashFunction; - this.buffers = []; - } - Hash.prototype.update = function (buffer) { - if (!Buffer.isBuffer(buffer)) { - throw new Error("hdkey-crypto shim is outdated"); - } - this.buffers.push(buffer); - return this; - }; - Hash.prototype.digest = function (param) { - if (param) { - throw new Error("hdkey-crypto shim is outdated"); - } - return this.hashFunction(Buffer.concat(this.buffers)); - }; - return Hash; - }()); - // We don't use create-hash here, as it doesn't work well with Rollup - exports.createHash = function (name) { - if (name === "ripemd160") { - return new Hash(ripemd160_1.ripemd160); - } - if (name === "sha256") { - return new Hash(sha256_1.sha256); - } - throw new Error("hdkey-crypto shim is outdated"); - }; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"../ripemd160":74,"../sha256":75,"buffer":266,"create-hmac":53,"randombytes":105}],77:[function(require,module,exports){ - "use strict"; - function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - } - Object.defineProperty(exports, "__esModule", { value: true }); - __export(require("../../shims/hdkey-secp256k1v3")); - - },{"../../shims/hdkey-secp256k1v3":81}],78:[function(require,module,exports){ - 'use strict'; - - function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - - var assert = _interopDefault(require('assert')); - var safeBuffer = _interopDefault(require('safe-buffer')); - var bs58check = _interopDefault(require('bs58check')); - - var cryptoShim = require("../shims/hdkey-crypto"); - - var secp256k1Shim = require("../shims/hdkey-secp256k1v3"); - - var Buffer = safeBuffer.Buffer; - - - - - var MASTER_SECRET = Buffer.from('Bitcoin seed', 'utf8'); - var HARDENED_OFFSET = 0x80000000; - var LEN = 78; - - // Bitcoin hardcoded by default, can use package `coininfo` for others - var BITCOIN_VERSIONS = {private: 0x0488ADE4, public: 0x0488B21E}; - - function HDKey (versions) { - this.versions = versions || BITCOIN_VERSIONS; - this.depth = 0; - this.index = 0; - this._privateKey = null; - this._publicKey = null; - this.chainCode = null; - this._fingerprint = 0; - this.parentFingerprint = 0; - } - - Object.defineProperty(HDKey.prototype, 'fingerprint', { get: function () { return this._fingerprint } }); - Object.defineProperty(HDKey.prototype, 'identifier', { get: function () { return this._identifier } }); - Object.defineProperty(HDKey.prototype, 'pubKeyHash', { get: function () { return this.identifier } }); - - Object.defineProperty(HDKey.prototype, 'privateKey', { - get: function () { - return this._privateKey - }, - set: function (value) { - assert.equal(value.length, 32, 'Private key must be 32 bytes.'); - assert(secp256k1Shim.privateKeyVerify(value) === true, 'Invalid private key'); - - this._privateKey = value; - this._publicKey = secp256k1Shim.publicKeyCreate(value, true); - this._identifier = hash160(this.publicKey); - this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); - } - }); - - Object.defineProperty(HDKey.prototype, 'publicKey', { - get: function () { - return this._publicKey - }, - set: function (value) { - assert(value.length === 33 || value.length === 65, 'Public key must be 33 or 65 bytes.'); - assert(secp256k1Shim.publicKeyVerify(value) === true, 'Invalid public key'); - - this._publicKey = secp256k1Shim.publicKeyConvert(value, true); // force compressed point - this._identifier = hash160(this.publicKey); - this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0); - this._privateKey = null; - } - }); - - Object.defineProperty(HDKey.prototype, 'privateExtendedKey', { - get: function () { - if (this._privateKey) return bs58check.encode(serialize(this, this.versions.private, Buffer.concat([Buffer.alloc(1, 0), this.privateKey]))) - else return null - } - }); - - Object.defineProperty(HDKey.prototype, 'publicExtendedKey', { - get: function () { - return bs58check.encode(serialize(this, this.versions.public, this.publicKey)) - } - }); - - HDKey.prototype.derive = function (path) { - if (path === 'm' || path === 'M' || path === "m'" || path === "M'") { - return this - } - - var entries = path.split('/'); - var hdkey = this; - entries.forEach(function (c, i) { - if (i === 0) { - assert(/^[mM]{1}/.test(c), 'Path must start with "m" or "M"'); - return - } - - var hardened = (c.length > 1) && (c[c.length - 1] === "'"); - var childIndex = parseInt(c, 10); // & (HARDENED_OFFSET - 1) - assert(childIndex < HARDENED_OFFSET, 'Invalid index'); - if (hardened) childIndex += HARDENED_OFFSET; - - hdkey = hdkey.deriveChild(childIndex); - }); - - return hdkey - }; - - HDKey.prototype.deriveChild = function (index) { - var isHardened = index >= HARDENED_OFFSET; - var indexBuffer = Buffer.allocUnsafe(4); - indexBuffer.writeUInt32BE(index, 0); - - var data; - - if (isHardened) { // Hardened child - assert(this.privateKey, 'Could not derive hardened child key'); - - var pk = this.privateKey; - var zb = Buffer.alloc(1, 0); - pk = Buffer.concat([zb, pk]); - - // data = 0x00 || ser256(kpar) || ser32(index) - data = Buffer.concat([pk, indexBuffer]); - } else { // Normal child - // data = serP(point(kpar)) || ser32(index) - // = serP(Kpar) || ser32(index) - data = Buffer.concat([this.publicKey, indexBuffer]); - } - - var I = cryptoShim.createHmac('sha512', this.chainCode).update(data).digest(); - var IL = I.slice(0, 32); - var IR = I.slice(32); - - var hd = new HDKey(this.versions); - - // Private parent key -> private child key - if (this.privateKey) { - // ki = parse256(IL) + kpar (mod n) - try { - hd.privateKey = secp256k1Shim.privateKeyTweakAdd(this.privateKey, IL); - // throw if IL >= n || (privateKey + IL) === 0 - } catch (err) { - // In case parse256(IL) >= n or ki == 0, one should proceed with the next value for i - return this.deriveChild(index + 1) - } - // Public parent key -> public child key - } else { - // Ki = point(parse256(IL)) + Kpar - // = G*IL + Kpar - try { - hd.publicKey = secp256k1Shim.publicKeyTweakAdd(this.publicKey, IL, true); - // throw if IL >= n || (g**IL + publicKey) is infinity - } catch (err) { - // In case parse256(IL) >= n or Ki is the point at infinity, one should proceed with the next value for i - return this.deriveChild(index + 1) - } - } - - hd.chainCode = IR; - hd.depth = this.depth + 1; - hd.parentFingerprint = this.fingerprint;// .readUInt32BE(0) - hd.index = index; - - return hd - }; - - HDKey.prototype.sign = function (hash) { - return secp256k1Shim.sign(hash, this.privateKey).signature - }; - - HDKey.prototype.verify = function (hash, signature) { - return secp256k1Shim.verify(hash, signature, this.publicKey) - }; - - HDKey.prototype.wipePrivateData = function () { - if (this._privateKey) cryptoShim.randomBytes(this._privateKey.length).copy(this._privateKey); - this._privateKey = null; - return this - }; - - HDKey.prototype.toJSON = function () { - return { - xpriv: this.privateExtendedKey, - xpub: this.publicExtendedKey - } - }; - - HDKey.fromMasterSeed = function (seedBuffer, versions) { - var I = cryptoShim.createHmac('sha512', MASTER_SECRET).update(seedBuffer).digest(); - var IL = I.slice(0, 32); - var IR = I.slice(32); - - var hdkey = new HDKey(versions); - hdkey.chainCode = IR; - hdkey.privateKey = IL; - - return hdkey - }; - - HDKey.fromExtendedKey = function (base58key, versions) { - // => version(4) || depth(1) || fingerprint(4) || index(4) || chain(32) || key(33) - versions = versions || BITCOIN_VERSIONS; - var hdkey = new HDKey(versions); - - var keyBuffer = bs58check.decode(base58key); - - var version = keyBuffer.readUInt32BE(0); - assert(version === versions.private || version === versions.public, 'Version mismatch: does not match private or public'); - - hdkey.depth = keyBuffer.readUInt8(4); - hdkey.parentFingerprint = keyBuffer.readUInt32BE(5); - hdkey.index = keyBuffer.readUInt32BE(9); - hdkey.chainCode = keyBuffer.slice(13, 45); - - var key = keyBuffer.slice(45); - if (key.readUInt8(0) === 0) { // private - assert(version === versions.private, 'Version mismatch: version does not match private'); - hdkey.privateKey = key.slice(1); // cut off first 0x0 byte - } else { - assert(version === versions.public, 'Version mismatch: version does not match public'); - hdkey.publicKey = key; - } - - return hdkey - }; - - HDKey.fromJSON = function (obj) { - return HDKey.fromExtendedKey(obj.xpriv) - }; - - function serialize (hdkey, version, key) { - // => version(4) || depth(1) || fingerprint(4) || index(4) || chain(32) || key(33) - var buffer = Buffer.allocUnsafe(LEN); - - buffer.writeUInt32BE(version, 0); - buffer.writeUInt8(hdkey.depth, 4); - - var fingerprint = hdkey.depth ? hdkey.parentFingerprint : 0x00000000; - buffer.writeUInt32BE(fingerprint, 5); - buffer.writeUInt32BE(hdkey.index, 9); - - hdkey.chainCode.copy(buffer, 13); - key.copy(buffer, 45); - - return buffer - } - - function hash160 (buf) { - var sha = cryptoShim.createHash('sha256').update(buf).digest(); - return cryptoShim.createHash('ripemd160').update(sha).digest() - } - - HDKey.HARDENED_OFFSET = HARDENED_OFFSET; - var hdkey = HDKey; - - module.exports = hdkey; - - },{"../shims/hdkey-crypto":76,"../shims/hdkey-secp256k1v3":77,"assert":215,"bs58check":49,"safe-buffer":122}],79:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var randombytes = require("randombytes"); - function getRandomBytes(bytes) { - return new Promise(function (resolve, reject) { - randombytes(bytes, function (err, resp) { - if (err) { - reject(err); - return; - } - resolve(resp); - }); - }); - } - exports.getRandomBytes = getRandomBytes; - function getRandomBytesSync(bytes) { - return randombytes(bytes); - } - exports.getRandomBytesSync = getRandomBytesSync; - - },{"randombytes":105}],80:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - } - Object.defineProperty(exports, "__esModule", { value: true }); - var secp256k1_1 = require("secp256k1"); - var random_1 = require("./random"); - var SECP256K1_PRIVATE_KEY_SIZE = 32; - function createPrivateKey() { - return __awaiter(this, void 0, void 0, function () { - var pk; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!true) return [3 /*break*/, 2]; - return [4 /*yield*/, random_1.getRandomBytes(SECP256K1_PRIVATE_KEY_SIZE)]; - case 1: - pk = _a.sent(); - if (secp256k1_1.privateKeyVerify(pk)) { - return [2 /*return*/, pk]; - } - return [3 /*break*/, 0]; - case 2: return [2 /*return*/]; - } - }); - }); - } - exports.createPrivateKey = createPrivateKey; - function createPrivateKeySync() { - while (true) { - var pk = random_1.getRandomBytesSync(SECP256K1_PRIVATE_KEY_SIZE); - if (secp256k1_1.privateKeyVerify(pk)) { - return pk; - } - } - } - exports.createPrivateKeySync = createPrivateKeySync; - __export(require("secp256k1")); - - },{"./random":79,"secp256k1":124}],81:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var secp256k1 = __importStar(require("secp256k1")); - function privateKeyVerify(privateKey) { - return secp256k1.privateKeyVerify(privateKey); - } - exports.privateKeyVerify = privateKeyVerify; - function publicKeyCreate(privateKey, compressed) { - if (compressed === void 0) { compressed = true; } - return Buffer.from(secp256k1.publicKeyCreate(privateKey, compressed)); - } - exports.publicKeyCreate = publicKeyCreate; - function publicKeyVerify(publicKey) { - return secp256k1.publicKeyVerify(publicKey); - } - exports.publicKeyVerify = publicKeyVerify; - function publicKeyConvert(publicKey, compressed) { - if (compressed === void 0) { compressed = true; } - return Buffer.from(secp256k1.publicKeyConvert(publicKey, compressed)); - } - exports.publicKeyConvert = publicKeyConvert; - function privateKeyTweakAdd(publicKey, tweak) { - return Buffer.from(secp256k1.privateKeyTweakAdd(Buffer.from(publicKey), tweak)); - } - exports.privateKeyTweakAdd = privateKeyTweakAdd; - function publicKeyTweakAdd(publicKey, tweak, compressed) { - if (compressed === void 0) { compressed = true; } - return Buffer.from(secp256k1.publicKeyTweakAdd(Buffer.from(publicKey), tweak, compressed)); - } - exports.publicKeyTweakAdd = publicKeyTweakAdd; - function sign(message, privateKey) { - var ret = secp256k1.ecdsaSign(message, privateKey); - return { signature: Buffer.from(ret.signature), recovery: ret.recid }; - } - exports.sign = sign; - function verify(message, signature, publicKey) { - return secp256k1.ecdsaVerify(signature, message, publicKey); - } - exports.verify = verify; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266,"secp256k1":124}],82:[function(require,module,exports){ - 'use strict' - var Buffer = require('safe-buffer').Buffer - var Transform = require('readable-stream').Transform - var inherits = require('inherits') - - function throwIfNotStringOrBuffer (val, prefix) { - if (!Buffer.isBuffer(val) && typeof val !== 'string') { - throw new TypeError(prefix + ' must be a string or a buffer') - } - } - - function HashBase (blockSize) { - Transform.call(this) - - this._block = Buffer.allocUnsafe(blockSize) - this._blockSize = blockSize - this._blockOffset = 0 - this._length = [0, 0, 0, 0] - - this._finalized = false - } - - inherits(HashBase, Transform) - - HashBase.prototype._transform = function (chunk, encoding, callback) { - var error = null - try { - this.update(chunk, encoding) - } catch (err) { - error = err - } - - callback(error) - } - - HashBase.prototype._flush = function (callback) { - var error = null - try { - this.push(this.digest()) - } catch (err) { - error = err - } - - callback(error) - } - - HashBase.prototype.update = function (data, encoding) { - throwIfNotStringOrBuffer(data, 'Data') - if (this._finalized) throw new Error('Digest already called') - if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) - - // consume data - var block = this._block - var offset = 0 - while (this._blockOffset + data.length - offset >= this._blockSize) { - for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++] - this._update() - this._blockOffset = 0 - } - while (offset < data.length) block[this._blockOffset++] = data[offset++] - - // update length - for (var j = 0, carry = data.length * 8; carry > 0; ++j) { - this._length[j] += carry - carry = (this._length[j] / 0x0100000000) | 0 - if (carry > 0) this._length[j] -= 0x0100000000 * carry - } - - return this - } - - HashBase.prototype._update = function () { - throw new Error('_update is not implemented') - } - - HashBase.prototype.digest = function (encoding) { - if (this._finalized) throw new Error('Digest already called') - this._finalized = true - - var digest = this._digest() - if (encoding !== undefined) digest = digest.toString(encoding) - - // reset state - this._block.fill(0) - this._blockOffset = 0 - for (var i = 0; i < 4; ++i) this._length[i] = 0 - - return digest - } - - HashBase.prototype._digest = function () { - throw new Error('_digest is not implemented') - } - - module.exports = HashBase - - },{"inherits":97,"readable-stream":120,"safe-buffer":122}],83:[function(require,module,exports){ - var hash = exports; - - hash.utils = require('./hash/utils'); - hash.common = require('./hash/common'); - hash.sha = require('./hash/sha'); - hash.ripemd = require('./hash/ripemd'); - hash.hmac = require('./hash/hmac'); - - // Proxy hash functions to the main object - hash.sha1 = hash.sha.sha1; - hash.sha256 = hash.sha.sha256; - hash.sha224 = hash.sha.sha224; - hash.sha384 = hash.sha.sha384; - hash.sha512 = hash.sha.sha512; - hash.ripemd160 = hash.ripemd.ripemd160; - - },{"./hash/common":84,"./hash/hmac":85,"./hash/ripemd":86,"./hash/sha":87,"./hash/utils":94}],84:[function(require,module,exports){ - 'use strict'; - - var utils = require('./utils'); - var assert = 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 update(msg, enc) { - // Convert message to array, pad it, and join into 32bit blocks - msg = utils.toArray(msg, enc); - if (!this.pending) - this.pending = msg; - else - this.pending = this.pending.concat(msg); - this.pendingTotal += msg.length; - - // Enough data, try updating - if (this.pending.length >= this._delta8) { - msg = this.pending; - - // Process pending data in blocks - var r = msg.length % this._delta8; - this.pending = msg.slice(msg.length - r, msg.length); - if (this.pending.length === 0) - this.pending = null; - - msg = utils.join32(msg, 0, msg.length - r, 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()); - assert(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] = 0x80; - for (var i = 1; i < k; i++) - res[i] = 0; - - // Append length - 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) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = len & 0xff; - } else { - res[i++] = len & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 24) & 0xff; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - - for (t = 8; t < this.padLength; t++) - res[i++] = 0; - } - - return res; - }; - - },{"./utils":94,"minimalistic-assert":103}],85:[function(require,module,exports){ - 'use strict'; - - var utils = require('./utils'); - var assert = require('minimalistic-assert'); - - function Hmac(hash, key, enc) { - if (!(this instanceof Hmac)) - return new Hmac(hash, key, enc); - this.Hash = hash; - this.blockSize = hash.blockSize / 8; - this.outSize = hash.outSize / 8; - this.inner = null; - this.outer = null; - - this._init(utils.toArray(key, enc)); - } - module.exports = Hmac; - - Hmac.prototype._init = function init(key) { - // Shorten key, if needed - if (key.length > this.blockSize) - key = new this.Hash().update(key).digest(); - assert(key.length <= this.blockSize); - - // Add padding to key - for (var i = key.length; i < this.blockSize; i++) - key.push(0); - - for (i = 0; i < key.length; i++) - key[i] ^= 0x36; - this.inner = new this.Hash().update(key); - - // 0x36 ^ 0x5c = 0x6a - for (i = 0; i < key.length; i++) - key[i] ^= 0x6a; - this.outer = new this.Hash().update(key); - }; - - Hmac.prototype.update = function update(msg, enc) { - this.inner.update(msg, enc); - return this; - }; - - Hmac.prototype.digest = function digest(enc) { - this.outer.update(this.inner.digest()); - return this.outer.digest(enc); - }; - - },{"./utils":94,"minimalistic-assert":103}],86:[function(require,module,exports){ - 'use strict'; - - var utils = require('./utils'); - var common = require('./common'); - - var rotl32 = utils.rotl32; - var sum32 = utils.sum32; - var sum32_3 = utils.sum32_3; - var sum32_4 = utils.sum32_4; - var BlockHash = common.BlockHash; - - function RIPEMD160() { - if (!(this instanceof RIPEMD160)) - return new RIPEMD160(); - - BlockHash.call(this); - - this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; - this.endian = 'little'; - } - utils.inherits(RIPEMD160, BlockHash); - exports.ripemd160 = RIPEMD160; - - RIPEMD160.blockSize = 512; - RIPEMD160.outSize = 160; - RIPEMD160.hmacStrength = 192; - RIPEMD160.padLength = 64; - - RIPEMD160.prototype._update = function update(msg, start) { - 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 Ah = A; - var Bh = B; - var Ch = C; - var Dh = D; - var Eh = E; - for (var j = 0; j < 80; j++) { - var T = sum32( - rotl32( - sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), - s[j]), - E); - A = E; - E = D; - D = rotl32(C, 10); - C = B; - B = T; - T = sum32( - rotl32( - sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), - sh[j]), - Eh); - Ah = Eh; - Eh = Dh; - Dh = rotl32(Ch, 10); - Ch = Bh; - Bh = T; - } - T = sum32_3(this.h[1], C, Dh); - this.h[1] = sum32_3(this.h[2], D, Eh); - this.h[2] = sum32_3(this.h[3], E, Ah); - this.h[3] = sum32_3(this.h[4], A, Bh); - this.h[4] = sum32_3(this.h[0], B, Ch); - this.h[0] = T; - }; - - RIPEMD160.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'little'); - else - return utils.split32(this.h, 'little'); - }; - - function f(j, x, y, z) { - if (j <= 15) - return x ^ y ^ z; - else if (j <= 31) - return (x & y) | ((~x) & z); - else if (j <= 47) - return (x | (~y)) ^ z; - else if (j <= 63) - return (x & z) | (y & (~z)); - else - return x ^ (y | (~z)); - } - - function K(j) { - if (j <= 15) - return 0x00000000; - else if (j <= 31) - return 0x5a827999; - else if (j <= 47) - return 0x6ed9eba1; - else if (j <= 63) - return 0x8f1bbcdc; - else - return 0xa953fd4e; - } - - function Kh(j) { - if (j <= 15) - return 0x50a28be6; - else if (j <= 31) - return 0x5c4dd124; - else if (j <= 47) - return 0x6d703ef3; - else if (j <= 63) - return 0x7a6d76e9; - else - return 0x00000000; - } - - var r = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 - ]; - - var rh = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 - ]; - - var s = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 - ]; - - var sh = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 - ]; - - },{"./common":84,"./utils":94}],87:[function(require,module,exports){ - 'use strict'; - - exports.sha1 = require('./sha/1'); - exports.sha224 = require('./sha/224'); - exports.sha256 = require('./sha/256'); - exports.sha384 = require('./sha/384'); - exports.sha512 = require('./sha/512'); - - },{"./sha/1":88,"./sha/224":89,"./sha/256":90,"./sha/384":91,"./sha/512":92}],88:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var common = require('../common'); - var shaCommon = require('./common'); - - 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 = [ - 0x5A827999, 0x6ED9EBA1, - 0x8F1BBCDC, 0xCA62C1D6 - ]; - - function SHA1() { - if (!(this instanceof SHA1)) - return new SHA1(); - - BlockHash.call(this); - this.h = [ - 0x67452301, 0xefcdab89, 0x98badcfe, - 0x10325476, 0xc3d2e1f0 ]; - 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'); - }; - - },{"../common":84,"../utils":94,"./common":93}],89:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var SHA256 = require('./256'); - - function SHA224() { - if (!(this instanceof SHA224)) - return new SHA224(); - - SHA256.call(this); - this.h = [ - 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, - 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; - } - 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) { - // Just truncate output - if (enc === 'hex') - return utils.toHex32(this.h.slice(0, 7), 'big'); - else - return utils.split32(this.h.slice(0, 7), 'big'); - }; - - - },{"../utils":94,"./256":90}],90:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var common = require('../common'); - var shaCommon = require('./common'); - var assert = 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 = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ]; - - function SHA256() { - if (!(this instanceof SHA256)) - return new SHA256(); - - BlockHash.call(this); - this.h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ]; - 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]; - - assert(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'); - }; - - },{"../common":84,"../utils":94,"./common":93,"minimalistic-assert":103}],91:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - - var SHA512 = require('./512'); - - function SHA384() { - if (!(this instanceof SHA384)) - return new SHA384(); - - SHA512.call(this); - this.h = [ - 0xcbbb9d5d, 0xc1059ed8, - 0x629a292a, 0x367cd507, - 0x9159015a, 0x3070dd17, - 0x152fecd8, 0xf70e5939, - 0x67332667, 0xffc00b31, - 0x8eb44a87, 0x68581511, - 0xdb0c2e0d, 0x64f98fa7, - 0x47b5481d, 0xbefa4fa4 ]; - } - utils.inherits(SHA384, SHA512); - module.exports = SHA384; - - SHA384.blockSize = 1024; - SHA384.outSize = 384; - SHA384.hmacStrength = 192; - SHA384.padLength = 128; - - SHA384.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h.slice(0, 12), 'big'); - else - return utils.split32(this.h.slice(0, 12), 'big'); - }; - - },{"../utils":94,"./512":92}],92:[function(require,module,exports){ - 'use strict'; - - var utils = require('../utils'); - var common = require('../common'); - var assert = 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 = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 - ]; - - function SHA512() { - if (!(this instanceof SHA512)) - return new SHA512(); - - BlockHash.call(this); - this.h = [ - 0x6a09e667, 0xf3bcc908, - 0xbb67ae85, 0x84caa73b, - 0x3c6ef372, 0xfe94f82b, - 0xa54ff53a, 0x5f1d36f1, - 0x510e527f, 0xade682d1, - 0x9b05688c, 0x2b3e6c1f, - 0x1f83d9ab, 0xfb41bd6b, - 0x5be0cd19, 0x137e2179 ]; - 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; - - // 32 x 32bit words - 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]); // i - 2 - var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); - var c1_hi = W[i - 14]; // i - 7 - var c1_lo = W[i - 13]; - var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 - var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); - var c3_hi = W[i - 32]; // i - 16 - 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]; - - assert(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.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); - }; - - function ch64_hi(xh, xl, yh, yl, zh) { - var r = (xh & yh) ^ ((~xh) & zh); - if (r < 0) - r += 0x100000000; - return r; - } - - function ch64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ ((~xl) & zl); - if (r < 0) - r += 0x100000000; - return r; - } - - function maj64_hi(xh, xl, yh, yl, zh) { - var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); - if (r < 0) - r += 0x100000000; - return r; - } - - function maj64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); - if (r < 0) - r += 0x100000000; - return r; - } - - function s0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 28); - var c1_hi = rotr64_hi(xl, xh, 2); // 34 - var c2_hi = rotr64_hi(xl, xh, 7); // 39 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; - } - - function s0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 28); - var c1_lo = rotr64_lo(xl, xh, 2); // 34 - var c2_lo = rotr64_lo(xl, xh, 7); // 39 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; - } - - function s1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 14); - var c1_hi = rotr64_hi(xh, xl, 18); - var c2_hi = rotr64_hi(xl, xh, 9); // 41 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; - } - - function s1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 14); - var c1_lo = rotr64_lo(xh, xl, 18); - var c2_lo = rotr64_lo(xl, xh, 9); // 41 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; - } - - function g0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 1); - var c1_hi = rotr64_hi(xh, xl, 8); - var c2_hi = shr64_hi(xh, xl, 7); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; - } - - function g0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 1); - var c1_lo = rotr64_lo(xh, xl, 8); - var c2_lo = shr64_lo(xh, xl, 7); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; - } - - function g1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 19); - var c1_hi = rotr64_hi(xl, xh, 29); // 61 - var c2_hi = shr64_hi(xh, xl, 6); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; - } - - function g1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 19); - var c1_lo = rotr64_lo(xl, xh, 29); // 61 - var c2_lo = shr64_lo(xh, xl, 6); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; - } - - },{"../common":84,"../utils":94,"minimalistic-assert":103}],93:[function(require,module,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; - - },{"../utils":94}],94:[function(require,module,exports){ - 'use strict'; - - var assert = require('minimalistic-assert'); - var inherits = require('inherits'); - - exports.inherits = inherits; - - function isSurrogatePair(msg, i) { - if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) { - return false; - } - if (i < 0 || i + 1 >= msg.length) { - return false; - } - return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00; - } - - function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg === 'string') { - if (!enc) { - // Inspired by stringToUtf8ByteArray() in closure-library by Google - // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143 - // Apache License 2.0 - // https://github.com/google/closure-library/blob/master/LICENSE - 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 = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF); - 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 toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; - } - exports.toHex = toHex; - - function htonl(w) { - var res = (w >>> 24) | - ((w >>> 8) & 0xff00) | - ((w << 8) & 0xff0000) | - ((w & 0xff) << 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; - assert(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) & 0xff; - res[k + 2] = (m >>> 8) & 0xff; - res[k + 3] = m & 0xff; - } else { - res[k + 3] = m >>> 24; - res[k + 2] = (m >>> 16) & 0xff; - res[k + 1] = (m >>> 8) & 0xff; - res[k] = m & 0xff; - } - } - 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 r = (al << (32 - num)) | (ah >>> num); - return r >>> 0; - } - exports.rotr64_hi = rotr64_hi; - - function rotr64_lo(ah, al, num) { - var r = (ah << (32 - num)) | (al >>> num); - return r >>> 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 r = (ah << (32 - num)) | (al >>> num); - return r >>> 0; - } - exports.shr64_lo = shr64_lo; - - },{"inherits":97,"minimalistic-assert":103}],95:[function(require,module,exports){ - 'use strict'; - - var hash = require('hash.js'); - var utils = require('minimalistic-crypto-utils'); - var assert = require('minimalistic-assert'); - - function HmacDRBG(options) { - if (!(this instanceof HmacDRBG)) - return new HmacDRBG(options); - this.hash = options.hash; - this.predResist = !!options.predResist; - - this.outLen = this.hash.outSize; - this.minEntropy = options.minEntropy || this.hash.hmacStrength; - - this._reseed = null; - this.reseedInterval = null; - this.K = null; - this.V = null; - - var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex'); - var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex'); - var pers = utils.toArray(options.pers, options.persEnc || 'hex'); - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - this._init(entropy, nonce, pers); - } - module.exports = HmacDRBG; - - HmacDRBG.prototype._init = function init(entropy, nonce, pers) { - var seed = entropy.concat(nonce).concat(pers); - - this.K = new Array(this.outLen / 8); - this.V = new Array(this.outLen / 8); - for (var i = 0; i < this.V.length; i++) { - this.K[i] = 0x00; - this.V[i] = 0x01; - } - - this._update(seed); - this._reseed = 1; - this.reseedInterval = 0x1000000000000; // 2^48 - }; - - HmacDRBG.prototype._hmac = function hmac() { - return new hash.hmac(this.hash, this.K); - }; - - HmacDRBG.prototype._update = function update(seed) { - var kmac = this._hmac() - .update(this.V) - .update([ 0x00 ]); - if (seed) - kmac = kmac.update(seed); - this.K = kmac.digest(); - this.V = this._hmac().update(this.V).digest(); - if (!seed) - return; - - this.K = this._hmac() - .update(this.V) - .update([ 0x01 ]) - .update(seed) - .digest(); - this.V = this._hmac().update(this.V).digest(); - }; - - HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { - // Optional entropy enc - if (typeof entropyEnc !== 'string') { - addEnc = add; - add = entropyEnc; - entropyEnc = null; - } - - entropy = utils.toArray(entropy, entropyEnc); - add = utils.toArray(add, addEnc); - - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - - this._update(entropy.concat(add || [])); - this._reseed = 1; - }; - - HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { - if (this._reseed > this.reseedInterval) - throw new Error('Reseed is required'); - - // Optional encoding - if (typeof enc !== 'string') { - addEnc = add; - add = enc; - enc = null; - } - - // Optional additional data - if (add) { - add = utils.toArray(add, addEnc || 'hex'); - this._update(add); - } - - var temp = []; - while (temp.length < len) { - this.V = this._hmac().update(this.V).digest(); - temp = temp.concat(this.V); - } - - var res = temp.slice(0, len); - this._update(add); - this._reseed++; - return utils.encode(res, enc); - }; - - },{"hash.js":83,"minimalistic-assert":103,"minimalistic-crypto-utils":104}],96:[function(require,module,exports){ - // HumanizeDuration.js - https://git.io/j0HgmQ - - /* global define, module */ - - (function () { - // This has to be defined separately because of a bug: we want to alias - // `gr` and `el` for backwards-compatiblity. In a breaking change, we can - // remove `gr` entirely. - // See https://github.com/EvanHahn/HumanizeDuration.js/issues/143 for more. - var greek = { - y: function (c) { - return c === 1 ? "χρόνος" : "χρόνια"; - }, - mo: function (c) { - return c === 1 ? "μήνας" : "μήνες"; - }, - w: function (c) { - return c === 1 ? "εβδομάδα" : "εβδομάδες"; - }, - d: function (c) { - return c === 1 ? "μέρα" : "μέρες"; - }, - h: function (c) { - return c === 1 ? "ώρα" : "ώρες"; - }, - m: function (c) { - return c === 1 ? "λεπτό" : "λεπτά"; - }, - s: function (c) { - return c === 1 ? "δευτερόλεπτο" : "δευτερόλεπτα"; - }, - ms: function (c) { - return c === 1 - ? "χιλιοστό του δευτερολέπτου" - : "χιλιοστά του δευτερολέπτου"; - }, - decimal: ",", - }; - - var LANGUAGES = { - ar: { - y: function (c) { - return c === 1 ? "سنة" : "سنوات"; - }, - mo: function (c) { - return c === 1 ? "شهر" : "أشهر"; - }, - w: function (c) { - return c === 1 ? "أسبوع" : "أسابيع"; - }, - d: function (c) { - return c === 1 ? "يوم" : "أيام"; - }, - h: function (c) { - return c === 1 ? "ساعة" : "ساعات"; - }, - m: function (c) { - return c > 2 && c < 11 ? "دقائق" : "دقيقة"; - }, - s: function (c) { - return c === 1 ? "ثانية" : "ثواني"; - }, - ms: function (c) { - return c === 1 ? "جزء من الثانية" : "أجزاء من الثانية"; - }, - decimal: ",", - }, - bg: { - y: function (c) { - return ["години", "година", "години"][getSlavicForm(c)]; - }, - mo: function (c) { - return ["месеца", "месец", "месеца"][getSlavicForm(c)]; - }, - w: function (c) { - return ["седмици", "седмица", "седмици"][getSlavicForm(c)]; - }, - d: function (c) { - return ["дни", "ден", "дни"][getSlavicForm(c)]; - }, - h: function (c) { - return ["часа", "час", "часа"][getSlavicForm(c)]; - }, - m: function (c) { - return ["минути", "минута", "минути"][getSlavicForm(c)]; - }, - s: function (c) { - return ["секунди", "секунда", "секунди"][getSlavicForm(c)]; - }, - ms: function (c) { - return ["милисекунди", "милисекунда", "милисекунди"][getSlavicForm(c)]; - }, - decimal: ",", - }, - ca: { - y: function (c) { - return "any" + (c === 1 ? "" : "s"); - }, - mo: function (c) { - return "mes" + (c === 1 ? "" : "os"); - }, - w: function (c) { - return "setman" + (c === 1 ? "a" : "es"); - }, - d: function (c) { - return "di" + (c === 1 ? "a" : "es"); - }, - h: function (c) { - return "hor" + (c === 1 ? "a" : "es"); - }, - m: function (c) { - return "minut" + (c === 1 ? "" : "s"); - }, - s: function (c) { - return "segon" + (c === 1 ? "" : "s"); - }, - ms: function (c) { - return "milisegon" + (c === 1 ? "" : "s"); - }, - decimal: ",", - }, - cs: { - y: function (c) { - return ["rok", "roku", "roky", "let"][getCzechOrSlovakForm(c)]; - }, - mo: function (c) { - return ["měsíc", "měsíce", "měsíce", "měsíců"][getCzechOrSlovakForm(c)]; - }, - w: function (c) { - return ["týden", "týdne", "týdny", "týdnů"][getCzechOrSlovakForm(c)]; - }, - d: function (c) { - return ["den", "dne", "dny", "dní"][getCzechOrSlovakForm(c)]; - }, - h: function (c) { - return ["hodina", "hodiny", "hodiny", "hodin"][getCzechOrSlovakForm(c)]; - }, - m: function (c) { - return ["minuta", "minuty", "minuty", "minut"][getCzechOrSlovakForm(c)]; - }, - s: function (c) { - return ["sekunda", "sekundy", "sekundy", "sekund"][ - getCzechOrSlovakForm(c) - ]; - }, - ms: function (c) { - return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ - getCzechOrSlovakForm(c) - ]; - }, - decimal: ",", - }, - da: { - y: "år", - mo: function (c) { - return "måned" + (c === 1 ? "" : "er"); - }, - w: function (c) { - return "uge" + (c === 1 ? "" : "r"); - }, - d: function (c) { - return "dag" + (c === 1 ? "" : "e"); - }, - h: function (c) { - return "time" + (c === 1 ? "" : "r"); - }, - m: function (c) { - return "minut" + (c === 1 ? "" : "ter"); - }, - s: function (c) { - return "sekund" + (c === 1 ? "" : "er"); - }, - ms: function (c) { - return "millisekund" + (c === 1 ? "" : "er"); - }, - decimal: ",", - }, - de: { - y: function (c) { - return "Jahr" + (c === 1 ? "" : "e"); - }, - mo: function (c) { - return "Monat" + (c === 1 ? "" : "e"); - }, - w: function (c) { - return "Woche" + (c === 1 ? "" : "n"); - }, - d: function (c) { - return "Tag" + (c === 1 ? "" : "e"); - }, - h: function (c) { - return "Stunde" + (c === 1 ? "" : "n"); - }, - m: function (c) { - return "Minute" + (c === 1 ? "" : "n"); - }, - s: function (c) { - return "Sekunde" + (c === 1 ? "" : "n"); - }, - ms: function (c) { - return "Millisekunde" + (c === 1 ? "" : "n"); - }, - decimal: ",", - }, - el: greek, - en: { - y: function (c) { - return "year" + (c === 1 ? "" : "s"); - }, - mo: function (c) { - return "month" + (c === 1 ? "" : "s"); - }, - w: function (c) { - return "week" + (c === 1 ? "" : "s"); - }, - d: function (c) { - return "day" + (c === 1 ? "" : "s"); - }, - h: function (c) { - return "hour" + (c === 1 ? "" : "s"); - }, - m: function (c) { - return "minute" + (c === 1 ? "" : "s"); - }, - s: function (c) { - return "second" + (c === 1 ? "" : "s"); - }, - ms: function (c) { - return "millisecond" + (c === 1 ? "" : "s"); - }, - decimal: ".", - }, - es: { - y: function (c) { - return "año" + (c === 1 ? "" : "s"); - }, - mo: function (c) { - return "mes" + (c === 1 ? "" : "es"); - }, - w: function (c) { - return "semana" + (c === 1 ? "" : "s"); - }, - d: function (c) { - return "día" + (c === 1 ? "" : "s"); - }, - h: function (c) { - return "hora" + (c === 1 ? "" : "s"); - }, - m: function (c) { - return "minuto" + (c === 1 ? "" : "s"); - }, - s: function (c) { - return "segundo" + (c === 1 ? "" : "s"); - }, - ms: function (c) { - return "milisegundo" + (c === 1 ? "" : "s"); - }, - decimal: ",", - }, - et: { - y: function (c) { - return "aasta" + (c === 1 ? "" : "t"); - }, - mo: function (c) { - return "kuu" + (c === 1 ? "" : "d"); - }, - w: function (c) { - return "nädal" + (c === 1 ? "" : "at"); - }, - d: function (c) { - return "päev" + (c === 1 ? "" : "a"); - }, - h: function (c) { - return "tund" + (c === 1 ? "" : "i"); - }, - m: function (c) { - return "minut" + (c === 1 ? "" : "it"); - }, - s: function (c) { - return "sekund" + (c === 1 ? "" : "it"); - }, - ms: function (c) { - return "millisekund" + (c === 1 ? "" : "it"); - }, - decimal: ",", - }, - fa: { - y: "سال", - mo: "ماه", - w: "هفته", - d: "روز", - h: "ساعت", - m: "دقیقه", - s: "ثانیه", - ms: "میلی ثانیه", - decimal: ".", - }, - fi: { - y: function (c) { - return c === 1 ? "vuosi" : "vuotta"; - }, - mo: function (c) { - return c === 1 ? "kuukausi" : "kuukautta"; - }, - w: function (c) { - return "viikko" + (c === 1 ? "" : "a"); - }, - d: function (c) { - return "päivä" + (c === 1 ? "" : "ä"); - }, - h: function (c) { - return "tunti" + (c === 1 ? "" : "a"); - }, - m: function (c) { - return "minuutti" + (c === 1 ? "" : "a"); - }, - s: function (c) { - return "sekunti" + (c === 1 ? "" : "a"); - }, - ms: function (c) { - return "millisekunti" + (c === 1 ? "" : "a"); - }, - decimal: ",", - }, - fo: { - y: "ár", - mo: function (c) { - return c === 1 ? "mánaður" : "mánaðir"; - }, - w: function (c) { - return c === 1 ? "vika" : "vikur"; - }, - d: function (c) { - return c === 1 ? "dagur" : "dagar"; - }, - h: function (c) { - return c === 1 ? "tími" : "tímar"; - }, - m: function (c) { - return c === 1 ? "minuttur" : "minuttir"; - }, - s: "sekund", - ms: "millisekund", - decimal: ",", - }, - fr: { - y: function (c) { - return "an" + (c >= 2 ? "s" : ""); - }, - mo: "mois", - w: function (c) { - return "semaine" + (c >= 2 ? "s" : ""); - }, - d: function (c) { - return "jour" + (c >= 2 ? "s" : ""); - }, - h: function (c) { - return "heure" + (c >= 2 ? "s" : ""); - }, - m: function (c) { - return "minute" + (c >= 2 ? "s" : ""); - }, - s: function (c) { - return "seconde" + (c >= 2 ? "s" : ""); - }, - ms: function (c) { - return "milliseconde" + (c >= 2 ? "s" : ""); - }, - decimal: ",", - }, - gr: greek, - he: { - y: function (c) { - return c === 1 ? "שנה" : "שנים"; - }, - mo: function (c) { - return c === 1 ? "חודש" : "חודשים"; - }, - w: function (c) { - return c === 1 ? "שבוע" : "שבועות"; - }, - d: function (c) { - return c === 1 ? "יום" : "ימים"; - }, - h: function (c) { - return c === 1 ? "שעה" : "שעות"; - }, - m: function (c) { - return c === 1 ? "דקה" : "דקות"; - }, - s: function (c) { - return c === 1 ? "שניה" : "שניות"; - }, - ms: function (c) { - return c === 1 ? "מילישנייה" : "מילישניות"; - }, - decimal: ".", - }, - hr: { - y: function (c) { - if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { - return "godine"; - } - return "godina"; - }, - mo: function (c) { - if (c === 1) { - return "mjesec"; - } else if (c === 2 || c === 3 || c === 4) { - return "mjeseca"; - } - return "mjeseci"; - }, - w: function (c) { - if (c % 10 === 1 && c !== 11) { - return "tjedan"; - } - return "tjedna"; - }, - d: function (c) { - return c === 1 ? "dan" : "dana"; - }, - h: function (c) { - if (c === 1) { - return "sat"; - } else if (c === 2 || c === 3 || c === 4) { - return "sata"; - } - return "sati"; - }, - m: function (c) { - var mod10 = c % 10; - if ((mod10 === 2 || mod10 === 3 || mod10 === 4) && (c < 10 || c > 14)) { - return "minute"; - } - return "minuta"; - }, - s: function (c) { - var mod10 = c % 10; - if (mod10 === 5 || (Math.floor(c) === c && c >= 10 && c <= 19)) { - return "sekundi"; - } else if (mod10 === 1) { - return "sekunda"; - } else if (mod10 === 2 || mod10 === 3 || mod10 === 4) { - return "sekunde"; - } - return "sekundi"; - }, - ms: function (c) { - if (c === 1) { - return "milisekunda"; - } else if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { - return "milisekunde"; - } - return "milisekundi"; - }, - decimal: ",", - }, - hi: { - y: "साल", - mo: function (c) { - return c === 1 ? "महीना" : "महीने"; - }, - w: function (c) { - return c === 1 ? "हफ़्ता" : "हफ्ते"; - }, - d: "दिन", - h: function (c) { - return c === 1 ? "घंटा" : "घंटे"; - }, - m: "मिनट", - s: "सेकंड", - ms: "मिलीसेकंड", - decimal: ".", - }, - hu: { - y: "év", - mo: "hónap", - w: "hét", - d: "nap", - h: "óra", - m: "perc", - s: "másodperc", - ms: "ezredmásodperc", - decimal: ",", - }, - id: { - y: "tahun", - mo: "bulan", - w: "minggu", - d: "hari", - h: "jam", - m: "menit", - s: "detik", - ms: "milidetik", - decimal: ".", - }, - is: { - y: "ár", - mo: function (c) { - return "mánuð" + (c === 1 ? "ur" : "ir"); - }, - w: function (c) { - return "vik" + (c === 1 ? "a" : "ur"); - }, - d: function (c) { - return "dag" + (c === 1 ? "ur" : "ar"); - }, - h: function (c) { - return "klukkutím" + (c === 1 ? "i" : "ar"); - }, - m: function (c) { - return "mínút" + (c === 1 ? "a" : "ur"); - }, - s: function (c) { - return "sekúnd" + (c === 1 ? "a" : "ur"); - }, - ms: function (c) { - return "millisekúnd" + (c === 1 ? "a" : "ur"); - }, - decimal: ".", - }, - it: { - y: function (c) { - return "ann" + (c === 1 ? "o" : "i"); - }, - mo: function (c) { - return "mes" + (c === 1 ? "e" : "i"); - }, - w: function (c) { - return "settiman" + (c === 1 ? "a" : "e"); - }, - d: function (c) { - return "giorn" + (c === 1 ? "o" : "i"); - }, - h: function (c) { - return "or" + (c === 1 ? "a" : "e"); - }, - m: function (c) { - return "minut" + (c === 1 ? "o" : "i"); - }, - s: function (c) { - return "second" + (c === 1 ? "o" : "i"); - }, - ms: function (c) { - return "millisecond" + (c === 1 ? "o" : "i"); - }, - decimal: ",", - }, - ja: { - y: "年", - mo: "月", - w: "週", - d: "日", - h: "時間", - m: "分", - s: "秒", - ms: "ミリ秒", - decimal: ".", - }, - ko: { - y: "년", - mo: "개월", - w: "주일", - d: "일", - h: "시간", - m: "분", - s: "초", - ms: "밀리 초", - decimal: ".", - }, - lo: { - y: "ປີ", - mo: "ເດືອນ", - w: "ອາທິດ", - d: "ມື້", - h: "ຊົ່ວໂມງ", - m: "ນາທີ", - s: "ວິນາທີ", - ms: "ມິນລິວິນາທີ", - decimal: ",", - }, - lt: { - y: function (c) { - return c % 10 === 0 || (c % 100 >= 10 && c % 100 <= 20) - ? "metų" - : "metai"; - }, - mo: function (c) { - return ["mėnuo", "mėnesiai", "mėnesių"][getLithuanianForm(c)]; - }, - w: function (c) { - return ["savaitė", "savaitės", "savaičių"][getLithuanianForm(c)]; - }, - d: function (c) { - return ["diena", "dienos", "dienų"][getLithuanianForm(c)]; - }, - h: function (c) { - return ["valanda", "valandos", "valandų"][getLithuanianForm(c)]; - }, - m: function (c) { - return ["minutė", "minutės", "minučių"][getLithuanianForm(c)]; - }, - s: function (c) { - return ["sekundė", "sekundės", "sekundžių"][getLithuanianForm(c)]; - }, - ms: function (c) { - return ["milisekundė", "milisekundės", "milisekundžių"][ - getLithuanianForm(c) - ]; - }, - decimal: ",", - }, - lv: { - y: function (c) { - return getLatvianForm(c) ? "gads" : "gadi"; - }, - mo: function (c) { - return getLatvianForm(c) ? "mēnesis" : "mēneši"; - }, - w: function (c) { - return getLatvianForm(c) ? "nedēļa" : "nedēļas"; - }, - d: function (c) { - return getLatvianForm(c) ? "diena" : "dienas"; - }, - h: function (c) { - return getLatvianForm(c) ? "stunda" : "stundas"; - }, - m: function (c) { - return getLatvianForm(c) ? "minūte" : "minūtes"; - }, - s: function (c) { - return getLatvianForm(c) ? "sekunde" : "sekundes"; - }, - ms: function (c) { - return getLatvianForm(c) ? "milisekunde" : "milisekundes"; - }, - decimal: ",", - }, - ms: { - y: "tahun", - mo: "bulan", - w: "minggu", - d: "hari", - h: "jam", - m: "minit", - s: "saat", - ms: "milisaat", - decimal: ".", - }, - nl: { - y: "jaar", - mo: function (c) { - return c === 1 ? "maand" : "maanden"; - }, - w: function (c) { - return c === 1 ? "week" : "weken"; - }, - d: function (c) { - return c === 1 ? "dag" : "dagen"; - }, - h: "uur", - m: function (c) { - return c === 1 ? "minuut" : "minuten"; - }, - s: function (c) { - return c === 1 ? "seconde" : "seconden"; - }, - ms: function (c) { - return c === 1 ? "milliseconde" : "milliseconden"; - }, - decimal: ",", - }, - no: { - y: "år", - mo: function (c) { - return "måned" + (c === 1 ? "" : "er"); - }, - w: function (c) { - return "uke" + (c === 1 ? "" : "r"); - }, - d: function (c) { - return "dag" + (c === 1 ? "" : "er"); - }, - h: function (c) { - return "time" + (c === 1 ? "" : "r"); - }, - m: function (c) { - return "minutt" + (c === 1 ? "" : "er"); - }, - s: function (c) { - return "sekund" + (c === 1 ? "" : "er"); - }, - ms: function (c) { - return "millisekund" + (c === 1 ? "" : "er"); - }, - decimal: ",", - }, - pl: { - y: function (c) { - return ["rok", "roku", "lata", "lat"][getPolishForm(c)]; - }, - mo: function (c) { - return ["miesiąc", "miesiąca", "miesiące", "miesięcy"][ - getPolishForm(c) - ]; - }, - w: function (c) { - return ["tydzień", "tygodnia", "tygodnie", "tygodni"][getPolishForm(c)]; - }, - d: function (c) { - return ["dzień", "dnia", "dni", "dni"][getPolishForm(c)]; - }, - h: function (c) { - return ["godzina", "godziny", "godziny", "godzin"][getPolishForm(c)]; - }, - m: function (c) { - return ["minuta", "minuty", "minuty", "minut"][getPolishForm(c)]; - }, - s: function (c) { - return ["sekunda", "sekundy", "sekundy", "sekund"][getPolishForm(c)]; - }, - ms: function (c) { - return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ - getPolishForm(c) - ]; - }, - decimal: ",", - }, - pt: { - y: function (c) { - return "ano" + (c === 1 ? "" : "s"); - }, - mo: function (c) { - return c === 1 ? "mês" : "meses"; - }, - w: function (c) { - return "semana" + (c === 1 ? "" : "s"); - }, - d: function (c) { - return "dia" + (c === 1 ? "" : "s"); - }, - h: function (c) { - return "hora" + (c === 1 ? "" : "s"); - }, - m: function (c) { - return "minuto" + (c === 1 ? "" : "s"); - }, - s: function (c) { - return "segundo" + (c === 1 ? "" : "s"); - }, - ms: function (c) { - return "milissegundo" + (c === 1 ? "" : "s"); - }, - decimal: ",", - }, - ro: { - y: function (c) { - return c === 1 ? "an" : "ani"; - }, - mo: function (c) { - return c === 1 ? "lună" : "luni"; - }, - w: function (c) { - return c === 1 ? "săptămână" : "săptămâni"; - }, - d: function (c) { - return c === 1 ? "zi" : "zile"; - }, - h: function (c) { - return c === 1 ? "oră" : "ore"; - }, - m: function (c) { - return c === 1 ? "minut" : "minute"; - }, - s: function (c) { - return c === 1 ? "secundă" : "secunde"; - }, - ms: function (c) { - return c === 1 ? "milisecundă" : "milisecunde"; - }, - decimal: ",", - }, - ru: { - y: function (c) { - return ["лет", "год", "года"][getSlavicForm(c)]; - }, - mo: function (c) { - return ["месяцев", "месяц", "месяца"][getSlavicForm(c)]; - }, - w: function (c) { - return ["недель", "неделя", "недели"][getSlavicForm(c)]; - }, - d: function (c) { - return ["дней", "день", "дня"][getSlavicForm(c)]; - }, - h: function (c) { - return ["часов", "час", "часа"][getSlavicForm(c)]; - }, - m: function (c) { - return ["минут", "минута", "минуты"][getSlavicForm(c)]; - }, - s: function (c) { - return ["секунд", "секунда", "секунды"][getSlavicForm(c)]; - }, - ms: function (c) { - return ["миллисекунд", "миллисекунда", "миллисекунды"][ - getSlavicForm(c) - ]; - }, - decimal: ",", - }, - uk: { - y: function (c) { - return ["років", "рік", "роки"][getSlavicForm(c)]; - }, - mo: function (c) { - return ["місяців", "місяць", "місяці"][getSlavicForm(c)]; - }, - w: function (c) { - return ["тижнів", "тиждень", "тижні"][getSlavicForm(c)]; - }, - d: function (c) { - return ["днів", "день", "дні"][getSlavicForm(c)]; - }, - h: function (c) { - return ["годин", "година", "години"][getSlavicForm(c)]; - }, - m: function (c) { - return ["хвилин", "хвилина", "хвилини"][getSlavicForm(c)]; - }, - s: function (c) { - return ["секунд", "секунда", "секунди"][getSlavicForm(c)]; - }, - ms: function (c) { - return ["мілісекунд", "мілісекунда", "мілісекунди"][getSlavicForm(c)]; - }, - decimal: ",", - }, - ur: { - y: "سال", - mo: function (c) { - return c === 1 ? "مہینہ" : "مہینے"; - }, - w: function (c) { - return c === 1 ? "ہفتہ" : "ہفتے"; - }, - d: "دن", - h: function (c) { - return c === 1 ? "گھنٹہ" : "گھنٹے"; - }, - m: "منٹ", - s: "سیکنڈ", - ms: "ملی سیکنڈ", - decimal: ".", - }, - sk: { - y: function (c) { - return ["rok", "roky", "roky", "rokov"][getCzechOrSlovakForm(c)]; - }, - mo: function (c) { - return ["mesiac", "mesiace", "mesiace", "mesiacov"][ - getCzechOrSlovakForm(c) - ]; - }, - w: function (c) { - return ["týždeň", "týždne", "týždne", "týždňov"][ - getCzechOrSlovakForm(c) - ]; - }, - d: function (c) { - return ["deň", "dni", "dni", "dní"][getCzechOrSlovakForm(c)]; - }, - h: function (c) { - return ["hodina", "hodiny", "hodiny", "hodín"][getCzechOrSlovakForm(c)]; - }, - m: function (c) { - return ["minúta", "minúty", "minúty", "minút"][getCzechOrSlovakForm(c)]; - }, - s: function (c) { - return ["sekunda", "sekundy", "sekundy", "sekúnd"][ - getCzechOrSlovakForm(c) - ]; - }, - ms: function (c) { - return ["milisekunda", "milisekundy", "milisekundy", "milisekúnd"][ - getCzechOrSlovakForm(c) - ]; - }, - decimal: ",", - }, - sl: { - y: function (c) { - if (c % 10 === 1) { - return "leto"; - } else if (c % 100 === 2) { - return "leti"; - } else if ( - c % 100 === 3 || - c % 100 === 4 || - (Math.floor(c) !== c && c % 100 <= 5) - ) { - return "leta"; - } else { - return "let"; - } - }, - mo: function (c) { - if (c % 10 === 1) { - return "mesec"; - } else if (c % 100 === 2 || (Math.floor(c) !== c && c % 100 <= 5)) { - return "meseca"; - } else if (c % 10 === 3 || c % 10 === 4) { - return "mesece"; - } else { - return "mesecev"; - } - }, - w: function (c) { - if (c % 10 === 1) { - return "teden"; - } else if (c % 10 === 2 || (Math.floor(c) !== c && c % 100 <= 4)) { - return "tedna"; - } else if (c % 10 === 3 || c % 10 === 4) { - return "tedne"; - } else { - return "tednov"; - } - }, - d: function (c) { - return c % 100 === 1 ? "dan" : "dni"; - }, - h: function (c) { - if (c % 10 === 1) { - return "ura"; - } else if (c % 100 === 2) { - return "uri"; - } else if (c % 10 === 3 || c % 10 === 4 || Math.floor(c) !== c) { - return "ure"; - } else { - return "ur"; - } - }, - m: function (c) { - if (c % 10 === 1) { - return "minuta"; - } else if (c % 10 === 2) { - return "minuti"; - } else if ( - c % 10 === 3 || - c % 10 === 4 || - (Math.floor(c) !== c && c % 100 <= 4) - ) { - return "minute"; - } else { - return "minut"; - } - }, - s: function (c) { - if (c % 10 === 1) { - return "sekunda"; - } else if (c % 100 === 2) { - return "sekundi"; - } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { - return "sekunde"; - } else { - return "sekund"; - } - }, - ms: function (c) { - if (c % 10 === 1) { - return "milisekunda"; - } else if (c % 100 === 2) { - return "milisekundi"; - } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { - return "milisekunde"; - } else { - return "milisekund"; - } - }, - decimal: ",", - }, - sv: { - y: "år", - mo: function (c) { - return "månad" + (c === 1 ? "" : "er"); - }, - w: function (c) { - return "veck" + (c === 1 ? "a" : "or"); - }, - d: function (c) { - return "dag" + (c === 1 ? "" : "ar"); - }, - h: function (c) { - return "timm" + (c === 1 ? "e" : "ar"); - }, - m: function (c) { - return "minut" + (c === 1 ? "" : "er"); - }, - s: function (c) { - return "sekund" + (c === 1 ? "" : "er"); - }, - ms: function (c) { - return "millisekund" + (c === 1 ? "" : "er"); - }, - decimal: ",", - }, - sw: { - y: function (c) { - return c === 1 ? "mwaka" : "miaka"; - }, - mo: function (c) { - return c === 1 ? "mwezi" : "miezi"; - }, - w: "wiki", - d: function (c) { - return c === 1 ? "siku" : "masiku"; - }, - h: function (c) { - return c === 1 ? "saa" : "masaa"; - }, - m: "dakika", - s: "sekunde", - ms: "milisekunde", - decimal: ".", - }, - tr: { - y: "yıl", - mo: "ay", - w: "hafta", - d: "gün", - h: "saat", - m: "dakika", - s: "saniye", - ms: "milisaniye", - decimal: ",", - }, - th: { - y: "ปี", - mo: "เดือน", - w: "สัปดาห์", - d: "วัน", - h: "ชั่วโมง", - m: "นาที", - s: "วินาที", - ms: "มิลลิวินาที", - decimal: ".", - }, - vi: { - y: "năm", - mo: "tháng", - w: "tuần", - d: "ngày", - h: "giờ", - m: "phút", - s: "giây", - ms: "mili giây", - decimal: ",", - }, - zh_CN: { - y: "年", - mo: "个月", - w: "周", - d: "天", - h: "小时", - m: "分钟", - s: "秒", - ms: "毫秒", - decimal: ".", - }, - zh_TW: { - y: "年", - mo: "個月", - w: "周", - d: "天", - h: "小時", - m: "分鐘", - s: "秒", - ms: "毫秒", - decimal: ".", - }, - }; - - // You can create a humanizer, which returns a function with default - // parameters. - function humanizer(passedOptions) { - var result = function humanizer(ms, humanizerOptions) { - var options = assign({}, result, humanizerOptions || {}); - return doHumanization(ms, options); - }; - - return assign( - result, - { - language: "en", - delimiter: ", ", - spacer: " ", - conjunction: "", - serialComma: true, - units: ["y", "mo", "w", "d", "h", "m", "s"], - languages: {}, - round: false, - unitMeasures: { - y: 31557600000, - mo: 2629800000, - w: 604800000, - d: 86400000, - h: 3600000, - m: 60000, - s: 1000, - ms: 1, - }, - }, - passedOptions - ); - } - - // The main function is just a wrapper around a default humanizer. - var humanizeDuration = humanizer({}); - - // Build dictionary from options - function getDictionary(options) { - var languagesFromOptions = [options.language]; - - if (has(options, "fallbacks")) { - if (isArray(options.fallbacks) && options.fallbacks.length) { - languagesFromOptions = languagesFromOptions.concat(options.fallbacks); - } else { - throw new Error("fallbacks must be an array with at least one element"); - } - } - - for (var i = 0; i < languagesFromOptions.length; i++) { - var languageToTry = languagesFromOptions[i]; - if (has(options.languages, languageToTry)) { - return options.languages[languageToTry]; - } else if (has(LANGUAGES, languageToTry)) { - return LANGUAGES[languageToTry]; - } - } - - throw new Error("No language found."); - } - - // doHumanization does the bulk of the work. - function doHumanization(ms, options) { - var i, len, piece; - - // Make sure we have a positive number. - // Has the nice sideffect of turning Number objects into primitives. - ms = Math.abs(ms); - - var dictionary = getDictionary(options); - var pieces = []; - - // Start at the top and keep removing units, bit by bit. - var unitName, unitMS, unitCount; - for (i = 0, len = options.units.length; i < len; i++) { - unitName = options.units[i]; - unitMS = options.unitMeasures[unitName]; - - // What's the number of full units we can fit? - if (i + 1 === len) { - if (has(options, "maxDecimalPoints")) { - // We need to use this expValue to avoid rounding functionality of toFixed call - var expValue = Math.pow(10, options.maxDecimalPoints); - var unitCountFloat = ms / unitMS; - unitCount = parseFloat( - (Math.floor(expValue * unitCountFloat) / expValue).toFixed( - options.maxDecimalPoints - ) - ); - } else { - unitCount = ms / unitMS; - } - } else { - unitCount = Math.floor(ms / unitMS); - } - - // Add the string. - pieces.push({ - unitCount: unitCount, - unitName: unitName, - }); - - // Remove what we just figured out. - ms -= unitCount * unitMS; - } - - var firstOccupiedUnitIndex = 0; - for (i = 0; i < pieces.length; i++) { - if (pieces[i].unitCount) { - firstOccupiedUnitIndex = i; - break; - } - } - - if (options.round) { - var ratioToLargerUnit, previousPiece; - for (i = pieces.length - 1; i >= 0; i--) { - piece = pieces[i]; - piece.unitCount = Math.round(piece.unitCount); - - if (i === 0) { - break; - } - - previousPiece = pieces[i - 1]; - - ratioToLargerUnit = - options.unitMeasures[previousPiece.unitName] / - options.unitMeasures[piece.unitName]; - if ( - piece.unitCount % ratioToLargerUnit === 0 || - (options.largest && options.largest - 1 < i - firstOccupiedUnitIndex) - ) { - previousPiece.unitCount += piece.unitCount / ratioToLargerUnit; - piece.unitCount = 0; - } - } - } - - var result = []; - for (i = 0, pieces.length; i < len; i++) { - piece = pieces[i]; - if (piece.unitCount) { - result.push( - render(piece.unitCount, piece.unitName, dictionary, options) - ); - } - - if (result.length === options.largest) { - break; - } - } - - if (result.length) { - if (!options.conjunction || result.length === 1) { - return result.join(options.delimiter); - } else if (result.length === 2) { - return result.join(options.conjunction); - } else if (result.length > 2) { - return ( - result.slice(0, -1).join(options.delimiter) + - (options.serialComma ? "," : "") + - options.conjunction + - result.slice(-1) - ); - } - } else { - return render( - 0, - options.units[options.units.length - 1], - dictionary, - options - ); - } - } - - function render(count, type, dictionary, options) { - var decimal; - if (has(options, "decimal")) { - decimal = options.decimal; - } else if (has(dictionary, "decimal")) { - decimal = dictionary.decimal; - } else { - decimal = "."; - } - - var countStr = count.toString().replace(".", decimal); - - var dictionaryValue = dictionary[type]; - var word; - if (typeof dictionaryValue === "function") { - word = dictionaryValue(count); - } else { - word = dictionaryValue; - } - - return countStr + options.spacer + word; - } - - function assign(destination) { - var source; - for (var i = 1; i < arguments.length; i++) { - source = arguments[i]; - for (var prop in source) { - if (has(source, prop)) { - destination[prop] = source[prop]; - } - } - } - return destination; - } - - // Internal helper function for Polish language. - function getPolishForm(c) { - if (c === 1) { - return 0; - } else if (Math.floor(c) !== c) { - return 1; - } else if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) { - return 2; - } else { - return 3; - } - } - - // Internal helper function for Russian and Ukranian languages. - function getSlavicForm(c) { - if (Math.floor(c) !== c) { - return 2; - } else if ( - (c % 100 >= 5 && c % 100 <= 20) || - (c % 10 >= 5 && c % 10 <= 9) || - c % 10 === 0 - ) { - return 0; - } else if (c % 10 === 1) { - return 1; - } else if (c > 1) { - return 2; - } else { - return 0; - } - } - - // Internal helper function for Slovak language. - function getCzechOrSlovakForm(c) { - if (c === 1) { - return 0; - } else if (Math.floor(c) !== c) { - return 1; - } else if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) { - return 2; - } else { - return 3; - } - } - - // Internal helper function for Lithuanian language. - function getLithuanianForm(c) { - if (c === 1 || (c % 10 === 1 && c % 100 > 20)) { - return 0; - } else if ( - Math.floor(c) !== c || - (c % 10 >= 2 && c % 100 > 20) || - (c % 10 >= 2 && c % 100 < 10) - ) { - return 1; - } else { - return 2; - } - } - - // Internal helper function for Latvian language. - function getLatvianForm(c) { - return c % 10 === 1 && c % 100 !== 11; - } - - // We need to make sure we support browsers that don't have - // `Array.isArray`, so we define a fallback here. - var isArray = - Array.isArray || - function (arg) { - return Object.prototype.toString.call(arg) === "[object Array]"; - }; - - function has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } - - humanizeDuration.getSupportedLanguages = function getSupportedLanguages() { - var result = []; - for (var language in LANGUAGES) { - if (has(LANGUAGES, language) && language !== "gr") { - result.push(language); - } - } - return result; - }; - - humanizeDuration.humanizer = humanizer; - - if (typeof define === "function" && define.amd) { - define(function () { - return humanizeDuration; - }); - } else if (typeof module !== "undefined" && module.exports) { - module.exports = humanizeDuration; - } else { - this.humanizeDuration = humanizeDuration; - } - })(); - - },{}],97:[function(require,module,exports){ - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - 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 { - // old school shim for old browsers - 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 - } - } - } - - },{}],98:[function(require,module,exports){ - // the whatwg-fetch polyfill installs the fetch() function - // on the global object (window or self) - // - // Return that as the export for use in Webpack, Browserify etc. - require('whatwg-fetch'); - module.exports = self.fetch.bind(self); - - },{"whatwg-fetch":180}],99:[function(require,module,exports){ - (function (global){(function (){ - // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js - - var ws = null - - if (typeof WebSocket !== 'undefined') { - ws = WebSocket - } else if (typeof MozWebSocket !== 'undefined') { - ws = MozWebSocket - } else if (typeof global !== 'undefined') { - ws = global.WebSocket || global.MozWebSocket - } else if (typeof window !== 'undefined') { - ws = window.WebSocket || window.MozWebSocket - } else if (typeof self !== 'undefined') { - ws = self.WebSocket || self.MozWebSocket - } - - module.exports = ws - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{}],100:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - const key_encoder_1 = require("./key-encoder"); - exports.default = key_encoder_1.default; - - },{"./key-encoder":101}],101:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - const elliptic_1 = require("elliptic"); - // @ts-ignore - const asn1 = require("asn1.js"); - const BN = require('bn.js'); - const ECPrivateKeyASN = asn1.define('ECPrivateKey', function () { - // @ts-ignore - const self = this; - self.seq().obj(self.key('version').int(), self.key('privateKey').octstr(), self.key('parameters').explicit(0).objid().optional(), self.key('publicKey').explicit(1).bitstr().optional()); - }); - const SubjectPublicKeyInfoASN = asn1.define('SubjectPublicKeyInfo', function () { - // @ts-ignore - const self = this; - self.seq().obj(self.key('algorithm').seq().obj(self.key("id").objid(), self.key("curve").objid()), self.key('pub').bitstr()); - }); - const curves = { - secp256k1: { - curveParameters: [1, 3, 132, 0, 10], - privatePEMOptions: { label: 'EC PRIVATE KEY' }, - publicPEMOptions: { label: 'PUBLIC KEY' }, - curve: new elliptic_1.ec('secp256k1') - } - }; - class KeyEncoder { - constructor(options) { - if (typeof options === 'string') { - if (options !== 'secp256k1') { - throw new Error('Unknown curve ' + options); - } - options = curves[options]; - } - this.options = options; - this.algorithmID = [1, 2, 840, 10045, 2, 1]; - } - privateKeyObject(rawPrivateKey, rawPublicKey) { - const privateKeyObject = { - version: new BN(1), - privateKey: Buffer.from(rawPrivateKey, 'hex'), - parameters: this.options.curveParameters - }; - if (rawPublicKey) { - privateKeyObject.publicKey = { - unused: 0, - data: Buffer.from(rawPublicKey, 'hex') - }; - } - return privateKeyObject; - } - publicKeyObject(rawPublicKey) { - return { - algorithm: { - id: this.algorithmID, - curve: this.options.curveParameters - }, - pub: { - unused: 0, - data: Buffer.from(rawPublicKey, 'hex') - } - }; - } - encodePrivate(privateKey, originalFormat, destinationFormat) { - let privateKeyObject; - /* Parse the incoming private key and convert it to a private key object */ - if (originalFormat === 'raw') { - if (typeof privateKey !== 'string') { - throw 'private key must be a string'; - } - let keyPair = this.options.curve.keyFromPrivate(privateKey, 'hex'); - let rawPublicKey = keyPair.getPublic('hex'); - privateKeyObject = this.privateKeyObject(privateKey, rawPublicKey); - } - else if (originalFormat === 'der') { - if (typeof privateKey !== 'string') { - // do nothing - } - else if (typeof privateKey === 'string') { - privateKey = Buffer.from(privateKey, 'hex'); - } - else { - throw 'private key must be a buffer or a string'; - } - privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'der'); - } - else if (originalFormat === 'pem') { - if (typeof privateKey !== 'string') { - throw 'private key must be a string'; - } - privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'pem', this.options.privatePEMOptions); - } - else { - throw 'invalid private key format'; - } - /* Export the private key object to the desired format */ - if (destinationFormat === 'raw') { - return privateKeyObject.privateKey.toString('hex'); - } - else if (destinationFormat === 'der') { - return ECPrivateKeyASN.encode(privateKeyObject, 'der').toString('hex'); - } - else if (destinationFormat === 'pem') { - return ECPrivateKeyASN.encode(privateKeyObject, 'pem', this.options.privatePEMOptions); - } - else { - throw 'invalid destination format for private key'; - } - } - encodePublic(publicKey, originalFormat, destinationFormat) { - let publicKeyObject; - /* Parse the incoming public key and convert it to a public key object */ - if (originalFormat === 'raw') { - if (typeof publicKey !== 'string') { - throw 'public key must be a string'; - } - publicKeyObject = this.publicKeyObject(publicKey); - } - else if (originalFormat === 'der') { - if (typeof publicKey !== 'string') { - // do nothing - } - else if (typeof publicKey === 'string') { - publicKey = Buffer.from(publicKey, 'hex'); - } - else { - throw 'public key must be a buffer or a string'; - } - publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'der'); - } - else if (originalFormat === 'pem') { - if (typeof publicKey !== 'string') { - throw 'public key must be a string'; - } - publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'pem', this.options.publicPEMOptions); - } - else { - throw 'invalid public key format'; - } - /* Export the private key object to the desired format */ - if (destinationFormat === 'raw') { - return publicKeyObject.pub.data.toString('hex'); - } - else if (destinationFormat === 'der') { - return SubjectPublicKeyInfoASN.encode(publicKeyObject, 'der').toString('hex'); - } - else if (destinationFormat === 'pem') { - return SubjectPublicKeyInfoASN.encode(publicKeyObject, 'pem', this.options.publicPEMOptions); - } - else { - throw 'invalid destination format for public key'; - } - } - } - exports.default = KeyEncoder; - KeyEncoder.ECPrivateKeyASN = ECPrivateKeyASN; - KeyEncoder.SubjectPublicKeyInfoASN = SubjectPublicKeyInfoASN; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"asn1.js":26,"bn.js":45,"buffer":266,"elliptic":56}],102:[function(require,module,exports){ - 'use strict' - var inherits = require('inherits') - var HashBase = require('hash-base') - var Buffer = require('safe-buffer').Buffer - - var ARRAY16 = new Array(16) - - function MD5 () { - HashBase.call(this, 64) - - // state - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - } - - inherits(MD5, HashBase) - - MD5.prototype._update = function () { - var M = ARRAY16 - for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4) - - var a = this._a - var b = this._b - var c = this._c - var d = this._d - - a = fnF(a, b, c, d, M[0], 0xd76aa478, 7) - d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12) - c = fnF(c, d, a, b, M[2], 0x242070db, 17) - b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22) - a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7) - d = fnF(d, a, b, c, M[5], 0x4787c62a, 12) - c = fnF(c, d, a, b, M[6], 0xa8304613, 17) - b = fnF(b, c, d, a, M[7], 0xfd469501, 22) - a = fnF(a, b, c, d, M[8], 0x698098d8, 7) - d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12) - c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17) - b = fnF(b, c, d, a, M[11], 0x895cd7be, 22) - a = fnF(a, b, c, d, M[12], 0x6b901122, 7) - d = fnF(d, a, b, c, M[13], 0xfd987193, 12) - c = fnF(c, d, a, b, M[14], 0xa679438e, 17) - b = fnF(b, c, d, a, M[15], 0x49b40821, 22) - - a = fnG(a, b, c, d, M[1], 0xf61e2562, 5) - d = fnG(d, a, b, c, M[6], 0xc040b340, 9) - c = fnG(c, d, a, b, M[11], 0x265e5a51, 14) - b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20) - a = fnG(a, b, c, d, M[5], 0xd62f105d, 5) - d = fnG(d, a, b, c, M[10], 0x02441453, 9) - c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14) - b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20) - a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5) - d = fnG(d, a, b, c, M[14], 0xc33707d6, 9) - c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14) - b = fnG(b, c, d, a, M[8], 0x455a14ed, 20) - a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5) - d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9) - c = fnG(c, d, a, b, M[7], 0x676f02d9, 14) - b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20) - - a = fnH(a, b, c, d, M[5], 0xfffa3942, 4) - d = fnH(d, a, b, c, M[8], 0x8771f681, 11) - c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16) - b = fnH(b, c, d, a, M[14], 0xfde5380c, 23) - a = fnH(a, b, c, d, M[1], 0xa4beea44, 4) - d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11) - c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16) - b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23) - a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4) - d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11) - c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16) - b = fnH(b, c, d, a, M[6], 0x04881d05, 23) - a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4) - d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11) - c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16) - b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23) - - a = fnI(a, b, c, d, M[0], 0xf4292244, 6) - d = fnI(d, a, b, c, M[7], 0x432aff97, 10) - c = fnI(c, d, a, b, M[14], 0xab9423a7, 15) - b = fnI(b, c, d, a, M[5], 0xfc93a039, 21) - a = fnI(a, b, c, d, M[12], 0x655b59c3, 6) - d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10) - c = fnI(c, d, a, b, M[10], 0xffeff47d, 15) - b = fnI(b, c, d, a, M[1], 0x85845dd1, 21) - a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6) - d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10) - c = fnI(c, d, a, b, M[6], 0xa3014314, 15) - b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21) - a = fnI(a, b, c, d, M[4], 0xf7537e82, 6) - d = fnI(d, a, b, c, M[11], 0xbd3af235, 10) - c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15) - b = fnI(b, c, d, a, M[9], 0xeb86d391, 21) - - this._a = (this._a + a) | 0 - this._b = (this._b + b) | 0 - this._c = (this._c + c) | 0 - this._d = (this._d + d) | 0 - } - - MD5.prototype._digest = function () { - // create padding and handle blocks - this._block[this._blockOffset++] = 0x80 - if (this._blockOffset > 56) { - this._block.fill(0, this._blockOffset, 64) - this._update() - this._blockOffset = 0 - } - - this._block.fill(0, this._blockOffset, 56) - this._block.writeUInt32LE(this._length[0], 56) - this._block.writeUInt32LE(this._length[1], 60) - this._update() - - // produce result - var buffer = Buffer.allocUnsafe(16) - buffer.writeInt32LE(this._a, 0) - buffer.writeInt32LE(this._b, 4) - buffer.writeInt32LE(this._c, 8) - buffer.writeInt32LE(this._d, 12) - return buffer - } - - function rotl (x, n) { - return (x << n) | (x >>> (32 - n)) - } - - function fnF (a, b, c, d, m, k, s) { - return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0 - } - - function fnG (a, b, c, d, m, k, s) { - return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0 - } - - function fnH (a, b, c, d, m, k, s) { - return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0 - } - - function fnI (a, b, c, d, m, k, s) { - return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0 - } - - module.exports = MD5 - - },{"hash-base":82,"inherits":97,"safe-buffer":122}],103:[function(require,module,exports){ - module.exports = assert; - - function assert(val, msg) { - if (!val) - throw new Error(msg || 'Assertion failed'); - } - - assert.equal = function assertEqual(l, r, msg) { - if (l != r) - throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); - }; - - },{}],104:[function(require,module,exports){ - 'use strict'; - - var utils = exports; - - function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg !== 'string') { - for (var i = 0; i < msg.length; i++) - res[i] = msg[i] | 0; - return res; - } - if (enc === 'hex') { - msg = msg.replace(/[^a-z0-9]+/ig, ''); - if (msg.length % 2 !== 0) - msg = '0' + msg; - for (var i = 0; i < msg.length; i += 2) - res.push(parseInt(msg[i] + msg[i + 1], 16)); - } else { - for (var i = 0; i < msg.length; i++) { - var c = msg.charCodeAt(i); - var hi = c >> 8; - var lo = c & 0xff; - if (hi) - res.push(hi, lo); - else - res.push(lo); - } - } - return res; - } - utils.toArray = toArray; - - function zero2(word) { - if (word.length === 1) - return '0' + word; - else - return word; - } - utils.zero2 = zero2; - - function toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; - } - utils.toHex = toHex; - - utils.encode = function encode(arr, enc) { - if (enc === 'hex') - return toHex(arr); - else - return arr; - }; - - },{}],105:[function(require,module,exports){ - (function (process,global){(function (){ - 'use strict' - - // limit of Crypto.getRandomValues() - // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues - var MAX_BYTES = 65536 - - // Node supports requesting up to this number of bytes - // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48 - var MAX_UINT32 = 4294967295 - - function oldBrowser () { - throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') - } - - var Buffer = require('safe-buffer').Buffer - var crypto = global.crypto || global.msCrypto - - if (crypto && crypto.getRandomValues) { - module.exports = randomBytes - } else { - module.exports = oldBrowser - } - - function randomBytes (size, cb) { - // phantomjs needs to throw - if (size > MAX_UINT32) throw new RangeError('requested too many random bytes') - - var bytes = Buffer.allocUnsafe(size) - - if (size > 0) { // getRandomValues fails on IE if size == 0 - if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues - // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues - for (var generated = 0; generated < size; generated += MAX_BYTES) { - // buffer.slice automatically checks if the end is past the end of - // the buffer so we don't have to here - crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES)) - } - } else { - crypto.getRandomValues(bytes) - } - } - - if (typeof cb === 'function') { - return process.nextTick(function () { - cb(null, bytes) - }) - } - - return bytes - } - - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"_process":353,"safe-buffer":122}],106:[function(require,module,exports){ - 'use strict'; - - function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } - - var codes = {}; - - function createErrorType(code, message, Base) { - if (!Base) { - Base = Error; - } - - function getMessage(arg1, arg2, arg3) { - if (typeof message === 'string') { - return message; - } else { - return message(arg1, arg2, arg3); - } - } - - var NodeError = - /*#__PURE__*/ - function (_Base) { - _inheritsLoose(NodeError, _Base); - - function NodeError(arg1, arg2, arg3) { - return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; - } - - return NodeError; - }(Base); - - NodeError.prototype.name = Base.name; - NodeError.prototype.code = code; - codes[code] = NodeError; - } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js - - - function oneOf(expected, thing) { - if (Array.isArray(expected)) { - var len = expected.length; - expected = expected.map(function (i) { - return String(i); - }); - - if (len > 2) { - return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; - } else if (len === 2) { - return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); - } else { - return "of ".concat(thing, " ").concat(expected[0]); - } - } else { - return "of ".concat(thing, " ").concat(String(expected)); - } - } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith - - - function startsWith(str, search, pos) { - return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; - } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith - - - function endsWith(str, search, this_len) { - if (this_len === undefined || this_len > str.length) { - this_len = str.length; - } - - return str.substring(this_len - search.length, this_len) === search; - } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes - - - function includes(str, search, start) { - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > str.length) { - return false; - } else { - return str.indexOf(search, start) !== -1; - } - } - - createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { - return 'The value "' + value + '" is invalid for option "' + name + '"'; - }, TypeError); - createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { - // determiner: 'must be' or 'must not be' - var determiner; - - if (typeof expected === 'string' && startsWith(expected, 'not ')) { - determiner = 'must not be'; - expected = expected.replace(/^not /, ''); - } else { - determiner = 'must be'; - } - - var msg; - - if (endsWith(name, ' argument')) { - // For cases like 'first argument' - msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); - } else { - var type = includes(name, '.') ? 'property' : 'argument'; - msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); - } - - msg += ". Received type ".concat(typeof actual); - return msg; - }, TypeError); - createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); - createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { - return 'The ' + name + ' method is not implemented'; - }); - createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); - createErrorType('ERR_STREAM_DESTROYED', function (name) { - return 'Cannot call ' + name + ' after a stream was destroyed'; - }); - createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); - createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); - createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); - createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); - createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { - return 'Unknown encoding: ' + arg; - }, TypeError); - createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); - module.exports.codes = codes; - - },{}],107:[function(require,module,exports){ - (function (process){(function (){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a duplex stream is just a stream that is both readable and writable. - // Since JS doesn't have multiple prototypal inheritance, this class - // prototypally inherits from Readable, and then parasitically from - // Writable. - 'use strict'; - /**/ - - var objectKeys = Object.keys || function (obj) { - var keys = []; - - for (var key in obj) { - keys.push(key); - } - - return keys; - }; - /**/ - - - module.exports = Duplex; - - var Readable = require('./_stream_readable'); - - var Writable = require('./_stream_writable'); - - require('inherits')(Duplex, Readable); - - { - // Allow the keys array to be GC'ed. - var keys = objectKeys(Writable.prototype); - - for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; - } - } - - function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - Readable.call(this, options); - Writable.call(this, options); - this.allowHalfOpen = true; - - if (options) { - if (options.readable === false) this.readable = false; - if (options.writable === false) this.writable = false; - - if (options.allowHalfOpen === false) { - this.allowHalfOpen = false; - this.once('end', onend); - } - } - } - - Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.highWaterMark; - } - }); - Object.defineProperty(Duplex.prototype, 'writableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState && this._writableState.getBuffer(); - } - }); - Object.defineProperty(Duplex.prototype, 'writableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.length; - } - }); // the no-half-open enforcer - - function onend() { - // If the writable side ended, then we're ok. - if (this._writableState.ended) return; // no more data can be written. - // But allow more writes to happen in this tick. - - process.nextTick(onEndNT, this); - } - - function onEndNT(self) { - self.end(); - } - - Object.defineProperty(Duplex.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - if (this._readableState === undefined || this._writableState === undefined) { - return false; - } - - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function set(value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; - } // backward compatibility, the user is explicitly - // managing destroyed - - - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } - }); - }).call(this)}).call(this,require('_process')) - },{"./_stream_readable":109,"./_stream_writable":111,"_process":353,"inherits":97}],108:[function(require,module,exports){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a passthrough stream. - // basically just the most minimal sort of Transform stream. - // Every written chunk gets output as-is. - 'use strict'; - - module.exports = PassThrough; - - var Transform = require('./_stream_transform'); - - require('inherits')(PassThrough, Transform); - - function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options); - Transform.call(this, options); - } - - PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk); - }; - },{"./_stream_transform":110,"inherits":97}],109:[function(require,module,exports){ - (function (process,global){(function (){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - 'use strict'; - - module.exports = Readable; - /**/ - - var Duplex; - /**/ - - Readable.ReadableState = ReadableState; - /**/ - - var EE = require('events').EventEmitter; - - var EElistenerCount = function EElistenerCount(emitter, type) { - return emitter.listeners(type).length; - }; - /**/ - - /**/ - - - var Stream = require('./internal/streams/stream'); - /**/ - - - var Buffer = require('buffer').Buffer; - - var OurUint8Array = global.Uint8Array || function () {}; - - function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); - } - - function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; - } - /**/ - - - var debugUtil = require('util'); - - var debug; - - if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); - } else { - debug = function debug() {}; - } - /**/ - - - var BufferList = require('./internal/streams/buffer_list'); - - var destroyImpl = require('./internal/streams/destroy'); - - var _require = require('./internal/streams/state'), - getHighWaterMark = _require.getHighWaterMark; - - var _require$codes = require('../errors').codes, - ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, - ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. - - - var StringDecoder; - var createReadableStreamAsyncIterator; - var from; - - require('inherits')(Readable, Stream); - - var errorOrDestroy = destroyImpl.errorOrDestroy; - var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; - - function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; - } - - function ReadableState(options, stream, isDuplex) { - Duplex = Duplex || require('./_stream_duplex'); - options = options || {}; // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - - this.objectMode = !!options.objectMode; - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - - this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted - // immediately, or on a later tick. We set this to true at first, because - // any actions that shouldn't happen until "later" should generally also - // not happen before the first read call. - - this.sync = true; // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; - this.paused = true; // Should close be emitted on destroy. Defaults to true. - - this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') - - this.autoDestroy = !!options.autoDestroy; // has it been destroyed - - this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - - this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s - - this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled - - this.readingMore = false; - this.decoder = null; - this.encoding = null; - - if (options.encoding) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } - } - - function Readable(options) { - Duplex = Duplex || require('./_stream_duplex'); - if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside - // the ReadableState constructor, at least with V8 6.5 - - var isDuplex = this instanceof Duplex; - this._readableState = new ReadableState(options, this, isDuplex); // legacy - - this.readable = true; - - if (options) { - if (typeof options.read === 'function') this._read = options.read; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - } - - Stream.call(this); - } - - Object.defineProperty(Readable.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - if (this._readableState === undefined) { - return false; - } - - return this._readableState.destroyed; - }, - set: function set(value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._readableState) { - return; - } // backward compatibility, the user is explicitly - // managing destroyed - - - this._readableState.destroyed = value; - } - }); - Readable.prototype.destroy = destroyImpl.destroy; - Readable.prototype._undestroy = destroyImpl.undestroy; - - Readable.prototype._destroy = function (err, cb) { - cb(err); - }; // Manually shove something into the read() buffer. - // This returns true if the highWaterMark has not been hit yet, - // similar to how Writable.write() returns true if you should - // write() some more. - - - Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; - var skipChunkCheck; - - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - - if (encoding !== state.encoding) { - chunk = Buffer.from(chunk, encoding); - encoding = ''; - } - - skipChunkCheck = true; - } - } else { - skipChunkCheck = true; - } - - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); - }; // Unshift should *always* be something directly out of read() - - - Readable.prototype.unshift = function (chunk) { - return readableAddChunk(this, chunk, null, true, false); - }; - - function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - debug('readableAddChunk', chunk); - var state = stream._readableState; - - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) er = chunkInvalid(state, chunk); - - if (er) { - errorOrDestroy(stream, er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (addToFront) { - if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); - } else if (state.ended) { - errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); - } else if (state.destroyed) { - return false; - } else { - state.reading = false; - - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk); - if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); - } else { - addChunk(stream, state, chunk, false); - } - } - } else if (!addToFront) { - state.reading = false; - maybeReadMore(stream, state); - } - } // We can push more data if we are below the highWaterMark. - // Also, if we have no data yet, we can stand some more bytes. - // This is to work around cases where hwm=0, such as the repl. - - - return !state.ended && (state.length < state.highWaterMark || state.length === 0); - } - - function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - state.awaitDrain = 0; - stream.emit('data', chunk); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - if (state.needReadable) emitReadable(stream); - } - - maybeReadMore(stream, state); - } - - function chunkInvalid(state, chunk) { - var er; - - if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); - } - - return er; - } - - Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; - }; // backwards compatibility. - - - Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - var decoder = new StringDecoder(enc); - this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 - - this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: - - var p = this._readableState.buffer.head; - var content = ''; - - while (p !== null) { - content += decoder.write(p.data); - p = p.next; - } - - this._readableState.buffer.clear(); - - if (content !== '') this._readableState.buffer.push(content); - this._readableState.length = content.length; - return this; - }; // Don't raise the hwm > 1GB - - - var MAX_HWM = 0x40000000; - - function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - - return n; - } // This function is designed to be inlinable, so please take care when making - // changes to the function body. - - - function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } // If we're asking for more than the current hwm, then raise the hwm. - - - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; // Don't have enough - - if (!state.ended) { - state.needReadable = true; - return 0; - } - - return state.length; - } // you can override either this method, or the async _read(n) below. - - - Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; - if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - - if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; - } - - n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. - - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this); - return null; - } // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - // if we need a readable event, then we need to do some reading. - - - var doRead = state.needReadable; - debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - - - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } else if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; // if the length is currently zero, then we *need* a readable event. - - if (state.length === 0) state.needReadable = true; // call internal read method - - this._read(state.highWaterMark); - - state.sync = false; // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - - if (!state.reading) n = howMuchToRead(nOrig, state); - } - - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; - - if (ret === null) { - state.needReadable = state.length <= state.highWaterMark; - n = 0; - } else { - state.length -= n; - state.awaitDrain = 0; - } - - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. - - if (nOrig !== n && state.ended) endReadable(this); - } - - if (ret !== null) this.emit('data', ret); - return ret; - }; - - function onEofChunk(stream, state) { - debug('onEofChunk'); - if (state.ended) return; - - if (state.decoder) { - var chunk = state.decoder.end(); - - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - - state.ended = true; - - if (state.sync) { - // if we are sync, wait until next tick to emit the data. - // Otherwise we risk emitting data in the flow() - // the readable code triggers during a read() call - emitReadable(stream); - } else { - // emit 'readable' now to make sure it gets picked up. - state.needReadable = false; - - if (!state.emittedReadable) { - state.emittedReadable = true; - emitReadable_(stream); - } - } - } // Don't emit readable right away in sync mode, because this can trigger - // another read() call => stack overflow. This way, it might trigger - // a nextTick recursion warning, but that's not so bad. - - - function emitReadable(stream) { - var state = stream._readableState; - debug('emitReadable', state.needReadable, state.emittedReadable); - state.needReadable = false; - - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - process.nextTick(emitReadable_, stream); - } - } - - function emitReadable_(stream) { - var state = stream._readableState; - debug('emitReadable_', state.destroyed, state.length, state.ended); - - if (!state.destroyed && (state.length || state.ended)) { - stream.emit('readable'); - state.emittedReadable = false; - } // The stream needs another readable event if - // 1. It is not flowing, as the flow mechanism will take - // care of it. - // 2. It is not ended. - // 3. It is below the highWaterMark, so we can schedule - // another readable later. - - - state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; - flow(stream); - } // at this point, the user has presumably seen the 'readable' event, - // and called read() to consume some data. that may have triggered - // in turn another _read(n) call, in which case reading = true if - // it's in progress. - // However, if we're not ended, or reading, and the length < hwm, - // then go ahead and try to read some more preemptively. - - - function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - process.nextTick(maybeReadMore_, stream, state); - } - } - - function maybeReadMore_(stream, state) { - // Attempt to read more data if we should. - // - // The conditions for reading more data are (one of): - // - Not enough data buffered (state.length < state.highWaterMark). The loop - // is responsible for filling the buffer with enough data if such data - // is available. If highWaterMark is 0 and we are not in the flowing mode - // we should _not_ attempt to buffer any extra data. We'll get more data - // when the stream consumer calls read() instead. - // - No data in the buffer, and the stream is in flowing mode. In this mode - // the loop below is responsible for ensuring read() is called. Failing to - // call read here would abort the flow and there's no other mechanism for - // continuing the flow if the stream consumer has just subscribed to the - // 'data' event. - // - // In addition to the above conditions to keep reading data, the following - // conditions prevent the data from being read: - // - The stream has ended (state.ended). - // - There is already a pending 'read' operation (state.reading). This is a - // case where the the stream has called the implementation defined _read() - // method, but they are processing the call asynchronously and have _not_ - // called push() with new data. In this case we skip performing more - // read()s. The execution ends in this method again after the _read() ends - // up calling push() with more data. - while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { - var len = state.length; - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) // didn't get any data, stop spinning. - break; - } - - state.readingMore = false; - } // abstract method. to be overridden in specific implementation classes. - // call cb(er, data) where data is <= n in length. - // for virtual (non-string, non-buffer) streams, "length" is somewhat - // arbitrary, and perhaps not very meaningful. - - - Readable.prototype._read = function (n) { - errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); - }; - - Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; - - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - - case 1: - state.pipes = [state.pipes, dest]; - break; - - default: - state.pipes.push(dest); - break; - } - - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); - dest.on('unpipe', onunpipe); - - function onunpipe(readable, unpipeInfo) { - debug('onunpipe'); - - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); - } - } - } - - function onend() { - debug('onend'); - dest.end(); - } // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - - - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - var cleanedUp = false; - - function cleanup() { - debug('cleanup'); // cleanup event handlers once the pipe is broken - - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', unpipe); - src.removeListener('data', ondata); - cleanedUp = true; // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } - - src.on('data', ondata); - - function ondata(chunk) { - debug('ondata'); - var ret = dest.write(chunk); - debug('dest.write', ret); - - if (ret === false) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', state.awaitDrain); - state.awaitDrain++; - } - - src.pause(); - } - } // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - - - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); - } // Make sure our error handler is attached before userland ones. - - - prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. - - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - - dest.once('close', onclose); - - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); - } - - dest.once('finish', onfinish); - - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } // tell the dest that it's being piped to - - - dest.emit('pipe', src); // start the flow if it hasn't been started already. - - if (!state.flowing) { - debug('pipe resume'); - src.resume(); - } - - return dest; - }; - - function pipeOnDrain(src) { - return function pipeOnDrainFunctionResult() { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; - } - - Readable.prototype.unpipe = function (dest) { - var state = this._readableState; - var unpipeInfo = { - hasUnpiped: false - }; // if we're not piping anywhere, then do nothing. - - if (state.pipesCount === 0) return this; // just one destination. most common case. - - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; - if (!dest) dest = state.pipes; // got a match. - - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this, unpipeInfo); - return this; - } // slow case. multiple pipe destinations. - - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, { - hasUnpiped: false - }); - } - - return this; - } // try to find the right one. - - - var index = indexOf(state.pipes, dest); - if (index === -1) return this; - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this, unpipeInfo); - return this; - }; // set up data events if they are asked for - // Ensure readable listeners eventually get something - - - Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - var state = this._readableState; - - if (ev === 'data') { - // update readableListening so that resume() may be a no-op - // a few lines down. This is needed to support once('readable'). - state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused - - if (state.flowing !== false) this.resume(); - } else if (ev === 'readable') { - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.flowing = false; - state.emittedReadable = false; - debug('on readable', state.length, state.reading); - - if (state.length) { - emitReadable(this); - } else if (!state.reading) { - process.nextTick(nReadingNextTick, this); - } - } - } - - return res; - }; - - Readable.prototype.addListener = Readable.prototype.on; - - Readable.prototype.removeListener = function (ev, fn) { - var res = Stream.prototype.removeListener.call(this, ev, fn); - - if (ev === 'readable') { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this); - } - - return res; - }; - - Readable.prototype.removeAllListeners = function (ev) { - var res = Stream.prototype.removeAllListeners.apply(this, arguments); - - if (ev === 'readable' || ev === undefined) { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this); - } - - return res; - }; - - function updateReadableListening(self) { - var state = self._readableState; - state.readableListening = self.listenerCount('readable') > 0; - - if (state.resumeScheduled && !state.paused) { - // flowing needs to be set to true now, otherwise - // the upcoming resume will not flow. - state.flowing = true; // crude way to check if we should resume - } else if (self.listenerCount('data') > 0) { - self.resume(); - } - } - - function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); - } // pause() and resume() are remnants of the legacy readable stream API - // If the user uses them, then switch into old mode. - - - Readable.prototype.resume = function () { - var state = this._readableState; - - if (!state.flowing) { - debug('resume'); // we flow only if there is no one listening - // for readable, but we still have to call - // resume() - - state.flowing = !state.readableListening; - resume(this, state); - } - - state.paused = false; - return this; - }; - - function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - process.nextTick(resume_, stream, state); - } - } - - function resume_(stream, state) { - debug('resume', state.reading); - - if (!state.reading) { - stream.read(0); - } - - state.resumeScheduled = false; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); - } - - Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - - if (this._readableState.flowing !== false) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - - this._readableState.paused = true; - return this; - }; - - function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - - while (state.flowing && stream.read() !== null) { - ; - } - } // wrap an old-style stream as the async data source. - // This is *not* part of the readable stream interface. - // It is an ugly unfortunate mess of history. - - - Readable.prototype.wrap = function (stream) { - var _this = this; - - var state = this._readableState; - var paused = false; - stream.on('end', function () { - debug('wrapped end'); - - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) _this.push(chunk); - } - - _this.push(null); - }); - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode - - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - - var ret = _this.push(chunk); - - if (!ret) { - paused = true; - stream.pause(); - } - }); // proxy all the other methods. - // important when wrapping filters and duplexes. - - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function methodWrap(method) { - return function methodWrapReturnFunction() { - return stream[method].apply(stream, arguments); - }; - }(i); - } - } // proxy certain important events. - - - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } // when we try to consume some more bytes, simply unpause the - // underlying stream. - - - this._read = function (n) { - debug('wrapped _read', n); - - if (paused) { - paused = false; - stream.resume(); - } - }; - - return this; - }; - - if (typeof Symbol === 'function') { - Readable.prototype[Symbol.asyncIterator] = function () { - if (createReadableStreamAsyncIterator === undefined) { - createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); - } - - return createReadableStreamAsyncIterator(this); - }; - } - - Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState.highWaterMark; - } - }); - Object.defineProperty(Readable.prototype, 'readableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState && this._readableState.buffer; - } - }); - Object.defineProperty(Readable.prototype, 'readableFlowing', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState.flowing; - }, - set: function set(state) { - if (this._readableState) { - this._readableState.flowing = state; - } - } - }); // exposed for testing purposes only. - - Readable._fromList = fromList; - Object.defineProperty(Readable.prototype, 'readableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState.length; - } - }); // Pluck off n bytes from an array of buffers. - // Length is the combined lengths of all the buffers in the list. - // This function is designed to be inlinable, so please take care when making - // changes to the function body. - - function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = state.buffer.consume(n, state.decoder); - } - return ret; - } - - function endReadable(stream) { - var state = stream._readableState; - debug('endReadable', state.endEmitted); - - if (!state.endEmitted) { - state.ended = true; - process.nextTick(endReadableNT, state, stream); - } - } - - function endReadableNT(state, stream) { - debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. - - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - - if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the writable side is ready for autoDestroy as well - var wState = stream._writableState; - - if (!wState || wState.autoDestroy && wState.finished) { - stream.destroy(); - } - } - } - } - - if (typeof Symbol === 'function') { - Readable.from = function (iterable, opts) { - if (from === undefined) { - from = require('./internal/streams/from'); - } - - return from(Readable, iterable, opts); - }; - } - - function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - - return -1; - } - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"../errors":106,"./_stream_duplex":107,"./internal/streams/async_iterator":112,"./internal/streams/buffer_list":113,"./internal/streams/destroy":114,"./internal/streams/from":116,"./internal/streams/state":118,"./internal/streams/stream":119,"_process":353,"buffer":266,"events":303,"inherits":97,"string_decoder/":135,"util":222}],110:[function(require,module,exports){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a transform stream is a readable/writable stream where you do - // something with the data. Sometimes it's called a "filter", - // but that's not a great name for it, since that implies a thing where - // some bits pass through, and others are simply ignored. (That would - // be a valid example of a transform, of course.) - // - // While the output is causally related to the input, it's not a - // necessarily symmetric or synchronous transformation. For example, - // a zlib stream might take multiple plain-text writes(), and then - // emit a single compressed chunk some time in the future. - // - // Here's how this works: - // - // The Transform stream has all the aspects of the readable and writable - // stream classes. When you write(chunk), that calls _write(chunk,cb) - // internally, and returns false if there's a lot of pending writes - // buffered up. When you call read(), that calls _read(n) until - // there's enough pending readable data buffered up. - // - // In a transform stream, the written data is placed in a buffer. When - // _read(n) is called, it transforms the queued up data, calling the - // buffered _write cb's as it consumes chunks. If consuming a single - // written chunk would result in multiple output chunks, then the first - // outputted bit calls the readcb, and subsequent chunks just go into - // the read buffer, and will cause it to emit 'readable' if necessary. - // - // This way, back-pressure is actually determined by the reading side, - // since _read has to be called to start processing a new chunk. However, - // a pathological inflate type of transform can cause excessive buffering - // here. For example, imagine a stream where every byte of input is - // interpreted as an integer from 0-255, and then results in that many - // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in - // 1kb of data being output. In this case, you could write a very small - // amount of input, and end up with a very large amount of output. In - // such a pathological inflating mechanism, there'd be no way to tell - // the system to stop doing the transform. A single 4MB write could - // cause the system to run out of memory. - // - // However, even in such a pathological case, only a single written chunk - // would be consumed, and then the rest would wait (un-transformed) until - // the results of the previous transformed chunk were consumed. - 'use strict'; - - module.exports = Transform; - - var _require$codes = require('../errors').codes, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, - ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, - ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; - - var Duplex = require('./_stream_duplex'); - - require('inherits')(Transform, Duplex); - - function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; - var cb = ts.writecb; - - if (cb === null) { - return this.emit('error', new ERR_MULTIPLE_CALLBACK()); - } - - ts.writechunk = null; - ts.writecb = null; - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); - cb(er); - var rs = this._readableState; - rs.reading = false; - - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); - } - } - - function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); - Duplex.call(this, options); - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; // start out asking for a readable event once data is transformed. - - this._readableState.needReadable = true; // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - - this._readableState.sync = false; - - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') this._flush = options.flush; - } // When the writable side finishes, then flush out anything remaining. - - - this.on('prefinish', prefinish); - } - - function prefinish() { - var _this = this; - - if (typeof this._flush === 'function' && !this._readableState.destroyed) { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); - } - } - - Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); - }; // This is the part where you do stuff! - // override this function in implementation classes. - // 'chunk' is an input chunk. - // - // Call `push(newChunk)` to pass along transformed output - // to the readable side. You may call 'push' zero or more times. - // - // Call `cb(err)` when you are done with this chunk. If you pass - // an error, then that'll put the hurt on the whole operation. If you - // never call cb(), then you'll never get another chunk. - - - Transform.prototype._transform = function (chunk, encoding, cb) { - cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); - }; - - Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } - }; // Doesn't matter what the args are here. - // _transform does all the work. - // That we got here means that the readable side wants more data. - - - Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && !ts.transforming) { - ts.transforming = true; - - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } - }; - - Transform.prototype._destroy = function (err, cb) { - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - }); - }; - - function done(stream, er, data) { - if (er) return stream.emit('error', er); - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); // TODO(BridgeAR): Write a test for these two error cases - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - - if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); - if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); - return stream.push(null); - } - },{"../errors":106,"./_stream_duplex":107,"inherits":97}],111:[function(require,module,exports){ - (function (process,global){(function (){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - // A bit simpler than readable streams. - // Implement an async ._write(chunk, encoding, cb), and it'll handle all - // the drain event emission and buffering. - 'use strict'; - - module.exports = Writable; - /* */ - - function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; - } // It seems a linked list but it is not - // there will be only 2 of these for each stream - - - function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; - - this.finish = function () { - onCorkedFinish(_this, state); - }; - } - /* */ - - /**/ - - - var Duplex; - /**/ - - Writable.WritableState = WritableState; - /**/ - - var internalUtil = { - deprecate: require('util-deprecate') - }; - /**/ - - /**/ - - var Stream = require('./internal/streams/stream'); - /**/ - - - var Buffer = require('buffer').Buffer; - - var OurUint8Array = global.Uint8Array || function () {}; - - function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); - } - - function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; - } - - var destroyImpl = require('./internal/streams/destroy'); - - var _require = require('./internal/streams/state'), - getHighWaterMark = _require.getHighWaterMark; - - var _require$codes = require('../errors').codes, - ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, - ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, - ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, - ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, - ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, - ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; - - var errorOrDestroy = destroyImpl.errorOrDestroy; - - require('inherits')(Writable, Stream); - - function nop() {} - - function WritableState(options, stream, isDuplex) { - Duplex = Duplex || require('./_stream_duplex'); - options = options || {}; // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream, - // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream - // contains buffers or objects. - - this.objectMode = !!options.objectMode; - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - - this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called - - this.finalCalled = false; // drain event flag. - - this.needDrain = false; // at the start of calling end() - - this.ending = false; // when end() has been called, and returned - - this.ended = false; // when 'finish' is emitted - - this.finished = false; // has it been destroyed - - this.destroyed = false; // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - - this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - - this.length = 0; // a flag to see when we're in the middle of a write. - - this.writing = false; // when true all writes will be buffered until .uncork() call - - this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - - this.sync = true; // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - - this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) - - this.onwrite = function (er) { - onwrite(stream, er); - }; // the callback that the user supplies to write(chunk,encoding,cb) - - - this.writecb = null; // the amount that is being written when _write is called. - - this.writelen = 0; - this.bufferedRequest = null; - this.lastBufferedRequest = null; // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - - this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - - this.prefinished = false; // True if the error was already emitted and should not be thrown again - - this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. - - this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') - - this.autoDestroy = !!options.autoDestroy; // count buffered requests - - this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - - this.corkedRequestsFree = new CorkedRequest(this); - } - - WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - - while (current) { - out.push(current); - current = current.next; - } - - return out; - }; - - (function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function writableStateBufferGetter() { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') - }); - } catch (_) {} - })(); // Test _writableState for inheritance to account for Duplex streams, - // whose prototype chain only points to Readable. - - - var realHasInstance; - - if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function value(object) { - if (realHasInstance.call(this, object)) return true; - if (this !== Writable) return false; - return object && object._writableState instanceof WritableState; - } - }); - } else { - realHasInstance = function realHasInstance(object) { - return object instanceof this; - }; - } - - function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - // Checking for a Stream.Duplex instance is faster here instead of inside - // the WritableState constructor, at least with V8 6.5 - - var isDuplex = this instanceof Duplex; - if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); - this._writableState = new WritableState(options, this, isDuplex); // legacy. - - this.writable = true; - - if (options) { - if (typeof options.write === 'function') this._write = options.write; - if (typeof options.writev === 'function') this._writev = options.writev; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - if (typeof options.final === 'function') this._final = options.final; - } - - Stream.call(this); - } // Otherwise people can pipe Writable streams, which is just wrong. - - - Writable.prototype.pipe = function () { - errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); - }; - - function writeAfterEnd(stream, cb) { - var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb - - errorOrDestroy(stream, er); - process.nextTick(cb, er); - } // Checks that a user-supplied chunk is valid, especially for the particular - // mode the stream is in. Currently this means that `null` is never accepted - // and undefined/non-string values are only allowed in object mode. - - - function validChunk(stream, state, chunk, cb) { - var er; - - if (chunk === null) { - er = new ERR_STREAM_NULL_VALUES(); - } else if (typeof chunk !== 'string' && !state.objectMode) { - er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); - } - - if (er) { - errorOrDestroy(stream, er); - process.nextTick(cb, er); - return false; - } - - return true; - } - - Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - - var isBuf = !state.objectMode && _isUint8Array(chunk); - - if (isBuf && !Buffer.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') cb = nop; - if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } - return ret; - }; - - Writable.prototype.cork = function () { - this._writableState.corked++; - }; - - Writable.prototype.uncork = function () { - var state = this._writableState; - - if (state.corked) { - state.corked--; - if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); - } - }; - - Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); - this._writableState.defaultEncoding = encoding; - return this; - }; - - Object.defineProperty(Writable.prototype, 'writableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState && this._writableState.getBuffer(); - } - }); - - function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = Buffer.from(chunk, encoding); - } - - return chunk; - } - - Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.highWaterMark; - } - }); // if we're already writing something, then just put this - // in the queue, and wait our turn. Otherwise, call _write - // If we return false, then we need a drain event, so set that flag. - - function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - - if (chunk !== newChunk) { - isBuf = true; - encoding = 'buffer'; - chunk = newChunk; - } - } - - var len = state.objectMode ? 1 : chunk.length; - state.length += len; - var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. - - if (!ret) state.needDrain = true; - - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk: chunk, - encoding: encoding, - isBuf: isBuf, - callback: cb, - next: null - }; - - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); - } - - return ret; - } - - function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; - } - - function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - - if (sync) { - // defer the callback if we are being called synchronously - // to avoid piling up things on the stack - process.nextTick(cb, er); // this can emit finish, and it will always happen - // after error - - process.nextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - errorOrDestroy(stream, er); - } else { - // the caller expect this to happen before if - // it is async - cb(er); - stream._writableState.errorEmitted = true; - errorOrDestroy(stream, er); // this can emit finish, but finish must - // always follow error - - finishMaybe(stream, state); - } - } - - function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; - } - - function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); - onwriteStateUpdate(state); - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state) || stream.destroyed; - - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } - - if (sync) { - process.nextTick(afterWrite, stream, state, finished, cb); - } else { - afterWrite(stream, state, finished, cb); - } - } - } - - function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); - } // Must force callback to be called on nextTick, so that we don't - // emit 'drain' before the write() consumer gets the 'false' return - // value, and has a chance to attach a 'drain' listener. - - - function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } - } // if there's something in the buffer waiting, then process it - - - function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; - - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; - var count = 0; - var allBuffers = true; - - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) allBuffers = false; - entry = entry.next; - count += 1; - } - - buffer.allBuffers = allBuffers; - doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - - state.pendingcb++; - state.lastBufferedRequest = null; - - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - - state.bufferedRequestCount = 0; - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - - if (state.writing) { - break; - } - } - - if (entry === null) state.lastBufferedRequest = null; - } - - state.bufferedRequest = entry; - state.bufferProcessing = false; - } - - Writable.prototype._write = function (chunk, encoding, cb) { - cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); - }; - - Writable.prototype._writev = null; - - Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; - - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks - - if (state.corked) { - state.corked = 1; - this.uncork(); - } // ignore unnecessary end() calls. - - - if (!state.ending) endWritable(this, state, cb); - return this; - }; - - Object.defineProperty(Writable.prototype, 'writableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.length; - } - }); - - function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; - } - - function callFinal(stream, state) { - stream._final(function (err) { - state.pendingcb--; - - if (err) { - errorOrDestroy(stream, err); - } - - state.prefinished = true; - stream.emit('prefinish'); - finishMaybe(stream, state); - }); - } - - function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function' && !state.destroyed) { - state.pendingcb++; - state.finalCalled = true; - process.nextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit('prefinish'); - } - } - } - - function finishMaybe(stream, state) { - var need = needFinish(state); - - if (need) { - prefinish(stream, state); - - if (state.pendingcb === 0) { - state.finished = true; - stream.emit('finish'); - - if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the readable side is ready for autoDestroy as well - var rState = stream._readableState; - - if (!rState || rState.autoDestroy && rState.endEmitted) { - stream.destroy(); - } - } - } - } - - return need; - } - - function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - - if (cb) { - if (state.finished) process.nextTick(cb);else stream.once('finish', cb); - } - - state.ended = true; - stream.writable = false; - } - - function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } // reuse the free corkReq. - - - state.corkedRequestsFree.next = corkReq; - } - - Object.defineProperty(Writable.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - if (this._writableState === undefined) { - return false; - } - - return this._writableState.destroyed; - }, - set: function set(value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; - } // backward compatibility, the user is explicitly - // managing destroyed - - - this._writableState.destroyed = value; - } - }); - Writable.prototype.destroy = destroyImpl.destroy; - Writable.prototype._undestroy = destroyImpl.undestroy; - - Writable.prototype._destroy = function (err, cb) { - cb(err); - }; - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"../errors":106,"./_stream_duplex":107,"./internal/streams/destroy":114,"./internal/streams/state":118,"./internal/streams/stream":119,"_process":353,"buffer":266,"inherits":97,"util-deprecate":179}],112:[function(require,module,exports){ - (function (process){(function (){ - 'use strict'; - - var _Object$setPrototypeO; - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - var finished = require('./end-of-stream'); - - var kLastResolve = Symbol('lastResolve'); - var kLastReject = Symbol('lastReject'); - var kError = Symbol('error'); - var kEnded = Symbol('ended'); - var kLastPromise = Symbol('lastPromise'); - var kHandlePromise = Symbol('handlePromise'); - var kStream = Symbol('stream'); - - function createIterResult(value, done) { - return { - value: value, - done: done - }; - } - - function readAndResolve(iter) { - var resolve = iter[kLastResolve]; - - if (resolve !== null) { - var data = iter[kStream].read(); // we defer if data is null - // we can be expecting either 'end' or - // 'error' - - if (data !== null) { - iter[kLastPromise] = null; - iter[kLastResolve] = null; - iter[kLastReject] = null; - resolve(createIterResult(data, false)); - } - } - } - - function onReadable(iter) { - // we wait for the next tick, because it might - // emit an error with process.nextTick - process.nextTick(readAndResolve, iter); - } - - function wrapForNext(lastPromise, iter) { - return function (resolve, reject) { - lastPromise.then(function () { - if (iter[kEnded]) { - resolve(createIterResult(undefined, true)); - return; - } - - iter[kHandlePromise](resolve, reject); - }, reject); - }; - } - - var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); - var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { - get stream() { - return this[kStream]; - }, - - next: function next() { - var _this = this; - - // if we have detected an error in the meanwhile - // reject straight away - var error = this[kError]; - - if (error !== null) { - return Promise.reject(error); - } - - if (this[kEnded]) { - return Promise.resolve(createIterResult(undefined, true)); - } - - if (this[kStream].destroyed) { - // We need to defer via nextTick because if .destroy(err) is - // called, the error will be emitted via nextTick, and - // we cannot guarantee that there is no error lingering around - // waiting to be emitted. - return new Promise(function (resolve, reject) { - process.nextTick(function () { - if (_this[kError]) { - reject(_this[kError]); - } else { - resolve(createIterResult(undefined, true)); - } - }); - }); - } // if we have multiple next() calls - // we will wait for the previous Promise to finish - // this logic is optimized to support for await loops, - // where next() is only called once at a time - - - var lastPromise = this[kLastPromise]; - var promise; - - if (lastPromise) { - promise = new Promise(wrapForNext(lastPromise, this)); - } else { - // fast path needed to support multiple this.push() - // without triggering the next() queue - var data = this[kStream].read(); - - if (data !== null) { - return Promise.resolve(createIterResult(data, false)); - } - - promise = new Promise(this[kHandlePromise]); - } - - this[kLastPromise] = promise; - return promise; - } - }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { - return this; - }), _defineProperty(_Object$setPrototypeO, "return", function _return() { - var _this2 = this; - - // destroy(err, cb) is a private API - // we can guarantee we have that here, because we control the - // Readable class this is attached to - return new Promise(function (resolve, reject) { - _this2[kStream].destroy(null, function (err) { - if (err) { - reject(err); - return; - } - - resolve(createIterResult(undefined, true)); - }); - }); - }), _Object$setPrototypeO), AsyncIteratorPrototype); - - var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { - var _Object$create; - - var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { - value: stream, - writable: true - }), _defineProperty(_Object$create, kLastResolve, { - value: null, - writable: true - }), _defineProperty(_Object$create, kLastReject, { - value: null, - writable: true - }), _defineProperty(_Object$create, kError, { - value: null, - writable: true - }), _defineProperty(_Object$create, kEnded, { - value: stream._readableState.endEmitted, - writable: true - }), _defineProperty(_Object$create, kHandlePromise, { - value: function value(resolve, reject) { - var data = iterator[kStream].read(); - - if (data) { - iterator[kLastPromise] = null; - iterator[kLastResolve] = null; - iterator[kLastReject] = null; - resolve(createIterResult(data, false)); - } else { - iterator[kLastResolve] = resolve; - iterator[kLastReject] = reject; - } - }, - writable: true - }), _Object$create)); - iterator[kLastPromise] = null; - finished(stream, function (err) { - if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { - var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise - // returned by next() and store the error - - if (reject !== null) { - iterator[kLastPromise] = null; - iterator[kLastResolve] = null; - iterator[kLastReject] = null; - reject(err); - } - - iterator[kError] = err; - return; - } - - var resolve = iterator[kLastResolve]; - - if (resolve !== null) { - iterator[kLastPromise] = null; - iterator[kLastResolve] = null; - iterator[kLastReject] = null; - resolve(createIterResult(undefined, true)); - } - - iterator[kEnded] = true; - }); - stream.on('readable', onReadable.bind(null, iterator)); - return iterator; - }; - - module.exports = createReadableStreamAsyncIterator; - }).call(this)}).call(this,require('_process')) - },{"./end-of-stream":115,"_process":353}],113:[function(require,module,exports){ - 'use strict'; - - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } - - function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - - var _require = require('buffer'), - Buffer = _require.Buffer; - - var _require2 = require('util'), - inspect = _require2.inspect; - - var custom = inspect && inspect.custom || 'inspect'; - - function copyBuffer(src, target, offset) { - Buffer.prototype.copy.call(src, target, offset); - } - - module.exports = - /*#__PURE__*/ - function () { - function BufferList() { - _classCallCheck(this, BufferList); - - this.head = null; - this.tail = null; - this.length = 0; - } - - _createClass(BufferList, [{ - key: "push", - value: function push(v) { - var entry = { - data: v, - next: null - }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - } - }, { - key: "unshift", - value: function unshift(v) { - var entry = { - data: v, - next: this.head - }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - } - }, { - key: "shift", - value: function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - } - }, { - key: "clear", - value: function clear() { - this.head = this.tail = null; - this.length = 0; - } - }, { - key: "join", - value: function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - - while (p = p.next) { - ret += s + p.data; - } - - return ret; - } - }, { - key: "concat", - value: function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - - return ret; - } // Consumes a specified amount of bytes or characters from the buffered data. - - }, { - key: "consume", - value: function consume(n, hasStrings) { - var ret; - - if (n < this.head.data.length) { - // `slice` is the same for buffers and strings. - ret = this.head.data.slice(0, n); - this.head.data = this.head.data.slice(n); - } else if (n === this.head.data.length) { - // First chunk is a perfect match. - ret = this.shift(); - } else { - // Result spans more than one buffer. - ret = hasStrings ? this._getString(n) : this._getBuffer(n); - } - - return ret; - } - }, { - key: "first", - value: function first() { - return this.head.data; - } // Consumes a specified amount of characters from the buffered data. - - }, { - key: "_getString", - value: function _getString(n) { - var p = this.head; - var c = 1; - var ret = p.data; - n -= ret.length; - - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) this.head = p.next;else this.head = this.tail = null; - } else { - this.head = p; - p.data = str.slice(nb); - } - - break; - } - - ++c; - } - - this.length -= c; - return ret; - } // Consumes a specified amount of bytes from the buffered data. - - }, { - key: "_getBuffer", - value: function _getBuffer(n) { - var ret = Buffer.allocUnsafe(n); - var p = this.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) this.head = p.next;else this.head = this.tail = null; - } else { - this.head = p; - p.data = buf.slice(nb); - } - - break; - } - - ++c; - } - - this.length -= c; - return ret; - } // Make sure the linked list only shows the minimal necessary information. - - }, { - key: custom, - value: function value(_, options) { - return inspect(this, _objectSpread({}, options, { - // Only inspect one level. - depth: 0, - // It should not recurse. - customInspect: false - })); - } - }]); - - return BufferList; - }(); - },{"buffer":266,"util":222}],114:[function(require,module,exports){ - (function (process){(function (){ - 'use strict'; // undocumented cb() API, needed for core, not for public API - - function destroy(err, cb) { - var _this = this; - - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; - - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err) { - if (!this._writableState) { - process.nextTick(emitErrorNT, this, err); - } else if (!this._writableState.errorEmitted) { - this._writableState.errorEmitted = true; - process.nextTick(emitErrorNT, this, err); - } - } - - return this; - } // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks - - - if (this._readableState) { - this._readableState.destroyed = true; - } // if this is a duplex stream mark the writable part as destroyed as well - - - if (this._writableState) { - this._writableState.destroyed = true; - } - - this._destroy(err || null, function (err) { - if (!cb && err) { - if (!_this._writableState) { - process.nextTick(emitErrorAndCloseNT, _this, err); - } else if (!_this._writableState.errorEmitted) { - _this._writableState.errorEmitted = true; - process.nextTick(emitErrorAndCloseNT, _this, err); - } else { - process.nextTick(emitCloseNT, _this); - } - } else if (cb) { - process.nextTick(emitCloseNT, _this); - cb(err); - } else { - process.nextTick(emitCloseNT, _this); - } - }); - - return this; - } - - function emitErrorAndCloseNT(self, err) { - emitErrorNT(self, err); - emitCloseNT(self); - } - - function emitCloseNT(self) { - if (self._writableState && !self._writableState.emitClose) return; - if (self._readableState && !self._readableState.emitClose) return; - self.emit('close'); - } - - function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } - - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finalCalled = false; - this._writableState.prefinished = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; - } - } - - function emitErrorNT(self, err) { - self.emit('error', err); - } - - function errorOrDestroy(stream, err) { - // We have tests that rely on errors being emitted - // in the same tick, so changing this is semver major. - // For now when you opt-in to autoDestroy we allow - // the error to be emitted nextTick. In a future - // semver major update we should change the default to this. - var rState = stream._readableState; - var wState = stream._writableState; - if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); - } - - module.exports = { - destroy: destroy, - undestroy: undestroy, - errorOrDestroy: errorOrDestroy - }; - }).call(this)}).call(this,require('_process')) - },{"_process":353}],115:[function(require,module,exports){ - // Ported from https://github.com/mafintosh/end-of-stream with - // permission from the author, Mathias Buus (@mafintosh). - 'use strict'; - - var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; - - function once(callback) { - var called = false; - return function () { - if (called) return; - called = true; - - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - callback.apply(this, args); - }; - } - - function noop() {} - - function isRequest(stream) { - return stream.setHeader && typeof stream.abort === 'function'; - } - - function eos(stream, opts, callback) { - if (typeof opts === 'function') return eos(stream, null, opts); - if (!opts) opts = {}; - callback = once(callback || noop); - var readable = opts.readable || opts.readable !== false && stream.readable; - var writable = opts.writable || opts.writable !== false && stream.writable; - - var onlegacyfinish = function onlegacyfinish() { - if (!stream.writable) onfinish(); - }; - - var writableEnded = stream._writableState && stream._writableState.finished; - - var onfinish = function onfinish() { - writable = false; - writableEnded = true; - if (!readable) callback.call(stream); - }; - - var readableEnded = stream._readableState && stream._readableState.endEmitted; - - var onend = function onend() { - readable = false; - readableEnded = true; - if (!writable) callback.call(stream); - }; - - var onerror = function onerror(err) { - callback.call(stream, err); - }; - - var onclose = function onclose() { - var err; - - if (readable && !readableEnded) { - if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); - return callback.call(stream, err); - } - - if (writable && !writableEnded) { - if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); - return callback.call(stream, err); - } - }; - - var onrequest = function onrequest() { - stream.req.on('finish', onfinish); - }; - - if (isRequest(stream)) { - stream.on('complete', onfinish); - stream.on('abort', onclose); - if (stream.req) onrequest();else stream.on('request', onrequest); - } else if (writable && !stream._writableState) { - // legacy streams - stream.on('end', onlegacyfinish); - stream.on('close', onlegacyfinish); - } - - stream.on('end', onend); - stream.on('finish', onfinish); - if (opts.error !== false) stream.on('error', onerror); - stream.on('close', onclose); - return function () { - stream.removeListener('complete', onfinish); - stream.removeListener('abort', onclose); - stream.removeListener('request', onrequest); - if (stream.req) stream.req.removeListener('finish', onfinish); - stream.removeListener('end', onlegacyfinish); - stream.removeListener('close', onlegacyfinish); - stream.removeListener('finish', onfinish); - stream.removeListener('end', onend); - stream.removeListener('error', onerror); - stream.removeListener('close', onclose); - }; - } - - module.exports = eos; - },{"../../../errors":106}],116:[function(require,module,exports){ - module.exports = function () { - throw new Error('Readable.from is not available in the browser') - }; - - },{}],117:[function(require,module,exports){ - // Ported from https://github.com/mafintosh/pump with - // permission from the author, Mathias Buus (@mafintosh). - 'use strict'; - - var eos; - - function once(callback) { - var called = false; - return function () { - if (called) return; - called = true; - callback.apply(void 0, arguments); - }; - } - - var _require$codes = require('../../../errors').codes, - ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, - ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; - - function noop(err) { - // Rethrow the error if it exists to avoid swallowing it - if (err) throw err; - } - - function isRequest(stream) { - return stream.setHeader && typeof stream.abort === 'function'; - } - - function destroyer(stream, reading, writing, callback) { - callback = once(callback); - var closed = false; - stream.on('close', function () { - closed = true; - }); - if (eos === undefined) eos = require('./end-of-stream'); - eos(stream, { - readable: reading, - writable: writing - }, function (err) { - if (err) return callback(err); - closed = true; - callback(); - }); - var destroyed = false; - return function (err) { - if (closed) return; - if (destroyed) return; - destroyed = true; // request.destroy just do .end - .abort is what we want - - if (isRequest(stream)) return stream.abort(); - if (typeof stream.destroy === 'function') return stream.destroy(); - callback(err || new ERR_STREAM_DESTROYED('pipe')); - }; - } - - function call(fn) { - fn(); - } - - function pipe(from, to) { - return from.pipe(to); - } - - function popCallback(streams) { - if (!streams.length) return noop; - if (typeof streams[streams.length - 1] !== 'function') return noop; - return streams.pop(); - } - - function pipeline() { - for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { - streams[_key] = arguments[_key]; - } - - var callback = popCallback(streams); - if (Array.isArray(streams[0])) streams = streams[0]; - - if (streams.length < 2) { - throw new ERR_MISSING_ARGS('streams'); - } - - var error; - var destroys = streams.map(function (stream, i) { - var reading = i < streams.length - 1; - var writing = i > 0; - return destroyer(stream, reading, writing, function (err) { - if (!error) error = err; - if (err) destroys.forEach(call); - if (reading) return; - destroys.forEach(call); - callback(error); - }); - }); - return streams.reduce(pipe); - } - - module.exports = pipeline; - },{"../../../errors":106,"./end-of-stream":115}],118:[function(require,module,exports){ - 'use strict'; - - var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; - - function highWaterMarkFrom(options, isDuplex, duplexKey) { - return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; - } - - function getHighWaterMark(state, options, duplexKey, isDuplex) { - var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); - - if (hwm != null) { - if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { - var name = isDuplex ? duplexKey : 'highWaterMark'; - throw new ERR_INVALID_OPT_VALUE(name, hwm); - } - - return Math.floor(hwm); - } // Default value - - - return state.objectMode ? 16 : 16 * 1024; - } - - module.exports = { - getHighWaterMark: getHighWaterMark - }; - },{"../../../errors":106}],119:[function(require,module,exports){ - module.exports = require('events').EventEmitter; - - },{"events":303}],120:[function(require,module,exports){ - exports = module.exports = require('./lib/_stream_readable.js'); - exports.Stream = exports; - exports.Readable = exports; - exports.Writable = require('./lib/_stream_writable.js'); - exports.Duplex = require('./lib/_stream_duplex.js'); - exports.Transform = require('./lib/_stream_transform.js'); - exports.PassThrough = require('./lib/_stream_passthrough.js'); - exports.finished = require('./lib/internal/streams/end-of-stream.js'); - exports.pipeline = require('./lib/internal/streams/pipeline.js'); - - },{"./lib/_stream_duplex.js":107,"./lib/_stream_passthrough.js":108,"./lib/_stream_readable.js":109,"./lib/_stream_transform.js":110,"./lib/_stream_writable.js":111,"./lib/internal/streams/end-of-stream.js":115,"./lib/internal/streams/pipeline.js":117}],121:[function(require,module,exports){ - 'use strict' - var Buffer = require('buffer').Buffer - var inherits = require('inherits') - var HashBase = require('hash-base') - - var ARRAY16 = new Array(16) - - var zl = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 - ] - - var zr = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 - ] - - var sl = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 - ] - - var sr = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 - ] - - var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e] - var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000] - - function RIPEMD160 () { - HashBase.call(this, 64) - - // state - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - } - - inherits(RIPEMD160, HashBase) - - RIPEMD160.prototype._update = function () { - var words = ARRAY16 - for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4) - - var al = this._a | 0 - var bl = this._b | 0 - var cl = this._c | 0 - var dl = this._d | 0 - var el = this._e | 0 - - var ar = this._a | 0 - var br = this._b | 0 - var cr = this._c | 0 - var dr = this._d | 0 - var er = this._e | 0 - - // computation - for (var i = 0; i < 80; i += 1) { - var tl - var tr - if (i < 16) { - tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]) - tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]) - } else if (i < 32) { - tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]) - tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]) - } else if (i < 48) { - tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]) - tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]) - } else if (i < 64) { - tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]) - tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]) - } else { // if (i<80) { - tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]) - tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]) - } - - al = el - el = dl - dl = rotl(cl, 10) - cl = bl - bl = tl - - ar = er - er = dr - dr = rotl(cr, 10) - cr = br - br = tr - } - - // update state - var t = (this._b + cl + dr) | 0 - this._b = (this._c + dl + er) | 0 - this._c = (this._d + el + ar) | 0 - this._d = (this._e + al + br) | 0 - this._e = (this._a + bl + cr) | 0 - this._a = t - } - - RIPEMD160.prototype._digest = function () { - // create padding and handle blocks - this._block[this._blockOffset++] = 0x80 - if (this._blockOffset > 56) { - this._block.fill(0, this._blockOffset, 64) - this._update() - this._blockOffset = 0 - } - - this._block.fill(0, this._blockOffset, 56) - this._block.writeUInt32LE(this._length[0], 56) - this._block.writeUInt32LE(this._length[1], 60) - this._update() - - // produce result - var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20) - buffer.writeInt32LE(this._a, 0) - buffer.writeInt32LE(this._b, 4) - buffer.writeInt32LE(this._c, 8) - buffer.writeInt32LE(this._d, 12) - buffer.writeInt32LE(this._e, 16) - return buffer - } - - function rotl (x, n) { - return (x << n) | (x >>> (32 - n)) - } - - function fn1 (a, b, c, d, e, m, k, s) { - return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 - } - - function fn2 (a, b, c, d, e, m, k, s) { - return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 - } - - function fn3 (a, b, c, d, e, m, k, s) { - return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 - } - - function fn4 (a, b, c, d, e, m, k, s) { - return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 - } - - function fn5 (a, b, c, d, e, m, k, s) { - return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 - } - - module.exports = RIPEMD160 - - },{"buffer":266,"hash-base":82,"inherits":97}],122:[function(require,module,exports){ - /*! safe-buffer. MIT License. Feross Aboukhadijeh */ - /* eslint-disable node/no-deprecated-api */ - var buffer = require('buffer') - var Buffer = buffer.Buffer - - // alternative to using Object.keys for old browsers - function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } - } - if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer - } else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer - } - - function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) - } - - SafeBuffer.prototype = Object.create(Buffer.prototype) - - // Copy static methods from Buffer - copyProps(Buffer, SafeBuffer) - - SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) - } - - SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf - } - - SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) - } - - SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) - } - - },{"buffer":266}],123:[function(require,module,exports){ - (function (process){(function (){ - /* eslint-disable node/no-deprecated-api */ - - 'use strict' - - var buffer = require('buffer') - var Buffer = buffer.Buffer - - var safer = {} - - var key - - for (key in buffer) { - if (!buffer.hasOwnProperty(key)) continue - if (key === 'SlowBuffer' || key === 'Buffer') continue - safer[key] = buffer[key] - } - - var Safer = safer.Buffer = {} - for (key in Buffer) { - if (!Buffer.hasOwnProperty(key)) continue - if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue - Safer[key] = Buffer[key] - } - - safer.Buffer.prototype = Buffer.prototype - - if (!Safer.from || Safer.from === Uint8Array.from) { - Safer.from = function (value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) - } - if (value && typeof value.length === 'undefined') { - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) - } - return Buffer(value, encodingOrOffset, length) - } - } - - if (!Safer.alloc) { - Safer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) - } - if (size < 0 || size >= 2 * (1 << 30)) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } - var buf = Buffer(size) - if (!fill || fill.length === 0) { - buf.fill(0) - } else if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - return buf - } - } - - if (!safer.kStringMaxLength) { - try { - safer.kStringMaxLength = process.binding('buffer').kStringMaxLength - } catch (e) { - // we can't determine kStringMaxLength in environments where process.binding - // is unsupported, so let's not set it - } - } - - if (!safer.constants) { - safer.constants = { - MAX_LENGTH: safer.kMaxLength - } - if (safer.kStringMaxLength) { - safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength - } - } - - module.exports = safer - - }).call(this)}).call(this,require('_process')) - },{"_process":353,"buffer":266}],124:[function(require,module,exports){ - module.exports = require('./lib')(require('./lib/elliptic')) - - },{"./lib":126,"./lib/elliptic":125}],125:[function(require,module,exports){ - const EC = require('elliptic').ec - - const ec = new EC('secp256k1') - const ecparams = ec.curve - - // Hack, we can not use bn.js@5, while elliptic uses bn.js@4 - // See https://github.com/indutny/elliptic/issues/191#issuecomment-569888758 - const BN = ecparams.n.constructor - - function loadCompressedPublicKey (first, xbuf) { - let x = new BN(xbuf) - - // overflow - if (x.cmp(ecparams.p) >= 0) return null - x = x.toRed(ecparams.red) - - // compute corresponding Y - let y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() - if ((first === 0x03) !== y.isOdd()) y = y.redNeg() - - return ec.keyPair({ pub: { x: x, y: y } }) - } - - function loadUncompressedPublicKey (first, xbuf, ybuf) { - let x = new BN(xbuf) - let y = new BN(ybuf) - - // overflow - if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null - - x = x.toRed(ecparams.red) - y = y.toRed(ecparams.red) - - // is odd flag - if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null - - // x*x*x + b = y*y - const x3 = x.redSqr().redIMul(x) - if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null - - return ec.keyPair({ pub: { x: x, y: y } }) - } - - function loadPublicKey (pubkey) { - // length should be validated in interface - const first = pubkey[0] - switch (first) { - case 0x02: - case 0x03: - if (pubkey.length !== 33) return null - return loadCompressedPublicKey(first, pubkey.subarray(1, 33)) - case 0x04: - case 0x06: - case 0x07: - if (pubkey.length !== 65) return null - return loadUncompressedPublicKey(first, pubkey.subarray(1, 33), pubkey.subarray(33, 65)) - default: - return null - } - } - - function savePublicKey (output, point) { - const pubkey = point.encode(null, output.length === 33) - // Loop should be faster because we do not need create extra Uint8Array - // output.set(new Uint8Array(pubkey)) - for (let i = 0; i < output.length; ++i) output[i] = pubkey[i] - } - - module.exports = { - contextRandomize () { - return 0 - }, - - privateKeyVerify (seckey) { - const bn = new BN(seckey) - return bn.cmp(ecparams.n) < 0 && !bn.isZero() ? 0 : 1 - }, - - privateKeyNegate (seckey) { - const bn = new BN(seckey) - const negate = ecparams.n.sub(bn).umod(ecparams.n).toArrayLike(Uint8Array, 'be', 32) - seckey.set(negate) - return 0 - }, - - privateKeyTweakAdd (seckey, tweak) { - const bn = new BN(tweak) - if (bn.cmp(ecparams.n) >= 0) return 1 - - bn.iadd(new BN(seckey)) - if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n) - if (bn.isZero()) return 1 - - const tweaked = bn.toArrayLike(Uint8Array, 'be', 32) - seckey.set(tweaked) - - return 0 - }, - - privateKeyTweakMul (seckey, tweak) { - let bn = new BN(tweak) - if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) return 1 - - bn.imul(new BN(seckey)) - if (bn.cmp(ecparams.n) >= 0) bn = bn.umod(ecparams.n) - - const tweaked = bn.toArrayLike(Uint8Array, 'be', 32) - seckey.set(tweaked) - - return 0 - }, - - publicKeyVerify (pubkey) { - const pair = loadPublicKey(pubkey) - return pair === null ? 1 : 0 - }, - - publicKeyCreate (output, seckey) { - const bn = new BN(seckey) - if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) return 1 - - const point = ec.keyFromPrivate(seckey).getPublic() - savePublicKey(output, point) - - return 0 - }, - - publicKeyConvert (output, pubkey) { - const pair = loadPublicKey(pubkey) - if (pair === null) return 1 - - const point = pair.getPublic() - savePublicKey(output, point) - - return 0 - }, - - publicKeyNegate (output, pubkey) { - const pair = loadPublicKey(pubkey) - if (pair === null) return 1 - - const point = pair.getPublic() - point.y = point.y.redNeg() - savePublicKey(output, point) - - return 0 - }, - - publicKeyCombine (output, pubkeys) { - const pairs = new Array(pubkeys.length) - for (let i = 0; i < pubkeys.length; ++i) { - pairs[i] = loadPublicKey(pubkeys[i]) - if (pairs[i] === null) return 1 - } - - let point = pairs[0].getPublic() - for (let i = 1; i < pairs.length; ++i) point = point.add(pairs[i].pub) - if (point.isInfinity()) return 2 - - savePublicKey(output, point) - - return 0 - }, - - publicKeyTweakAdd (output, pubkey, tweak) { - const pair = loadPublicKey(pubkey) - if (pair === null) return 1 - - tweak = new BN(tweak) - if (tweak.cmp(ecparams.n) >= 0) return 2 - - const point = pair.getPublic().add(ecparams.g.mul(tweak)) - if (point.isInfinity()) return 2 - - savePublicKey(output, point) - - return 0 - }, - - publicKeyTweakMul (output, pubkey, tweak) { - const pair = loadPublicKey(pubkey) - if (pair === null) return 1 - - tweak = new BN(tweak) - if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) return 2 - - const point = pair.getPublic().mul(tweak) - savePublicKey(output, point) - - return 0 - }, - - signatureNormalize (sig) { - const r = new BN(sig.subarray(0, 32)) - const s = new BN(sig.subarray(32, 64)) - if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) return 1 - - if (s.cmp(ec.nh) === 1) { - sig.set(ecparams.n.sub(s).toArrayLike(Uint8Array, 'be', 32), 32) - } - - return 0 - }, - - // Copied 1-to-1 from https://github.com/bitcoinjs/bip66/blob/master/index.js - // Adapted for Uint8Array instead Buffer - signatureExport (obj, sig) { - const sigR = sig.subarray(0, 32) - const sigS = sig.subarray(32, 64) - if (new BN(sigR).cmp(ecparams.n) >= 0) return 1 - if (new BN(sigS).cmp(ecparams.n) >= 0) return 1 - - const { output } = obj - - // Prepare R - let r = output.subarray(4, 4 + 33) - r[0] = 0x00 - r.set(sigR, 1) - - let lenR = 33 - let posR = 0 - for (; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR); - - r = r.subarray(posR) - if (r[0] & 0x80) return 1 - if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) return 1 - - // Prepare S - let s = output.subarray(6 + 33, 6 + 33 + 33) - s[0] = 0x00 - s.set(sigS, 1) - - let lenS = 33 - let posS = 0 - for (; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS); - - s = s.subarray(posS) - if (s[0] & 0x80) return 1 - if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) return 1 - - // Set output length for return - obj.outputlen = 6 + lenR + lenS - - // Output in specified format - // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] - output[0] = 0x30 - output[1] = obj.outputlen - 2 - output[2] = 0x02 - output[3] = r.length - output.set(r, 4) - output[4 + lenR] = 0x02 - output[5 + lenR] = s.length - output.set(s, 6 + lenR) - - return 0 - }, - - // Copied 1-to-1 from https://github.com/bitcoinjs/bip66/blob/master/index.js - // Adapted for Uint8Array instead Buffer - signatureImport (output, sig) { - if (sig.length < 8) return 1 - if (sig.length > 72) return 1 - if (sig[0] !== 0x30) return 1 - if (sig[1] !== sig.length - 2) return 1 - if (sig[2] !== 0x02) return 1 - - const lenR = sig[3] - if (lenR === 0) return 1 - if (5 + lenR >= sig.length) return 1 - if (sig[4 + lenR] !== 0x02) return 1 - - const lenS = sig[5 + lenR] - if (lenS === 0) return 1 - if ((6 + lenR + lenS) !== sig.length) return 1 - - if (sig[4] & 0x80) return 1 - if (lenR > 1 && (sig[4] === 0x00) && !(sig[5] & 0x80)) return 1 - - if (sig[lenR + 6] & 0x80) return 1 - if (lenS > 1 && (sig[lenR + 6] === 0x00) && !(sig[lenR + 7] & 0x80)) return 1 - - let sigR = sig.subarray(4, 4 + lenR) - if (sigR.length === 33 && sigR[0] === 0x00) sigR = sigR.subarray(1) - if (sigR.length > 32) return 1 - - let sigS = sig.subarray(6 + lenR) - if (sigS.length === 33 && sigS[0] === 0x00) sigS = sigS.slice(1) - if (sigS.length > 32) throw new Error('S length is too long') - - let r = new BN(sigR) - if (r.cmp(ecparams.n) >= 0) r = new BN(0) - - let s = new BN(sig.subarray(6 + lenR)) - if (s.cmp(ecparams.n) >= 0) s = new BN(0) - - output.set(r.toArrayLike(Uint8Array, 'be', 32), 0) - output.set(s.toArrayLike(Uint8Array, 'be', 32), 32) - - return 0 - }, - - ecdsaSign (obj, message, seckey, data, noncefn) { - if (noncefn) { - const _noncefn = noncefn - noncefn = (counter) => { - const nonce = _noncefn(message, seckey, null, data, counter) - - const isValid = nonce instanceof Uint8Array && nonce.length === 32 - if (!isValid) throw new Error('This is the way') - - return new BN(nonce) - } - } - - const d = new BN(seckey) - if (d.cmp(ecparams.n) >= 0 || d.isZero()) return 1 - - let sig - try { - sig = ec.sign(message, seckey, { canonical: true, k: noncefn, pers: data }) - } catch (err) { - return 1 - } - - obj.signature.set(sig.r.toArrayLike(Uint8Array, 'be', 32), 0) - obj.signature.set(sig.s.toArrayLike(Uint8Array, 'be', 32), 32) - obj.recid = sig.recoveryParam - - return 0 - }, - - ecdsaVerify (sig, msg32, pubkey) { - const sigObj = { r: sig.subarray(0, 32), s: sig.subarray(32, 64) } - - const sigr = new BN(sigObj.r) - const sigs = new BN(sigObj.s) - if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1 - if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return 3 - - const pair = loadPublicKey(pubkey) - if (pair === null) return 2 - - const point = pair.getPublic() - const isValid = ec.verify(msg32, sigObj, point) - return isValid ? 0 : 3 - }, - - ecdsaRecover (output, sig, recid, msg32) { - const sigObj = { r: sig.slice(0, 32), s: sig.slice(32, 64) } - - const sigr = new BN(sigObj.r) - const sigs = new BN(sigObj.s) - if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1 - - if (sigr.isZero() || sigs.isZero()) return 2 - - // Can throw `throw new Error('Unable to find sencond key candinate');` - let point - try { - point = ec.recoverPubKey(msg32, sigObj, recid) - } catch (err) { - return 2 - } - - savePublicKey(output, point) - - return 0 - }, - - ecdh (output, pubkey, seckey, data, hashfn, xbuf, ybuf) { - const pair = loadPublicKey(pubkey) - if (pair === null) return 1 - - const scalar = new BN(seckey) - if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) return 2 - - const point = pair.getPublic().mul(scalar) - - if (hashfn === undefined) { - const data = point.encode(null, true) - const sha256 = ec.hash().update(data).digest() - for (let i = 0; i < 32; ++i) output[i] = sha256[i] - } else { - if (!xbuf) xbuf = new Uint8Array(32) - const x = point.getX().toArray('be', 32) - for (let i = 0; i < 32; ++i) xbuf[i] = x[i] - - if (!ybuf) ybuf = new Uint8Array(32) - const y = point.getY().toArray('be', 32) - for (let i = 0; i < 32; ++i) ybuf[i] = y[i] - - const hash = hashfn(xbuf, ybuf, data) - - const isValid = hash instanceof Uint8Array && hash.length === output.length - if (!isValid) return 2 - - output.set(hash) - } - - return 0 - } - } - - },{"elliptic":56}],126:[function(require,module,exports){ - const errors = { - IMPOSSIBLE_CASE: 'Impossible case. Please create issue.', - TWEAK_ADD: - 'The tweak was out of range or the resulted private key is invalid', - TWEAK_MUL: 'The tweak was out of range or equal to zero', - CONTEXT_RANDOMIZE_UNKNOW: 'Unknow error on context randomization', - SECKEY_INVALID: 'Private Key is invalid', - PUBKEY_PARSE: 'Public Key could not be parsed', - PUBKEY_SERIALIZE: 'Public Key serialization error', - PUBKEY_COMBINE: 'The sum of the public keys is not valid', - SIG_PARSE: 'Signature could not be parsed', - SIGN: 'The nonce generation function failed, or the private key was invalid', - RECOVER: 'Public key could not be recover', - ECDH: 'Scalar was invalid (zero or overflow)' - } - - function assert (cond, msg) { - if (!cond) throw new Error(msg) - } - - function isUint8Array (name, value, length) { - assert(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`) - - if (length !== undefined) { - if (Array.isArray(length)) { - const numbers = length.join(', ') - const msg = `Expected ${name} to be an Uint8Array with length [${numbers}]` - assert(length.includes(value.length), msg) - } else { - const msg = `Expected ${name} to be an Uint8Array with length ${length}` - assert(value.length === length, msg) - } - } - } - - function isCompressed (value) { - assert(toTypeString(value) === 'Boolean', 'Expected compressed to be a Boolean') - } - - function getAssertedOutput (output = (len) => new Uint8Array(len), length) { - if (typeof output === 'function') output = output(length) - isUint8Array('output', output, length) - return output - } - - function toTypeString (value) { - return Object.prototype.toString.call(value).slice(8, -1) - } - - module.exports = (secp256k1) => { - return { - contextRandomize (seed) { - assert( - seed === null || seed instanceof Uint8Array, - 'Expected seed to be an Uint8Array or null' - ) - if (seed !== null) isUint8Array('seed', seed, 32) - - switch (secp256k1.contextRandomize(seed)) { - case 1: - throw new Error(errors.CONTEXT_RANDOMIZE_UNKNOW) - } - }, - - privateKeyVerify (seckey) { - isUint8Array('private key', seckey, 32) - - return secp256k1.privateKeyVerify(seckey) === 0 - }, - - privateKeyNegate (seckey) { - isUint8Array('private key', seckey, 32) - - switch (secp256k1.privateKeyNegate(seckey)) { - case 0: - return seckey - case 1: - throw new Error(errors.IMPOSSIBLE_CASE) - } - }, - - privateKeyTweakAdd (seckey, tweak) { - isUint8Array('private key', seckey, 32) - isUint8Array('tweak', tweak, 32) - - switch (secp256k1.privateKeyTweakAdd(seckey, tweak)) { - case 0: - return seckey - case 1: - throw new Error(errors.TWEAK_ADD) - } - }, - - privateKeyTweakMul (seckey, tweak) { - isUint8Array('private key', seckey, 32) - isUint8Array('tweak', tweak, 32) - - switch (secp256k1.privateKeyTweakMul(seckey, tweak)) { - case 0: - return seckey - case 1: - throw new Error(errors.TWEAK_MUL) - } - }, - - publicKeyVerify (pubkey) { - isUint8Array('public key', pubkey, [33, 65]) - - return secp256k1.publicKeyVerify(pubkey) === 0 - }, - - publicKeyCreate (seckey, compressed = true, output) { - isUint8Array('private key', seckey, 32) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyCreate(output, seckey)) { - case 0: - return output - case 1: - throw new Error(errors.SECKEY_INVALID) - case 2: - throw new Error(errors.PUBKEY_SERIALIZE) - } - }, - - publicKeyConvert (pubkey, compressed = true, output) { - isUint8Array('public key', pubkey, [33, 65]) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyConvert(output, pubkey)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.PUBKEY_SERIALIZE) - } - }, - - publicKeyNegate (pubkey, compressed = true, output) { - isUint8Array('public key', pubkey, [33, 65]) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyNegate(output, pubkey)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.IMPOSSIBLE_CASE) - case 3: - throw new Error(errors.PUBKEY_SERIALIZE) - } - }, - - publicKeyCombine (pubkeys, compressed = true, output) { - assert(Array.isArray(pubkeys), 'Expected public keys to be an Array') - assert(pubkeys.length > 0, 'Expected public keys array will have more than zero items') - for (const pubkey of pubkeys) { - isUint8Array('public key', pubkey, [33, 65]) - } - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyCombine(output, pubkeys)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.PUBKEY_COMBINE) - case 3: - throw new Error(errors.PUBKEY_SERIALIZE) - } - }, - - publicKeyTweakAdd (pubkey, tweak, compressed = true, output) { - isUint8Array('public key', pubkey, [33, 65]) - isUint8Array('tweak', tweak, 32) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyTweakAdd(output, pubkey, tweak)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.TWEAK_ADD) - } - }, - - publicKeyTweakMul (pubkey, tweak, compressed = true, output) { - isUint8Array('public key', pubkey, [33, 65]) - isUint8Array('tweak', tweak, 32) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.publicKeyTweakMul(output, pubkey, tweak)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.TWEAK_MUL) - } - }, - - signatureNormalize (sig) { - isUint8Array('signature', sig, 64) - - switch (secp256k1.signatureNormalize(sig)) { - case 0: - return sig - case 1: - throw new Error(errors.SIG_PARSE) - } - }, - - signatureExport (sig, output) { - isUint8Array('signature', sig, 64) - output = getAssertedOutput(output, 72) - - const obj = { output, outputlen: 72 } - switch (secp256k1.signatureExport(obj, sig)) { - case 0: - return output.slice(0, obj.outputlen) - case 1: - throw new Error(errors.SIG_PARSE) - case 2: - throw new Error(errors.IMPOSSIBLE_CASE) - } - }, - - signatureImport (sig, output) { - isUint8Array('signature', sig) - output = getAssertedOutput(output, 64) - - switch (secp256k1.signatureImport(output, sig)) { - case 0: - return output - case 1: - throw new Error(errors.SIG_PARSE) - case 2: - throw new Error(errors.IMPOSSIBLE_CASE) - } - }, - - ecdsaSign (msg32, seckey, options = {}, output) { - isUint8Array('message', msg32, 32) - isUint8Array('private key', seckey, 32) - assert(toTypeString(options) === 'Object', 'Expected options to be an Object') - if (options.data !== undefined) isUint8Array('options.data', options.data) - if (options.noncefn !== undefined) assert(toTypeString(options.noncefn) === 'Function', 'Expected options.noncefn to be a Function') - output = getAssertedOutput(output, 64) - - const obj = { signature: output, recid: null } - switch (secp256k1.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) { - case 0: - return obj - case 1: - throw new Error(errors.SIGN) - case 2: - throw new Error(errors.IMPOSSIBLE_CASE) - } - }, - - ecdsaVerify (sig, msg32, pubkey) { - isUint8Array('signature', sig, 64) - isUint8Array('message', msg32, 32) - isUint8Array('public key', pubkey, [33, 65]) - - switch (secp256k1.ecdsaVerify(sig, msg32, pubkey)) { - case 0: - return true - case 3: - return false - case 1: - throw new Error(errors.SIG_PARSE) - case 2: - throw new Error(errors.PUBKEY_PARSE) - } - }, - - ecdsaRecover (sig, recid, msg32, compressed = true, output) { - isUint8Array('signature', sig, 64) - assert( - toTypeString(recid) === 'Number' && - recid >= 0 && - recid <= 3, - 'Expected recovery id to be a Number within interval [0, 3]' - ) - isUint8Array('message', msg32, 32) - isCompressed(compressed) - output = getAssertedOutput(output, compressed ? 33 : 65) - - switch (secp256k1.ecdsaRecover(output, sig, recid, msg32)) { - case 0: - return output - case 1: - throw new Error(errors.SIG_PARSE) - case 2: - throw new Error(errors.RECOVER) - case 3: - throw new Error(errors.IMPOSSIBLE_CASE) - } - }, - - ecdh (pubkey, seckey, options = {}, output) { - isUint8Array('public key', pubkey, [33, 65]) - isUint8Array('private key', seckey, 32) - assert(toTypeString(options) === 'Object', 'Expected options to be an Object') - if (options.data !== undefined) isUint8Array('options.data', options.data) - if (options.hashfn !== undefined) { - assert(toTypeString(options.hashfn) === 'Function', 'Expected options.hashfn to be a Function') - if (options.xbuf !== undefined) isUint8Array('options.xbuf', options.xbuf, 32) - if (options.ybuf !== undefined) isUint8Array('options.ybuf', options.ybuf, 32) - isUint8Array('output', output) - } else { - output = getAssertedOutput(output, 32) - } - - switch (secp256k1.ecdh(output, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) { - case 0: - return output - case 1: - throw new Error(errors.PUBKEY_PARSE) - case 2: - throw new Error(errors.ECDH) - } - } - } - } - - },{}],127:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - - // prototype class for hash functions - function Hash (blockSize, finalSize) { - this._block = Buffer.alloc(blockSize) - this._finalSize = finalSize - this._blockSize = blockSize - this._len = 0 - } - - Hash.prototype.update = function (data, enc) { - if (typeof data === 'string') { - enc = enc || 'utf8' - data = Buffer.from(data, enc) - } - - var block = this._block - var blockSize = this._blockSize - var length = data.length - var accum = this._len - - for (var offset = 0; offset < length;) { - var assigned = accum % blockSize - var remainder = Math.min(length - offset, blockSize - assigned) - - for (var i = 0; i < remainder; i++) { - block[assigned + i] = data[offset + i] - } - - accum += remainder - offset += remainder - - if ((accum % blockSize) === 0) { - this._update(block) - } - } - - this._len += length - return this - } - - Hash.prototype.digest = function (enc) { - var rem = this._len % this._blockSize - - this._block[rem] = 0x80 - - // zero (rem + 1) trailing bits, where (rem + 1) is the smallest - // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize - this._block.fill(0, rem + 1) - - if (rem >= this._finalSize) { - this._update(this._block) - this._block.fill(0) - } - - var bits = this._len * 8 - - // uint32 - if (bits <= 0xffffffff) { - this._block.writeUInt32BE(bits, this._blockSize - 4) - - // uint64 - } else { - var lowBits = (bits & 0xffffffff) >>> 0 - var highBits = (bits - lowBits) / 0x100000000 - - this._block.writeUInt32BE(highBits, this._blockSize - 8) - this._block.writeUInt32BE(lowBits, this._blockSize - 4) - } - - this._update(this._block) - var hash = this._hash() - - return enc ? hash.toString(enc) : hash - } - - Hash.prototype._update = function () { - throw new Error('_update must be implemented by subclass') - } - - module.exports = Hash - - },{"safe-buffer":122}],128:[function(require,module,exports){ - var exports = module.exports = function SHA (algorithm) { - algorithm = algorithm.toLowerCase() - - var Algorithm = exports[algorithm] - if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') - - return new Algorithm() - } - - exports.sha = require('./sha') - exports.sha1 = require('./sha1') - exports.sha224 = require('./sha224') - exports.sha256 = require('./sha256') - exports.sha384 = require('./sha384') - exports.sha512 = require('./sha512') - - },{"./sha":129,"./sha1":130,"./sha224":131,"./sha256":132,"./sha384":133,"./sha512":134}],129:[function(require,module,exports){ - /* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined - * in FIPS PUB 180-1 - * This source code is derived from sha1.js of the same repository. - * The difference between SHA-0 and SHA-1 is just a bitwise rotate left - * operation was added. - */ - - var inherits = require('inherits') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 - ] - - var W = new Array(80) - - function Sha () { - this.init() - this._w = W - - Hash.call(this, 64, 56) - } - - inherits(Sha, Hash) - - Sha.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this - } - - function rotl5 (num) { - return (num << 5) | (num >>> 27) - } - - function rotl30 (num) { - return (num << 30) | (num >>> 2) - } - - function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d - } - - Sha.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - } - - Sha.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H - } - - module.exports = Sha - - },{"./hash":127,"inherits":97,"safe-buffer":122}],130:[function(require,module,exports){ - /* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined - * in FIPS PUB 180-1 - * Version 2.1a Copyright Paul Johnston 2000 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for details. - */ - - var inherits = require('inherits') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 - ] - - var W = new Array(80) - - function Sha1 () { - this.init() - this._w = W - - Hash.call(this, 64, 56) - } - - inherits(Sha1, Hash) - - Sha1.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this - } - - function rotl1 (num) { - return (num << 1) | (num >>> 31) - } - - function rotl5 (num) { - return (num << 5) | (num >>> 27) - } - - function rotl30 (num) { - return (num << 30) | (num >>> 2) - } - - function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d - } - - Sha1.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - } - - Sha1.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H - } - - module.exports = Sha1 - - },{"./hash":127,"inherits":97,"safe-buffer":122}],131:[function(require,module,exports){ - /** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - - var inherits = require('inherits') - var Sha256 = require('./sha256') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var W = new Array(64) - - function Sha224 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) - } - - inherits(Sha224, Sha256) - - Sha224.prototype.init = function () { - this._a = 0xc1059ed8 - this._b = 0x367cd507 - this._c = 0x3070dd17 - this._d = 0xf70e5939 - this._e = 0xffc00b31 - this._f = 0x68581511 - this._g = 0x64f98fa7 - this._h = 0xbefa4fa4 - - return this - } - - Sha224.prototype._hash = function () { - var H = Buffer.allocUnsafe(28) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - - return H - } - - module.exports = Sha224 - - },{"./hash":127,"./sha256":132,"inherits":97,"safe-buffer":122}],132:[function(require,module,exports){ - /** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - - var inherits = require('inherits') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var K = [ - 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, - 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, - 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, - 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, - 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, - 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, - 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, - 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, - 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, - 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, - 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, - 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, - 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, - 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, - 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, - 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 - ] - - var W = new Array(64) - - function Sha256 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) - } - - inherits(Sha256, Hash) - - Sha256.prototype.init = function () { - this._a = 0x6a09e667 - this._b = 0xbb67ae85 - this._c = 0x3c6ef372 - this._d = 0xa54ff53a - this._e = 0x510e527f - this._f = 0x9b05688c - this._g = 0x1f83d9ab - this._h = 0x5be0cd19 - - return this - } - - function ch (x, y, z) { - return z ^ (x & (y ^ z)) - } - - function maj (x, y, z) { - return (x & y) | (z & (x | y)) - } - - function sigma0 (x) { - return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) - } - - function sigma1 (x) { - return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) - } - - function gamma0 (x) { - return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) - } - - function gamma1 (x) { - return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) - } - - Sha256.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - var f = this._f | 0 - var g = this._g | 0 - var h = this._h | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 - - for (var j = 0; j < 64; ++j) { - var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 - var T2 = (sigma0(a) + maj(a, b, c)) | 0 - - h = g - g = f - f = e - e = (d + T1) | 0 - d = c - c = b - b = a - a = (T1 + T2) | 0 - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - this._f = (f + this._f) | 0 - this._g = (g + this._g) | 0 - this._h = (h + this._h) | 0 - } - - Sha256.prototype._hash = function () { - var H = Buffer.allocUnsafe(32) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - H.writeInt32BE(this._h, 28) - - return H - } - - module.exports = Sha256 - - },{"./hash":127,"inherits":97,"safe-buffer":122}],133:[function(require,module,exports){ - var inherits = require('inherits') - var SHA512 = require('./sha512') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var W = new Array(160) - - function Sha384 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) - } - - inherits(Sha384, SHA512) - - Sha384.prototype.init = function () { - this._ah = 0xcbbb9d5d - this._bh = 0x629a292a - this._ch = 0x9159015a - this._dh = 0x152fecd8 - this._eh = 0x67332667 - this._fh = 0x8eb44a87 - this._gh = 0xdb0c2e0d - this._hh = 0x47b5481d - - this._al = 0xc1059ed8 - this._bl = 0x367cd507 - this._cl = 0x3070dd17 - this._dl = 0xf70e5939 - this._el = 0xffc00b31 - this._fl = 0x68581511 - this._gl = 0x64f98fa7 - this._hl = 0xbefa4fa4 - - return this - } - - Sha384.prototype._hash = function () { - var H = Buffer.allocUnsafe(48) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - - return H - } - - module.exports = Sha384 - - },{"./hash":127,"./sha512":134,"inherits":97,"safe-buffer":122}],134:[function(require,module,exports){ - var inherits = require('inherits') - var Hash = require('./hash') - var Buffer = require('safe-buffer').Buffer - - var K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 - ] - - var W = new Array(160) - - function Sha512 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) - } - - inherits(Sha512, Hash) - - Sha512.prototype.init = function () { - this._ah = 0x6a09e667 - this._bh = 0xbb67ae85 - this._ch = 0x3c6ef372 - this._dh = 0xa54ff53a - this._eh = 0x510e527f - this._fh = 0x9b05688c - this._gh = 0x1f83d9ab - this._hh = 0x5be0cd19 - - this._al = 0xf3bcc908 - this._bl = 0x84caa73b - this._cl = 0xfe94f82b - this._dl = 0x5f1d36f1 - this._el = 0xade682d1 - this._fl = 0x2b3e6c1f - this._gl = 0xfb41bd6b - this._hl = 0x137e2179 - - return this - } - - function Ch (x, y, z) { - return z ^ (x & (y ^ z)) - } - - function maj (x, y, z) { - return (x & y) | (z & (x | y)) - } - - function sigma0 (x, xl) { - return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) - } - - function sigma1 (x, xl) { - return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) - } - - function Gamma0 (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) - } - - function Gamma0l (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) - } - - function Gamma1 (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) - } - - function Gamma1l (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) - } - - function getCarry (a, b) { - return (a >>> 0) < (b >>> 0) ? 1 : 0 - } - - Sha512.prototype._update = function (M) { - var W = this._w - - var ah = this._ah | 0 - var bh = this._bh | 0 - var ch = this._ch | 0 - var dh = this._dh | 0 - var eh = this._eh | 0 - var fh = this._fh | 0 - var gh = this._gh | 0 - var hh = this._hh | 0 - - var al = this._al | 0 - var bl = this._bl | 0 - var cl = this._cl | 0 - var dl = this._dl | 0 - var el = this._el | 0 - var fl = this._fl | 0 - var gl = this._gl | 0 - var hl = this._hl | 0 - - for (var i = 0; i < 32; i += 2) { - W[i] = M.readInt32BE(i * 4) - W[i + 1] = M.readInt32BE(i * 4 + 4) - } - for (; i < 160; i += 2) { - var xh = W[i - 15 * 2] - var xl = W[i - 15 * 2 + 1] - var gamma0 = Gamma0(xh, xl) - var gamma0l = Gamma0l(xl, xh) - - xh = W[i - 2 * 2] - xl = W[i - 2 * 2 + 1] - var gamma1 = Gamma1(xh, xl) - var gamma1l = Gamma1l(xl, xh) - - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7h = W[i - 7 * 2] - var Wi7l = W[i - 7 * 2 + 1] - - var Wi16h = W[i - 16 * 2] - var Wi16l = W[i - 16 * 2 + 1] - - var Wil = (gamma0l + Wi7l) | 0 - var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 - Wil = (Wil + gamma1l) | 0 - Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 - Wil = (Wil + Wi16l) | 0 - Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 - - W[i] = Wih - W[i + 1] = Wil - } - - for (var j = 0; j < 160; j += 2) { - Wih = W[j] - Wil = W[j + 1] - - var majh = maj(ah, bh, ch) - var majl = maj(al, bl, cl) - - var sigma0h = sigma0(ah, al) - var sigma0l = sigma0(al, ah) - var sigma1h = sigma1(eh, el) - var sigma1l = sigma1(el, eh) - - // t1 = h + sigma1 + ch + K[j] + W[j] - var Kih = K[j] - var Kil = K[j + 1] - - var chh = Ch(eh, fh, gh) - var chl = Ch(el, fl, gl) - - var t1l = (hl + sigma1l) | 0 - var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 - t1l = (t1l + chl) | 0 - t1h = (t1h + chh + getCarry(t1l, chl)) | 0 - t1l = (t1l + Kil) | 0 - t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 - t1l = (t1l + Wil) | 0 - t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 - - // t2 = sigma0 + maj - var t2l = (sigma0l + majl) | 0 - var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 - - hh = gh - hl = gl - gh = fh - gl = fl - fh = eh - fl = el - el = (dl + t1l) | 0 - eh = (dh + t1h + getCarry(el, dl)) | 0 - dh = ch - dl = cl - ch = bh - cl = bl - bh = ah - bl = al - al = (t1l + t2l) | 0 - ah = (t1h + t2h + getCarry(al, t1l)) | 0 - } - - this._al = (this._al + al) | 0 - this._bl = (this._bl + bl) | 0 - this._cl = (this._cl + cl) | 0 - this._dl = (this._dl + dl) | 0 - this._el = (this._el + el) | 0 - this._fl = (this._fl + fl) | 0 - this._gl = (this._gl + gl) | 0 - this._hl = (this._hl + hl) | 0 - - this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 - this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 - this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 - this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 - this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 - this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 - this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 - this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 - } - - Sha512.prototype._hash = function () { - var H = Buffer.allocUnsafe(64) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - writeInt64BE(this._gh, this._gl, 48) - writeInt64BE(this._hh, this._hl, 56) - - return H - } - - module.exports = Sha512 - - },{"./hash":127,"inherits":97,"safe-buffer":122}],135:[function(require,module,exports){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - 'use strict'; - - /**/ - - var Buffer = require('safe-buffer').Buffer; - /**/ - - var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } - }; - - function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } - }; - - // Do not cache `Buffer.isEncoding` when checking encoding names as some - // modules monkey-patch it to support additional encodings - function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; - } - - // StringDecoder provides an interface for efficiently splitting a series of - // buffers into a series of JS strings without breaking apart multi-byte - // characters. - exports.StringDecoder = StringDecoder; - function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); - } - - StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; - }; - - StringDecoder.prototype.end = utf8End; - - // Returns only complete characters in a Buffer - StringDecoder.prototype.text = utf8Text; - - // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer - StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; - }; - - // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a - // continuation byte. If an invalid byte is detected, -2 is returned. - function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; - } - - // Checks at most 3 bytes at the end of a Buffer in order to detect an - // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) - // needed to complete the UTF-8 character (if applicable) are returned. - function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; - } - - // Validates as many continuation bytes for a multi-byte UTF-8 character as - // needed or are available. If we see a non-continuation byte where we expect - // one, we "replace" the validated continuation bytes we've seen so far with - // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding - // behavior. The continuation byte check is included three times in the case - // where all of the continuation bytes for a character exist in the same buffer. - // It is also done this way as a slight performance increase instead of using a - // loop. - function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } - } - - // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. - function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; - } - - // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a - // partial character, the character's bytes are buffered until the required - // number of bytes are available. - function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); - } - - // For UTF-8, a replacement character is added when ending on a partial - // character. - function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; - } - - // UTF-16LE typically needs two bytes per character, but even if we have an even - // number of bytes available, we need to check if we end on a leading/high - // surrogate. In that case, we need to wait for the next two bytes in order to - // decode the last character properly. - function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); - } - - // For UTF-16LE we do not explicitly append special replacement characters if we - // end on a partial character, we simply let v8 handle that. - function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; - } - - function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); - } - - function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; - } - - // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) - function simpleWrite(buf) { - return buf.toString(this.encoding); - } - - function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; - } - },{"safe-buffer":122}],136:[function(require,module,exports){ - (function (factory) { - if (typeof module === "object" && typeof module.exports === "object") { - var v = factory(require, exports); - if (v !== undefined) module.exports = v; - } - else if (typeof define === "function" && define.amd) { - define(["require", "exports", "tslib", "./result", "./option"], factory); - } - })(function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = require("tslib"); - tslib_1.__exportStar(require("./result"), exports); - tslib_1.__exportStar(require("./option"), exports); - }); - - },{"./option":137,"./result":138,"tslib":140}],137:[function(require,module,exports){ - (function (factory) { - if (typeof module === "object" && typeof module.exports === "object") { - var v = factory(require, exports); - if (v !== undefined) module.exports = v; - } - else if (typeof define === "function" && define.amd) { - define(["require", "exports", "./utils"], factory); - } - })(function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Option = exports.Some = exports.None = void 0; - var utils_1 = require("./utils"); - /** - * Contains the None value - */ - var NoneImpl = /** @class */ (function () { - function NoneImpl() { - this.some = false; - this.none = true; - } - NoneImpl.prototype[Symbol.iterator] = function () { - return { - next: function () { - return { done: true, value: undefined }; - }, - }; - }; - NoneImpl.prototype.unwrapOr = function (val) { - return val; - }; - NoneImpl.prototype.expect = function (msg) { - throw new Error("" + msg); - }; - NoneImpl.prototype.unwrap = function () { - throw new Error("Tried to unwrap None"); - }; - NoneImpl.prototype.map = function (_mapper) { - return this; - }; - NoneImpl.prototype.andThen = function (op) { - return this; - }; - NoneImpl.prototype.toString = function () { - return 'None'; - }; - return NoneImpl; - }()); - // Export None as a singleton, then freeze it so it can't be modified - exports.None = new NoneImpl(); - Object.freeze(exports.None); - /** - * Contains the success value - */ - var SomeImpl = /** @class */ (function () { - function SomeImpl(val) { - if (!(this instanceof SomeImpl)) { - return new SomeImpl(val); - } - this.some = true; - this.none = false; - this.val = val; - } - /** - * Helper function if you know you have an Some and T is iterable - */ - SomeImpl.prototype[Symbol.iterator] = function () { - var obj = Object(this.val); - return Symbol.iterator in obj - ? obj[Symbol.iterator]() - : { - next: function () { - return { done: true, value: undefined }; - }, - }; - }; - SomeImpl.prototype.unwrapOr = function (_val) { - return this.val; - }; - SomeImpl.prototype.expect = function (_msg) { - return this.val; - }; - SomeImpl.prototype.unwrap = function () { - return this.val; - }; - SomeImpl.prototype.map = function (mapper) { - return exports.Some(mapper(this.val)); - }; - SomeImpl.prototype.andThen = function (mapper) { - return mapper(this.val); - }; - /** - * Returns the contained `Some` value, but never throws. - * Unlike `unwrap()`, this method doesn't throw and is only callable on an Some - * - * Therefore, it can be used instead of `unwrap()` as a maintainability safeguard - * that will fail to compile if the type of the Option is later changed to a None that can actually occur. - * - * (this is the `into_Some()` in rust) - */ - SomeImpl.prototype.safeUnwrap = function () { - return this.val; - }; - SomeImpl.prototype.toString = function () { - return "Some(" + utils_1.toString(this.val) + ")"; - }; - SomeImpl.EMPTY = new SomeImpl(undefined); - return SomeImpl; - }()); - // This allows Some to be callable - possible because of the es5 compilation target - exports.Some = SomeImpl; - var Option; - (function (Option) { - /** - * Parse a set of `Option`s, returning an array of all `Some` values. - * Short circuits with the first `None` found, if any - */ - function all() { - var options = []; - for (var _i = 0; _i < arguments.length; _i++) { - options[_i] = arguments[_i]; - } - var someOption = []; - for (var _a = 0, options_1 = options; _a < options_1.length; _a++) { - var option = options_1[_a]; - if (option.some) { - someOption.push(option.val); - } - else { - return option; - } - } - return exports.Some(someOption); - } - Option.all = all; - /** - * Parse a set of `Option`s, short-circuits when an input value is `Some`. - * If no `Some` is found, returns `None`. - */ - function any() { - var options = []; - for (var _i = 0; _i < arguments.length; _i++) { - options[_i] = arguments[_i]; - } - // short-circuits - for (var _a = 0, options_2 = options; _a < options_2.length; _a++) { - var option = options_2[_a]; - if (option.some) { - return option; - } - else { - return option; - } - } - // it must be None - return exports.None; - } - Option.any = any; - function isOption(value) { - return value instanceof exports.Some || value === exports.None; - } - Option.isOption = isOption; - })(Option = exports.Option || (exports.Option = {})); - }); - - },{"./utils":139}],138:[function(require,module,exports){ - (function (factory) { - if (typeof module === "object" && typeof module.exports === "object") { - var v = factory(require, exports); - if (v !== undefined) module.exports = v; - } - else if (typeof define === "function" && define.amd) { - define(["require", "exports", "./utils"], factory); - } - })(function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Result = exports.Ok = exports.OkImpl = exports.Err = exports.ErrImpl = void 0; - var utils_1 = require("./utils"); - /** - * Contains the error value - */ - var ErrImpl = /** @class */ (function () { - function ErrImpl(val) { - if (!(this instanceof ErrImpl)) { - return new ErrImpl(val); - } - this.ok = false; - this.err = true; - this.val = val; - } - ErrImpl.prototype[Symbol.iterator] = function () { - return { - next: function () { - return { done: true, value: undefined }; - }, - }; - }; - /** - * @deprecated in favor of unwrapOr - * @see unwrapOr - */ - ErrImpl.prototype.else = function (val) { - return val; - }; - ErrImpl.prototype.unwrapOr = function (val) { - return val; - }; - ErrImpl.prototype.expect = function (msg) { - throw new Error(msg + " - Error: " + utils_1.toString(this.val)); - }; - ErrImpl.prototype.unwrap = function () { - throw new Error("Tried to unwrap Error: " + utils_1.toString(this.val)); - }; - ErrImpl.prototype.map = function (_mapper) { - return this; - }; - ErrImpl.prototype.andThen = function (op) { - return this; - }; - ErrImpl.prototype.mapErr = function (mapper) { - return new exports.Err(mapper(this.val)); - }; - ErrImpl.prototype.toString = function () { - return "Err(" + utils_1.toString(this.val) + ")"; - }; - /** An empty Err */ - ErrImpl.EMPTY = new ErrImpl(undefined); - return ErrImpl; - }()); - exports.ErrImpl = ErrImpl; - // This allows Err to be callable - possible because of the es5 compilation target - exports.Err = ErrImpl; - /** - * Contains the success value - */ - var OkImpl = /** @class */ (function () { - function OkImpl(val) { - if (!(this instanceof OkImpl)) { - return new OkImpl(val); - } - this.ok = true; - this.err = false; - this.val = val; - } - /** - * Helper function if you know you have an Ok and T is iterable - */ - OkImpl.prototype[Symbol.iterator] = function () { - var obj = Object(this.val); - return Symbol.iterator in obj - ? obj[Symbol.iterator]() - : { - next: function () { - return { done: true, value: undefined }; - }, - }; - }; - /** - * @see unwrapOr - * @deprecated in favor of unwrapOr - */ - OkImpl.prototype.else = function (_val) { - return this.val; - }; - OkImpl.prototype.unwrapOr = function (_val) { - return this.val; - }; - OkImpl.prototype.expect = function (_msg) { - return this.val; - }; - OkImpl.prototype.unwrap = function () { - return this.val; - }; - OkImpl.prototype.map = function (mapper) { - return new exports.Ok(mapper(this.val)); - }; - OkImpl.prototype.andThen = function (mapper) { - return mapper(this.val); - }; - OkImpl.prototype.mapErr = function (_mapper) { - return this; - }; - /** - * Returns the contained `Ok` value, but never throws. - * Unlike `unwrap()`, this method doesn't throw and is only callable on an Ok - * - * Therefore, it can be used instead of `unwrap()` as a maintainability safeguard - * that will fail to compile if the error type of the Result is later changed to an error that can actually occur. - * - * (this is the `into_ok()` in rust) - */ - OkImpl.prototype.safeUnwrap = function () { - return this.val; - }; - OkImpl.prototype.toString = function () { - return "Ok(" + utils_1.toString(this.val) + ")"; - }; - OkImpl.EMPTY = new OkImpl(undefined); - return OkImpl; - }()); - exports.OkImpl = OkImpl; - // This allows Ok to be callable - possible because of the es5 compilation target - exports.Ok = OkImpl; - var Result; - (function (Result) { - /** - * Parse a set of `Result`s, returning an array of all `Ok` values. - * Short circuits with the first `Err` found, if any - */ - function all() { - var results = []; - for (var _i = 0; _i < arguments.length; _i++) { - results[_i] = arguments[_i]; - } - var okResult = []; - for (var _a = 0, results_1 = results; _a < results_1.length; _a++) { - var result = results_1[_a]; - if (result.ok) { - okResult.push(result.val); - } - else { - return result; - } - } - return new exports.Ok(okResult); - } - Result.all = all; - /** - * Parse a set of `Result`s, short-circuits when an input value is `Ok`. - * If no `Ok` is found, returns an `Err` containing the collected error values - */ - function any() { - var results = []; - for (var _i = 0; _i < arguments.length; _i++) { - results[_i] = arguments[_i]; - } - var errResult = []; - // short-circuits - for (var _a = 0, results_2 = results; _a < results_2.length; _a++) { - var result = results_2[_a]; - if (result.ok) { - return result; - } - else { - errResult.push(result.val); - } - } - // it must be a Err - return new exports.Err(errResult); - } - Result.any = any; - /** - * Wrap an operation that may throw an Error (`try-catch` style) into checked exception style - * @param op The operation function - */ - function wrap(op) { - try { - return new exports.Ok(op()); - } - catch (e) { - return new exports.Err(e); - } - } - Result.wrap = wrap; - /** - * Wrap an async operation that may throw an Error (`try-catch` style) into checked exception style - * @param op The operation function - */ - function wrapAsync(op) { - try { - return op() - .then(function (val) { return new exports.Ok(val); }) - .catch(function (e) { return new exports.Err(e); }); - } - catch (e) { - return Promise.resolve(new exports.Err(e)); - } - } - Result.wrapAsync = wrapAsync; - function isResult(val) { - return val instanceof exports.Err || val instanceof exports.Ok; - } - Result.isResult = isResult; - })(Result = exports.Result || (exports.Result = {})); - }); - - },{"./utils":139}],139:[function(require,module,exports){ - (function (factory) { - if (typeof module === "object" && typeof module.exports === "object") { - var v = factory(require, exports); - if (v !== undefined) module.exports = v; - } - else if (typeof define === "function" && define.amd) { - define(["require", "exports"], factory); - } - })(function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.toString = void 0; - function toString(val) { - var value = String(val); - if (value === '[object Object]') { - try { - value = JSON.stringify(val); - } - catch (_a) { } - } - return value; - } - exports.toString = toString; - }); - - },{}],140:[function(require,module,exports){ - (function (global){(function (){ - /*! ***************************************************************************** - 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. - ***************************************************************************** */ - - /* global global, define, System, Reflect, Promise */ - var __extends; - var __assign; - var __rest; - var __decorate; - var __param; - var __metadata; - var __awaiter; - var __generator; - var __exportStar; - var __values; - var __read; - var __spread; - var __spreadArrays; - var __await; - var __asyncGenerator; - var __asyncDelegator; - var __asyncValues; - var __makeTemplateObject; - var __importStar; - var __importDefault; - var __classPrivateFieldGet; - var __classPrivateFieldSet; - var __createBinding; - (function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if (typeof module === "object" && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } - }) - (function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - - __extends = function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __awaiter = function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - - __generator = function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - - __createBinding = function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - }; - - __exportStar = function (m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; - }; - - __values = function (o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); - }; - - __read = function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; - }; - - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - __spreadArrays = function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - __importStar = function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - __classPrivateFieldGet = function (receiver, privateMap) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to get private field on non-instance"); - } - return privateMap.get(receiver); - }; - - __classPrivateFieldSet = function (receiver, privateMap, value) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to set private field on non-instance"); - } - privateMap.set(receiver, value); - return value; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__createBinding", __createBinding); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__spreadArrays", __spreadArrays); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); - exporter("__classPrivateFieldGet", __classPrivateFieldGet); - exporter("__classPrivateFieldSet", __classPrivateFieldSet); - }); - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{}],141:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function ByteArray(n) { - return new Uint8Array(n); - } - exports.ByteArray = ByteArray; - function HalfArray(n) { - return new Uint16Array(n); - } - exports.HalfArray = HalfArray; - function WordArray(n) { - return new Uint32Array(n); - } - exports.WordArray = WordArray; - function IntArray(n) { - return new Int32Array(n); - } - exports.IntArray = IntArray; - function NumArray(n) { - return new Float64Array(n); - } - exports.NumArray = NumArray; - - },{}],142:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var hash_1 = require("./hash"); - function auth(msg, key) { - var out = array_1.ByteArray(32); - out.set(hmac(msg, key).subarray(0, 32)); - return out; - } - exports.auth = auth; - var BLOCK_SIZE = 128; - var HASH_SIZE = 64; - function hmac(msg, key) { - var buf = array_1.ByteArray(BLOCK_SIZE + Math.max(HASH_SIZE, msg.length)); - var i, innerHash; - if (key.length > BLOCK_SIZE) - key = hash_1.hash(key); - for (i = 0; i < BLOCK_SIZE; i++) - buf[i] = 0x36; - for (i = 0; i < key.length; i++) - buf[i] ^= key[i]; - buf.set(msg, BLOCK_SIZE); - innerHash = hash_1.hash(buf.subarray(0, BLOCK_SIZE + msg.length)); - for (i = 0; i < BLOCK_SIZE; i++) - buf[i] = 0x5c; - for (i = 0; i < key.length; i++) - buf[i] ^= key[i]; - buf.set(innerHash, BLOCK_SIZE); - return hash_1.hash(buf.subarray(0, BLOCK_SIZE + innerHash.length)); - } - exports.auth_full = hmac; - - },{"./array":141,"./hash":152}],143:[function(require,module,exports){ - "use strict"; - // Blake2B in pure Javascript - // Adapted from the reference implementation in RFC7693 - // Ported to Javascript by DC - https://github.com/dcposch - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - // Computes the BLAKE2B hash of a string or byte array, and returns a ByteArray - // - // Returns a n-byte ByteArray - // - // Parameters: - // - input - the input bytes, as a ByteArray - // - key - optional key ByteArray, up to 64 bytes - // - outlen - optional output length in bytes, default 64 - function blake2b(input, key, outlen) { - if (outlen === void 0) { outlen = 64; } - var ctx = blake2b_init(outlen, key); - blake2b_update(ctx, input); - return blake2b_final(ctx); - } - exports.blake2b = blake2b; - // Creates a BLAKE2b hashing context - // Requires an output length between 1 and 64 bytes - // Takes an optional ByteArray key - function blake2b_init(outlen, key) { - if (outlen === 0 || outlen > 64) - throw new Error('Illegal output length, expected 0 < length <= 64'); - if (key && key.length > 64) - throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64'); - // hash state - var h = array_1.WordArray(16); - // initialize hash state - for (var i = 0; i < 16; i++) - h[i] = BLAKE2B_IV32[i]; - var keylen = key ? key.length : 0; - h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; - // state, 'param block' - var ctx = { - b: array_1.ByteArray(128), - h: h, - t: 0, - c: 0, - outlen: outlen // output length in bytes - }; - // key the hash, if applicable - if (key) { - blake2b_update(ctx, key); - // at the end - ctx.c = 128; - } - return ctx; - } - exports.blake2b_init = blake2b_init; - // Updates a BLAKE2b streaming hash - // Requires hash context and Uint8Array (byte array) - function blake2b_update(ctx, input) { - for (var i = 0; i < input.length; i++) { - if (ctx.c === 128) { // buffer full ? - ctx.t += ctx.c; // add counters - blake2b_compress(ctx, false); // compress (not last) - ctx.c = 0; // counter to zero - } - ctx.b[ctx.c++] = input[i]; - } - } - exports.blake2b_update = blake2b_update; - // Completes a BLAKE2b streaming hash - // Returns a Uint8Array containing the message digest - function blake2b_final(ctx) { - ctx.t += ctx.c; // mark last block offset - while (ctx.c < 128) { // fill up with zeros - ctx.b[ctx.c++] = 0; - } - blake2b_compress(ctx, true); // final block flag = 1 - // little endian convert and store - var out = array_1.ByteArray(ctx.outlen); - for (var i = 0; i < ctx.outlen; i++) { - out[i] = ctx.h[i >> 2] >> (8 * (i & 3)); - } - return out; - } - exports.blake2b_final = blake2b_final; - // Initialization Vector - var BLAKE2B_IV32 = array_1.WordArray([ - 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, - 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, - 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, - 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 - ]); - var SIGMA8 = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, - 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, - 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, - 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, - 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, - 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, - 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, - 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, - 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 - ]; - // These are offsets into a uint64 buffer. - // Multiply them all by 2 to make them offsets into a uint32 buffer, - // because this is Javascript and we don't have uint64s - var SIGMA82 = array_1.ByteArray(SIGMA8.map(function (x) { return x * 2; })); - // Compression function. 'last' flag indicates last block. - // Note we're representing 16 uint64s as 32 uint32s - var v = array_1.WordArray(32); - var m = array_1.WordArray(32); - function blake2b_compress(ctx, last) { - var i; - // init work variables - for (i = 0; i < 16; i++) { - v[i] = ctx.h[i]; - v[i + 16] = BLAKE2B_IV32[i]; - } - // low 64 bits of offset - v[24] = v[24] ^ ctx.t; - v[25] = v[25] ^ (ctx.t / 0x100000000); - // high 64 bits not supported, offset may not be higher than 2**53-1 - // last block flag set ? - if (last) { - v[28] = ~v[28]; - v[29] = ~v[29]; - } - // get little-endian words - for (i = 0; i < 32; i++) { - m[i] = B2B_GET32(ctx.b, 4 * i); - } - // twelve rounds of mixing - // uncomment the DebugPrint calls to log the computation - // and match the RFC sample documentation - for (i = 0; i < 12; i++) { - B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]); - B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]); - B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]); - B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]); - B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]); - B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]); - B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]); - B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]); - } - for (i = 0; i < 16; i++) { - ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16]; - } - } - // 64-bit unsigned addition - // Sets v[a,a+1] += v[b,b+1] - // v should be a Uint32Array - function ADD64AA(v, a, b) { - var o0 = v[a] + v[b], o1 = v[a + 1] + v[b + 1]; - if (o0 >= 0x100000000) - o1++; - v[a] = o0; - v[a + 1] = o1; - } - // 64-bit unsigned addition - // Sets v[a,a+1] += b - // b0 is the low 32 bits of b, b1 represents the high 32 bits - function ADD64AC(v, a, b0, b1) { - var o0 = v[a] + b0; - if (b0 < 0) - o0 += 0x100000000; - var o1 = v[a + 1] + b1; - if (o0 >= 0x100000000) - o1++; - v[a] = o0; - v[a + 1] = o1; - } - // Little-endian byte access - function B2B_GET32(arr, i) { - return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24); - } - // G Mixing function - // The ROTRs are inlined for speed - function B2B_G(a, b, c, d, ix, iy) { - var x0 = m[ix]; - var x1 = m[ix + 1]; - var y0 = m[iy]; - var y1 = m[iy + 1]; - ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s - ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits - // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits - var xor0 = v[d] ^ v[a]; - var xor1 = v[d + 1] ^ v[a + 1]; - v[d] = xor1; - v[d + 1] = xor0; - ADD64AA(v, c, d); - // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits - xor0 = v[b] ^ v[c]; - xor1 = v[b + 1] ^ v[c + 1]; - v[b] = (xor0 >>> 24) ^ (xor1 << 8); - v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8); - ADD64AA(v, a, b); - ADD64AC(v, a, y0, y1); - // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits - xor0 = v[d] ^ v[a]; - xor1 = v[d + 1] ^ v[a + 1]; - v[d] = (xor0 >>> 16) ^ (xor1 << 16); - v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16); - ADD64AA(v, c, d); - // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits - xor0 = v[b] ^ v[c]; - xor1 = v[b + 1] ^ v[c + 1]; - v[b] = (xor1 >>> 31) ^ (xor0 << 1); - v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1); - } - - },{"./array":141}],144:[function(require,module,exports){ - "use strict"; - // Blake2S in pure Javascript - // Adapted from the reference implementation in RFC7693 - // Ported to Javascript by DC - https://github.com/dcposch - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - // Computes the BLAKE2S hash of a string or byte array, and returns a ByteArray - // - // Returns a n-byte ByteArray - // - // Parameters: - // - input - the input bytes, as a string, Buffer, or Uint8Array - // - key - optional key ByteArray, up to 32 bytes - // - outlen - optional output length in bytes, default 64 - function blake2s(input, key, outlen) { - if (outlen === void 0) { outlen = 32; } - var ctx = blake2s_init(outlen, key); - blake2s_update(ctx, input); - return blake2s_final(ctx); - } - exports.blake2s = blake2s; - // Creates a BLAKE2s hashing context - // Requires an output length between 1 and 32 bytes - // Takes an optional Uint8Array key - function blake2s_init(outlen, key) { - if (!(outlen > 0 && outlen <= 32)) { - throw new Error('Incorrect output length, should be in [1, 32]'); - } - var keylen = key ? key.length : 0; - if (key && !(keylen > 0 && keylen <= 32)) { - throw new Error('Incorrect key length, should be in [1, 32]'); - } - var ctx = { - h: array_1.WordArray(BLAKE2S_IV), - b: array_1.WordArray(64), - c: 0, - t: 0, - outlen: outlen // output length in bytes - }; - ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; - if (keylen) { - blake2s_update(ctx, key); - ctx.c = 64; // at the end - } - return ctx; - } - exports.blake2s_init = blake2s_init; - // Updates a BLAKE2s streaming hash - // Requires hash context and Uint8Array (byte array) - function blake2s_update(ctx, input) { - for (var i = 0; i < input.length; i++) { - if (ctx.c === 64) { // buffer full ? - ctx.t += ctx.c; // add counters - blake2s_compress(ctx, false); // compress (not last) - ctx.c = 0; // counter to zero - } - ctx.b[ctx.c++] = input[i]; - } - } - exports.blake2s_update = blake2s_update; - // Completes a BLAKE2s streaming hash - // Returns a Uint8Array containing the message digest - function blake2s_final(ctx) { - ctx.t += ctx.c; // mark last block offset - while (ctx.c < 64) { // fill up with zeros - ctx.b[ctx.c++] = 0; - } - blake2s_compress(ctx, true); // final block flag = 1 - // little endian convert and store - var out = array_1.ByteArray(ctx.outlen); - for (var i = 0; i < ctx.outlen; i++) { - out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xFF; - } - return out; - } - exports.blake2s_final = blake2s_final; - // Initialization Vector. - var BLAKE2S_IV = array_1.WordArray([ - 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, - 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 - ]); - var SIGMA = array_1.ByteArray([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, - 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, - 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, - 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, - 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, - 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, - 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, - 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, - 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 - ]); - // Compression function. "last" flag indicates last block - var v = array_1.WordArray(16); - var m = array_1.WordArray(16); - function blake2s_compress(ctx, last) { - var i = 0; - for (i = 0; i < 8; i++) { // init work variables - v[i] = ctx.h[i]; - v[i + 8] = BLAKE2S_IV[i]; - } - v[12] ^= ctx.t; // low 32 bits of offset - v[13] ^= (ctx.t / 0x100000000); // high 32 bits - if (last) { // last block flag set ? - v[14] = ~v[14]; - } - for (i = 0; i < 16; i++) { // get little-endian words - m[i] = B2S_GET32(ctx.b, 4 * i); - } - // ten rounds of mixing - // uncomment the DebugPrint calls to log the computation - // and match the RFC sample documentation - for (i = 0; i < 10; i++) { - B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]); - B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]); - B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]); - B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]); - B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]); - B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]); - B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]); - B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]); - } - for (i = 0; i < 8; i++) { - ctx.h[i] ^= v[i] ^ v[i + 8]; - } - } - // Little-endian byte access. - // Expects a ByteArray and an index - // Returns the little-endian uint32 at v[i..i+3] - function B2S_GET32(v, i) { - return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24); - } - // Mixing function G. - function B2S_G(a, b, c, d, x, y) { - v[a] = v[a] + v[b] + x; - v[d] = ROTR32(v[d] ^ v[a], 16); - v[c] = v[c] + v[d]; - v[b] = ROTR32(v[b] ^ v[c], 12); - v[a] = v[a] + v[b] + y; - v[d] = ROTR32(v[d] ^ v[a], 8); - v[c] = v[c] + v[d]; - v[b] = ROTR32(v[b] ^ v[c], 7); - } - // 32-bit right rotation - // x should be a uint32 - // y must be between 1 and 31, inclusive - function ROTR32(x, y) { - return (x >>> y) ^ (x << (32 - y)); - } - - },{"./array":141}],145:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var core_1 = require("./core"); - var random_1 = require("./random"); - var salsa20_1 = require("./salsa20"); - var scalarmult_1 = require("./scalarmult"); - var secretbox_1 = require("./secretbox"); - var check_1 = require("./check"); - function box(msg, nonce, publicKey, secretKey) { - var k = box_before(publicKey, secretKey); - return secretbox_1.secretbox(msg, nonce, k); - } - exports.box = box; - function box_before(publicKey, secretKey) { - check_1.checkArrayTypes(publicKey, secretKey); - check_1.checkBoxLengths(publicKey, secretKey); - var k = array_1.ByteArray(32 /* SharedKey */); - _box_beforenm(k, publicKey, secretKey); - return k; - } - exports.box_before = box_before; - exports.box_after = secretbox_1.secretbox; - function box_open(msg, nonce, publicKey, secretKey) { - var k = box_before(publicKey, secretKey); - return secretbox_1.secretbox_open(msg, nonce, k); - } - exports.box_open = box_open; - exports.box_open_after = secretbox_1.secretbox_open; - function box_keyPair() { - var pk = array_1.ByteArray(32 /* PublicKey */); - var sk = array_1.ByteArray(32 /* SecretKey */); - _box_keypair(pk, sk); - return { publicKey: pk, secretKey: sk }; - } - exports.box_keyPair = box_keyPair; - function box_keyPair_fromSecretKey(secretKey) { - check_1.checkArrayTypes(secretKey); - if (secretKey.length !== 32 /* SecretKey */) - throw new Error('bad secret key size'); - var pk = array_1.ByteArray(32 /* PublicKey */); - scalarmult_1._scalarMult_base(pk, secretKey); - return { publicKey: pk, secretKey: array_1.ByteArray(secretKey) }; - } - exports.box_keyPair_fromSecretKey = box_keyPair_fromSecretKey; - // low level - function _box_keypair(y, x) { - random_1._randomBytes(x, 32); - return scalarmult_1._scalarMult_base(y, x); - } - function _box_beforenm(k, y, x) { - var s = array_1.ByteArray(32); - scalarmult_1._scalarMult(s, x, y); - return salsa20_1._hsalsa20(k, core_1._0, s, salsa20_1._sigma); - } - - },{"./array":141,"./check":146,"./core":150,"./random":155,"./salsa20":156,"./scalarmult":157,"./secretbox":159}],146:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function checkLengths(k, n) { - if (k.length != 32 /* Key */) - throw new Error('bad key size'); - if (n.length != 24 /* Nonce */) - throw new Error('bad nonce size'); - } - exports.checkLengths = checkLengths; - function checkBoxLengths(pk, sk) { - if (pk.length != 32 /* PublicKey */) - throw new Error('bad public key size'); - if (sk.length != 32 /* SecretKey */) - throw new Error('bad secret key size'); - } - exports.checkBoxLengths = checkBoxLengths; - function checkArrayTypes() { - var arrays = []; - for (var _i = 0; _i < arguments.length; _i++) { - arrays[_i] = arguments[_i]; - } - for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) { - var array = arrays_1[_a]; - if (!(array instanceof Uint8Array)) { - throw new TypeError('unexpected type, use ByteArray'); - } - } - } - exports.checkArrayTypes = checkArrayTypes; - - },{}],147:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("../array"); - var validate_1 = require("../validate"); - var fromCharCode = String.fromCharCode; - function encodeUTF8(a) { - return decodeURIComponent(escape(fromCharCode.apply(undefined, a))); - } - exports.encodeUTF8 = encodeUTF8; - function decodeUTF8(s) { - if (typeof s !== 'string') - throw new TypeError('expected string'); - var d = unescape(encodeURIComponent(s)), b = array_1.ByteArray(d.length); - for (var i = 0; i < d.length; i++) { - b[i] = d.charCodeAt(i); - } - return b; - } - exports.decodeUTF8 = decodeUTF8; - function encodeBase64(a) { - return btoa(fromCharCode.apply(undefined, a)); - } - exports.encodeBase64 = encodeBase64; - function decodeBase64(s) { - validate_1.validateBase64(s); - var d = atob(s), b = array_1.ByteArray(d.length); - for (var i = 0; i < d.length; i++) { - b[i] = d.charCodeAt(i); - } - return b; - } - exports.decodeBase64 = decodeBase64; - function put_hb(h) { - return h + (h < 10 ? 48 : 87); - } - function encodeHex(a) { - var b = array_1.ByteArray(a.length << 1); - for (var i = 0, j = void 0; i < a.length; i++) { - j = i << 1; - b[j] = put_hb(a[i] >> 8); - b[j + 1] = put_hb(a[i] & 0xf); - } - return fromCharCode.apply(undefined, b); - } - exports.encodeHex = encodeHex; - function get_hb(s, i) { - var c = s.charCodeAt(i); - return c - (c < 58 ? 48 : c < 71 ? 55 : 87); - } - function decodeHex(s) { - validate_1.validateHex(s); - var a = array_1.ByteArray(s.length >> 1); - for (var i = 0; i < a.length; i += 2) { - a[i] = (get_hb(s, i) << 8) | get_hb(s, i + 1); - } - return a; - } - exports.decodeHex = decodeHex; - - },{"../array":141,"../validate":161}],148:[function(require,module,exports){ - "use strict"; - // Initialize PRNG if environment provides CSPRNG. - // If not, methods calling randombytes will throw. - Object.defineProperty(exports, "__esModule", { value: true }); - var QUOTE = 1 << 16; - function _randomBytes(x, n) { - for (var i = 0; i < n; i += QUOTE) { - crypto.getRandomValues(x.subarray(i, i + Math.min(n - i, QUOTE))); - } - } - exports._randomBytes = _randomBytes; - - },{}],149:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = require("tslib"); - tslib_1.__exportStar(require("./server/convert"), exports); - - },{"./server/convert":147,"tslib":140}],150:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - function gf(init) { - var r = array_1.NumArray(16); - if (init) - for (var i = 0; i < init.length; i++) - r[i] = init[i]; - return r; - } - exports.gf = gf; - exports._0 = array_1.ByteArray(16); - exports._9 = array_1.ByteArray(32); - exports._9[0] = 9; - exports.gf0 = gf(); - exports.gf1 = gf([1]); - exports._121665 = gf([0xdb41, 1]); - exports.D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]); - exports.D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]); - exports.X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]); - exports.Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]); - exports.I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]); - function A(o, a, b) { - for (var i = 0; i < 16; i++) - o[i] = a[i] + b[i]; - } - exports.A = A; - function Z(o, a, b) { - for (var i = 0; i < 16; i++) - o[i] = a[i] - b[i]; - } - exports.Z = Z; - function M(o, a, b) { - var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; - v = a[0]; - t0 += v * b0; - t1 += v * b1; - t2 += v * b2; - t3 += v * b3; - t4 += v * b4; - t5 += v * b5; - t6 += v * b6; - t7 += v * b7; - t8 += v * b8; - t9 += v * b9; - t10 += v * b10; - t11 += v * b11; - t12 += v * b12; - t13 += v * b13; - t14 += v * b14; - t15 += v * b15; - v = a[1]; - t1 += v * b0; - t2 += v * b1; - t3 += v * b2; - t4 += v * b3; - t5 += v * b4; - t6 += v * b5; - t7 += v * b6; - t8 += v * b7; - t9 += v * b8; - t10 += v * b9; - t11 += v * b10; - t12 += v * b11; - t13 += v * b12; - t14 += v * b13; - t15 += v * b14; - t16 += v * b15; - v = a[2]; - t2 += v * b0; - t3 += v * b1; - t4 += v * b2; - t5 += v * b3; - t6 += v * b4; - t7 += v * b5; - t8 += v * b6; - t9 += v * b7; - t10 += v * b8; - t11 += v * b9; - t12 += v * b10; - t13 += v * b11; - t14 += v * b12; - t15 += v * b13; - t16 += v * b14; - t17 += v * b15; - v = a[3]; - t3 += v * b0; - t4 += v * b1; - t5 += v * b2; - t6 += v * b3; - t7 += v * b4; - t8 += v * b5; - t9 += v * b6; - t10 += v * b7; - t11 += v * b8; - t12 += v * b9; - t13 += v * b10; - t14 += v * b11; - t15 += v * b12; - t16 += v * b13; - t17 += v * b14; - t18 += v * b15; - v = a[4]; - t4 += v * b0; - t5 += v * b1; - t6 += v * b2; - t7 += v * b3; - t8 += v * b4; - t9 += v * b5; - t10 += v * b6; - t11 += v * b7; - t12 += v * b8; - t13 += v * b9; - t14 += v * b10; - t15 += v * b11; - t16 += v * b12; - t17 += v * b13; - t18 += v * b14; - t19 += v * b15; - v = a[5]; - t5 += v * b0; - t6 += v * b1; - t7 += v * b2; - t8 += v * b3; - t9 += v * b4; - t10 += v * b5; - t11 += v * b6; - t12 += v * b7; - t13 += v * b8; - t14 += v * b9; - t15 += v * b10; - t16 += v * b11; - t17 += v * b12; - t18 += v * b13; - t19 += v * b14; - t20 += v * b15; - v = a[6]; - t6 += v * b0; - t7 += v * b1; - t8 += v * b2; - t9 += v * b3; - t10 += v * b4; - t11 += v * b5; - t12 += v * b6; - t13 += v * b7; - t14 += v * b8; - t15 += v * b9; - t16 += v * b10; - t17 += v * b11; - t18 += v * b12; - t19 += v * b13; - t20 += v * b14; - t21 += v * b15; - v = a[7]; - t7 += v * b0; - t8 += v * b1; - t9 += v * b2; - t10 += v * b3; - t11 += v * b4; - t12 += v * b5; - t13 += v * b6; - t14 += v * b7; - t15 += v * b8; - t16 += v * b9; - t17 += v * b10; - t18 += v * b11; - t19 += v * b12; - t20 += v * b13; - t21 += v * b14; - t22 += v * b15; - v = a[8]; - t8 += v * b0; - t9 += v * b1; - t10 += v * b2; - t11 += v * b3; - t12 += v * b4; - t13 += v * b5; - t14 += v * b6; - t15 += v * b7; - t16 += v * b8; - t17 += v * b9; - t18 += v * b10; - t19 += v * b11; - t20 += v * b12; - t21 += v * b13; - t22 += v * b14; - t23 += v * b15; - v = a[9]; - t9 += v * b0; - t10 += v * b1; - t11 += v * b2; - t12 += v * b3; - t13 += v * b4; - t14 += v * b5; - t15 += v * b6; - t16 += v * b7; - t17 += v * b8; - t18 += v * b9; - t19 += v * b10; - t20 += v * b11; - t21 += v * b12; - t22 += v * b13; - t23 += v * b14; - t24 += v * b15; - v = a[10]; - t10 += v * b0; - t11 += v * b1; - t12 += v * b2; - t13 += v * b3; - t14 += v * b4; - t15 += v * b5; - t16 += v * b6; - t17 += v * b7; - t18 += v * b8; - t19 += v * b9; - t20 += v * b10; - t21 += v * b11; - t22 += v * b12; - t23 += v * b13; - t24 += v * b14; - t25 += v * b15; - v = a[11]; - t11 += v * b0; - t12 += v * b1; - t13 += v * b2; - t14 += v * b3; - t15 += v * b4; - t16 += v * b5; - t17 += v * b6; - t18 += v * b7; - t19 += v * b8; - t20 += v * b9; - t21 += v * b10; - t22 += v * b11; - t23 += v * b12; - t24 += v * b13; - t25 += v * b14; - t26 += v * b15; - v = a[12]; - t12 += v * b0; - t13 += v * b1; - t14 += v * b2; - t15 += v * b3; - t16 += v * b4; - t17 += v * b5; - t18 += v * b6; - t19 += v * b7; - t20 += v * b8; - t21 += v * b9; - t22 += v * b10; - t23 += v * b11; - t24 += v * b12; - t25 += v * b13; - t26 += v * b14; - t27 += v * b15; - v = a[13]; - t13 += v * b0; - t14 += v * b1; - t15 += v * b2; - t16 += v * b3; - t17 += v * b4; - t18 += v * b5; - t19 += v * b6; - t20 += v * b7; - t21 += v * b8; - t22 += v * b9; - t23 += v * b10; - t24 += v * b11; - t25 += v * b12; - t26 += v * b13; - t27 += v * b14; - t28 += v * b15; - v = a[14]; - t14 += v * b0; - t15 += v * b1; - t16 += v * b2; - t17 += v * b3; - t18 += v * b4; - t19 += v * b5; - t20 += v * b6; - t21 += v * b7; - t22 += v * b8; - t23 += v * b9; - t24 += v * b10; - t25 += v * b11; - t26 += v * b12; - t27 += v * b13; - t28 += v * b14; - t29 += v * b15; - v = a[15]; - t15 += v * b0; - t16 += v * b1; - t17 += v * b2; - t18 += v * b3; - t19 += v * b4; - t20 += v * b5; - t21 += v * b6; - t22 += v * b7; - t23 += v * b8; - t24 += v * b9; - t25 += v * b10; - t26 += v * b11; - t27 += v * b12; - t28 += v * b13; - t29 += v * b14; - t30 += v * b15; - t0 += 38 * t16; - t1 += 38 * t17; - t2 += 38 * t18; - t3 += 38 * t19; - t4 += 38 * t20; - t5 += 38 * t21; - t6 += 38 * t22; - t7 += 38 * t23; - t8 += 38 * t24; - t9 += 38 * t25; - t10 += 38 * t26; - t11 += 38 * t27; - t12 += 38 * t28; - t13 += 38 * t29; - t14 += 38 * t30; - // t15 left as is - // first car - c = 1; - v = t0 + c + 65535; - c = Math.floor(v / 65536); - t0 = v - c * 65536; - v = t1 + c + 65535; - c = Math.floor(v / 65536); - t1 = v - c * 65536; - v = t2 + c + 65535; - c = Math.floor(v / 65536); - t2 = v - c * 65536; - v = t3 + c + 65535; - c = Math.floor(v / 65536); - t3 = v - c * 65536; - v = t4 + c + 65535; - c = Math.floor(v / 65536); - t4 = v - c * 65536; - v = t5 + c + 65535; - c = Math.floor(v / 65536); - t5 = v - c * 65536; - v = t6 + c + 65535; - c = Math.floor(v / 65536); - t6 = v - c * 65536; - v = t7 + c + 65535; - c = Math.floor(v / 65536); - t7 = v - c * 65536; - v = t8 + c + 65535; - c = Math.floor(v / 65536); - t8 = v - c * 65536; - v = t9 + c + 65535; - c = Math.floor(v / 65536); - t9 = v - c * 65536; - v = t10 + c + 65535; - c = Math.floor(v / 65536); - t10 = v - c * 65536; - v = t11 + c + 65535; - c = Math.floor(v / 65536); - t11 = v - c * 65536; - v = t12 + c + 65535; - c = Math.floor(v / 65536); - t12 = v - c * 65536; - v = t13 + c + 65535; - c = Math.floor(v / 65536); - t13 = v - c * 65536; - v = t14 + c + 65535; - c = Math.floor(v / 65536); - t14 = v - c * 65536; - v = t15 + c + 65535; - c = Math.floor(v / 65536); - t15 = v - c * 65536; - t0 += c - 1 + 37 * (c - 1); - // second car - c = 1; - v = t0 + c + 65535; - c = Math.floor(v / 65536); - t0 = v - c * 65536; - v = t1 + c + 65535; - c = Math.floor(v / 65536); - t1 = v - c * 65536; - v = t2 + c + 65535; - c = Math.floor(v / 65536); - t2 = v - c * 65536; - v = t3 + c + 65535; - c = Math.floor(v / 65536); - t3 = v - c * 65536; - v = t4 + c + 65535; - c = Math.floor(v / 65536); - t4 = v - c * 65536; - v = t5 + c + 65535; - c = Math.floor(v / 65536); - t5 = v - c * 65536; - v = t6 + c + 65535; - c = Math.floor(v / 65536); - t6 = v - c * 65536; - v = t7 + c + 65535; - c = Math.floor(v / 65536); - t7 = v - c * 65536; - v = t8 + c + 65535; - c = Math.floor(v / 65536); - t8 = v - c * 65536; - v = t9 + c + 65535; - c = Math.floor(v / 65536); - t9 = v - c * 65536; - v = t10 + c + 65535; - c = Math.floor(v / 65536); - t10 = v - c * 65536; - v = t11 + c + 65535; - c = Math.floor(v / 65536); - t11 = v - c * 65536; - v = t12 + c + 65535; - c = Math.floor(v / 65536); - t12 = v - c * 65536; - v = t13 + c + 65535; - c = Math.floor(v / 65536); - t13 = v - c * 65536; - v = t14 + c + 65535; - c = Math.floor(v / 65536); - t14 = v - c * 65536; - v = t15 + c + 65535; - c = Math.floor(v / 65536); - t15 = v - c * 65536; - t0 += c - 1 + 37 * (c - 1); - o[0] = t0; - o[1] = t1; - o[2] = t2; - o[3] = t3; - o[4] = t4; - o[5] = t5; - o[6] = t6; - o[7] = t7; - o[8] = t8; - o[9] = t9; - o[10] = t10; - o[11] = t11; - o[12] = t12; - o[13] = t13; - o[14] = t14; - o[15] = t15; - } - exports.M = M; - function S(o, a) { - M(o, a, a); - } - exports.S = S; - - },{"./array":141}],151:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var verify_1 = require("./verify"); - var core_1 = require("./core"); - function set25519(r, a) { - for (var i = 0; i < 16; i++) - r[i] = a[i] | 0; - } - exports.set25519 = set25519; - function car25519(o) { - var i, v, c = 1; - for (i = 0; i < 16; i++) { - v = o[i] + c + 65535; - c = Math.floor(v / 65536); - o[i] = v - c * 65536; - } - o[0] += c - 1 + 37 * (c - 1); - } - function sel25519(p, q, b) { - var t, c = ~(b - 1); - for (var i = 0; i < 16; i++) { - t = c & (p[i] ^ q[i]); - p[i] ^= t; - q[i] ^= t; - } - } - exports.sel25519 = sel25519; - function pack25519(o, n) { - var m = core_1.gf(), t = core_1.gf(); - var i, j, b; - for (i = 0; i < 16; i++) - t[i] = n[i]; - car25519(t); - car25519(t); - car25519(t); - for (j = 0; j < 2; j++) { - m[0] = t[0] - 0xffed; - for (i = 1; i < 15; i++) { - m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1); - m[i - 1] &= 0xffff; - } - m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1); - b = (m[15] >> 16) & 1; - m[14] &= 0xffff; - sel25519(t, m, 1 - b); - } - for (i = 0; i < 16; i++) { - o[2 * i] = t[i] & 0xff; - o[2 * i + 1] = t[i] >> 8; - } - } - exports.pack25519 = pack25519; - function neq25519(a, b) { - var c = array_1.ByteArray(32), d = array_1.ByteArray(32); - pack25519(c, a); - pack25519(d, b); - return verify_1._verify_32(c, 0, d, 0); - } - exports.neq25519 = neq25519; - function par25519(a) { - var d = array_1.ByteArray(32); - pack25519(d, a); - return d[0] & 1; - } - exports.par25519 = par25519; - function unpack25519(o, n) { - for (var i = 0; i < 16; i++) - o[i] = n[2 * i] + (n[2 * i + 1] << 8); - o[15] &= 0x7fff; - } - exports.unpack25519 = unpack25519; - function inv25519(o, i) { - var c = core_1.gf(); - var a; - for (a = 0; a < 16; a++) - c[a] = i[a]; - for (a = 253; a >= 0; a--) { - core_1.S(c, c); - if (a !== 2 && a !== 4) - core_1.M(c, c, i); - } - for (a = 0; a < 16; a++) - o[a] = c[a]; - } - exports.inv25519 = inv25519; - - },{"./array":141,"./core":150,"./verify":162}],152:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var check_1 = require("./check"); - function hash(msg) { - check_1.checkArrayTypes(msg); - var h = array_1.ByteArray(64 /* Hash */); - _hash(h, msg, msg.length); - return h; - } - exports.hash = hash; - function _hash(out, m, n) { - var hh = array_1.IntArray(8), hl = array_1.IntArray(8), x = array_1.ByteArray(256); - var i, b = n; - hh[0] = 0x6a09e667; - hh[1] = 0xbb67ae85; - hh[2] = 0x3c6ef372; - hh[3] = 0xa54ff53a; - hh[4] = 0x510e527f; - hh[5] = 0x9b05688c; - hh[6] = 0x1f83d9ab; - hh[7] = 0x5be0cd19; - hl[0] = 0xf3bcc908; - hl[1] = 0x84caa73b; - hl[2] = 0xfe94f82b; - hl[3] = 0x5f1d36f1; - hl[4] = 0xade682d1; - hl[5] = 0x2b3e6c1f; - hl[6] = 0xfb41bd6b; - hl[7] = 0x137e2179; - _hashblocks_hl(hh, hl, m, n); - n %= 128; - for (i = 0; i < n; i++) - x[i] = m[b - n + i]; - x[n] = 128; - n = 256 - 128 * (n < 112 ? 1 : 0); - x[n - 9] = 0; - _ts64(x, n - 8, (b / 0x20000000) | 0, b << 3); - _hashblocks_hl(hh, hl, x, n); - for (i = 0; i < 8; i++) - _ts64(out, 8 * i, hh[i], hl[i]); - return 0; - } - exports._hash = _hash; - var _K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 - ]; - function _hashblocks_hl(hh, hl, m, n) { - var wh = array_1.IntArray(16), wl = array_1.IntArray(16); - var bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d; - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; - var pos = 0; - while (n >= 128) { - for (i = 0; i < 16; i++) { - j = 8 * i + pos; - wh[i] = (m[j + 0] << 24) | (m[j + 1] << 16) | (m[j + 2] << 8) | m[j + 3]; - wl[i] = (m[j + 4] << 24) | (m[j + 5] << 16) | (m[j + 6] << 8) | m[j + 7]; - } - for (i = 0; i < 80; i++) { - bh0 = ah0; - bh1 = ah1; - bh2 = ah2; - bh3 = ah3; - bh4 = ah4; - bh5 = ah5; - bh6 = ah6; - bh7 = ah7; - bl0 = al0; - bl1 = al1; - bl2 = al2; - bl3 = al3; - bl4 = al4; - bl5 = al5; - bl6 = al6; - bl7 = al7; - // add - h = ah7; - l = al7; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - // Sigma1 - h = ((ah4 >>> 14) | (al4 << (32 - 14))) ^ ((ah4 >>> 18) | (al4 << (32 - 18))) ^ ((al4 >>> (41 - 32)) | (ah4 << (32 - (41 - 32)))); - l = ((al4 >>> 14) | (ah4 << (32 - 14))) ^ ((al4 >>> 18) | (ah4 << (32 - 18))) ^ ((ah4 >>> (41 - 32)) | (al4 << (32 - (41 - 32)))); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // Ch - h = (ah4 & ah5) ^ (~ah4 & ah6); - l = (al4 & al5) ^ (~al4 & al6); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // K - h = _K[i * 2]; - l = _K[i * 2 + 1]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // w - h = wh[i % 16]; - l = wl[i % 16]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - th = c & 0xffff | d << 16; - tl = a & 0xffff | b << 16; - // add - h = th; - l = tl; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - // Sigma0 - h = ((ah0 >>> 28) | (al0 << (32 - 28))) ^ ((al0 >>> (34 - 32)) | (ah0 << (32 - (34 - 32)))) ^ ((al0 >>> (39 - 32)) | (ah0 << (32 - (39 - 32)))); - l = ((al0 >>> 28) | (ah0 << (32 - 28))) ^ ((ah0 >>> (34 - 32)) | (al0 << (32 - (34 - 32)))) ^ ((ah0 >>> (39 - 32)) | (al0 << (32 - (39 - 32)))); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // Maj - h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2); - l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - bh7 = (c & 0xffff) | (d << 16); - bl7 = (a & 0xffff) | (b << 16); - // add - h = bh3; - l = bl3; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = th; - l = tl; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - bh3 = (c & 0xffff) | (d << 16); - bl3 = (a & 0xffff) | (b << 16); - ah1 = bh0; - ah2 = bh1; - ah3 = bh2; - ah4 = bh3; - ah5 = bh4; - ah6 = bh5; - ah7 = bh6; - ah0 = bh7; - al1 = bl0; - al2 = bl1; - al3 = bl2; - al4 = bl3; - al5 = bl4; - al6 = bl5; - al7 = bl6; - al0 = bl7; - if (i % 16 === 15) { - for (j = 0; j < 16; j++) { - // add - h = wh[j]; - l = wl[j]; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = wh[(j + 9) % 16]; - l = wl[(j + 9) % 16]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // sigma0 - th = wh[(j + 1) % 16]; - tl = wl[(j + 1) % 16]; - h = ((th >>> 1) | (tl << (32 - 1))) ^ ((th >>> 8) | (tl << (32 - 8))) ^ (th >>> 7); - l = ((tl >>> 1) | (th << (32 - 1))) ^ ((tl >>> 8) | (th << (32 - 8))) ^ ((tl >>> 7) | (th << (32 - 7))); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - // sigma1 - th = wh[(j + 14) % 16]; - tl = wl[(j + 14) % 16]; - h = ((th >>> 19) | (tl << (32 - 19))) ^ ((tl >>> (61 - 32)) | (th << (32 - (61 - 32)))) ^ (th >>> 6); - l = ((tl >>> 19) | (th << (32 - 19))) ^ ((th >>> (61 - 32)) | (tl << (32 - (61 - 32)))) ^ ((tl >>> 6) | (th << (32 - 6))); - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - wh[j] = (c & 0xffff) | (d << 16); - wl[j] = (a & 0xffff) | (b << 16); - } - } - } - // add - h = ah0; - l = al0; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[0]; - l = hl[0]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[0] = ah0 = (c & 0xffff) | (d << 16); - hl[0] = al0 = (a & 0xffff) | (b << 16); - h = ah1; - l = al1; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[1]; - l = hl[1]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[1] = ah1 = (c & 0xffff) | (d << 16); - hl[1] = al1 = (a & 0xffff) | (b << 16); - h = ah2; - l = al2; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[2]; - l = hl[2]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[2] = ah2 = (c & 0xffff) | (d << 16); - hl[2] = al2 = (a & 0xffff) | (b << 16); - h = ah3; - l = al3; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[3]; - l = hl[3]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[3] = ah3 = (c & 0xffff) | (d << 16); - hl[3] = al3 = (a & 0xffff) | (b << 16); - h = ah4; - l = al4; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[4]; - l = hl[4]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[4] = ah4 = (c & 0xffff) | (d << 16); - hl[4] = al4 = (a & 0xffff) | (b << 16); - h = ah5; - l = al5; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[5]; - l = hl[5]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[5] = ah5 = (c & 0xffff) | (d << 16); - hl[5] = al5 = (a & 0xffff) | (b << 16); - h = ah6; - l = al6; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[6]; - l = hl[6]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[6] = ah6 = (c & 0xffff) | (d << 16); - hl[6] = al6 = (a & 0xffff) | (b << 16); - h = ah7; - l = al7; - a = l & 0xffff; - b = l >>> 16; - c = h & 0xffff; - d = h >>> 16; - h = hh[7]; - l = hl[7]; - a += l & 0xffff; - b += l >>> 16; - c += h & 0xffff; - d += h >>> 16; - b += a >>> 16; - c += b >>> 16; - d += c >>> 16; - hh[7] = ah7 = (c & 0xffff) | (d << 16); - hl[7] = al7 = (a & 0xffff) | (b << 16); - pos += 128; - n -= 128; - } - return n; - } - function _ts64(x, i, h, l) { - x[i] = (h >> 24) & 0xff; - x[i + 1] = (h >> 16) & 0xff; - x[i + 2] = (h >> 8) & 0xff; - x[i + 3] = h & 0xff; - x[i + 4] = (l >> 24) & 0xff; - x[i + 5] = (l >> 16) & 0xff; - x[i + 6] = (l >> 8) & 0xff; - x[i + 7] = l & 0xff; - } - - },{"./array":141,"./check":146}],153:[function(require,module,exports){ - "use strict"; - // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. - // Public domain. - // - // Implementation derived from TweetNaCl version 20140427. - // See for details: http://tweetnacl.cr.yp.to/ - // - // Ported to TypeScript in 2018 by K. - // - Object.defineProperty(exports, "__esModule", { value: true }); - var tslib_1 = require("tslib"); - tslib_1.__exportStar(require("./array"), exports); - tslib_1.__exportStar(require("./validate"), exports); - tslib_1.__exportStar(require("./convert"), exports); - tslib_1.__exportStar(require("./verify"), exports); - tslib_1.__exportStar(require("./random"), exports); - tslib_1.__exportStar(require("./scalarmult"), exports); - tslib_1.__exportStar(require("./secretbox"), exports); - tslib_1.__exportStar(require("./box"), exports); - tslib_1.__exportStar(require("./sign"), exports); - tslib_1.__exportStar(require("./hash"), exports); - tslib_1.__exportStar(require("./auth"), exports); - tslib_1.__exportStar(require("./blake2s"), exports); - tslib_1.__exportStar(require("./blake2b"), exports); - tslib_1.__exportStar(require("./sealedbox"), exports); - - },{"./array":141,"./auth":142,"./blake2b":143,"./blake2s":144,"./box":145,"./convert":149,"./hash":152,"./random":155,"./scalarmult":157,"./sealedbox":158,"./secretbox":159,"./sign":160,"./validate":161,"./verify":162,"tslib":140}],154:[function(require,module,exports){ - "use strict"; - /* - * Port of Andrew Moon's Poly1305-donna-16. Public domain. - * https://github.com/floodyberry/poly1305-donna - * - * Ported to TypeScript in 2018 by K. - */ - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - function poly1305_init(key) { - var r = array_1.HalfArray(10); - var pad = array_1.HalfArray(8); - var t0, t1, t2, t3, t4, t5, t6, t7; - t0 = key[0] & 0xff | (key[1] & 0xff) << 8; - r[0] = (t0) & 0x1fff; - t1 = key[2] & 0xff | (key[3] & 0xff) << 8; - r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff; - t2 = key[4] & 0xff | (key[5] & 0xff) << 8; - r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03; - t3 = key[6] & 0xff | (key[7] & 0xff) << 8; - r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff; - t4 = key[8] & 0xff | (key[9] & 0xff) << 8; - r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff; - r[5] = ((t4 >>> 1)) & 0x1ffe; - t5 = key[10] & 0xff | (key[11] & 0xff) << 8; - r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff; - t6 = key[12] & 0xff | (key[13] & 0xff) << 8; - r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81; - t7 = key[14] & 0xff | (key[15] & 0xff) << 8; - r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff; - r[9] = ((t7 >>> 5)) & 0x007f; - pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8; - pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8; - pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8; - pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8; - pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8; - pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8; - pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8; - pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8; - return { - buffer: array_1.ByteArray(16), - r: r, - h: array_1.HalfArray(10), - pad: pad, - leftover: 0, - fin: 0, - }; - } - exports.poly1305_init = poly1305_init; - ; - function poly1305_blocks(self, m, mpos, bytes) { - var hibit = self.fin ? 0 : (1 << 11); - var t0, t1, t2, t3, t4, t5, t6, t7, c; - var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9; - var h = self.h, r = self.r; - var h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3], h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7], h8 = h[8], h9 = h[9]; - var r0 = r[0], r1 = r[1], r2 = r[2], r3 = r[3], r4 = r[4], r5 = r[5], r6 = r[6], r7 = r[7], r8 = r[8], r9 = r[9]; - while (bytes >= 16) { - t0 = m[mpos + 0] & 0xff | (m[mpos + 1] & 0xff) << 8; - h0 += (t0) & 0x1fff; - t1 = m[mpos + 2] & 0xff | (m[mpos + 3] & 0xff) << 8; - h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff; - t2 = m[mpos + 4] & 0xff | (m[mpos + 5] & 0xff) << 8; - h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff; - t3 = m[mpos + 6] & 0xff | (m[mpos + 7] & 0xff) << 8; - h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff; - t4 = m[mpos + 8] & 0xff | (m[mpos + 9] & 0xff) << 8; - h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff; - h5 += ((t4 >>> 1)) & 0x1fff; - t5 = m[mpos + 10] & 0xff | (m[mpos + 11] & 0xff) << 8; - h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff; - t6 = m[mpos + 12] & 0xff | (m[mpos + 13] & 0xff) << 8; - h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff; - t7 = m[mpos + 14] & 0xff | (m[mpos + 15] & 0xff) << 8; - h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff; - h9 += ((t7 >>> 5)) | hibit; - c = 0; - d0 = c; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h2 * (5 * r8); - d0 += h3 * (5 * r7); - d0 += h4 * (5 * r6); - c = (d0 >>> 13); - d0 &= 0x1fff; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c += (d0 >>> 13); - d0 &= 0x1fff; - d1 = c; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h2 * (5 * r9); - d1 += h3 * (5 * r8); - d1 += h4 * (5 * r7); - c = (d1 >>> 13); - d1 &= 0x1fff; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c += (d1 >>> 13); - d1 &= 0x1fff; - d2 = c; - d2 += h0 * r2; - d2 += h1 * r1; - d2 += h2 * r0; - d2 += h3 * (5 * r9); - d2 += h4 * (5 * r8); - c = (d2 >>> 13); - d2 &= 0x1fff; - d2 += h5 * (5 * r7); - d2 += h6 * (5 * r6); - d2 += h7 * (5 * r5); - d2 += h8 * (5 * r4); - d2 += h9 * (5 * r3); - c += (d2 >>> 13); - d2 &= 0x1fff; - d3 = c; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h2 * r1; - d3 += h3 * r0; - d3 += h4 * (5 * r9); - c = (d3 >>> 13); - d3 &= 0x1fff; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c += (d3 >>> 13); - d3 &= 0x1fff; - d4 = c; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h2 * r2; - d4 += h3 * r1; - d4 += h4 * r0; - c = (d4 >>> 13); - d4 &= 0x1fff; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c += (d4 >>> 13); - d4 &= 0x1fff; - d5 = c; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h2 * r3; - d5 += h3 * r2; - d5 += h4 * r1; - c = (d5 >>> 13); - d5 &= 0x1fff; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c += (d5 >>> 13); - d5 &= 0x1fff; - d6 = c; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h2 * r4; - d6 += h3 * r3; - d6 += h4 * r2; - c = (d6 >>> 13); - d6 &= 0x1fff; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c += (d6 >>> 13); - d6 &= 0x1fff; - d7 = c; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h2 * r5; - d7 += h3 * r4; - d7 += h4 * r3; - c = (d7 >>> 13); - d7 &= 0x1fff; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c += (d7 >>> 13); - d7 &= 0x1fff; - d8 = c; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h2 * r6; - d8 += h3 * r5; - d8 += h4 * r4; - c = (d8 >>> 13); - d8 &= 0x1fff; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c += (d8 >>> 13); - d8 &= 0x1fff; - d9 = c; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h2 * r7; - d9 += h3 * r6; - d9 += h4 * r5; - c = (d9 >>> 13); - d9 &= 0x1fff; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c += (d9 >>> 13); - d9 &= 0x1fff; - c = (((c << 2) + c)) | 0; - c = (c + d0) | 0; - d0 = c & 0x1fff; - c = (c >>> 13); - d1 += c; - h0 = d0; - h1 = d1; - h2 = d2; - h3 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; - } - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; - } - exports.poly1305_blocks = poly1305_blocks; - ; - function poly1305_finish(self, mac, macpos) { - var g = array_1.HalfArray(10); - var c, mask, f, i; - var buffer = self.buffer, h = self.h, pad = self.pad, leftover = self.leftover; - if (leftover) { - i = leftover; - buffer[i++] = 1; - for (; i < 16; i++) - buffer[i] = 0; - self.fin = 1; - poly1305_blocks(self, buffer, 0, 16); - } - c = h[1] >>> 13; - h[1] &= 0x1fff; - for (i = 2; i < 10; i++) { - h[i] += c; - c = h[i] >>> 13; - h[i] &= 0x1fff; - } - h[0] += (c * 5); - c = h[0] >>> 13; - h[0] &= 0x1fff; - h[1] += c; - c = h[1] >>> 13; - h[1] &= 0x1fff; - h[2] += c; - g[0] = h[0] + 5; - c = g[0] >>> 13; - g[0] &= 0x1fff; - for (i = 1; i < 10; i++) { - g[i] = h[i] + c; - c = g[i] >>> 13; - g[i] &= 0x1fff; - } - g[9] -= (1 << 13); - mask = (c ^ 1) - 1; - for (i = 0; i < 10; i++) - g[i] &= mask; - mask = ~mask; - for (i = 0; i < 10; i++) - h[i] = (h[i] & mask) | g[i]; - h[0] = ((h[0]) | (h[1] << 13)) & 0xffff; - h[1] = ((h[1] >>> 3) | (h[2] << 10)) & 0xffff; - h[2] = ((h[2] >>> 6) | (h[3] << 7)) & 0xffff; - h[3] = ((h[3] >>> 9) | (h[4] << 4)) & 0xffff; - h[4] = ((h[4] >>> 12) | (h[5] << 1) | (h[6] << 14)) & 0xffff; - h[5] = ((h[6] >>> 2) | (h[7] << 11)) & 0xffff; - h[6] = ((h[7] >>> 5) | (h[8] << 8)) & 0xffff; - h[7] = ((h[8] >>> 8) | (h[9] << 5)) & 0xffff; - f = h[0] + pad[0]; - h[0] = f & 0xffff; - for (i = 1; i < 8; i++) { - f = (((h[i] + pad[i]) | 0) + (f >>> 16)) | 0; - h[i] = f & 0xffff; - } - mac[macpos + 0] = (h[0] >>> 0) & 0xff; - mac[macpos + 1] = (h[0] >>> 8) & 0xff; - mac[macpos + 2] = (h[1] >>> 0) & 0xff; - mac[macpos + 3] = (h[1] >>> 8) & 0xff; - mac[macpos + 4] = (h[2] >>> 0) & 0xff; - mac[macpos + 5] = (h[2] >>> 8) & 0xff; - mac[macpos + 6] = (h[3] >>> 0) & 0xff; - mac[macpos + 7] = (h[3] >>> 8) & 0xff; - mac[macpos + 8] = (h[4] >>> 0) & 0xff; - mac[macpos + 9] = (h[4] >>> 8) & 0xff; - mac[macpos + 10] = (h[5] >>> 0) & 0xff; - mac[macpos + 11] = (h[5] >>> 8) & 0xff; - mac[macpos + 12] = (h[6] >>> 0) & 0xff; - mac[macpos + 13] = (h[6] >>> 8) & 0xff; - mac[macpos + 14] = (h[7] >>> 0) & 0xff; - mac[macpos + 15] = (h[7] >>> 8) & 0xff; - } - exports.poly1305_finish = poly1305_finish; - ; - function poly1305_update(self, m, mpos, bytes) { - var i, want; - var buffer = self.buffer; - if (self.leftover) { - want = (16 - self.leftover); - if (want > bytes) - want = bytes; - for (i = 0; i < want; i++) - buffer[self.leftover + i] = m[mpos + i]; - bytes -= want; - mpos += want; - self.leftover += want; - if (self.leftover < 16) - return; - poly1305_blocks(self, buffer, 0, 16); - self.leftover = 0; - } - if (bytes >= 16) { - want = bytes - (bytes % 16); - poly1305_blocks(self, m, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (i = 0; i < bytes; i++) - buffer[self.leftover + i] = m[mpos + i]; - self.leftover += bytes; - } - } - exports.poly1305_update = poly1305_update; - - },{"./array":141}],155:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var random_1 = require("./server/random"); - exports._randomBytes = random_1._randomBytes; - function randomBytes(n) { - var b = array_1.ByteArray(n); - random_1._randomBytes(b, n); - return b; - } - exports.randomBytes = randomBytes; - - },{"./array":141,"./server/random":148}],156:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - function _salsa20(o, p, k, c) { - var j0 = c[0] & 0xff | (c[1] & 0xff) << 8 | (c[2] & 0xff) << 16 | (c[3] & 0xff) << 24, j1 = k[0] & 0xff | (k[1] & 0xff) << 8 | (k[2] & 0xff) << 16 | (k[3] & 0xff) << 24, j2 = k[4] & 0xff | (k[5] & 0xff) << 8 | (k[6] & 0xff) << 16 | (k[7] & 0xff) << 24, j3 = k[8] & 0xff | (k[9] & 0xff) << 8 | (k[10] & 0xff) << 16 | (k[11] & 0xff) << 24, j4 = k[12] & 0xff | (k[13] & 0xff) << 8 | (k[14] & 0xff) << 16 | (k[15] & 0xff) << 24, j5 = c[4] & 0xff | (c[5] & 0xff) << 8 | (c[6] & 0xff) << 16 | (c[7] & 0xff) << 24, j6 = p[0] & 0xff | (p[1] & 0xff) << 8 | (p[2] & 0xff) << 16 | (p[3] & 0xff) << 24, j7 = p[4] & 0xff | (p[5] & 0xff) << 8 | (p[6] & 0xff) << 16 | (p[7] & 0xff) << 24, j8 = p[8] & 0xff | (p[9] & 0xff) << 8 | (p[10] & 0xff) << 16 | (p[11] & 0xff) << 24, j9 = p[12] & 0xff | (p[13] & 0xff) << 8 | (p[14] & 0xff) << 16 | (p[15] & 0xff) << 24, j10 = c[8] & 0xff | (c[9] & 0xff) << 8 | (c[10] & 0xff) << 16 | (c[11] & 0xff) << 24, j11 = k[16] & 0xff | (k[17] & 0xff) << 8 | (k[18] & 0xff) << 16 | (k[19] & 0xff) << 24, j12 = k[20] & 0xff | (k[21] & 0xff) << 8 | (k[22] & 0xff) << 16 | (k[23] & 0xff) << 24, j13 = k[24] & 0xff | (k[25] & 0xff) << 8 | (k[26] & 0xff) << 16 | (k[27] & 0xff) << 24, j14 = k[28] & 0xff | (k[29] & 0xff) << 8 | (k[30] & 0xff) << 16 | (k[31] & 0xff) << 24, j15 = c[12] & 0xff | (c[13] & 0xff) << 8 | (c[14] & 0xff) << 16 | (c[15] & 0xff) << 24; - var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u; - for (var i = 0; i < 20; i += 2) { - u = x0 + x12 | 0; - x4 ^= u << 7 | u >>> (32 - 7); - u = x4 + x0 | 0; - x8 ^= u << 9 | u >>> (32 - 9); - u = x8 + x4 | 0; - x12 ^= u << 13 | u >>> (32 - 13); - u = x12 + x8 | 0; - x0 ^= u << 18 | u >>> (32 - 18); - u = x5 + x1 | 0; - x9 ^= u << 7 | u >>> (32 - 7); - u = x9 + x5 | 0; - x13 ^= u << 9 | u >>> (32 - 9); - u = x13 + x9 | 0; - x1 ^= u << 13 | u >>> (32 - 13); - u = x1 + x13 | 0; - x5 ^= u << 18 | u >>> (32 - 18); - u = x10 + x6 | 0; - x14 ^= u << 7 | u >>> (32 - 7); - u = x14 + x10 | 0; - x2 ^= u << 9 | u >>> (32 - 9); - u = x2 + x14 | 0; - x6 ^= u << 13 | u >>> (32 - 13); - u = x6 + x2 | 0; - x10 ^= u << 18 | u >>> (32 - 18); - u = x15 + x11 | 0; - x3 ^= u << 7 | u >>> (32 - 7); - u = x3 + x15 | 0; - x7 ^= u << 9 | u >>> (32 - 9); - u = x7 + x3 | 0; - x11 ^= u << 13 | u >>> (32 - 13); - u = x11 + x7 | 0; - x15 ^= u << 18 | u >>> (32 - 18); - u = x0 + x3 | 0; - x1 ^= u << 7 | u >>> (32 - 7); - u = x1 + x0 | 0; - x2 ^= u << 9 | u >>> (32 - 9); - u = x2 + x1 | 0; - x3 ^= u << 13 | u >>> (32 - 13); - u = x3 + x2 | 0; - x0 ^= u << 18 | u >>> (32 - 18); - u = x5 + x4 | 0; - x6 ^= u << 7 | u >>> (32 - 7); - u = x6 + x5 | 0; - x7 ^= u << 9 | u >>> (32 - 9); - u = x7 + x6 | 0; - x4 ^= u << 13 | u >>> (32 - 13); - u = x4 + x7 | 0; - x5 ^= u << 18 | u >>> (32 - 18); - u = x10 + x9 | 0; - x11 ^= u << 7 | u >>> (32 - 7); - u = x11 + x10 | 0; - x8 ^= u << 9 | u >>> (32 - 9); - u = x8 + x11 | 0; - x9 ^= u << 13 | u >>> (32 - 13); - u = x9 + x8 | 0; - x10 ^= u << 18 | u >>> (32 - 18); - u = x15 + x14 | 0; - x12 ^= u << 7 | u >>> (32 - 7); - u = x12 + x15 | 0; - x13 ^= u << 9 | u >>> (32 - 9); - u = x13 + x12 | 0; - x14 ^= u << 13 | u >>> (32 - 13); - u = x14 + x13 | 0; - x15 ^= u << 18 | u >>> (32 - 18); - } - x0 = x0 + j0 | 0; - x1 = x1 + j1 | 0; - x2 = x2 + j2 | 0; - x3 = x3 + j3 | 0; - x4 = x4 + j4 | 0; - x5 = x5 + j5 | 0; - x6 = x6 + j6 | 0; - x7 = x7 + j7 | 0; - x8 = x8 + j8 | 0; - x9 = x9 + j9 | 0; - x10 = x10 + j10 | 0; - x11 = x11 + j11 | 0; - x12 = x12 + j12 | 0; - x13 = x13 + j13 | 0; - x14 = x14 + j14 | 0; - x15 = x15 + j15 | 0; - o[0] = x0 >>> 0 & 0xff; - o[1] = x0 >>> 8 & 0xff; - o[2] = x0 >>> 16 & 0xff; - o[3] = x0 >>> 24 & 0xff; - o[4] = x1 >>> 0 & 0xff; - o[5] = x1 >>> 8 & 0xff; - o[6] = x1 >>> 16 & 0xff; - o[7] = x1 >>> 24 & 0xff; - o[8] = x2 >>> 0 & 0xff; - o[9] = x2 >>> 8 & 0xff; - o[10] = x2 >>> 16 & 0xff; - o[11] = x2 >>> 24 & 0xff; - o[12] = x3 >>> 0 & 0xff; - o[13] = x3 >>> 8 & 0xff; - o[14] = x3 >>> 16 & 0xff; - o[15] = x3 >>> 24 & 0xff; - o[16] = x4 >>> 0 & 0xff; - o[17] = x4 >>> 8 & 0xff; - o[18] = x4 >>> 16 & 0xff; - o[19] = x4 >>> 24 & 0xff; - o[20] = x5 >>> 0 & 0xff; - o[21] = x5 >>> 8 & 0xff; - o[22] = x5 >>> 16 & 0xff; - o[23] = x5 >>> 24 & 0xff; - o[24] = x6 >>> 0 & 0xff; - o[25] = x6 >>> 8 & 0xff; - o[26] = x6 >>> 16 & 0xff; - o[27] = x6 >>> 24 & 0xff; - o[28] = x7 >>> 0 & 0xff; - o[29] = x7 >>> 8 & 0xff; - o[30] = x7 >>> 16 & 0xff; - o[31] = x7 >>> 24 & 0xff; - o[32] = x8 >>> 0 & 0xff; - o[33] = x8 >>> 8 & 0xff; - o[34] = x8 >>> 16 & 0xff; - o[35] = x8 >>> 24 & 0xff; - o[36] = x9 >>> 0 & 0xff; - o[37] = x9 >>> 8 & 0xff; - o[38] = x9 >>> 16 & 0xff; - o[39] = x9 >>> 24 & 0xff; - o[40] = x10 >>> 0 & 0xff; - o[41] = x10 >>> 8 & 0xff; - o[42] = x10 >>> 16 & 0xff; - o[43] = x10 >>> 24 & 0xff; - o[44] = x11 >>> 0 & 0xff; - o[45] = x11 >>> 8 & 0xff; - o[46] = x11 >>> 16 & 0xff; - o[47] = x11 >>> 24 & 0xff; - o[48] = x12 >>> 0 & 0xff; - o[49] = x12 >>> 8 & 0xff; - o[50] = x12 >>> 16 & 0xff; - o[51] = x12 >>> 24 & 0xff; - o[52] = x13 >>> 0 & 0xff; - o[53] = x13 >>> 8 & 0xff; - o[54] = x13 >>> 16 & 0xff; - o[55] = x13 >>> 24 & 0xff; - o[56] = x14 >>> 0 & 0xff; - o[57] = x14 >>> 8 & 0xff; - o[58] = x14 >>> 16 & 0xff; - o[59] = x14 >>> 24 & 0xff; - o[60] = x15 >>> 0 & 0xff; - o[61] = x15 >>> 8 & 0xff; - o[62] = x15 >>> 16 & 0xff; - o[63] = x15 >>> 24 & 0xff; - } - exports._salsa20 = _salsa20; - function _hsalsa20(o, p, k, c) { - var j0 = c[0] & 0xff | (c[1] & 0xff) << 8 | (c[2] & 0xff) << 16 | (c[3] & 0xff) << 24, j1 = k[0] & 0xff | (k[1] & 0xff) << 8 | (k[2] & 0xff) << 16 | (k[3] & 0xff) << 24, j2 = k[4] & 0xff | (k[5] & 0xff) << 8 | (k[6] & 0xff) << 16 | (k[7] & 0xff) << 24, j3 = k[8] & 0xff | (k[9] & 0xff) << 8 | (k[10] & 0xff) << 16 | (k[11] & 0xff) << 24, j4 = k[12] & 0xff | (k[13] & 0xff) << 8 | (k[14] & 0xff) << 16 | (k[15] & 0xff) << 24, j5 = c[4] & 0xff | (c[5] & 0xff) << 8 | (c[6] & 0xff) << 16 | (c[7] & 0xff) << 24, j6 = p[0] & 0xff | (p[1] & 0xff) << 8 | (p[2] & 0xff) << 16 | (p[3] & 0xff) << 24, j7 = p[4] & 0xff | (p[5] & 0xff) << 8 | (p[6] & 0xff) << 16 | (p[7] & 0xff) << 24, j8 = p[8] & 0xff | (p[9] & 0xff) << 8 | (p[10] & 0xff) << 16 | (p[11] & 0xff) << 24, j9 = p[12] & 0xff | (p[13] & 0xff) << 8 | (p[14] & 0xff) << 16 | (p[15] & 0xff) << 24, j10 = c[8] & 0xff | (c[9] & 0xff) << 8 | (c[10] & 0xff) << 16 | (c[11] & 0xff) << 24, j11 = k[16] & 0xff | (k[17] & 0xff) << 8 | (k[18] & 0xff) << 16 | (k[19] & 0xff) << 24, j12 = k[20] & 0xff | (k[21] & 0xff) << 8 | (k[22] & 0xff) << 16 | (k[23] & 0xff) << 24, j13 = k[24] & 0xff | (k[25] & 0xff) << 8 | (k[26] & 0xff) << 16 | (k[27] & 0xff) << 24, j14 = k[28] & 0xff | (k[29] & 0xff) << 8 | (k[30] & 0xff) << 16 | (k[31] & 0xff) << 24, j15 = c[12] & 0xff | (c[13] & 0xff) << 8 | (c[14] & 0xff) << 16 | (c[15] & 0xff) << 24; - var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u; - for (var i = 0; i < 20; i += 2) { - u = x0 + x12 | 0; - x4 ^= u << 7 | u >>> (32 - 7); - u = x4 + x0 | 0; - x8 ^= u << 9 | u >>> (32 - 9); - u = x8 + x4 | 0; - x12 ^= u << 13 | u >>> (32 - 13); - u = x12 + x8 | 0; - x0 ^= u << 18 | u >>> (32 - 18); - u = x5 + x1 | 0; - x9 ^= u << 7 | u >>> (32 - 7); - u = x9 + x5 | 0; - x13 ^= u << 9 | u >>> (32 - 9); - u = x13 + x9 | 0; - x1 ^= u << 13 | u >>> (32 - 13); - u = x1 + x13 | 0; - x5 ^= u << 18 | u >>> (32 - 18); - u = x10 + x6 | 0; - x14 ^= u << 7 | u >>> (32 - 7); - u = x14 + x10 | 0; - x2 ^= u << 9 | u >>> (32 - 9); - u = x2 + x14 | 0; - x6 ^= u << 13 | u >>> (32 - 13); - u = x6 + x2 | 0; - x10 ^= u << 18 | u >>> (32 - 18); - u = x15 + x11 | 0; - x3 ^= u << 7 | u >>> (32 - 7); - u = x3 + x15 | 0; - x7 ^= u << 9 | u >>> (32 - 9); - u = x7 + x3 | 0; - x11 ^= u << 13 | u >>> (32 - 13); - u = x11 + x7 | 0; - x15 ^= u << 18 | u >>> (32 - 18); - u = x0 + x3 | 0; - x1 ^= u << 7 | u >>> (32 - 7); - u = x1 + x0 | 0; - x2 ^= u << 9 | u >>> (32 - 9); - u = x2 + x1 | 0; - x3 ^= u << 13 | u >>> (32 - 13); - u = x3 + x2 | 0; - x0 ^= u << 18 | u >>> (32 - 18); - u = x5 + x4 | 0; - x6 ^= u << 7 | u >>> (32 - 7); - u = x6 + x5 | 0; - x7 ^= u << 9 | u >>> (32 - 9); - u = x7 + x6 | 0; - x4 ^= u << 13 | u >>> (32 - 13); - u = x4 + x7 | 0; - x5 ^= u << 18 | u >>> (32 - 18); - u = x10 + x9 | 0; - x11 ^= u << 7 | u >>> (32 - 7); - u = x11 + x10 | 0; - x8 ^= u << 9 | u >>> (32 - 9); - u = x8 + x11 | 0; - x9 ^= u << 13 | u >>> (32 - 13); - u = x9 + x8 | 0; - x10 ^= u << 18 | u >>> (32 - 18); - u = x15 + x14 | 0; - x12 ^= u << 7 | u >>> (32 - 7); - u = x12 + x15 | 0; - x13 ^= u << 9 | u >>> (32 - 9); - u = x13 + x12 | 0; - x14 ^= u << 13 | u >>> (32 - 13); - u = x14 + x13 | 0; - x15 ^= u << 18 | u >>> (32 - 18); - } - o[0] = x0 >>> 0 & 0xff; - o[1] = x0 >>> 8 & 0xff; - o[2] = x0 >>> 16 & 0xff; - o[3] = x0 >>> 24 & 0xff; - o[4] = x5 >>> 0 & 0xff; - o[5] = x5 >>> 8 & 0xff; - o[6] = x5 >>> 16 & 0xff; - o[7] = x5 >>> 24 & 0xff; - o[8] = x10 >>> 0 & 0xff; - o[9] = x10 >>> 8 & 0xff; - o[10] = x10 >>> 16 & 0xff; - o[11] = x10 >>> 24 & 0xff; - o[12] = x15 >>> 0 & 0xff; - o[13] = x15 >>> 8 & 0xff; - o[14] = x15 >>> 16 & 0xff; - o[15] = x15 >>> 24 & 0xff; - o[16] = x6 >>> 0 & 0xff; - o[17] = x6 >>> 8 & 0xff; - o[18] = x6 >>> 16 & 0xff; - o[19] = x6 >>> 24 & 0xff; - o[20] = x7 >>> 0 & 0xff; - o[21] = x7 >>> 8 & 0xff; - o[22] = x7 >>> 16 & 0xff; - o[23] = x7 >>> 24 & 0xff; - o[24] = x8 >>> 0 & 0xff; - o[25] = x8 >>> 8 & 0xff; - o[26] = x8 >>> 16 & 0xff; - o[27] = x8 >>> 24 & 0xff; - o[28] = x9 >>> 0 & 0xff; - o[29] = x9 >>> 8 & 0xff; - o[30] = x9 >>> 16 & 0xff; - o[31] = x9 >>> 24 & 0xff; - } - exports._hsalsa20 = _hsalsa20; - exports._sigma = array_1.ByteArray([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); - // "expand 32-byte k" - function _stream_salsa20_xor(c, cpos, m, mpos, b, n, k) { - var z = array_1.ByteArray(16), x = array_1.ByteArray(64); - var u, i; - for (i = 0; i < 16; i++) - z[i] = 0; - for (i = 0; i < 8; i++) - z[i] = n[i]; - while (b >= 64) { - _salsa20(x, z, k, exports._sigma); - for (i = 0; i < 64; i++) - c[cpos + i] = m[mpos + i] ^ x[i]; - u = 1; - for (i = 8; i < 16; i++) { - u = u + (z[i] & 0xff) | 0; - z[i] = u & 0xff; - u >>>= 8; - } - b -= 64; - cpos += 64; - mpos += 64; - } - if (b > 0) { - _salsa20(x, z, k, exports._sigma); - for (i = 0; i < b; i++) - c[cpos + i] = m[mpos + i] ^ x[i]; - } - return 0; - } - function _stream_salsa20(c, cpos, b, n, k) { - var z = array_1.ByteArray(16), x = array_1.ByteArray(64); - var u, i; - for (i = 0; i < 16; i++) - z[i] = 0; - for (i = 0; i < 8; i++) - z[i] = n[i]; - while (b >= 64) { - _salsa20(x, z, k, exports._sigma); - for (i = 0; i < 64; i++) - c[cpos + i] = x[i]; - u = 1; - for (i = 8; i < 16; i++) { - u = u + (z[i] & 0xff) | 0; - z[i] = u & 0xff; - u >>>= 8; - } - b -= 64; - cpos += 64; - } - if (b > 0) { - _salsa20(x, z, k, exports._sigma); - for (i = 0; i < b; i++) - c[cpos + i] = x[i]; - } - return 0; - } - function _stream(c, cpos, d, n, k) { - var s = array_1.ByteArray(32), sn = array_1.ByteArray(8); - _hsalsa20(s, n, k, exports._sigma); - for (var i = 0; i < 8; i++) - sn[i] = n[i + 16]; - return _stream_salsa20(c, cpos, d, sn, s); - } - exports._stream = _stream; - function _stream_xor(c, cpos, m, mpos, d, n, k) { - var s = array_1.ByteArray(32), sn = array_1.ByteArray(8); - _hsalsa20(s, n, k, exports._sigma); - for (var i = 0; i < 8; i++) - sn[i] = n[i + 16]; - return _stream_salsa20_xor(c, cpos, m, mpos, d, sn, s); - } - exports._stream_xor = _stream_xor; - - },{"./array":141}],157:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var core_1 = require("./core"); - var curve25519_1 = require("./curve25519"); - var check_1 = require("./check"); - function scalarMult(n, p) { - check_1.checkArrayTypes(n, p); - if (n.length !== 32 /* Scalar */) - throw new Error('bad n size'); - if (p.length !== 32 /* GroupElement */) - throw new Error('bad p size'); - var q = array_1.ByteArray(32 /* GroupElement */); - _scalarMult(q, n, p); - return q; - } - exports.scalarMult = scalarMult; - function scalarMult_base(n) { - check_1.checkArrayTypes(n); - if (n.length !== 32 /* Scalar */) - throw new Error('bad n size'); - var q = array_1.ByteArray(32 /* GroupElement */); - _scalarMult_base(q, n); - return q; - } - exports.scalarMult_base = scalarMult_base; - // low level - function _scalarMult(q, n, p) { - var z = array_1.ByteArray(32); - var x = array_1.NumArray(80); - var a = core_1.gf(); - var b = core_1.gf(); - var c = core_1.gf(); - var d = core_1.gf(); - var e = core_1.gf(); - var f = core_1.gf(); - var r, i; - for (i = 0; i < 31; i++) - z[i] = n[i]; - z[31] = (n[31] & 127) | 64; - z[0] &= 248; - curve25519_1.unpack25519(x, p); - for (i = 0; i < 16; i++) { - b[i] = x[i]; - d[i] = a[i] = c[i] = 0; - } - a[0] = d[0] = 1; - for (i = 254; i >= 0; --i) { - r = (z[i >>> 3] >>> (i & 7)) & 1; - curve25519_1.sel25519(a, b, r); - curve25519_1.sel25519(c, d, r); - core_1.A(e, a, c); - core_1.Z(a, a, c); - core_1.A(c, b, d); - core_1.Z(b, b, d); - core_1.S(d, e); - core_1.S(f, a); - core_1.M(a, c, a); - core_1.M(c, b, e); - core_1.A(e, a, c); - core_1.Z(a, a, c); - core_1.S(b, a); - core_1.Z(c, d, f); - core_1.M(a, c, core_1._121665); - core_1.A(a, a, d); - core_1.M(c, c, a); - core_1.M(a, d, f); - core_1.M(d, b, x); - core_1.S(b, e); - curve25519_1.sel25519(a, b, r); - curve25519_1.sel25519(c, d, r); - } - for (i = 0; i < 16; i++) { - x[i + 16] = a[i]; - x[i + 32] = c[i]; - x[i + 48] = b[i]; - x[i + 64] = d[i]; - } - var x32 = x.subarray(32); - var x16 = x.subarray(16); - curve25519_1.inv25519(x32, x32); - core_1.M(x16, x16, x32); - curve25519_1.pack25519(q, x16); - return 0; - } - exports._scalarMult = _scalarMult; - function _scalarMult_base(q, n) { - return _scalarMult(q, n, core_1._9); - } - exports._scalarMult_base = _scalarMult_base; - - },{"./array":141,"./check":146,"./core":150,"./curve25519":151}],158:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var box_1 = require("./box"); - var blake2b_1 = require("./blake2b"); - function sealedbox(m, pk) { - var c = array_1.ByteArray(48 /* Overhead */ + m.length); - var ek = box_1.box_keyPair(); - c.set(ek.publicKey); - var nonce = nonce_gen(ek.publicKey, pk); - var boxed = box_1.box(m, nonce, pk, ek.secretKey); - c.set(boxed, ek.publicKey.length); - // clear secret key - for (var i = 0; i < ek.secretKey.length; i++) - ek.secretKey[i] = 0; - return c; - } - exports.sealedbox = sealedbox; - function sealedbox_open(c, pk, sk) { - if (c.length < 48 /* Overhead */) - return; - var epk = c.subarray(0, 32 /* PublicKey */); - var nonce = nonce_gen(epk, pk); - var boxData = c.subarray(32 /* PublicKey */); - return box_1.box_open(boxData, nonce, epk, sk); - } - exports.sealedbox_open = sealedbox_open; - function nonce_gen(pk1, pk2) { - var state = blake2b_1.blake2b_init(24 /* Nonce */); - blake2b_1.blake2b_update(state, pk1); - blake2b_1.blake2b_update(state, pk2); - return blake2b_1.blake2b_final(state); - } - - },{"./array":141,"./blake2b":143,"./box":145}],159:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var verify_1 = require("./verify"); - var salsa20_1 = require("./salsa20"); - var poly1305_1 = require("./poly1305"); - var check_1 = require("./check"); - function secretbox(msg, nonce, key) { - check_1.checkArrayTypes(msg, nonce, key); - check_1.checkLengths(key, nonce); - var m = array_1.ByteArray(32 /* Zero */ + msg.length); - var c = array_1.ByteArray(m.length); - for (var i = 0; i < msg.length; i++) - m[i + 32 /* Zero */] = msg[i]; - _secretbox(c, m, m.length, nonce, key); - return c.subarray(16 /* Overhead */); - } - exports.secretbox = secretbox; - function secretbox_open(box, nonce, key) { - check_1.checkArrayTypes(box, nonce, key); - check_1.checkLengths(key, nonce); - var c = array_1.ByteArray(16 /* Overhead */ + box.length); - var m = array_1.ByteArray(c.length); - for (var i = 0; i < box.length; i++) - c[i + 16 /* Overhead */] = box[i]; - if (c.length < 32 /* Zero */ || _secretbox_open(m, c, c.length, nonce, key) !== 0) - return; - return m.subarray(32 /* Zero */); - } - exports.secretbox_open = secretbox_open; - // low level - function _secretbox(c, m, d, n, k) { - if (d < 32) - return -1; - salsa20_1._stream_xor(c, 0, m, 0, d, n, k); - _onetimeauth(c, 16, c, 32, d - 32, c); - for (var i = 0; i < 16; i++) - c[i] = 0; - return 0; - } - function _secretbox_open(m, c, d, n, k) { - var x = array_1.ByteArray(32); - if (d < 32) - return -1; - salsa20_1._stream(x, 0, 32, n, k); - if (_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) - return -1; - salsa20_1._stream_xor(m, 0, c, 0, d, n, k); - for (var i = 0; i < 32; i++) - m[i] = 0; - return 0; - } - function _onetimeauth(out, outpos, m, mpos, n, k) { - var s = poly1305_1.poly1305_init(k); - poly1305_1.poly1305_update(s, m, mpos, n); - poly1305_1.poly1305_finish(s, out, outpos); - return 0; - } - exports._onetimeauth = _onetimeauth; - function _onetimeauth_verify(h, hpos, m, mpos, n, k) { - var x = array_1.ByteArray(16); - _onetimeauth(x, 0, m, mpos, n, k); - return verify_1._verify_16(h, hpos, x, 0); - } - - },{"./array":141,"./check":146,"./poly1305":154,"./salsa20":156,"./verify":162}],160:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var array_1 = require("./array"); - var verify_1 = require("./verify"); - var core_1 = require("./core"); - var random_1 = require("./random"); - var curve25519_1 = require("./curve25519"); - var hash_1 = require("./hash"); - var check_1 = require("./check"); - function sign(msg, secretKey) { - check_1.checkArrayTypes(msg, secretKey); - if (secretKey.length !== 64 /* SecretKey */) - throw new Error('bad secret key size'); - var signedMsg = array_1.ByteArray(64 /* Signature */ + msg.length); - _sign(signedMsg, msg, msg.length, secretKey); - return signedMsg; - } - exports.sign = sign; - function sign_open(signedMsg, publicKey) { - check_1.checkArrayTypes(signedMsg, publicKey); - if (publicKey.length !== 32 /* PublicKey */) - throw new Error('bad public key size'); - var tmp = array_1.ByteArray(signedMsg.length); - var mlen = _sign_open(tmp, signedMsg, signedMsg.length, publicKey); - if (mlen < 0) - return; - var m = array_1.ByteArray(mlen); - for (var i = 0; i < m.length; i++) - m[i] = tmp[i]; - return m; - } - exports.sign_open = sign_open; - function sign_detached(msg, secretKey) { - var signedMsg = sign(msg, secretKey); - var sig = array_1.ByteArray(64 /* Signature */); - for (var i = 0; i < sig.length; i++) - sig[i] = signedMsg[i]; - return sig; - } - exports.sign_detached = sign_detached; - function sign_detached_verify(msg, sig, publicKey) { - check_1.checkArrayTypes(msg, sig, publicKey); - if (sig.length !== 64 /* Signature */) - throw new Error('bad signature size'); - if (publicKey.length !== 32 /* PublicKey */) - throw new Error('bad public key size'); - var sm = array_1.ByteArray(64 /* Signature */ + msg.length); - var m = array_1.ByteArray(64 /* Signature */ + msg.length); - var i; - for (i = 0; i < 64 /* Signature */; i++) - sm[i] = sig[i]; - for (i = 0; i < msg.length; i++) - sm[i + 64 /* Signature */] = msg[i]; - return _sign_open(m, sm, sm.length, publicKey) >= 0; - } - exports.sign_detached_verify = sign_detached_verify; - function sign_keyPair() { - var pk = array_1.ByteArray(32 /* PublicKey */); - var sk = array_1.ByteArray(64 /* SecretKey */); - _sign_keypair(pk, sk, false); - return { publicKey: pk, secretKey: sk }; - } - exports.sign_keyPair = sign_keyPair; - function sign_keyPair_fromSecretKey(secretKey) { - check_1.checkArrayTypes(secretKey); - if (secretKey.length !== 64 /* SecretKey */) - throw new Error('bad secret key size'); - var pk = array_1.ByteArray(32 /* PublicKey */); - for (var i = 0; i < pk.length; i++) - pk[i] = secretKey[32 + i]; - return { publicKey: pk, secretKey: array_1.ByteArray(secretKey) }; - } - exports.sign_keyPair_fromSecretKey = sign_keyPair_fromSecretKey; - function sign_keyPair_fromSeed(seed) { - check_1.checkArrayTypes(seed); - if (seed.length !== 32 /* Seed */) - throw new Error('bad seed size'); - var pk = array_1.ByteArray(32 /* PublicKey */); - var sk = array_1.ByteArray(64 /* SecretKey */); - for (var i = 0; i < 32; i++) - sk[i] = seed[i]; - _sign_keypair(pk, sk, true); - return { publicKey: pk, secretKey: sk }; - } - exports.sign_keyPair_fromSeed = sign_keyPair_fromSeed; - // low level - function _sign_keypair(pk, sk, seeded) { - var d = array_1.ByteArray(64); - var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; - var i; - if (!seeded) - random_1._randomBytes(sk, 32); - hash_1._hash(d, sk, 32); - d[0] &= 248; - d[31] &= 127; - d[31] |= 64; - scalarbase(p, d); - pack(pk, p); - for (i = 0; i < 32; i++) - sk[i + 32] = pk[i]; - return 0; - } - // Note: difference from C - smlen returned, not passed as argument. - function _sign(sm, m, n, sk) { - var d = array_1.ByteArray(64), h = array_1.ByteArray(64), r = array_1.ByteArray(64); - var x = array_1.NumArray(64); - var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; - var i, j; - hash_1._hash(d, sk, 32); - d[0] &= 248; - d[31] &= 127; - d[31] |= 64; - var smlen = n + 64; - for (i = 0; i < n; i++) - sm[64 + i] = m[i]; - for (i = 0; i < 32; i++) - sm[32 + i] = d[32 + i]; - hash_1._hash(r, sm.subarray(32), n + 32); - reduce(r); - scalarbase(p, r); - pack(sm, p); - for (i = 32; i < 64; i++) - sm[i] = sk[i]; - hash_1._hash(h, sm, n + 64); - reduce(h); - for (i = 0; i < 64; i++) - x[i] = 0; - for (i = 0; i < 32; i++) - x[i] = r[i]; - for (i = 0; i < 32; i++) { - for (j = 0; j < 32; j++) { - x[i + j] += h[i] * d[j]; - } - } - modL(sm.subarray(32), x); - return smlen; - } - function _sign_open(m, sm, n, pk) { - var t = array_1.ByteArray(32), h = array_1.ByteArray(64); - var p = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()], q = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; - var i, mlen; - mlen = -1; - if (n < 64 || unpackneg(q, pk)) - return -1; - for (i = 0; i < n; i++) - m[i] = sm[i]; - for (i = 0; i < 32; i++) - m[i + 32] = pk[i]; - hash_1._hash(h, m, n); - reduce(h); - scalarmult(p, q, h); - scalarbase(q, sm.subarray(32)); - add(p, q); - pack(t, p); - n -= 64; - if (verify_1._verify_32(sm, 0, t, 0)) { - for (i = 0; i < n; i++) - m[i] = 0; - return -1; - } - for (i = 0; i < n; i++) - m[i] = sm[i + 64]; - mlen = n; - return mlen; - } - function scalarbase(p, s) { - var q = [core_1.gf(), core_1.gf(), core_1.gf(), core_1.gf()]; - curve25519_1.set25519(q[0], core_1.X); - curve25519_1.set25519(q[1], core_1.Y); - curve25519_1.set25519(q[2], core_1.gf1); - core_1.M(q[3], core_1.X, core_1.Y); - scalarmult(p, q, s); - } - exports.scalarbase = scalarbase; - function scalarmult(p, q, s) { - var b, i; - curve25519_1.set25519(p[0], core_1.gf0); - curve25519_1.set25519(p[1], core_1.gf1); - curve25519_1.set25519(p[2], core_1.gf1); - curve25519_1.set25519(p[3], core_1.gf0); - for (i = 255; i >= 0; --i) { - b = (s[(i / 8) | 0] >> (i & 7)) & 1; - cswap(p, q, b); - add(q, p); - add(p, p); - cswap(p, q, b); - } - } - exports.scalarmult = scalarmult; - function pack(r, p) { - var tx = core_1.gf(), ty = core_1.gf(), zi = core_1.gf(); - curve25519_1.inv25519(zi, p[2]); - core_1.M(tx, p[0], zi); - core_1.M(ty, p[1], zi); - curve25519_1.pack25519(r, ty); - r[31] ^= curve25519_1.par25519(tx) << 7; - } - function unpackneg(r, p) { - var t = core_1.gf(), chk = core_1.gf(), num = core_1.gf(), den = core_1.gf(), den2 = core_1.gf(), den4 = core_1.gf(), den6 = core_1.gf(); - curve25519_1.set25519(r[2], core_1.gf1); - curve25519_1.unpack25519(r[1], p); - core_1.S(num, r[1]); - core_1.M(den, num, core_1.D); - core_1.Z(num, num, r[2]); - core_1.A(den, r[2], den); - core_1.S(den2, den); - core_1.S(den4, den2); - core_1.M(den6, den4, den2); - core_1.M(t, den6, num); - core_1.M(t, t, den); - pow2523(t, t); - core_1.M(t, t, num); - core_1.M(t, t, den); - core_1.M(t, t, den); - core_1.M(r[0], t, den); - core_1.S(chk, r[0]); - core_1.M(chk, chk, den); - if (curve25519_1.neq25519(chk, num)) - core_1.M(r[0], r[0], core_1.I); - core_1.S(chk, r[0]); - core_1.M(chk, chk, den); - if (curve25519_1.neq25519(chk, num)) - return -1; - if (curve25519_1.par25519(r[0]) === (p[31] >> 7)) - core_1.Z(r[0], core_1.gf0, r[0]); - core_1.M(r[3], r[0], r[1]); - return 0; - } - function reduce(r) { - var x = array_1.NumArray(64); - var i; - for (i = 0; i < 64; i++) - x[i] = r[i]; - for (i = 0; i < 64; i++) - r[i] = 0; - modL(r, x); - } - var L = array_1.NumArray([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]); - function modL(r, x) { - var carry, i, j, k; - for (i = 63; i >= 32; --i) { - carry = 0; - for (j = i - 32, k = i - 12; j < k; ++j) { - x[j] += carry - 16 * x[i] * L[j - (i - 32)]; - carry = (x[j] + 128) >> 8; - x[j] -= carry * 256; - } - x[j] += carry; - x[i] = 0; - } - carry = 0; - for (j = 0; j < 32; j++) { - x[j] += carry - (x[31] >> 4) * L[j]; - carry = x[j] >> 8; - x[j] &= 255; - } - for (j = 0; j < 32; j++) - x[j] -= carry * L[j]; - for (i = 0; i < 32; i++) { - x[i + 1] += x[i] >> 8; - r[i] = x[i] & 255; - } - } - function add(p, q) { - var a = core_1.gf(), b = core_1.gf(), c = core_1.gf(), d = core_1.gf(), e = core_1.gf(), f = core_1.gf(), g = core_1.gf(), h = core_1.gf(), t = core_1.gf(); - core_1.Z(a, p[1], p[0]); - core_1.Z(t, q[1], q[0]); - core_1.M(a, a, t); - core_1.A(b, p[0], p[1]); - core_1.A(t, q[0], q[1]); - core_1.M(b, b, t); - core_1.M(c, p[3], q[3]); - core_1.M(c, c, core_1.D2); - core_1.M(d, p[2], q[2]); - core_1.A(d, d, d); - core_1.Z(e, b, a); - core_1.Z(f, d, c); - core_1.A(g, d, c); - core_1.A(h, b, a); - core_1.M(p[0], e, f); - core_1.M(p[1], h, g); - core_1.M(p[2], g, f); - core_1.M(p[3], e, h); - } - function cswap(p, q, b) { - for (var i = 0; i < 4; i++) { - curve25519_1.sel25519(p[i], q[i], b); - } - } - function pow2523(o, i) { - var c = core_1.gf(); - var a; - for (a = 0; a < 16; a++) - c[a] = i[a]; - for (a = 250; a >= 0; a--) { - core_1.S(c, c); - if (a !== 1) - core_1.M(c, c, i); - } - for (a = 0; a < 16; a++) - o[a] = c[a]; - } - - },{"./array":141,"./check":146,"./core":150,"./curve25519":151,"./hash":152,"./random":155,"./verify":162}],161:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function validateBase64(s) { - if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)) { - throw new TypeError('invalid base64 string'); - } - } - exports.validateBase64 = validateBase64; - function validateHex(s) { - if (!/^(?:[A-Fa-f0-9]{2})+$/.test(s)) { - throw new TypeError('invalid hex string'); - } - } - exports.validateHex = validateHex; - - },{}],162:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var check_1 = require("./check"); - function vn(x, xi, y, yi, n) { - var i, d = 0; - for (i = 0; i < n; i++) - d |= x[xi + i] ^ y[yi + i]; - return (1 & ((d - 1) >>> 8)) - 1; - } - function _verify_16(x, xi, y, yi) { - return vn(x, xi, y, yi, 16); - } - exports._verify_16 = _verify_16; - function _verify_32(x, xi, y, yi) { - return vn(x, xi, y, yi, 32); - } - exports._verify_32 = _verify_32; - function verify(x, y) { - check_1.checkArrayTypes(x, y); - // Zero length arguments are considered not equal - return x.length > 0 && y.length > 0 && - x.length == y.length && - vn(x, 0, y, 0, x.length) == 0; - } - exports.verify = verify; - - },{"./check":146}],163:[function(require,module,exports){ - (function (Buffer){(function (){ - // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri. - // Public domain. - (function(root, f) { - 'use strict'; - if (typeof module !== 'undefined' && module.exports) module.exports = f(); - else if (root.nacl) root.nacl.util = f(); - else { - root.nacl = {}; - root.nacl.util = f(); - } - }(this, function() { - 'use strict'; - - var util = {}; - - function validateBase64(s) { - if (!(/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s))) { - throw new TypeError('invalid encoding'); - } - } - - util.decodeUTF8 = function(s) { - if (typeof s !== 'string') throw new TypeError('expected string'); - var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - }; - - util.encodeUTF8 = function(arr) { - var i, s = []; - for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i])); - return decodeURIComponent(escape(s.join(''))); - }; - - if (typeof atob === 'undefined') { - // Node.js - - if (typeof Buffer.from !== 'undefined') { - // Node v6 and later - util.encodeBase64 = function (arr) { // v6 and later - return Buffer.from(arr).toString('base64'); - }; - - util.decodeBase64 = function (s) { - validateBase64(s); - return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0)); - }; - - } else { - // Node earlier than v6 - util.encodeBase64 = function (arr) { // v6 and later - return (new Buffer(arr)).toString('base64'); - }; - - util.decodeBase64 = function(s) { - validateBase64(s); - return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0)); - }; - } - - } else { - // Browsers - - util.encodeBase64 = function(arr) { - var i, s = [], len = arr.length; - for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i])); - return btoa(s.join('')); - }; - - util.decodeBase64 = function(s) { - validateBase64(s); - var i, d = atob(s), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - }; - - } - - return util; - - })); - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":222}],164:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Deserializer = exports.defaultTypeResolver = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function defaultTypeResolver(sourceObject, knownTypes) { - if (sourceObject.__type != null) { - return knownTypes.get(sourceObject.__type); - } - } - exports.defaultTypeResolver = defaultTypeResolver; - var Deserializer = (function () { - function Deserializer() { - this.typeResolver = defaultTypeResolver; - this.errorHandler = helpers_1.logError; - this.deserializationStrategy = new Map([ - [type_descriptor_1.AnyT.ctor, helpers_1.identity], - [Number, deserializeDirectly], - [String, deserializeDirectly], - [Boolean, deserializeDirectly], - [Date, deserializeDate], - [ArrayBuffer, stringToArrayBuffer], - [DataView, stringToDataView], - [Array, convertAsArray], - [Set, convertAsSet], - [Map, convertAsMap], - [Float32Array, convertAsFloatArray], - [Float64Array, convertAsFloatArray], - [Uint8Array, convertAsUintArray], - [Uint8ClampedArray, convertAsUintArray], - [Uint16Array, convertAsUintArray], - [Uint32Array, convertAsUintArray], - ]); - } - Deserializer.prototype.setDeserializationStrategy = function (type, deserializer) { - this.deserializationStrategy.set(type, deserializer); - }; - Deserializer.prototype.setNameResolver = function (nameResolverCallback) { - this.nameResolver = nameResolverCallback; - }; - Deserializer.prototype.setTypeResolver = function (typeResolverCallback) { - if (typeof typeResolverCallback !== 'function') { - throw new TypeError('\'typeResolverCallback\' is not a function.'); - } - this.typeResolver = typeResolverCallback; - }; - Deserializer.prototype.getTypeResolver = function () { - return this.typeResolver; - }; - Deserializer.prototype.setErrorHandler = function (errorHandlerCallback) { - if (typeof errorHandlerCallback !== 'function') { - throw new TypeError('\'errorHandlerCallback\' is not a function.'); - } - this.errorHandler = errorHandlerCallback; - }; - Deserializer.prototype.getErrorHandler = function () { - return this.errorHandler; - }; - Deserializer.prototype.convertSingleValue = function (sourceObject, typeDescriptor, knownTypes, memberName, memberOptions) { - if (memberName === void 0) { memberName = 'object'; } - if (this.retrievePreserveNull(memberOptions) && sourceObject === null) { - return null; - } - else if (!helpers_1.isValueDefined(sourceObject)) { - return; - } - var deserializer = this.deserializationStrategy.get(typeDescriptor.ctor); - if (deserializer !== undefined) { - return deserializer(sourceObject, typeDescriptor, knownTypes, memberName, this, memberOptions); - } - if (typeof sourceObject === 'object') { - return convertAsObject(sourceObject, typeDescriptor, knownTypes, memberName, this); - } - var error = "Could not deserialize '" + memberName + "'; don't know how to deserialize type"; - if (typeDescriptor.hasFriendlyName()) { - error += " '" + typeDescriptor.ctor.name + "'"; - } - this.errorHandler(new TypeError(error + ".")); - }; - Deserializer.prototype.instantiateType = function (ctor) { - return new ctor(); - }; - Deserializer.prototype.mergeKnownTypes = function () { - var _this = this; - var knownTypeMaps = []; - for (var _i = 0; _i < arguments.length; _i++) { - knownTypeMaps[_i] = arguments[_i]; - } - var result = new Map(); - knownTypeMaps.forEach(function (knownTypes) { - knownTypes.forEach(function (ctor, name) { - if (_this.nameResolver === undefined) { - result.set(name, ctor); - } - else { - result.set(_this.nameResolver(ctor), ctor); - } - }); - }); - return result; - }; - Deserializer.prototype.createKnownTypesMap = function (knowTypes) { - var _this = this; - var map = new Map(); - knowTypes.forEach(function (ctor) { - if (_this.nameResolver === undefined) { - var knownTypeMeta = metadata_1.JsonObjectMetadata.getFromConstructor(ctor); - var customName = (knownTypeMeta === null || knownTypeMeta === void 0 ? void 0 : knownTypeMeta.isExplicitlyMarked) === true - ? knownTypeMeta.name - : null; - map.set(customName !== null && customName !== void 0 ? customName : ctor.name, ctor); - } - else { - map.set(_this.nameResolver(ctor), ctor); - } - }); - return map; - }; - Deserializer.prototype.retrievePreserveNull = function (memberOptions) { - return options_base_1.getOptionValue('preserveNull', options_base_1.mergeOptions(this.options, memberOptions)); - }; - return Deserializer; - }()); - exports.Deserializer = Deserializer; - function throwTypeMismatchError(targetType, expectedSourceType, actualSourceType, memberName) { - throw new TypeError("Could not deserialize " + memberName + " as " + targetType + ":" - + (" expected " + expectedSourceType + ", got " + actualSourceType + ".")); - } - function makeTypeErrorMessage(expectedType, actualType, memberName) { - var expectedTypeName = typeof expectedType === 'function' - ? helpers_1.nameof(expectedType) - : expectedType; - var actualTypeName = typeof actualType === 'function' ? helpers_1.nameof(actualType) : actualType; - return "Could not deserialize " + memberName + ": expected '" + expectedTypeName + "'," - + (" got '" + actualTypeName + "'."); - } - function srcTypeNameForDebug(sourceObject) { - return sourceObject == null ? 'undefined' : helpers_1.nameof(sourceObject.constructor); - } - function deserializeDirectly(sourceObject, typeDescriptor, knownTypes, objectName) { - if (sourceObject.constructor !== typeDescriptor.ctor) { - throw new TypeError(makeTypeErrorMessage(helpers_1.nameof(typeDescriptor.ctor), sourceObject.constructor, objectName)); - } - return sourceObject; - } - function convertAsObject(sourceObject, typeDescriptor, knownTypes, memberName, deserializer) { - if (typeof sourceObject !== 'object' || sourceObject === null) { - deserializer.getErrorHandler()(new TypeError("Cannot deserialize " + memberName + ": 'sourceObject' must be a defined object.")); - return undefined; - } - var expectedSelfType = typeDescriptor.ctor; - var sourceObjectMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(expectedSelfType); - var knownTypeConstructors = knownTypes; - var typeResolver = deserializer.getTypeResolver(); - if (sourceObjectMetadata !== undefined) { - sourceObjectMetadata.processDeferredKnownTypes(); - knownTypeConstructors = deserializer.mergeKnownTypes(knownTypeConstructors, deserializer.createKnownTypesMap(sourceObjectMetadata.knownTypes)); - if (sourceObjectMetadata.typeResolver != null) { - typeResolver = sourceObjectMetadata.typeResolver; - } - } - var typeFromTypeHint = typeResolver(sourceObject, knownTypeConstructors); - if (typeFromTypeHint != null) { - if (helpers_1.isSubtypeOf(typeFromTypeHint, expectedSelfType)) { - expectedSelfType = typeFromTypeHint; - sourceObjectMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(typeFromTypeHint); - if (sourceObjectMetadata !== undefined) { - knownTypeConstructors = deserializer.mergeKnownTypes(knownTypeConstructors, deserializer.createKnownTypesMap(sourceObjectMetadata.knownTypes)); - } - } - } - if ((sourceObjectMetadata === null || sourceObjectMetadata === void 0 ? void 0 : sourceObjectMetadata.isExplicitlyMarked) === true) { - var sourceMetadata_1 = sourceObjectMetadata; - var sourceObjectWithDeserializedProperties_1 = {}; - var classOptions_1 = options_base_1.mergeOptions(deserializer.options, sourceMetadata_1.options); - sourceMetadata_1.dataMembers.forEach(function (objMemberMetadata, propKey) { - var objMemberValue = sourceObject[propKey]; - var objMemberDebugName = helpers_1.nameof(sourceMetadata_1.classType) + "." + propKey; - var objMemberOptions = options_base_1.mergeOptions(classOptions_1, objMemberMetadata.options); - var revivedValue; - if (objMemberMetadata.deserializer != null) { - revivedValue = objMemberMetadata.deserializer(objMemberValue); - } - else if (objMemberMetadata.type == null) { - throw new TypeError("Cannot deserialize " + objMemberDebugName + " there is" - + " no constructor nor deserialization function to use."); - } - else { - revivedValue = deserializer.convertSingleValue(objMemberValue, objMemberMetadata.type(), knownTypeConstructors, objMemberDebugName, objMemberOptions); - } - if (helpers_1.isValueDefined(revivedValue) - || (deserializer.retrievePreserveNull(objMemberOptions) - && revivedValue === null)) { - sourceObjectWithDeserializedProperties_1[objMemberMetadata.key] = revivedValue; - } - else if (objMemberMetadata.isRequired === true) { - deserializer.getErrorHandler()(new TypeError("Missing required member '" + objMemberDebugName + "'.")); - } - }); - var targetObject = void 0; - if (typeof sourceObjectMetadata.initializerCallback === 'function') { - try { - targetObject = sourceObjectMetadata.initializerCallback(sourceObjectWithDeserializedProperties_1, sourceObject); - if (targetObject == null) { - throw new TypeError("Cannot deserialize " + memberName + ":" - + " 'initializer' function returned undefined/null" - + (", but '" + helpers_1.nameof(sourceObjectMetadata.classType) + "' was expected.")); - } - else if (!(targetObject instanceof sourceObjectMetadata.classType)) { - throw new TypeError("Cannot deserialize " + memberName + ":" - + ("'initializer' returned '" + helpers_1.nameof(targetObject.constructor) + "'") - + (", but '" + helpers_1.nameof(sourceObjectMetadata.classType) + "' was expected") - + (", and '" + helpers_1.nameof(targetObject.constructor) + "' is not a subtype of") - + (" '" + helpers_1.nameof(sourceObjectMetadata.classType) + "'")); - } - } - catch (e) { - deserializer.getErrorHandler()(e); - return undefined; - } - } - else { - targetObject = deserializer.instantiateType(expectedSelfType); - } - Object.assign(targetObject, sourceObjectWithDeserializedProperties_1); - var methodName = sourceObjectMetadata.onDeserializedMethodName; - if (methodName != null) { - if (typeof targetObject[methodName] === 'function') { - targetObject[methodName](); - } - else if (typeof targetObject.constructor[methodName] === 'function') { - targetObject.constructor[methodName](); - } - else { - deserializer.getErrorHandler()(new TypeError("onDeserialized callback" - + ("'" + helpers_1.nameof(sourceObjectMetadata.classType) + "." + methodName + "' is not a method."))); - } - } - return targetObject; - } - else { - var targetObject_1 = {}; - Object.keys(sourceObject).forEach(function (sourceKey) { - targetObject_1[sourceKey] = deserializer.convertSingleValue(sourceObject[sourceKey], new type_descriptor_1.ConcreteTypeDescriptor(sourceObject[sourceKey].constructor), knownTypes, sourceKey); - }); - return targetObject_1; - } - } - function convertAsArray(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor)) { - throw new TypeError("Could not deserialize " + memberName + " as Array: incorrect TypeDescriptor detected," - + ' please use proper annotation or function for this type'); - } - if (!Array.isArray(sourceObject)) { - deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(Array, sourceObject.constructor, memberName))); - return []; - } - if (typeDescriptor.elementType == null) { - deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Array: missing constructor reference of" - + " Array elements.")); - return []; - } - return sourceObject.map(function (element, i) { - try { - return deserializer.convertSingleValue(element, typeDescriptor.elementType, knownTypes, memberName + "[" + i + "]", memberOptions); - } - catch (e) { - deserializer.getErrorHandler()(e); - return undefined; - } - }); - } - function convertAsSet(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor)) { - throw new TypeError("Could not deserialize " + memberName + " as Set: incorrect TypeDescriptor detected," - + " please use proper annotation or function for this type"); - } - if (!Array.isArray(sourceObject)) { - deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(Array, sourceObject.constructor, memberName))); - return new Set(); - } - if (typeDescriptor.elementType == null) { - deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Set: missing constructor reference of" - + " Set elements.")); - return new Set(); - } - var resultSet = new Set(); - sourceObject.forEach(function (element, i) { - try { - resultSet.add(deserializer.convertSingleValue(element, typeDescriptor.elementType, knownTypes, memberName + "[" + i + "]", memberOptions)); - } - catch (e) { - deserializer.getErrorHandler()(e); - } - }); - return resultSet; - } - function isExpectedMapShape(source, expectedShape) { - return (expectedShape === 0 && Array.isArray(source)) - || (expectedShape === 1 && typeof source === 'object'); - } - function convertAsMap(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor)) { - throw new TypeError("Could not deserialize " + memberName + " as Map: incorrect TypeDescriptor detected," - + 'please use proper annotation or function for this type'); - } - var expectedShape = typeDescriptor.getCompleteOptions().shape; - if (!isExpectedMapShape(sourceObject, expectedShape)) { - var expectedType = expectedShape === 0 ? Array : Object; - deserializer.getErrorHandler()(new TypeError(makeTypeErrorMessage(expectedType, sourceObject.constructor, memberName))); - return new Map(); - } - if (typeDescriptor.keyType == null) { - deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Map: missing key constructor.")); - return new Map(); - } - if (typeDescriptor.valueType == null) { - deserializer.getErrorHandler()(new TypeError("Could not deserialize " + memberName + " as Map: missing value constructor.")); - return new Map(); - } - var keyMemberName = memberName + "[].key"; - var valueMemberName = memberName + "[].value"; - var resultMap = new Map(); - if (expectedShape === 1) { - Object.keys(sourceObject).forEach(function (key) { - try { - var resultKey = deserializer.convertSingleValue(key, typeDescriptor.keyType, knownTypes, keyMemberName, memberOptions); - if (helpers_1.isValueDefined(resultKey)) { - resultMap.set(resultKey, deserializer.convertSingleValue(sourceObject[key], typeDescriptor.valueType, knownTypes, valueMemberName, memberOptions)); - } - } - catch (e) { - deserializer.getErrorHandler()(e); - } - }); - } - else { - sourceObject.forEach(function (element) { - try { - var key = deserializer.convertSingleValue(element.key, typeDescriptor.keyType, knownTypes, keyMemberName, memberOptions); - if (helpers_1.isValueDefined(key)) { - resultMap.set(key, deserializer.convertSingleValue(element.value, typeDescriptor.valueType, knownTypes, valueMemberName, memberOptions)); - } - } - catch (e) { - deserializer.getErrorHandler()(e); - } - }); - } - return resultMap; - } - function deserializeDate(sourceObject, typeDescriptor, knownTypes, memberName) { - if (typeof sourceObject === 'number') { - var isInteger = sourceObject % 1 === 0; - if (!isInteger) { - throw new TypeError("Could not deserialize " + memberName + " as Date:" - + " expected an integer, got a number with decimal places."); - } - return new Date(sourceObject); - } - else if (typeof sourceObject === 'string') { - return new Date(sourceObject); - } - else if (sourceObject instanceof Date) { - return sourceObject; - } - else { - throwTypeMismatchError('Date', 'an ISO-8601 string', srcTypeNameForDebug(sourceObject), memberName); - } - } - function stringToArrayBuffer(sourceObject, typeDescriptor, knownTypes, memberName) { - if (typeof sourceObject !== 'string') { - throwTypeMismatchError('ArrayBuffer', 'a string source', srcTypeNameForDebug(sourceObject), memberName); - } - return createArrayBufferFromString(sourceObject); - } - function stringToDataView(sourceObject, typeDescriptor, knownTypes, memberName) { - if (typeof sourceObject !== 'string') { - throwTypeMismatchError('DataView', 'a string source', srcTypeNameForDebug(sourceObject), memberName); - } - return new DataView(createArrayBufferFromString(sourceObject)); - } - function createArrayBufferFromString(input) { - var buf = new ArrayBuffer(input.length * 2); - var bufView = new Uint16Array(buf); - for (var i = 0, strLen = input.length; i < strLen; i++) { - bufView[i] = input.charCodeAt(i); - } - return buf; - } - function convertAsFloatArray(sourceObject, typeDescriptor, knownTypes, memberName) { - var constructor = typeDescriptor.ctor; - if (Array.isArray(sourceObject) && sourceObject.every(function (elem) { return !isNaN(elem); })) { - return new constructor(sourceObject); - } - return throwTypeMismatchError(constructor.name, 'a numeric source array', srcTypeNameForDebug(sourceObject), memberName); - } - function convertAsUintArray(sourceObject, typeDescriptor, knownTypes, memberName) { - var constructor = typeDescriptor.ctor; - if (Array.isArray(sourceObject) && sourceObject.every(function (elem) { return !isNaN(elem); })) { - return new constructor(sourceObject.map(function (value) { return ~~value; })); - } - return throwTypeMismatchError(typeDescriptor.ctor.name, 'a numeric source array', srcTypeNameForDebug(sourceObject), memberName); - } - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],165:[function(require,module,exports){ - "use strict"; - var __spreadArrays = (this && this.__spreadArrays) || function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.identity = exports.nameof = exports.isReflectMetadataSupported = exports.isInstanceOf = exports.isValueDefined = exports.logWarning = exports.logMessage = exports.logError = exports.isSubtypeOf = exports.parseToJSObject = exports.shouldOmitParseString = exports.isObject = exports.isTypeTypedArray = exports.isDirectlyDeserializableNativeType = exports.isDirectlySerializableNativeType = exports.MISSING_REFLECT_CONF_MSG = exports.LAZY_TYPE_EXPLANATION = void 0; - var type_descriptor_1 = require("./type-descriptor"); - exports.LAZY_TYPE_EXPLANATION = "If the type is not yet defined, for example due to circular references, add '() => ' before it. E.g. @jsonMember(() => Foo)"; - exports.MISSING_REFLECT_CONF_MSG = 'Make sure that you have both "experimentalDecorators"' - + ' and "emitDecoratorMetadata" enabled in your tsconfig.json'; - function isDirectlySerializableNativeType(type) { - return [Date, Number, String, Boolean].indexOf(type) !== -1; - } - exports.isDirectlySerializableNativeType = isDirectlySerializableNativeType; - function isDirectlyDeserializableNativeType(type) { - return [Number, String, Boolean].indexOf(type) !== -1; - } - exports.isDirectlyDeserializableNativeType = isDirectlyDeserializableNativeType; - function isTypeTypedArray(type) { - return [ - Float32Array, - Float64Array, - Int8Array, - Uint8Array, - Uint8ClampedArray, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - ].indexOf(type) !== -1; - } - exports.isTypeTypedArray = isTypeTypedArray; - function isObject(value) { - return typeof value === 'object'; - } - exports.isObject = isObject; - function shouldOmitParseString(jsonStr, expectedType) { - var expectsTypesSerializedAsStrings = expectedType === String - || expectedType === ArrayBuffer - || expectedType === DataView; - var hasQuotes = jsonStr.length >= 2 - && jsonStr[0] === '"' - && jsonStr[jsonStr.length - 1] === '"'; - if (expectedType === Date) { - var isNumber = !isNaN(Number(jsonStr.trim())); - return !hasQuotes && !isNumber; - } - return expectsTypesSerializedAsStrings && !hasQuotes; - } - exports.shouldOmitParseString = shouldOmitParseString; - function parseToJSObject(json, expectedType) { - if (typeof json !== 'string' || shouldOmitParseString(json, expectedType)) { - return json; - } - return JSON.parse(json); - } - exports.parseToJSObject = parseToJSObject; - function isSubtypeOf(A, B) { - return A === B || A.prototype instanceof B; - } - exports.isSubtypeOf = isSubtypeOf; - function logError(message) { - var optionalParams = []; - for (var _i = 1; _i < arguments.length; _i++) { - optionalParams[_i - 1] = arguments[_i]; - } - if (typeof console === 'object' && typeof console.error === 'function') { - console.error.apply(console, __spreadArrays([message], optionalParams)); - } - else if (typeof console === 'object' && typeof console.log === 'function') { - console.log.apply(console, __spreadArrays(["ERROR: " + message], optionalParams)); - } - } - exports.logError = logError; - function logMessage(message) { - var optionalParams = []; - for (var _i = 1; _i < arguments.length; _i++) { - optionalParams[_i - 1] = arguments[_i]; - } - if (typeof console === 'object' && typeof console.log === 'function') { - console.log.apply(console, __spreadArrays([message], optionalParams)); - } - } - exports.logMessage = logMessage; - function logWarning(message) { - var optionalParams = []; - for (var _i = 1; _i < arguments.length; _i++) { - optionalParams[_i - 1] = arguments[_i]; - } - if (typeof console === 'object' && typeof console.warn === 'function') { - console.warn.apply(console, __spreadArrays([message], optionalParams)); - } - else if (typeof console === 'object' && typeof console.log === 'function') { - console.log.apply(console, __spreadArrays(["WARNING: " + message], optionalParams)); - } - } - exports.logWarning = logWarning; - function isValueDefined(value) { - return !(typeof value === 'undefined' || value === null); - } - exports.isValueDefined = isValueDefined; - function isInstanceOf(value, constructor) { - if (constructor === type_descriptor_1.AnyT.ctor) { - return true; - } - else if (typeof value === 'number') { - return constructor === Number; - } - else if (typeof value === 'string') { - return constructor === String; - } - else if (typeof value === 'boolean') { - return constructor === Boolean; - } - else if (isObject(value)) { - return value instanceof constructor; - } - return false; - } - exports.isInstanceOf = isInstanceOf; - exports.isReflectMetadataSupported = typeof Reflect === 'object' && typeof Reflect.getMetadata === 'function'; - function nameof(fn) { - if (typeof fn.name === 'string') { - return fn.name; - } - return 'undefined'; - } - exports.nameof = nameof; - function identity(arg) { - return arg; - } - exports.identity = identity; - - },{"./type-descriptor":177}],166:[function(require,module,exports){ - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var parser_1 = require("./parser"); - Object.defineProperty(exports, "TypedJSON", { enumerable: true, get: function () { return parser_1.TypedJSON; } }); - Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return parser_1.defaultTypeResolver; } }); - Object.defineProperty(exports, "defaultTypeEmitter", { enumerable: true, get: function () { return parser_1.defaultTypeEmitter; } }); - var metadata_1 = require("./metadata"); - Object.defineProperty(exports, "JsonObjectMetadata", { enumerable: true, get: function () { return metadata_1.JsonObjectMetadata; } }); - var json_object_1 = require("./json-object"); - Object.defineProperty(exports, "jsonObject", { enumerable: true, get: function () { return json_object_1.jsonObject; } }); - var json_member_1 = require("./json-member"); - Object.defineProperty(exports, "jsonMember", { enumerable: true, get: function () { return json_member_1.jsonMember; } }); - var json_array_member_1 = require("./json-array-member"); - Object.defineProperty(exports, "jsonArrayMember", { enumerable: true, get: function () { return json_array_member_1.jsonArrayMember; } }); - var json_set_member_1 = require("./json-set-member"); - Object.defineProperty(exports, "jsonSetMember", { enumerable: true, get: function () { return json_set_member_1.jsonSetMember; } }); - var json_map_member_1 = require("./json-map-member"); - Object.defineProperty(exports, "jsonMapMember", { enumerable: true, get: function () { return json_map_member_1.jsonMapMember; } }); - var to_json_1 = require("./to-json"); - Object.defineProperty(exports, "toJson", { enumerable: true, get: function () { return to_json_1.toJson; } }); - var type_descriptor_1 = require("./type-descriptor"); - Object.defineProperty(exports, "ArrayT", { enumerable: true, get: function () { return type_descriptor_1.ArrayT; } }); - Object.defineProperty(exports, "AnyT", { enumerable: true, get: function () { return type_descriptor_1.AnyT; } }); - Object.defineProperty(exports, "SetT", { enumerable: true, get: function () { return type_descriptor_1.SetT; } }); - Object.defineProperty(exports, "MapT", { enumerable: true, get: function () { return type_descriptor_1.MapT; } }); - Object.defineProperty(exports, "SetTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.SetTypeDescriptor; } }); - Object.defineProperty(exports, "ArrayTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.ArrayTypeDescriptor; } }); - Object.defineProperty(exports, "MapTypeDescriptor", { enumerable: true, get: function () { return type_descriptor_1.MapTypeDescriptor; } }); - __exportStar(require("./types"), exports); - - },{"./json-array-member":167,"./json-map-member":168,"./json-member":169,"./json-object":170,"./json-set-member":171,"./metadata":172,"./parser":174,"./to-json":176,"./type-descriptor":177,"./types":178}],167:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.createArrayType = exports.jsonArrayMember = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function jsonArrayMember(maybeTypeThunk, options) { - if (options === void 0) { options = {}; } - return function (target, propKey) { - var _a; - var decoratorName = "@jsonArrayMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); - var typeThunk = type_descriptor_1.ensureTypeThunk(maybeTypeThunk, decoratorName); - var dimensions = options.dimensions == null ? 1 : options.dimensions; - if (!isNaN(dimensions) && dimensions < 1) { - helpers_1.logError(decoratorName + ": 'dimensions' option must be at least 1."); - return; - } - var reflectedType = helpers_1.isReflectMetadataSupported - ? Reflect.getMetadata('design:type', target, propKey) - : null; - if (reflectedType != null && reflectedType !== Array && reflectedType !== Object) { - helpers_1.logError(decoratorName + ": property is not an Array. " + helpers_1.MISSING_REFLECT_CONF_MSG); - return; - } - metadata_1.injectMetadataInformation(target, propKey, { - type: function () { return createArrayType(type_descriptor_1.ensureTypeDescriptor(typeThunk()), dimensions); }, - emitDefaultValue: options.emitDefaultValue, - isRequired: options.isRequired, - options: options_base_1.extractOptionBase(options), - key: propKey.toString(), - name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), - deserializer: options.deserializer, - serializer: options.serializer, - }); - }; - } - exports.jsonArrayMember = jsonArrayMember; - function createArrayType(elementType, dimensions) { - var type = new type_descriptor_1.ArrayTypeDescriptor(elementType); - for (var i = 1; i < dimensions; ++i) { - type = new type_descriptor_1.ArrayTypeDescriptor(type); - } - return type; - } - exports.createArrayType = createArrayType; - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],168:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.jsonMapMember = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function jsonMapMember(maybeKeyThunk, maybeValueThunk, options) { - if (options === void 0) { options = {}; } - return function (target, propKey) { - var _a; - var decoratorName = "@jsonMapMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); - var keyThunk = type_descriptor_1.ensureTypeThunk(maybeKeyThunk, decoratorName); - var valueThunk = type_descriptor_1.ensureTypeThunk(maybeValueThunk, decoratorName); - var reflectedType = helpers_1.isReflectMetadataSupported - ? Reflect.getMetadata('design:type', target, propKey) - : null; - if (reflectedType != null && reflectedType !== Map && reflectedType !== Object) { - helpers_1.logError(decoratorName + ": property is not a Map. " + helpers_1.MISSING_REFLECT_CONF_MSG); - return; - } - metadata_1.injectMetadataInformation(target, propKey, { - type: function () { return type_descriptor_1.MapT(keyThunk(), valueThunk(), { shape: options.shape }); }, - emitDefaultValue: options.emitDefaultValue, - isRequired: options.isRequired, - options: options_base_1.extractOptionBase(options), - key: propKey.toString(), - name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), - deserializer: options.deserializer, - serializer: options.serializer, - }); - }; - } - exports.jsonMapMember = jsonMapMember; - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],169:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.jsonMember = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function jsonMember(optionsOrPrototype, propertyKeyOrOptions) { - if (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') { - var property = propertyKeyOrOptions; - var prototype = optionsOrPrototype; - var decoratorName = "@jsonMember on " + helpers_1.nameof(prototype.constructor) + "." + String(property); - if (!helpers_1.isReflectMetadataSupported) { - helpers_1.logError(decoratorName + ": ReflectDecorators is required if the type is not explicitly provided with e.g. @jsonMember(Number)"); - return; - } - var reflectPropCtor = Reflect.getMetadata('design:type', prototype, property); - if (reflectPropCtor == null) { - helpers_1.logError(decoratorName + ": could not resolve detected property constructor at runtime. Potential solutions:\n - " + helpers_1.LAZY_TYPE_EXPLANATION + "\n - " + helpers_1.MISSING_REFLECT_CONF_MSG); - return; - } - var typeDescriptor_1 = type_descriptor_1.ensureTypeDescriptor(reflectPropCtor); - if (isSpecialPropertyType(decoratorName, typeDescriptor_1)) { - return; - } - metadata_1.injectMetadataInformation(prototype, property, { - type: function () { return typeDescriptor_1; }, - key: propertyKeyOrOptions.toString(), - name: propertyKeyOrOptions.toString(), - }); - return; - } - return jsonMemberDecoratorFactory(optionsOrPrototype, propertyKeyOrOptions); - } - exports.jsonMember = jsonMember; - function jsonMemberDecoratorFactory(optionsOrType, options) { - return function (target, property) { - var _a; - var decoratorName = "@jsonMember on " + helpers_1.nameof(target.constructor) + "." + String(property); - var typeThunk; - if (type_descriptor_1.isTypelike(optionsOrType) || type_descriptor_1.isTypeThunk(optionsOrType)) { - typeThunk = type_descriptor_1.ensureTypeThunk(optionsOrType, decoratorName); - } - else { - options = optionsOrType; - } - options = options !== null && options !== void 0 ? options : {}; - if (Object.prototype.hasOwnProperty.call(options, 'constructor')) { - if (typeThunk !== undefined) { - throw new Error('Cannot both define constructor option and type. Only one allowed.'); - } - if (!helpers_1.isValueDefined(options.constructor)) { - helpers_1.logError(decoratorName + ": cannot resolve specified property constructor at runtime. " + helpers_1.LAZY_TYPE_EXPLANATION); - return; - } - var newTypeDescriptor_1 = type_descriptor_1.ensureTypeDescriptor(options.constructor); - typeThunk = function () { return newTypeDescriptor_1; }; - if (helpers_1.isReflectMetadataSupported && !helpers_1.isSubtypeOf(newTypeDescriptor_1.ctor, Reflect.getMetadata('design:type', target, property))) { - helpers_1.logWarning(decoratorName + ": detected property type does not match" - + " 'constructor' option."); - } - } - else if (typeThunk !== undefined) { - } - else if (helpers_1.isReflectMetadataSupported) { - var reflectCtor_1 = Reflect.getMetadata('design:type', target, property); - if (reflectCtor_1 == null) { - helpers_1.logError(decoratorName + ": cannot resolve detected property constructor at runtime. " + helpers_1.LAZY_TYPE_EXPLANATION); - return; - } - typeThunk = function () { return type_descriptor_1.ensureTypeDescriptor(reflectCtor_1); }; - } - else if (options.deserializer === undefined) { - helpers_1.logError(decoratorName + ": Cannot determine type"); - return; - } - var typeToTest = typeThunk === null || typeThunk === void 0 ? void 0 : typeThunk(); - if (typeToTest !== undefined && isSpecialPropertyType(decoratorName, typeToTest)) { - return; - } - metadata_1.injectMetadataInformation(target, property, { - type: typeThunk === undefined - ? undefined - : function () { return type_descriptor_1.ensureTypeDescriptor(typeThunk()); }, - emitDefaultValue: options.emitDefaultValue, - isRequired: options.isRequired, - options: options_base_1.extractOptionBase(options), - key: property.toString(), - name: (_a = options.name) !== null && _a !== void 0 ? _a : property.toString(), - deserializer: options.deserializer, - serializer: options.serializer, - }); - }; - } - function isConstructorEqual(type, constructor) { - return type instanceof type_descriptor_1.TypeDescriptor ? type.ctor === constructor : type === constructor; - } - function isSpecialPropertyType(decoratorName, typeDescriptor) { - if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor) - && isConstructorEqual(typeDescriptor, Array)) { - helpers_1.logError(decoratorName + ": property is an Array. Use the jsonArrayMember decorator to" - + " serialize this property."); - return true; - } - if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor) && isConstructorEqual(typeDescriptor, Set)) { - helpers_1.logError(decoratorName + ": property is a Set. Use the jsonSetMember decorator to" - + " serialize this property."); - return true; - } - if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor) && isConstructorEqual(typeDescriptor, Map)) { - helpers_1.logError(decoratorName + ": property is a Map. Use the jsonMapMember decorator to" - + " serialize this property."); - return true; - } - return false; - } - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],170:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.jsonObject = void 0; - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - function jsonObject(optionsOrTarget) { - var options; - if (typeof optionsOrTarget === 'function') { - options = {}; - } - else { - options = optionsOrTarget !== null && optionsOrTarget !== void 0 ? optionsOrTarget : {}; - } - function decorator(target) { - var objectMetadata = metadata_1.JsonObjectMetadata.ensurePresentInPrototype(target.prototype); - objectMetadata.isExplicitlyMarked = true; - objectMetadata.onDeserializedMethodName = options.onDeserialized; - objectMetadata.beforeSerializationMethodName = options.beforeSerialization; - if (options.typeResolver != null) { - objectMetadata.typeResolver = options.typeResolver; - } - if (options.typeHintEmitter != null) { - objectMetadata.typeHintEmitter = options.typeHintEmitter; - } - objectMetadata.initializerCallback = options.initializer; - if (options.name != null) { - objectMetadata.name = options.name; - } - var optionsBase = options_base_1.extractOptionBase(options); - if (optionsBase !== undefined) { - objectMetadata.options = optionsBase; - } - if (options.knownTypes != null) { - options.knownTypes - .filter(function (knownType) { return Boolean(knownType); }) - .forEach(function (knownType) { return objectMetadata.knownTypes.add(knownType); }); - } - } - if (typeof optionsOrTarget === 'function') { - decorator(optionsOrTarget); - } - else { - return decorator; - } - } - exports.jsonObject = jsonObject; - - },{"./metadata":172,"./options-base":173}],171:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.jsonSetMember = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function jsonSetMember(maybeTypeThunk, options) { - if (options === void 0) { options = {}; } - return function (target, propKey) { - var _a; - var decoratorName = "@jsonSetMember on " + helpers_1.nameof(target.constructor) + "." + String(propKey); - var typeThunk = type_descriptor_1.ensureTypeThunk(maybeTypeThunk, decoratorName); - var reflectedType = helpers_1.isReflectMetadataSupported - ? Reflect.getMetadata('design:type', target, propKey) - : null; - if (reflectedType != null && reflectedType !== Set && reflectedType !== Object) { - helpers_1.logError(decoratorName + ": property is not a Set. " + helpers_1.MISSING_REFLECT_CONF_MSG); - return; - } - metadata_1.injectMetadataInformation(target, propKey, { - type: function () { return type_descriptor_1.SetT(typeThunk()); }, - emitDefaultValue: options.emitDefaultValue, - isRequired: options.isRequired, - options: options_base_1.extractOptionBase(options), - key: propKey.toString(), - name: (_a = options.name) !== null && _a !== void 0 ? _a : propKey.toString(), - deserializer: options.deserializer, - serializer: options.serializer, - }); - }; - } - exports.jsonSetMember = jsonSetMember; - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],172:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.injectMetadataInformation = exports.JsonObjectMetadata = exports.METADATA_FIELD_KEY = void 0; - var helpers_1 = require("./helpers"); - exports.METADATA_FIELD_KEY = '__typedJsonJsonObjectMetadataInformation__'; - var JsonObjectMetadata = (function () { - function JsonObjectMetadata(classType) { - this.dataMembers = new Map(); - this.knownTypes = new Set(); - this.knownTypesDeferred = []; - this.isExplicitlyMarked = false; - this.isHandledWithoutAnnotation = false; - this.classType = classType; - } - JsonObjectMetadata.getJsonObjectName = function (ctor) { - var metadata = JsonObjectMetadata.getFromConstructor(ctor); - return metadata === undefined ? helpers_1.nameof(ctor) : helpers_1.nameof(metadata.classType); - }; - JsonObjectMetadata.getFromConstructor = function (ctor) { - var prototype = ctor.prototype; - if (prototype == null) { - return; - } - var metadata; - if (Object.prototype.hasOwnProperty.call(prototype, exports.METADATA_FIELD_KEY)) { - metadata = prototype[exports.METADATA_FIELD_KEY]; - } - if ((metadata === null || metadata === void 0 ? void 0 : metadata.isExplicitlyMarked) === true) { - return metadata; - } - if (JsonObjectMetadata.doesHandleWithoutAnnotation(ctor)) { - var primitiveMeta = new JsonObjectMetadata(ctor); - primitiveMeta.isExplicitlyMarked = true; - return primitiveMeta; - } - }; - JsonObjectMetadata.ensurePresentInPrototype = function (prototype) { - if (Object.prototype.hasOwnProperty.call(prototype, exports.METADATA_FIELD_KEY)) { - return prototype[exports.METADATA_FIELD_KEY]; - } - var objectMetadata = new JsonObjectMetadata(prototype.constructor); - var parentMetadata = prototype[exports.METADATA_FIELD_KEY]; - if (parentMetadata !== undefined) { - parentMetadata.dataMembers.forEach(function (memberMetadata, propKey) { - objectMetadata.dataMembers.set(propKey, memberMetadata); - }); - parentMetadata.knownTypes.forEach(function (knownType) { - objectMetadata.knownTypes.add(knownType); - }); - objectMetadata.typeResolver = parentMetadata.typeResolver; - objectMetadata.typeHintEmitter = parentMetadata.typeHintEmitter; - } - Object.defineProperty(prototype, exports.METADATA_FIELD_KEY, { - enumerable: false, - configurable: false, - writable: false, - value: objectMetadata, - }); - return objectMetadata; - }; - JsonObjectMetadata.getKnownTypeNameFromType = function (constructor) { - var metadata = JsonObjectMetadata.getFromConstructor(constructor); - return metadata === undefined ? helpers_1.nameof(constructor) : helpers_1.nameof(metadata.classType); - }; - JsonObjectMetadata.doesHandleWithoutAnnotation = function (ctor) { - return helpers_1.isDirectlySerializableNativeType(ctor) || helpers_1.isTypeTypedArray(ctor) - || ctor === DataView || ctor === ArrayBuffer; - }; - JsonObjectMetadata.prototype.processDeferredKnownTypes = function () { - var _this = this; - this.knownTypesDeferred.forEach(function (typeThunk) { - typeThunk().getTypes().forEach(function (ctor) { return _this.knownTypes.add(ctor); }); - }); - this.knownTypesDeferred = []; - }; - return JsonObjectMetadata; - }()); - exports.JsonObjectMetadata = JsonObjectMetadata; - function injectMetadataInformation(prototype, propKey, metadata) { - var decoratorName = "@jsonMember on " + helpers_1.nameof(prototype.constructor) + "." + String(propKey); - if (typeof prototype === 'function') { - helpers_1.logError(decoratorName + ": cannot use a static property."); - return; - } - if (typeof prototype[propKey] === 'function') { - helpers_1.logError(decoratorName + ": cannot use a method property."); - return; - } - if (metadata == null - || (metadata.type === undefined && metadata.deserializer === undefined)) { - helpers_1.logError(decoratorName + ": JsonMemberMetadata has unknown type."); - return; - } - var objectMetadata = JsonObjectMetadata.ensurePresentInPrototype(prototype); - if (metadata.deserializer === undefined) { - objectMetadata.knownTypesDeferred.push(metadata.type); - } - Object.keys(metadata) - .forEach(function (key) { return (metadata[key] === undefined) && delete metadata[key]; }); - objectMetadata.dataMembers.set(metadata.name, metadata); - } - exports.injectMetadataInformation = injectMetadataInformation; - - },{"./helpers":165}],173:[function(require,module,exports){ - "use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.mergeOptions = exports.getOptionValue = exports.getDefaultOptionOf = exports.extractOptionBase = void 0; - var kAllOptions = [ - 'preserveNull', - ]; - function extractOptionBase(from) { - var options = Object.keys(from) - .filter(function (key) { return kAllOptions.indexOf(key) > -1; }) - .reduce(function (obj, key) { - obj[key] = from[key]; - return obj; - }, {}); - return Object.keys(options).length > 0 ? options : undefined; - } - exports.extractOptionBase = extractOptionBase; - function getDefaultOptionOf(key) { - switch (key) { - case 'preserveNull': - return false; - } - return null; - } - exports.getDefaultOptionOf = getDefaultOptionOf; - function getOptionValue(key, options) { - if (options != null && options[key] != null) { - return options[key]; - } - return getDefaultOptionOf(key); - } - exports.getOptionValue = getOptionValue; - function mergeOptions(existing, moreSpecific) { - return moreSpecific == null - ? existing - : __assign(__assign({}, existing), moreSpecific); - } - exports.mergeOptions = mergeOptions; - - },{}],174:[function(require,module,exports){ - "use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.TypedJSON = exports.defaultTypeEmitter = exports.defaultTypeResolver = void 0; - var deserializer_1 = require("./deserializer"); - Object.defineProperty(exports, "defaultTypeResolver", { enumerable: true, get: function () { return deserializer_1.defaultTypeResolver; } }); - var helpers_1 = require("./helpers"); - var json_array_member_1 = require("./json-array-member"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var serializer_1 = require("./serializer"); - Object.defineProperty(exports, "defaultTypeEmitter", { enumerable: true, get: function () { return serializer_1.defaultTypeEmitter; } }); - var type_descriptor_1 = require("./type-descriptor"); - var TypedJSON = (function () { - function TypedJSON(rootConstructor, settings) { - this.serializer = new serializer_1.Serializer(); - this.deserializer = new deserializer_1.Deserializer(); - this.globalKnownTypes = []; - this.indent = 0; - var rootMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(rootConstructor); - if (rootMetadata === undefined - || (!rootMetadata.isExplicitlyMarked && !rootMetadata.isHandledWithoutAnnotation)) { - throw new TypeError('The TypedJSON root data type must have the @jsonObject decorator used.'); - } - this.nameResolver = function (ctor) { return helpers_1.nameof(ctor); }; - this.rootConstructor = rootConstructor; - this.errorHandler = function (error) { return helpers_1.logError(error); }; - this.config(settings); - } - TypedJSON.parse = function (object, rootType, settings) { - return new TypedJSON(rootType, settings).parse(object); - }; - TypedJSON.parseAsArray = function (object, elementType, settings, dimensions) { - return new TypedJSON(elementType, settings).parseAsArray(object, dimensions); - }; - TypedJSON.parseAsSet = function (object, elementType, settings) { - return new TypedJSON(elementType, settings).parseAsSet(object); - }; - TypedJSON.parseAsMap = function (object, keyType, valueType, settings) { - return new TypedJSON(valueType, settings).parseAsMap(object, keyType); - }; - TypedJSON.toPlainJson = function (object, rootType, settings) { - return new TypedJSON(rootType, settings).toPlainJson(object); - }; - TypedJSON.toPlainArray = function (object, elementType, dimensions, settings) { - return new TypedJSON(elementType, settings).toPlainArray(object, dimensions); - }; - TypedJSON.toPlainSet = function (object, elementType, settings) { - return new TypedJSON(elementType, settings).toPlainSet(object); - }; - TypedJSON.toPlainMap = function (object, keyCtor, valueCtor, settings) { - return new TypedJSON(valueCtor, settings).toPlainMap(object, keyCtor); - }; - TypedJSON.stringify = function (object, rootType, settings) { - return new TypedJSON(rootType, settings).stringify(object); - }; - TypedJSON.stringifyAsArray = function (object, elementType, dimensions, settings) { - return new TypedJSON(elementType, settings).stringifyAsArray(object, dimensions); - }; - TypedJSON.stringifyAsSet = function (object, elementType, settings) { - return new TypedJSON(elementType, settings).stringifyAsSet(object); - }; - TypedJSON.stringifyAsMap = function (object, keyCtor, valueCtor, settings) { - return new TypedJSON(valueCtor, settings).stringifyAsMap(object, keyCtor); - }; - TypedJSON.setGlobalConfig = function (config) { - Object.assign(this._globalConfig, config); - }; - TypedJSON.mapType = function (type, converters) { - if (this._globalConfig.mappedTypes == null) { - this._globalConfig.mappedTypes = new Map(); - } - this._globalConfig.mappedTypes.set(type, converters); - }; - TypedJSON.prototype.config = function (settings) { - var _this = this; - settings = __assign(__assign({}, TypedJSON._globalConfig), settings); - if (settings.knownTypes != null - && TypedJSON._globalConfig.knownTypes != null) { - settings.knownTypes = Array.from(new Set(settings.knownTypes.concat(TypedJSON._globalConfig.knownTypes))); - } - var options = options_base_1.extractOptionBase(settings); - this.serializer.options = options; - this.deserializer.options = options; - if (settings.errorHandler != null) { - this.errorHandler = settings.errorHandler; - this.deserializer.setErrorHandler(settings.errorHandler); - this.serializer.setErrorHandler(settings.errorHandler); - } - if (settings.replacer != null) { - this.replacer = settings.replacer; - } - if (settings.typeResolver != null) { - this.deserializer.setTypeResolver(settings.typeResolver); - } - if (settings.typeHintEmitter != null) { - this.serializer.setTypeHintEmitter(settings.typeHintEmitter); - } - if (settings.indent != null) { - this.indent = settings.indent; - } - if (settings.mappedTypes != null) { - settings.mappedTypes.forEach(function (upDown, type) { - _this.setSerializationStrategies(type, upDown); - }); - } - if (settings.nameResolver != null) { - this.nameResolver = settings.nameResolver; - this.deserializer.setNameResolver(settings.nameResolver); - } - if (settings.knownTypes != null) { - settings.knownTypes.forEach(function (knownType, i) { - if (typeof knownType === 'undefined' || knownType === null) { - helpers_1.logWarning("TypedJSON.config: 'knownTypes' contains an undefined/null value" - + (" (element " + i + ").")); - } - }); - this.globalKnownTypes = settings.knownTypes; - } - }; - TypedJSON.prototype.mapType = function (type, converters) { - this.setSerializationStrategies(type, converters); - }; - TypedJSON.prototype.parse = function (object) { - var _this = this; - var json = helpers_1.parseToJSObject(object, this.rootConstructor); - var rootMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(this.rootConstructor); - var result; - var knownTypes = new Map(); - this.globalKnownTypes.filter(function (ktc) { return ktc; }).forEach(function (knownTypeCtor) { - knownTypes.set(_this.nameResolver(knownTypeCtor), knownTypeCtor); - }); - if (rootMetadata !== undefined) { - rootMetadata.processDeferredKnownTypes(); - rootMetadata.knownTypes.forEach(function (knownTypeCtor) { - knownTypes.set(_this.nameResolver(knownTypeCtor), knownTypeCtor); - }); - } - try { - result = this.deserializer.convertSingleValue(json, type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), knownTypes); - } - catch (e) { - this.errorHandler(e); - } - return result; - }; - TypedJSON.prototype.parseAsArray = function (object, dimensions) { - if (dimensions === void 0) { dimensions = 1; } - var json = helpers_1.parseToJSObject(object, Array); - return this.deserializer.convertSingleValue(json, json_array_member_1.createArrayType(type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), dimensions), this._mapKnownTypes(this.globalKnownTypes)); - }; - TypedJSON.prototype.parseAsSet = function (object) { - var json = helpers_1.parseToJSObject(object, Set); - return this.deserializer.convertSingleValue(json, type_descriptor_1.SetT(this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); - }; - TypedJSON.prototype.parseAsMap = function (object, keyConstructor) { - var json = helpers_1.parseToJSObject(object, Map); - return this.deserializer.convertSingleValue(json, type_descriptor_1.MapT(keyConstructor, this.rootConstructor), this._mapKnownTypes(this.globalKnownTypes)); - }; - TypedJSON.prototype.toPlainJson = function (object) { - try { - return this.serializer.convertSingleValue(object, type_descriptor_1.ensureTypeDescriptor(this.rootConstructor)); - } - catch (e) { - this.errorHandler(e); - } - }; - TypedJSON.prototype.toPlainArray = function (object, dimensions) { - if (dimensions === void 0) { dimensions = 1; } - try { - return this.serializer.convertSingleValue(object, json_array_member_1.createArrayType(type_descriptor_1.ensureTypeDescriptor(this.rootConstructor), dimensions)); - } - catch (e) { - this.errorHandler(e); - } - }; - TypedJSON.prototype.toPlainSet = function (object) { - try { - return this.serializer.convertSingleValue(object, type_descriptor_1.SetT(this.rootConstructor)); - } - catch (e) { - this.errorHandler(e); - } - }; - TypedJSON.prototype.toPlainMap = function (object, keyConstructor) { - try { - return this.serializer.convertSingleValue(object, type_descriptor_1.MapT(keyConstructor, this.rootConstructor)); - } - catch (e) { - this.errorHandler(e); - } - }; - TypedJSON.prototype.stringify = function (object) { - var result = this.toPlainJson(object); - if (result === undefined) { - return ''; - } - return JSON.stringify(result, this.replacer, this.indent); - }; - TypedJSON.prototype.stringifyAsArray = function (object, dimensions) { - return JSON.stringify(this.toPlainArray(object, dimensions), this.replacer, this.indent); - }; - TypedJSON.prototype.stringifyAsSet = function (object) { - return JSON.stringify(this.toPlainSet(object), this.replacer, this.indent); - }; - TypedJSON.prototype.stringifyAsMap = function (object, keyConstructor) { - return JSON.stringify(this.toPlainMap(object, keyConstructor), this.replacer, this.indent); - }; - TypedJSON.prototype._mapKnownTypes = function (constructors) { - var _this = this; - var map = new Map(); - constructors.filter(function (ctor) { return ctor; }).forEach(function (ctor) { return map.set(_this.nameResolver(ctor), ctor); }); - return map; - }; - TypedJSON.prototype.setSerializationStrategies = function (type, converters) { - if (converters.deserializer != null) { - this.deserializer.setDeserializationStrategy(type, function (value) { - return converters.deserializer(value); - }); - } - if (converters.serializer != null) { - this.serializer.setSerializationStrategy(type, function (value) { - return converters.serializer(value); - }); - } - }; - TypedJSON._globalConfig = {}; - return TypedJSON; - }()); - exports.TypedJSON = TypedJSON; - - },{"./deserializer":164,"./helpers":165,"./json-array-member":167,"./metadata":172,"./options-base":173,"./serializer":175,"./type-descriptor":177}],175:[function(require,module,exports){ - "use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Serializer = exports.defaultTypeEmitter = void 0; - var helpers_1 = require("./helpers"); - var metadata_1 = require("./metadata"); - var options_base_1 = require("./options-base"); - var type_descriptor_1 = require("./type-descriptor"); - function defaultTypeEmitter(targetObject, sourceObject, expectedSourceType, sourceTypeMetadata) { - var _a; - if (sourceObject.constructor !== expectedSourceType) { - targetObject.__type = (_a = sourceTypeMetadata === null || sourceTypeMetadata === void 0 ? void 0 : sourceTypeMetadata.name) !== null && _a !== void 0 ? _a : helpers_1.nameof(sourceObject.constructor); - } - } - exports.defaultTypeEmitter = defaultTypeEmitter; - var Serializer = (function () { - function Serializer() { - this.typeHintEmitter = defaultTypeEmitter; - this.errorHandler = helpers_1.logError; - this.serializationStrategy = new Map([ - [type_descriptor_1.AnyT.ctor, helpers_1.identity], - [Date, helpers_1.identity], - [Number, helpers_1.identity], - [String, helpers_1.identity], - [Boolean, helpers_1.identity], - [ArrayBuffer, convertAsArrayBuffer], - [DataView, convertAsDataView], - [Array, convertAsArray], - [Set, convertAsSet], - [Map, convertAsMap], - [Float32Array, convertAsTypedArray], - [Float64Array, convertAsTypedArray], - [Int8Array, convertAsTypedArray], - [Uint8Array, convertAsTypedArray], - [Uint8ClampedArray, convertAsTypedArray], - [Int16Array, convertAsTypedArray], - [Uint16Array, convertAsTypedArray], - [Int32Array, convertAsTypedArray], - [Uint32Array, convertAsTypedArray], - ]); - } - Serializer.prototype.setSerializationStrategy = function (type, serializer) { - this.serializationStrategy.set(type, serializer); - }; - Serializer.prototype.setTypeHintEmitter = function (typeEmitterCallback) { - if (typeof typeEmitterCallback !== 'function') { - throw new TypeError('\'typeEmitterCallback\' is not a function.'); - } - this.typeHintEmitter = typeEmitterCallback; - }; - Serializer.prototype.getTypeHintEmitter = function () { - return this.typeHintEmitter; - }; - Serializer.prototype.setErrorHandler = function (errorHandlerCallback) { - if (typeof errorHandlerCallback !== 'function') { - throw new TypeError('\'errorHandlerCallback\' is not a function.'); - } - this.errorHandler = errorHandlerCallback; - }; - Serializer.prototype.getErrorHandler = function () { - return this.errorHandler; - }; - Serializer.prototype.retrievePreserveNull = function (memberOptions) { - return options_base_1.getOptionValue('preserveNull', options_base_1.mergeOptions(this.options, memberOptions)); - }; - Serializer.prototype.convertSingleValue = function (sourceObject, typeDescriptor, memberName, memberOptions) { - if (memberName === void 0) { memberName = 'object'; } - if (this.retrievePreserveNull(memberOptions) && sourceObject === null) { - return null; - } - if (!helpers_1.isValueDefined(sourceObject)) { - return; - } - if (!helpers_1.isInstanceOf(sourceObject, typeDescriptor.ctor)) { - var expectedName = helpers_1.nameof(typeDescriptor.ctor); - var actualName = helpers_1.nameof(sourceObject.constructor); - this.errorHandler(new TypeError("Could not serialize '" + memberName + "': expected '" + expectedName + "'," - + (" got '" + actualName + "'."))); - return; - } - var serializer = this.serializationStrategy.get(typeDescriptor.ctor); - if (serializer !== undefined) { - return serializer(sourceObject, typeDescriptor, memberName, this, memberOptions); - } - if (typeof sourceObject === 'object') { - return convertAsObject(sourceObject, typeDescriptor, memberName, this, memberOptions); - } - var error = "Could not serialize '" + memberName + "'; don't know how to serialize type"; - if (typeDescriptor.hasFriendlyName()) { - error += " '" + typeDescriptor.ctor.name + "'"; - } - this.errorHandler(new TypeError(error + ".")); - }; - return Serializer; - }()); - exports.Serializer = Serializer; - function convertAsObject(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { - var sourceTypeMetadata; - var targetObject; - var typeHintEmitter = serializer.getTypeHintEmitter(); - if (sourceObject.constructor !== typeDescriptor.ctor - && sourceObject instanceof typeDescriptor.ctor) { - sourceTypeMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(sourceObject.constructor); - } - else { - sourceTypeMetadata = metadata_1.JsonObjectMetadata.getFromConstructor(typeDescriptor.ctor); - } - if (sourceTypeMetadata === undefined) { - targetObject = __assign({}, sourceObject); - } - else { - var beforeSerializationMethodName = sourceTypeMetadata.beforeSerializationMethodName; - if (beforeSerializationMethodName != null) { - if (typeof sourceObject[beforeSerializationMethodName] === 'function') { - sourceObject[beforeSerializationMethodName](); - } - else if (typeof sourceObject.constructor[beforeSerializationMethodName] - === 'function') { - sourceObject.constructor[beforeSerializationMethodName](); - } - else { - serializer.getErrorHandler()(new TypeError("beforeSerialization callback '" - + (helpers_1.nameof(sourceTypeMetadata.classType) + "." + beforeSerializationMethodName) - + "' is not a method.")); - } - } - var sourceMeta_1 = sourceTypeMetadata; - targetObject = {}; - var classOptions_1 = options_base_1.mergeOptions(serializer.options, sourceMeta_1.options); - if (sourceMeta_1.typeHintEmitter != null) { - typeHintEmitter = sourceMeta_1.typeHintEmitter; - } - sourceMeta_1.dataMembers.forEach(function (objMemberMetadata) { - var objMemberOptions = options_base_1.mergeOptions(classOptions_1, objMemberMetadata.options); - var serialized; - if (objMemberMetadata.serializer != null) { - serialized = objMemberMetadata.serializer(sourceObject[objMemberMetadata.key]); - } - else if (objMemberMetadata.type == null) { - throw new TypeError("Could not serialize " + objMemberMetadata.name + ", there is" - + " no constructor nor serialization function to use."); - } - else { - serialized = serializer.convertSingleValue(sourceObject[objMemberMetadata.key], objMemberMetadata.type(), helpers_1.nameof(sourceMeta_1.classType) + "." + objMemberMetadata.key, objMemberOptions); - } - if ((serializer.retrievePreserveNull(objMemberOptions) && serialized === null) - || helpers_1.isValueDefined(serialized)) { - targetObject[objMemberMetadata.name] = serialized; - } - }); - } - typeHintEmitter(targetObject, sourceObject, typeDescriptor.ctor, sourceTypeMetadata); - return targetObject; - } - function convertAsArray(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.ArrayTypeDescriptor)) { - throw new TypeError("Could not serialize " + memberName + " as Array: incorrect TypeDescriptor detected, please" - + ' use proper annotation or function for this type'); - } - if (typeDescriptor.elementType == null) { - throw new TypeError("Could not serialize " + memberName + " as Array: missing element type definition."); - } - sourceObject.forEach(function (element, i) { - if (!(serializer.retrievePreserveNull(memberOptions) && element === null) - && !helpers_1.isInstanceOf(element, typeDescriptor.elementType.ctor)) { - var expectedTypeName = helpers_1.nameof(typeDescriptor.elementType.ctor); - var actualTypeName = element && helpers_1.nameof(element.constructor); - throw new TypeError("Could not serialize " + memberName + "[" + i + "]:" - + (" expected '" + expectedTypeName + "', got '" + actualTypeName + "'.")); - } - }); - return sourceObject.map(function (element, i) { - return serializer.convertSingleValue(element, typeDescriptor.elementType, memberName + "[" + i + "]", memberOptions); - }); - } - function convertAsSet(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.SetTypeDescriptor)) { - throw new TypeError("Could not serialize " + memberName + " as Set: incorrect TypeDescriptor detected, please" - + ' use proper annotation or function for this type'); - } - if (typeDescriptor.elementType == null) { - throw new TypeError("Could not serialize " + memberName + " as Set: missing element type definition."); - } - memberName += '[]'; - var resultArray = []; - sourceObject.forEach(function (element) { - var resultElement = serializer.convertSingleValue(element, typeDescriptor.elementType, memberName, memberOptions); - if (!helpers_1.isValueDefined(element) || helpers_1.isValueDefined(resultElement)) { - resultArray.push(resultElement); - } - }); - return resultArray; - } - function convertAsMap(sourceObject, typeDescriptor, memberName, serializer, memberOptions) { - if (!(typeDescriptor instanceof type_descriptor_1.MapTypeDescriptor)) { - throw new TypeError("Could not serialize " + memberName + " as Map: incorrect TypeDescriptor detected, please" - + ' use proper annotation or function for this type'); - } - if (typeDescriptor.valueType == null) { - throw new TypeError("Could not serialize " + memberName + " as Map: missing value type definition."); - } - if (typeDescriptor.keyType == null) { - throw new TypeError("Could not serialize " + memberName + " as Map: missing key type definition."); - } - var keyMemberName = memberName + "[].key"; - var valueMemberName = memberName + "[].value"; - var resultShape = typeDescriptor.getCompleteOptions().shape; - var result = resultShape === 1 ? {} : []; - var preserveNull = serializer.retrievePreserveNull(memberOptions); - sourceObject.forEach(function (value, key) { - var resultKeyValuePairObj = { - key: serializer.convertSingleValue(key, typeDescriptor.keyType, keyMemberName, memberOptions), - value: serializer.convertSingleValue(value, typeDescriptor.valueType, valueMemberName, memberOptions), - }; - var keyDefined = helpers_1.isValueDefined(resultKeyValuePairObj.key); - var valueDefined = (resultKeyValuePairObj.value === null && preserveNull) - || helpers_1.isValueDefined(resultKeyValuePairObj.value); - if (keyDefined && valueDefined) { - if (resultShape === 1) { - result[resultKeyValuePairObj.key] = resultKeyValuePairObj.value; - } - else { - result.push(resultKeyValuePairObj); - } - } - }); - return result; - } - function convertAsTypedArray(sourceObject) { - return Array.from(sourceObject); - } - function convertAsArrayBuffer(buffer) { - return Array.from(new Uint16Array(buffer)) - .map(function (charCode) { return String.fromCharCode(charCode); }).join(''); - } - function convertAsDataView(dataView) { - return convertAsArrayBuffer(dataView.buffer); - } - - },{"./helpers":165,"./metadata":172,"./options-base":173,"./type-descriptor":177}],176:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.toJson = void 0; - var parser_1 = require("./parser"); - function toJson(optionsOrTarget) { - if (typeof optionsOrTarget === 'function') { - toJsonDecorator(optionsOrTarget, {}); - return; - } - return function (target) { - toJsonDecorator(target, optionsOrTarget); - }; - } - exports.toJson = toJson; - function toJsonDecorator(target, options) { - if (options.overwrite !== true && target.prototype.toJSON !== undefined) { - throw new Error(target.name + " already has toJSON defined!"); - } - target.prototype.toJSON = function toJSON() { - return parser_1.TypedJSON.toPlainJson(this, Object.getPrototypeOf(this).constructor); - }; - } - - },{"./parser":174}],177:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ensureTypeThunk = exports.ensureTypeDescriptor = exports.isTypeThunk = exports.isTypelike = exports.AnyT = exports.MapT = exports.MapTypeDescriptor = exports.SetT = exports.SetTypeDescriptor = exports.ArrayT = exports.ArrayTypeDescriptor = exports.GenericTypeDescriptor = exports.ConcreteTypeDescriptor = exports.TypeDescriptor = void 0; - var helpers_1 = require("./helpers"); - var TypeDescriptor = (function () { - function TypeDescriptor(ctor) { - this.ctor = ctor; - } - TypeDescriptor.prototype.getTypes = function () { - return [this.ctor]; - }; - TypeDescriptor.prototype.hasFriendlyName = function () { - return this.ctor.name !== 'Object'; - }; - return TypeDescriptor; - }()); - exports.TypeDescriptor = TypeDescriptor; - var ConcreteTypeDescriptor = (function (_super) { - __extends(ConcreteTypeDescriptor, _super); - function ConcreteTypeDescriptor(ctor) { - return _super.call(this, ctor) || this; - } - return ConcreteTypeDescriptor; - }(TypeDescriptor)); - exports.ConcreteTypeDescriptor = ConcreteTypeDescriptor; - var GenericTypeDescriptor = (function (_super) { - __extends(GenericTypeDescriptor, _super); - function GenericTypeDescriptor(ctor) { - return _super.call(this, ctor) || this; - } - return GenericTypeDescriptor; - }(TypeDescriptor)); - exports.GenericTypeDescriptor = GenericTypeDescriptor; - var ArrayTypeDescriptor = (function (_super) { - __extends(ArrayTypeDescriptor, _super); - function ArrayTypeDescriptor(elementType) { - var _this = _super.call(this, Array) || this; - _this.elementType = elementType; - return _this; - } - ArrayTypeDescriptor.prototype.getTypes = function () { - return _super.prototype.getTypes.call(this).concat(this.elementType.getTypes()); - }; - return ArrayTypeDescriptor; - }(GenericTypeDescriptor)); - exports.ArrayTypeDescriptor = ArrayTypeDescriptor; - function ArrayT(elementType) { - return new ArrayTypeDescriptor(ensureTypeDescriptor(elementType)); - } - exports.ArrayT = ArrayT; - var SetTypeDescriptor = (function (_super) { - __extends(SetTypeDescriptor, _super); - function SetTypeDescriptor(elementType) { - var _this = _super.call(this, Set) || this; - _this.elementType = elementType; - return _this; - } - SetTypeDescriptor.prototype.getTypes = function () { - return _super.prototype.getTypes.call(this).concat(this.elementType.getTypes()); - }; - return SetTypeDescriptor; - }(GenericTypeDescriptor)); - exports.SetTypeDescriptor = SetTypeDescriptor; - function SetT(elementType) { - return new SetTypeDescriptor(ensureTypeDescriptor(elementType)); - } - exports.SetT = SetT; - var MapTypeDescriptor = (function (_super) { - __extends(MapTypeDescriptor, _super); - function MapTypeDescriptor(keyType, valueType, options) { - var _this = _super.call(this, Map) || this; - _this.keyType = keyType; - _this.valueType = valueType; - _this.options = options; - return _this; - } - MapTypeDescriptor.prototype.getTypes = function () { - return _super.prototype.getTypes.call(this).concat(this.keyType.getTypes(), this.valueType.getTypes()); - }; - MapTypeDescriptor.prototype.getCompleteOptions = function () { - var _a, _b; - return { - shape: (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.shape) !== null && _b !== void 0 ? _b : 0, - }; - }; - return MapTypeDescriptor; - }(GenericTypeDescriptor)); - exports.MapTypeDescriptor = MapTypeDescriptor; - function MapT(keyType, valueType, options) { - return new MapTypeDescriptor(ensureTypeDescriptor(keyType), ensureTypeDescriptor(valueType), options); - } - exports.MapT = MapT; - exports.AnyT = new ConcreteTypeDescriptor(function () { return undefined; }); - function isTypelike(type) { - return type != null && (typeof type === 'function' || type instanceof TypeDescriptor); - } - exports.isTypelike = isTypelike; - function isTypeThunk(candidate) { - return typeof candidate === 'function' && candidate.name === ''; - } - exports.isTypeThunk = isTypeThunk; - function ensureTypeDescriptor(type) { - return type instanceof TypeDescriptor ? type : new ConcreteTypeDescriptor(type); - } - exports.ensureTypeDescriptor = ensureTypeDescriptor; - function ensureTypeThunk(typeThunkOrSerializable, decoratorName) { - if (typeThunkOrSerializable == null) { - throw new Error("No type given on " + decoratorName + ". " + helpers_1.LAZY_TYPE_EXPLANATION); - } - if (isTypeThunk(typeThunkOrSerializable)) { - return typeThunkOrSerializable; - } - return function () { return typeThunkOrSerializable; }; - } - exports.ensureTypeThunk = ensureTypeThunk; - - },{"./helpers":165}],178:[function(require,module,exports){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - - },{}],179:[function(require,module,exports){ - (function (global){(function (){ - - /** - * Module exports. - */ - - module.exports = deprecate; - - /** - * Mark that a method should not be used. - * Returns a modified function which warns once by default. - * - * If `localStorage.noDeprecation = true` is set, then it is a no-op. - * - * If `localStorage.throwDeprecation = true` is set, then deprecated functions - * will throw an Error when invoked. - * - * If `localStorage.traceDeprecation = true` is set, then deprecated functions - * will invoke `console.trace()` instead of `console.error()`. - * - * @param {Function} fn - the function to deprecate - * @param {String} msg - the string to print to the console when `fn` is invoked - * @returns {Function} a new "deprecated" version of `fn` - * @api public - */ - - function deprecate (fn, msg) { - if (config('noDeprecation')) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (config('throwDeprecation')) { - throw new Error(msg); - } else if (config('traceDeprecation')) { - console.trace(msg); - } else { - console.warn(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; - } - - /** - * Checks `localStorage` for boolean values for the given `name`. - * - * @param {String} name - * @returns {Boolean} - * @api private - */ - - function config (name) { - // accessing global.localStorage can trigger a DOMException in sandboxed iframes - try { - if (!global.localStorage) return false; - } catch (_) { - return false; - } - var val = global.localStorage[name]; - if (null == val) return false; - return String(val).toLowerCase() === 'true'; - } - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{}],180:[function(require,module,exports){ - (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.WHATWGFetch = {}))); - }(this, (function (exports) { 'use strict'; - - var global = - (typeof globalThis !== 'undefined' && globalThis) || - (typeof self !== 'undefined' && self) || - (typeof global !== 'undefined' && global); - - var support = { - searchParams: 'URLSearchParams' in global, - iterable: 'Symbol' in global && 'iterator' in Symbol, - blob: - 'FileReader' in global && - 'Blob' in global && - (function() { - try { - new Blob(); - return true - } catch (e) { - return false - } - })(), - formData: 'FormData' in global, - arrayBuffer: 'ArrayBuffer' in global - }; - - function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj) - } - - if (support.arrayBuffer) { - var viewClasses = [ - '[object Int8Array]', - '[object Uint8Array]', - '[object Uint8ClampedArray]', - '[object Int16Array]', - '[object Uint16Array]', - '[object Int32Array]', - '[object Uint32Array]', - '[object Float32Array]', - '[object Float64Array]' - ]; - - var isArrayBufferView = - ArrayBuffer.isView || - function(obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 - }; - } - - function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name); - } - if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { - throw new TypeError('Invalid character in header field name: "' + name + '"') - } - return name.toLowerCase() - } - - function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value); - } - return value - } - - // Build a destructive iterator for the value list - function iteratorFor(items) { - var iterator = { - next: function() { - var value = items.shift(); - return {done: value === undefined, value: value} - } - }; - - if (support.iterable) { - iterator[Symbol.iterator] = function() { - return iterator - }; - } - - return iterator - } - - function Headers(headers) { - this.map = {}; - - if (headers instanceof Headers) { - headers.forEach(function(value, name) { - this.append(name, value); - }, this); - } else if (Array.isArray(headers)) { - headers.forEach(function(header) { - this.append(header[0], header[1]); - }, this); - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]); - }, this); - } - } - - Headers.prototype.append = function(name, value) { - name = normalizeName(name); - value = normalizeValue(value); - var oldValue = this.map[name]; - this.map[name] = oldValue ? oldValue + ', ' + value : value; - }; - - Headers.prototype['delete'] = function(name) { - delete this.map[normalizeName(name)]; - }; - - Headers.prototype.get = function(name) { - name = normalizeName(name); - return this.has(name) ? this.map[name] : null - }; - - Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - }; - - Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = normalizeValue(value); - }; - - Headers.prototype.forEach = function(callback, thisArg) { - for (var name in this.map) { - if (this.map.hasOwnProperty(name)) { - callback.call(thisArg, this.map[name], name, this); - } - } - }; - - Headers.prototype.keys = function() { - var items = []; - this.forEach(function(value, name) { - items.push(name); - }); - return iteratorFor(items) - }; - - Headers.prototype.values = function() { - var items = []; - this.forEach(function(value) { - items.push(value); - }); - return iteratorFor(items) - }; - - Headers.prototype.entries = function() { - var items = []; - this.forEach(function(value, name) { - items.push([name, value]); - }); - return iteratorFor(items) - }; - - if (support.iterable) { - Headers.prototype[Symbol.iterator] = Headers.prototype.entries; - } - - function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')) - } - body.bodyUsed = true; - } - - function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result); - }; - reader.onerror = function() { - reject(reader.error); - }; - }) - } - - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsArrayBuffer(blob); - return promise - } - - function readBlobAsText(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsText(blob); - return promise - } - - function readArrayBufferAsText(buf) { - var view = new Uint8Array(buf); - var chars = new Array(view.length); - - for (var i = 0; i < view.length; i++) { - chars[i] = String.fromCharCode(view[i]); - } - return chars.join('') - } - - function bufferClone(buf) { - if (buf.slice) { - return buf.slice(0) - } else { - var view = new Uint8Array(buf.byteLength); - view.set(new Uint8Array(buf)); - return view.buffer - } - } - - function Body() { - this.bodyUsed = false; - - this._initBody = function(body) { - /* - fetch-mock wraps the Response object in an ES6 Proxy to - provide useful test harness features such as flush. However, on - ES5 browsers without fetch or Proxy support pollyfills must be used; - the proxy-pollyfill is unable to proxy an attribute unless it exists - on the object before the Proxy is created. This change ensures - Response.bodyUsed exists on the instance, while maintaining the - semantic of setting Request.bodyUsed in the constructor before - _initBody is called. - */ - this.bodyUsed = this.bodyUsed; - this._bodyInit = body; - if (!body) { - this._bodyText = ''; - } else if (typeof body === 'string') { - this._bodyText = body; - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body; - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body; - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this._bodyText = body.toString(); - } else if (support.arrayBuffer && support.blob && isDataView(body)) { - this._bodyArrayBuffer = bufferClone(body.buffer); - // IE 10-11 can't handle a DataView body. - this._bodyInit = new Blob([this._bodyArrayBuffer]); - } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { - this._bodyArrayBuffer = bufferClone(body); - } else { - this._bodyText = body = Object.prototype.toString.call(body); - } - - if (!this.headers.get('content-type')) { - if (typeof body === 'string') { - this.headers.set('content-type', 'text/plain;charset=UTF-8'); - } else if (this._bodyBlob && this._bodyBlob.type) { - this.headers.set('content-type', this._bodyBlob.type); - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); - } - } - }; - - if (support.blob) { - this.blob = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(new Blob([this._bodyArrayBuffer])) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob') - } else { - return Promise.resolve(new Blob([this._bodyText])) - } - }; - - this.arrayBuffer = function() { - if (this._bodyArrayBuffer) { - var isConsumed = consumed(this); - if (isConsumed) { - return isConsumed - } - if (ArrayBuffer.isView(this._bodyArrayBuffer)) { - return Promise.resolve( - this._bodyArrayBuffer.buffer.slice( - this._bodyArrayBuffer.byteOffset, - this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength - ) - ) - } else { - return Promise.resolve(this._bodyArrayBuffer) - } - } else { - return this.blob().then(readBlobAsArrayBuffer) - } - }; - } - - this.text = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text') - } else { - return Promise.resolve(this._bodyText) - } - }; - - if (support.formData) { - this.formData = function() { - return this.text().then(decode) - }; - } - - this.json = function() { - return this.text().then(JSON.parse) - }; - - return this - } - - // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - - function normalizeMethod(method) { - var upcased = method.toUpperCase(); - return methods.indexOf(upcased) > -1 ? upcased : method - } - - function Request(input, options) { - if (!(this instanceof Request)) { - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') - } - - options = options || {}; - var body = options.body; - - if (input instanceof Request) { - if (input.bodyUsed) { - throw new TypeError('Already read') - } - this.url = input.url; - this.credentials = input.credentials; - if (!options.headers) { - this.headers = new Headers(input.headers); - } - this.method = input.method; - this.mode = input.mode; - this.signal = input.signal; - if (!body && input._bodyInit != null) { - body = input._bodyInit; - input.bodyUsed = true; - } - } else { - this.url = String(input); - } - - this.credentials = options.credentials || this.credentials || 'same-origin'; - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers); - } - this.method = normalizeMethod(options.method || this.method || 'GET'); - this.mode = options.mode || this.mode || null; - this.signal = options.signal || this.signal; - this.referrer = null; - - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests') - } - this._initBody(body); - - if (this.method === 'GET' || this.method === 'HEAD') { - if (options.cache === 'no-store' || options.cache === 'no-cache') { - // Search for a '_' parameter in the query string - var reParamSearch = /([?&])_=[^&]*/; - if (reParamSearch.test(this.url)) { - // If it already exists then set the value with the current time - this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); - } else { - // Otherwise add a new '_' parameter to the end with the current time - var reQueryString = /\?/; - this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); - } - } - } - } - - Request.prototype.clone = function() { - return new Request(this, {body: this._bodyInit}) - }; - - function decode(body) { - var form = new FormData(); - body - .trim() - .split('&') - .forEach(function(bytes) { - if (bytes) { - var split = bytes.split('='); - var name = split.shift().replace(/\+/g, ' '); - var value = split.join('=').replace(/\+/g, ' '); - form.append(decodeURIComponent(name), decodeURIComponent(value)); - } - }); - return form - } - - function parseHeaders(rawHeaders) { - var headers = new Headers(); - // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space - // https://tools.ietf.org/html/rfc7230#section-3.2 - var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); - // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill - // https://github.com/github/fetch/issues/748 - // https://github.com/zloirock/core-js/issues/751 - preProcessedHeaders - .split('\r') - .map(function(header) { - return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header - }) - .forEach(function(line) { - var parts = line.split(':'); - var key = parts.shift().trim(); - if (key) { - var value = parts.join(':').trim(); - headers.append(key, value); - } - }); - return headers - } - - Body.call(Request.prototype); - - function Response(bodyInit, options) { - if (!(this instanceof Response)) { - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') - } - if (!options) { - options = {}; - } - - this.type = 'default'; - this.status = options.status === undefined ? 200 : options.status; - this.ok = this.status >= 200 && this.status < 300; - this.statusText = options.statusText === undefined ? '' : '' + options.statusText; - this.headers = new Headers(options.headers); - this.url = options.url || ''; - this._initBody(bodyInit); - } - - Body.call(Response.prototype); - - Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - }; - - Response.error = function() { - var response = new Response(null, {status: 0, statusText: ''}); - response.type = 'error'; - return response - }; - - var redirectStatuses = [301, 302, 303, 307, 308]; - - Response.redirect = function(url, status) { - if (redirectStatuses.indexOf(status) === -1) { - throw new RangeError('Invalid status code') - } - - return new Response(null, {status: status, headers: {location: url}}) - }; - - exports.DOMException = global.DOMException; - try { - new exports.DOMException(); - } catch (err) { - exports.DOMException = function(message, name) { - this.message = message; - this.name = name; - var error = Error(message); - this.stack = error.stack; - }; - exports.DOMException.prototype = Object.create(Error.prototype); - exports.DOMException.prototype.constructor = exports.DOMException; - } - - function fetch(input, init) { - return new Promise(function(resolve, reject) { - var request = new Request(input, init); - - if (request.signal && request.signal.aborted) { - return reject(new exports.DOMException('Aborted', 'AbortError')) - } - - var xhr = new XMLHttpRequest(); - - function abortXhr() { - xhr.abort(); - } - - xhr.onload = function() { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') - }; - options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); - var body = 'response' in xhr ? xhr.response : xhr.responseText; - setTimeout(function() { - resolve(new Response(body, options)); - }, 0); - }; - - xhr.onerror = function() { - setTimeout(function() { - reject(new TypeError('Network request failed')); - }, 0); - }; - - xhr.ontimeout = function() { - setTimeout(function() { - reject(new TypeError('Network request failed')); - }, 0); - }; - - xhr.onabort = function() { - setTimeout(function() { - reject(new exports.DOMException('Aborted', 'AbortError')); - }, 0); - }; - - function fixUrl(url) { - try { - return url === '' && global.location.href ? global.location.href : url - } catch (e) { - return url - } - } - - xhr.open(request.method, fixUrl(request.url), true); - - if (request.credentials === 'include') { - xhr.withCredentials = true; - } else if (request.credentials === 'omit') { - xhr.withCredentials = false; - } - - if ('responseType' in xhr) { - if (support.blob) { - xhr.responseType = 'blob'; - } else if ( - support.arrayBuffer && - request.headers.get('Content-Type') && - request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 - ) { - xhr.responseType = 'arraybuffer'; - } - } - - if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { - Object.getOwnPropertyNames(init.headers).forEach(function(name) { - xhr.setRequestHeader(name, normalizeValue(init.headers[name])); - }); - } else { - request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value); - }); - } - - if (request.signal) { - request.signal.addEventListener('abort', abortXhr); - - xhr.onreadystatechange = function() { - // DONE (success or failure) - if (xhr.readyState === 4) { - request.signal.removeEventListener('abort', abortXhr); - } - }; - } - - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); - }) - } - - fetch.polyfill = true; - - if (!global.fetch) { - global.fetch = fetch; - global.Headers = Headers; - global.Request = Request; - global.Response = Response; - } - - exports.Headers = Headers; - exports.Request = Request; - exports.Response = Response; - exports.fetch = fetch; - - Object.defineProperty(exports, '__esModule', { value: true }); - - }))); - - },{}],181:[function(require,module,exports){ - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - __exportStar(require("./services"), exports); - __exportStar(require("./lib"), exports); - var Conversions_1 = require("./lib/Conversions"); - Object.defineProperty(exports, "base64to16", { enumerable: true, get: function () { return Conversions_1.base64to16; } }); - Object.defineProperty(exports, "encodeBase16", { enumerable: true, get: function () { return Conversions_1.encodeBase16; } }); - Object.defineProperty(exports, "decodeBase16", { enumerable: true, get: function () { return Conversions_1.decodeBase16; } }); - Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return Conversions_1.encodeBase64; } }); - Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return Conversions_1.decodeBase64; } }); - - },{"./lib":194,"./lib/Conversions":186,"./services":198}],182:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.URef = exports.AccessRights = exports.KeyValue = exports.AccountHash = exports.KeyVariant = exports.CLValue = exports.CLTypedAndToBytesHelper = exports.CLTypeHelper = exports.OptionType = exports.MapValue = exports.PublicKey = exports.Tuple3 = exports.Tuple2 = exports.Tuple1 = exports.List = exports.fromBytesByCLType = exports.StringValue = exports.Unit = exports.U512 = exports.U128 = exports.I64 = exports.U64 = exports.I32 = exports.U32 = exports.U8 = exports.Bool = exports.Result = exports.FromBytesError = exports.SimpleType = exports.staticImplements = exports.CLTypedAndToBytes = void 0; - var bytes_1 = require("@ethersproject/bytes"); - var byterepr_1 = require("./byterepr"); - var bignumber_1 = require("@ethersproject/bignumber"); - var Conversions_1 = require("./Conversions"); - var option_1 = require("./option"); - var Contracts_1 = require("./Contracts"); - var Keys_1 = require("./Keys"); - var typedjson_1 = require("typedjson"); - var ED25519_PUBLIC_KEY_LENGTH = 32; - var SECP256K1_PUBLIC_KEY_LENGTH = 33; - var CLTypedAndToBytes = /** @class */ (function () { - function CLTypedAndToBytes() { - } - CLTypedAndToBytes.prototype.clTypeEncoded = function () { - return CLTypeHelper.toBytesHelper(this.clType()); - }; - return CLTypedAndToBytes; - }()); - exports.CLTypedAndToBytes = CLTypedAndToBytes; - function staticImplements() { - // @ts-ignore - return function (constructor) { - // @ts-ignore - }; - } - exports.staticImplements = staticImplements; - var ED25519_TAG = 1; - var SECP256K1_TAG = 2; - var SimpleType; - (function (SimpleType) { - SimpleType[SimpleType["Bool"] = 0] = "Bool"; - SimpleType[SimpleType["I32"] = 1] = "I32"; - SimpleType[SimpleType["I64"] = 2] = "I64"; - SimpleType[SimpleType["U8"] = 3] = "U8"; - SimpleType[SimpleType["U32"] = 4] = "U32"; - SimpleType[SimpleType["U64"] = 5] = "U64"; - SimpleType[SimpleType["U128"] = 6] = "U128"; - SimpleType[SimpleType["U256"] = 7] = "U256"; - SimpleType[SimpleType["U512"] = 8] = "U512"; - SimpleType[SimpleType["Unit"] = 9] = "Unit"; - SimpleType[SimpleType["String"] = 10] = "String"; - SimpleType[SimpleType["Key"] = 11] = "Key"; - SimpleType[SimpleType["URef"] = 12] = "URef"; - SimpleType[SimpleType["PublicKey"] = 22] = "PublicKey"; - })(SimpleType = exports.SimpleType || (exports.SimpleType = {})); - var ComplexType; - (function (ComplexType) { - ComplexType[ComplexType["Option"] = 13] = "Option"; - ComplexType[ComplexType["List"] = 14] = "List"; - ComplexType[ComplexType["ByteArray"] = 15] = "ByteArray"; - ComplexType[ComplexType["Result"] = 16] = "Result"; - ComplexType[ComplexType["Map"] = 17] = "Map"; - ComplexType[ComplexType["Tuple1"] = 18] = "Tuple1"; - ComplexType[ComplexType["Tuple2"] = 19] = "Tuple2"; - ComplexType[ComplexType["Tuple3"] = 20] = "Tuple3"; - ComplexType[ComplexType["Any"] = 21] = "Any"; - })(ComplexType || (ComplexType = {})); - /** - * Enum representing possible results of deserialization. - */ - var FromBytesError; - (function (FromBytesError) { - /** - * Last operation was a success - */ - FromBytesError[FromBytesError["Ok"] = 0] = "Ok"; - /** - * Early end of stream - */ - FromBytesError[FromBytesError["EarlyEndOfStream"] = 1] = "EarlyEndOfStream"; - /** - * Unexpected data encountered while decoding byte stream - */ - FromBytesError[FromBytesError["FormattingError"] = 2] = "FormattingError"; - })(FromBytesError = exports.FromBytesError || (exports.FromBytesError = {})); - /** - * Class representing a result of an operation that might have failed. Can contain either a value - * resulting from a successful completion of a calculation, or an error. Similar to `Result` in Rust - * or `Either` in Haskell. - */ - var Result = /** @class */ (function () { - /** - * Creates new Result with value - * @param value value (success) or null (error) - * @param error FromBytesError code - * @param rem Remaining input stream - */ - function Result(val, rem, error) { - this.val = val; - this.rem = rem; - this.error = error; - } - Result.Err = function (errorCode) { - return new Result(null, null, errorCode); - }; - Result.Ok = function (val, rem) { - return new Result(val, rem, FromBytesError.Ok); - }; - Result.prototype.remainder = function () { - if (this.rem === null) { - throw new Error("Don't have remainder"); - } - return this.rem; - }; - /** - * Assumes that reference wrapper contains a value and then returns it - */ - Result.prototype.value = function () { - if (!this.hasValue()) { - throw new Error("Don't have value"); - } - return this.val; - }; - /** - * Checks if given Result contains a value - */ - Result.prototype.hasValue = function () { - return this.val !== null; - }; - /** - * Checks if error value is set. - * - * Truth also implies !hasValue(), false value implies hasValue() - */ - Result.prototype.hasError = function () { - return this.error !== FromBytesError.Ok; - }; - return Result; - }()); - exports.Result = Result; - var Bool = /** @class */ (function (_super) { - __extends(Bool, _super); - function Bool(val) { - var _this = _super.call(this) || this; - _this.val = val; - return _this; - } - Bool_1 = Bool; - Bool.prototype.toBytes = function () { - return new Uint8Array([this.val ? 1 : 0]); - }; - Bool.prototype.clType = function () { - return SimpleType.Bool; - }; - Bool.fromBytes = function (bytes) { - if (bytes.length === 0) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - if (bytes[0] === 1) { - return Result.Ok(new Bool_1(true), bytes.subarray(1)); - } - else if (bytes[0] === 0) { - return Result.Ok(new Bool_1(false), bytes.subarray(1)); - } - else { - return Result.Err(FromBytesError.FormattingError); - } - }; - var Bool_1; - Bool = Bool_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Boolean]) - ], Bool); - return Bool; - }(CLTypedAndToBytes)); - exports.Bool = Bool; - var NumberCoder = /** @class */ (function (_super) { - __extends(NumberCoder, _super); - function NumberCoder(bitSize, signed, value) { - var _this = _super.call(this) || this; - _this.toBytes = function () { - return byterepr_1.toBytesNumber(_this.bitSize, _this.signed, _this.val); - }; - _this.name = (signed ? 'i' : 'u') + bitSize; - _this.bitSize = bitSize; - _this.signed = signed; - _this.val = bignumber_1.BigNumber.from(value); - return _this; - } - return NumberCoder; - }(CLTypedAndToBytes)); - var U8 = /** @class */ (function (_super) { - __extends(U8, _super); - function U8(u8) { - return _super.call(this, 8, false, u8) || this; - } - U8_1 = U8; - U8.prototype.clType = function () { - return SimpleType.U8; - }; - U8.fromBytes = function (bytes) { - if (bytes.length === 0) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - return Result.Ok(new U8_1(bytes[0]), bytes.subarray(1)); - }; - var U8_1; - U8 = U8_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Number]) - ], U8); - return U8; - }(NumberCoder)); - exports.U8 = U8; - var U32 = /** @class */ (function (_super) { - __extends(U32, _super); - function U32(n) { - return _super.call(this, 32, false, n) || this; - } - U32_1 = U32; - U32.prototype.clType = function () { - return SimpleType.U32; - }; - U32.fromBytes = function (bytes) { - if (bytes.length < 4) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var u32Bytes = Buffer.from(bytes.subarray(0, 4)); - var u32 = u32Bytes.readUInt32LE(0); - return Result.Ok(new U32_1(u32), bytes.subarray(4)); - }; - var U32_1; - U32 = U32_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Number]) - ], U32); - return U32; - }(NumberCoder)); - exports.U32 = U32; - var I32 = /** @class */ (function (_super) { - __extends(I32, _super); - function I32(n) { - return _super.call(this, 32, true, n) || this; - } - I32_1 = I32; - I32.prototype.clType = function () { - return SimpleType.I32; - }; - I32.fromBytes = function (bytes) { - if (bytes.length < 4) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var i32Bytes = Buffer.from(bytes.subarray(0, 4)); - var i32 = i32Bytes.readInt32LE(0); - return Result.Ok(new I32_1(i32), bytes.subarray(4)); - }; - var I32_1; - I32 = I32_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Number]) - ], I32); - return I32; - }(NumberCoder)); - exports.I32 = I32; - var U64 = /** @class */ (function (_super) { - __extends(U64, _super); - function U64(n) { - return _super.call(this, 64, false, n) || this; - } - U64_1 = U64; - U64.prototype.clType = function () { - return SimpleType.U64; - }; - U64.fromBytes = function (bytes) { - var tmp = Uint8Array.from(bytes); - if (bytes.length < 8) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var u64Bytes = tmp.subarray(0, 8); - var rem = tmp.subarray(8); - return Result.Ok(new U64_1(bignumber_1.BigNumber.from(u64Bytes.reverse())), rem); - }; - var U64_1; - U64 = U64_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Object]) - ], U64); - return U64; - }(NumberCoder)); - exports.U64 = U64; - var I64 = /** @class */ (function (_super) { - __extends(I64, _super); - function I64(n) { - return _super.call(this, 64, true, n) || this; - } - I64_1 = I64; - I64.prototype.clType = function () { - return SimpleType.I64; - }; - I64.fromBytes = function (bytes) { - if (bytes.length < 8) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var tmp = Uint8Array.from(bytes); - var i64Bytes = tmp.subarray(0, 8); - var rem = tmp.subarray(8); - return Result.Ok(new I64_1(bignumber_1.BigNumber.from(i64Bytes.reverse()).fromTwos(64)), rem); - }; - var I64_1; - I64 = I64_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Object]) - ], I64); - return I64; - }(NumberCoder)); - exports.I64 = I64; - var U128 = /** @class */ (function (_super) { - __extends(U128, _super); - function U128(n) { - return _super.call(this, 128, false, n) || this; - } - U128.prototype.clType = function () { - return SimpleType.U128; - }; - U128.fromBytes = function (bytes) { - return fromBytesBigInt(bytes, 128); - }; - U128 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Object]) - ], U128); - return U128; - }(NumberCoder)); - exports.U128 = U128; - var U256 = /** @class */ (function (_super) { - __extends(U256, _super); - function U256(n) { - return _super.call(this, 256, false, n) || this; - } - U256.prototype.clType = function () { - return SimpleType.U256; - }; - U256.fromBytes = function (bytes) { - return fromBytesBigInt(bytes, 256); - }; - U256 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Object]) - ], U256); - return U256; - }(NumberCoder)); - var U512 = /** @class */ (function (_super) { - __extends(U512, _super); - function U512(n) { - return _super.call(this, 512, false, n) || this; - } - U512.prototype.clType = function () { - return SimpleType.U512; - }; - U512.fromBytes = function (bytes) { - return fromBytesBigInt(bytes, 512); - }; - U512 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Object]) - ], U512); - return U512; - }(NumberCoder)); - exports.U512 = U512; - var Unit = /** @class */ (function (_super) { - __extends(Unit, _super); - function Unit() { - return _super !== null && _super.apply(this, arguments) || this; - } - Unit_1 = Unit; - Unit.prototype.clType = function () { - return SimpleType.Unit; - }; - Unit.prototype.toBytes = function () { - return Uint8Array.from([]); - }; - Unit.fromBytes = function (bytes) { - return Result.Ok(new Unit_1(), bytes); - }; - var Unit_1; - Unit = Unit_1 = __decorate([ - staticImplements() - ], Unit); - return Unit; - }(CLTypedAndToBytes)); - exports.Unit = Unit; - var StringValue = /** @class */ (function (_super) { - __extends(StringValue, _super); - function StringValue(val) { - var _this = _super.call(this) || this; - _this.val = val; - _this.toBytes = function () { - return byterepr_1.toBytesString(_this.val); - }; - return _this; - } - StringValue_1 = StringValue; - StringValue.prototype.clType = function () { - return SimpleType.String; - }; - StringValue.fromBytes = function (bytes) { - var res = U32.fromBytes(bytes); - if (res.hasError()) { - return Result.Err(res.error); - } - var len = res.value().val.toNumber(); - var str = Buffer.from(res.remainder().subarray(0, len)).toString('utf8'); - return Result.Ok(new StringValue_1(str), res.remainder().subarray(len)); - }; - var StringValue_1; - StringValue = StringValue_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [String]) - ], StringValue); - return StringValue; - }(CLTypedAndToBytes)); - exports.StringValue = StringValue; - exports.fromBytesByCLType = function (type, bytes) { - if (type instanceof ListType) { - return List.fromBytes(type, bytes); - } - else if (type instanceof Tuple1Type) { - return Tuple1.fromBytes(type, bytes); - } - else if (type instanceof Tuple2Type) { - return Tuple2.fromBytes(type, bytes); - } - else if (type instanceof Tuple3Type) { - return Tuple3.fromBytes(type, bytes); - } - else if (type instanceof ByteArrayType) { - return ByteArrayValue.fromBytes(bytes); - } - else if (type instanceof MapType) { - return MapValue.fromBytes(type, bytes); - } - else if (type instanceof OptionType) { - return option_1.Option.fromBytes(type, bytes); - } - else { - return fromBytesSimpleType(type, bytes); - } - }; - var fromBytesSimpleType = function (simpleType, bytes) { - var innerRes; - switch (simpleType) { - case SimpleType.Bool: - innerRes = Bool.fromBytes(bytes); - break; - case SimpleType.I32: - innerRes = I32.fromBytes(bytes); - break; - case SimpleType.I64: - innerRes = I64.fromBytes(bytes); - break; - case SimpleType.U8: - innerRes = U8.fromBytes(bytes); - break; - case SimpleType.U32: - innerRes = U32.fromBytes(bytes); - break; - case SimpleType.U64: - innerRes = U64.fromBytes(bytes); - break; - case SimpleType.U128: - innerRes = U128.fromBytes(bytes); - break; - case SimpleType.U256: - innerRes = U256.fromBytes(bytes); - break; - case SimpleType.U512: - innerRes = U512.fromBytes(bytes); - break; - case SimpleType.Unit: - innerRes = Unit.fromBytes(bytes); - break; - case SimpleType.String: - innerRes = StringValue.fromBytes(bytes); - break; - case SimpleType.Key: - innerRes = KeyValue.fromBytes(bytes); - break; - case SimpleType.URef: - innerRes = URef.fromBytes(bytes); - break; - case SimpleType.PublicKey: - innerRes = PublicKey.fromBytes(bytes); - break; - default: - innerRes = Result.Err(FromBytesError.FormattingError); - break; - } - if (innerRes.hasError()) { - return Result.Err(innerRes.error); - } - else { - return Result.Ok(innerRes.value(), innerRes.remainder()); - } - }; - var List = /** @class */ (function (_super) { - __extends(List, _super); - function List(vec) { - var _this = _super.call(this) || this; - _this.vec = vec; - if (vec.length === 0) { - throw new Error("Can't create instance for empty list"); - } - return _this; - } - List.prototype.clType = function () { - return CLTypeHelper.list(this.vec[0].clType()); - }; - List.prototype.toBytes = function () { - return byterepr_1.toBytesVecT(this.vec); - }; - List.fromBytes = function (type, bytes) { - var u32Res = U32.fromBytes(bytes); - if (u32Res.hasError()) { - return Result.Err(u32Res.error); - } - var size = u32Res.value().val.toNumber(); - var vec = []; - var remainder = u32Res.remainder(); - for (var i = 0; i < size; i++) { - var v = exports.fromBytesByCLType(type.innerType, remainder); - if (v.hasError()) { - return Result.Err(v.error); - } - vec.push(v.value()); - remainder = v.remainder(); - } - return Result.Ok(new List(vec), remainder); - }; - return List; - }(CLTypedAndToBytes)); - exports.List = List; - var Tuple1 = /** @class */ (function (_super) { - __extends(Tuple1, _super); - function Tuple1(v0) { - var _this = _super.call(this) || this; - _this.v0 = v0; - return _this; - } - Tuple1.prototype.toBytes = function () { - return this.v0.toBytes(); - }; - Tuple1.prototype.clType = function () { - return CLTypeHelper.tuple1(this.v0.clType()); - }; - Tuple1.fromBytes = function (type, bytes) { - var innerRes = exports.fromBytesByCLType(type.t0, bytes); - if (innerRes.hasError()) { - return Result.Err(innerRes.error); - } - var tuple = new Tuple1(innerRes.value()); - return Result.Ok(tuple, innerRes.remainder()); - }; - return Tuple1; - }(CLTypedAndToBytes)); - exports.Tuple1 = Tuple1; - var Tuple2 = /** @class */ (function (_super) { - __extends(Tuple2, _super); - function Tuple2(v0, v1) { - var _this = _super.call(this) || this; - _this.v0 = v0; - _this.v1 = v1; - return _this; - } - Tuple2.prototype.toBytes = function () { - return bytes_1.concat([this.v0.toBytes(), this.v1.toBytes()]); - }; - Tuple2.prototype.clType = function () { - return CLTypeHelper.tuple2(this.v0.clType(), this.v1.clType()); - }; - Tuple2.fromBytes = function (type, bytes) { - var t0Res = exports.fromBytesByCLType(type.t0, bytes); - if (t0Res.hasError()) { - return Result.Err(t0Res.error); - } - var t1Res = exports.fromBytesByCLType(type.t1, t0Res.remainder()); - if (t1Res.hasError()) { - return Result.Err(t1Res.error); - } - var tuple = new Tuple2(t0Res.value(), t1Res.value()); - return Result.Ok(tuple, t1Res.remainder()); - }; - return Tuple2; - }(CLTypedAndToBytes)); - exports.Tuple2 = Tuple2; - var Tuple3 = /** @class */ (function (_super) { - __extends(Tuple3, _super); - function Tuple3(v0, v1, v2) { - var _this = _super.call(this) || this; - _this.v0 = v0; - _this.v1 = v1; - _this.v2 = v2; - return _this; - } - Tuple3.prototype.clType = function () { - return CLTypeHelper.tuple3(this.v0.clType(), this.v1.clType(), this.v2.clType()); - }; - Tuple3.prototype.toBytes = function () { - return bytes_1.concat([this.v0.toBytes(), this.v1.toBytes(), this.v2.toBytes()]); - }; - Tuple3.fromBytes = function (type, bytes) { - var t0Res = exports.fromBytesByCLType(type.t0, bytes); - if (t0Res.hasError()) { - return Result.Err(t0Res.error); - } - var t1Res = exports.fromBytesByCLType(type.t1, t0Res.remainder()); - if (t1Res.hasError()) { - return Result.Err(t1Res.error); - } - var t2Res = exports.fromBytesByCLType(type.t2, t1Res.remainder()); - if (t2Res.hasError()) { - return Result.Err(t2Res.error); - } - var tuple = new Tuple3(t0Res.value(), t1Res.value(), t2Res.value()); - return Result.Ok(tuple, t2Res.remainder()); - }; - return Tuple3; - }(CLTypedAndToBytes)); - exports.Tuple3 = Tuple3; - var PublicKey = /** @class */ (function (_super) { - __extends(PublicKey, _super); - function PublicKey(rawPublicKey, tag) { - var _this = _super.call(this) || this; - _this.rawPublicKey = rawPublicKey; - _this.tag = tag; - return _this; - } - PublicKey_1 = PublicKey; - PublicKey.prototype.clType = function () { - return SimpleType.PublicKey; - }; - PublicKey.prototype.toBytes = function () { - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesBytesArray(this.rawPublicKey) - ]); - }; - PublicKey.prototype.toAccountHex = function () { - var accountHash; - switch (this.tag) { - case ED25519_TAG: - accountHash = '01' + Conversions_1.encodeBase16(this.rawPublicKey); - break; - case SECP256K1_TAG: - accountHash = '02' + Conversions_1.encodeBase16(this.rawPublicKey); - break; - default: - throw new Error('Unsupported type of public key'); - } - return accountHash; - }; - PublicKey.prototype.isEd25519 = function () { - return this.tag === ED25519_TAG; - }; - PublicKey.prototype.isSecp256K1 = function () { - return this.tag === SECP256K1_TAG; - }; - PublicKey.prototype.toAccountHash = function () { - var algorithmIdentifier = this.signatureAlgorithm(); - var separator = Buffer.from([0]); - var prefix = Buffer.concat([ - Buffer.from(algorithmIdentifier.toLowerCase()), - separator - ]); - if (this.rawPublicKey.length === 0) { - return Buffer.from([]); - } - else { - return Contracts_1.byteHash(Buffer.concat([prefix, Buffer.from(this.rawPublicKey)])); - } - }; - PublicKey.fromEd25519 = function (publicKey) { - return new PublicKey_1(publicKey, ED25519_TAG); - }; - PublicKey.fromSecp256K1 = function (publicKey) { - return new PublicKey_1(publicKey, SECP256K1_TAG); - }; - PublicKey.from = function (publicKey, signatureAlgorithm) { - switch (signatureAlgorithm) { - case Keys_1.SignatureAlgorithm.Ed25519: - return PublicKey_1.fromEd25519(publicKey); - case Keys_1.SignatureAlgorithm.Secp256K1: - return PublicKey_1.fromSecp256K1(publicKey); - default: - throw new Error('Unsupported type of public key'); - } - }; - /** - * Tries to decode PublicKey from its hex-representation. - * The hex format should be as produced by PublicKey.toAccountHex - * @param publicKeyHex - */ - PublicKey.fromHex = function (publicKeyHex) { - if (publicKeyHex.length < 2) { - throw new Error('asymmetric key error: too short'); - } - var publicKeyHexBytes = Conversions_1.decodeBase16(publicKeyHex); - switch (publicKeyHexBytes[0]) { - case 1: - return PublicKey_1.fromEd25519(publicKeyHexBytes.subarray(1)); - case 2: - return PublicKey_1.fromSecp256K1(publicKeyHexBytes.subarray(1)); - default: - throw new Error('Unsupported type of public key'); - } - }; - PublicKey.prototype.signatureAlgorithm = function () { - switch (this.tag) { - case ED25519_TAG: - return Keys_1.SignatureAlgorithm.Ed25519; - case SECP256K1_TAG: - return Keys_1.SignatureAlgorithm.Secp256K1; - default: - throw new Error('Unsupported type of public key'); - } - }; - /** Deserializes a `PublicKey` from an array of bytes. */ - PublicKey.fromBytes = function (bytes) { - if (bytes.length < 1) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var variant = bytes[0]; - var currentPos = 1; - var expectedPublicKeySize; - switch (variant) { - case ED25519_TAG: - expectedPublicKeySize = ED25519_PUBLIC_KEY_LENGTH; - break; - case SECP256K1_TAG: - expectedPublicKeySize = SECP256K1_PUBLIC_KEY_LENGTH; - break; - default: - return Result.Err(FromBytesError.FormattingError); - } - var publicKeyBytes = bytes.subarray(currentPos, currentPos + expectedPublicKeySize); - currentPos += expectedPublicKeySize; - var publicKey = new PublicKey_1(publicKeyBytes, variant); - return Result.Ok(publicKey, bytes.subarray(currentPos)); - }; - var PublicKey_1; - PublicKey = PublicKey_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Uint8Array, Number]) - ], PublicKey); - return PublicKey; - }(CLTypedAndToBytes)); - exports.PublicKey = PublicKey; - var MapValue = /** @class */ (function (_super) { - __extends(MapValue, _super); - function MapValue(v) { - var _this = _super.call(this) || this; - _this.v = v; - return _this; - } - MapValue.prototype.toBytes = function () { - var kvBytes = this.v.map(function (vv) { - return bytes_1.concat([vv.key.toBytes(), vv.value.toBytes()]); - }); - kvBytes.splice(0, 0, byterepr_1.toBytesU32(this.v.length)); - return bytes_1.concat(kvBytes); - }; - MapValue.prototype.clType = function () { - return new MapType(this.v[0].key.clType(), this.v[0].value.clType()); - }; - MapValue.fromBytes = function (type, bytes) { - var u32Res = U32.fromBytes(bytes); - if (u32Res.hasError()) { - return Result.Err(u32Res.error); - } - var size = u32Res.value().val.toNumber(); - var vec = []; - var remainder = u32Res.remainder(); - for (var i = 0; i < size; i++) { - var keyRes = exports.fromBytesByCLType(type.keyType, remainder); - if (keyRes.hasError()) { - return Result.Err(keyRes.error); - } - remainder = keyRes.remainder(); - var valueRes = exports.fromBytesByCLType(type.valueType, remainder); - if (valueRes.hasError()) { - return Result.Err(valueRes.error); - } - remainder = valueRes.remainder(); - vec.push({ key: keyRes.value(), value: valueRes.value() }); - } - return Result.Ok(new MapValue(vec), remainder); - }; - return MapValue; - }(CLTypedAndToBytes)); - exports.MapValue = MapValue; - var ByteArrayValue = /** @class */ (function (_super) { - __extends(ByteArrayValue, _super); - function ByteArrayValue(rawBytes) { - var _this = _super.call(this) || this; - _this.rawBytes = rawBytes; - return _this; - } - ByteArrayValue_1 = ByteArrayValue; - ByteArrayValue.prototype.clType = function () { - return CLTypeHelper.byteArray(this.rawBytes.length); - }; - ByteArrayValue.prototype.toBytes = function () { - return byterepr_1.toBytesBytesArray(this.rawBytes); - }; - ByteArrayValue.fromBytes = function (bytes) { - var b = new ByteArrayValue_1(bytes.subarray(0, 32)); - return Result.Ok(b, bytes.subarray(32)); - }; - var ByteArrayValue_1; - ByteArrayValue = ByteArrayValue_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Uint8Array]) - ], ByteArrayValue); - return ByteArrayValue; - }(CLTypedAndToBytes)); - var fromBytesBigInt = function (bytes, bitSize) { - var byteSize = bitSize / 8; - if (bytes.length < 1) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var tmp = Uint8Array.from(bytes); - var n = tmp[0]; - if (n > byteSize) { - return Result.Err(FromBytesError.FormattingError); - } - if (n + 1 > bytes.length) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var bigIntBytes; - if (n === 0) { - bigIntBytes = [0]; - } - else { - bigIntBytes = tmp.subarray(1, 1 + n); - } - var rem = tmp.subarray(1 + n); - if (bitSize === 128) { - return Result.Ok(new U128(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); - } - else if (bitSize === 256) { - return Result.Ok(new U256(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); - } - else if (bitSize === 512) { - return Result.Ok(new U512(bignumber_1.BigNumber.from(bigIntBytes.reverse())), rem); - } - else { - return Result.Err(FromBytesError.FormattingError); - } - }; - var OptionType = /** @class */ (function () { - function OptionType(innerType) { - this.innerType = innerType; - this.tag = ComplexType.Option; - } - OptionType.prototype.toJSON = function () { - var _c; - var innerTypeInJSON = clTypeToJSON(this.innerType); - return _c = {}, - _c[OptionType.TypeId] = innerTypeInJSON, - _c; - }; - OptionType.TypeId = 'Option'; - return OptionType; - }()); - exports.OptionType = OptionType; - var ListType = /** @class */ (function () { - function ListType(innerType) { - this.tag = ComplexType.List; - this.innerType = innerType; - } - ListType.prototype.toJSON = function () { - var _c; - var innerTypeInJSON = clTypeToJSON(this.innerType); - return _c = {}, - _c[ListType.TypeId] = innerTypeInJSON, - _c; - }; - ListType.TypeId = 'List'; - return ListType; - }()); - var ByteArrayType = /** @class */ (function () { - function ByteArrayType(size) { - this.size = size; - this.tag = ComplexType.ByteArray; - } - ByteArrayType.prototype.toJSON = function () { - var _c; - return _c = {}, - _c[ByteArrayType.TypeId] = this.size, - _c; - }; - ByteArrayType.TypeId = 'ByteArray'; - return ByteArrayType; - }()); - var MapType = /** @class */ (function () { - function MapType(keyType, valueType) { - this.keyType = keyType; - this.valueType = valueType; - this.tag = ComplexType.Map; - } - MapType.prototype.toJSON = function () { - var _c; - return _c = {}, - _c[MapType.TypeId] = { - key: clTypeToJSON(this.keyType), - value: clTypeToJSON(this.valueType) - }, - _c; - }; - MapType.TypeId = 'Map'; - return MapType; - }()); - var Tuple1Type = /** @class */ (function () { - function Tuple1Type(t0) { - this.t0 = t0; - this.tag = ComplexType.Tuple1; - } - Tuple1Type.prototype.toJSON = function () { - var _c; - var t0TypeInJSON = clTypeToJSON(this.t0); - return _c = {}, - _c[Tuple1Type.TypeId] = t0TypeInJSON, - _c; - }; - Tuple1Type.TypeId = 'Tuple1'; - return Tuple1Type; - }()); - var Tuple2Type = /** @class */ (function () { - function Tuple2Type(t0, t1) { - this.t0 = t0; - this.t1 = t1; - this.tag = ComplexType.Tuple2; - } - Tuple2Type.prototype.toJSON = function () { - var _c; - var t0TypeInJSON = clTypeToJSON(this.t0); - var t1TypeInJSON = clTypeToJSON(this.t1); - return _c = {}, - _c[Tuple2Type.TypeId] = [t0TypeInJSON, t1TypeInJSON], - _c; - }; - Tuple2Type.TypeId = 'Tuple2'; - return Tuple2Type; - }()); - var Tuple3Type = /** @class */ (function () { - function Tuple3Type(t0, t1, t2) { - this.t0 = t0; - this.t1 = t1; - this.t2 = t2; - this.tag = ComplexType.Tuple3; - } - Tuple3Type.prototype.toJSON = function () { - var _c; - var t0TypeInJSON = clTypeToJSON(this.t0); - var t1TypeInJSON = clTypeToJSON(this.t1); - var t2TypeInJSON = clTypeToJSON(this.t2); - return _c = {}, - _c[Tuple3Type.TypeId] = [t0TypeInJSON, t1TypeInJSON, t2TypeInJSON], - _c; - }; - Tuple3Type.TypeId = 'Tuple3'; - return Tuple3Type; - }()); - var CLTypeHelper = /** @class */ (function () { - function CLTypeHelper() { - } - CLTypeHelper.u8 = function () { - return SimpleType.U8; - }; - CLTypeHelper.u32 = function () { - return SimpleType.U32; - }; - CLTypeHelper.u64 = function () { - return SimpleType.U64; - }; - CLTypeHelper.u128 = function () { - return SimpleType.U128; - }; - CLTypeHelper.u256 = function () { - return SimpleType.U256; - }; - CLTypeHelper.u512 = function () { - return SimpleType.U512; - }; - CLTypeHelper.i32 = function () { - return SimpleType.I32; - }; - CLTypeHelper.i64 = function () { - return SimpleType.I64; - }; - CLTypeHelper.bool = function () { - return SimpleType.Bool; - }; - CLTypeHelper.unit = function () { - return SimpleType.Unit; - }; - CLTypeHelper.string = function () { - return SimpleType.String; - }; - CLTypeHelper.key = function () { - return SimpleType.Key; - }; - CLTypeHelper.publicKey = function () { - return SimpleType.PublicKey; - }; - CLTypeHelper.uRef = function () { - return SimpleType.URef; - }; - CLTypeHelper.option = function (innerType) { - return new OptionType(innerType); - }; - CLTypeHelper.list = function (innerType) { - return new ListType(innerType); - }; - CLTypeHelper.byteArray = function (len) { - return new ByteArrayType(len); - }; - CLTypeHelper.map = function (keyType, valueType) { - return new MapType(keyType, valueType); - }; - CLTypeHelper.tuple1 = function (t0) { - return new Tuple1Type(t0); - }; - CLTypeHelper.tuple2 = function (t0, t1) { - return new Tuple2Type(t0, t1); - }; - CLTypeHelper.tuple3 = function (t0, t1, t2) { - return new Tuple3Type(t0, t1, t2); - }; - CLTypeHelper.fromBytes = function (bytes) { - if (bytes.length < 1) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var tag = bytes[0]; - var rem = bytes.subarray(1); - switch (tag) { - case SimpleType.Bool: - case SimpleType.I32: - case SimpleType.I64: - case SimpleType.U8: - case SimpleType.U32: - case SimpleType.U64: - case SimpleType.U256: - case SimpleType.U512: - case SimpleType.Unit: - case SimpleType.String: - case SimpleType.Key: - case SimpleType.URef: - case SimpleType.PublicKey: - return Result.Ok(tag, rem); - case ComplexType.Option: { - // 1 inner type - var innerTypeRes = CLTypeHelper.fromBytes(rem); - if (innerTypeRes.hasError()) { - return Result.Err(innerTypeRes.error); - } - return Result.Ok(CLTypeHelper.option(innerTypeRes.value()), innerTypeRes.remainder()); - } - case ComplexType.List: { - // 1 inner type - var innerTypeRes = CLTypeHelper.fromBytes(rem); - if (innerTypeRes.hasError()) { - return Result.Err(innerTypeRes.error); - } - return Result.Ok(CLTypeHelper.list(innerTypeRes.value()), innerTypeRes.remainder()); - } - case ComplexType.ByteArray: { - // size of bytes - var sizeRes = U32.fromBytes(rem); - if (sizeRes.hasError()) { - return Result.Err(sizeRes.error); - } - return Result.Ok(CLTypeHelper.byteArray(sizeRes.value().val.toNumber()), sizeRes.remainder()); - } - case ComplexType.Result: - // todo(abner) support Result - throw new Error('Result type is unsupported now'); - case ComplexType.Map: { - // type of key - var keyTypeRes = CLTypeHelper.fromBytes(rem); - if (keyTypeRes.hasError()) { - return Result.Err(keyTypeRes.error); - } - var valueTypeRes = CLTypeHelper.fromBytes(keyTypeRes.remainder()); - if (valueTypeRes.hasError()) { - return Result.Err(valueTypeRes.error); - } - return Result.Ok(CLTypeHelper.map(keyTypeRes.value(), valueTypeRes.value()), valueTypeRes.remainder()); - } - case ComplexType.Tuple1: { - // 1 inner type - var innerTypeRes = CLTypeHelper.fromBytes(rem); - if (innerTypeRes.hasError()) { - return Result.Err(innerTypeRes.error); - } - return Result.Ok(CLTypeHelper.tuple1(innerTypeRes.value()), innerTypeRes.remainder()); - } - case ComplexType.Tuple2: { - // 2 inner types - var innerType1Res = CLTypeHelper.fromBytes(rem); - if (innerType1Res.hasError()) { - return Result.Err(innerType1Res.error); - } - var innerType2Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); - if (innerType2Res.hasError()) { - return Result.Err(innerType2Res.error); - } - return Result.Ok(CLTypeHelper.tuple2(innerType1Res.value(), innerType2Res.value()), innerType2Res.remainder()); - } - case ComplexType.Tuple3: { - // 3 inner types - var innerType1Res = CLTypeHelper.fromBytes(rem); - if (innerType1Res.hasError()) { - return Result.Err(innerType1Res.error); - } - var innerType2Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); - if (innerType2Res.hasError()) { - return Result.Err(innerType2Res.error); - } - var innerType3Res = CLTypeHelper.fromBytes(innerType1Res.remainder()); - if (innerType3Res.hasError()) { - return Result.Err(innerType3Res.error); - } - return Result.Ok(CLTypeHelper.tuple3(innerType1Res.value(), innerType2Res.value(), innerType3Res.value()), innerType3Res.remainder()); - } - case ComplexType.Any: - // todo(abner) support Any - throw new Error('Any type is unsupported now'); - default: - return Result.Err(FromBytesError.FormattingError); - } - }; - CLTypeHelper.toBytesHelper = function (type) { - if (type instanceof ListType) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.innerType) - ]); - } - else if (type instanceof Tuple1Type) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.t0) - ]); - } - else if (type instanceof Tuple2Type) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.t0), - CLTypeHelper.toBytesHelper(type.t1) - ]); - } - else if (type instanceof Tuple3Type) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.t0), - CLTypeHelper.toBytesHelper(type.t1), - CLTypeHelper.toBytesHelper(type.t2) - ]); - } - else if (type instanceof ByteArrayType) { - return bytes_1.concat([Uint8Array.from([type.tag]), byterepr_1.toBytesU32(type.size)]); - } - else if (type instanceof MapType) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.keyType), - CLTypeHelper.toBytesHelper(type.valueType) - ]); - } - else if (type instanceof OptionType) { - return bytes_1.concat([ - Uint8Array.from([type.tag]), - CLTypeHelper.toBytesHelper(type.innerType) - ]); - } - else { - switch (type) { - case SimpleType.Bool: - case SimpleType.I32: - case SimpleType.I64: - case SimpleType.U8: - case SimpleType.U32: - case SimpleType.U64: - case SimpleType.U128: - case SimpleType.U256: - case SimpleType.U512: - case SimpleType.Unit: - case SimpleType.String: - case SimpleType.Key: - case SimpleType.URef: - case SimpleType.PublicKey: - return Uint8Array.from([type]); - default: - throw new Error('Wrong type'); - } - } - }; - return CLTypeHelper; - }()); - exports.CLTypeHelper = CLTypeHelper; - var CLTypedAndToBytesHelper = /** @class */ (function () { - function CLTypedAndToBytesHelper() { - } - CLTypedAndToBytesHelper.list = function (vec) { - // todo(abner) implement fromEmptyList - return new List(vec); - }; - CLTypedAndToBytesHelper.tuple1 = function (t0) { - return new Tuple1(t0); - }; - CLTypedAndToBytesHelper.tuple2 = function (t0, t1) { - return new Tuple2(t0, t1); - }; - CLTypedAndToBytesHelper.tuple3 = function (t0, t1, t2) { - return new Tuple3(t0, t1, t2); - }; - CLTypedAndToBytesHelper.option = function (t, innerType) { - return new option_1.Option(t, innerType); - }; - CLTypedAndToBytesHelper.map = function (mapEntries) { - return new MapValue(mapEntries); - }; - CLTypedAndToBytesHelper.publicKey = function (publicKey) { - return PublicKey.fromEd25519(publicKey); - }; - CLTypedAndToBytesHelper.bytes = function (bytes) { - return new ByteArrayValue(bytes); - }; - CLTypedAndToBytesHelper.bool = function (b) { - return new Bool(b); - }; - CLTypedAndToBytesHelper.u8 = function (u8) { - return new U8(u8); - }; - CLTypedAndToBytesHelper.u32 = function (u32) { - return new U32(u32); - }; - CLTypedAndToBytesHelper.i32 = function (i32) { - return new I32(i32); - }; - CLTypedAndToBytesHelper.u64 = function (u64) { - return new U64(u64); - }; - CLTypedAndToBytesHelper.i64 = function (i64) { - return new I64(i64); - }; - CLTypedAndToBytesHelper.u128 = function (u128) { - return new U128(u128); - }; - CLTypedAndToBytesHelper.u256 = function (u256) { - return new U256(u256); - }; - CLTypedAndToBytesHelper.u512 = function (u512) { - return new U512(u512); - }; - CLTypedAndToBytesHelper.unit = function () { - return new Unit(); - }; - CLTypedAndToBytesHelper.string = function (x) { - return new StringValue(x); - }; - return CLTypedAndToBytesHelper; - }()); - exports.CLTypedAndToBytesHelper = CLTypedAndToBytesHelper; - function toJSONSimpleType(type) { - switch (type) { - case SimpleType.Bool: - return 'Bool'; - case SimpleType.I32: - return 'I32'; - case SimpleType.I64: - return 'I64'; - case SimpleType.U8: - return 'U8'; - case SimpleType.U32: - return 'U32'; - case SimpleType.U64: - return 'U64'; - case SimpleType.U128: - return 'U128'; - case SimpleType.U256: - return 'U256'; - case SimpleType.U512: - return 'U512'; - case SimpleType.Unit: - return 'Unit'; - case SimpleType.String: - return 'String'; - case SimpleType.Key: - return 'Key'; - case SimpleType.URef: - return 'URef'; - case SimpleType.PublicKey: - return 'PublicKey'; - } - } - function jsonToSimpleType(str) { - switch (str) { - case 'Bool': - return SimpleType.Bool; - case 'I32': - return SimpleType.I32; - case 'I64': - return SimpleType.I64; - case 'U8': - return SimpleType.U8; - case 'U32': - return SimpleType.U32; - case 'U64': - return SimpleType.U64; - case 'U128': - return SimpleType.U128; - case 'U256': - return SimpleType.U256; - case 'U512': - return SimpleType.U512; - case 'Unit': - return SimpleType.Unit; - case 'String': - return SimpleType.String; - case 'Key': - return SimpleType.Key; - case 'URef': - return SimpleType.URef; - case 'PublicKey': - return SimpleType.PublicKey; - default: - throw new Error("The type " + str + " is not supported"); - } - } - var clTypeToJSON = function (type) { - if (type instanceof ListType || - type instanceof Tuple1Type || - type instanceof Tuple2Type || - type instanceof Tuple3Type || - type instanceof ByteArrayType || - type instanceof MapType || - type instanceof OptionType) { - return type.toJSON(); - } - else { - return toJSONSimpleType(type); - } - }; - var jsonToCLType = function (json) { - if (typeof json === typeof 'str') { - return jsonToSimpleType(json); - } - else if (typeof json === typeof {}) { - if (ListType.TypeId in json) { - var innerType = jsonToCLType(json[ListType.TypeId]); - return CLTypeHelper.list(innerType); - } - else if (Tuple1Type.TypeId in json) { - var t0Type = jsonToCLType(json[Tuple1Type.TypeId][0]); - return CLTypeHelper.tuple1(t0Type); - } - else if (Tuple2Type.TypeId in json) { - var innerTypes = json[Tuple2Type.TypeId]; - var t0Type = jsonToCLType(innerTypes[0]); - var t1Type = jsonToCLType(innerTypes[1]); - return CLTypeHelper.tuple2(t0Type, t1Type); - } - else if (Tuple3Type.TypeId in json) { - var innerTypes = json[Tuple2Type.TypeId]; - var t0Type = jsonToCLType(innerTypes[0]); - var t1Type = jsonToCLType(innerTypes[1]); - var t2Type = jsonToCLType(innerTypes[2]); - return CLTypeHelper.tuple3(t0Type, t1Type, t2Type); - } - else if (ByteArrayType.TypeId in json) { - var size = json[ByteArrayType.TypeId]; - return CLTypeHelper.byteArray(size); - } - else if (OptionType.TypeId in json) { - var innerType = jsonToCLType(json[OptionType.TypeId]); - return CLTypeHelper.option(innerType); - } - else if (MapType.TypeId in json) { - var keyType = jsonToCLType(json[MapType.TypeId].key); - var valueType = jsonToCLType(json[MapType.TypeId].value); - return CLTypeHelper.map(keyType, valueType); - } - else { - throw new Error("The type " + json + " is not supported"); - } - } - else { - throw new Error("The type " + json + " is not supported"); - } - }; - function deserializeCLValue(_a, _b) { - var v = exports.fromBytesByCLType(_a.clType, Conversions_1.decodeBase16(_a.bytes)); - var ret = CLValue.fromT(v.value()); - return ret; - } - /** - * A Casper value, i.e. a value which can be stored and manipulated by smart contracts. - * - * It holds the underlying data as a type-erased, serialized array of bytes and also holds the - * [[CLType]] of the underlying data as a separate member. - */ - var CLValue = /** @class */ (function () { - /** - * Please use static methodsto constructs a new `CLValue` - */ - function CLValue(value, clType) { - this.value = value; - this.clType = clType; - this.bytes = Conversions_1.encodeBase16(this.value.toBytes()); - } - CLValue_1 = CLValue; - CLValue.prototype.clValueBytes = function () { - return this.value.toBytes(); - }; - CLValue.fromT = function (v) { - return new CLValue_1(v, v.clType()); - }; - /** - * Serializes a `CLValue` into an array of bytes. - */ - CLValue.prototype.toBytes = function () { - return bytes_1.concat([ - byterepr_1.toBytesArrayU8(this.clValueBytes()), - CLTypeHelper.toBytesHelper(this.clType) - ]); - }; - CLValue.fromBytes = function (bytes) { - var bytesRes = ByteArrayValue.fromBytes(bytes); - if (bytesRes.hasError()) { - return Result.Err(bytesRes.error); - } - var clTypeRes = CLTypeHelper.fromBytes(bytesRes.remainder()); - if (clTypeRes.hasError()) { - return Result.Err(clTypeRes.error); - } - var v = exports.fromBytesByCLType(clTypeRes.value(), bytesRes.value().rawBytes); - var clValue = new CLValue_1(v.value(), clTypeRes.value()); - return Result.Ok(clValue, clTypeRes.remainder()); - }; - CLValue.prototype.reconstruct = function () { - var v = exports.fromBytesByCLType(this.clType, Conversions_1.decodeBase16(this.bytes)); - if (v.hasError()) { - throw new Error('Failed to deserialize CLValue'); - } - this.value = v.value(); - }; - CLValue.list = function (vec) { - return CLValue_1.fromT(new List(vec)); - }; - CLValue.tuple1 = function (t0) { - return CLValue_1.fromT(new Tuple1(t0)); - }; - CLValue.tuple2 = function (t0, t1) { - return CLValue_1.fromT(new Tuple2(t0, t1)); - }; - CLValue.tuple3 = function (t0, t1, t2) { - return CLValue_1.fromT(new Tuple3(t0, t1, t2)); - }; - CLValue.option = function (t, innerType) { - return CLValue_1.fromT(new option_1.Option(t, innerType)); - }; - CLValue.map = function (mapEntries) { - return CLValue_1.fromT(new MapValue(mapEntries)); - }; - CLValue.publicKey = function (publicKey) { - return CLValue_1.fromT(publicKey); - }; - CLValue.byteArray = function (bytes) { - return CLValue_1.fromT(new ByteArrayValue(bytes)); - }; - CLValue.prototype.isBigNumber = function () { - return (this.clType === SimpleType.U8 || - this.clType === SimpleType.I32 || - this.clType === SimpleType.I64 || - this.clType === SimpleType.U32 || - this.clType === SimpleType.U64 || - this.clType === SimpleType.U128 || - this.clType === SimpleType.U256 || - this.clType === SimpleType.U512); - }; - CLValue.prototype.asBigNumber = function () { - if (this.isBigNumber()) { - var numberCoder = this.value; - return bignumber_1.BigNumber.from(numberCoder.val); - } - else { - throw new Error('The CLValue is not an instance of BigNumber'); - } - }; - CLValue.prototype.isBoolean = function () { - return this.clType === SimpleType.Bool; - }; - CLValue.prototype.asBoolean = function () { - if (!this.isBoolean()) { - throw new Error('The CLValue is not an instance of Boolean'); - } - return this.value.val; - }; - CLValue.prototype.isString = function () { - return this.clType === SimpleType.String; - }; - CLValue.prototype.asString = function () { - if (!this.isString()) { - throw new Error('The CLValue is not an instance of String'); - } - return this.value.val; - }; - CLValue.prototype.isPublicKey = function () { - return this.clType === SimpleType.PublicKey; - }; - CLValue.prototype.asPublicKey = function () { - if (!this.isPublicKey()) { - throw new Error('The CLValue is not an instance of PublicKey'); - } - return this.value; - }; - CLValue.prototype.isKey = function () { - return this.clType === SimpleType.Key; - }; - CLValue.prototype.asKey = function () { - if (!this.isKey()) { - throw new Error('The CLValue is not an instance of Key'); - } - return this.value; - }; - CLValue.prototype.isURef = function () { - return this.clType === SimpleType.URef; - }; - CLValue.prototype.asURef = function () { - if (!this.isURef()) { - throw new Error('The CLValue is not an instance of URef'); - } - return this.value; - }; - CLValue.prototype.isBytesArray = function () { - return this.clType instanceof ByteArrayType; - }; - CLValue.prototype.asBytesArray = function () { - if (!this.isBytesArray()) { - throw new Error('The CLValue is not an instance of BytesArray'); - } - return this.value.toBytes(); - }; - CLValue.prototype.isOption = function () { - return this.clType instanceof OptionType; - }; - CLValue.prototype.asOption = function () { - if (!this.isOption()) { - throw new Error('The CLValue is not an instance of Option'); - } - return this.value; - }; - CLValue.prototype.isList = function () { - return this.clType instanceof ListType; - }; - CLValue.prototype.asList = function () { - if (!this.isList()) { - throw new Error('The CLValue is not an instance of List'); - } - var innerType = this.clType; - var list = List.fromBytes(innerType, this.clValueBytes()); - if (list.hasError()) { - throw new Error('The CLValue can not be parsed to list.'); - } - return list.value().vec.map(function (e) { return CLValue_1.fromT(e); }); - }; - var CLValue_1; - CLValue.bool = function (b) { - return CLValue_1.fromT(new Bool(b)); - }; - CLValue.u8 = function (u8) { - return CLValue_1.fromT(new U8(u8)); - }; - CLValue.u32 = function (u32) { - return CLValue_1.fromT(new U32(u32)); - }; - CLValue.i32 = function (i32) { - return CLValue_1.fromT(new I32(i32)); - }; - CLValue.u64 = function (u64) { - return CLValue_1.fromT(new U64(u64)); - }; - CLValue.i64 = function (i64) { - return CLValue_1.fromT(new I64(i64)); - }; - CLValue.u128 = function (u128) { - return CLValue_1.fromT(new U128(u128)); - }; - CLValue.u256 = function (u256) { - return CLValue_1.fromT(new U256(u256)); - }; - CLValue.u512 = function (u512) { - return CLValue_1.fromT(new U512(u512)); - }; - CLValue.unit = function () { - return CLValue_1.fromT(new Unit()); - }; - CLValue.string = function (x) { - return CLValue_1.fromT(new StringValue(x)); - }; - CLValue.key = function (key) { - return CLValue_1.fromT(key); - }; - CLValue.uref = function (uRef) { - return CLValue_1.fromT(uRef); - }; - CLValue.stringList = function (strings) { - var v = CLTypedAndToBytesHelper.list(strings.map(function (s) { return CLTypedAndToBytesHelper.string(s); })); - return new CLValue_1(v, CLTypeHelper.list(SimpleType.String)); - }; - __decorate([ - typedjson_1.jsonMember({ - name: 'cl_type', - serializer: clTypeToJSON, - deserializer: jsonToCLType - }), - __metadata("design:type", Object) - ], CLValue.prototype, "clType", void 0); - __decorate([ - typedjson_1.jsonMember({ - constructor: String - }), - __metadata("design:type", String) - ], CLValue.prototype, "bytes", void 0); - __decorate([ - typedjson_1.jsonMember({ - serializer: function (_) { return 'null'; }, - deserializer: function (_) { return null; } - }), - __metadata("design:type", Object) - ], CLValue.prototype, "parsed", void 0); - CLValue = CLValue_1 = __decorate([ - typedjson_1.jsonObject({ - initializer: function (a, b) { return deserializeCLValue(a, b); } - }), - __metadata("design:paramtypes", [CLTypedAndToBytes, Object]) - ], CLValue); - return CLValue; - }()); - exports.CLValue = CLValue; - var KeyVariant; - (function (KeyVariant) { - /** The Account variant */ - KeyVariant[KeyVariant["ACCOUNT_ID"] = 0] = "ACCOUNT_ID"; - /** The Hash variant */ - KeyVariant[KeyVariant["HASH_ID"] = 1] = "HASH_ID"; - /** The URef variant */ - KeyVariant[KeyVariant["UREF_ID"] = 2] = "UREF_ID"; - // todo(abner) support the new introduced variants - /** The Transfer variant */ - // TRANSFER_ID = 3, - // DEPLOY_INFO_ID = 4, - // ERA_INFO_ID = 5 - })(KeyVariant = exports.KeyVariant || (exports.KeyVariant = {})); - /// The length in bytes of a [`AccountHash`]. - var ACCOUNT_HASH_LENGTH = 32; - /** A cryptographic public key. */ - var AccountHash = /** @class */ (function (_super) { - __extends(AccountHash, _super); - /** - * Constructs a new `AccountHash`. - * - * @param bytes The bytes constituting the public key. - */ - function AccountHash(bytes) { - var _this = _super.call(this) || this; - _this.bytes = bytes; - return _this; - } - AccountHash_1 = AccountHash; - /** Serializes a `AccountHash` into an array of bytes. */ - AccountHash.prototype.toBytes = function () { - return this.bytes; - }; - AccountHash.prototype.clType = function () { - return CLTypeHelper.byteArray(ACCOUNT_HASH_LENGTH); - }; - AccountHash.fromBytes = function (bytes) { - if (bytes.length < ACCOUNT_HASH_LENGTH) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var accountHashBytes = bytes.subarray(0, ACCOUNT_HASH_LENGTH); - var accountHash = new AccountHash_1(accountHashBytes); - return Result.Ok(accountHash, bytes.subarray(ACCOUNT_HASH_LENGTH)); - }; - var AccountHash_1; - AccountHash = AccountHash_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Uint8Array]) - ], AccountHash); - return AccountHash; - }(CLTypedAndToBytes)); - exports.AccountHash = AccountHash; - /** - * The type under which data (e.g. [[CLValue]]s, smart contracts, user accounts) - * are indexed on the network. - */ - var KeyValue = /** @class */ (function (_super) { - __extends(KeyValue, _super); - function KeyValue() { - return _super !== null && _super.apply(this, arguments) || this; - } - KeyValue_1 = KeyValue; - KeyValue.prototype.isHash = function () { - return this.variant === KeyVariant.HASH_ID; - }; - KeyValue.prototype.isURef = function () { - return this.variant === KeyVariant.UREF_ID; - }; - KeyValue.prototype.isAccount = function () { - return this.variant === KeyVariant.ACCOUNT_ID; - }; - /** Creates a `Key` from a given [[URef]]. */ - KeyValue.fromURef = function (uref) { - var key = new KeyValue_1(); - key.variant = KeyVariant.UREF_ID; - key.uRef = uref; - return key; - }; - /** Creates a `Key` from a given hash. */ - KeyValue.fromHash = function (hash) { - var key = new KeyValue_1(); - key.variant = KeyVariant.HASH_ID; - key.hash = hash; - return key; - }; - /** Creates a `Key` from a [[]] representing an account. */ - KeyValue.fromAccount = function (account) { - var key = new KeyValue_1(); - key.variant = KeyVariant.ACCOUNT_ID; - key.account = account; - return key; - }; - KeyValue.prototype.clType = function () { - return SimpleType.Key; - }; - /** Serializes a `Key` into an array of bytes. */ - KeyValue.prototype.toBytes = function () { - if (this.variant === KeyVariant.ACCOUNT_ID) { - return bytes_1.concat([Uint8Array.from([this.variant]), this.account.toBytes()]); - } - else if (this.variant === KeyVariant.HASH_ID) { - return bytes_1.concat([Uint8Array.from([this.variant]), this.hash]); - } - else if (this.variant === KeyVariant.UREF_ID) { - return bytes_1.concat([Uint8Array.from([this.variant]), this.uRef.toBytes()]); - } - else { - throw new Error('Unknown variant'); - } - }; - KeyValue.fromBytes = function (bytes) { - if (bytes.length < 1) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var tag = bytes[0]; - var currentPos = 1; - if (tag === KeyVariant.HASH_ID) { - var hashBytes = bytes.subarray(currentPos, 32 + currentPos); - currentPos += 32; - var key = KeyValue_1.fromHash(hashBytes); - return Result.Ok(key, bytes.subarray(currentPos)); - } - else if (tag === KeyVariant.UREF_ID) { - var urefBytes = bytes.subarray(1); - var urefResult = URef.fromBytes(urefBytes); - if (urefResult.hasError()) { - return Result.Err(urefResult.error); - } - var key = KeyValue_1.fromURef(urefResult.value()); - return Result.Ok(key, urefResult.remainder()); - } - else if (tag === KeyVariant.ACCOUNT_ID) { - var accountHashBytes = bytes.subarray(1); - var accountHashResult = AccountHash.fromBytes(accountHashBytes); - if (accountHashResult.hasError()) { - return Result.Err(accountHashResult.error); - } - var key = KeyValue_1.fromAccount(accountHashResult.value()); - return Result.Ok(key, accountHashResult.remainder()); - } - else { - return Result.Err(FromBytesError.FormattingError); - } - }; - var KeyValue_1; - KeyValue = KeyValue_1 = __decorate([ - staticImplements() - ], KeyValue); - return KeyValue; - }(CLTypedAndToBytes)); - exports.KeyValue = KeyValue; - var FORMATTED_STRING_PREFIX = 'uref-'; - /** - * Length of [[URef]] address field. - * @internal - */ - var UREF_ADDR_LENGTH = 32; - /** - * Length of [[ACCESS_RIGHT]] field. - * @internal - */ - var ACCESS_RIGHT_LENGTH = 1; - var UREF_BYTES_LENGTH = UREF_ADDR_LENGTH + ACCESS_RIGHT_LENGTH; - var AccessRights; - (function (AccessRights) { - // No permissions - AccessRights[AccessRights["None"] = 0] = "None"; - // Permission to read the value under the associated [[URef]]. - AccessRights[AccessRights["READ"] = 1] = "READ"; - // Permission to write a value under the associated [[URef]]. - AccessRights[AccessRights["WRITE"] = 2] = "WRITE"; - // Permission to add to the value under the associated [[URef]]. - AccessRights[AccessRights["ADD"] = 4] = "ADD"; - // Permission to read or write the value under the associated [[URef]]. - AccessRights[AccessRights["READ_WRITE"] = 3] = "READ_WRITE"; - // Permission to read or add to the value under the associated [[URef]]. - AccessRights[AccessRights["READ_ADD"] = 5] = "READ_ADD"; - // Permission to add to, or write the value under the associated [[URef]]. - AccessRights[AccessRights["ADD_WRITE"] = 6] = "ADD_WRITE"; - // Permission to read, add to, or write the value under the associated [[URef]]. - AccessRights[AccessRights["READ_ADD_WRITE"] = 7] = "READ_ADD_WRITE"; - })(AccessRights = exports.AccessRights || (exports.AccessRights = {})); - var URef = /** @class */ (function (_super) { - __extends(URef, _super); - /** - * Constructs new instance of URef. - * @param uRefAddr Bytes representing address of the URef. - * @param accessRights Access rights flag. Use [[AccessRights.NONE]] to indicate no permissions. - */ - function URef(uRefAddr, accessRights) { - var _this = _super.call(this) || this; - _this.uRefAddr = uRefAddr; - _this.accessRights = accessRights; - if (_this.uRefAddr.byteLength !== 32) { - throw new Error('The length of URefAddr should be 32'); - } - return _this; - } - URef_1 = URef; - /** - * Parses a casper-client supported string formatted argument into a `URef`. - */ - URef.fromFormattedStr = function (input) { - if (!input.startsWith(FORMATTED_STRING_PREFIX)) { - throw new Error("prefix is not 'uref-'"); - } - var parts = input.substring(FORMATTED_STRING_PREFIX.length).split('-', 2); - if (parts.length !== 2) { - throw new Error('no access rights as suffix'); - } - var addr = Conversions_1.decodeBase16(parts[0]); - var accessRight = parseInt(parts[1], 8); - return new URef_1(addr, accessRight); - }; - URef.prototype.toFormattedStr = function () { - return [ - FORMATTED_STRING_PREFIX, - Conversions_1.encodeBase16(this.uRefAddr), - this.accessRights.toString(8) - ].join('-'); - }; - /** - * Serializes the URef into an array of bytes that represents it in the Casper serialization - * format. - */ - URef.prototype.toBytes = function () { - return bytes_1.concat([this.uRefAddr, Uint8Array.from([this.accessRights])]); - }; - URef.prototype.clType = function () { - return CLTypeHelper.uRef(); - }; - URef.fromBytes = function (bytes) { - if (bytes.length < UREF_BYTES_LENGTH) { - return Result.Err(FromBytesError.EarlyEndOfStream); - } - var urefBytes = bytes.subarray(0, UREF_ADDR_LENGTH); - var accessRights = bytes[UREF_BYTES_LENGTH - 1]; - var uref = new URef_1(urefBytes, accessRights); - return Result.Ok(uref, bytes.subarray(UREF_BYTES_LENGTH)); - }; - var URef_1; - URef = URef_1 = __decorate([ - staticImplements(), - __metadata("design:paramtypes", [Uint8Array, Number]) - ], URef); - return URef; - }(CLTypedAndToBytes)); - exports.URef = URef; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./Contracts":185,"./Conversions":186,"./Keys":188,"./byterepr":193,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"buffer":266,"typedjson":166}],183:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.CasperClient = void 0; - var services_1 = require("../services"); - var index_1 = require("./index"); - var Conversions_1 = require("./Conversions"); - var Keys_1 = require("./Keys"); - var CasperHDKey_1 = require("./CasperHDKey"); - var bignumber_1 = require("@ethersproject/bignumber"); - var CasperClient = /** @class */ (function () { - function CasperClient(nodeUrl) { - this.nodeClient = new services_1.CasperServiceByJsonRPC(nodeUrl); - } - /** - * Generate new key pair. - * @param algo Currently we support Ed25519 and Secp256K1. - */ - CasperClient.prototype.newKeyPair = function (algo) { - switch (algo) { - case Keys_1.SignatureAlgorithm.Ed25519: - return index_1.Keys.Ed25519.new(); - case Keys_1.SignatureAlgorithm.Secp256K1: - return index_1.Keys.Secp256K1.new(); - default: - throw new Error('Invalid signature algorithm'); - } - }; - /** - * Load private key from file - * - * @param path the path to the publicKey file - * @param algo the signature algorithm of the file - */ - CasperClient.prototype.loadPublicKeyFromFile = function (path, algo) { - switch (algo) { - case Keys_1.SignatureAlgorithm.Ed25519: - return index_1.Keys.Ed25519.parsePublicKeyFile(path); - case Keys_1.SignatureAlgorithm.Secp256K1: - return index_1.Keys.Secp256K1.parsePublicKeyFile(path); - default: - throw new Error('Invalid signature algorithm'); - } - }; - /** - * Load private key - * @param path the path to the private key file - */ - CasperClient.prototype.loadPrivateKeyFromFile = function (path, algo) { - switch (algo) { - case Keys_1.SignatureAlgorithm.Ed25519: - return index_1.Keys.Ed25519.parsePrivateKeyFile(path); - case Keys_1.SignatureAlgorithm.Secp256K1: - return index_1.Keys.Secp256K1.parsePrivateKeyFile(path); - default: - throw new Error('Invalid signature algorithm'); - } - }; - /** - * Load private key file to restore keyPair - * - * @param path The path to the private key - * @param algo - */ - CasperClient.prototype.loadKeyPairFromPrivateFile = function (path, algo) { - switch (algo) { - case Keys_1.SignatureAlgorithm.Ed25519: - return index_1.Keys.Ed25519.loadKeyPairFromPrivateFile(path); - case Keys_1.SignatureAlgorithm.Secp256K1: - return index_1.Keys.Secp256K1.loadKeyPairFromPrivateFile(path); - default: - throw new Error('Invalid signature algorithm'); - } - }; - /** - * Create a new hierarchical deterministic wallet, supporting bip32 protocol - * - * @param seed The seed buffer for parent key - */ - CasperClient.prototype.newHdWallet = function (seed) { - return CasperHDKey_1.CasperHDKey.fromMasterSeed(seed); - }; - /** - * Compute public key from private Key. - * @param privateKey - */ - CasperClient.prototype.privateToPublicKey = function (privateKey, algo) { - switch (algo) { - case Keys_1.SignatureAlgorithm.Ed25519: - return index_1.Keys.Ed25519.privateToPublicKey(privateKey); - case Keys_1.SignatureAlgorithm.Secp256K1: - return index_1.Keys.Secp256K1.privateToPublicKey(privateKey); - default: - throw new Error('Invalid signature algorithm'); - } - }; - /** - * Construct a unsigned Deploy object - * - * @param deployParams Parameters for deploy - * @param session - * @param payment - */ - CasperClient.prototype.makeDeploy = function (deployParams, session, payment) { - return index_1.DeployUtil.makeDeploy(deployParams, session, payment); - }; - /** - * Sign the deploy with the specified signKeyPair - * @param deploy unsigned Deploy object - * @param signKeyPair the keypair to sign the Deploy object - */ - CasperClient.prototype.signDeploy = function (deploy, signKeyPair) { - return index_1.DeployUtil.signDeploy(deploy, signKeyPair); - }; - /** - * Send deploy to network - * @param signedDeploy Signed deploy object - */ - CasperClient.prototype.putDeploy = function (signedDeploy) { - return this.nodeClient.deploy(signedDeploy).then(function (it) { return it.deploy_hash; }); - }; - /** - * convert the deploy object to json - * @param deploy - */ - CasperClient.prototype.deployToJson = function (deploy) { - return index_1.DeployUtil.deployToJson(deploy); - }; - /** - * Convert the json to deploy object - * - * @param json - */ - CasperClient.prototype.deployFromJson = function (json) { - return index_1.DeployUtil.deployFromJson(json); - }; - /** - * Construct the deploy for transfer purpose - * - * @param deployParams - * @param session - * @param payment - */ - CasperClient.prototype.makeTransferDeploy = function (deployParams, session, payment) { - if (!session.isTransfer()) { - throw new Error('The session is not a Transfer ExecutableDeployItem'); - } - return this.makeDeploy(deployParams, session, payment); - }; - /** - * Get the balance of public key - */ - CasperClient.prototype.balanceOfByPublicKey = function (publicKey) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, this.balanceOfByAccountHash(Conversions_1.encodeBase16(publicKey.toAccountHash()))]; - }); - }); - }; - /** - * Get the balance by account hash - */ - CasperClient.prototype.balanceOfByAccountHash = function (accountHashStr) { - return __awaiter(this, void 0, void 0, function () { - var stateRootHash, balanceUref, e_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - return [4 /*yield*/, this.nodeClient - .getLatestBlockInfo() - .then(function (it) { var _a; return (_a = it.block) === null || _a === void 0 ? void 0 : _a.header.state_root_hash; })]; - case 1: - stateRootHash = _a.sent(); - // Find the balance Uref and cache it if we don't have it. - if (!stateRootHash) { - return [2 /*return*/, bignumber_1.BigNumber.from(0)]; - } - return [4 /*yield*/, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(stateRootHash, accountHashStr)]; - case 2: - balanceUref = _a.sent(); - if (!balanceUref) { - return [2 /*return*/, bignumber_1.BigNumber.from(0)]; - } - return [4 /*yield*/, this.nodeClient.getAccountBalance(stateRootHash, balanceUref)]; - case 3: return [2 /*return*/, _a.sent()]; - case 4: - e_1 = _a.sent(); - return [2 /*return*/, bignumber_1.BigNumber.from(0)]; - case 5: return [2 /*return*/]; - } - }); - }); - }; - /** - * Get deploy by hash from RPC. - * @param deployHash - * @returns Tuple of Deploy and raw RPC response. - */ - CasperClient.prototype.getDeploy = function (deployHash) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.nodeClient - .getDeployInfo(deployHash) - .then(function (result) { - return [index_1.DeployUtil.deployFromJson(result), result]; - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - /** - * Get the main purse uref for the specified publicKey - * @param publicKey - */ - CasperClient.prototype.getAccountMainPurseUref = function (publicKey) { - return __awaiter(this, void 0, void 0, function () { - var stateRootHash, balanceUref; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.nodeClient - .getLatestBlockInfo() - .then(function (it) { var _a; return (_a = it.block) === null || _a === void 0 ? void 0 : _a.header.state_root_hash; })]; - case 1: - stateRootHash = _a.sent(); - if (!stateRootHash) { - return [2 /*return*/, null]; - } - return [4 /*yield*/, this.nodeClient.getAccountBalanceUrefByPublicKeyHash(stateRootHash, Conversions_1.encodeBase16(publicKey.toAccountHash()))]; - case 2: - balanceUref = _a.sent(); - return [2 /*return*/, balanceUref]; - } - }); - }); - }; - return CasperClient; - }()); - exports.CasperClient = CasperClient; - - },{"../services":198,"./CasperHDKey":184,"./Conversions":186,"./Keys":188,"./index":194,"@ethersproject/bignumber":4}],184:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.CasperHDKey = void 0; - var hdkey_1 = require("ethereum-cryptography/hdkey"); - var sha256_1 = require("ethereum-cryptography/sha256"); - var Keys_1 = require("./Keys"); - var CasperHDKey = /** @class */ (function () { - function CasperHDKey(hdKey) { - this.hdKey = hdKey; - // Registered at https://github.com/satoshilabs/slips/blob/master/slip-0044.md - this.bip44Index = 506; - } - // see https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#path-levels - CasperHDKey.prototype.bip44Path = function (index) { - return [ - 'm', - "44'", - this.bip44Index + "'", - "0'", - "0", - "" + index // child account index - ].join('/'); - }; - /** - * Generate HDKey from master seed - * @param seed - */ - CasperHDKey.fromMasterSeed = function (seed) { - return new CasperHDKey(hdkey_1.HDKey.fromMasterSeed(Buffer.from(seed))); - }; - CasperHDKey.prototype.publicKey = function () { - return this.hdKey.publicKey; - }; - CasperHDKey.prototype.privateKey = function () { - return this.hdKey.privateKey; - }; - CasperHDKey.prototype.privateExtendedKey = function () { - return this.hdKey.privateExtendedKey; - }; - CasperHDKey.prototype.publicExtendedKey = function () { - return this.hdKey.publicExtendedKey; - }; - /** - * Derive the child key basing the path - * @param path - */ - CasperHDKey.prototype.derive = function (path) { - var secpKeyPair = this.hdKey.derive(path); - return new Keys_1.Secp256K1(new Uint8Array(secpKeyPair.publicKey), new Uint8Array(secpKeyPair.privateKey)); - }; - /** - * Derive child key basing the bip44 protocol - * @param index the index of child key - */ - CasperHDKey.prototype.deriveIndex = function (index) { - return this.derive(this.bip44Path(index)); - }; - /** - * Generate the signature for the message by using the key - * @param msg The message to sign - */ - CasperHDKey.prototype.sign = function (msg) { - return this.hdKey.sign(sha256_1.sha256(Buffer.from(msg))); - }; - /** - * Verify the signature - * @param signature the signature generated for the msg - * @param msg the raw message - */ - CasperHDKey.prototype.verify = function (signature, msg) { - return this.hdKey.verify(sha256_1.sha256(Buffer.from(msg)), Buffer.from(signature)); - }; - /** - * Get the JSON representation of the wallet - */ - CasperHDKey.prototype.toJSON = function () { - return this.hdKey.toJSON(); - }; - return CasperHDKey; - }()); - exports.CasperHDKey = CasperHDKey; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./Keys":188,"buffer":266,"ethereum-cryptography/hdkey":73,"ethereum-cryptography/sha256":75}],185:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }); - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; - }; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Transfer = exports.Faucet = exports.BoundContract = exports.Contract = exports.byteHash = void 0; - var blakejs_1 = __importDefault(require("blakejs")); - var fs = __importStar(require("fs")); - var DeployUtil = __importStar(require("./DeployUtil")); - var DeployUtil_1 = require("./DeployUtil"); - var RuntimeArgs_1 = require("./RuntimeArgs"); - var CLValue_1 = require("./CLValue"); - // https://www.npmjs.com/package/tweetnacl-ts - // https://github.com/dcposch/blakejs - /** - * Use blake2b to compute hash of ByteArray - * - * @param x - */ - function byteHash(x) { - return blakejs_1.default.blake2b(x, null, 32); - } - exports.byteHash = byteHash; - var Contract = /** @class */ (function () { - /** - * - * @param sessionPath - * @param paymentPath the path of payment contract file, set it undefined if you want use standard payment - */ - function Contract(sessionPath, paymentPath) { - this.sessionWasm = fs.readFileSync(sessionPath); - if (!paymentPath) { - this.paymentWasm = Buffer.from(''); - } - else { - this.paymentWasm = fs.readFileSync(paymentPath); - } - } - /** - * Generate the Deploy message for this contract - * - * @param args Arguments - * @param paymentAmount - * @param accountPublicKey - * @param signingKeyPair key pair to sign the deploy - * @param chainName - */ - Contract.prototype.deploy = function (args, paymentAmount, accountPublicKey, signingKeyPair, chainName) { - var session = DeployUtil_1.ExecutableDeployItem.newModuleBytes(this.sessionWasm, args); - var paymentArgs = RuntimeArgs_1.RuntimeArgs.fromMap({ - amount: CLValue_1.CLValue.u512(paymentAmount.toString()) - }); - var payment = DeployUtil_1.ExecutableDeployItem.newModuleBytes(this.paymentWasm, paymentArgs); - var deploy = DeployUtil.makeDeploy(new DeployUtil_1.DeployParams(accountPublicKey, chainName), session, payment); - return DeployUtil.signDeploy(deploy, signingKeyPair); - }; - return Contract; - }()); - exports.Contract = Contract; - /** - * Always use the same account for deploying and signing. - */ - var BoundContract = /** @class */ (function () { - function BoundContract(contract, contractKeyPair) { - this.contract = contract; - this.contractKeyPair = contractKeyPair; - } - BoundContract.prototype.deploy = function (args, paymentAmount, chainName) { - return this.contract.deploy(args, paymentAmount, this.contractKeyPair.publicKey, this.contractKeyPair, chainName); - }; - return BoundContract; - }()); - exports.BoundContract = BoundContract; - var Faucet = /** @class */ (function () { - function Faucet() { - } - /** - * Arguments for Faucet smart contract - * - * @param accountPublicKeyHash the public key hash that want to be funded - */ - Faucet.args = function (accountPublicKeyHash) { - var accountKey = CLValue_1.KeyValue.fromAccount(new CLValue_1.AccountHash(accountPublicKeyHash)); - return RuntimeArgs_1.RuntimeArgs.fromMap({ - account: CLValue_1.CLValue.key(accountKey) - }); - }; - return Faucet; - }()); - exports.Faucet = Faucet; - var Transfer = /** @class */ (function () { - function Transfer() { - } - /** - * Arguments for Transfer smart contract - * - * @param accountPublicKeyHash the target account to transfer tokens - * @param amount the amount of tokens to transfer - */ - Transfer.args = function (accountPublicKeyHash, amount) { - var account = CLValue_1.CLValue.key(CLValue_1.KeyValue.fromAccount(new CLValue_1.AccountHash(accountPublicKeyHash))); - return RuntimeArgs_1.RuntimeArgs.fromMap({ - account: account, - amount: CLValue_1.CLValue.u512(amount.toString()) - }); - }; - return Transfer; - }()); - exports.Transfer = Transfer; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./CLValue":182,"./DeployUtil":187,"./RuntimeArgs":189,"blakejs":43,"buffer":266,"fs":199}],186:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.decodeBase16 = exports.encodeBase16 = exports.base64to16 = void 0; - var tweetnacl_util_1 = require("tweetnacl-util"); - // https://nodejs.org/api/buffer.html - var tweetnacl_util_2 = require("tweetnacl-util"); - Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return tweetnacl_util_2.encodeBase64; } }); - Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return tweetnacl_util_2.decodeBase64; } }); - /** - * Convert base64 encoded string to base16 encoded string - * - * @param base64 base64 encoded string - */ - function base64to16(base64) { - return encodeBase16(tweetnacl_util_1.decodeBase64(base64)); - } - exports.base64to16 = base64to16; - /** - * Encode Uint8Array into string using Base-16 encoding. - */ - function encodeBase16(bytes) { - return Buffer.from(bytes).toString('hex'); - } - exports.encodeBase16 = encodeBase16; - /** - * Decode Base-16 encoded string and returns Uint8Array of bytes. - * - * @param base16String base16 encoded string - */ - function decodeBase16(base16String) { - return new Uint8Array(Buffer.from(base16String, 'hex')); - } - exports.decodeBase16 = decodeBase16; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266,"tweetnacl-util":163}],187:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); - }; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.deployToBytes = exports.validateDeploy = exports.deploySizeInBytes = exports.addArgToDeploy = exports.deployFromJson = exports.deployToJson = exports.standardPayment = exports.setSignature = exports.signDeploy = exports.makeDeploy = exports.DeployParams = exports.ContractType = exports.serializeApprovals = exports.serializeBody = exports.serializeHeader = exports.Deploy = exports.ExecutableDeployItem = exports.Transfer = exports.StoredVersionedContractByHash = exports.StoredVersionedContractByName = exports.StoredContractByName = exports.StoredContractByHash = exports.ModuleBytes = exports.Approval = exports.DeployHeader = exports.UniqAddress = exports.dehumanizerTTL = exports.humanizerTTL = void 0; - /** - * Util methods for making Deploy message - * - * @packageDocumentation - */ - var bytes_1 = require("@ethersproject/bytes"); - var blakejs_1 = __importDefault(require("blakejs")); - var option_1 = require("./option"); - var Conversions_1 = require("./Conversions"); - var humanize_duration_1 = __importDefault(require("humanize-duration")); - var CLValue_1 = require("./CLValue"); - var byterepr_1 = require("./byterepr"); - var RuntimeArgs_1 = require("./RuntimeArgs"); - // import JSBI from 'jsbi'; - var index_1 = require("./index"); - var Keys_1 = require("./Keys"); - var bignumber_1 = require("@ethersproject/bignumber"); - var typedjson_1 = require("typedjson"); - var tweetnacl_ts_1 = require("tweetnacl-ts"); - var ts_results_1 = require("ts-results"); - var shortEnglishHumanizer = humanize_duration_1.default.humanizer({ - spacer: '', - serialComma: false, - conjunction: ' ', - delimiter: ' ', - language: 'shortEn', - languages: { - // https://docs.rs/humantime/2.0.1/humantime/fn.parse_duration.html - shortEn: { - d: function () { return 'day'; }, - h: function () { return 'h'; }, - m: function () { return 'm'; }, - s: function () { return 's'; }, - ms: function () { return 'ms'; } - } - } - }); - var byteArrayJsonSerializer = function (bytes) { - return Conversions_1.encodeBase16(bytes); - }; - var byteArrayJsonDeserializer = function (str) { - return Conversions_1.decodeBase16(str); - }; - /** - * Returns a humanizer duration - * @param ttl in milliseconds - */ - exports.humanizerTTL = function (ttl) { - return shortEnglishHumanizer(ttl); - }; - /** - * Returns duration in ms - * @param ttl in humanized string - */ - exports.dehumanizerTTL = function (ttl) { - var dehumanizeUnit = function (s) { - if (s.includes('ms')) { - return Number(s.replace('ms', '')); - } - if (s.includes('s') && !s.includes('m')) { - return Number(s.replace('s', '')) * 1000; - } - if (s.includes('m') && !s.includes('s')) { - return Number(s.replace('m', '')) * 60 * 1000; - } - if (s.includes('h')) { - return Number(s.replace('h', '')) * 60 * 60 * 1000; - } - if (s.includes('day')) { - return Number(s.replace('day', '')) * 24 * 60 * 60 * 1000; - } - throw Error('Unsuported TTL unit'); - }; - return ttl - .split(' ') - .map(dehumanizeUnit) - .reduce(function (acc, val) { return (acc += val); }); - }; - var UniqAddress = /** @class */ (function () { - /** - * Constructs UniqAddress - * @param publicKey PublicKey instance - * @param transferId BigNumberish value (can be also string representing number). Max U64. - */ - function UniqAddress(publicKey, transferId) { - if (!(publicKey instanceof CLValue_1.PublicKey)) { - throw new Error('publicKey is not an instance of PublicKey'); - } - var bigNum = bignumber_1.BigNumber.from(transferId); - if (bigNum.gt('18446744073709551615')) { - throw new Error('transferId max value is U64'); - } - this.transferId = bigNum; - this.publicKey = publicKey; - } - /** - * Returns string in format "accountHex-transferIdHex" - * @param ttl in humanized string - */ - UniqAddress.prototype.toString = function () { - return this.publicKey.toAccountHex() + "-" + this.transferId.toHexString(); - }; - /** - * Builds UniqAddress from string - * @param value value returned from UniqAddress.toString() - */ - UniqAddress.fromString = function (value) { - var _a = value.split('-'), accountHex = _a[0], transferHex = _a[1]; - var publicKey = CLValue_1.PublicKey.fromHex(accountHex); - return new UniqAddress(publicKey, transferHex); - }; - return UniqAddress; - }()); - exports.UniqAddress = UniqAddress; - var DeployHeader = /** @class */ (function () { - /** - * The header portion of a Deploy - * - * @param account The account within which the deploy will be run. - * @param timestamp When the deploy was created. - * @param ttl How long the deploy will stay valid. - * @param gasPrice Price per gas unit for this deploy. - * @param bodyHash Hash of the Wasm code. - * @param dependencies Other deploys that have to be run before this one. - * @param chainName Which chain the deploy is supposed to be run on. - */ - function DeployHeader(account, timestamp, ttl, gasPrice, bodyHash, dependencies, chainName) { - this.account = account; - this.timestamp = timestamp; - this.ttl = ttl; - this.gasPrice = gasPrice; - this.bodyHash = bodyHash; - this.dependencies = dependencies; - this.chainName = chainName; - } - DeployHeader.prototype.toBytes = function () { - return bytes_1.concat([ - this.account.toBytes(), - byterepr_1.toBytesU64(this.timestamp), - byterepr_1.toBytesU64(this.ttl), - byterepr_1.toBytesU64(this.gasPrice), - byterepr_1.toBytesDeployHash(this.bodyHash), - byterepr_1.toBytesVecT(this.dependencies.map(function (d) { return new DeployHash(d); })), - byterepr_1.toBytesString(this.chainName) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ - serializer: function (account) { - return account.toAccountHex(); - }, - deserializer: function (hexStr) { - return CLValue_1.PublicKey.fromHex(hexStr); - } - }), - __metadata("design:type", CLValue_1.PublicKey) - ], DeployHeader.prototype, "account", void 0); - __decorate([ - typedjson_1.jsonMember({ - serializer: function (n) { return new Date(n).toISOString(); }, - deserializer: function (s) { return Date.parse(s); } - }), - __metadata("design:type", Number) - ], DeployHeader.prototype, "timestamp", void 0); - __decorate([ - typedjson_1.jsonMember({ - serializer: exports.humanizerTTL, - deserializer: exports.dehumanizerTTL - }), - __metadata("design:type", Number) - ], DeployHeader.prototype, "ttl", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: Number, name: 'gas_price' }), - __metadata("design:type", Number) - ], DeployHeader.prototype, "gasPrice", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'body_hash', - serializer: byteArrayJsonSerializer, - deserializer: byteArrayJsonDeserializer - }), - __metadata("design:type", Uint8Array) - ], DeployHeader.prototype, "bodyHash", void 0); - __decorate([ - typedjson_1.jsonArrayMember(tweetnacl_ts_1.ByteArray, { - serializer: function (value) { - return value.map(function (it) { return byteArrayJsonSerializer(it); }); - }, - deserializer: function (json) { - return json.map(function (it) { return byteArrayJsonDeserializer(it); }); - } - }), - __metadata("design:type", Array) - ], DeployHeader.prototype, "dependencies", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'chain_name', constructor: String }), - __metadata("design:type", String) - ], DeployHeader.prototype, "chainName", void 0); - DeployHeader = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [CLValue_1.PublicKey, Number, Number, Number, Uint8Array, Array, String]) - ], DeployHeader); - return DeployHeader; - }()); - exports.DeployHeader = DeployHeader; - /** - * The cryptographic hash of a Deploy. - */ - var DeployHash = /** @class */ (function () { - function DeployHash(hash) { - this.hash = hash; - } - DeployHash.prototype.toBytes = function () { - return byterepr_1.toBytesDeployHash(this.hash); - }; - return DeployHash; - }()); - /** - * A struct containing a signature and the public key of the signer. - */ - var Approval = /** @class */ (function () { - function Approval() { - } - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], Approval.prototype, "signer", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], Approval.prototype, "signature", void 0); - Approval = __decorate([ - typedjson_1.jsonObject - ], Approval); - return Approval; - }()); - exports.Approval = Approval; - var ExecutableDeployItemInternal = /** @class */ (function () { - function ExecutableDeployItemInternal() { - } - ExecutableDeployItemInternal.prototype.getArgByName = function (name) { - return this.args.args.get(name); - }; - ExecutableDeployItemInternal.prototype.setArg = function (name, value) { - this.args.args.set(name, value); - }; - return ExecutableDeployItemInternal; - }()); - var desRA = function (arr) { - var raSerializer = new typedjson_1.TypedJSON(RuntimeArgs_1.RuntimeArgs); - var value = { - args: arr - }; - return raSerializer.parse(value); - }; - var serRA = function (ra) { - var raSerializer = new typedjson_1.TypedJSON(RuntimeArgs_1.RuntimeArgs); - var json = raSerializer.toPlainJson(ra); - return Object.values(json)[0]; - }; - var ModuleBytes = /** @class */ (function (_super) { - __extends(ModuleBytes, _super); - function ModuleBytes(moduleBytes, args) { - var _this = _super.call(this) || this; - _this.tag = 0; - _this.moduleBytes = moduleBytes; - _this.args = args; - return _this; - } - ModuleBytes.prototype.toBytes = function () { - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesArrayU8(this.moduleBytes), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ - name: 'module_bytes', - serializer: byteArrayJsonSerializer, - deserializer: byteArrayJsonDeserializer - }), - __metadata("design:type", Uint8Array) - ], ModuleBytes.prototype, "moduleBytes", void 0); - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], ModuleBytes.prototype, "args", void 0); - ModuleBytes = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [Uint8Array, RuntimeArgs_1.RuntimeArgs]) - ], ModuleBytes); - return ModuleBytes; - }(ExecutableDeployItemInternal)); - exports.ModuleBytes = ModuleBytes; - var StoredContractByHash = /** @class */ (function (_super) { - __extends(StoredContractByHash, _super); - function StoredContractByHash(hash, entryPoint, args) { - var _this = _super.call(this) || this; - _this.tag = 1; - _this.entryPoint = entryPoint; - _this.args = args; - _this.hash = hash; - return _this; - } - StoredContractByHash.prototype.toBytes = function () { - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesBytesArray(this.hash), - byterepr_1.toBytesString(this.entryPoint), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ - serializer: byteArrayJsonSerializer, - deserializer: byteArrayJsonDeserializer - }), - __metadata("design:type", Uint8Array) - ], StoredContractByHash.prototype, "hash", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'entry_point', - constructor: String - }), - __metadata("design:type", String) - ], StoredContractByHash.prototype, "entryPoint", void 0); - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], StoredContractByHash.prototype, "args", void 0); - StoredContractByHash = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [Uint8Array, String, RuntimeArgs_1.RuntimeArgs]) - ], StoredContractByHash); - return StoredContractByHash; - }(ExecutableDeployItemInternal)); - exports.StoredContractByHash = StoredContractByHash; - var StoredContractByName = /** @class */ (function (_super) { - __extends(StoredContractByName, _super); - function StoredContractByName(name, entryPoint, args) { - var _this = _super.call(this) || this; - _this.tag = 2; - _this.name = name; - _this.entryPoint = entryPoint; - _this.args = args; - return _this; - } - StoredContractByName.prototype.toBytes = function () { - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesString(this.name), - byterepr_1.toBytesString(this.entryPoint), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], StoredContractByName.prototype, "name", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'entry_point', - constructor: String - }), - __metadata("design:type", String) - ], StoredContractByName.prototype, "entryPoint", void 0); - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], StoredContractByName.prototype, "args", void 0); - StoredContractByName = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [String, String, RuntimeArgs_1.RuntimeArgs]) - ], StoredContractByName); - return StoredContractByName; - }(ExecutableDeployItemInternal)); - exports.StoredContractByName = StoredContractByName; - var StoredVersionedContractByName = /** @class */ (function (_super) { - __extends(StoredVersionedContractByName, _super); - function StoredVersionedContractByName(name, version, entryPoint, args) { - var _this = _super.call(this) || this; - _this.tag = 4; - _this.name = name; - _this.version = version; - _this.entryPoint = entryPoint; - _this.args = args; - return _this; - } - StoredVersionedContractByName.prototype.toBytes = function () { - var serializedVersion; - if (this.version === null) { - serializedVersion = new option_1.Option(null, CLValue_1.CLTypeHelper.u32()); - } - else { - serializedVersion = new option_1.Option(new CLValue_1.U32(this.version)); - } - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesString(this.name), - serializedVersion.toBytes(), - byterepr_1.toBytesString(this.entryPoint), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], StoredVersionedContractByName.prototype, "name", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: Number, preserveNull: true }), - __metadata("design:type", Object) - ], StoredVersionedContractByName.prototype, "version", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'entry_point', constructor: String }), - __metadata("design:type", String) - ], StoredVersionedContractByName.prototype, "entryPoint", void 0); - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], StoredVersionedContractByName.prototype, "args", void 0); - StoredVersionedContractByName = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [String, Object, String, RuntimeArgs_1.RuntimeArgs]) - ], StoredVersionedContractByName); - return StoredVersionedContractByName; - }(ExecutableDeployItemInternal)); - exports.StoredVersionedContractByName = StoredVersionedContractByName; - var StoredVersionedContractByHash = /** @class */ (function (_super) { - __extends(StoredVersionedContractByHash, _super); - function StoredVersionedContractByHash(hash, version, entryPoint, args) { - var _this = _super.call(this) || this; - _this.tag = 3; - _this.hash = hash; - _this.version = version; - _this.entryPoint = entryPoint; - _this.args = args; - return _this; - } - StoredVersionedContractByHash.prototype.toBytes = function () { - var serializedVersion; - if (this.version === null) { - serializedVersion = new option_1.Option(null, CLValue_1.CLTypeHelper.u32()); - } - else { - serializedVersion = new option_1.Option(new CLValue_1.U32(this.version)); - } - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesBytesArray(this.hash), - serializedVersion.toBytes(), - byterepr_1.toBytesString(this.entryPoint), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ - serializer: byteArrayJsonSerializer, - deserializer: byteArrayJsonDeserializer - }), - __metadata("design:type", Uint8Array) - ], StoredVersionedContractByHash.prototype, "hash", void 0); - __decorate([ - typedjson_1.jsonMember({ - constructor: Number, - preserveNull: true - }), - __metadata("design:type", Object) - ], StoredVersionedContractByHash.prototype, "version", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'entry_point', - constructor: String - }), - __metadata("design:type", String) - ], StoredVersionedContractByHash.prototype, "entryPoint", void 0); - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], StoredVersionedContractByHash.prototype, "args", void 0); - StoredVersionedContractByHash = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [Uint8Array, Object, String, RuntimeArgs_1.RuntimeArgs]) - ], StoredVersionedContractByHash); - return StoredVersionedContractByHash; - }(ExecutableDeployItemInternal)); - exports.StoredVersionedContractByHash = StoredVersionedContractByHash; - var Transfer = /** @class */ (function (_super) { - __extends(Transfer, _super); - /** - * Constructor for Transfer deploy item. - * @param amount The number of motes to transfer - * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex - * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ - * transfer will be used as the source purse - * @param id user-defined transfer id - */ - function Transfer(args) { - var _this = _super.call(this) || this; - _this.tag = 5; - _this.args = args; - return _this; - } - Transfer.prototype.toBytes = function () { - return bytes_1.concat([ - Uint8Array.from([this.tag]), - byterepr_1.toBytesBytesArray(this.args.toBytes()) - ]); - }; - __decorate([ - typedjson_1.jsonMember({ - deserializer: desRA, - serializer: serRA - }), - __metadata("design:type", RuntimeArgs_1.RuntimeArgs) - ], Transfer.prototype, "args", void 0); - Transfer = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [RuntimeArgs_1.RuntimeArgs]) - ], Transfer); - return Transfer; - }(ExecutableDeployItemInternal)); - exports.Transfer = Transfer; - var ExecutableDeployItem = /** @class */ (function () { - function ExecutableDeployItem() { - } - ExecutableDeployItem_1 = ExecutableDeployItem; - ExecutableDeployItem.prototype.toBytes = function () { - if (this.isModuleBytes()) { - return this.moduleBytes.toBytes(); - } - else if (this.isStoredContractByHash()) { - return this.storedContractByHash.toBytes(); - } - else if (this.isStoredContractByName()) { - return this.storedContractByName.toBytes(); - } - else if (this.isStoredVersionContractByHash()) { - return this.storedVersionedContractByHash.toBytes(); - } - else if (this.isStoredVersionContractByName()) { - return this.storedVersionedContractByName.toBytes(); - } - else if (this.isTransfer()) { - return this.transfer.toBytes(); - } - throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); - }; - ExecutableDeployItem.prototype.getArgByName = function (name) { - if (this.isModuleBytes()) { - return this.moduleBytes.getArgByName(name); - } - else if (this.isStoredContractByHash()) { - return this.storedContractByHash.getArgByName(name); - } - else if (this.isStoredContractByName()) { - return this.storedContractByName.getArgByName(name); - } - else if (this.isStoredVersionContractByHash()) { - return this.storedVersionedContractByHash.getArgByName(name); - } - else if (this.isStoredVersionContractByName()) { - return this.storedVersionedContractByName.getArgByName(name); - } - else if (this.isTransfer()) { - return this.transfer.getArgByName(name); - } - throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); - }; - ExecutableDeployItem.prototype.setArg = function (name, value) { - if (this.isModuleBytes()) { - return this.moduleBytes.setArg(name, value); - } - else if (this.isStoredContractByHash()) { - return this.storedContractByHash.setArg(name, value); - } - else if (this.isStoredContractByName()) { - return this.storedContractByName.setArg(name, value); - } - else if (this.isStoredVersionContractByHash()) { - return this.storedVersionedContractByHash.setArg(name, value); - } - else if (this.isStoredVersionContractByName()) { - return this.storedVersionedContractByName.setArg(name, value); - } - else if (this.isTransfer()) { - return this.transfer.setArg(name, value); - } - throw new Error('failed to serialize ExecutableDeployItemJsonWrapper'); - }; - ExecutableDeployItem.fromExecutableDeployItemInternal = function (item) { - var res = new ExecutableDeployItem_1(); - switch (item.tag) { - case 0: - res.moduleBytes = item; - break; - case 1: - res.storedContractByHash = item; - break; - case 2: - res.storedContractByName = item; - break; - case 3: - res.storedVersionedContractByHash = item; - break; - case 4: - res.storedVersionedContractByName = item; - break; - case 5: - res.transfer = item; - break; - } - return res; - }; - ExecutableDeployItem.newModuleBytes = function (moduleBytes, args) { - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new ModuleBytes(moduleBytes, args)); - }; - ExecutableDeployItem.newStoredContractByHash = function (hash, entryPoint, args) { - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredContractByHash(hash, entryPoint, args)); - }; - ExecutableDeployItem.newStoredContractByName = function (name, entryPoint, args) { - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredContractByName(name, entryPoint, args)); - }; - ExecutableDeployItem.newStoredVersionContractByHash = function (hash, version, entryPoint, args) { - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredVersionedContractByHash(hash, version, entryPoint, args)); - }; - ExecutableDeployItem.newStoredVersionContractByName = function (name, version, entryPoint, args) { - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new StoredVersionedContractByName(name, version, entryPoint, args)); - }; - /** - * Constructor for Transfer deploy item. - * @param amount The number of motes to transfer - * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex - * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ - * transfer will be used as the source purse - * @param id user-defined transfer id. This parameter is required. - */ - ExecutableDeployItem.newTransfer = function (amount, target, sourcePurse, id) { - if (sourcePurse === void 0) { sourcePurse = null; } - var runtimeArgs = RuntimeArgs_1.RuntimeArgs.fromMap({}); - runtimeArgs.insert('amount', CLValue_1.CLValue.u512(amount)); - if (sourcePurse) { - runtimeArgs.insert('source', CLValue_1.CLValue.uref(sourcePurse)); - } - if (target instanceof index_1.URef) { - runtimeArgs.insert('target', CLValue_1.CLValue.uref(target)); - } - else if (target instanceof CLValue_1.PublicKey) { - runtimeArgs.insert('target', CLValue_1.CLValue.byteArray(target.toAccountHash())); - } - else { - throw new Error('Please specify target'); - } - if (id === undefined) { - throw new Error('transfer-id missing in new transfer.'); - } - else { - runtimeArgs.insert('id', CLValue_1.CLValue.option(CLValue_1.CLTypedAndToBytesHelper.u64(id), CLValue_1.CLTypeHelper.u64())); - } - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new Transfer(runtimeArgs)); - }; - // TODO: Abstract the logic of this and newTransfer so there won't be so much redundancy. - /** - * Constructor for Transfer deploy item without obligatory transfer-id. - * @param amount The number of motes to transfer - * @param target URef of the target purse or the public key of target account. You could generate this public key from accountHex by PublicKey.fromHex - * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ - * transfer will be used as the source purse - * @param id user-defined transfer id. This parameter is optional. - */ - ExecutableDeployItem.newTransferWithOptionalTransferId = function (amount, target, sourcePurse, id) { - var runtimeArgs = RuntimeArgs_1.RuntimeArgs.fromMap({}); - runtimeArgs.insert('amount', CLValue_1.CLValue.u512(amount)); - if (sourcePurse) { - runtimeArgs.insert('source', CLValue_1.CLValue.uref(sourcePurse)); - } - if (target instanceof index_1.URef) { - runtimeArgs.insert('target', CLValue_1.CLValue.uref(target)); - } - else if (target instanceof CLValue_1.PublicKey) { - runtimeArgs.insert('target', CLValue_1.CLValue.byteArray(target.toAccountHash())); - } - else { - throw new Error('Please specify target'); - } - if (id !== undefined && id !== null) { - runtimeArgs.insert('id', CLValue_1.CLValue.option(CLValue_1.CLTypedAndToBytesHelper.u64(id), CLValue_1.CLTypeHelper.u64())); - } - else { - runtimeArgs.insert('id', CLValue_1.CLValue.option(null, CLValue_1.CLTypeHelper.u64())); - } - return ExecutableDeployItem_1.fromExecutableDeployItemInternal(new Transfer(runtimeArgs)); - }; - /** - * Constructor for Transfer deploy item using UniqAddress. - * @param source PublicKey of source account - * @param target UniqAddress of target account - * @param amount The number of motes to transfer - * @param paymentAmount the number of motes paying to execution engine - * @param chainName Name of the chain, to avoid the `Deploy` from being accidentally or maliciously included in a different chain. - * @param gasPrice Conversion rate between the cost of Wasm opcodes and the motes sent by the payment code. - * @param ttl Time that the `Deploy` will remain valid for, in milliseconds. The default value is 1800000, which is 30 minutes - * @param sourcePurse URef of the source purse. If this is omitted, the main purse of the account creating this \ - * transfer will be used as the source purse - */ - ExecutableDeployItem.newTransferToUniqAddress = function (source, target, amount, paymentAmount, chainName, gasPrice, ttl, sourcePurse) { - if (gasPrice === void 0) { gasPrice = 1; } - if (ttl === void 0) { ttl = 1800000; } - var deployParams = new index_1.DeployUtil.DeployParams(source, chainName, gasPrice, ttl); - var payment = index_1.DeployUtil.standardPayment(paymentAmount); - var session = index_1.DeployUtil.ExecutableDeployItem.newTransfer(amount, target.publicKey, sourcePurse, target.transferId); - return index_1.DeployUtil.makeDeploy(deployParams, session, payment); - }; - ExecutableDeployItem.prototype.isModuleBytes = function () { - return !!this.moduleBytes; - }; - ExecutableDeployItem.prototype.asModuleBytes = function () { - return this.moduleBytes; - }; - ExecutableDeployItem.prototype.isStoredContractByHash = function () { - return !!this.storedContractByHash; - }; - ExecutableDeployItem.prototype.asStoredContractByHash = function () { - return this.storedContractByHash; - }; - ExecutableDeployItem.prototype.isStoredContractByName = function () { - return !!this.storedContractByName; - }; - ExecutableDeployItem.prototype.asStoredContractByName = function () { - return this.storedContractByName; - }; - ExecutableDeployItem.prototype.isStoredVersionContractByName = function () { - return !!this.storedVersionedContractByName; - }; - ExecutableDeployItem.prototype.asStoredVersionContractByName = function () { - return this.storedVersionedContractByName; - }; - ExecutableDeployItem.prototype.isStoredVersionContractByHash = function () { - return !!this.storedVersionedContractByHash; - }; - ExecutableDeployItem.prototype.asStoredVersionContractByHash = function () { - return this.storedVersionedContractByHash; - }; - ExecutableDeployItem.prototype.isTransfer = function () { - return !!this.transfer; - }; - ExecutableDeployItem.prototype.asTransfer = function () { - return this.transfer; - }; - var ExecutableDeployItem_1; - __decorate([ - typedjson_1.jsonMember({ - name: 'ModuleBytes', - constructor: ModuleBytes - }), - __metadata("design:type", ModuleBytes) - ], ExecutableDeployItem.prototype, "moduleBytes", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'StoredContractByHash', - constructor: StoredContractByHash - }), - __metadata("design:type", StoredContractByHash) - ], ExecutableDeployItem.prototype, "storedContractByHash", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'StoredContractByName', - constructor: StoredContractByName - }), - __metadata("design:type", StoredContractByName) - ], ExecutableDeployItem.prototype, "storedContractByName", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'StoredVersionedContractByHash', - constructor: StoredVersionedContractByHash - }), - __metadata("design:type", StoredVersionedContractByHash) - ], ExecutableDeployItem.prototype, "storedVersionedContractByHash", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'StoredVersionedContractByName', - constructor: StoredVersionedContractByName - }), - __metadata("design:type", StoredVersionedContractByName) - ], ExecutableDeployItem.prototype, "storedVersionedContractByName", void 0); - __decorate([ - typedjson_1.jsonMember({ - name: 'Transfer', - constructor: Transfer - }), - __metadata("design:type", Transfer) - ], ExecutableDeployItem.prototype, "transfer", void 0); - ExecutableDeployItem = ExecutableDeployItem_1 = __decorate([ - typedjson_1.jsonObject - ], ExecutableDeployItem); - return ExecutableDeployItem; - }()); - exports.ExecutableDeployItem = ExecutableDeployItem; - /** - * A deploy containing a smart contract along with the requester's signature(s). - */ - var Deploy = /** @class */ (function () { - /** - * - * @param hash The DeployHash identifying this Deploy - * @param header The deployHeader - * @param payment The ExecutableDeployItem for payment code. - * @param session the ExecutableDeployItem for session code. - * @param approvals An array of signature and public key of the signers, who approve this deploy - */ - function Deploy(hash, header, payment, session, approvals) { - this.approvals = approvals; - this.session = session; - this.payment = payment; - this.header = header; - this.hash = hash; - } - Deploy.prototype.isTransfer = function () { - return this.session.isTransfer(); - }; - Deploy.prototype.isStandardPayment = function () { - var _a; - if (this.payment.isModuleBytes()) { - return ((_a = this.payment.asModuleBytes()) === null || _a === void 0 ? void 0 : _a.moduleBytes.length) === 0; - } - return false; - }; - __decorate([ - typedjson_1.jsonMember({ - serializer: byteArrayJsonSerializer, - deserializer: byteArrayJsonDeserializer - }), - __metadata("design:type", Uint8Array) - ], Deploy.prototype, "hash", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: DeployHeader }), - __metadata("design:type", DeployHeader) - ], Deploy.prototype, "header", void 0); - __decorate([ - typedjson_1.jsonMember({ - constructor: ExecutableDeployItem - }), - __metadata("design:type", ExecutableDeployItem) - ], Deploy.prototype, "payment", void 0); - __decorate([ - typedjson_1.jsonMember({ - constructor: ExecutableDeployItem - }), - __metadata("design:type", ExecutableDeployItem) - ], Deploy.prototype, "session", void 0); - __decorate([ - typedjson_1.jsonArrayMember(Approval), - __metadata("design:type", Array) - ], Deploy.prototype, "approvals", void 0); - Deploy = __decorate([ - typedjson_1.jsonObject, - __metadata("design:paramtypes", [Uint8Array, - DeployHeader, - ExecutableDeployItem, - ExecutableDeployItem, Array]) - ], Deploy); - return Deploy; - }()); - exports.Deploy = Deploy; - /** - * Serialize deployHeader into a array of bytes - * @param deployHeader - */ - exports.serializeHeader = function (deployHeader) { - return deployHeader.toBytes(); - }; - /** - * Serialize deployBody into a array of bytes - * @param payment - * @param session - */ - exports.serializeBody = function (payment, session) { - return bytes_1.concat([payment.toBytes(), session.toBytes()]); - }; - exports.serializeApprovals = function (approvals) { - var len = byterepr_1.toBytesU32(approvals.length); - var bytes = bytes_1.concat(approvals.map(function (approval) { - return bytes_1.concat([ - Uint8Array.from(Buffer.from(approval.signer, 'hex')), - Uint8Array.from(Buffer.from(approval.signature, 'hex')) - ]); - })); - return bytes_1.concat([len, bytes]); - }; - /** - * Supported contract type - */ - var ContractType; - (function (ContractType) { - ContractType["WASM"] = "WASM"; - ContractType["Hash"] = "Hash"; - ContractType["Name"] = "Name"; - })(ContractType = exports.ContractType || (exports.ContractType = {})); - var DeployParams = /** @class */ (function () { - /** - * Container for `Deploy` construction options. - * @param accountPublicKey - * @param chainName Name of the chain, to avoid the `Deploy` from being accidentally or maliciously included in a different chain. - * @param gasPrice Conversion rate between the cost of Wasm opcodes and the motes sent by the payment code. - * @param ttl Time that the `Deploy` will remain valid for, in milliseconds. The default value is 1800000, which is 30 minutes - * @param dependencies Hex-encoded `Deploy` hashes of deploys which must be executed before this one. - * @param timestamp If `timestamp` is empty, the current time will be used. Note that timestamp is UTC, not local. - */ - function DeployParams(accountPublicKey, chainName, gasPrice, ttl, dependencies, timestamp) { - if (gasPrice === void 0) { gasPrice = 1; } - if (ttl === void 0) { ttl = 1800000; } - if (dependencies === void 0) { dependencies = []; } - this.accountPublicKey = accountPublicKey; - this.chainName = chainName; - this.gasPrice = gasPrice; - this.ttl = ttl; - this.dependencies = dependencies; - this.timestamp = timestamp; - this.dependencies = dependencies.filter(function (d) { - return dependencies.filter(function (t) { return Conversions_1.encodeBase16(d) === Conversions_1.encodeBase16(t); }).length < 2; - }); - if (!timestamp) { - this.timestamp = Date.now(); - } - } - return DeployParams; - }()); - exports.DeployParams = DeployParams; - /** - * Makes Deploy message - */ - function makeDeploy(deployParam, session, payment) { - var serializedBody = exports.serializeBody(payment, session); - var bodyHash = blakejs_1.default.blake2b(serializedBody, null, 32); - var header = new DeployHeader(deployParam.accountPublicKey, deployParam.timestamp, deployParam.ttl, deployParam.gasPrice, bodyHash, deployParam.dependencies, deployParam.chainName); - var serializedHeader = exports.serializeHeader(header); - var deployHash = blakejs_1.default.blake2b(serializedHeader, null, 32); - return new Deploy(deployHash, header, payment, session, []); - } - exports.makeDeploy = makeDeploy; - /** - * Uses the provided key pair to sign the Deploy message - * - * @param deploy - * @param signingKey the keyPair to sign deploy - */ - exports.signDeploy = function (deploy, signingKey) { - var approval = new Approval(); - var signature = signingKey.sign(deploy.hash); - approval.signer = signingKey.accountHex(); - switch (signingKey.signatureAlgorithm) { - case Keys_1.SignatureAlgorithm.Ed25519: - approval.signature = index_1.Keys.Ed25519.accountHex(signature); - break; - case Keys_1.SignatureAlgorithm.Secp256K1: - approval.signature = index_1.Keys.Secp256K1.accountHex(signature); - break; - } - deploy.approvals.push(approval); - return deploy; - }; - /** - * Sets the already generated Ed25519 signature for the Deploy message - * - * @param deploy - * @param sig the Ed25519 signature - * @param publicKey the public key used to generate the Ed25519 signature - */ - exports.setSignature = function (deploy, sig, publicKey) { - var approval = new Approval(); - approval.signer = publicKey.toAccountHex(); - switch (publicKey.signatureAlgorithm()) { - case Keys_1.SignatureAlgorithm.Ed25519: - approval.signature = index_1.Keys.Ed25519.accountHex(sig); - break; - case Keys_1.SignatureAlgorithm.Secp256K1: - approval.signature = index_1.Keys.Secp256K1.accountHex(sig); - break; - } - deploy.approvals.push(approval); - return deploy; - }; - /** - * Standard payment code. - * - * @param paymentAmount the number of motes paying to execution engine - */ - exports.standardPayment = function (paymentAmount) { - var paymentArgs = RuntimeArgs_1.RuntimeArgs.fromMap({ - amount: CLValue_1.CLValue.u512(paymentAmount.toString()) - }); - return ExecutableDeployItem.newModuleBytes(Uint8Array.from([]), paymentArgs); - }; - /** - * Convert the deploy object to json - * - * @param deploy - */ - exports.deployToJson = function (deploy) { - var serializer = new typedjson_1.TypedJSON(Deploy); - return { - deploy: serializer.toPlainJson(deploy) - }; - }; - /** - * Convert the json to deploy object - * - * @param json - */ - exports.deployFromJson = function (json) { - var serializer = new typedjson_1.TypedJSON(Deploy); - var deploy = serializer.parse(json.deploy); - if (deploy !== undefined && exports.validateDeploy(deploy).ok) { - return deploy; - } - return undefined; - }; - exports.addArgToDeploy = function (deploy, name, value) { - if (deploy.approvals.length !== 0) { - throw Error('Can not add argument to already signed deploy.'); - } - var deployParams = new index_1.DeployUtil.DeployParams(deploy.header.account, deploy.header.chainName, deploy.header.gasPrice, deploy.header.ttl, deploy.header.dependencies, deploy.header.timestamp); - var session = deploy.session; - session.setArg(name, value); - return makeDeploy(deployParams, session, deploy.payment); - }; - exports.deploySizeInBytes = function (deploy) { - var hashSize = deploy.hash.length; - var bodySize = exports.serializeBody(deploy.payment, deploy.session).length; - var headerSize = exports.serializeHeader(deploy.header).length; - var approvalsSize = deploy.approvals - .map(function (approval) { - return (approval.signature.length + approval.signer.length) / 2; - }) - .reduce(function (a, b) { return a + b; }, 0); - return hashSize + headerSize + bodySize + approvalsSize; - }; - exports.validateDeploy = function (deploy) { - var serializedBody = exports.serializeBody(deploy.payment, deploy.session); - var bodyHash = blakejs_1.default.blake2b(serializedBody, null, 32); - if (!arrayEquals(deploy.header.bodyHash, bodyHash)) { - return ts_results_1.Err("Invalid deploy: bodyHash missmatch. Expected: " + bodyHash + ", \n got: " + deploy.header.bodyHash + "."); - } - var serializedHeader = exports.serializeHeader(deploy.header); - var deployHash = blakejs_1.default.blake2b(serializedHeader, null, 32); - if (!arrayEquals(deploy.hash, deployHash)) { - return ts_results_1.Err("Invalid deploy: hash missmatch. Expected: " + deployHash + ", \n got: " + deploy.hash + "."); - } - // TODO: Verify included signatures. - return ts_results_1.Ok(deploy); - }; - var arrayEquals = function (a, b) { - return a.length === b.length && a.every(function (val, index) { return val === b[index]; }); - }; - exports.deployToBytes = function (deploy) { - return bytes_1.concat([ - exports.serializeHeader(deploy.header), - deploy.hash, - exports.serializeBody(deploy.payment, deploy.session), - exports.serializeApprovals(deploy.approvals) - ]); - }; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./CLValue":182,"./Conversions":186,"./Keys":188,"./RuntimeArgs":189,"./byterepr":193,"./index":194,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"blakejs":43,"buffer":266,"humanize-duration":96,"ts-results":136,"tweetnacl-ts":153,"typedjson":166}],188:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }); - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; - }; - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Secp256K1 = exports.Ed25519 = exports.AsymmetricKey = exports.readBase64WithPEM = exports.SignatureAlgorithm = void 0; - var fs = __importStar(require("fs")); - var nacl = __importStar(require("tweetnacl-ts")); - var tweetnacl_util_1 = require("tweetnacl-util"); - var index_1 = require("../index"); - var index_2 = require("../lib/index"); - var Contracts_1 = require("./Contracts"); - var eccrypto_1 = __importDefault(require("eccrypto")); - var secp256k1 = __importStar(require("ethereum-cryptography/secp256k1")); - var key_encoder_1 = __importDefault(require("key-encoder")); - var sha256_1 = require("ethereum-cryptography/sha256"); - var keyEncoder = new key_encoder_1.default('secp256k1'); - var ED25519_PEM_SECRET_KEY_TAG = 'PRIVATE KEY'; - var ED25519_PEM_PUBLIC_KEY_TAG = 'PUBLIC KEY'; - /** - * Supported types of Asymmetric Key algorithm - */ - var SignatureAlgorithm; - (function (SignatureAlgorithm) { - SignatureAlgorithm["Ed25519"] = "ed25519"; - SignatureAlgorithm["Secp256K1"] = "secp256k1"; - })(SignatureAlgorithm = exports.SignatureAlgorithm || (exports.SignatureAlgorithm = {})); - function accountHashHelper(signatureAlgorithm, publicKey) { - var separator = Buffer.from([0]); - var prefix = Buffer.concat([Buffer.from(signatureAlgorithm), separator]); - if (publicKey.length === 0) { - return Buffer.from([]); - } - else { - return Contracts_1.byteHash(Buffer.concat([prefix, Buffer.from(publicKey)])); - } - } - /** - * Get rid of PEM frames, skips header `-----BEGIN PUBLIC KEY-----` - * and footer `-----END PUBLIC KEY-----` - * - * Example PEM: - * - * ``` - * -----BEGIN PUBLIC KEY-----\r\n - * MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEj1fgdbpNbt06EY/8C+wbBXq6VvG+vCVD\r\n - * Nl74LvVAmXfpdzCWFKbdrnIlX3EFDxkd9qpk35F/kLcqV3rDn/u3dg==\r\n - * -----END PUBLIC KEY-----\r\n - * ``` - * - */ - function readBase64WithPEM(content) { - var base64 = content - // there are two kinks of line-endings, CRLF(\r\n) and LF(\n) - // we need handle both - .split(/\r?\n/) - .filter(function (x) { return !x.startsWith('---'); }) - .join('') - // remove the line-endings in the end of content - .trim(); - return tweetnacl_util_1.decodeBase64(base64); - } - exports.readBase64WithPEM = readBase64WithPEM; - var AsymmetricKey = /** @class */ (function () { - function AsymmetricKey(publicKey, privateKey, signatureAlgorithm) { - this.publicKey = index_2.PublicKey.from(publicKey, signatureAlgorithm); - this.privateKey = privateKey; - this.signatureAlgorithm = signatureAlgorithm; - } - /** - * Compute a unique hash from the algorithm name(Ed25519 here) and a public key, used for accounts. - */ - AsymmetricKey.prototype.accountHash = function () { - return this.publicKey.toAccountHash(); - }; - /** - * Get the account hex - */ - AsymmetricKey.prototype.accountHex = function () { - return this.publicKey.toAccountHex(); - }; - AsymmetricKey.prototype.toPem = function (tag, content) { - // prettier-ignore - return "-----BEGIN " + tag + "-----\n" + - (content + "\n") + - ("-----END " + tag + "-----\n"); - }; - return AsymmetricKey; - }()); - exports.AsymmetricKey = AsymmetricKey; - // Based on SignatureAlgorithm.scala - var Ed25519 = /** @class */ (function (_super) { - __extends(Ed25519, _super); - function Ed25519(keyPair) { - return _super.call(this, keyPair.publicKey, keyPair.secretKey, SignatureAlgorithm.Ed25519) || this; - } - /** - * Generating a new Ed25519 key pair - */ - Ed25519.new = function () { - return new Ed25519(nacl.sign_keyPair()); - }; - /** - * Generate the accountHex for the Ed25519 public key - * @param publicKey - */ - Ed25519.accountHex = function (publicKey) { - return '01' + index_1.encodeBase16(publicKey); - }; - /** - * Parse the key pair from publicKey file and privateKey file - * @param publicKeyPath path of public key file - * @param privateKeyPath path of private key file - */ - Ed25519.parseKeyFiles = function (publicKeyPath, privateKeyPath) { - var publicKey = Ed25519.parsePublicKeyFile(publicKeyPath); - var privateKey = Ed25519.parsePrivateKeyFile(privateKeyPath); - // nacl expects that the private key will contain both. - return new Ed25519({ - publicKey: publicKey, - secretKey: Buffer.concat([privateKey, publicKey]) - }); - }; - /** - * Generate the accountHash for the Ed25519 public key - * @param publicKey - */ - Ed25519.accountHash = function (publicKey) { - return accountHashHelper(SignatureAlgorithm.Ed25519, publicKey); - }; - /** - * Construct keyPair from a public key and private key - * @param publicKey - * @param privateKey - */ - Ed25519.parseKeyPair = function (publicKey, privateKey) { - var publ = Ed25519.parsePublicKey(publicKey); - var priv = Ed25519.parsePrivateKey(privateKey); - // nacl expects that the private key will contain both. - var secr = new Uint8Array(publ.length + priv.length); - secr.set(priv); - secr.set(publ, priv.length); - return new Ed25519({ - publicKey: publ, - secretKey: secr - }); - }; - Ed25519.parsePrivateKeyFile = function (path) { - return Ed25519.parsePrivateKey(Ed25519.readBase64File(path)); - }; - Ed25519.parsePublicKeyFile = function (path) { - return Ed25519.parsePublicKey(Ed25519.readBase64File(path)); - }; - Ed25519.parsePrivateKey = function (bytes) { - return Ed25519.parseKey(bytes, 0, 32); - }; - Ed25519.parsePublicKey = function (bytes) { - return Ed25519.parseKey(bytes, 32, 64); - }; - Ed25519.readBase64WithPEM = function (content) { - return readBase64WithPEM(content); - }; - /** - * Read the Base64 content of a file, get rid of PEM frames. - * - * @param path the path of file to read from - */ - Ed25519.readBase64File = function (path) { - var content = fs.readFileSync(path).toString(); - return Ed25519.readBase64WithPEM(content); - }; - Ed25519.parseKey = function (bytes, from, to) { - var len = bytes.length; - // prettier-ignore - var key = (len === 32) ? bytes : - (len === 64) ? Buffer.from(bytes).slice(from, to) : - (len > 32 && len < 64) ? Buffer.from(bytes).slice(len % 32) : - null; - if (key == null || key.length !== 32) { - throw Error("Unexpected key length: " + len); - } - return key; - }; - /** - * Export the private key encoded in pem - */ - Ed25519.prototype.exportPrivateKeyInPem = function () { - // prettier-ignore - var derPrefix = Buffer.from([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]); - var encoded = index_1.encodeBase64(Buffer.concat([ - derPrefix, - Buffer.from(Ed25519.parsePrivateKey(this.privateKey)) - ])); - return this.toPem(ED25519_PEM_SECRET_KEY_TAG, encoded); - }; - /** - * Expect the public key encoded in pem - */ - Ed25519.prototype.exportPublicKeyInPem = function () { - // prettier-ignore - var derPrefix = Buffer.from([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]); - var encoded = index_1.encodeBase64(Buffer.concat([derPrefix, Buffer.from(this.publicKey.rawPublicKey)])); - return this.toPem(ED25519_PEM_PUBLIC_KEY_TAG, encoded); - }; - /** - * Sign the message by using the keyPair - * @param msg - */ - Ed25519.prototype.sign = function (msg) { - return nacl.sign_detached(msg, this.privateKey); - }; - /** - * Verify the signature along with the raw message - * @param signature - * @param msg - */ - Ed25519.prototype.verify = function (signature, msg) { - return nacl.sign_detached_verify(msg, signature, this.publicKey.rawPublicKey); - }; - /** - * Derive public key from private key - * @param privateKey - */ - Ed25519.privateToPublicKey = function (privateKey) { - if (privateKey.length === 64 /* SecretKey */) { - return nacl.sign_keyPair_fromSecretKey(privateKey).publicKey; - } - else { - return nacl.sign_keyPair_fromSeed(privateKey).publicKey; - } - }; - /** - * Restore Ed25519 keyPair from private key file - * @param privateKeyPath - */ - Ed25519.loadKeyPairFromPrivateFile = function (privateKeyPath) { - var privateKey = Ed25519.parsePrivateKeyFile(privateKeyPath); - var publicKey = Ed25519.privateToPublicKey(privateKey); - return Ed25519.parseKeyPair(publicKey, privateKey); - }; - return Ed25519; - }(AsymmetricKey)); - exports.Ed25519 = Ed25519; - var Secp256K1 = /** @class */ (function (_super) { - __extends(Secp256K1, _super); - function Secp256K1(publicKey, privateKey) { - return _super.call(this, publicKey, privateKey, SignatureAlgorithm.Secp256K1) || this; - } - /** - * Generating a new Secp256K1 key pair - */ - Secp256K1.new = function () { - var privateKey = eccrypto_1.default.generatePrivate(); - var publicKey = Uint8Array.from(eccrypto_1.default.getPublicCompressed(privateKey)); - return new Secp256K1(publicKey, privateKey); - }; - /** - * Parse the key pair from publicKey file and privateKey file - * @param publicKeyPath path of public key file - * @param privateKeyPath path of private key file - */ - Secp256K1.parseKeyFiles = function (publicKeyPath, privateKeyPath) { - var publicKey = Secp256K1.parsePublicKeyFile(publicKeyPath); - var privateKey = Secp256K1.parsePrivateKeyFile(privateKeyPath); - return new Secp256K1(publicKey, privateKey); - }; - /** - * Generate the accountHash for the Secp256K1 public key - * @param publicKey - */ - Secp256K1.accountHash = function (publicKey) { - return accountHashHelper(SignatureAlgorithm.Secp256K1, publicKey); - }; - /** - * Generate the accountHex for the Secp256K1 public key - * @param publicKey - */ - Secp256K1.accountHex = function (publicKey) { - return '02' + index_1.encodeBase16(publicKey); - }; - /** - * Construct keyPair from public key and private key - * @param publicKey - * @param privateKey - * @param originalFormat the format of the public/private key - */ - Secp256K1.parseKeyPair = function (publicKey, privateKey, originalFormat) { - var publ = Secp256K1.parsePublicKey(publicKey, originalFormat); - var priv = Secp256K1.parsePrivateKey(privateKey, originalFormat); - // nacl expects that the private key will contain both. - return new Secp256K1(publ, priv); - }; - Secp256K1.parsePrivateKeyFile = function (path) { - return Secp256K1.parsePrivateKey(Secp256K1.readBase64File(path)); - }; - Secp256K1.parsePublicKeyFile = function (path) { - return Secp256K1.parsePublicKey(Secp256K1.readBase64File(path)); - }; - Secp256K1.parsePrivateKey = function (bytes, originalFormat) { - if (originalFormat === void 0) { originalFormat = 'der'; } - var rawKeyHex; - if (originalFormat === 'der') { - rawKeyHex = keyEncoder.encodePrivate(Buffer.from(bytes), 'der', 'raw'); - } - else { - rawKeyHex = index_1.encodeBase16(bytes); - } - var privateKey = Buffer.from(rawKeyHex, 'hex'); - return privateKey; - }; - Secp256K1.parsePublicKey = function (bytes, originalFormat) { - if (originalFormat === void 0) { originalFormat = 'der'; } - var rawKeyHex; - if (originalFormat === 'der') { - rawKeyHex = keyEncoder.encodePublic(Buffer.from(bytes), 'der', 'raw'); - } - else { - rawKeyHex = index_1.encodeBase16(bytes); - } - var publicKey = Uint8Array.from(Buffer.from(rawKeyHex, 'hex')); - return publicKey; - }; - Secp256K1.readBase64WithPEM = function (content) { - return readBase64WithPEM(content); - }; - /** - * Read the Base64 content of a file, get rid of PEM frames. - * - * @param path the path of file to read from - */ - Secp256K1.readBase64File = function (path) { - var content = fs.readFileSync(path).toString(); - return Secp256K1.readBase64WithPEM(content); - }; - /** - * Export the private key encoded in pem - */ - Secp256K1.prototype.exportPrivateKeyInPem = function () { - return keyEncoder.encodePrivate(index_1.encodeBase16(this.privateKey), 'raw', 'pem'); - }; - /** - * Expect the public key encoded in pem - */ - Secp256K1.prototype.exportPublicKeyInPem = function () { - return keyEncoder.encodePublic(index_1.encodeBase16(this.publicKey.rawPublicKey), 'raw', 'pem'); - }; - /** - * Sign the message by using the keyPair - * @param msg - */ - Secp256K1.prototype.sign = function (msg) { - var res = secp256k1.ecdsaSign(sha256_1.sha256(Buffer.from(msg)), this.privateKey); - return res.signature; - }; - /** - * Verify the signature along with the raw message - * @param signature - * @param msg - */ - Secp256K1.prototype.verify = function (signature, msg) { - return secp256k1.ecdsaVerify(signature, sha256_1.sha256(Buffer.from(msg)), this.publicKey.rawPublicKey); - }; - /** - * Derive public key from private key - * @param privateKey - */ - Secp256K1.privateToPublicKey = function (privateKey) { - return secp256k1.publicKeyCreate(privateKey, true); - }; - /** - * Restore Secp256K1 keyPair from private key file - * @param privateKeyPath a path to file of the private key - */ - Secp256K1.loadKeyPairFromPrivateFile = function (privateKeyPath) { - var privateKey = Secp256K1.parsePrivateKeyFile(privateKeyPath); - var publicKey = Secp256K1.privateToPublicKey(privateKey); - return Secp256K1.parseKeyPair(publicKey, privateKey, 'raw'); - }; - /** - * From hdKey derive a child Secp256K1 key - * @param hdKey - * @param index - */ - Secp256K1.deriveIndex = function (hdKey, index) { - return hdKey.deriveIndex(index); - }; - return Secp256K1; - }(AsymmetricKey)); - exports.Secp256K1 = Secp256K1; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"../index":181,"../lib/index":194,"./Contracts":185,"buffer":266,"eccrypto":55,"ethereum-cryptography/secp256k1":80,"ethereum-cryptography/sha256":75,"fs":199,"key-encoder":100,"tweetnacl-ts":153,"tweetnacl-util":163}],189:[function(require,module,exports){ - "use strict"; - var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.RuntimeArgs = exports.NamedArg = void 0; - /** - * Implements a collection of runtime arguments. - */ - var byterepr_1 = require("./byterepr"); - var CLValue_1 = require("./CLValue"); - var bytes_1 = require("@ethersproject/bytes"); - var typedjson_1 = require("typedjson"); - var NamedArg = /** @class */ (function () { - function NamedArg(name, value) { - this.name = name; - this.value = value; - } - NamedArg.prototype.toBytes = function () { - var name = byterepr_1.toBytesString(this.name); - var value = this.value.toBytes(); - return bytes_1.concat([name, value]); - }; - NamedArg.fromBytes = function (bytes) { - var nameRes = CLValue_1.StringValue.fromBytes(bytes); - if (nameRes.hasError()) { - return CLValue_1.Result.Err(nameRes.error); - } - var clValueRes = CLValue_1.CLValue.fromBytes(nameRes.remainder()); - if (clValueRes.hasError()) { - return CLValue_1.Result.Err(clValueRes.error); - } - return CLValue_1.Result.Ok(new NamedArg(nameRes.value().val, clValueRes.value()), clValueRes.remainder()); - }; - return NamedArg; - }()); - exports.NamedArg = NamedArg; - var desRA = function (_arr) { - var clValueSerializer = new typedjson_1.TypedJSON(CLValue_1.CLValue); - return new Map(Array.from(_arr, function (_a) { - var key = _a[0], value = _a[1]; - return [key, clValueSerializer.parse(value)]; - })); - }; - var serRA = function (map) { - var clValueSerializer = new typedjson_1.TypedJSON(CLValue_1.CLValue); - return Array.from(map, function (_a) { - var key = _a[0], value = _a[1]; - return [ - key, - clValueSerializer.toPlainJson(value) - ]; - }); - }; - var RuntimeArgs = /** @class */ (function () { - function RuntimeArgs(args) { - this.args = args; - } - RuntimeArgs_1 = RuntimeArgs; - RuntimeArgs.fromMap = function (args) { - var map = new Map(Object.keys(args).map(function (k) { return [k, args[k]]; })); - return new RuntimeArgs_1(map); - }; - RuntimeArgs.fromNamedArgs = function (namedArgs) { - var args = namedArgs.reduce(function (pre, cur) { - pre[cur.name] = cur.value; - return pre; - }, {}); - return RuntimeArgs_1.fromMap(args); - }; - RuntimeArgs.prototype.insert = function (key, value) { - this.args.set(key, value); - }; - RuntimeArgs.prototype.toBytes = function () { - var vec = Array.from(this.args.entries()).map(function (a) { - return new NamedArg(a[0], a[1]); - }); - return byterepr_1.toBytesVecT(vec); - }; - RuntimeArgs.fromBytes = function (bytes) { - var sizeRes = CLValue_1.U32.fromBytes(bytes); - if (sizeRes.hasError()) { - return CLValue_1.Result.Err(sizeRes.error); - } - var size = sizeRes.value().val.toNumber(); - var remainBytes = sizeRes.remainder(); - var res = []; - for (var i = 0; i < size; i++) { - var namedArgRes = NamedArg.fromBytes(remainBytes); - if (namedArgRes.hasError()) { - return CLValue_1.Result.Err(namedArgRes.error); - } - res.push(namedArgRes.value()); - remainBytes = namedArgRes.remainder(); - } - return CLValue_1.Result.Ok(RuntimeArgs_1.fromNamedArgs(res), remainBytes); - }; - var RuntimeArgs_1; - __decorate([ - typedjson_1.jsonMember({ - serializer: serRA, - deserializer: desRA - }), - __metadata("design:type", Map) - ], RuntimeArgs.prototype, "args", void 0); - RuntimeArgs = RuntimeArgs_1 = __decorate([ - typedjson_1.jsonObject(), - __metadata("design:paramtypes", [Map]) - ], RuntimeArgs); - return RuntimeArgs; - }()); - exports.RuntimeArgs = RuntimeArgs; - - },{"./CLValue":182,"./byterepr":193,"@ethersproject/bytes":6,"typedjson":166}],190:[function(require,module,exports){ - (function (Buffer){(function (){ - "use strict"; - /** - * Functions to convert data to the FFI - * @packageDocumentation - */ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Args = exports.UInt64Arg = exports.PublicKeyArg = exports.ByteSequenceArg = exports.ByteArrayArg = void 0; - /** - * Help function to serialize size - * - * @param size - * @constructor - */ - var Size = function (size) { - var buffer = Buffer.alloc(4); - buffer.writeInt32LE(size, 0); - return buffer; - }; - /** - * `Array[Byte]` serializes as follows: - * 1) your array of bytes - * - * So for `[1,2,3,4,5,6]` it serializes to`[1, 2, 3, 4, 5, 6]` - * - * @param bytes - */ - exports.ByteArrayArg = function (bytes) { - return Buffer.from(bytes); - }; - /** - * Serialize ByteArray - * - * `Seq[Byte]` serializes as follows: - * 1) length of the array as 4 bytes - * 2) your array of bytes - * - * So for `[1,2,3,4,5,6]` it serializes to`[6, 0, 0, 0, 1, 2, 3, 4, 5, 6]` - */ - exports.ByteSequenceArg = function (bytes) { - return Buffer.concat([Size(bytes.length), bytes].map(Buffer.from)); - }; - /** - * Serialize public key - * - * A public key is the same as array but it's expected to be 32 bytes long exactly. - * It's `[u8; 32]` (32 element byte array) but serializes to `(32.toBytes() ++ array.toBytes())` - * We serialize 32(literally, number 32) to 4 bytes instead of 1 byte, little endianness. - * This is how`111..11` public key looks like when serialized: - * [32, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - */ - exports.PublicKeyArg = exports.ByteArrayArg; - /** - * Serialize UINT64 - * - * @param value - */ - exports.UInt64Arg = function (value) { - var u64Buffer = Buffer.alloc(8); - u64Buffer.writeBigUInt64LE(value, 0); - return u64Buffer; - }; - /** - * Combine multiple arguments. - * - * so, what you want to send is`Vec(PublicKey, u64)`: - * • `PublicKey` serializes to`byte array of the key`, - * • `u64` serializes to`8 byte array`, - * - * so, what we have is(for example): - * `Vec([32, 0, 0, 0, {public key bytes}], [1, 2, 3, 4, 0, 0, 0, 0])` - * - * Which gives us: - * `[2, 0, 0, 0` - for the number of elements in the external vector - * `32, 0, 0, 0, 1, 1, …` - public key - * `8, 0, 0, 0, ` - for the number of bytes in the second element of the vector. - * That was serialized `u64` (`[1, 2, 3, 4, 0, 0, 0, 0]`) - * `1, 2, 3, 4, 0, 0, 0, 0]` - */ - function Args() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var arrays = [Size(args.length)].concat(args.map(exports.ByteSequenceArg)); - return Buffer.concat(arrays.map(Buffer.from)); - } - exports.Args = Args; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266}],191:[function(require,module,exports){ - "use strict"; - /** - * Provide methods to communicate with [CasperLabs Signer Extension](https://github.com/CasperLabs/signer). - * Works only on browser. - * - * @packageDocumentation - */ - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.signTestDeploy = exports.getToSignMessageID = exports.createTestAccount = exports.createNewVault = exports.resetExistingVault = exports.hasCreatedVault = exports.forceDisconnect = exports.forceConnection = exports.disconnectFromSite = exports.sign = exports.getActivePublicKey = exports.getSelectedPublicKeyBase64 = exports.sendConnectionRequest = exports.isConnected = exports.getVersion = void 0; - /** - * Returns Signer version - */ - exports.getVersion = function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, window.casperlabsHelper.getVersion()]; - case 1: return [2 /*return*/, _b.sent()]; - case 2: - _a = _b.sent(); - return [2 /*return*/, "<1.0.0"]; - case 3: return [2 /*return*/]; - } - }); - }); }; - /** - * Check whether CasperLabs Signer extension is connected - */ - exports.isConnected = function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, window.casperlabsHelper.isConnected()]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); }; - /** - * Attempt connection to Signer - */ - exports.sendConnectionRequest = function () { - return window.casperlabsHelper.requestConnection(); - }; - /** - * Return base64 encoded public key of user current selected account. - * - * @throws Error if haven't connected to CasperLabs Signer browser extension. - */ - exports.getSelectedPublicKeyBase64 = function () { - return window.casperlabsHelper.getSelectedPublicKeyBase64(); - }; - /** - * Retrieve the active public key. - * - * @returns {string} Hex-encoded public key with algorithm prefix. - */ - exports.getActivePublicKey = function () { - return window.casperlabsHelper.getActivePublicKey(); - }; - /** - * Send Deploy in JSON format message to Signer plugin to sign. - * - * @param deploy deploy in JSON format - * @param sourcePublicKeyHex public key in hex format with algorithm prefix. Used to sign the deploy - * @param targetPublicKeyHex public key in hex format with algorithm prefix. Used to display hex-formatted address on the UI - * - * @throws Error if haven't connected to CasperLabs Signer browser extension. - * @throws Error if sourcePublicKeyHex is not the same as the key that Signer used to sign the message - * @throws Error if targetPublicKeyHex is not the same as the key that is used as target in deploy. - */ - exports.sign = function (deploy, sourcePublicKey, targetPublicKey) { - return window.casperlabsHelper.sign(deploy, sourcePublicKey, targetPublicKey); - }; - /* - * Forces Signer to disconnect from the currently open site. - */ - exports.disconnectFromSite = function () { - return window.casperlabsHelper.disconnectFromSite(); - }; - exports.forceConnection = function () { - return window.signerTestingHelper.forceConnection(); - }; - exports.forceDisconnect = function () { - return window.signerTestingHelper.forceDisconnect(); - }; - exports.hasCreatedVault = function () { - return window.signerTestingHelper.hasCreatedVault(); - }; - exports.resetExistingVault = function () { - return window.signerTestingHelper.resetExistingVault(); - }; - exports.createNewVault = function (password) { - return window.signerTestingHelper.createNewVault(password); - }; - exports.createTestAccount = function (name, privateKey) { - return window.signerTestingHelper.createTestAccount(name, privateKey); - }; - exports.getToSignMessageID = function () { - return window.signerTestingHelper.getToSignMessageID(); - }; - exports.signTestDeploy = function (msgId) { - return window.signerTestingHelper.signTestDeploy(msgId); - }; - - },{}],192:[function(require,module,exports){ - "use strict"; - var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.StoredValue = exports.ContractMetadataJson = exports.EraInfoJson = exports.SeigniorageAllocation = exports.DeployInfoJson = exports.TransferJson = void 0; - var typedjson_1 = require("typedjson"); - var CLValue_1 = require("./CLValue"); - var NamedKey = /** @class */ (function () { - function NamedKey() { - } - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], NamedKey.prototype, "name", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], NamedKey.prototype, "key", void 0); - NamedKey = __decorate([ - typedjson_1.jsonObject - ], NamedKey); - return NamedKey; - }()); - var AssociatedKey = /** @class */ (function () { - function AssociatedKey() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'account_hash', constructor: String }), - __metadata("design:type", String) - ], AssociatedKey.prototype, "accountHash", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: Number }), - __metadata("design:type", Number) - ], AssociatedKey.prototype, "weight", void 0); - AssociatedKey = __decorate([ - typedjson_1.jsonObject - ], AssociatedKey); - return AssociatedKey; - }()); - var ActionThresholds = /** @class */ (function () { - function ActionThresholds() { - } - __decorate([ - typedjson_1.jsonMember({ constructor: Number }), - __metadata("design:type", Number) - ], ActionThresholds.prototype, "deployment", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'key_management', constructor: Number }), - __metadata("design:type", Number) - ], ActionThresholds.prototype, "keyManagement", void 0); - ActionThresholds = __decorate([ - typedjson_1.jsonObject - ], ActionThresholds); - return ActionThresholds; - }()); - /** - * Structure representing a user's account, stored in global state. - */ - var AccountJson = /** @class */ (function () { - function AccountJson() { - } - AccountJson.prototype.accountHash = function () { - return this._accountHash; - }; - __decorate([ - typedjson_1.jsonMember({ name: 'account_hash', constructor: String }), - __metadata("design:type", String) - ], AccountJson.prototype, "_accountHash", void 0); - __decorate([ - typedjson_1.jsonArrayMember(NamedKey, { name: 'named_keys' }), - __metadata("design:type", Array) - ], AccountJson.prototype, "namedKeys", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'main_purse', constructor: String }), - __metadata("design:type", String) - ], AccountJson.prototype, "mainPurse", void 0); - __decorate([ - typedjson_1.jsonArrayMember(AssociatedKey, { name: 'associated_keys' }), - __metadata("design:type", Array) - ], AccountJson.prototype, "associatedKeys", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'action_thresholds', constructor: ActionThresholds }), - __metadata("design:type", ActionThresholds) - ], AccountJson.prototype, "actionThresholds", void 0); - AccountJson = __decorate([ - typedjson_1.jsonObject - ], AccountJson); - return AccountJson; - }()); - var TransferJson = /** @class */ (function () { - function TransferJson() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'deploy_hash', constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "deployHash", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "from", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "source", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "target", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "amount", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], TransferJson.prototype, "gas", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String, preserveNull: true }), - __metadata("design:type", Object) - ], TransferJson.prototype, "id", void 0); - TransferJson = __decorate([ - typedjson_1.jsonObject - ], TransferJson); - return TransferJson; - }()); - exports.TransferJson = TransferJson; - var DeployInfoJson = /** @class */ (function () { - function DeployInfoJson() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'deploy_hash', constructor: String }), - __metadata("design:type", String) - ], DeployInfoJson.prototype, "deployHash", void 0); - __decorate([ - typedjson_1.jsonArrayMember(String), - __metadata("design:type", Array) - ], DeployInfoJson.prototype, "transfers", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], DeployInfoJson.prototype, "from", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], DeployInfoJson.prototype, "source", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], DeployInfoJson.prototype, "gas", void 0); - DeployInfoJson = __decorate([ - typedjson_1.jsonObject - ], DeployInfoJson); - return DeployInfoJson; - }()); - exports.DeployInfoJson = DeployInfoJson; - /** - * Info about a seigniorage allocation for a validator - */ - var Validator = /** @class */ (function () { - function Validator() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'validator_public_key', constructor: String }), - __metadata("design:type", String) - ], Validator.prototype, "validatorPublicKey", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], Validator.prototype, "amount", void 0); - Validator = __decorate([ - typedjson_1.jsonObject - ], Validator); - return Validator; - }()); - /** - * Info about a seigniorage allocation for a delegator - */ - var Delegator = /** @class */ (function () { - function Delegator() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'delegator_public_key', constructor: String }), - __metadata("design:type", String) - ], Delegator.prototype, "delegatorPublicKey", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'validator_public_key', constructor: String }), - __metadata("design:type", String) - ], Delegator.prototype, "validatorPublicKey", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], Delegator.prototype, "amount", void 0); - Delegator = __decorate([ - typedjson_1.jsonObject - ], Delegator); - return Delegator; - }()); - /** - * Information about a seigniorage allocation - */ - var SeigniorageAllocation = /** @class */ (function () { - function SeigniorageAllocation() { - } - __decorate([ - typedjson_1.jsonMember({ constructor: Validator }), - __metadata("design:type", Validator) - ], SeigniorageAllocation.prototype, "Validator", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: Delegator }), - __metadata("design:type", Delegator) - ], SeigniorageAllocation.prototype, "Delegator", void 0); - SeigniorageAllocation = __decorate([ - typedjson_1.jsonObject - ], SeigniorageAllocation); - return SeigniorageAllocation; - }()); - exports.SeigniorageAllocation = SeigniorageAllocation; - /** - * Auction metadata. Intended to be recorded at each era. - */ - var EraInfoJson = /** @class */ (function () { - function EraInfoJson() { - } - __decorate([ - typedjson_1.jsonArrayMember(SeigniorageAllocation, { name: 'seigniorage_allocations' }), - __metadata("design:type", Array) - ], EraInfoJson.prototype, "seigniorageAllocations", void 0); - EraInfoJson = __decorate([ - typedjson_1.jsonObject - ], EraInfoJson); - return EraInfoJson; - }()); - exports.EraInfoJson = EraInfoJson; - /** - * Contract metadata. - */ - var ContractMetadataJson = /** @class */ (function () { - function ContractMetadataJson() { - } - __decorate([ - typedjson_1.jsonMember({ name: 'contract_package_hash', constructor: String }), - __metadata("design:type", String) - ], ContractMetadataJson.prototype, "contractPackageHash", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'contract_wasm_hash', constructor: String }), - __metadata("design:type", String) - ], ContractMetadataJson.prototype, "contractWasmHash", void 0); - __decorate([ - typedjson_1.jsonMember({ name: 'protocol_version', constructor: String }), - __metadata("design:type", String) - ], ContractMetadataJson.prototype, "protocolVersion", void 0); - ContractMetadataJson = __decorate([ - typedjson_1.jsonObject - ], ContractMetadataJson); - return ContractMetadataJson; - }()); - exports.ContractMetadataJson = ContractMetadataJson; - var StoredValue = /** @class */ (function () { - function StoredValue() { - } - __decorate([ - typedjson_1.jsonMember({ constructor: CLValue_1.CLValue }), - __metadata("design:type", CLValue_1.CLValue) - ], StoredValue.prototype, "CLValue", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: AccountJson }), - __metadata("design:type", AccountJson) - ], StoredValue.prototype, "Account", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], StoredValue.prototype, "ContractWASM", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: ContractMetadataJson }), - __metadata("design:type", ContractMetadataJson) - ], StoredValue.prototype, "Contract", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: String }), - __metadata("design:type", String) - ], StoredValue.prototype, "ContractPackage", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: TransferJson }), - __metadata("design:type", TransferJson) - ], StoredValue.prototype, "Transfer", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: DeployInfoJson }), - __metadata("design:type", DeployInfoJson) - ], StoredValue.prototype, "DeployInfo", void 0); - __decorate([ - typedjson_1.jsonMember({ constructor: EraInfoJson }), - __metadata("design:type", EraInfoJson) - ], StoredValue.prototype, "EraInfo", void 0); - StoredValue = __decorate([ - typedjson_1.jsonObject - ], StoredValue); - return StoredValue; - }()); - exports.StoredValue = StoredValue; - - },{"./CLValue":182,"typedjson":166}],193:[function(require,module,exports){ - (function (Buffer){(function (){ - // migrate from casper-types/bytesrepr.rs - // https://github.com/CasperLabs/casper-node/blob/4b9f01463845120f6c428a08e108da67b448abb1/types/src/bytesrepr.rs - 'use strict'; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.toBytesStringList = exports.toBytesVecT = exports.toBytesBytesArray = exports.toBytesArrayU8 = exports.toBytesString = exports.toBytesU512 = exports.toBytesDeployHash = exports.toBytesU256 = exports.toBytesU128 = exports.toBytesI64 = exports.toBytesU64 = exports.toBytesU32 = exports.toBytesI32 = exports.toBytesU8 = exports.toBytesNumber = void 0; - var bignumber_1 = require("@ethersproject/bignumber"); - var constants_1 = require("@ethersproject/constants"); - var bytes_1 = require("@ethersproject/bytes"); - var CLValue_1 = require("./CLValue"); - /** - * Convert number to bytes - */ - exports.toBytesNumber = function (bitSize, signed, value) { - var v = bignumber_1.BigNumber.from(value); - // Check bounds are safe for encoding - var maxUintValue = constants_1.MaxUint256.mask(bitSize); - if (signed) { - var bounds = maxUintValue.mask(bitSize - 1); // 1 bit for signed - if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { - throw new Error('value out-of-bounds, value: ' + value); - } - } - else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(bitSize))) { - throw new Error('value out-of-bounds, value: ' + value); - } - v = v.toTwos(bitSize).mask(bitSize); - var bytes = bytes_1.arrayify(v); - if (v.gte(0)) { - // for positive number, we had to deal with paddings - if (bitSize > 64) { - // for u128, u256, u512, we have to and append extra byte for length - return bytes_1.concat([bytes, Uint8Array.from([bytes.length])]).reverse(); - } - else { - // for other types, we have to add padding 0s - var byteLength = bitSize / 8; - return bytes_1.concat([ - bytes.reverse(), - new Uint8Array(byteLength - bytes.length) - ]); - } - } - else { - return bytes.reverse(); - } - }; - /** - * Converts `u8` to little endian. - */ - function toBytesU8(u8) { - return exports.toBytesNumber(8, false, u8); - } - exports.toBytesU8 = toBytesU8; - /** - * Converts `i32` to little endian. - */ - function toBytesI32(i32) { - return exports.toBytesNumber(32, true, i32); - } - exports.toBytesI32 = toBytesI32; - /** - * Converts `u32` to little endian. - */ - function toBytesU32(u32) { - return exports.toBytesNumber(32, false, u32); - } - exports.toBytesU32 = toBytesU32; - /** - * Converts `u64` to little endian. - */ - function toBytesU64(u64) { - return exports.toBytesNumber(64, false, u64); - } - exports.toBytesU64 = toBytesU64; - /** - * Converts `i64` to little endian. - */ - function toBytesI64(i64) { - return exports.toBytesNumber(64, true, i64); - } - exports.toBytesI64 = toBytesI64; - /** - * Converts `u128` to little endian. - */ - function toBytesU128(u128) { - return exports.toBytesNumber(128, false, u128); - } - exports.toBytesU128 = toBytesU128; - /** - * Converts `u256` to little endian. - */ - function toBytesU256(u256) { - return exports.toBytesNumber(256, false, u256); - } - exports.toBytesU256 = toBytesU256; - function toBytesDeployHash(deployHash) { - return toBytesBytesArray(deployHash); - } - exports.toBytesDeployHash = toBytesDeployHash; - /** - * Converts `u512` to little endian. - */ - function toBytesU512(u512) { - return exports.toBytesNumber(512, false, u512); - } - exports.toBytesU512 = toBytesU512; - /** - * Serializes a string into an array of bytes. - */ - function toBytesString(str) { - var arr = Uint8Array.from(Buffer.from(str)); - return bytes_1.concat([toBytesU32(arr.byteLength), arr]); - } - exports.toBytesString = toBytesString; - /** - * Serializes an array of u8, equal to Vec in rust. - */ - function toBytesArrayU8(arr) { - return bytes_1.concat([toBytesU32(arr.length), arr]); - } - exports.toBytesArrayU8 = toBytesArrayU8; - /** - * Serializes an byteArray, equal to [u8;n] in rust. - */ - function toBytesBytesArray(arr) { - return arr; - } - exports.toBytesBytesArray = toBytesBytesArray; - /** - * Serializes a vector of values of type `T` into an array of bytes. - */ - function toBytesVecT(vec) { - var valueByteList = vec.map(function (e) { return e.toBytes(); }); - valueByteList.splice(0, 0, toBytesU32(vec.length)); - return bytes_1.concat(valueByteList); - } - exports.toBytesVecT = toBytesVecT; - /** - * Serializes a list of strings into an array of bytes. - */ - function toBytesStringList(arr) { - return toBytesVecT(arr.map(function (e) { return CLValue_1.CLValue.string(e); })); - } - exports.toBytesStringList = toBytesStringList; - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./CLValue":182,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"@ethersproject/constants":10,"buffer":266}],194:[function(require,module,exports){ - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }); - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; - }; - var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Signer = exports.DeployUtil = exports.Serialization = exports.Keys = exports.Contracts = void 0; - var Contracts = __importStar(require("./Contracts")); - exports.Contracts = Contracts; - var DeployUtil = __importStar(require("./DeployUtil")); - exports.DeployUtil = DeployUtil; - var Keys = __importStar(require("./Keys")); - exports.Keys = Keys; - var Serialization = __importStar(require("./Serialization")); - exports.Serialization = Serialization; - var Signer = __importStar(require("./Signer")); - exports.Signer = Signer; - __exportStar(require("./CLValue"), exports); - __exportStar(require("./RuntimeArgs"), exports); - __exportStar(require("./CasperClient"), exports); - __exportStar(require("./option"), exports); - - },{"./CLValue":182,"./CasperClient":183,"./Contracts":185,"./DeployUtil":187,"./Keys":188,"./RuntimeArgs":189,"./Serialization":190,"./Signer":191,"./option":195}],195:[function(require,module,exports){ - "use strict"; - var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Option = void 0; - // copy from https://github.com/CasperLabs/casper-node/blob/master/smart_contracts/contract_as/assembly/option.ts - var CLValue_1 = require("./CLValue"); - var bytes_1 = require("@ethersproject/bytes"); - var OPTION_TAG_NONE = 0; - var OPTION_TAG_SOME = 1; - // TODO: explore Option (without interfaces to constrain T with, is it practical?) - /** - * A class representing an optional value, i.e. it might contain either a value of some type or - * no value at all. Similar to Rust's `Option` or Haskell's `Maybe`. - */ - var Option = /** @class */ (function (_super) { - __extends(Option, _super); - /** - * Constructs a new option containing the value of `CLTypedAndToBytes`. `t` can be `null`, which - * indicates no value. - */ - function Option(t, innerType) { - var _this = _super.call(this) || this; - _this.t = t; - if (t === null) { - if (!innerType) { - throw new Error('You had to assign innerType for None'); - } - _this.innerType = innerType; - } - else { - _this.innerType = t.clType(); - } - return _this; - } - /** - * Checks whether the `Option` contains no value. - * - * @returns True if the `Option` has no value. - */ - Option.prototype.isNone = function () { - return this.t === null; - }; - /** - * Checks whether the `Option` contains a value. - * - * @returns True if the `Option` has some value. - */ - Option.prototype.isSome = function () { - return this.t !== null; - }; - /** - * Extract value. - * - * @returns CLValue if the `Option` has some value. - */ - Option.prototype.getSome = function () { - if (!this.isSome()) { - throw new Error('Value is None'); - } - return CLValue_1.CLValue.fromT(this.t); - }; - /** - * Serializes the `Option` into an array of bytes. - */ - Option.prototype.toBytes = function () { - if (this.t === null) { - return Uint8Array.from([OPTION_TAG_NONE]); - } - return bytes_1.concat([Uint8Array.from([OPTION_TAG_SOME]), this.t.toBytes()]); - }; - Option.prototype.clType = function () { - return CLValue_1.CLTypeHelper.option(this.innerType); - }; - Option.fromBytes = function (type, bytes) { - var u8Res = CLValue_1.U8.fromBytes(bytes); - if (u8Res.hasError()) { - return CLValue_1.Result.Err(u8Res.error); - } - var optionTag = u8Res.value().val.toNumber(); - if (optionTag === OPTION_TAG_NONE) { - return CLValue_1.Result.Ok(new Option(null, type.innerType), u8Res.remainder()); - } - else if (optionTag === OPTION_TAG_SOME) { - var innerValueRes = CLValue_1.fromBytesByCLType(type.innerType, u8Res.remainder()); - if (innerValueRes.hasError()) { - return CLValue_1.Result.Err(innerValueRes.error); - } - return CLValue_1.Result.Ok(new Option(innerValueRes.value(), type.innerType), innerValueRes.remainder()); - } - else { - return CLValue_1.Result.Err(CLValue_1.FromBytesError.FormattingError); - } - }; - return Option; - }(CLValue_1.CLTypedAndToBytes)); - exports.Option = Option; - - },{"./CLValue":182,"@ethersproject/bytes":6}],196:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.BalanceServiceByJsonRPC = void 0; - var BalanceServiceByJsonRPC = /** @class */ (function () { - function BalanceServiceByJsonRPC(casperService) { - this.casperService = casperService; - this.balanceUrefs = new Map(); - } - /** - * Query balance for the specified account - * - * It will cache balance URef values for accounts so that on subsequent queries, - * it only takes 1 state query not 4 to get the value. - * @param blockHashBase16 - * @param publicKey - */ - BalanceServiceByJsonRPC.prototype.getAccountBalance = function (blockHashBase16, publicKey) { - return __awaiter(this, void 0, void 0, function () { - var stateRootHash, balanceUref, e_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 5, , 6]); - return [4 /*yield*/, this.casperService.getStateRootHash(blockHashBase16)]; - case 1: - stateRootHash = _a.sent(); - balanceUref = this.balanceUrefs.get(publicKey.toAccountHex()); - if (!!balanceUref) return [3 /*break*/, 3]; - return [4 /*yield*/, this.casperService.getAccountBalanceUrefByPublicKey(stateRootHash, publicKey)]; - case 2: - balanceUref = _a.sent(); - if (balanceUref) { - this.balanceUrefs.set(publicKey.toAccountHex(), balanceUref); - } - _a.label = 3; - case 3: - if (!balanceUref) { - return [2 /*return*/, undefined]; - } - return [4 /*yield*/, this.casperService.getAccountBalance(stateRootHash, balanceUref)]; - case 4: return [2 /*return*/, _a.sent()]; - case 5: - e_1 = _a.sent(); - return [2 /*return*/, undefined]; - case 6: return [2 /*return*/]; - } - }); - }); - }; - return BalanceServiceByJsonRPC; - }()); - exports.BalanceServiceByJsonRPC = BalanceServiceByJsonRPC; - - },{}],197:[function(require,module,exports){ - "use strict"; - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.CasperServiceByJsonRPC = void 0; - var client_js_1 = require("@open-rpc/client-js"); - var __1 = require(".."); - var DeployUtil_1 = require("../lib/DeployUtil"); - var typedjson_1 = require("typedjson"); - var StoredValue_1 = require("../lib/StoredValue"); - var bignumber_1 = require("@ethersproject/bignumber"); - var CasperServiceByJsonRPC = /** @class */ (function () { - function CasperServiceByJsonRPC(url) { - var transport = new client_js_1.HTTPTransport(url); - var requestManager = new client_js_1.RequestManager([transport]); - this.client = new client_js_1.Client(requestManager); - } - /** - * Get information about a single deploy by hash. - * - * @param deployHashBase16 - */ - CasperServiceByJsonRPC.prototype.getDeployInfo = function (deployHashBase16) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'info_get_deploy', - params: { - deploy_hash: deployHashBase16 - } - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getBlockInfo = function (blockHashBase16) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'chain_get_block', - params: { - block_identifier: { - Hash: blockHashBase16 - } - } - }).then(function (res) { - if (res.block !== null && res.block.hash !== blockHashBase16) { - throw new Error("Returned block does not have a matching hash."); - } - return res; - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getBlockInfoByHeight = function (height) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'chain_get_block', - params: { - block_identifier: { - Height: height - } - } - }).then(function (res) { - if (res.block !== null && res.block.header.height !== height) { - throw new Error("Returned block does not have a matching height."); - } - return res; - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getLatestBlockInfo = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'chain_get_block' - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getPeers = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'info_get_peers' - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getStatus = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'info_get_status' - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getValidatorsInfo = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'state_get_auction_info' - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - /** - * Get the reference to the balance so we can cache it. - */ - CasperServiceByJsonRPC.prototype.getAccountBalanceUrefByPublicKeyHash = function (stateRootHash, accountHash) { - return __awaiter(this, void 0, void 0, function () { - var account; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.getBlockState(stateRootHash, 'account-hash-' + accountHash, []).then(function (res) { return res.Account; })]; - case 1: - account = _a.sent(); - return [2 /*return*/, account.mainPurse]; - } - }); - }); - }; - /** - * Get the reference to the balance so we can cache it. - */ - CasperServiceByJsonRPC.prototype.getAccountBalanceUrefByPublicKey = function (stateRootHash, publicKey) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, this.getAccountBalanceUrefByPublicKeyHash(stateRootHash, __1.encodeBase16(publicKey.toAccountHash()))]; - }); - }); - }; - CasperServiceByJsonRPC.prototype.getAccountBalance = function (stateRootHash, balanceUref) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client - .request({ - method: 'state_get_balance', - params: { - state_root_hash: stateRootHash, - purse_uref: balanceUref - } - }) - .then(function (res) { return bignumber_1.BigNumber.from(res.balance_value); })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.getStateRootHash = function (blockHashBase16) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client - .request({ - method: 'chain_get_state_root_hash', - params: { - block_hash: blockHashBase16 - } - }) - .then(function (res) { return res.state_root_hash; })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - /** - * get global state item - * @param stateRootHash - * @param key - * @param path - */ - CasperServiceByJsonRPC.prototype.getBlockState = function (stateRootHash, key, path) { - return __awaiter(this, void 0, void 0, function () { - var res, storedValueJson, serializer, storedValue; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.client.request({ - method: 'state_get_item', - params: { - state_root_hash: stateRootHash, - key: key, - path: path - } - })]; - case 1: - res = _a.sent(); - if (res.error) { - return [2 /*return*/, res]; - } - else { - storedValueJson = res.stored_value; - serializer = new typedjson_1.TypedJSON(StoredValue_1.StoredValue); - storedValue = serializer.parse(storedValueJson); - return [2 /*return*/, storedValue]; - } - return [2 /*return*/]; - } - }); - }); - }; - CasperServiceByJsonRPC.prototype.deploy = function (signedDeploy) { - return __awaiter(this, void 0, void 0, function () { - var oneMegaByte, size; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - oneMegaByte = 1048576; - size = __1.DeployUtil.deploySizeInBytes(signedDeploy); - if (size > oneMegaByte) { - throw Error("Deploy can not be send, because it's too large: " + size + " bytes. " + - "Max size is 1 megabyte."); - } - return [4 /*yield*/, this.client.request({ - method: 'account_put_deploy', - params: DeployUtil_1.deployToJson(signedDeploy) - })]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); - }); - }; - return CasperServiceByJsonRPC; - }()); - exports.CasperServiceByJsonRPC = CasperServiceByJsonRPC; - - },{"..":181,"../lib/DeployUtil":187,"../lib/StoredValue":192,"@ethersproject/bignumber":4,"@open-rpc/client-js":18,"typedjson":166}],198:[function(require,module,exports){ - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); - }) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - })); - var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - __exportStar(require("./CasperServiceByJsonRPC"), exports); - __exportStar(require("./BalanceServiceByJsonRPC"), exports); - - },{"./BalanceServiceByJsonRPC":196,"./CasperServiceByJsonRPC":197}],199:[function(require,module,exports){ - - },{}],200:[function(require,module,exports){ - arguments[4][26][0].apply(exports,arguments) - },{"./asn1/api":201,"./asn1/base":203,"./asn1/constants":207,"./asn1/decoders":209,"./asn1/encoders":212,"bn.js":214,"dup":26}],201:[function(require,module,exports){ - arguments[4][27][0].apply(exports,arguments) - },{"./decoders":209,"./encoders":212,"dup":27,"inherits":335}],202:[function(require,module,exports){ - arguments[4][28][0].apply(exports,arguments) - },{"../base/reporter":205,"dup":28,"inherits":335,"safer-buffer":365}],203:[function(require,module,exports){ - arguments[4][29][0].apply(exports,arguments) - },{"./buffer":202,"./node":204,"./reporter":205,"dup":29}],204:[function(require,module,exports){ - arguments[4][30][0].apply(exports,arguments) - },{"../base/buffer":202,"../base/reporter":205,"dup":30,"minimalistic-assert":339}],205:[function(require,module,exports){ - arguments[4][31][0].apply(exports,arguments) - },{"dup":31,"inherits":335}],206:[function(require,module,exports){ - arguments[4][32][0].apply(exports,arguments) - },{"dup":32}],207:[function(require,module,exports){ - arguments[4][33][0].apply(exports,arguments) - },{"./der":206,"dup":33}],208:[function(require,module,exports){ - arguments[4][34][0].apply(exports,arguments) - },{"../base/buffer":202,"../base/node":204,"../constants/der":206,"bn.js":214,"dup":34,"inherits":335}],209:[function(require,module,exports){ - arguments[4][35][0].apply(exports,arguments) - },{"./der":208,"./pem":210,"dup":35}],210:[function(require,module,exports){ - arguments[4][36][0].apply(exports,arguments) - },{"./der":208,"dup":36,"inherits":335,"safer-buffer":365}],211:[function(require,module,exports){ - arguments[4][37][0].apply(exports,arguments) - },{"../base/node":204,"../constants/der":206,"dup":37,"inherits":335,"safer-buffer":365}],212:[function(require,module,exports){ - arguments[4][38][0].apply(exports,arguments) - },{"./der":211,"./pem":213,"dup":38}],213:[function(require,module,exports){ - arguments[4][39][0].apply(exports,arguments) - },{"./der":211,"dup":39,"inherits":335}],214:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],215:[function(require,module,exports){ - (function (global){(function (){ - 'use strict'; - - var objectAssign = require('object-assign'); - - // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js - // original notice: - - /*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - function compare(a, b) { - if (a === b) { - return 0; - } - - var x = a.length; - var y = b.length; - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i]; - y = b[i]; - break; - } - } - - if (x < y) { - return -1; - } - if (y < x) { - return 1; - } - return 0; - } - function isBuffer(b) { - if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { - return global.Buffer.isBuffer(b); - } - return !!(b != null && b._isBuffer); - } - - // based on node assert, original notice: - // NB: The URL to the CommonJS spec is kept just for tradition. - // node-assert has evolved a lot since then, both in API and behavior. - - // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 - // - // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! - // - // Originally from narwhal.js (http://narwhaljs.org) - // Copyright (c) 2009 Thomas Robinson <280north.com> - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the 'Software'), to - // deal in the Software without restriction, including without limitation the - // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - // sell copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions: - // - // The above copyright notice and this permission notice shall be included in - // all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - var util = require('util/'); - var hasOwn = Object.prototype.hasOwnProperty; - var pSlice = Array.prototype.slice; - var functionsHaveNames = (function () { - return function foo() {}.name === 'foo'; - }()); - function pToString (obj) { - return Object.prototype.toString.call(obj); - } - function isView(arrbuf) { - if (isBuffer(arrbuf)) { - return false; - } - if (typeof global.ArrayBuffer !== 'function') { - return false; - } - if (typeof ArrayBuffer.isView === 'function') { - return ArrayBuffer.isView(arrbuf); - } - if (!arrbuf) { - return false; - } - if (arrbuf instanceof DataView) { - return true; - } - if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { - return true; - } - return false; - } - // 1. The assert module provides functions that throw - // AssertionError's when particular conditions are not met. The - // assert module must conform to the following interface. - - var assert = module.exports = ok; - - // 2. The AssertionError is defined in assert. - // new assert.AssertionError({ message: message, - // actual: actual, - // expected: expected }) - - var regex = /\s*function\s+([^\(\s]*)\s*/; - // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js - function getName(func) { - if (!util.isFunction(func)) { - return; - } - if (functionsHaveNames) { - return func.name; - } - var str = func.toString(); - var match = str.match(regex); - return match && match[1]; - } - assert.AssertionError = function AssertionError(options) { - this.name = 'AssertionError'; - this.actual = options.actual; - this.expected = options.expected; - this.operator = options.operator; - if (options.message) { - this.message = options.message; - this.generatedMessage = false; - } else { - this.message = getMessage(this); - this.generatedMessage = true; - } - var stackStartFunction = options.stackStartFunction || fail; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); - } else { - // non v8 browsers so we can have a stacktrace - var err = new Error(); - if (err.stack) { - var out = err.stack; - - // try to strip useless frames - var fn_name = getName(stackStartFunction); - var idx = out.indexOf('\n' + fn_name); - if (idx >= 0) { - // once we have located the function frame - // we need to strip out everything before it (and its line) - var next_line = out.indexOf('\n', idx + 1); - out = out.substring(next_line + 1); - } - - this.stack = out; - } - } - }; - - // assert.AssertionError instanceof Error - util.inherits(assert.AssertionError, Error); - - function truncate(s, n) { - if (typeof s === 'string') { - return s.length < n ? s : s.slice(0, n); - } else { - return s; - } - } - function inspect(something) { - if (functionsHaveNames || !util.isFunction(something)) { - return util.inspect(something); - } - var rawname = getName(something); - var name = rawname ? ': ' + rawname : ''; - return '[Function' + name + ']'; - } - function getMessage(self) { - return truncate(inspect(self.actual), 128) + ' ' + - self.operator + ' ' + - truncate(inspect(self.expected), 128); - } - - // At present only the three keys mentioned above are used and - // understood by the spec. Implementations or sub modules can pass - // other keys to the AssertionError's constructor - they will be - // ignored. - - // 3. All of the following functions must throw an AssertionError - // when a corresponding condition is not met, with a message that - // may be undefined if not provided. All assertion methods provide - // both the actual and expected values to the assertion error for - // display purposes. - - function fail(actual, expected, message, operator, stackStartFunction) { - throw new assert.AssertionError({ - message: message, - actual: actual, - expected: expected, - operator: operator, - stackStartFunction: stackStartFunction - }); - } - - // EXTENSION! allows for well behaved errors defined elsewhere. - assert.fail = fail; - - // 4. Pure assertion tests whether a value is truthy, as determined - // by !!guard. - // assert.ok(guard, message_opt); - // This statement is equivalent to assert.equal(true, !!guard, - // message_opt);. To test strictly for the value true, use - // assert.strictEqual(true, guard, message_opt);. - - function ok(value, message) { - if (!value) fail(value, true, message, '==', assert.ok); - } - assert.ok = ok; - - // 5. The equality assertion tests shallow, coercive equality with - // ==. - // assert.equal(actual, expected, message_opt); - - assert.equal = function equal(actual, expected, message) { - if (actual != expected) fail(actual, expected, message, '==', assert.equal); - }; - - // 6. The non-equality assertion tests for whether two objects are not equal - // with != assert.notEqual(actual, expected, message_opt); - - assert.notEqual = function notEqual(actual, expected, message) { - if (actual == expected) { - fail(actual, expected, message, '!=', assert.notEqual); - } - }; - - // 7. The equivalence assertion tests a deep equality relation. - // assert.deepEqual(actual, expected, message_opt); - - assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, false)) { - fail(actual, expected, message, 'deepEqual', assert.deepEqual); - } - }; - - assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); - } - }; - - function _deepEqual(actual, expected, strict, memos) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - } else if (isBuffer(actual) && isBuffer(expected)) { - return compare(actual, expected) === 0; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (util.isDate(actual) && util.isDate(expected)) { - return actual.getTime() === expected.getTime(); - - // 7.3 If the expected value is a RegExp object, the actual value is - // equivalent if it is also a RegExp object with the same source and - // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). - } else if (util.isRegExp(actual) && util.isRegExp(expected)) { - return actual.source === expected.source && - actual.global === expected.global && - actual.multiline === expected.multiline && - actual.lastIndex === expected.lastIndex && - actual.ignoreCase === expected.ignoreCase; - - // 7.4. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if ((actual === null || typeof actual !== 'object') && - (expected === null || typeof expected !== 'object')) { - return strict ? actual === expected : actual == expected; - - // If both values are instances of typed arrays, wrap their underlying - // ArrayBuffers in a Buffer each to increase performance - // This optimization requires the arrays to have the same type as checked by - // Object.prototype.toString (aka pToString). Never perform binary - // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their - // bit patterns are not identical. - } else if (isView(actual) && isView(expected) && - pToString(actual) === pToString(expected) && - !(actual instanceof Float32Array || - actual instanceof Float64Array)) { - return compare(new Uint8Array(actual.buffer), - new Uint8Array(expected.buffer)) === 0; - - // 7.5 For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else if (isBuffer(actual) !== isBuffer(expected)) { - return false; - } else { - memos = memos || {actual: [], expected: []}; - - var actualIndex = memos.actual.indexOf(actual); - if (actualIndex !== -1) { - if (actualIndex === memos.expected.indexOf(expected)) { - return true; - } - } - - memos.actual.push(actual); - memos.expected.push(expected); - - return objEquiv(actual, expected, strict, memos); - } - } - - function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; - } - - function objEquiv(a, b, strict, actualVisitedObjects) { - if (a === null || a === undefined || b === null || b === undefined) - return false; - // if one is a primitive, the other must be same - if (util.isPrimitive(a) || util.isPrimitive(b)) - return a === b; - if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) - return false; - var aIsArgs = isArguments(a); - var bIsArgs = isArguments(b); - if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) - return false; - if (aIsArgs) { - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b, strict); - } - var ka = objectKeys(a); - var kb = objectKeys(b); - var key, i; - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length !== kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] !== kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) - return false; - } - return true; - } - - // 8. The non-equivalence assertion tests for any deep inequality. - // assert.notDeepEqual(actual, expected, message_opt); - - assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected, false)) { - fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); - } - }; - - assert.notDeepStrictEqual = notDeepStrictEqual; - function notDeepStrictEqual(actual, expected, message) { - if (_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); - } - } - - - // 9. The strict equality assertion tests strict equality, as determined by ===. - // assert.strictEqual(actual, expected, message_opt); - - assert.strictEqual = function strictEqual(actual, expected, message) { - if (actual !== expected) { - fail(actual, expected, message, '===', assert.strictEqual); - } - }; - - // 10. The strict non-equality assertion tests for strict inequality, as - // determined by !==. assert.notStrictEqual(actual, expected, message_opt); - - assert.notStrictEqual = function notStrictEqual(actual, expected, message) { - if (actual === expected) { - fail(actual, expected, message, '!==', assert.notStrictEqual); - } - }; - - function expectedException(actual, expected) { - if (!actual || !expected) { - return false; - } - - if (Object.prototype.toString.call(expected) == '[object RegExp]') { - return expected.test(actual); - } - - try { - if (actual instanceof expected) { - return true; - } - } catch (e) { - // Ignore. The instanceof check doesn't work for arrow functions. - } - - if (Error.isPrototypeOf(expected)) { - return false; - } - - return expected.call({}, actual) === true; - } - - function _tryBlock(block) { - var error; - try { - block(); - } catch (e) { - error = e; - } - return error; - } - - function _throws(shouldThrow, block, expected, message) { - var actual; - - if (typeof block !== 'function') { - throw new TypeError('"block" argument must be a function'); - } - - if (typeof expected === 'string') { - message = expected; - expected = null; - } - - actual = _tryBlock(block); - - message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + - (message ? ' ' + message : '.'); - - if (shouldThrow && !actual) { - fail(actual, expected, 'Missing expected exception' + message); - } - - var userProvidedMessage = typeof message === 'string'; - var isUnwantedException = !shouldThrow && util.isError(actual); - var isUnexpectedException = !shouldThrow && actual && !expected; - - if ((isUnwantedException && - userProvidedMessage && - expectedException(actual, expected)) || - isUnexpectedException) { - fail(actual, expected, 'Got unwanted exception' + message); - } - - if ((shouldThrow && actual && expected && - !expectedException(actual, expected)) || (!shouldThrow && actual)) { - throw actual; - } - } - - // 11. Expected to throw an error: - // assert.throws(block, Error_opt, message_opt); - - assert.throws = function(block, /*optional*/error, /*optional*/message) { - _throws(true, block, error, message); - }; - - // EXTENSION! This is annoying to write outside this module. - assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { - _throws(false, block, error, message); - }; - - assert.ifError = function(err) { if (err) throw err; }; - - // Expose a strict only variant of assert - function strict(value, message) { - if (!value) fail(value, true, message, '==', strict); - } - assert.strict = objectAssign(strict, assert, { - equal: assert.strictEqual, - deepEqual: assert.deepStrictEqual, - notEqual: assert.notStrictEqual, - notDeepEqual: assert.notDeepStrictEqual - }); - assert.strict.strict = assert.strict; - - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - if (hasOwn.call(obj, key)) keys.push(key); - } - return keys; - }; - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"object-assign":341,"util/":218}],216:[function(require,module,exports){ - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - },{}],217:[function(require,module,exports){ - module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; - } - },{}],218:[function(require,module,exports){ - (function (process,global){(function (){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - var formatRegExp = /%[sdj%]/g; - exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } - - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } - } - return str; - }; - - - // Mark that a method should not be used. - // Returns a modified function which warns once by default. - // If --no-deprecation is set, then it is a no-op. - exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; - }; - - - var debugs = {}; - var debugEnviron; - exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; - }; - - - /** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ - /* legacy: obj, showHidden, depth, colors*/ - function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor - }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); - } - exports.inspect = inspect; - - - // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics - inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] - }; - - // Don't use 'blue' not visible on cmd.exe - inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' - }; - - - function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; - - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; - } else { - return str; - } - } - - - function stylizeNoColor(str, styleType) { - return str; - } - - - function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; - } - - - function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // IE doesn't make error fields non-enumerable - // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } - - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); - } - - - function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); - } - - - function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; - } - - - function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; - } - - - function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; - } - - - function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; - } - - - // NOTE: These type checking functions intentionally don't use `instanceof` - // because it is fragile and can be easily faked with `Object.create()`. - function isArray(ar) { - return Array.isArray(ar); - } - exports.isArray = isArray; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); - } - exports.isError = isError; - - function isFunction(arg) { - return typeof arg === 'function'; - } - exports.isFunction = isFunction; - - function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; - } - exports.isPrimitive = isPrimitive; - - exports.isBuffer = require('./support/isBuffer'); - - function objectToString(o) { - return Object.prototype.toString.call(o); - } - - - function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); - } - - - var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - - // 26 Feb 16:19:34 - function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); - } - - - // log is just a thin wrapper to console.log that prepends a timestamp - exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); - }; - - - /** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ - exports.inherits = require('inherits'); - - exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin; - }; - - function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); - } - - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"./support/isBuffer":217,"_process":353,"inherits":216}],219:[function(require,module,exports){ - 'use strict' - - exports.byteLength = byteLength - exports.toByteArray = toByteArray - exports.fromByteArray = fromByteArray - - var lookup = [] - var revLookup = [] - var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - - var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i - } - - // Support decoding URL-safe base64 strings, as Node.js does. - // See: https://en.wikipedia.org/wiki/Base64#URL_applications - revLookup['-'.charCodeAt(0)] = 62 - revLookup['_'.charCodeAt(0)] = 63 - - function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] - } - - // base64 is 4/3 + up to two characters of the original data - function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen - } - - function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen - } - - function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - var i - for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr - } - - function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] - } - - function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') - } - - function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') - } - - },{}],220:[function(require,module,exports){ - (function (module, exports) { - 'use strict'; - - // Utils - function assert (val, msg) { - if (!val) throw new Error(msg || 'Assertion failed'); - } - - // Could use `inherits` module, but don't want to move from single file - // architecture yet. - function inherits (ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - - // BN - - function BN (number, base, endian) { - if (BN.isBN(number)) { - return number; - } - - this.negative = 0; - this.words = null; - this.length = 0; - - // Reduction context - this.red = null; - - if (number !== null) { - if (base === 'le' || base === 'be') { - endian = base; - base = 10; - } - - this._init(number || 0, base || 10, endian || 'be'); - } - } - if (typeof module === 'object') { - module.exports = BN; - } else { - exports.BN = BN; - } - - BN.BN = BN; - BN.wordSize = 26; - - var Buffer; - try { - if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { - Buffer = window.Buffer; - } else { - Buffer = require('buffer').Buffer; - } - } catch (e) { - } - - BN.isBN = function isBN (num) { - if (num instanceof BN) { - return true; - } - - return num !== null && typeof num === 'object' && - num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); - }; - - BN.max = function max (left, right) { - if (left.cmp(right) > 0) return left; - return right; - }; - - BN.min = function min (left, right) { - if (left.cmp(right) < 0) return left; - return right; - }; - - BN.prototype._init = function init (number, base, endian) { - if (typeof number === 'number') { - return this._initNumber(number, base, endian); - } - - if (typeof number === 'object') { - return this._initArray(number, base, endian); - } - - if (base === 'hex') { - base = 16; - } - assert(base === (base | 0) && base >= 2 && base <= 36); - - number = number.toString().replace(/\s+/g, ''); - var start = 0; - if (number[0] === '-') { - start++; - this.negative = 1; - } - - if (start < number.length) { - if (base === 16) { - this._parseHex(number, start, endian); - } else { - this._parseBase(number, base, start); - if (endian === 'le') { - this._initArray(this.toArray(), base, endian); - } - } - } - }; - - BN.prototype._initNumber = function _initNumber (number, base, endian) { - if (number < 0) { - this.negative = 1; - number = -number; - } - if (number < 0x4000000) { - this.words = [number & 0x3ffffff]; - this.length = 1; - } else if (number < 0x10000000000000) { - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff - ]; - this.length = 2; - } else { - assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff, - 1 - ]; - this.length = 3; - } - - if (endian !== 'le') return; - - // Reverse the bytes - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initArray = function _initArray (number, base, endian) { - // Perhaps a Uint8Array - assert(typeof number.length === 'number'); - if (number.length <= 0) { - this.words = [0]; - this.length = 1; - return this; - } - - this.length = Math.ceil(number.length / 3); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - var off = 0; - if (endian === 'be') { - for (i = number.length - 1, j = 0; i >= 0; i -= 3) { - w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } else if (endian === 'le') { - for (i = 0, j = 0; i < number.length; i += 3) { - w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } - return this._strip(); - }; - - function parseHex4Bits (string, index) { - var c = string.charCodeAt(index); - // '0' - '9' - if (c >= 48 && c <= 57) { - return c - 48; - // 'A' - 'F' - } else if (c >= 65 && c <= 70) { - return c - 55; - // 'a' - 'f' - } else if (c >= 97 && c <= 102) { - return c - 87; - } else { - assert(false, 'Invalid character in ' + string); - } - } - - function parseHexByte (string, lowerBound, index) { - var r = parseHex4Bits(string, index); - if (index - 1 >= lowerBound) { - r |= parseHex4Bits(string, index - 1) << 4; - } - return r; - } - - BN.prototype._parseHex = function _parseHex (number, start, endian) { - // Create possibly bigger array to ensure that it fits the number - this.length = Math.ceil((number.length - start) / 6); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - // 24-bits chunks - var off = 0; - var j = 0; - - var w; - if (endian === 'be') { - for (i = number.length - 1; i >= start; i -= 2) { - w = parseHexByte(number, start, i) << off; - this.words[j] |= w & 0x3ffffff; - if (off >= 18) { - off -= 18; - j += 1; - this.words[j] |= w >>> 26; - } else { - off += 8; - } - } - } else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { - w = parseHexByte(number, start, i) << off; - this.words[j] |= w & 0x3ffffff; - if (off >= 18) { - off -= 18; - j += 1; - this.words[j] |= w >>> 26; - } else { - off += 8; - } - } - } - - this._strip(); - }; - - function parseBase (str, start, end, mul) { - var r = 0; - var b = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r *= mul; - - // 'a' - if (c >= 49) { - b = c - 49 + 0xa; - - // 'A' - } else if (c >= 17) { - b = c - 17 + 0xa; - - // '0' - '9' - } else { - b = c; - } - assert(c >= 0 && b < mul, 'Invalid character'); - r += b; - } - return r; - } - - BN.prototype._parseBase = function _parseBase (number, base, start) { - // Initialize as zero - this.words = [0]; - this.length = 1; - - // Find length of limb in base - for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { - limbLen++; - } - limbLen--; - limbPow = (limbPow / base) | 0; - - var total = number.length - start; - var mod = total % limbLen; - var end = Math.min(total, total - mod) + start; - - var word = 0; - for (var i = start; i < end; i += limbLen) { - word = parseBase(number, i, i + limbLen, base); - - this.imuln(limbPow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - if (mod !== 0) { - var pow = 1; - word = parseBase(number, i, number.length, base); - - for (i = 0; i < mod; i++) { - pow *= base; - } - - this.imuln(pow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - this._strip(); - }; - - BN.prototype.copy = function copy (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - dest.words[i] = this.words[i]; - } - dest.length = this.length; - dest.negative = this.negative; - dest.red = this.red; - }; - - function move (dest, src) { - dest.words = src.words; - dest.length = src.length; - dest.negative = src.negative; - dest.red = src.red; - } - - BN.prototype._move = function _move (dest) { - move(dest, this); - }; - - BN.prototype.clone = function clone () { - var r = new BN(null); - this.copy(r); - return r; - }; - - BN.prototype._expand = function _expand (size) { - while (this.length < size) { - this.words[this.length++] = 0; - } - return this; - }; - - // Remove leading `0` from `this` - BN.prototype._strip = function strip () { - while (this.length > 1 && this.words[this.length - 1] === 0) { - this.length--; - } - return this._normSign(); - }; - - BN.prototype._normSign = function _normSign () { - // -0 = 0 - if (this.length === 1 && this.words[0] === 0) { - this.negative = 0; - } - return this; - }; - - // Check Symbol.for because not everywhere where Symbol defined - // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility - if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { - try { - BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; - } catch (e) { - BN.prototype.inspect = inspect; - } - } else { - BN.prototype.inspect = inspect; - } - - function inspect () { - return (this.red ? ''; - } - - /* - - var zeros = []; - var groupSizes = []; - var groupBases = []; - - var s = ''; - var i = -1; - while (++i < BN.wordSize) { - zeros[i] = s; - s += '0'; - } - groupSizes[0] = 0; - groupSizes[1] = 0; - groupBases[0] = 0; - groupBases[1] = 0; - var base = 2 - 1; - while (++base < 36 + 1) { - var groupSize = 0; - var groupBase = 1; - while (groupBase < (1 << BN.wordSize) / base) { - groupBase *= base; - groupSize += 1; - } - groupSizes[base] = groupSize; - groupBases[base] = groupBase; - } - - */ - - var zeros = [ - '', - '0', - '00', - '000', - '0000', - '00000', - '000000', - '0000000', - '00000000', - '000000000', - '0000000000', - '00000000000', - '000000000000', - '0000000000000', - '00000000000000', - '000000000000000', - '0000000000000000', - '00000000000000000', - '000000000000000000', - '0000000000000000000', - '00000000000000000000', - '000000000000000000000', - '0000000000000000000000', - '00000000000000000000000', - '000000000000000000000000', - '0000000000000000000000000' - ]; - - var groupSizes = [ - 0, 0, - 25, 16, 12, 11, 10, 9, 8, - 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5 - ]; - - var groupBases = [ - 0, 0, - 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, - 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, - 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, - 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, - 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 - ]; - - BN.prototype.toString = function toString (base, padding) { - base = base || 10; - padding = padding | 0 || 1; - - var out; - if (base === 16 || base === 'hex') { - out = ''; - var off = 0; - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = this.words[i]; - var word = (((w << off) | carry) & 0xffffff).toString(16); - carry = (w >>> (24 - off)) & 0xffffff; - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - } - if (carry !== 0) { - out = carry.toString(16) + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - if (base === (base | 0) && base >= 2 && base <= 36) { - // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); - var groupSize = groupSizes[base]; - // var groupBase = Math.pow(base, groupSize); - var groupBase = groupBases[base]; - out = ''; - var c = this.clone(); - c.negative = 0; - while (!c.isZero()) { - var r = c.modrn(groupBase).toString(base); - c = c.idivn(groupBase); - - if (!c.isZero()) { - out = zeros[groupSize - r.length] + r + out; - } else { - out = r + out; - } - } - if (this.isZero()) { - out = '0' + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - assert(false, 'Base should be between 2 and 36'); - }; - - BN.prototype.toNumber = function toNumber () { - var ret = this.words[0]; - if (this.length === 2) { - ret += this.words[1] * 0x4000000; - } else if (this.length === 3 && this.words[2] === 0x01) { - // NOTE: at this stage it is known that the top bit is set - ret += 0x10000000000000 + (this.words[1] * 0x4000000); - } else if (this.length > 2) { - assert(false, 'Number can only safely store up to 53 bits'); - } - return (this.negative !== 0) ? -ret : ret; - }; - - BN.prototype.toJSON = function toJSON () { - return this.toString(16, 2); - }; - - if (Buffer) { - BN.prototype.toBuffer = function toBuffer (endian, length) { - return this.toArrayLike(Buffer, endian, length); - }; - } - - BN.prototype.toArray = function toArray (endian, length) { - return this.toArrayLike(Array, endian, length); - }; - - var allocate = function allocate (ArrayType, size) { - if (ArrayType.allocUnsafe) { - return ArrayType.allocUnsafe(size); - } - return new ArrayType(size); - }; - - BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { - this._strip(); - - var byteLength = this.byteLength(); - var reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, 'byte array longer than desired length'); - assert(reqLength > 0, 'Requested array length <= 0'); - - var res = allocate(ArrayType, reqLength); - var postfix = endian === 'le' ? 'LE' : 'BE'; - this['_toArrayLike' + postfix](res, byteLength); - return res; - }; - - BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { - var position = 0; - var carry = 0; - - for (var i = 0, shift = 0; i < this.length; i++) { - var word = (this.words[i] << shift) | carry; - - res[position++] = word & 0xff; - if (position < res.length) { - res[position++] = (word >> 8) & 0xff; - } - if (position < res.length) { - res[position++] = (word >> 16) & 0xff; - } - - if (shift === 6) { - if (position < res.length) { - res[position++] = (word >> 24) & 0xff; - } - carry = 0; - shift = 0; - } else { - carry = word >>> 24; - shift += 2; - } - } - - if (position < res.length) { - res[position++] = carry; - - while (position < res.length) { - res[position++] = 0; - } - } - }; - - BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { - var position = res.length - 1; - var carry = 0; - - for (var i = 0, shift = 0; i < this.length; i++) { - var word = (this.words[i] << shift) | carry; - - res[position--] = word & 0xff; - if (position >= 0) { - res[position--] = (word >> 8) & 0xff; - } - if (position >= 0) { - res[position--] = (word >> 16) & 0xff; - } - - if (shift === 6) { - if (position >= 0) { - res[position--] = (word >> 24) & 0xff; - } - carry = 0; - shift = 0; - } else { - carry = word >>> 24; - shift += 2; - } - } - - if (position >= 0) { - res[position--] = carry; - - while (position >= 0) { - res[position--] = 0; - } - } - }; - - if (Math.clz32) { - BN.prototype._countBits = function _countBits (w) { - return 32 - Math.clz32(w); - }; - } else { - BN.prototype._countBits = function _countBits (w) { - var t = w; - var r = 0; - if (t >= 0x1000) { - r += 13; - t >>>= 13; - } - if (t >= 0x40) { - r += 7; - t >>>= 7; - } - if (t >= 0x8) { - r += 4; - t >>>= 4; - } - if (t >= 0x02) { - r += 2; - t >>>= 2; - } - return r + t; - }; - } - - BN.prototype._zeroBits = function _zeroBits (w) { - // Short-cut - if (w === 0) return 26; - - var t = w; - var r = 0; - if ((t & 0x1fff) === 0) { - r += 13; - t >>>= 13; - } - if ((t & 0x7f) === 0) { - r += 7; - t >>>= 7; - } - if ((t & 0xf) === 0) { - r += 4; - t >>>= 4; - } - if ((t & 0x3) === 0) { - r += 2; - t >>>= 2; - } - if ((t & 0x1) === 0) { - r++; - } - return r; - }; - - // Return number of used bits in a BN - BN.prototype.bitLength = function bitLength () { - var w = this.words[this.length - 1]; - var hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }; - - function toBitArray (num) { - var w = new Array(num.bitLength()); - - for (var bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0; - var wbit = bit % 26; - - w[bit] = (num.words[off] >>> wbit) & 0x01; - } - - return w; - } - - // Number of trailing zero bits - BN.prototype.zeroBits = function zeroBits () { - if (this.isZero()) return 0; - - var r = 0; - for (var i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - r += b; - if (b !== 26) break; - } - return r; - }; - - BN.prototype.byteLength = function byteLength () { - return Math.ceil(this.bitLength() / 8); - }; - - BN.prototype.toTwos = function toTwos (width) { - if (this.negative !== 0) { - return this.abs().inotn(width).iaddn(1); - } - return this.clone(); - }; - - BN.prototype.fromTwos = function fromTwos (width) { - if (this.testn(width - 1)) { - return this.notn(width).iaddn(1).ineg(); - } - return this.clone(); - }; - - BN.prototype.isNeg = function isNeg () { - return this.negative !== 0; - }; - - // Return negative clone of `this` - BN.prototype.neg = function neg () { - return this.clone().ineg(); - }; - - BN.prototype.ineg = function ineg () { - if (!this.isZero()) { - this.negative ^= 1; - } - - return this; - }; - - // Or `num` with `this` in-place - BN.prototype.iuor = function iuor (num) { - while (this.length < num.length) { - this.words[this.length++] = 0; - } - - for (var i = 0; i < num.length; i++) { - this.words[i] = this.words[i] | num.words[i]; - } - - return this._strip(); - }; - - BN.prototype.ior = function ior (num) { - assert((this.negative | num.negative) === 0); - return this.iuor(num); - }; - - // Or `num` with `this` - BN.prototype.or = function or (num) { - if (this.length > num.length) return this.clone().ior(num); - return num.clone().ior(this); - }; - - BN.prototype.uor = function uor (num) { - if (this.length > num.length) return this.clone().iuor(num); - return num.clone().iuor(this); - }; - - // And `num` with `this` in-place - BN.prototype.iuand = function iuand (num) { - // b = min-length(num, this) - var b; - if (this.length > num.length) { - b = num; - } else { - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = this.words[i] & num.words[i]; - } - - this.length = b.length; - - return this._strip(); - }; - - BN.prototype.iand = function iand (num) { - assert((this.negative | num.negative) === 0); - return this.iuand(num); - }; - - // And `num` with `this` - BN.prototype.and = function and (num) { - if (this.length > num.length) return this.clone().iand(num); - return num.clone().iand(this); - }; - - BN.prototype.uand = function uand (num) { - if (this.length > num.length) return this.clone().iuand(num); - return num.clone().iuand(this); - }; - - // Xor `num` with `this` in-place - BN.prototype.iuxor = function iuxor (num) { - // a.length > b.length - var a; - var b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = a.words[i] ^ b.words[i]; - } - - if (this !== a) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = a.length; - - return this._strip(); - }; - - BN.prototype.ixor = function ixor (num) { - assert((this.negative | num.negative) === 0); - return this.iuxor(num); - }; - - // Xor `num` with `this` - BN.prototype.xor = function xor (num) { - if (this.length > num.length) return this.clone().ixor(num); - return num.clone().ixor(this); - }; - - BN.prototype.uxor = function uxor (num) { - if (this.length > num.length) return this.clone().iuxor(num); - return num.clone().iuxor(this); - }; - - // Not ``this`` with ``width`` bitwidth - BN.prototype.inotn = function inotn (width) { - assert(typeof width === 'number' && width >= 0); - - var bytesNeeded = Math.ceil(width / 26) | 0; - var bitsLeft = width % 26; - - // Extend the buffer with leading zeroes - this._expand(bytesNeeded); - - if (bitsLeft > 0) { - bytesNeeded--; - } - - // Handle complete words - for (var i = 0; i < bytesNeeded; i++) { - this.words[i] = ~this.words[i] & 0x3ffffff; - } - - // Handle the residue - if (bitsLeft > 0) { - this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); - } - - // And remove leading zeroes - return this._strip(); - }; - - BN.prototype.notn = function notn (width) { - return this.clone().inotn(width); - }; - - // Set `bit` of `this` - BN.prototype.setn = function setn (bit, val) { - assert(typeof bit === 'number' && bit >= 0); - - var off = (bit / 26) | 0; - var wbit = bit % 26; - - this._expand(off + 1); - - if (val) { - this.words[off] = this.words[off] | (1 << wbit); - } else { - this.words[off] = this.words[off] & ~(1 << wbit); - } - - return this._strip(); - }; - - // Add `num` to `this` in-place - BN.prototype.iadd = function iadd (num) { - var r; - - // negative + positive - if (this.negative !== 0 && num.negative === 0) { - this.negative = 0; - r = this.isub(num); - this.negative ^= 1; - return this._normSign(); - - // positive + negative - } else if (this.negative === 0 && num.negative !== 0) { - num.negative = 0; - r = this.isub(num); - num.negative = 1; - return r._normSign(); - } - - // a.length > b.length - var a, b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) + (b.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - - this.length = a.length; - if (carry !== 0) { - this.words[this.length] = carry; - this.length++; - // Copy the rest of the words - } else if (a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - return this; - }; - - // Add `num` to `this` - BN.prototype.add = function add (num) { - var res; - if (num.negative !== 0 && this.negative === 0) { - num.negative = 0; - res = this.sub(num); - num.negative ^= 1; - return res; - } else if (num.negative === 0 && this.negative !== 0) { - this.negative = 0; - res = num.sub(this); - this.negative = 1; - return res; - } - - if (this.length > num.length) return this.clone().iadd(num); - - return num.clone().iadd(this); - }; - - // Subtract `num` from `this` in-place - BN.prototype.isub = function isub (num) { - // this - (-num) = this + num - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - num.negative = 1; - return r._normSign(); - - // -this - num = -(this + num) - } else if (this.negative !== 0) { - this.negative = 0; - this.iadd(num); - this.negative = 1; - return this._normSign(); - } - - // At this point both numbers are positive - var cmp = this.cmp(num); - - // Optimization - zeroify - if (cmp === 0) { - this.negative = 0; - this.length = 1; - this.words[0] = 0; - return this; - } - - // a > b - var a, b; - if (cmp > 0) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) - (b.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - - // Copy rest of the words - if (carry === 0 && i < a.length && a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = Math.max(this.length, i); - - if (a !== this) { - this.negative = 1; - } - - return this._strip(); - }; - - // Subtract `num` from `this` - BN.prototype.sub = function sub (num) { - return this.clone().isub(num); - }; - - function smallMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - var len = (self.length + num.length) | 0; - out.length = len; - len = (len - 1) | 0; - - // Peel one iteration (compiler can't do it, because of code complexity) - var a = self.words[0] | 0; - var b = num.words[0] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - var carry = (r / 0x4000000) | 0; - out.words[0] = lo; - - for (var k = 1; k < len; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = carry >>> 26; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = (k - j) | 0; - a = self.words[i] | 0; - b = num.words[j] | 0; - r = a * b + rword; - ncarry += (r / 0x4000000) | 0; - rword = r & 0x3ffffff; - } - out.words[k] = rword | 0; - carry = ncarry | 0; - } - if (carry !== 0) { - out.words[k] = carry | 0; - } else { - out.length--; - } - - return out._strip(); - } - - // TODO(indutny): it may be reasonable to omit it for users who don't need - // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit - // multiplication (like elliptic secp256k1). - var comb10MulTo = function comb10MulTo (self, num, out) { - var a = self.words; - var b = num.words; - var o = out.words; - var c = 0; - var lo; - var mid; - var hi; - var a0 = a[0] | 0; - var al0 = a0 & 0x1fff; - var ah0 = a0 >>> 13; - var a1 = a[1] | 0; - var al1 = a1 & 0x1fff; - var ah1 = a1 >>> 13; - var a2 = a[2] | 0; - var al2 = a2 & 0x1fff; - var ah2 = a2 >>> 13; - var a3 = a[3] | 0; - var al3 = a3 & 0x1fff; - var ah3 = a3 >>> 13; - var a4 = a[4] | 0; - var al4 = a4 & 0x1fff; - var ah4 = a4 >>> 13; - var a5 = a[5] | 0; - var al5 = a5 & 0x1fff; - var ah5 = a5 >>> 13; - var a6 = a[6] | 0; - var al6 = a6 & 0x1fff; - var ah6 = a6 >>> 13; - var a7 = a[7] | 0; - var al7 = a7 & 0x1fff; - var ah7 = a7 >>> 13; - var a8 = a[8] | 0; - var al8 = a8 & 0x1fff; - var ah8 = a8 >>> 13; - var a9 = a[9] | 0; - var al9 = a9 & 0x1fff; - var ah9 = a9 >>> 13; - var b0 = b[0] | 0; - var bl0 = b0 & 0x1fff; - var bh0 = b0 >>> 13; - var b1 = b[1] | 0; - var bl1 = b1 & 0x1fff; - var bh1 = b1 >>> 13; - var b2 = b[2] | 0; - var bl2 = b2 & 0x1fff; - var bh2 = b2 >>> 13; - var b3 = b[3] | 0; - var bl3 = b3 & 0x1fff; - var bh3 = b3 >>> 13; - var b4 = b[4] | 0; - var bl4 = b4 & 0x1fff; - var bh4 = b4 >>> 13; - var b5 = b[5] | 0; - var bl5 = b5 & 0x1fff; - var bh5 = b5 >>> 13; - var b6 = b[6] | 0; - var bl6 = b6 & 0x1fff; - var bh6 = b6 >>> 13; - var b7 = b[7] | 0; - var bl7 = b7 & 0x1fff; - var bh7 = b7 >>> 13; - var b8 = b[8] | 0; - var bl8 = b8 & 0x1fff; - var bh8 = b8 >>> 13; - var b9 = b[9] | 0; - var bl9 = b9 & 0x1fff; - var bh9 = b9 >>> 13; - - out.negative = self.negative ^ num.negative; - out.length = 19; - /* k = 0 */ - lo = Math.imul(al0, bl0); - mid = Math.imul(al0, bh0); - mid = (mid + Math.imul(ah0, bl0)) | 0; - hi = Math.imul(ah0, bh0); - var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; - w0 &= 0x3ffffff; - /* k = 1 */ - lo = Math.imul(al1, bl0); - mid = Math.imul(al1, bh0); - mid = (mid + Math.imul(ah1, bl0)) | 0; - hi = Math.imul(ah1, bh0); - lo = (lo + Math.imul(al0, bl1)) | 0; - mid = (mid + Math.imul(al0, bh1)) | 0; - mid = (mid + Math.imul(ah0, bl1)) | 0; - hi = (hi + Math.imul(ah0, bh1)) | 0; - var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; - w1 &= 0x3ffffff; - /* k = 2 */ - lo = Math.imul(al2, bl0); - mid = Math.imul(al2, bh0); - mid = (mid + Math.imul(ah2, bl0)) | 0; - hi = Math.imul(ah2, bh0); - lo = (lo + Math.imul(al1, bl1)) | 0; - mid = (mid + Math.imul(al1, bh1)) | 0; - mid = (mid + Math.imul(ah1, bl1)) | 0; - hi = (hi + Math.imul(ah1, bh1)) | 0; - lo = (lo + Math.imul(al0, bl2)) | 0; - mid = (mid + Math.imul(al0, bh2)) | 0; - mid = (mid + Math.imul(ah0, bl2)) | 0; - hi = (hi + Math.imul(ah0, bh2)) | 0; - var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; - w2 &= 0x3ffffff; - /* k = 3 */ - lo = Math.imul(al3, bl0); - mid = Math.imul(al3, bh0); - mid = (mid + Math.imul(ah3, bl0)) | 0; - hi = Math.imul(ah3, bh0); - lo = (lo + Math.imul(al2, bl1)) | 0; - mid = (mid + Math.imul(al2, bh1)) | 0; - mid = (mid + Math.imul(ah2, bl1)) | 0; - hi = (hi + Math.imul(ah2, bh1)) | 0; - lo = (lo + Math.imul(al1, bl2)) | 0; - mid = (mid + Math.imul(al1, bh2)) | 0; - mid = (mid + Math.imul(ah1, bl2)) | 0; - hi = (hi + Math.imul(ah1, bh2)) | 0; - lo = (lo + Math.imul(al0, bl3)) | 0; - mid = (mid + Math.imul(al0, bh3)) | 0; - mid = (mid + Math.imul(ah0, bl3)) | 0; - hi = (hi + Math.imul(ah0, bh3)) | 0; - var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; - w3 &= 0x3ffffff; - /* k = 4 */ - lo = Math.imul(al4, bl0); - mid = Math.imul(al4, bh0); - mid = (mid + Math.imul(ah4, bl0)) | 0; - hi = Math.imul(ah4, bh0); - lo = (lo + Math.imul(al3, bl1)) | 0; - mid = (mid + Math.imul(al3, bh1)) | 0; - mid = (mid + Math.imul(ah3, bl1)) | 0; - hi = (hi + Math.imul(ah3, bh1)) | 0; - lo = (lo + Math.imul(al2, bl2)) | 0; - mid = (mid + Math.imul(al2, bh2)) | 0; - mid = (mid + Math.imul(ah2, bl2)) | 0; - hi = (hi + Math.imul(ah2, bh2)) | 0; - lo = (lo + Math.imul(al1, bl3)) | 0; - mid = (mid + Math.imul(al1, bh3)) | 0; - mid = (mid + Math.imul(ah1, bl3)) | 0; - hi = (hi + Math.imul(ah1, bh3)) | 0; - lo = (lo + Math.imul(al0, bl4)) | 0; - mid = (mid + Math.imul(al0, bh4)) | 0; - mid = (mid + Math.imul(ah0, bl4)) | 0; - hi = (hi + Math.imul(ah0, bh4)) | 0; - var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; - w4 &= 0x3ffffff; - /* k = 5 */ - lo = Math.imul(al5, bl0); - mid = Math.imul(al5, bh0); - mid = (mid + Math.imul(ah5, bl0)) | 0; - hi = Math.imul(ah5, bh0); - lo = (lo + Math.imul(al4, bl1)) | 0; - mid = (mid + Math.imul(al4, bh1)) | 0; - mid = (mid + Math.imul(ah4, bl1)) | 0; - hi = (hi + Math.imul(ah4, bh1)) | 0; - lo = (lo + Math.imul(al3, bl2)) | 0; - mid = (mid + Math.imul(al3, bh2)) | 0; - mid = (mid + Math.imul(ah3, bl2)) | 0; - hi = (hi + Math.imul(ah3, bh2)) | 0; - lo = (lo + Math.imul(al2, bl3)) | 0; - mid = (mid + Math.imul(al2, bh3)) | 0; - mid = (mid + Math.imul(ah2, bl3)) | 0; - hi = (hi + Math.imul(ah2, bh3)) | 0; - lo = (lo + Math.imul(al1, bl4)) | 0; - mid = (mid + Math.imul(al1, bh4)) | 0; - mid = (mid + Math.imul(ah1, bl4)) | 0; - hi = (hi + Math.imul(ah1, bh4)) | 0; - lo = (lo + Math.imul(al0, bl5)) | 0; - mid = (mid + Math.imul(al0, bh5)) | 0; - mid = (mid + Math.imul(ah0, bl5)) | 0; - hi = (hi + Math.imul(ah0, bh5)) | 0; - var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; - w5 &= 0x3ffffff; - /* k = 6 */ - lo = Math.imul(al6, bl0); - mid = Math.imul(al6, bh0); - mid = (mid + Math.imul(ah6, bl0)) | 0; - hi = Math.imul(ah6, bh0); - lo = (lo + Math.imul(al5, bl1)) | 0; - mid = (mid + Math.imul(al5, bh1)) | 0; - mid = (mid + Math.imul(ah5, bl1)) | 0; - hi = (hi + Math.imul(ah5, bh1)) | 0; - lo = (lo + Math.imul(al4, bl2)) | 0; - mid = (mid + Math.imul(al4, bh2)) | 0; - mid = (mid + Math.imul(ah4, bl2)) | 0; - hi = (hi + Math.imul(ah4, bh2)) | 0; - lo = (lo + Math.imul(al3, bl3)) | 0; - mid = (mid + Math.imul(al3, bh3)) | 0; - mid = (mid + Math.imul(ah3, bl3)) | 0; - hi = (hi + Math.imul(ah3, bh3)) | 0; - lo = (lo + Math.imul(al2, bl4)) | 0; - mid = (mid + Math.imul(al2, bh4)) | 0; - mid = (mid + Math.imul(ah2, bl4)) | 0; - hi = (hi + Math.imul(ah2, bh4)) | 0; - lo = (lo + Math.imul(al1, bl5)) | 0; - mid = (mid + Math.imul(al1, bh5)) | 0; - mid = (mid + Math.imul(ah1, bl5)) | 0; - hi = (hi + Math.imul(ah1, bh5)) | 0; - lo = (lo + Math.imul(al0, bl6)) | 0; - mid = (mid + Math.imul(al0, bh6)) | 0; - mid = (mid + Math.imul(ah0, bl6)) | 0; - hi = (hi + Math.imul(ah0, bh6)) | 0; - var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; - w6 &= 0x3ffffff; - /* k = 7 */ - lo = Math.imul(al7, bl0); - mid = Math.imul(al7, bh0); - mid = (mid + Math.imul(ah7, bl0)) | 0; - hi = Math.imul(ah7, bh0); - lo = (lo + Math.imul(al6, bl1)) | 0; - mid = (mid + Math.imul(al6, bh1)) | 0; - mid = (mid + Math.imul(ah6, bl1)) | 0; - hi = (hi + Math.imul(ah6, bh1)) | 0; - lo = (lo + Math.imul(al5, bl2)) | 0; - mid = (mid + Math.imul(al5, bh2)) | 0; - mid = (mid + Math.imul(ah5, bl2)) | 0; - hi = (hi + Math.imul(ah5, bh2)) | 0; - lo = (lo + Math.imul(al4, bl3)) | 0; - mid = (mid + Math.imul(al4, bh3)) | 0; - mid = (mid + Math.imul(ah4, bl3)) | 0; - hi = (hi + Math.imul(ah4, bh3)) | 0; - lo = (lo + Math.imul(al3, bl4)) | 0; - mid = (mid + Math.imul(al3, bh4)) | 0; - mid = (mid + Math.imul(ah3, bl4)) | 0; - hi = (hi + Math.imul(ah3, bh4)) | 0; - lo = (lo + Math.imul(al2, bl5)) | 0; - mid = (mid + Math.imul(al2, bh5)) | 0; - mid = (mid + Math.imul(ah2, bl5)) | 0; - hi = (hi + Math.imul(ah2, bh5)) | 0; - lo = (lo + Math.imul(al1, bl6)) | 0; - mid = (mid + Math.imul(al1, bh6)) | 0; - mid = (mid + Math.imul(ah1, bl6)) | 0; - hi = (hi + Math.imul(ah1, bh6)) | 0; - lo = (lo + Math.imul(al0, bl7)) | 0; - mid = (mid + Math.imul(al0, bh7)) | 0; - mid = (mid + Math.imul(ah0, bl7)) | 0; - hi = (hi + Math.imul(ah0, bh7)) | 0; - var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; - w7 &= 0x3ffffff; - /* k = 8 */ - lo = Math.imul(al8, bl0); - mid = Math.imul(al8, bh0); - mid = (mid + Math.imul(ah8, bl0)) | 0; - hi = Math.imul(ah8, bh0); - lo = (lo + Math.imul(al7, bl1)) | 0; - mid = (mid + Math.imul(al7, bh1)) | 0; - mid = (mid + Math.imul(ah7, bl1)) | 0; - hi = (hi + Math.imul(ah7, bh1)) | 0; - lo = (lo + Math.imul(al6, bl2)) | 0; - mid = (mid + Math.imul(al6, bh2)) | 0; - mid = (mid + Math.imul(ah6, bl2)) | 0; - hi = (hi + Math.imul(ah6, bh2)) | 0; - lo = (lo + Math.imul(al5, bl3)) | 0; - mid = (mid + Math.imul(al5, bh3)) | 0; - mid = (mid + Math.imul(ah5, bl3)) | 0; - hi = (hi + Math.imul(ah5, bh3)) | 0; - lo = (lo + Math.imul(al4, bl4)) | 0; - mid = (mid + Math.imul(al4, bh4)) | 0; - mid = (mid + Math.imul(ah4, bl4)) | 0; - hi = (hi + Math.imul(ah4, bh4)) | 0; - lo = (lo + Math.imul(al3, bl5)) | 0; - mid = (mid + Math.imul(al3, bh5)) | 0; - mid = (mid + Math.imul(ah3, bl5)) | 0; - hi = (hi + Math.imul(ah3, bh5)) | 0; - lo = (lo + Math.imul(al2, bl6)) | 0; - mid = (mid + Math.imul(al2, bh6)) | 0; - mid = (mid + Math.imul(ah2, bl6)) | 0; - hi = (hi + Math.imul(ah2, bh6)) | 0; - lo = (lo + Math.imul(al1, bl7)) | 0; - mid = (mid + Math.imul(al1, bh7)) | 0; - mid = (mid + Math.imul(ah1, bl7)) | 0; - hi = (hi + Math.imul(ah1, bh7)) | 0; - lo = (lo + Math.imul(al0, bl8)) | 0; - mid = (mid + Math.imul(al0, bh8)) | 0; - mid = (mid + Math.imul(ah0, bl8)) | 0; - hi = (hi + Math.imul(ah0, bh8)) | 0; - var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; - w8 &= 0x3ffffff; - /* k = 9 */ - lo = Math.imul(al9, bl0); - mid = Math.imul(al9, bh0); - mid = (mid + Math.imul(ah9, bl0)) | 0; - hi = Math.imul(ah9, bh0); - lo = (lo + Math.imul(al8, bl1)) | 0; - mid = (mid + Math.imul(al8, bh1)) | 0; - mid = (mid + Math.imul(ah8, bl1)) | 0; - hi = (hi + Math.imul(ah8, bh1)) | 0; - lo = (lo + Math.imul(al7, bl2)) | 0; - mid = (mid + Math.imul(al7, bh2)) | 0; - mid = (mid + Math.imul(ah7, bl2)) | 0; - hi = (hi + Math.imul(ah7, bh2)) | 0; - lo = (lo + Math.imul(al6, bl3)) | 0; - mid = (mid + Math.imul(al6, bh3)) | 0; - mid = (mid + Math.imul(ah6, bl3)) | 0; - hi = (hi + Math.imul(ah6, bh3)) | 0; - lo = (lo + Math.imul(al5, bl4)) | 0; - mid = (mid + Math.imul(al5, bh4)) | 0; - mid = (mid + Math.imul(ah5, bl4)) | 0; - hi = (hi + Math.imul(ah5, bh4)) | 0; - lo = (lo + Math.imul(al4, bl5)) | 0; - mid = (mid + Math.imul(al4, bh5)) | 0; - mid = (mid + Math.imul(ah4, bl5)) | 0; - hi = (hi + Math.imul(ah4, bh5)) | 0; - lo = (lo + Math.imul(al3, bl6)) | 0; - mid = (mid + Math.imul(al3, bh6)) | 0; - mid = (mid + Math.imul(ah3, bl6)) | 0; - hi = (hi + Math.imul(ah3, bh6)) | 0; - lo = (lo + Math.imul(al2, bl7)) | 0; - mid = (mid + Math.imul(al2, bh7)) | 0; - mid = (mid + Math.imul(ah2, bl7)) | 0; - hi = (hi + Math.imul(ah2, bh7)) | 0; - lo = (lo + Math.imul(al1, bl8)) | 0; - mid = (mid + Math.imul(al1, bh8)) | 0; - mid = (mid + Math.imul(ah1, bl8)) | 0; - hi = (hi + Math.imul(ah1, bh8)) | 0; - lo = (lo + Math.imul(al0, bl9)) | 0; - mid = (mid + Math.imul(al0, bh9)) | 0; - mid = (mid + Math.imul(ah0, bl9)) | 0; - hi = (hi + Math.imul(ah0, bh9)) | 0; - var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; - w9 &= 0x3ffffff; - /* k = 10 */ - lo = Math.imul(al9, bl1); - mid = Math.imul(al9, bh1); - mid = (mid + Math.imul(ah9, bl1)) | 0; - hi = Math.imul(ah9, bh1); - lo = (lo + Math.imul(al8, bl2)) | 0; - mid = (mid + Math.imul(al8, bh2)) | 0; - mid = (mid + Math.imul(ah8, bl2)) | 0; - hi = (hi + Math.imul(ah8, bh2)) | 0; - lo = (lo + Math.imul(al7, bl3)) | 0; - mid = (mid + Math.imul(al7, bh3)) | 0; - mid = (mid + Math.imul(ah7, bl3)) | 0; - hi = (hi + Math.imul(ah7, bh3)) | 0; - lo = (lo + Math.imul(al6, bl4)) | 0; - mid = (mid + Math.imul(al6, bh4)) | 0; - mid = (mid + Math.imul(ah6, bl4)) | 0; - hi = (hi + Math.imul(ah6, bh4)) | 0; - lo = (lo + Math.imul(al5, bl5)) | 0; - mid = (mid + Math.imul(al5, bh5)) | 0; - mid = (mid + Math.imul(ah5, bl5)) | 0; - hi = (hi + Math.imul(ah5, bh5)) | 0; - lo = (lo + Math.imul(al4, bl6)) | 0; - mid = (mid + Math.imul(al4, bh6)) | 0; - mid = (mid + Math.imul(ah4, bl6)) | 0; - hi = (hi + Math.imul(ah4, bh6)) | 0; - lo = (lo + Math.imul(al3, bl7)) | 0; - mid = (mid + Math.imul(al3, bh7)) | 0; - mid = (mid + Math.imul(ah3, bl7)) | 0; - hi = (hi + Math.imul(ah3, bh7)) | 0; - lo = (lo + Math.imul(al2, bl8)) | 0; - mid = (mid + Math.imul(al2, bh8)) | 0; - mid = (mid + Math.imul(ah2, bl8)) | 0; - hi = (hi + Math.imul(ah2, bh8)) | 0; - lo = (lo + Math.imul(al1, bl9)) | 0; - mid = (mid + Math.imul(al1, bh9)) | 0; - mid = (mid + Math.imul(ah1, bl9)) | 0; - hi = (hi + Math.imul(ah1, bh9)) | 0; - var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; - w10 &= 0x3ffffff; - /* k = 11 */ - lo = Math.imul(al9, bl2); - mid = Math.imul(al9, bh2); - mid = (mid + Math.imul(ah9, bl2)) | 0; - hi = Math.imul(ah9, bh2); - lo = (lo + Math.imul(al8, bl3)) | 0; - mid = (mid + Math.imul(al8, bh3)) | 0; - mid = (mid + Math.imul(ah8, bl3)) | 0; - hi = (hi + Math.imul(ah8, bh3)) | 0; - lo = (lo + Math.imul(al7, bl4)) | 0; - mid = (mid + Math.imul(al7, bh4)) | 0; - mid = (mid + Math.imul(ah7, bl4)) | 0; - hi = (hi + Math.imul(ah7, bh4)) | 0; - lo = (lo + Math.imul(al6, bl5)) | 0; - mid = (mid + Math.imul(al6, bh5)) | 0; - mid = (mid + Math.imul(ah6, bl5)) | 0; - hi = (hi + Math.imul(ah6, bh5)) | 0; - lo = (lo + Math.imul(al5, bl6)) | 0; - mid = (mid + Math.imul(al5, bh6)) | 0; - mid = (mid + Math.imul(ah5, bl6)) | 0; - hi = (hi + Math.imul(ah5, bh6)) | 0; - lo = (lo + Math.imul(al4, bl7)) | 0; - mid = (mid + Math.imul(al4, bh7)) | 0; - mid = (mid + Math.imul(ah4, bl7)) | 0; - hi = (hi + Math.imul(ah4, bh7)) | 0; - lo = (lo + Math.imul(al3, bl8)) | 0; - mid = (mid + Math.imul(al3, bh8)) | 0; - mid = (mid + Math.imul(ah3, bl8)) | 0; - hi = (hi + Math.imul(ah3, bh8)) | 0; - lo = (lo + Math.imul(al2, bl9)) | 0; - mid = (mid + Math.imul(al2, bh9)) | 0; - mid = (mid + Math.imul(ah2, bl9)) | 0; - hi = (hi + Math.imul(ah2, bh9)) | 0; - var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; - w11 &= 0x3ffffff; - /* k = 12 */ - lo = Math.imul(al9, bl3); - mid = Math.imul(al9, bh3); - mid = (mid + Math.imul(ah9, bl3)) | 0; - hi = Math.imul(ah9, bh3); - lo = (lo + Math.imul(al8, bl4)) | 0; - mid = (mid + Math.imul(al8, bh4)) | 0; - mid = (mid + Math.imul(ah8, bl4)) | 0; - hi = (hi + Math.imul(ah8, bh4)) | 0; - lo = (lo + Math.imul(al7, bl5)) | 0; - mid = (mid + Math.imul(al7, bh5)) | 0; - mid = (mid + Math.imul(ah7, bl5)) | 0; - hi = (hi + Math.imul(ah7, bh5)) | 0; - lo = (lo + Math.imul(al6, bl6)) | 0; - mid = (mid + Math.imul(al6, bh6)) | 0; - mid = (mid + Math.imul(ah6, bl6)) | 0; - hi = (hi + Math.imul(ah6, bh6)) | 0; - lo = (lo + Math.imul(al5, bl7)) | 0; - mid = (mid + Math.imul(al5, bh7)) | 0; - mid = (mid + Math.imul(ah5, bl7)) | 0; - hi = (hi + Math.imul(ah5, bh7)) | 0; - lo = (lo + Math.imul(al4, bl8)) | 0; - mid = (mid + Math.imul(al4, bh8)) | 0; - mid = (mid + Math.imul(ah4, bl8)) | 0; - hi = (hi + Math.imul(ah4, bh8)) | 0; - lo = (lo + Math.imul(al3, bl9)) | 0; - mid = (mid + Math.imul(al3, bh9)) | 0; - mid = (mid + Math.imul(ah3, bl9)) | 0; - hi = (hi + Math.imul(ah3, bh9)) | 0; - var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; - w12 &= 0x3ffffff; - /* k = 13 */ - lo = Math.imul(al9, bl4); - mid = Math.imul(al9, bh4); - mid = (mid + Math.imul(ah9, bl4)) | 0; - hi = Math.imul(ah9, bh4); - lo = (lo + Math.imul(al8, bl5)) | 0; - mid = (mid + Math.imul(al8, bh5)) | 0; - mid = (mid + Math.imul(ah8, bl5)) | 0; - hi = (hi + Math.imul(ah8, bh5)) | 0; - lo = (lo + Math.imul(al7, bl6)) | 0; - mid = (mid + Math.imul(al7, bh6)) | 0; - mid = (mid + Math.imul(ah7, bl6)) | 0; - hi = (hi + Math.imul(ah7, bh6)) | 0; - lo = (lo + Math.imul(al6, bl7)) | 0; - mid = (mid + Math.imul(al6, bh7)) | 0; - mid = (mid + Math.imul(ah6, bl7)) | 0; - hi = (hi + Math.imul(ah6, bh7)) | 0; - lo = (lo + Math.imul(al5, bl8)) | 0; - mid = (mid + Math.imul(al5, bh8)) | 0; - mid = (mid + Math.imul(ah5, bl8)) | 0; - hi = (hi + Math.imul(ah5, bh8)) | 0; - lo = (lo + Math.imul(al4, bl9)) | 0; - mid = (mid + Math.imul(al4, bh9)) | 0; - mid = (mid + Math.imul(ah4, bl9)) | 0; - hi = (hi + Math.imul(ah4, bh9)) | 0; - var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; - w13 &= 0x3ffffff; - /* k = 14 */ - lo = Math.imul(al9, bl5); - mid = Math.imul(al9, bh5); - mid = (mid + Math.imul(ah9, bl5)) | 0; - hi = Math.imul(ah9, bh5); - lo = (lo + Math.imul(al8, bl6)) | 0; - mid = (mid + Math.imul(al8, bh6)) | 0; - mid = (mid + Math.imul(ah8, bl6)) | 0; - hi = (hi + Math.imul(ah8, bh6)) | 0; - lo = (lo + Math.imul(al7, bl7)) | 0; - mid = (mid + Math.imul(al7, bh7)) | 0; - mid = (mid + Math.imul(ah7, bl7)) | 0; - hi = (hi + Math.imul(ah7, bh7)) | 0; - lo = (lo + Math.imul(al6, bl8)) | 0; - mid = (mid + Math.imul(al6, bh8)) | 0; - mid = (mid + Math.imul(ah6, bl8)) | 0; - hi = (hi + Math.imul(ah6, bh8)) | 0; - lo = (lo + Math.imul(al5, bl9)) | 0; - mid = (mid + Math.imul(al5, bh9)) | 0; - mid = (mid + Math.imul(ah5, bl9)) | 0; - hi = (hi + Math.imul(ah5, bh9)) | 0; - var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; - w14 &= 0x3ffffff; - /* k = 15 */ - lo = Math.imul(al9, bl6); - mid = Math.imul(al9, bh6); - mid = (mid + Math.imul(ah9, bl6)) | 0; - hi = Math.imul(ah9, bh6); - lo = (lo + Math.imul(al8, bl7)) | 0; - mid = (mid + Math.imul(al8, bh7)) | 0; - mid = (mid + Math.imul(ah8, bl7)) | 0; - hi = (hi + Math.imul(ah8, bh7)) | 0; - lo = (lo + Math.imul(al7, bl8)) | 0; - mid = (mid + Math.imul(al7, bh8)) | 0; - mid = (mid + Math.imul(ah7, bl8)) | 0; - hi = (hi + Math.imul(ah7, bh8)) | 0; - lo = (lo + Math.imul(al6, bl9)) | 0; - mid = (mid + Math.imul(al6, bh9)) | 0; - mid = (mid + Math.imul(ah6, bl9)) | 0; - hi = (hi + Math.imul(ah6, bh9)) | 0; - var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; - w15 &= 0x3ffffff; - /* k = 16 */ - lo = Math.imul(al9, bl7); - mid = Math.imul(al9, bh7); - mid = (mid + Math.imul(ah9, bl7)) | 0; - hi = Math.imul(ah9, bh7); - lo = (lo + Math.imul(al8, bl8)) | 0; - mid = (mid + Math.imul(al8, bh8)) | 0; - mid = (mid + Math.imul(ah8, bl8)) | 0; - hi = (hi + Math.imul(ah8, bh8)) | 0; - lo = (lo + Math.imul(al7, bl9)) | 0; - mid = (mid + Math.imul(al7, bh9)) | 0; - mid = (mid + Math.imul(ah7, bl9)) | 0; - hi = (hi + Math.imul(ah7, bh9)) | 0; - var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; - w16 &= 0x3ffffff; - /* k = 17 */ - lo = Math.imul(al9, bl8); - mid = Math.imul(al9, bh8); - mid = (mid + Math.imul(ah9, bl8)) | 0; - hi = Math.imul(ah9, bh8); - lo = (lo + Math.imul(al8, bl9)) | 0; - mid = (mid + Math.imul(al8, bh9)) | 0; - mid = (mid + Math.imul(ah8, bl9)) | 0; - hi = (hi + Math.imul(ah8, bh9)) | 0; - var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; - w17 &= 0x3ffffff; - /* k = 18 */ - lo = Math.imul(al9, bl9); - mid = Math.imul(al9, bh9); - mid = (mid + Math.imul(ah9, bl9)) | 0; - hi = Math.imul(ah9, bh9); - var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; - w18 &= 0x3ffffff; - o[0] = w0; - o[1] = w1; - o[2] = w2; - o[3] = w3; - o[4] = w4; - o[5] = w5; - o[6] = w6; - o[7] = w7; - o[8] = w8; - o[9] = w9; - o[10] = w10; - o[11] = w11; - o[12] = w12; - o[13] = w13; - o[14] = w14; - o[15] = w15; - o[16] = w16; - o[17] = w17; - o[18] = w18; - if (c !== 0) { - o[19] = c; - out.length++; - } - return out; - }; - - // Polyfill comb - if (!Math.imul) { - comb10MulTo = smallMulTo; - } - - function bigMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - out.length = self.length + num.length; - - var carry = 0; - var hncarry = 0; - for (var k = 0; k < out.length - 1; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = hncarry; - hncarry = 0; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = k - j; - var a = self.words[i] | 0; - var b = num.words[j] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; - lo = (lo + rword) | 0; - rword = lo & 0x3ffffff; - ncarry = (ncarry + (lo >>> 26)) | 0; - - hncarry += ncarry >>> 26; - ncarry &= 0x3ffffff; - } - out.words[k] = rword; - carry = ncarry; - ncarry = hncarry; - } - if (carry !== 0) { - out.words[k] = carry; - } else { - out.length--; - } - - return out._strip(); - } - - function jumboMulTo (self, num, out) { - // Temporary disable, see https://github.com/indutny/bn.js/issues/211 - // var fftm = new FFTM(); - // return fftm.mulp(self, num, out); - return bigMulTo(self, num, out); - } - - BN.prototype.mulTo = function mulTo (num, out) { - var res; - var len = this.length + num.length; - if (this.length === 10 && num.length === 10) { - res = comb10MulTo(this, num, out); - } else if (len < 63) { - res = smallMulTo(this, num, out); - } else if (len < 1024) { - res = bigMulTo(this, num, out); - } else { - res = jumboMulTo(this, num, out); - } - - return res; - }; - - // Cooley-Tukey algorithm for FFT - // slightly revisited to rely on looping instead of recursion - - function FFTM (x, y) { - this.x = x; - this.y = y; - } - - FFTM.prototype.makeRBT = function makeRBT (N) { - var t = new Array(N); - var l = BN.prototype._countBits(N) - 1; - for (var i = 0; i < N; i++) { - t[i] = this.revBin(i, l, N); - } - - return t; - }; - - // Returns binary-reversed representation of `x` - FFTM.prototype.revBin = function revBin (x, l, N) { - if (x === 0 || x === N - 1) return x; - - var rb = 0; - for (var i = 0; i < l; i++) { - rb |= (x & 1) << (l - i - 1); - x >>= 1; - } - - return rb; - }; - - // Performs "tweedling" phase, therefore 'emulating' - // behaviour of the recursive algorithm - FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) { - rtws[i] = rws[rbt[i]]; - itws[i] = iws[rbt[i]]; - } - }; - - FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - - for (var s = 1; s < N; s <<= 1) { - var l = s << 1; - - var rtwdf = Math.cos(2 * Math.PI / l); - var itwdf = Math.sin(2 * Math.PI / l); - - for (var p = 0; p < N; p += l) { - var rtwdf_ = rtwdf; - var itwdf_ = itwdf; - - for (var j = 0; j < s; j++) { - var re = rtws[p + j]; - var ie = itws[p + j]; - - var ro = rtws[p + j + s]; - var io = itws[p + j + s]; - - var rx = rtwdf_ * ro - itwdf_ * io; - - io = rtwdf_ * io + itwdf_ * ro; - ro = rx; - - rtws[p + j] = re + ro; - itws[p + j] = ie + io; - - rtws[p + j + s] = re - ro; - itws[p + j + s] = ie - io; - - /* jshint maxdepth : false */ - if (j !== l) { - rx = rtwdf * rtwdf_ - itwdf * itwdf_; - - itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; - rtwdf_ = rx; - } - } - } - } - }; - - FFTM.prototype.guessLen13b = function guessLen13b (n, m) { - var N = Math.max(m, n) | 1; - var odd = N & 1; - var i = 0; - for (N = N / 2 | 0; N; N = N >>> 1) { - i++; - } - - return 1 << i + 1 + odd; - }; - - FFTM.prototype.conjugate = function conjugate (rws, iws, N) { - if (N <= 1) return; - - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - - rws[i] = rws[N - i - 1]; - rws[N - i - 1] = t; - - t = iws[i]; - - iws[i] = -iws[N - i - 1]; - iws[N - i - 1] = -t; - } - }; - - FFTM.prototype.normalize13b = function normalize13b (ws, N) { - var carry = 0; - for (var i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + - Math.round(ws[2 * i] / N) + - carry; - - ws[i] = w & 0x3ffffff; - - if (w < 0x4000000) { - carry = 0; - } else { - carry = w / 0x4000000 | 0; - } - } - - return ws; - }; - - FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { - var carry = 0; - for (var i = 0; i < len; i++) { - carry = carry + (ws[i] | 0); - - rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; - rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; - } - - // Pad with zeroes - for (i = 2 * len; i < N; ++i) { - rws[i] = 0; - } - - assert(carry === 0); - assert((carry & ~0x1fff) === 0); - }; - - FFTM.prototype.stub = function stub (N) { - var ph = new Array(N); - for (var i = 0; i < N; i++) { - ph[i] = 0; - } - - return ph; - }; - - FFTM.prototype.mulp = function mulp (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length); - - var rbt = this.makeRBT(N); - - var _ = this.stub(N); - - var rws = new Array(N); - var rwst = new Array(N); - var iwst = new Array(N); - - var nrws = new Array(N); - var nrwst = new Array(N); - var niwst = new Array(N); - - var rmws = out.words; - rmws.length = N; - - this.convert13b(x.words, x.length, rws, N); - this.convert13b(y.words, y.length, nrws, N); - - this.transform(rws, _, rwst, iwst, N, rbt); - this.transform(nrws, _, nrwst, niwst, N, rbt); - - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; - rwst[i] = rx; - } - - this.conjugate(rwst, iwst, N); - this.transform(rwst, iwst, rmws, _, N, rbt); - this.conjugate(rmws, _, N); - this.normalize13b(rmws, N); - - out.negative = x.negative ^ y.negative; - out.length = x.length + y.length; - return out._strip(); - }; - - // Multiply `this` by `num` - BN.prototype.mul = function mul (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return this.mulTo(num, out); - }; - - // Multiply employing FFT - BN.prototype.mulf = function mulf (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return jumboMulTo(this, num, out); - }; - - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; - - BN.prototype.imuln = function imuln (num) { - var isNegNum = num < 0; - if (isNegNum) num = -num; - - assert(typeof num === 'number'); - assert(num < 0x4000000); - - // Carry - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num; - var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); - carry >>= 26; - carry += (w / 0x4000000) | 0; - // NOTE: lo is 27bit maximum - carry += lo >>> 26; - this.words[i] = lo & 0x3ffffff; - } - - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - - return isNegNum ? this.ineg() : this; - }; - - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; - - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; - - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; - - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } - - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; - - res = res.mul(q); - } - } - - return res; - }; - - // Shift-left in-place - BN.prototype.iushln = function iushln (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); - var i; - - if (r !== 0) { - var carry = 0; - - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask; - var c = ((this.words[i] | 0) - newCarry) << r; - this.words[i] = c | carry; - carry = newCarry >>> (26 - r); - } - - if (carry) { - this.words[i] = carry; - this.length++; - } - } - - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } - - for (i = 0; i < s; i++) { - this.words[i] = 0; - } - - this.length += s; - } - - return this._strip(); - }; - - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; - - // Shift-right in-place - // NOTE: `hint` is a lowest bit before trailing zeroes - // NOTE: if `extended` is present - it will be filled with destroyed bits - BN.prototype.iushrn = function iushrn (bits, hint, extended) { - assert(typeof bits === 'number' && bits >= 0); - var h; - if (hint) { - h = (hint - (hint % 26)) / 26; - } else { - h = 0; - } - - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; - - h -= s; - h = Math.max(0, h); - - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } - - if (s === 0) { - // No-op, we should not move anything at all - } else if (this.length > s) { - this.length -= s; - for (i = 0; i < this.length; i++) { - this.words[i] = this.words[i + s]; - } - } else { - this.words[0] = 0; - this.length = 1; - } - - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - this.words[i] = (carry << (26 - r)) | (word >>> r); - carry = word & mask; - } - - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } - - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } - - return this._strip(); - }; - - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; - - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; - - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; - - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; - - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; - - // Test if n bit is set - BN.prototype.testn = function testn (bit) { - assert(typeof bit === 'number' && bit >= 0); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; - - // Check bit and return - var w = this.words[s]; - - return !!(w & q); - }; - - // Return only lowers bits of number (in-place) - BN.prototype.imaskn = function imaskn (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - - assert(this.negative === 0, 'imaskn works only with positive numbers'); - - if (this.length <= s) { - return this; - } - - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); - - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } - - return this._strip(); - }; - - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; - - // Add plain number `num` to `this` - BN.prototype.iaddn = function iaddn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.isubn(-num); - - // Possible sign change - if (this.negative !== 0) { - if (this.length === 1 && (this.words[0] | 0) <= num) { - this.words[0] = num - (this.words[0] | 0); - this.negative = 0; - return this; - } - - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } - - // Add without checks - return this._iaddn(num); - }; - - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; - - // Carry - for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { - this.words[i] -= 0x4000000; - if (i === this.length - 1) { - this.words[i + 1] = 1; - } else { - this.words[i + 1]++; - } - } - this.length = Math.max(this.length, i + 1); - - return this; - }; - - // Subtract plain number `num` from `this` - BN.prototype.isubn = function isubn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.iaddn(-num); - - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } - - this.words[0] -= num; - - if (this.length === 1 && this.words[0] < 0) { - this.words[0] = -this.words[0]; - this.negative = 1; - } else { - // Carry - for (var i = 0; i < this.length && this.words[i] < 0; i++) { - this.words[i] += 0x4000000; - this.words[i + 1] -= 1; - } - } - - return this._strip(); - }; - - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; - - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; - - BN.prototype.iabs = function iabs () { - this.negative = 0; - - return this; - }; - - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; - - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; - - this._expand(len); - - var w; - var carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - w -= right & 0x3ffffff; - carry = (w >> 26) - ((right / 0x4000000) | 0); - this.words[i + shift] = w & 0x3ffffff; - } - for (; i < this.length - shift; i++) { - w = (this.words[i + shift] | 0) + carry; - carry = w >> 26; - this.words[i + shift] = w & 0x3ffffff; - } - - if (carry === 0) return this._strip(); - - // Subtraction overflow - assert(carry === -1); - carry = 0; - for (i = 0; i < this.length; i++) { - w = -(this.words[i] | 0) + carry; - carry = w >> 26; - this.words[i] = w & 0x3ffffff; - } - this.negative = 1; - - return this._strip(); - }; - - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; - - var a = this.clone(); - var b = num; - - // Normalize - var bhi = b.words[b.length - 1] | 0; - var bhiBits = this._countBits(bhi); - shift = 26 - bhiBits; - if (shift !== 0) { - b = b.ushln(shift); - a.iushln(shift); - bhi = b.words[b.length - 1] | 0; - } - - // Initialize quotient - var m = a.length - b.length; - var q; - - if (mode !== 'mod') { - q = new BN(null); - q.length = m + 1; - q.words = new Array(q.length); - for (var i = 0; i < q.length; i++) { - q.words[i] = 0; - } - } - - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } - - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); - - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); - - a._ishlnsubmul(b, qj, j); - while (a.negative !== 0) { - qj--; - a.negative = 0; - a._ishlnsubmul(b, 1, j); - if (!a.isZero()) { - a.negative ^= 1; - } - } - if (q) { - q.words[j] = qj; - } - } - if (q) { - q._strip(); - } - a._strip(); - - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } - - return { - div: q || null, - mod: a - }; - }; - - // NOTE: 1) `mode` can be set to `mod` to request mod only, - // to `div` to request div only, or be absent to - // request both div & mod - // 2) `positive` is true if unsigned mod is requested - BN.prototype.divmod = function divmod (num, mode, positive) { - assert(!num.isZero()); - - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } - - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } - - return { - div: div, - mod: mod - }; - } - - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - return { - div: div, - mod: res.mod - }; - } - - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } - - return { - div: res.div, - mod: mod - }; - } - - // Both numbers are positive at this point - - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } - - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } - - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modrn(num.words[0])) - }; - } - - return { - div: this.divn(num.words[0]), - mod: new BN(this.modrn(num.words[0])) - }; - } - - return this._wordDiv(num, mode); - }; - - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; - - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; - - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; - - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); - - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; - - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); - - // Round down - if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; - - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; - - BN.prototype.modrn = function modrn (num) { - var isNegNum = num < 0; - if (isNegNum) num = -num; - - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; - - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } - - return isNegNum ? -acc : acc; - }; - - // WARNING: DEPRECATED - BN.prototype.modn = function modn (num) { - return this.modrn(num); - }; - - // In-place division by number - BN.prototype.idivn = function idivn (num) { - var isNegNum = num < 0; - if (isNegNum) num = -num; - - assert(num <= 0x3ffffff); - - var carry = 0; - for (var i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 0x4000000; - this.words[i] = (w / num) | 0; - carry = w % num; - } - - this._strip(); - return isNegNum ? this.ineg() : this; - }; - - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; - - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var x = this; - var y = p.clone(); - - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } - - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); - - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); - - var g = 0; - - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } - - var yp = y.clone(); - var xp = x.clone(); - - while (!x.isZero()) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - x.iushrn(i); - while (i-- > 0) { - if (A.isOdd() || B.isOdd()) { - A.iadd(yp); - B.isub(xp); - } - - A.iushrn(1); - B.iushrn(1); - } - } - - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - y.iushrn(j); - while (j-- > 0) { - if (C.isOdd() || D.isOdd()) { - C.iadd(yp); - D.isub(xp); - } - - C.iushrn(1); - D.iushrn(1); - } - } - - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } - - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; - - // This is reduced incarnation of the binary EEA - // above, designated to invert members of the - // _prime_ fields F(p) at a maximal speed - BN.prototype._invmp = function _invmp (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var a = this; - var b = p.clone(); - - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } - - var x1 = new BN(1); - var x2 = new BN(0); - - var delta = b.clone(); - - while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - a.iushrn(i); - while (i-- > 0) { - if (x1.isOdd()) { - x1.iadd(delta); - } - - x1.iushrn(1); - } - } - - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - b.iushrn(j); - while (j-- > 0) { - if (x2.isOdd()) { - x2.iadd(delta); - } - - x2.iushrn(1); - } - } - - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } - - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } - - if (res.cmpn(0) < 0) { - res.iadd(p); - } - - return res; - }; - - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; - - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } - - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } - - var r = a.cmp(b); - if (r < 0) { - // Swap `a` and `b` to make `a` always bigger than `b` - var t = a; - a = b; - b = t; - } else if (r === 0 || b.cmpn(1) === 0) { - break; - } - - a.isub(b); - } while (true); - - return b.iushln(shift); - }; - - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; - - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; - - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; - - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; - - // Increment at the bit position in-line - BN.prototype.bincn = function bincn (bit) { - assert(typeof bit === 'number'); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } - - // Add bit and propagate, if needed - var carry = q; - for (var i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - w += carry; - carry = w >>> 26; - w &= 0x3ffffff; - this.words[i] = w; - } - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - return this; - }; - - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; - - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; - - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - - this._strip(); - - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } - - assert(num <= 0x3ffffff, 'Number is too big'); - - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Compare two numbers and return: - // 1 - if `this` > `num` - // 0 - if `this` == `num` - // -1 - if `this` < `num` - BN.prototype.cmp = function cmp (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Unsigned comparison - BN.prototype.ucmp = function ucmp (num) { - // At this point both numbers have the same sign - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; - - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; - - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; - - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; - - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; - - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; - - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; - - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; - - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; - - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; - - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; - - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; - - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; - - BN.prototype.toRed = function toRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - assert(this.negative === 0, 'red works only with positives'); - return ctx.convertTo(this)._forceRed(ctx); - }; - - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; - - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; - - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; - - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; - - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; - - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; - - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; - - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; - - BN.prototype.redMul = function redMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.mul(this, num); - }; - - BN.prototype.redIMul = function redIMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.imul(this, num); - }; - - BN.prototype.redSqr = function redSqr () { - assert(this.red, 'redSqr works only with red numbers'); - this.red._verify1(this); - return this.red.sqr(this); - }; - - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; - - // Square root over p - BN.prototype.redSqrt = function redSqrt () { - assert(this.red, 'redSqrt works only with red numbers'); - this.red._verify1(this); - return this.red.sqrt(this); - }; - - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; - - // Return negative clone of `this` % `red modulo` - BN.prototype.redNeg = function redNeg () { - assert(this.red, 'redNeg works only with red numbers'); - this.red._verify1(this); - return this.red.neg(this); - }; - - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; - - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - - // Pseudo-Mersenne prime - function MPrime (name, p) { - // P = 2 ^ N - K - this.name = name; - this.p = new BN(p, 16); - this.n = this.p.bitLength(); - this.k = new BN(1).iushln(this.n).isub(this.p); - - this.tmp = this._tmp(); - } - - MPrime.prototype._tmp = function _tmp () { - var tmp = new BN(null); - tmp.words = new Array(Math.ceil(this.n / 13)); - return tmp; - }; - - MPrime.prototype.ireduce = function ireduce (num) { - // Assumes that `num` is less than `P^2` - // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) - var r = num; - var rlen; - - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); - - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - if (cmp === 0) { - r.words[0] = 0; - r.length = 1; - } else if (cmp > 0) { - r.isub(this.p); - } else { - if (r.strip !== undefined) { - // r is a BN v4 instance - r.strip(); - } else { - // r is a BN v5 instance - r._strip(); - } - } - - return r; - }; - - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); - }; - - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); - }; - - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); - - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; - - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; - - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } - - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; - - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; - } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; - } else { - input.length -= 9; - } - }; - - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; - - // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 - var lo = 0; - for (var i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - lo += w * 0x3d1; - num.words[i] = lo & 0x3ffffff; - lo = w * 0x40 + ((lo / 0x4000000) | 0); - } - - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; - } - } - return num; - }; - - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); - - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); - - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); - } - inherits(P25519, MPrime); - - P25519.prototype.imulK = function imulK (num) { - // K = 0x13 - var carry = 0; - for (var i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 0x13 + carry; - var lo = hi & 0x3ffffff; - hi >>>= 26; - - num.words[i] = lo; - carry = hi; - } - if (carry !== 0) { - num.words[num.length++] = carry; - } - return num; - }; - - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; - - var prime; - if (name === 'k256') { - prime = new K256(); - } else if (name === 'p224') { - prime = new P224(); - } else if (name === 'p192') { - prime = new P192(); - } else if (name === 'p25519') { - prime = new P25519(); - } else { - throw new Error('Unknown prime ' + name); - } - primes[name] = prime; - - return prime; - }; - - // - // Base reduction engine - // - function Red (m) { - if (typeof m === 'string') { - var prime = BN._prime(m); - this.m = prime.p; - this.prime = prime; - } else { - assert(m.gtn(1), 'modulus must be greater than 1'); - this.m = m; - this.prime = null; - } - } - - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; - - Red.prototype._verify2 = function _verify2 (a, b) { - assert((a.negative | b.negative) === 0, 'red works only with positives'); - assert(a.red && a.red === b.red, - 'red works only with red numbers'); - }; - - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - - move(a, a.umod(this.m)._forceRed(this)); - return a; - }; - - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); - } - - return this.m.sub(a)._forceRed(this); - }; - - Red.prototype.add = function add (a, b) { - this._verify2(a, b); - - var res = a.add(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.iadd = function iadd (a, b) { - this._verify2(a, b); - - var res = a.iadd(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res; - }; - - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); - - var res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); - - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res; - }; - - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); - }; - - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; - - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); - }; - - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); - }; - - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); - }; - - Red.prototype.sqrt = function sqrt (a) { - if (a.isZero()) return a.clone(); - - var mod3 = this.m.andln(3); - assert(mod3 % 2 === 1); - - // Fast case - if (mod3 === 3) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - - // Tonelli-Shanks algorithm (Totally unoptimized and slow) - // - // Find Q and S, that Q * 2 ^ S = (P - 1) - var q = this.m.subn(1); - var s = 0; - while (!q.isZero() && q.andln(1) === 0) { - s++; - q.iushrn(1); - } - assert(!q.isZero()); - - var one = new BN(1).toRed(this); - var nOne = one.redNeg(); - - // Find quadratic non-residue - // NOTE: Max is such because of generalized Riemann hypothesis. - var lpow = this.m.subn(1).iushrn(1); - var z = this.m.bitLength(); - z = new BN(2 * z * z).toRed(this); - - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } - - var c = this.pow(z, q); - var r = this.pow(a, q.addn(1).iushrn(1)); - var t = this.pow(a, q); - var m = s; - while (t.cmp(one) !== 0) { - var tmp = t; - for (var i = 0; tmp.cmp(one) !== 0; i++) { - tmp = tmp.redSqr(); - } - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } - - return r; - }; - - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); - } else { - return this.imod(inv); - } - }; - - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - - var windowSize = 4; - var wnd = new Array(1 << windowSize); - wnd[0] = new BN(1).toRed(this); - wnd[1] = a; - for (var i = 2; i < wnd.length; i++) { - wnd[i] = this.mul(wnd[i - 1], a); - } - - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; - } - - for (i = num.length - 1; i >= 0; i--) { - var word = num.words[i]; - for (var j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if (res !== wnd[0]) { - res = this.sqr(res); - } - - if (bit === 0 && current === 0) { - currentLen = 0; - continue; - } - - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; - } - start = 26; - } - - return res; - }; - - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); - - return r === num ? r.clone() : r; - }; - - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; - }; - - // - // Montgomery method engine - // - - BN.mont = function mont (num) { - return new Mont(num); - }; - - function Mont (m) { - Red.call(this, m); - - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); - } - - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); - - this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); - this.minv = this.minv.umod(this.r); - this.minv = this.r.sub(this.minv); - } - inherits(Mont, Red); - - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; - - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; - }; - - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } - - var t = a.imul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - - var t = a.mul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.invm = function invm (a) { - // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }; - })(typeof module === 'undefined' || module, this); - - },{"buffer":222}],221:[function(require,module,exports){ - arguments[4][46][0].apply(exports,arguments) - },{"crypto":222,"dup":46}],222:[function(require,module,exports){ - arguments[4][199][0].apply(exports,arguments) - },{"dup":199}],223:[function(require,module,exports){ - // based on the aes implimentation in triple sec - // https://github.com/keybase/triplesec - // which is in turn based on the one from crypto-js - // https://code.google.com/p/crypto-js/ - - var Buffer = require('safe-buffer').Buffer - - function asUInt32Array (buf) { - if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) - - var len = (buf.length / 4) | 0 - var out = new Array(len) - - for (var i = 0; i < len; i++) { - out[i] = buf.readUInt32BE(i * 4) - } - - return out - } - - function scrubVec (v) { - for (var i = 0; i < v.length; v++) { - v[i] = 0 - } - } - - function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) { - var SUB_MIX0 = SUB_MIX[0] - var SUB_MIX1 = SUB_MIX[1] - var SUB_MIX2 = SUB_MIX[2] - var SUB_MIX3 = SUB_MIX[3] - - var s0 = M[0] ^ keySchedule[0] - var s1 = M[1] ^ keySchedule[1] - var s2 = M[2] ^ keySchedule[2] - var s3 = M[3] ^ keySchedule[3] - var t0, t1, t2, t3 - var ksRow = 4 - - for (var round = 1; round < nRounds; round++) { - t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++] - t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++] - t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++] - t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++] - s0 = t0 - s1 = t1 - s2 = t2 - s3 = t3 - } - - t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] - t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] - t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] - t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] - t0 = t0 >>> 0 - t1 = t1 >>> 0 - t2 = t2 >>> 0 - t3 = t3 >>> 0 - - return [t0, t1, t2, t3] - } - - // AES constants - var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] - var G = (function () { - // Compute double table - var d = new Array(256) - for (var j = 0; j < 256; j++) { - if (j < 128) { - d[j] = j << 1 - } else { - d[j] = (j << 1) ^ 0x11b - } - } - - var SBOX = [] - var INV_SBOX = [] - var SUB_MIX = [[], [], [], []] - var INV_SUB_MIX = [[], [], [], []] - - // Walk GF(2^8) - var x = 0 - var xi = 0 - for (var i = 0; i < 256; ++i) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 - SBOX[x] = sx - INV_SBOX[sx] = x - - // Compute multiplication - var x2 = d[x] - var x4 = d[x2] - var x8 = d[x4] - - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100) - SUB_MIX[0][x] = (t << 24) | (t >>> 8) - SUB_MIX[1][x] = (t << 16) | (t >>> 16) - SUB_MIX[2][x] = (t << 8) | (t >>> 24) - SUB_MIX[3][x] = t - - // Compute inv sub bytes, inv mix columns tables - t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) - INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) - INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) - INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) - INV_SUB_MIX[3][sx] = t - - if (x === 0) { - x = xi = 1 - } else { - x = x2 ^ d[d[d[x8 ^ x2]]] - xi ^= d[d[xi]] - } - } - - return { - SBOX: SBOX, - INV_SBOX: INV_SBOX, - SUB_MIX: SUB_MIX, - INV_SUB_MIX: INV_SUB_MIX - } - })() - - function AES (key) { - this._key = asUInt32Array(key) - this._reset() - } - - AES.blockSize = 4 * 4 - AES.keySize = 256 / 8 - AES.prototype.blockSize = AES.blockSize - AES.prototype.keySize = AES.keySize - AES.prototype._reset = function () { - var keyWords = this._key - var keySize = keyWords.length - var nRounds = keySize + 6 - var ksRows = (nRounds + 1) * 4 - - var keySchedule = [] - for (var k = 0; k < keySize; k++) { - keySchedule[k] = keyWords[k] - } - - for (k = keySize; k < ksRows; k++) { - var t = keySchedule[k - 1] - - if (k % keySize === 0) { - t = (t << 8) | (t >>> 24) - t = - (G.SBOX[t >>> 24] << 24) | - (G.SBOX[(t >>> 16) & 0xff] << 16) | - (G.SBOX[(t >>> 8) & 0xff] << 8) | - (G.SBOX[t & 0xff]) - - t ^= RCON[(k / keySize) | 0] << 24 - } else if (keySize > 6 && k % keySize === 4) { - t = - (G.SBOX[t >>> 24] << 24) | - (G.SBOX[(t >>> 16) & 0xff] << 16) | - (G.SBOX[(t >>> 8) & 0xff] << 8) | - (G.SBOX[t & 0xff]) - } - - keySchedule[k] = keySchedule[k - keySize] ^ t - } - - var invKeySchedule = [] - for (var ik = 0; ik < ksRows; ik++) { - var ksR = ksRows - ik - var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)] - - if (ik < 4 || ksR <= 4) { - invKeySchedule[ik] = tt - } else { - invKeySchedule[ik] = - G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ - G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^ - G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^ - G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]] - } - } - - this._nRounds = nRounds - this._keySchedule = keySchedule - this._invKeySchedule = invKeySchedule - } - - AES.prototype.encryptBlockRaw = function (M) { - M = asUInt32Array(M) - return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds) - } - - AES.prototype.encryptBlock = function (M) { - var out = this.encryptBlockRaw(M) - var buf = Buffer.allocUnsafe(16) - buf.writeUInt32BE(out[0], 0) - buf.writeUInt32BE(out[1], 4) - buf.writeUInt32BE(out[2], 8) - buf.writeUInt32BE(out[3], 12) - return buf - } - - AES.prototype.decryptBlock = function (M) { - M = asUInt32Array(M) - - // swap - var m1 = M[1] - M[1] = M[3] - M[3] = m1 - - var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds) - var buf = Buffer.allocUnsafe(16) - buf.writeUInt32BE(out[0], 0) - buf.writeUInt32BE(out[3], 4) - buf.writeUInt32BE(out[2], 8) - buf.writeUInt32BE(out[1], 12) - return buf - } - - AES.prototype.scrub = function () { - scrubVec(this._keySchedule) - scrubVec(this._invKeySchedule) - scrubVec(this._key) - } - - module.exports.AES = AES - - },{"safe-buffer":364}],224:[function(require,module,exports){ - var aes = require('./aes') - var Buffer = require('safe-buffer').Buffer - var Transform = require('cipher-base') - var inherits = require('inherits') - var GHASH = require('./ghash') - var xor = require('buffer-xor') - var incr32 = require('./incr32') - - function xorTest (a, b) { - var out = 0 - if (a.length !== b.length) out++ - - var len = Math.min(a.length, b.length) - for (var i = 0; i < len; ++i) { - out += (a[i] ^ b[i]) - } - - return out - } - - function calcIv (self, iv, ck) { - if (iv.length === 12) { - self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]) - return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]) - } - var ghash = new GHASH(ck) - var len = iv.length - var toPad = len % 16 - ghash.update(iv) - if (toPad) { - toPad = 16 - toPad - ghash.update(Buffer.alloc(toPad, 0)) - } - ghash.update(Buffer.alloc(8, 0)) - var ivBits = len * 8 - var tail = Buffer.alloc(8) - tail.writeUIntBE(ivBits, 0, 8) - ghash.update(tail) - self._finID = ghash.state - var out = Buffer.from(self._finID) - incr32(out) - return out - } - function StreamCipher (mode, key, iv, decrypt) { - Transform.call(this) - - var h = Buffer.alloc(4, 0) - - this._cipher = new aes.AES(key) - var ck = this._cipher.encryptBlock(h) - this._ghash = new GHASH(ck) - iv = calcIv(this, iv, ck) - - this._prev = Buffer.from(iv) - this._cache = Buffer.allocUnsafe(0) - this._secCache = Buffer.allocUnsafe(0) - this._decrypt = decrypt - this._alen = 0 - this._len = 0 - this._mode = mode - - this._authTag = null - this._called = false - } - - inherits(StreamCipher, Transform) - - StreamCipher.prototype._update = function (chunk) { - if (!this._called && this._alen) { - var rump = 16 - (this._alen % 16) - if (rump < 16) { - rump = Buffer.alloc(rump, 0) - this._ghash.update(rump) - } - } - - this._called = true - var out = this._mode.encrypt(this, chunk) - if (this._decrypt) { - this._ghash.update(chunk) - } else { - this._ghash.update(out) - } - this._len += chunk.length - return out - } - - StreamCipher.prototype._final = function () { - if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data') - - var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID)) - if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data') - - this._authTag = tag - this._cipher.scrub() - } - - StreamCipher.prototype.getAuthTag = function getAuthTag () { - if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state') - - return this._authTag - } - - StreamCipher.prototype.setAuthTag = function setAuthTag (tag) { - if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state') - - this._authTag = tag - } - - StreamCipher.prototype.setAAD = function setAAD (buf) { - if (this._called) throw new Error('Attempting to set AAD in unsupported state') - - this._ghash.update(buf) - this._alen += buf.length - } - - module.exports = StreamCipher - - },{"./aes":223,"./ghash":228,"./incr32":229,"buffer-xor":265,"cipher-base":267,"inherits":335,"safe-buffer":364}],225:[function(require,module,exports){ - var ciphers = require('./encrypter') - var deciphers = require('./decrypter') - var modes = require('./modes/list.json') - - function getCiphers () { - return Object.keys(modes) - } - - exports.createCipher = exports.Cipher = ciphers.createCipher - exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv - exports.createDecipher = exports.Decipher = deciphers.createDecipher - exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv - exports.listCiphers = exports.getCiphers = getCiphers - - },{"./decrypter":226,"./encrypter":227,"./modes/list.json":237}],226:[function(require,module,exports){ - var AuthCipher = require('./authCipher') - var Buffer = require('safe-buffer').Buffer - var MODES = require('./modes') - var StreamCipher = require('./streamCipher') - var Transform = require('cipher-base') - var aes = require('./aes') - var ebtk = require('evp_bytestokey') - var inherits = require('inherits') - - function Decipher (mode, key, iv) { - Transform.call(this) - - this._cache = new Splitter() - this._last = void 0 - this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) - this._mode = mode - this._autopadding = true - } - - inherits(Decipher, Transform) - - Decipher.prototype._update = function (data) { - this._cache.add(data) - var chunk - var thing - var out = [] - while ((chunk = this._cache.get(this._autopadding))) { - thing = this._mode.decrypt(this, chunk) - out.push(thing) - } - return Buffer.concat(out) - } - - Decipher.prototype._final = function () { - var chunk = this._cache.flush() - if (this._autopadding) { - return unpad(this._mode.decrypt(this, chunk)) - } else if (chunk) { - throw new Error('data not multiple of block length') - } - } - - Decipher.prototype.setAutoPadding = function (setTo) { - this._autopadding = !!setTo - return this - } - - function Splitter () { - this.cache = Buffer.allocUnsafe(0) - } - - Splitter.prototype.add = function (data) { - this.cache = Buffer.concat([this.cache, data]) - } - - Splitter.prototype.get = function (autoPadding) { - var out - if (autoPadding) { - if (this.cache.length > 16) { - out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - } else { - if (this.cache.length >= 16) { - out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - } - - return null - } - - Splitter.prototype.flush = function () { - if (this.cache.length) return this.cache - } - - function unpad (last) { - var padded = last[15] - if (padded < 1 || padded > 16) { - throw new Error('unable to decrypt data') - } - var i = -1 - while (++i < padded) { - if (last[(i + (16 - padded))] !== padded) { - throw new Error('unable to decrypt data') - } - } - if (padded === 16) return - - return last.slice(0, 16 - padded) - } - - function createDecipheriv (suite, password, iv) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - if (typeof iv === 'string') iv = Buffer.from(iv) - if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - - if (typeof password === 'string') password = Buffer.from(password) - if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) - - if (config.type === 'stream') { - return new StreamCipher(config.module, password, iv, true) - } else if (config.type === 'auth') { - return new AuthCipher(config.module, password, iv, true) - } - - return new Decipher(config.module, password, iv) - } - - function createDecipher (suite, password) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - var keys = ebtk(password, false, config.key, config.iv) - return createDecipheriv(suite, keys.key, keys.iv) - } - - exports.createDecipher = createDecipher - exports.createDecipheriv = createDecipheriv - - },{"./aes":223,"./authCipher":224,"./modes":236,"./streamCipher":239,"cipher-base":267,"evp_bytestokey":304,"inherits":335,"safe-buffer":364}],227:[function(require,module,exports){ - var MODES = require('./modes') - var AuthCipher = require('./authCipher') - var Buffer = require('safe-buffer').Buffer - var StreamCipher = require('./streamCipher') - var Transform = require('cipher-base') - var aes = require('./aes') - var ebtk = require('evp_bytestokey') - var inherits = require('inherits') - - function Cipher (mode, key, iv) { - Transform.call(this) - - this._cache = new Splitter() - this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) - this._mode = mode - this._autopadding = true - } - - inherits(Cipher, Transform) - - Cipher.prototype._update = function (data) { - this._cache.add(data) - var chunk - var thing - var out = [] - - while ((chunk = this._cache.get())) { - thing = this._mode.encrypt(this, chunk) - out.push(thing) - } - - return Buffer.concat(out) - } - - var PADDING = Buffer.alloc(16, 0x10) - - Cipher.prototype._final = function () { - var chunk = this._cache.flush() - if (this._autopadding) { - chunk = this._mode.encrypt(this, chunk) - this._cipher.scrub() - return chunk - } - - if (!chunk.equals(PADDING)) { - this._cipher.scrub() - throw new Error('data not multiple of block length') - } - } - - Cipher.prototype.setAutoPadding = function (setTo) { - this._autopadding = !!setTo - return this - } - - function Splitter () { - this.cache = Buffer.allocUnsafe(0) - } - - Splitter.prototype.add = function (data) { - this.cache = Buffer.concat([this.cache, data]) - } - - Splitter.prototype.get = function () { - if (this.cache.length > 15) { - var out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - return null - } - - Splitter.prototype.flush = function () { - var len = 16 - this.cache.length - var padBuff = Buffer.allocUnsafe(len) - - var i = -1 - while (++i < len) { - padBuff.writeUInt8(len, i) - } - - return Buffer.concat([this.cache, padBuff]) - } - - function createCipheriv (suite, password, iv) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - if (typeof password === 'string') password = Buffer.from(password) - if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) - - if (typeof iv === 'string') iv = Buffer.from(iv) - if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - - if (config.type === 'stream') { - return new StreamCipher(config.module, password, iv) - } else if (config.type === 'auth') { - return new AuthCipher(config.module, password, iv) - } - - return new Cipher(config.module, password, iv) - } - - function createCipher (suite, password) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - var keys = ebtk(password, false, config.key, config.iv) - return createCipheriv(suite, keys.key, keys.iv) - } - - exports.createCipheriv = createCipheriv - exports.createCipher = createCipher - - },{"./aes":223,"./authCipher":224,"./modes":236,"./streamCipher":239,"cipher-base":267,"evp_bytestokey":304,"inherits":335,"safe-buffer":364}],228:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - var ZEROES = Buffer.alloc(16, 0) - - function toArray (buf) { - return [ - buf.readUInt32BE(0), - buf.readUInt32BE(4), - buf.readUInt32BE(8), - buf.readUInt32BE(12) - ] - } - - function fromArray (out) { - var buf = Buffer.allocUnsafe(16) - buf.writeUInt32BE(out[0] >>> 0, 0) - buf.writeUInt32BE(out[1] >>> 0, 4) - buf.writeUInt32BE(out[2] >>> 0, 8) - buf.writeUInt32BE(out[3] >>> 0, 12) - return buf - } - - function GHASH (key) { - this.h = key - this.state = Buffer.alloc(16, 0) - this.cache = Buffer.allocUnsafe(0) - } - - // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html - // by Juho Vähä-Herttua - GHASH.prototype.ghash = function (block) { - var i = -1 - while (++i < block.length) { - this.state[i] ^= block[i] - } - this._multiply() - } - - GHASH.prototype._multiply = function () { - var Vi = toArray(this.h) - var Zi = [0, 0, 0, 0] - var j, xi, lsbVi - var i = -1 - while (++i < 128) { - xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0 - if (xi) { - // Z_i+1 = Z_i ^ V_i - Zi[0] ^= Vi[0] - Zi[1] ^= Vi[1] - Zi[2] ^= Vi[2] - Zi[3] ^= Vi[3] - } - - // Store the value of LSB(V_i) - lsbVi = (Vi[3] & 1) !== 0 - - // V_i+1 = V_i >> 1 - for (j = 3; j > 0; j--) { - Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31) - } - Vi[0] = Vi[0] >>> 1 - - // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R - if (lsbVi) { - Vi[0] = Vi[0] ^ (0xe1 << 24) - } - } - this.state = fromArray(Zi) - } - - GHASH.prototype.update = function (buf) { - this.cache = Buffer.concat([this.cache, buf]) - var chunk - while (this.cache.length >= 16) { - chunk = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - this.ghash(chunk) - } - } - - GHASH.prototype.final = function (abl, bl) { - if (this.cache.length) { - this.ghash(Buffer.concat([this.cache, ZEROES], 16)) - } - - this.ghash(fromArray([0, abl, 0, bl])) - return this.state - } - - module.exports = GHASH - - },{"safe-buffer":364}],229:[function(require,module,exports){ - function incr32 (iv) { - var len = iv.length - var item - while (len--) { - item = iv.readUInt8(len) - if (item === 255) { - iv.writeUInt8(0, len) - } else { - item++ - iv.writeUInt8(item, len) - break - } - } - } - module.exports = incr32 - - },{}],230:[function(require,module,exports){ - var xor = require('buffer-xor') - - exports.encrypt = function (self, block) { - var data = xor(block, self._prev) - - self._prev = self._cipher.encryptBlock(data) - return self._prev - } - - exports.decrypt = function (self, block) { - var pad = self._prev - - self._prev = block - var out = self._cipher.decryptBlock(block) - - return xor(out, pad) - } - - },{"buffer-xor":265}],231:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - var xor = require('buffer-xor') - - function encryptStart (self, data, decrypt) { - var len = data.length - var out = xor(data, self._cache) - self._cache = self._cache.slice(len) - self._prev = Buffer.concat([self._prev, decrypt ? data : out]) - return out - } - - exports.encrypt = function (self, data, decrypt) { - var out = Buffer.allocUnsafe(0) - var len - - while (data.length) { - if (self._cache.length === 0) { - self._cache = self._cipher.encryptBlock(self._prev) - self._prev = Buffer.allocUnsafe(0) - } - - if (self._cache.length <= data.length) { - len = self._cache.length - out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]) - data = data.slice(len) - } else { - out = Buffer.concat([out, encryptStart(self, data, decrypt)]) - break - } - } - - return out - } - - },{"buffer-xor":265,"safe-buffer":364}],232:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - - function encryptByte (self, byteParam, decrypt) { - var pad - var i = -1 - var len = 8 - var out = 0 - var bit, value - while (++i < len) { - pad = self._cipher.encryptBlock(self._prev) - bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0 - value = pad[0] ^ bit - out += ((value & 0x80) >> (i % 8)) - self._prev = shiftIn(self._prev, decrypt ? bit : value) - } - return out - } - - function shiftIn (buffer, value) { - var len = buffer.length - var i = -1 - var out = Buffer.allocUnsafe(buffer.length) - buffer = Buffer.concat([buffer, Buffer.from([value])]) - - while (++i < len) { - out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) - } - - return out - } - - exports.encrypt = function (self, chunk, decrypt) { - var len = chunk.length - var out = Buffer.allocUnsafe(len) - var i = -1 - - while (++i < len) { - out[i] = encryptByte(self, chunk[i], decrypt) - } - - return out - } - - },{"safe-buffer":364}],233:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - - function encryptByte (self, byteParam, decrypt) { - var pad = self._cipher.encryptBlock(self._prev) - var out = pad[0] ^ byteParam - - self._prev = Buffer.concat([ - self._prev.slice(1), - Buffer.from([decrypt ? byteParam : out]) - ]) - - return out - } - - exports.encrypt = function (self, chunk, decrypt) { - var len = chunk.length - var out = Buffer.allocUnsafe(len) - var i = -1 - - while (++i < len) { - out[i] = encryptByte(self, chunk[i], decrypt) - } - - return out - } - - },{"safe-buffer":364}],234:[function(require,module,exports){ - var xor = require('buffer-xor') - var Buffer = require('safe-buffer').Buffer - var incr32 = require('../incr32') - - function getBlock (self) { - var out = self._cipher.encryptBlockRaw(self._prev) - incr32(self._prev) - return out - } - - var blockSize = 16 - exports.encrypt = function (self, chunk) { - var chunkNum = Math.ceil(chunk.length / blockSize) - var start = self._cache.length - self._cache = Buffer.concat([ - self._cache, - Buffer.allocUnsafe(chunkNum * blockSize) - ]) - for (var i = 0; i < chunkNum; i++) { - var out = getBlock(self) - var offset = start + i * blockSize - self._cache.writeUInt32BE(out[0], offset + 0) - self._cache.writeUInt32BE(out[1], offset + 4) - self._cache.writeUInt32BE(out[2], offset + 8) - self._cache.writeUInt32BE(out[3], offset + 12) - } - var pad = self._cache.slice(0, chunk.length) - self._cache = self._cache.slice(chunk.length) - return xor(chunk, pad) - } - - },{"../incr32":229,"buffer-xor":265,"safe-buffer":364}],235:[function(require,module,exports){ - exports.encrypt = function (self, block) { - return self._cipher.encryptBlock(block) - } - - exports.decrypt = function (self, block) { - return self._cipher.decryptBlock(block) - } - - },{}],236:[function(require,module,exports){ - var modeModules = { - ECB: require('./ecb'), - CBC: require('./cbc'), - CFB: require('./cfb'), - CFB8: require('./cfb8'), - CFB1: require('./cfb1'), - OFB: require('./ofb'), - CTR: require('./ctr'), - GCM: require('./ctr') - } - - var modes = require('./list.json') - - for (var key in modes) { - modes[key].module = modeModules[modes[key].mode] - } - - module.exports = modes - - },{"./cbc":230,"./cfb":231,"./cfb1":232,"./cfb8":233,"./ctr":234,"./ecb":235,"./list.json":237,"./ofb":238}],237:[function(require,module,exports){ - module.exports={ - "aes-128-ecb": { - "cipher": "AES", - "key": 128, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-192-ecb": { - "cipher": "AES", - "key": 192, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-256-ecb": { - "cipher": "AES", - "key": 256, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-128-cbc": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-192-cbc": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-256-cbc": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes128": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes192": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes256": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-128-cfb": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-192-cfb": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-256-cfb": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-128-cfb8": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-192-cfb8": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-256-cfb8": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-128-cfb1": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-192-cfb1": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-256-cfb1": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-128-ofb": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-192-ofb": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-256-ofb": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-128-ctr": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-192-ctr": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-256-ctr": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-128-gcm": { - "cipher": "AES", - "key": 128, - "iv": 12, - "mode": "GCM", - "type": "auth" - }, - "aes-192-gcm": { - "cipher": "AES", - "key": 192, - "iv": 12, - "mode": "GCM", - "type": "auth" - }, - "aes-256-gcm": { - "cipher": "AES", - "key": 256, - "iv": 12, - "mode": "GCM", - "type": "auth" - } - } - - },{}],238:[function(require,module,exports){ - (function (Buffer){(function (){ - var xor = require('buffer-xor') - - function getBlock (self) { - self._prev = self._cipher.encryptBlock(self._prev) - return self._prev - } - - exports.encrypt = function (self, chunk) { - while (self._cache.length < chunk.length) { - self._cache = Buffer.concat([self._cache, getBlock(self)]) - } - - var pad = self._cache.slice(0, chunk.length) - self._cache = self._cache.slice(chunk.length) - return xor(chunk, pad) - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266,"buffer-xor":265}],239:[function(require,module,exports){ - var aes = require('./aes') - var Buffer = require('safe-buffer').Buffer - var Transform = require('cipher-base') - var inherits = require('inherits') - - function StreamCipher (mode, key, iv, decrypt) { - Transform.call(this) - - this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) - this._cache = Buffer.allocUnsafe(0) - this._secCache = Buffer.allocUnsafe(0) - this._decrypt = decrypt - this._mode = mode - } - - inherits(StreamCipher, Transform) - - StreamCipher.prototype._update = function (chunk) { - return this._mode.encrypt(this, chunk, this._decrypt) - } - - StreamCipher.prototype._final = function () { - this._cipher.scrub() - } - - module.exports = StreamCipher - - },{"./aes":223,"cipher-base":267,"inherits":335,"safe-buffer":364}],240:[function(require,module,exports){ - var DES = require('browserify-des') - var aes = require('browserify-aes/browser') - var aesModes = require('browserify-aes/modes') - var desModes = require('browserify-des/modes') - var ebtk = require('evp_bytestokey') - - function createCipher (suite, password) { - suite = suite.toLowerCase() - - var keyLen, ivLen - if (aesModes[suite]) { - keyLen = aesModes[suite].key - ivLen = aesModes[suite].iv - } else if (desModes[suite]) { - keyLen = desModes[suite].key * 8 - ivLen = desModes[suite].iv - } else { - throw new TypeError('invalid suite type') - } - - var keys = ebtk(password, false, keyLen, ivLen) - return createCipheriv(suite, keys.key, keys.iv) - } - - function createDecipher (suite, password) { - suite = suite.toLowerCase() - - var keyLen, ivLen - if (aesModes[suite]) { - keyLen = aesModes[suite].key - ivLen = aesModes[suite].iv - } else if (desModes[suite]) { - keyLen = desModes[suite].key * 8 - ivLen = desModes[suite].iv - } else { - throw new TypeError('invalid suite type') - } - - var keys = ebtk(password, false, keyLen, ivLen) - return createDecipheriv(suite, keys.key, keys.iv) - } - - function createCipheriv (suite, key, iv) { - suite = suite.toLowerCase() - if (aesModes[suite]) return aes.createCipheriv(suite, key, iv) - if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite }) - - throw new TypeError('invalid suite type') - } - - function createDecipheriv (suite, key, iv) { - suite = suite.toLowerCase() - if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv) - if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true }) - - throw new TypeError('invalid suite type') - } - - function getCiphers () { - return Object.keys(desModes).concat(aes.getCiphers()) - } - - exports.createCipher = exports.Cipher = createCipher - exports.createCipheriv = exports.Cipheriv = createCipheriv - exports.createDecipher = exports.Decipher = createDecipher - exports.createDecipheriv = exports.Decipheriv = createDecipheriv - exports.listCiphers = exports.getCiphers = getCiphers - - },{"browserify-aes/browser":225,"browserify-aes/modes":236,"browserify-des":241,"browserify-des/modes":242,"evp_bytestokey":304}],241:[function(require,module,exports){ - var CipherBase = require('cipher-base') - var des = require('des.js') - var inherits = require('inherits') - var Buffer = require('safe-buffer').Buffer - - var modes = { - 'des-ede3-cbc': des.CBC.instantiate(des.EDE), - 'des-ede3': des.EDE, - 'des-ede-cbc': des.CBC.instantiate(des.EDE), - 'des-ede': des.EDE, - 'des-cbc': des.CBC.instantiate(des.DES), - 'des-ecb': des.DES - } - modes.des = modes['des-cbc'] - modes.des3 = modes['des-ede3-cbc'] - module.exports = DES - inherits(DES, CipherBase) - function DES (opts) { - CipherBase.call(this) - var modeName = opts.mode.toLowerCase() - var mode = modes[modeName] - var type - if (opts.decrypt) { - type = 'decrypt' - } else { - type = 'encrypt' - } - var key = opts.key - if (!Buffer.isBuffer(key)) { - key = Buffer.from(key) - } - if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { - key = Buffer.concat([key, key.slice(0, 8)]) - } - var iv = opts.iv - if (!Buffer.isBuffer(iv)) { - iv = Buffer.from(iv) - } - this._des = mode.create({ - key: key, - iv: iv, - type: type - }) - } - DES.prototype._update = function (data) { - return Buffer.from(this._des.update(data)) - } - DES.prototype._final = function () { - return Buffer.from(this._des.final()) - } - - },{"cipher-base":267,"des.js":275,"inherits":335,"safe-buffer":364}],242:[function(require,module,exports){ - exports['des-ecb'] = { - key: 8, - iv: 0 - } - exports['des-cbc'] = exports.des = { - key: 8, - iv: 8 - } - exports['des-ede3-cbc'] = exports.des3 = { - key: 24, - iv: 8 - } - exports['des-ede3'] = { - key: 24, - iv: 0 - } - exports['des-ede-cbc'] = { - key: 16, - iv: 8 - } - exports['des-ede'] = { - key: 16, - iv: 0 - } - - },{}],243:[function(require,module,exports){ - (function (Buffer){(function (){ - var BN = require('bn.js') - var randomBytes = require('randombytes') - - function blind (priv) { - var r = getr(priv) - var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() - return { blinder: blinder, unblinder: r.invm(priv.modulus) } - } - - function getr (priv) { - var len = priv.modulus.byteLength() - var r - do { - r = new BN(randomBytes(len)) - } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) - return r - } - - function crt (msg, priv) { - var blinds = blind(priv) - var len = priv.modulus.byteLength() - var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) - var c1 = blinded.toRed(BN.mont(priv.prime1)) - var c2 = blinded.toRed(BN.mont(priv.prime2)) - var qinv = priv.coefficient - var p = priv.prime1 - var q = priv.prime2 - var m1 = c1.redPow(priv.exponent1).fromRed() - var m2 = c2.redPow(priv.exponent2).fromRed() - var h = m1.isub(m2).imul(qinv).umod(p).imul(q) - return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) - } - crt.getr = getr - - module.exports = crt - - }).call(this)}).call(this,require("buffer").Buffer) - },{"bn.js":220,"buffer":266,"randombytes":361}],244:[function(require,module,exports){ - module.exports = require('./browser/algorithms.json') - - },{"./browser/algorithms.json":245}],245:[function(require,module,exports){ - module.exports={ - "sha224WithRSAEncryption": { - "sign": "rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "RSA-SHA224": { - "sign": "ecdsa/rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "sha256WithRSAEncryption": { - "sign": "rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "RSA-SHA256": { - "sign": "ecdsa/rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "sha384WithRSAEncryption": { - "sign": "rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "RSA-SHA384": { - "sign": "ecdsa/rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "sha512WithRSAEncryption": { - "sign": "rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA512": { - "sign": "ecdsa/rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA1": { - "sign": "rsa", - "hash": "sha1", - "id": "3021300906052b0e03021a05000414" - }, - "ecdsa-with-SHA1": { - "sign": "ecdsa", - "hash": "sha1", - "id": "" - }, - "sha256": { - "sign": "ecdsa", - "hash": "sha256", - "id": "" - }, - "sha224": { - "sign": "ecdsa", - "hash": "sha224", - "id": "" - }, - "sha384": { - "sign": "ecdsa", - "hash": "sha384", - "id": "" - }, - "sha512": { - "sign": "ecdsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-SHA1": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-WITH-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-WITH-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-WITH-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-WITH-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-RIPEMD160": { - "sign": "dsa", - "hash": "rmd160", - "id": "" - }, - "ripemd160WithRSA": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "RSA-RIPEMD160": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "md5WithRSAEncryption": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" - }, - "RSA-MD5": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" - } - } - - },{}],246:[function(require,module,exports){ - module.exports={ - "1.3.132.0.10": "secp256k1", - "1.3.132.0.33": "p224", - "1.2.840.10045.3.1.1": "p192", - "1.2.840.10045.3.1.7": "p256", - "1.3.132.0.34": "p384", - "1.3.132.0.35": "p521" - } - - },{}],247:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - var createHash = require('create-hash') - var stream = require('readable-stream') - var inherits = require('inherits') - var sign = require('./sign') - var verify = require('./verify') - - var algorithms = require('./algorithms.json') - Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] - }) - - function Sign (algorithm) { - stream.Writable.call(this) - - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') - - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign - } - inherits(Sign, stream.Writable) - - Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() - } - - Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) - - this._hash.update(data) - return this - } - - Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) - - return enc ? sig.toString(enc) : sig - } - - function Verify (algorithm) { - stream.Writable.call(this) - - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') - - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign - } - inherits(Verify, stream.Writable) - - Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() - } - - Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) - - this._hash.update(data) - return this - } - - Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = Buffer.from(sig, enc) - - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) - } - - function createSign (algorithm) { - return new Sign(algorithm) - } - - function createVerify (algorithm) { - return new Verify(algorithm) - } - - module.exports = { - Sign: createSign, - Verify: createVerify, - createSign: createSign, - createVerify: createVerify - } - - },{"./algorithms.json":245,"./sign":248,"./verify":249,"create-hash":270,"inherits":335,"readable-stream":264,"safe-buffer":364}],248:[function(require,module,exports){ - // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js - var Buffer = require('safe-buffer').Buffer - var createHmac = require('create-hmac') - var crt = require('browserify-rsa') - var EC = require('elliptic').ec - var BN = require('bn.js') - var parseKeys = require('parse-asn1') - var curves = require('./curves.json') - - function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) - if (priv.curve) { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) - } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [0, 1] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) - - var out = crt(pad, priv) - return out - } - - function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) - - return Buffer.from(out.toDER()) - } - - function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) - while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) - if (s.cmpn(0) === 0) { - s = false - r = new BN(0) - } - } - return toDER(r, s) - } - - function toDER (r, s) { - r = r.toArray() - s = s.toArray() - - // Pad values - if (r[0] & 0x80) r = [0].concat(r) - if (s[0] & 0x80) s = [0].concat(s) - - var total = r.length + s.length + 4 - var res = [0x30, total, 0x02, r.length] - res = res.concat(r, [0x02, s.length], s) - return Buffer.from(res) - } - - function getKey (x, q, hash, algo) { - x = Buffer.from(x.toArray()) - if (x.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - x.length) - x = Buffer.concat([zeros, x]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = Buffer.alloc(hlen) - v.fill(1) - var k = Buffer.alloc(hlen) - k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } - } - - function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits - } - - function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = Buffer.from(bits.toArray()) - if (out.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - out.length) - out = Buffer.concat([zeros, out]) - } - return out - } - - function makeKey (q, kv, algo) { - var t - var k - - do { - t = Buffer.alloc(0) - - while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([t, kv.v]) - } - - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) - - return k - } - - function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) - } - - module.exports = sign - module.exports.getKey = getKey - module.exports.makeKey = makeKey - - },{"./curves.json":246,"bn.js":220,"browserify-rsa":243,"create-hmac":272,"elliptic":286,"parse-asn1":346,"safe-buffer":364}],249:[function(require,module,exports){ - // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js - var Buffer = require('safe-buffer').Buffer - var BN = require('bn.js') - var EC = require('elliptic').ec - var parseKeys = require('parse-asn1') - var curves = require('./curves.json') - - function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) - if (pub.type === 'ec') { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) - } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [1] - var padNum = 0 - while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - pad = Buffer.from(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) - - sig = sig.redPow(new BN(pub.publicExponent)) - sig = Buffer.from(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 - - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 - } - - function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) - - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data - - return curve.verify(hash, sig, pubkey) - } - - function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) - var v = g.toRed(montp) - .redPow(new BN(hash).mul(w).mod(q)) - .fromRed() - .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) - .mod(p) - .mod(q) - return v.cmp(r) === 0 - } - - function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') - } - - module.exports = verify - - },{"./curves.json":246,"bn.js":220,"elliptic":286,"parse-asn1":346,"safe-buffer":364}],250:[function(require,module,exports){ - arguments[4][106][0].apply(exports,arguments) - },{"dup":106}],251:[function(require,module,exports){ - arguments[4][107][0].apply(exports,arguments) - },{"./_stream_readable":253,"./_stream_writable":255,"_process":353,"dup":107,"inherits":335}],252:[function(require,module,exports){ - arguments[4][108][0].apply(exports,arguments) - },{"./_stream_transform":254,"dup":108,"inherits":335}],253:[function(require,module,exports){ - arguments[4][109][0].apply(exports,arguments) - },{"../errors":250,"./_stream_duplex":251,"./internal/streams/async_iterator":256,"./internal/streams/buffer_list":257,"./internal/streams/destroy":258,"./internal/streams/from":260,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],254:[function(require,module,exports){ - arguments[4][110][0].apply(exports,arguments) - },{"../errors":250,"./_stream_duplex":251,"dup":110,"inherits":335}],255:[function(require,module,exports){ - arguments[4][111][0].apply(exports,arguments) - },{"../errors":250,"./_stream_duplex":251,"./internal/streams/destroy":258,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],256:[function(require,module,exports){ - arguments[4][112][0].apply(exports,arguments) - },{"./end-of-stream":259,"_process":353,"dup":112}],257:[function(require,module,exports){ - arguments[4][113][0].apply(exports,arguments) - },{"buffer":266,"dup":113,"util":222}],258:[function(require,module,exports){ - arguments[4][114][0].apply(exports,arguments) - },{"_process":353,"dup":114}],259:[function(require,module,exports){ - arguments[4][115][0].apply(exports,arguments) - },{"../../../errors":250,"dup":115}],260:[function(require,module,exports){ - arguments[4][116][0].apply(exports,arguments) - },{"dup":116}],261:[function(require,module,exports){ - arguments[4][117][0].apply(exports,arguments) - },{"../../../errors":250,"./end-of-stream":259,"dup":117}],262:[function(require,module,exports){ - arguments[4][118][0].apply(exports,arguments) - },{"../../../errors":250,"dup":118}],263:[function(require,module,exports){ - arguments[4][119][0].apply(exports,arguments) - },{"dup":119,"events":303}],264:[function(require,module,exports){ - arguments[4][120][0].apply(exports,arguments) - },{"./lib/_stream_duplex.js":251,"./lib/_stream_passthrough.js":252,"./lib/_stream_readable.js":253,"./lib/_stream_transform.js":254,"./lib/_stream_writable.js":255,"./lib/internal/streams/end-of-stream.js":259,"./lib/internal/streams/pipeline.js":261,"dup":120}],265:[function(require,module,exports){ - (function (Buffer){(function (){ - module.exports = function xor (a, b) { - var length = Math.min(a.length, b.length) - var buffer = new Buffer(length) - - for (var i = 0; i < length; ++i) { - buffer[i] = a[i] ^ b[i] - } - - return buffer - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"buffer":266}],266:[function(require,module,exports){ - (function (Buffer){(function (){ - /*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - /* eslint-disable no-proto */ - - 'use strict' - - var base64 = require('base64-js') - var ieee754 = require('ieee754') - - exports.Buffer = Buffer - exports.SlowBuffer = SlowBuffer - exports.INSPECT_MAX_BYTES = 50 - - var K_MAX_LENGTH = 0x7fffffff - exports.kMaxLength = K_MAX_LENGTH - - /** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ - Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - - if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) - } - - function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } - return arr.foo() === 42 - } catch (e) { - return false - } - } - - Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } - }) - - Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } - }) - - function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf - } - - /** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - - function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) - } - - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - if (typeof Symbol !== 'undefined' && Symbol.species != null && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) - } - - Buffer.poolSize = 8192 // not used by this implementation - - function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - /** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ - Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) - } - - // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: - // https://github.com/feross/buffer/pull/148 - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - - function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } - } - - function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) - } - - /** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ - Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) - } - - function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) - } - - /** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ - Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) - } - /** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ - Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) - } - - function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf - } - - function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf - } - - function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf - } - - function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } - } - - function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 - } - - function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) - } - - Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false - } - - Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 - } - - Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } - } - - Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (isInstance(buf, Uint8Array)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer - } - - function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } - } - Buffer.byteLength = byteLength - - function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } - } - - // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) - // to detect a Buffer instance. It's not possible to use `instanceof Buffer` - // reliably in a browserify context because there could be multiple different - // copies of the 'buffer' package in use. This method works even for Buffer - // instances that were created from another copy of the `buffer` package. - // See: https://github.com/feross/buffer/issues/154 - Buffer.prototype._isBuffer = true - - function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i - } - - Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this - } - - Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this - } - - Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this - } - - Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) - } - - Buffer.prototype.toLocaleString = Buffer.prototype.toString - - Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 - } - - Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' - } - - Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 - } - - // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, - // OR the last index of `val` in `buffer` at offset <= `byteOffset`. - // - // Arguments: - // - buffer - a Buffer to search - // - val - a string, Buffer, or number - // - byteOffset - an index into `buffer`; will be clamped to an int32 - // - encoding - an optional encoding, relevant is val is a string - // - dir - true for indexOf, false for lastIndexOf - function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') - } - - function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 - } - - Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 - } - - Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) - } - - Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) - } - - function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i - } - - function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - } - - function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) - } - - function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) - } - - function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) - } - - function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) - } - - Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } - } - - Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } - } - - function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } - } - - function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) - } - - // Based on http://stackoverflow.com/a/22747272/680742, the browser with - // the lowest limit is Chrome, with 0x10000 args. - // We go 1 magnitude less, for safety - var MAX_ARGUMENTS_LENGTH = 0x1000 - - function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res - } - - function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret - } - - function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret - } - - function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out - } - - function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res - } - - Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf - } - - /* - * Need to make sure that buffer isn't trying to write out of bounds. - */ - function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') - } - - Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val - } - - Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val - } - - Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] - } - - Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) - } - - Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] - } - - Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) - } - - Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) - } - - Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) - } - - Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) - } - - Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) - } - - Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) - } - - Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) - } - - Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) - } - - Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) - } - - function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') - } - - Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 - } - - Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 - } - - Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 - } - - Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 - } - - Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 - } - - Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 - } - - Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 - } - - Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 - } - - Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 - } - - Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 - } - - function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') - } - - function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 - } - - Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) - } - - function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 - } - - Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) - } - - // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) - Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len - } - - // Usage: - // buffer.fill(number[, offset[, end]]) - // buffer.fill(buffer[, offset[, end]]) - // buffer.fill(string[, offset[, end]][, encoding]) - Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this - } - - // HELPER FUNCTIONS - // ================ - - var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - - function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str - } - - function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) - } - - function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes - } - - function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray - } - - function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray - } - - function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) - } - - function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i - } - - // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass - // the `instanceof` check but they should be treated as of that type. - // See: https://github.com/feross/buffer/issues/166 - function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) - } - function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"base64-js":219,"buffer":266,"ieee754":334}],267:[function(require,module,exports){ - arguments[4][50][0].apply(exports,arguments) - },{"dup":50,"inherits":335,"safe-buffer":364,"stream":374,"string_decoder":389}],268:[function(require,module,exports){ - (function (Buffer){(function (){ - var elliptic = require('elliptic') - var BN = require('bn.js') - - module.exports = function createECDH (curve) { - return new ECDH(curve) - } - - var aliases = { - secp256k1: { - name: 'secp256k1', - byteLength: 32 - }, - secp224r1: { - name: 'p224', - byteLength: 28 - }, - prime256v1: { - name: 'p256', - byteLength: 32 - }, - prime192v1: { - name: 'p192', - byteLength: 24 - }, - ed25519: { - name: 'ed25519', - byteLength: 32 - }, - secp384r1: { - name: 'p384', - byteLength: 48 - }, - secp521r1: { - name: 'p521', - byteLength: 66 - } - } - - aliases.p224 = aliases.secp224r1 - aliases.p256 = aliases.secp256r1 = aliases.prime256v1 - aliases.p192 = aliases.secp192r1 = aliases.prime192v1 - aliases.p384 = aliases.secp384r1 - aliases.p521 = aliases.secp521r1 - - function ECDH (curve) { - this.curveType = aliases[curve] - if (!this.curveType) { - this.curveType = { - name: curve - } - } - this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap - this.keys = void 0 - } - - ECDH.prototype.generateKeys = function (enc, format) { - this.keys = this.curve.genKeyPair() - return this.getPublicKey(enc, format) - } - - ECDH.prototype.computeSecret = function (other, inenc, enc) { - inenc = inenc || 'utf8' - if (!Buffer.isBuffer(other)) { - other = new Buffer(other, inenc) - } - var otherPub = this.curve.keyFromPublic(other).getPublic() - var out = otherPub.mul(this.keys.getPrivate()).getX() - return formatReturnValue(out, enc, this.curveType.byteLength) - } - - ECDH.prototype.getPublicKey = function (enc, format) { - var key = this.keys.getPublic(format === 'compressed', true) - if (format === 'hybrid') { - if (key[key.length - 1] % 2) { - key[0] = 7 - } else { - key[0] = 6 - } - } - return formatReturnValue(key, enc) - } - - ECDH.prototype.getPrivateKey = function (enc) { - return formatReturnValue(this.keys.getPrivate(), enc) - } - - ECDH.prototype.setPublicKey = function (pub, enc) { - enc = enc || 'utf8' - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc) - } - this.keys._importPublic(pub) - return this - } - - ECDH.prototype.setPrivateKey = function (priv, enc) { - enc = enc || 'utf8' - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc) - } - - var _priv = new BN(priv) - _priv = _priv.toString(16) - this.keys = this.curve.genKeyPair() - this.keys._importPrivate(_priv) - return this - } - - function formatReturnValue (bn, enc, len) { - if (!Array.isArray(bn)) { - bn = bn.toArray() - } - var buf = new Buffer(bn) - if (len && buf.length < len) { - var zeros = new Buffer(len - buf.length) - zeros.fill(0) - buf = Buffer.concat([zeros, buf]) - } - if (!enc) { - return buf - } else { - return buf.toString(enc) - } - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"bn.js":269,"buffer":266,"elliptic":286}],269:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],270:[function(require,module,exports){ - arguments[4][51][0].apply(exports,arguments) - },{"cipher-base":267,"dup":51,"inherits":335,"md5.js":336,"ripemd160":363,"sha.js":367}],271:[function(require,module,exports){ - arguments[4][52][0].apply(exports,arguments) - },{"dup":52,"md5.js":336}],272:[function(require,module,exports){ - arguments[4][53][0].apply(exports,arguments) - },{"./legacy":273,"cipher-base":267,"create-hash/md5":271,"dup":53,"inherits":335,"ripemd160":363,"safe-buffer":364,"sha.js":367}],273:[function(require,module,exports){ - arguments[4][54][0].apply(exports,arguments) - },{"cipher-base":267,"dup":54,"inherits":335,"safe-buffer":364}],274:[function(require,module,exports){ - 'use strict' - - exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') - exports.createHash = exports.Hash = require('create-hash') - exports.createHmac = exports.Hmac = require('create-hmac') - - var algos = require('browserify-sign/algos') - var algoKeys = Object.keys(algos) - var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys) - exports.getHashes = function () { - return hashes - } - - var p = require('pbkdf2') - exports.pbkdf2 = p.pbkdf2 - exports.pbkdf2Sync = p.pbkdf2Sync - - var aes = require('browserify-cipher') - - exports.Cipher = aes.Cipher - exports.createCipher = aes.createCipher - exports.Cipheriv = aes.Cipheriv - exports.createCipheriv = aes.createCipheriv - exports.Decipher = aes.Decipher - exports.createDecipher = aes.createDecipher - exports.Decipheriv = aes.Decipheriv - exports.createDecipheriv = aes.createDecipheriv - exports.getCiphers = aes.getCiphers - exports.listCiphers = aes.listCiphers - - var dh = require('diffie-hellman') - - exports.DiffieHellmanGroup = dh.DiffieHellmanGroup - exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup - exports.getDiffieHellman = dh.getDiffieHellman - exports.createDiffieHellman = dh.createDiffieHellman - exports.DiffieHellman = dh.DiffieHellman - - var sign = require('browserify-sign') - - exports.createSign = sign.createSign - exports.Sign = sign.Sign - exports.createVerify = sign.createVerify - exports.Verify = sign.Verify - - exports.createECDH = require('create-ecdh') - - var publicEncrypt = require('public-encrypt') - - exports.publicEncrypt = publicEncrypt.publicEncrypt - exports.privateEncrypt = publicEncrypt.privateEncrypt - exports.publicDecrypt = publicEncrypt.publicDecrypt - exports.privateDecrypt = publicEncrypt.privateDecrypt - - // the least I can do is make error messages for the rest of the node.js/crypto api. - // ;[ - // 'createCredentials' - // ].forEach(function (name) { - // exports[name] = function () { - // throw new Error([ - // 'sorry, ' + name + ' is not implemented yet', - // 'we accept pull requests', - // 'https://github.com/crypto-browserify/crypto-browserify' - // ].join('\n')) - // } - // }) - - var rf = require('randomfill') - - exports.randomFill = rf.randomFill - exports.randomFillSync = rf.randomFillSync - - exports.createCredentials = function () { - throw new Error([ - 'sorry, createCredentials is not implemented yet', - 'we accept pull requests', - 'https://github.com/crypto-browserify/crypto-browserify' - ].join('\n')) - } - - exports.constants = { - 'DH_CHECK_P_NOT_SAFE_PRIME': 2, - 'DH_CHECK_P_NOT_PRIME': 1, - 'DH_UNABLE_TO_CHECK_GENERATOR': 4, - 'DH_NOT_SUITABLE_GENERATOR': 8, - 'NPN_ENABLED': 1, - 'ALPN_ENABLED': 1, - 'RSA_PKCS1_PADDING': 1, - 'RSA_SSLV23_PADDING': 2, - 'RSA_NO_PADDING': 3, - 'RSA_PKCS1_OAEP_PADDING': 4, - 'RSA_X931_PADDING': 5, - 'RSA_PKCS1_PSS_PADDING': 6, - 'POINT_CONVERSION_COMPRESSED': 2, - 'POINT_CONVERSION_UNCOMPRESSED': 4, - 'POINT_CONVERSION_HYBRID': 6 - } - - },{"browserify-cipher":240,"browserify-sign":247,"browserify-sign/algos":244,"create-ecdh":268,"create-hash":270,"create-hmac":272,"diffie-hellman":281,"pbkdf2":347,"public-encrypt":354,"randombytes":361,"randomfill":362}],275:[function(require,module,exports){ - 'use strict'; - - exports.utils = require('./des/utils'); - exports.Cipher = require('./des/cipher'); - exports.DES = require('./des/des'); - exports.CBC = require('./des/cbc'); - exports.EDE = require('./des/ede'); - - },{"./des/cbc":276,"./des/cipher":277,"./des/des":278,"./des/ede":279,"./des/utils":280}],276:[function(require,module,exports){ - 'use strict'; - - var assert = require('minimalistic-assert'); - var inherits = require('inherits'); - - var proto = {}; - - function CBCState(iv) { - assert.equal(iv.length, 8, 'Invalid IV length'); - - this.iv = new Array(8); - for (var i = 0; i < this.iv.length; i++) - this.iv[i] = iv[i]; - } - - function instantiate(Base) { - function CBC(options) { - Base.call(this, options); - this._cbcInit(); - } - inherits(CBC, Base); - - var keys = Object.keys(proto); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - CBC.prototype[key] = proto[key]; - } - - CBC.create = function create(options) { - return new CBC(options); - }; - - return CBC; - } - - exports.instantiate = instantiate; - - proto._cbcInit = function _cbcInit() { - var state = new CBCState(this.options.iv); - this._cbcState = state; - }; - - proto._update = function _update(inp, inOff, out, outOff) { - var state = this._cbcState; - var superProto = this.constructor.super_.prototype; - - var iv = state.iv; - if (this.type === 'encrypt') { - for (var i = 0; i < this.blockSize; i++) - iv[i] ^= inp[inOff + i]; - - superProto._update.call(this, iv, 0, out, outOff); - - for (var i = 0; i < this.blockSize; i++) - iv[i] = out[outOff + i]; - } else { - superProto._update.call(this, inp, inOff, out, outOff); - - for (var i = 0; i < this.blockSize; i++) - out[outOff + i] ^= iv[i]; - - for (var i = 0; i < this.blockSize; i++) - iv[i] = inp[inOff + i]; - } - }; - - },{"inherits":335,"minimalistic-assert":339}],277:[function(require,module,exports){ - 'use strict'; - - var assert = require('minimalistic-assert'); - - function Cipher(options) { - this.options = options; - - this.type = this.options.type; - this.blockSize = 8; - this._init(); - - this.buffer = new Array(this.blockSize); - this.bufferOff = 0; - } - module.exports = Cipher; - - Cipher.prototype._init = function _init() { - // Might be overrided - }; - - Cipher.prototype.update = function update(data) { - if (data.length === 0) - return []; - - if (this.type === 'decrypt') - return this._updateDecrypt(data); - else - return this._updateEncrypt(data); - }; - - Cipher.prototype._buffer = function _buffer(data, off) { - // Append data to buffer - var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); - for (var i = 0; i < min; i++) - this.buffer[this.bufferOff + i] = data[off + i]; - this.bufferOff += min; - - // Shift next - return min; - }; - - Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { - this._update(this.buffer, 0, out, off); - this.bufferOff = 0; - return this.blockSize; - }; - - Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { - var inputOff = 0; - var outputOff = 0; - - var count = ((this.bufferOff + data.length) / this.blockSize) | 0; - var out = new Array(count * this.blockSize); - - if (this.bufferOff !== 0) { - inputOff += this._buffer(data, inputOff); - - if (this.bufferOff === this.buffer.length) - outputOff += this._flushBuffer(out, outputOff); - } - - // Write blocks - var max = data.length - ((data.length - inputOff) % this.blockSize); - for (; inputOff < max; inputOff += this.blockSize) { - this._update(data, inputOff, out, outputOff); - outputOff += this.blockSize; - } - - // Queue rest - for (; inputOff < data.length; inputOff++, this.bufferOff++) - this.buffer[this.bufferOff] = data[inputOff]; - - return out; - }; - - Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { - var inputOff = 0; - var outputOff = 0; - - var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; - var out = new Array(count * this.blockSize); - - // TODO(indutny): optimize it, this is far from optimal - for (; count > 0; count--) { - inputOff += this._buffer(data, inputOff); - outputOff += this._flushBuffer(out, outputOff); - } - - // Buffer rest of the input - inputOff += this._buffer(data, inputOff); - - return out; - }; - - Cipher.prototype.final = function final(buffer) { - var first; - if (buffer) - first = this.update(buffer); - - var last; - if (this.type === 'encrypt') - last = this._finalEncrypt(); - else - last = this._finalDecrypt(); - - if (first) - return first.concat(last); - else - return last; - }; - - Cipher.prototype._pad = function _pad(buffer, off) { - if (off === 0) - return false; - - while (off < buffer.length) - buffer[off++] = 0; - - return true; - }; - - Cipher.prototype._finalEncrypt = function _finalEncrypt() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; - - var out = new Array(this.blockSize); - this._update(this.buffer, 0, out, 0); - return out; - }; - - Cipher.prototype._unpad = function _unpad(buffer) { - return buffer; - }; - - Cipher.prototype._finalDecrypt = function _finalDecrypt() { - assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); - var out = new Array(this.blockSize); - this._flushBuffer(out, 0); - - return this._unpad(out); - }; - - },{"minimalistic-assert":339}],278:[function(require,module,exports){ - 'use strict'; - - var assert = require('minimalistic-assert'); - var inherits = require('inherits'); - - var utils = require('./utils'); - var Cipher = require('./cipher'); - - function DESState() { - this.tmp = new Array(2); - this.keys = null; - } - - function DES(options) { - Cipher.call(this, options); - - var state = new DESState(); - this._desState = state; - - this.deriveKeys(state, options.key); - } - inherits(DES, Cipher); - module.exports = DES; - - DES.create = function create(options) { - return new DES(options); - }; - - var shiftTable = [ - 1, 1, 2, 2, 2, 2, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 1 - ]; - - DES.prototype.deriveKeys = function deriveKeys(state, key) { - state.keys = new Array(16 * 2); - - assert.equal(key.length, this.blockSize, 'Invalid key length'); - - var kL = utils.readUInt32BE(key, 0); - var kR = utils.readUInt32BE(key, 4); - - utils.pc1(kL, kR, state.tmp, 0); - kL = state.tmp[0]; - kR = state.tmp[1]; - for (var i = 0; i < state.keys.length; i += 2) { - var shift = shiftTable[i >>> 1]; - kL = utils.r28shl(kL, shift); - kR = utils.r28shl(kR, shift); - utils.pc2(kL, kR, state.keys, i); - } - }; - - DES.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._desState; - - var l = utils.readUInt32BE(inp, inOff); - var r = utils.readUInt32BE(inp, inOff + 4); - - // Initial Permutation - utils.ip(l, r, state.tmp, 0); - l = state.tmp[0]; - r = state.tmp[1]; - - if (this.type === 'encrypt') - this._encrypt(state, l, r, state.tmp, 0); - else - this._decrypt(state, l, r, state.tmp, 0); - - l = state.tmp[0]; - r = state.tmp[1]; - - utils.writeUInt32BE(out, l, outOff); - utils.writeUInt32BE(out, r, outOff + 4); - }; - - DES.prototype._pad = function _pad(buffer, off) { - var value = buffer.length - off; - for (var i = off; i < buffer.length; i++) - buffer[i] = value; - - return true; - }; - - DES.prototype._unpad = function _unpad(buffer) { - var pad = buffer[buffer.length - 1]; - for (var i = buffer.length - pad; i < buffer.length; i++) - assert.equal(buffer[i], pad); - - return buffer.slice(0, buffer.length - pad); - }; - - DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { - var l = lStart; - var r = rStart; - - // Apply f() x16 times - for (var i = 0; i < state.keys.length; i += 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; - - // f(r, k) - utils.expand(r, state.tmp, 0); - - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); - - var t = r; - r = (l ^ f) >>> 0; - l = t; - } - - // Reverse Initial Permutation - utils.rip(r, l, out, off); - }; - - DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { - var l = rStart; - var r = lStart; - - // Apply f() x16 times - for (var i = state.keys.length - 2; i >= 0; i -= 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; - - // f(r, k) - utils.expand(l, state.tmp, 0); - - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); - - var t = l; - l = (r ^ f) >>> 0; - r = t; - } - - // Reverse Initial Permutation - utils.rip(l, r, out, off); - }; - - },{"./cipher":277,"./utils":280,"inherits":335,"minimalistic-assert":339}],279:[function(require,module,exports){ - 'use strict'; - - var assert = require('minimalistic-assert'); - var inherits = require('inherits'); - - var Cipher = require('./cipher'); - var DES = require('./des'); - - function EDEState(type, key) { - assert.equal(key.length, 24, 'Invalid key length'); - - var k1 = key.slice(0, 8); - var k2 = key.slice(8, 16); - var k3 = key.slice(16, 24); - - if (type === 'encrypt') { - this.ciphers = [ - DES.create({ type: 'encrypt', key: k1 }), - DES.create({ type: 'decrypt', key: k2 }), - DES.create({ type: 'encrypt', key: k3 }) - ]; - } else { - this.ciphers = [ - DES.create({ type: 'decrypt', key: k3 }), - DES.create({ type: 'encrypt', key: k2 }), - DES.create({ type: 'decrypt', key: k1 }) - ]; - } - } - - function EDE(options) { - Cipher.call(this, options); - - var state = new EDEState(this.type, this.options.key); - this._edeState = state; - } - inherits(EDE, Cipher); - - module.exports = EDE; - - EDE.create = function create(options) { - return new EDE(options); - }; - - EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; - - state.ciphers[0]._update(inp, inOff, out, outOff); - state.ciphers[1]._update(out, outOff, out, outOff); - state.ciphers[2]._update(out, outOff, out, outOff); - }; - - EDE.prototype._pad = DES.prototype._pad; - EDE.prototype._unpad = DES.prototype._unpad; - - },{"./cipher":277,"./des":278,"inherits":335,"minimalistic-assert":339}],280:[function(require,module,exports){ - 'use strict'; - - exports.readUInt32BE = function readUInt32BE(bytes, off) { - var res = (bytes[0 + off] << 24) | - (bytes[1 + off] << 16) | - (bytes[2 + off] << 8) | - bytes[3 + off]; - return res >>> 0; - }; - - exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { - bytes[0 + off] = value >>> 24; - bytes[1 + off] = (value >>> 16) & 0xff; - bytes[2 + off] = (value >>> 8) & 0xff; - bytes[3 + off] = value & 0xff; - }; - - exports.ip = function ip(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - for (var i = 6; i >= 0; i -= 2) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - - for (var i = 6; i >= 0; i -= 2) { - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - } - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; - }; - - exports.rip = function rip(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - for (var i = 0; i < 4; i++) { - for (var j = 24; j >= 0; j -= 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - for (var i = 4; i < 8; i++) { - for (var j = 24; j >= 0; j -= 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; - }; - - exports.pc1 = function pc1(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - // 7, 15, 23, 31, 39, 47, 55, 63 - // 6, 14, 22, 30, 39, 47, 55, 63 - // 5, 13, 21, 29, 39, 47, 55, 63 - // 4, 12, 20, 28 - for (var i = 7; i >= 5; i--) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - - // 1, 9, 17, 25, 33, 41, 49, 57 - // 2, 10, 18, 26, 34, 42, 50, 58 - // 3, 11, 19, 27, 35, 43, 51, 59 - // 36, 44, 52, 60 - for (var i = 1; i <= 3; i++) { - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; - }; - - exports.r28shl = function r28shl(num, shift) { - return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); - }; - - var pc2table = [ - // inL => outL - 14, 11, 17, 4, 27, 23, 25, 0, - 13, 22, 7, 18, 5, 9, 16, 24, - 2, 20, 12, 21, 1, 8, 15, 26, - - // inR => outR - 15, 4, 25, 19, 9, 1, 26, 16, - 5, 11, 23, 8, 12, 7, 17, 0, - 22, 3, 10, 14, 6, 20, 27, 24 - ]; - - exports.pc2 = function pc2(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - var len = pc2table.length >>> 1; - for (var i = 0; i < len; i++) { - outL <<= 1; - outL |= (inL >>> pc2table[i]) & 0x1; - } - for (var i = len; i < pc2table.length; i++) { - outR <<= 1; - outR |= (inR >>> pc2table[i]) & 0x1; - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; - }; - - exports.expand = function expand(r, out, off) { - var outL = 0; - var outR = 0; - - outL = ((r & 1) << 5) | (r >>> 27); - for (var i = 23; i >= 15; i -= 4) { - outL <<= 6; - outL |= (r >>> i) & 0x3f; - } - for (var i = 11; i >= 3; i -= 4) { - outR |= (r >>> i) & 0x3f; - outR <<= 6; - } - outR |= ((r & 0x1f) << 1) | (r >>> 31); - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; - }; - - var sTable = [ - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, - - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, - - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, - - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, - - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, - - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, - - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 - ]; - - exports.substitute = function substitute(inL, inR) { - var out = 0; - for (var i = 0; i < 4; i++) { - var b = (inL >>> (18 - i * 6)) & 0x3f; - var sb = sTable[i * 0x40 + b]; - - out <<= 4; - out |= sb; - } - for (var i = 0; i < 4; i++) { - var b = (inR >>> (18 - i * 6)) & 0x3f; - var sb = sTable[4 * 0x40 + i * 0x40 + b]; - - out <<= 4; - out |= sb; - } - return out >>> 0; - }; - - var permuteTable = [ - 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, - 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 - ]; - - exports.permute = function permute(num) { - var out = 0; - for (var i = 0; i < permuteTable.length; i++) { - out <<= 1; - out |= (num >>> permuteTable[i]) & 0x1; - } - return out >>> 0; - }; - - exports.padSplit = function padSplit(num, size, group) { - var str = num.toString(2); - while (str.length < size) - str = '0' + str; - - var out = []; - for (var i = 0; i < size; i += group) - out.push(str.slice(i, i + group)); - return out.join(' '); - }; - - },{}],281:[function(require,module,exports){ - (function (Buffer){(function (){ - var generatePrime = require('./lib/generatePrime') - var primes = require('./lib/primes.json') - - var DH = require('./lib/dh') - - function getDiffieHellman (mod) { - var prime = new Buffer(primes[mod].prime, 'hex') - var gen = new Buffer(primes[mod].gen, 'hex') - - return new DH(prime, gen) - } - - var ENCODINGS = { - 'binary': true, 'hex': true, 'base64': true - } - - function createDiffieHellman (prime, enc, generator, genc) { - if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { - return createDiffieHellman(prime, 'binary', enc, generator) - } - - enc = enc || 'binary' - genc = genc || 'binary' - generator = generator || new Buffer([2]) - - if (!Buffer.isBuffer(generator)) { - generator = new Buffer(generator, genc) - } - - if (typeof prime === 'number') { - return new DH(generatePrime(prime, generator), generator, true) - } - - if (!Buffer.isBuffer(prime)) { - prime = new Buffer(prime, enc) - } - - return new DH(prime, generator, true) - } - - exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman - exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./lib/dh":282,"./lib/generatePrime":283,"./lib/primes.json":284,"buffer":266}],282:[function(require,module,exports){ - (function (Buffer){(function (){ - var BN = require('bn.js'); - var MillerRabin = require('miller-rabin'); - var millerRabin = new MillerRabin(); - var TWENTYFOUR = new BN(24); - var ELEVEN = new BN(11); - var TEN = new BN(10); - var THREE = new BN(3); - var SEVEN = new BN(7); - var primes = require('./generatePrime'); - var randomBytes = require('randombytes'); - module.exports = DH; - - function setPublicKey(pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this._pub = new BN(pub); - return this; - } - - function setPrivateKey(priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); - } - this._priv = new BN(priv); - return this; - } - - var primeCache = {}; - function checkPrime(prime, generator) { - var gen = generator.toString('hex'); - var hex = [gen, prime.toString(16)].join('_'); - if (hex in primeCache) { - return primeCache[hex]; - } - var error = 0; - - if (prime.isEven() || - !primes.simpleSieve || - !primes.fermatTest(prime) || - !millerRabin.test(prime)) { - //not a prime so +1 - error += 1; - - if (gen === '02' || gen === '05') { - // we'd be able to check the generator - // it would fail so +8 - error += 8; - } else { - //we wouldn't be able to test the generator - // so +4 - error += 4; - } - primeCache[hex] = error; - return error; - } - if (!millerRabin.test(prime.shrn(1))) { - //not a safe prime - error += 2; - } - var rem; - switch (gen) { - case '02': - if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { - // unsuidable generator - error += 8; - } - break; - case '05': - rem = prime.mod(TEN); - if (rem.cmp(THREE) && rem.cmp(SEVEN)) { - // prime mod 10 needs to equal 3 or 7 - error += 8; - } - break; - default: - error += 4; - } - primeCache[hex] = error; - return error; - } - - function DH(prime, generator, malleable) { - this.setGenerator(generator); - this.__prime = new BN(prime); - this._prime = BN.mont(this.__prime); - this._primeLen = prime.length; - this._pub = undefined; - this._priv = undefined; - this._primeCode = undefined; - if (malleable) { - this.setPublicKey = setPublicKey; - this.setPrivateKey = setPrivateKey; - } else { - this._primeCode = 8; - } - } - Object.defineProperty(DH.prototype, 'verifyError', { - enumerable: true, - get: function () { - if (typeof this._primeCode !== 'number') { - this._primeCode = checkPrime(this.__prime, this.__gen); - } - return this._primeCode; - } - }); - DH.prototype.generateKeys = function () { - if (!this._priv) { - this._priv = new BN(randomBytes(this._primeLen)); - } - this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); - return this.getPublicKey(); - }; - - DH.prototype.computeSecret = function (other) { - other = new BN(other); - other = other.toRed(this._prime); - var secret = other.redPow(this._priv).fromRed(); - var out = new Buffer(secret.toArray()); - var prime = this.getPrime(); - if (out.length < prime.length) { - var front = new Buffer(prime.length - out.length); - front.fill(0); - out = Buffer.concat([front, out]); - } - return out; - }; - - DH.prototype.getPublicKey = function getPublicKey(enc) { - return formatReturnValue(this._pub, enc); - }; - - DH.prototype.getPrivateKey = function getPrivateKey(enc) { - return formatReturnValue(this._priv, enc); - }; - - DH.prototype.getPrime = function (enc) { - return formatReturnValue(this.__prime, enc); - }; - - DH.prototype.getGenerator = function (enc) { - return formatReturnValue(this._gen, enc); - }; - - DH.prototype.setGenerator = function (gen, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(gen)) { - gen = new Buffer(gen, enc); - } - this.__gen = gen; - this._gen = new BN(gen); - return this; - }; - - function formatReturnValue(bn, enc) { - var buf = new Buffer(bn.toArray()); - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } - } - - }).call(this)}).call(this,require("buffer").Buffer) - },{"./generatePrime":283,"bn.js":285,"buffer":266,"miller-rabin":337,"randombytes":361}],283:[function(require,module,exports){ - var randomBytes = require('randombytes'); - module.exports = findPrime; - findPrime.simpleSieve = simpleSieve; - findPrime.fermatTest = fermatTest; - var BN = require('bn.js'); - var TWENTYFOUR = new BN(24); - var MillerRabin = require('miller-rabin'); - var millerRabin = new MillerRabin(); - var ONE = new BN(1); - var TWO = new BN(2); - var FIVE = new BN(5); - var SIXTEEN = new BN(16); - var EIGHT = new BN(8); - var TEN = new BN(10); - var THREE = new BN(3); - var SEVEN = new BN(7); - var ELEVEN = new BN(11); - var FOUR = new BN(4); - var TWELVE = new BN(12); - var primes = null; - - function _getPrimes() { - if (primes !== null) - return primes; - - var limit = 0x100000; - var res = []; - res[0] = 2; - for (var i = 1, k = 3; k < limit; k += 2) { - var sqrt = Math.ceil(Math.sqrt(k)); - for (var j = 0; j < i && res[j] <= sqrt; j++) - if (k % res[j] === 0) - break; - - if (i !== j && res[j] <= sqrt) - continue; - - res[i++] = k; - } - primes = res; - return res; - } - - function simpleSieve(p) { - var primes = _getPrimes(); - - for (var i = 0; i < primes.length; i++) - if (p.modn(primes[i]) === 0) { - if (p.cmpn(primes[i]) === 0) { - return true; - } else { - return false; - } - } - - return true; - } - - function fermatTest(p) { - var red = BN.mont(p); - return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; - } - - function findPrime(bits, gen) { - if (bits < 16) { - // this is what openssl does - if (gen === 2 || gen === 5) { - return new BN([0x8c, 0x7b]); - } else { - return new BN([0x8c, 0x27]); - } - } - gen = new BN(gen); - - var num, n2; - - while (true) { - num = new BN(randomBytes(Math.ceil(bits / 8))); - while (num.bitLength() > bits) { - num.ishrn(1); - } - if (num.isEven()) { - num.iadd(ONE); - } - if (!num.testn(1)) { - num.iadd(TWO); - } - if (!gen.cmp(TWO)) { - while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { - num.iadd(FOUR); - } - } else if (!gen.cmp(FIVE)) { - while (num.mod(TEN).cmp(THREE)) { - num.iadd(FOUR); - } - } - n2 = num.shrn(1); - if (simpleSieve(n2) && simpleSieve(num) && - fermatTest(n2) && fermatTest(num) && - millerRabin.test(n2) && millerRabin.test(num)) { - return num; - } - } - - } - - },{"bn.js":285,"miller-rabin":337,"randombytes":361}],284:[function(require,module,exports){ - module.exports={ - "modp1": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" - }, - "modp2": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" - }, - "modp5": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" - }, - "modp14": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" - }, - "modp15": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" - }, - "modp16": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" - }, - "modp17": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" - }, - "modp18": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" - } - } - },{}],285:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],286:[function(require,module,exports){ - arguments[4][56][0].apply(exports,arguments) - },{"../package.json":302,"./elliptic/curve":289,"./elliptic/curves":292,"./elliptic/ec":293,"./elliptic/eddsa":296,"./elliptic/utils":300,"brorand":221,"dup":56}],287:[function(require,module,exports){ - arguments[4][57][0].apply(exports,arguments) - },{"../utils":300,"bn.js":301,"dup":57}],288:[function(require,module,exports){ - arguments[4][58][0].apply(exports,arguments) - },{"../utils":300,"./base":287,"bn.js":301,"dup":58,"inherits":335}],289:[function(require,module,exports){ - arguments[4][59][0].apply(exports,arguments) - },{"./base":287,"./edwards":288,"./mont":290,"./short":291,"dup":59}],290:[function(require,module,exports){ - arguments[4][60][0].apply(exports,arguments) - },{"../utils":300,"./base":287,"bn.js":301,"dup":60,"inherits":335}],291:[function(require,module,exports){ - arguments[4][61][0].apply(exports,arguments) - },{"../utils":300,"./base":287,"bn.js":301,"dup":61,"inherits":335}],292:[function(require,module,exports){ - arguments[4][62][0].apply(exports,arguments) - },{"./curve":289,"./precomputed/secp256k1":299,"./utils":300,"dup":62,"hash.js":321}],293:[function(require,module,exports){ - arguments[4][63][0].apply(exports,arguments) - },{"../curves":292,"../utils":300,"./key":294,"./signature":295,"bn.js":301,"brorand":221,"dup":63,"hmac-drbg":333}],294:[function(require,module,exports){ - arguments[4][64][0].apply(exports,arguments) - },{"../utils":300,"bn.js":301,"dup":64}],295:[function(require,module,exports){ - arguments[4][65][0].apply(exports,arguments) - },{"../utils":300,"bn.js":301,"dup":65}],296:[function(require,module,exports){ - arguments[4][66][0].apply(exports,arguments) - },{"../curves":292,"../utils":300,"./key":297,"./signature":298,"dup":66,"hash.js":321}],297:[function(require,module,exports){ - arguments[4][67][0].apply(exports,arguments) - },{"../utils":300,"dup":67}],298:[function(require,module,exports){ - arguments[4][68][0].apply(exports,arguments) - },{"../utils":300,"bn.js":301,"dup":68}],299:[function(require,module,exports){ - arguments[4][69][0].apply(exports,arguments) - },{"dup":69}],300:[function(require,module,exports){ - arguments[4][70][0].apply(exports,arguments) - },{"bn.js":301,"dup":70,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],301:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],302:[function(require,module,exports){ - module.exports={ - "_from": "elliptic@^6.5.3", - "_id": "elliptic@6.5.4", - "_inBundle": false, - "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "_location": "/browserify/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "elliptic@^6.5.3", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "^6.5.3", - "saveSpec": null, - "fetchSpec": "^6.5.3" - }, - "_requiredBy": [ - "/browserify/browserify-sign", - "/browserify/create-ecdh" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "_shasum": "da37cebd31e79a1367e941b592ed1fbebd58abbb", - "_spec": "elliptic@^6.5.3", - "_where": "/usr/local/lib/node_modules/browserify/node_modules/browserify-sign", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "bundleDependencies": false, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - }, - "deprecated": false, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^2.0.2", - "coveralls": "^3.1.0", - "eslint": "^7.6.0", - "grunt": "^1.2.1", - "grunt-browserify": "^5.3.0", - "grunt-cli": "^1.3.2", - "grunt-contrib-connect": "^3.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^5.0.0", - "grunt-mocha-istanbul": "^5.0.2", - "grunt-saucelabs": "^9.0.1", - "istanbul": "^0.4.5", - "mocha": "^8.0.1" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.5.4" - } - - },{}],303:[function(require,module,exports){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - 'use strict'; - - var R = typeof Reflect === 'object' ? Reflect : null - var ReflectApply = R && typeof R.apply === 'function' - ? R.apply - : function ReflectApply(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); - } - - var ReflectOwnKeys - if (R && typeof R.ownKeys === 'function') { - ReflectOwnKeys = R.ownKeys - } else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target) - .concat(Object.getOwnPropertySymbols(target)); - }; - } else { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target); - }; - } - - function ProcessEmitWarning(warning) { - if (console && console.warn) console.warn(warning); - } - - var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { - return value !== value; - } - - function EventEmitter() { - EventEmitter.init.call(this); - } - module.exports = EventEmitter; - module.exports.once = once; - - // Backwards-compat with node 0.10.x - EventEmitter.EventEmitter = EventEmitter; - - EventEmitter.prototype._events = undefined; - EventEmitter.prototype._eventsCount = 0; - EventEmitter.prototype._maxListeners = undefined; - - // By default EventEmitters will print a warning if more than 10 listeners are - // added to it. This is a useful default which helps finding memory leaks. - var defaultMaxListeners = 10; - - function checkListener(listener) { - if (typeof listener !== 'function') { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } - } - - Object.defineProperty(EventEmitter, 'defaultMaxListeners', { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); - } - defaultMaxListeners = arg; - } - }); - - EventEmitter.init = function() { - - if (this._events === undefined || - this._events === Object.getPrototypeOf(this)._events) { - this._events = Object.create(null); - this._eventsCount = 0; - } - - this._maxListeners = this._maxListeners || undefined; - }; - - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); - } - this._maxListeners = n; - return this; - }; - - function _getMaxListeners(that) { - if (that._maxListeners === undefined) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; - } - - EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); - }; - - EventEmitter.prototype.emit = function emit(type) { - var args = []; - for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - var doError = (type === 'error'); - - var events = this._events; - if (events !== undefined) - doError = (doError && events.error === undefined); - else if (!doError) - return false; - - // If there is no 'error' event listener then throw. - if (doError) { - var er; - if (args.length > 0) - er = args[0]; - if (er instanceof Error) { - // Note: The comments on the `throw` lines are intentional, they show - // up in Node's output if this results in an unhandled exception. - throw er; // Unhandled 'error' event - } - // At least give some kind of context to the user - var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); - err.context = er; - throw err; // Unhandled 'error' event - } - - var handler = events[type]; - - if (handler === undefined) - return false; - - if (typeof handler === 'function') { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - ReflectApply(listeners[i], this, args); - } - - return true; - }; - - function _addListener(target, type, listener, prepend) { - var m; - var events; - var existing; - - checkListener(listener); - - events = target._events; - if (events === undefined) { - events = target._events = Object.create(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener !== undefined) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); - - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } - - if (existing === undefined) { - // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; - // If we've already got an array, just append. - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - - // Check for listener leak - m = _getMaxListeners(target); - if (m > 0 && existing.length > m && !existing.warned) { - existing.warned = true; - // No error code for this since it is a Warning - // eslint-disable-next-line no-restricted-syntax - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' ' + String(type) + ' listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - ProcessEmitWarning(w); - } - } - - return target; - } - - EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); - }; - - EventEmitter.prototype.on = EventEmitter.prototype.addListener; - - EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; - - function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } - } - - function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; - } - - EventEmitter.prototype.once = function once(type, listener) { - checkListener(listener); - this.on(type, _onceWrap(this, type, listener)); - return this; - }; - - EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - checkListener(listener); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - - // Emits a 'removeListener' event if and only if the listener was removed. - EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; - - checkListener(listener); - - events = this._events; - if (events === undefined) - return this; - - list = events[type]; - if (list === undefined) - return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; - - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - - if (list.length === 1) - events[type] = list[0]; - - if (events.removeListener !== undefined) - this.emit('removeListener', type, originalListener || listener); - } - - return this; - }; - - EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - - EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (events === undefined) - return this; - - // not listening for removeListener, no need to emit - if (events.removeListener === undefined) { - if (arguments.length === 0) { - this._events = Object.create(null); - this._eventsCount = 0; - } else if (events[type] !== undefined) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else - delete events[type]; - } - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = Object.create(null); - this._eventsCount = 0; - return this; - } - - listeners = events[type]; - - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners !== undefined) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } - - return this; - }; - - function _listeners(target, type, unwrap) { - var events = target._events; - - if (events === undefined) - return []; - - var evlistener = events[type]; - if (evlistener === undefined) - return []; - - if (typeof evlistener === 'function') - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - - return unwrap ? - unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); - } - - EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); - }; - - EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); - }; - - EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } - }; - - EventEmitter.prototype.listenerCount = listenerCount; - function listenerCount(type) { - var events = this._events; - - if (events !== undefined) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { - return 1; - } else if (evlistener !== undefined) { - return evlistener.length; - } - } - - return 0; - } - - EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; - }; - - function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; - } - - function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); - } - - function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; - } - - function once(emitter, name) { - return new Promise(function (resolve, reject) { - function errorListener(err) { - emitter.removeListener(name, resolver); - reject(err); - } - - function resolver() { - if (typeof emitter.removeListener === 'function') { - emitter.removeListener('error', errorListener); - } - resolve([].slice.call(arguments)); - }; - - eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); - if (name !== 'error') { - addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); - } - }); - } - - function addErrorHandlerIfEventEmitter(emitter, handler, flags) { - if (typeof emitter.on === 'function') { - eventTargetAgnosticAddListener(emitter, 'error', handler, flags); - } - } - - function eventTargetAgnosticAddListener(emitter, name, listener, flags) { - if (typeof emitter.on === 'function') { - if (flags.once) { - emitter.once(name, listener); - } else { - emitter.on(name, listener); - } - } else if (typeof emitter.addEventListener === 'function') { - // EventTarget does not have `error` event semantics like Node - // EventEmitters, we do not listen for `error` events here. - emitter.addEventListener(name, function wrapListener(arg) { - // IE does not have builtin `{ once: true }` support so we - // have to do it manually. - if (flags.once) { - emitter.removeEventListener(name, wrapListener); - } - listener(arg); - }); - } else { - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); - } - } - - },{}],304:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - var MD5 = require('md5.js') - - /* eslint-disable camelcase */ - function EVP_BytesToKey (password, salt, keyBits, ivLen) { - if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') - if (salt) { - if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') - if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') - } - - var keyLen = keyBits / 8 - var key = Buffer.alloc(keyLen) - var iv = Buffer.alloc(ivLen || 0) - var tmp = Buffer.alloc(0) - - while (keyLen > 0 || ivLen > 0) { - var hash = new MD5() - hash.update(tmp) - hash.update(password) - if (salt) hash.update(salt) - tmp = hash.digest() - - var used = 0 - - if (keyLen > 0) { - var keyStart = key.length - keyLen - used = Math.min(keyLen, tmp.length) - tmp.copy(key, keyStart, 0, used) - keyLen -= used - } - - if (used < tmp.length && ivLen > 0) { - var ivStart = iv.length - ivLen - var length = Math.min(ivLen, tmp.length - used) - tmp.copy(iv, ivStart, used, used + length) - ivLen -= length - } - } - - tmp.fill(0) - return { key: key, iv: iv } - } - - module.exports = EVP_BytesToKey - - },{"md5.js":336,"safe-buffer":364}],305:[function(require,module,exports){ - arguments[4][82][0].apply(exports,arguments) - },{"dup":82,"inherits":335,"readable-stream":320,"safe-buffer":364}],306:[function(require,module,exports){ - arguments[4][106][0].apply(exports,arguments) - },{"dup":106}],307:[function(require,module,exports){ - arguments[4][107][0].apply(exports,arguments) - },{"./_stream_readable":309,"./_stream_writable":311,"_process":353,"dup":107,"inherits":335}],308:[function(require,module,exports){ - arguments[4][108][0].apply(exports,arguments) - },{"./_stream_transform":310,"dup":108,"inherits":335}],309:[function(require,module,exports){ - arguments[4][109][0].apply(exports,arguments) - },{"../errors":306,"./_stream_duplex":307,"./internal/streams/async_iterator":312,"./internal/streams/buffer_list":313,"./internal/streams/destroy":314,"./internal/streams/from":316,"./internal/streams/state":318,"./internal/streams/stream":319,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],310:[function(require,module,exports){ - arguments[4][110][0].apply(exports,arguments) - },{"../errors":306,"./_stream_duplex":307,"dup":110,"inherits":335}],311:[function(require,module,exports){ - arguments[4][111][0].apply(exports,arguments) - },{"../errors":306,"./_stream_duplex":307,"./internal/streams/destroy":314,"./internal/streams/state":318,"./internal/streams/stream":319,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],312:[function(require,module,exports){ - arguments[4][112][0].apply(exports,arguments) - },{"./end-of-stream":315,"_process":353,"dup":112}],313:[function(require,module,exports){ - arguments[4][113][0].apply(exports,arguments) - },{"buffer":266,"dup":113,"util":222}],314:[function(require,module,exports){ - arguments[4][114][0].apply(exports,arguments) - },{"_process":353,"dup":114}],315:[function(require,module,exports){ - arguments[4][115][0].apply(exports,arguments) - },{"../../../errors":306,"dup":115}],316:[function(require,module,exports){ - arguments[4][116][0].apply(exports,arguments) - },{"dup":116}],317:[function(require,module,exports){ - arguments[4][117][0].apply(exports,arguments) - },{"../../../errors":306,"./end-of-stream":315,"dup":117}],318:[function(require,module,exports){ - arguments[4][118][0].apply(exports,arguments) - },{"../../../errors":306,"dup":118}],319:[function(require,module,exports){ - arguments[4][119][0].apply(exports,arguments) - },{"dup":119,"events":303}],320:[function(require,module,exports){ - arguments[4][120][0].apply(exports,arguments) - },{"./lib/_stream_duplex.js":307,"./lib/_stream_passthrough.js":308,"./lib/_stream_readable.js":309,"./lib/_stream_transform.js":310,"./lib/_stream_writable.js":311,"./lib/internal/streams/end-of-stream.js":315,"./lib/internal/streams/pipeline.js":317,"dup":120}],321:[function(require,module,exports){ - arguments[4][83][0].apply(exports,arguments) - },{"./hash/common":322,"./hash/hmac":323,"./hash/ripemd":324,"./hash/sha":325,"./hash/utils":332,"dup":83}],322:[function(require,module,exports){ - arguments[4][84][0].apply(exports,arguments) - },{"./utils":332,"dup":84,"minimalistic-assert":339}],323:[function(require,module,exports){ - arguments[4][85][0].apply(exports,arguments) - },{"./utils":332,"dup":85,"minimalistic-assert":339}],324:[function(require,module,exports){ - arguments[4][86][0].apply(exports,arguments) - },{"./common":322,"./utils":332,"dup":86}],325:[function(require,module,exports){ - arguments[4][87][0].apply(exports,arguments) - },{"./sha/1":326,"./sha/224":327,"./sha/256":328,"./sha/384":329,"./sha/512":330,"dup":87}],326:[function(require,module,exports){ - arguments[4][88][0].apply(exports,arguments) - },{"../common":322,"../utils":332,"./common":331,"dup":88}],327:[function(require,module,exports){ - arguments[4][89][0].apply(exports,arguments) - },{"../utils":332,"./256":328,"dup":89}],328:[function(require,module,exports){ - arguments[4][90][0].apply(exports,arguments) - },{"../common":322,"../utils":332,"./common":331,"dup":90,"minimalistic-assert":339}],329:[function(require,module,exports){ - arguments[4][91][0].apply(exports,arguments) - },{"../utils":332,"./512":330,"dup":91}],330:[function(require,module,exports){ - arguments[4][92][0].apply(exports,arguments) - },{"../common":322,"../utils":332,"dup":92,"minimalistic-assert":339}],331:[function(require,module,exports){ - arguments[4][93][0].apply(exports,arguments) - },{"../utils":332,"dup":93}],332:[function(require,module,exports){ - arguments[4][94][0].apply(exports,arguments) - },{"dup":94,"inherits":335,"minimalistic-assert":339}],333:[function(require,module,exports){ - arguments[4][95][0].apply(exports,arguments) - },{"dup":95,"hash.js":321,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],334:[function(require,module,exports){ - /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ - exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) - } - - exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 - } - - },{}],335:[function(require,module,exports){ - arguments[4][97][0].apply(exports,arguments) - },{"dup":97}],336:[function(require,module,exports){ - arguments[4][102][0].apply(exports,arguments) - },{"dup":102,"hash-base":305,"inherits":335,"safe-buffer":364}],337:[function(require,module,exports){ - var bn = require('bn.js'); - var brorand = require('brorand'); - - function MillerRabin(rand) { - this.rand = rand || new brorand.Rand(); - } - module.exports = MillerRabin; - - MillerRabin.create = function create(rand) { - return new MillerRabin(rand); - }; - - MillerRabin.prototype._randbelow = function _randbelow(n) { - var len = n.bitLength(); - var min_bytes = Math.ceil(len / 8); - - // Generage random bytes until a number less than n is found. - // This ensures that 0..n-1 have an equal probability of being selected. - do - var a = new bn(this.rand.generate(min_bytes)); - while (a.cmp(n) >= 0); - - return a; - }; - - MillerRabin.prototype._randrange = function _randrange(start, stop) { - // Generate a random number greater than or equal to start and less than stop. - var size = stop.sub(start); - return start.add(this._randbelow(size)); - }; - - MillerRabin.prototype.test = function test(n, k, cb) { - var len = n.bitLength(); - var red = bn.mont(n); - var rone = new bn(1).toRed(red); - - if (!k) - k = Math.max(1, (len / 48) | 0); - - // Find d and s, (n - 1) = (2 ^ s) * d; - var n1 = n.subn(1); - for (var s = 0; !n1.testn(s); s++) {} - var d = n.shrn(s); - - var rn1 = n1.toRed(red); - - var prime = true; - for (; k > 0; k--) { - var a = this._randrange(new bn(2), n1); - if (cb) - cb(a); - - var x = a.toRed(red).redPow(d); - if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) - continue; - - for (var i = 1; i < s; i++) { - x = x.redSqr(); - - if (x.cmp(rone) === 0) - return false; - if (x.cmp(rn1) === 0) - break; - } - - if (i === s) - return false; - } - - return prime; - }; - - MillerRabin.prototype.getDivisor = function getDivisor(n, k) { - var len = n.bitLength(); - var red = bn.mont(n); - var rone = new bn(1).toRed(red); - - if (!k) - k = Math.max(1, (len / 48) | 0); - - // Find d and s, (n - 1) = (2 ^ s) * d; - var n1 = n.subn(1); - for (var s = 0; !n1.testn(s); s++) {} - var d = n.shrn(s); - - var rn1 = n1.toRed(red); - - for (; k > 0; k--) { - var a = this._randrange(new bn(2), n1); - - var g = n.gcd(a); - if (g.cmpn(1) !== 0) - return g; - - var x = a.toRed(red).redPow(d); - if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) - continue; - - for (var i = 1; i < s; i++) { - x = x.redSqr(); - - if (x.cmp(rone) === 0) - return x.fromRed().subn(1).gcd(n); - if (x.cmp(rn1) === 0) - break; - } - - if (i === s) { - x = x.redSqr(); - return x.fromRed().subn(1).gcd(n); - } - } - - return false; - }; - - },{"bn.js":338,"brorand":221}],338:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],339:[function(require,module,exports){ - arguments[4][103][0].apply(exports,arguments) - },{"dup":103}],340:[function(require,module,exports){ - arguments[4][104][0].apply(exports,arguments) - },{"dup":104}],341:[function(require,module,exports){ - /* - object-assign - (c) Sindre Sorhus - @license MIT - */ - - 'use strict'; - /* eslint-disable no-unused-vars */ - var getOwnPropertySymbols = Object.getOwnPropertySymbols; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var propIsEnumerable = Object.prototype.propertyIsEnumerable; - - function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } - } - - module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; - }; - - },{}],342:[function(require,module,exports){ - module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", - "2.16.840.1.101.3.4.1.2": "aes-128-cbc", - "2.16.840.1.101.3.4.1.3": "aes-128-ofb", - "2.16.840.1.101.3.4.1.4": "aes-128-cfb", - "2.16.840.1.101.3.4.1.21": "aes-192-ecb", - "2.16.840.1.101.3.4.1.22": "aes-192-cbc", - "2.16.840.1.101.3.4.1.23": "aes-192-ofb", - "2.16.840.1.101.3.4.1.24": "aes-192-cfb", - "2.16.840.1.101.3.4.1.41": "aes-256-ecb", - "2.16.840.1.101.3.4.1.42": "aes-256-cbc", - "2.16.840.1.101.3.4.1.43": "aes-256-ofb", - "2.16.840.1.101.3.4.1.44": "aes-256-cfb" - } - },{}],343:[function(require,module,exports){ - // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js - // Fedor, you are amazing. - 'use strict' - - var asn1 = require('asn1.js') - - exports.certificate = require('./certificate') - - var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('modulus').int(), - this.key('publicExponent').int(), - this.key('privateExponent').int(), - this.key('prime1').int(), - this.key('prime2').int(), - this.key('exponent1').int(), - this.key('exponent2').int(), - this.key('coefficient').int() - ) - }) - exports.RSAPrivateKey = RSAPrivateKey - - var RSAPublicKey = asn1.define('RSAPublicKey', function () { - this.seq().obj( - this.key('modulus').int(), - this.key('publicExponent').int() - ) - }) - exports.RSAPublicKey = RSAPublicKey - - var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) - }) - exports.PublicKey = PublicKey - - var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('none').null_().optional(), - this.key('curve').objid().optional(), - this.key('params').seq().obj( - this.key('p').int(), - this.key('q').int(), - this.key('g').int() - ).optional() - ) - }) - - var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { - this.seq().obj( - this.key('version').int(), - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPrivateKey').octstr() - ) - }) - exports.PrivateKey = PrivateKeyInfo - var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { - this.seq().obj( - this.key('algorithm').seq().obj( - this.key('id').objid(), - this.key('decrypt').seq().obj( - this.key('kde').seq().obj( - this.key('id').objid(), - this.key('kdeparams').seq().obj( - this.key('salt').octstr(), - this.key('iters').int() - ) - ), - this.key('cipher').seq().obj( - this.key('algo').objid(), - this.key('iv').octstr() - ) - ) - ), - this.key('subjectPrivateKey').octstr() - ) - }) - - exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo - - var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('p').int(), - this.key('q').int(), - this.key('g').int(), - this.key('pub_key').int(), - this.key('priv_key').int() - ) - }) - exports.DSAPrivateKey = DSAPrivateKey - - exports.DSAparam = asn1.define('DSAparam', function () { - this.int() - }) - - var ECPrivateKey = asn1.define('ECPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('privateKey').octstr(), - this.key('parameters').optional().explicit(0).use(ECParameters), - this.key('publicKey').optional().explicit(1).bitstr() - ) - }) - exports.ECPrivateKey = ECPrivateKey - - var ECParameters = asn1.define('ECParameters', function () { - this.choice({ - namedCurve: this.objid() - }) - }) - - exports.signature = asn1.define('signature', function () { - this.seq().obj( - this.key('r').int(), - this.key('s').int() - ) - }) - - },{"./certificate":344,"asn1.js":200}],344:[function(require,module,exports){ - // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js - // thanks to @Rantanen - - 'use strict' - - var asn = require('asn1.js') - - var Time = asn.define('Time', function () { - this.choice({ - utcTime: this.utctime(), - generalTime: this.gentime() - }) - }) - - var AttributeTypeValue = asn.define('AttributeTypeValue', function () { - this.seq().obj( - this.key('type').objid(), - this.key('value').any() - ) - }) - - var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('parameters').optional(), - this.key('curve').objid().optional() - ) - }) - - var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) - }) - - var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { - this.setof(AttributeTypeValue) - }) - - var RDNSequence = asn.define('RDNSequence', function () { - this.seqof(RelativeDistinguishedName) - }) - - var Name = asn.define('Name', function () { - this.choice({ - rdnSequence: this.use(RDNSequence) - }) - }) - - var Validity = asn.define('Validity', function () { - this.seq().obj( - this.key('notBefore').use(Time), - this.key('notAfter').use(Time) - ) - }) - - var Extension = asn.define('Extension', function () { - this.seq().obj( - this.key('extnID').objid(), - this.key('critical').bool().def(false), - this.key('extnValue').octstr() - ) - }) - - var TBSCertificate = asn.define('TBSCertificate', function () { - this.seq().obj( - this.key('version').explicit(0).int().optional(), - this.key('serialNumber').int(), - this.key('signature').use(AlgorithmIdentifier), - this.key('issuer').use(Name), - this.key('validity').use(Validity), - this.key('subject').use(Name), - this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), - this.key('issuerUniqueID').implicit(1).bitstr().optional(), - this.key('subjectUniqueID').implicit(2).bitstr().optional(), - this.key('extensions').explicit(3).seqof(Extension).optional() - ) - }) - - var X509Certificate = asn.define('X509Certificate', function () { - this.seq().obj( - this.key('tbsCertificate').use(TBSCertificate), - this.key('signatureAlgorithm').use(AlgorithmIdentifier), - this.key('signatureValue').bitstr() - ) - }) - - module.exports = X509Certificate - - },{"asn1.js":200}],345:[function(require,module,exports){ - // adapted from https://github.com/apatil/pemstrip - var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m - var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m - var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m - var evp = require('evp_bytestokey') - var ciphers = require('browserify-aes') - var Buffer = require('safe-buffer').Buffer - module.exports = function (okey, password) { - var key = okey.toString() - var match = key.match(findProc) - var decrypted - if (!match) { - var match2 = key.match(fullRegex) - decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') - } else { - var suite = 'aes' + match[1] - var iv = Buffer.from(match[2], 'hex') - var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') - var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key - var out = [] - var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - decrypted = Buffer.concat(out) - } - var tag = key.match(startRegex)[1] - return { - tag: tag, - data: decrypted - } - } - - },{"browserify-aes":225,"evp_bytestokey":304,"safe-buffer":364}],346:[function(require,module,exports){ - var asn1 = require('./asn1') - var aesid = require('./aesid.json') - var fixProc = require('./fixProc') - var ciphers = require('browserify-aes') - var compat = require('pbkdf2') - var Buffer = require('safe-buffer').Buffer - module.exports = parseKeys - - function parseKeys (buffer) { - var password - if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { - password = buffer.passphrase - buffer = buffer.key - } - if (typeof buffer === 'string') { - buffer = Buffer.from(buffer) - } - - var stripped = fixProc(buffer, password) - - var type = stripped.tag - var data = stripped.data - var subtype, ndata - switch (type) { - case 'CERTIFICATE': - ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo - // falls through - case 'PUBLIC KEY': - if (!ndata) { - ndata = asn1.PublicKey.decode(data, 'der') - } - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') - case '1.2.840.10045.2.1': - ndata.subjectPrivateKey = ndata.subjectPublicKey - return { - type: 'ec', - data: ndata - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') - return { - type: 'dsa', - data: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) - } - // throw new Error('unknown key type ' + type) - case 'ENCRYPTED PRIVATE KEY': - data = asn1.EncryptedPrivateKey.decode(data, 'der') - data = decrypt(data, password) - // falls through - case 'PRIVATE KEY': - ndata = asn1.PrivateKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') - case '1.2.840.10045.2.1': - return { - curve: ndata.algorithm.curve, - privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') - return { - type: 'dsa', - params: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) - } - // throw new Error('unknown key type ' + type) - case 'RSA PUBLIC KEY': - return asn1.RSAPublicKey.decode(data, 'der') - case 'RSA PRIVATE KEY': - return asn1.RSAPrivateKey.decode(data, 'der') - case 'DSA PRIVATE KEY': - return { - type: 'dsa', - params: asn1.DSAPrivateKey.decode(data, 'der') - } - case 'EC PRIVATE KEY': - data = asn1.ECPrivateKey.decode(data, 'der') - return { - curve: data.parameters.value, - privateKey: data.privateKey - } - default: throw new Error('unknown key type ' + type) - } - } - parseKeys.signature = asn1.signature - function decrypt (data, password) { - var salt = data.algorithm.decrypt.kde.kdeparams.salt - var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) - var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] - var iv = data.algorithm.decrypt.cipher.iv - var cipherText = data.subjectPrivateKey - var keylen = parseInt(algo.split('-')[1], 10) / 8 - var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') - var cipher = ciphers.createDecipheriv(algo, key, iv) - var out = [] - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - return Buffer.concat(out) - } - - },{"./aesid.json":342,"./asn1":343,"./fixProc":345,"browserify-aes":225,"pbkdf2":347,"safe-buffer":364}],347:[function(require,module,exports){ - exports.pbkdf2 = require('./lib/async') - exports.pbkdf2Sync = require('./lib/sync') - - },{"./lib/async":348,"./lib/sync":351}],348:[function(require,module,exports){ - (function (global){(function (){ - var Buffer = require('safe-buffer').Buffer - - var checkParameters = require('./precondition') - var defaultEncoding = require('./default-encoding') - var sync = require('./sync') - var toBuffer = require('./to-buffer') - - var ZERO_BUF - var subtle = global.crypto && global.crypto.subtle - var toBrowser = { - sha: 'SHA-1', - 'sha-1': 'SHA-1', - sha1: 'SHA-1', - sha256: 'SHA-256', - 'sha-256': 'SHA-256', - sha384: 'SHA-384', - 'sha-384': 'SHA-384', - 'sha-512': 'SHA-512', - sha512: 'SHA-512' - } - var checks = [] - function checkNative (algo) { - if (global.process && !global.process.browser) { - return Promise.resolve(false) - } - if (!subtle || !subtle.importKey || !subtle.deriveBits) { - return Promise.resolve(false) - } - if (checks[algo] !== undefined) { - return checks[algo] - } - ZERO_BUF = ZERO_BUF || Buffer.alloc(8) - var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo) - .then(function () { - return true - }).catch(function () { - return false - }) - checks[algo] = prom - return prom - } - var nextTick - function getNextTick () { - if (nextTick) { - return nextTick - } - if (global.process && global.process.nextTick) { - nextTick = global.process.nextTick - } else if (global.queueMicrotask) { - nextTick = global.queueMicrotask - } else if (global.setImmediate) { - nextTick = global.setImmediate - } else { - nextTick = global.setTimeout - } - return nextTick - } - function browserPbkdf2 (password, salt, iterations, length, algo) { - return subtle.importKey( - 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits'] - ).then(function (key) { - return subtle.deriveBits({ - name: 'PBKDF2', - salt: salt, - iterations: iterations, - hash: { - name: algo - } - }, key, length << 3) - }).then(function (res) { - return Buffer.from(res) - }) - } - - function resolvePromise (promise, callback) { - promise.then(function (out) { - getNextTick()(function () { - callback(null, out) - }) - }, function (e) { - getNextTick()(function () { - callback(e) - }) - }) - } - module.exports = function (password, salt, iterations, keylen, digest, callback) { - if (typeof digest === 'function') { - callback = digest - digest = undefined - } - - digest = digest || 'sha1' - var algo = toBrowser[digest.toLowerCase()] - - if (!algo || typeof global.Promise !== 'function') { - getNextTick()(function () { - var out - try { - out = sync(password, salt, iterations, keylen, digest) - } catch (e) { - return callback(e) - } - callback(null, out) - }) - return - } - - checkParameters(iterations, keylen) - password = toBuffer(password, defaultEncoding, 'Password') - salt = toBuffer(salt, defaultEncoding, 'Salt') - if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2') - - resolvePromise(checkNative(algo).then(function (resp) { - if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo) - - return sync(password, salt, iterations, keylen, digest) - }), callback) - } - - }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"./default-encoding":349,"./precondition":350,"./sync":351,"./to-buffer":352,"safe-buffer":364}],349:[function(require,module,exports){ - (function (process,global){(function (){ - var defaultEncoding - /* istanbul ignore next */ - if (global.process && global.process.browser) { - defaultEncoding = 'utf-8' - } else if (global.process && global.process.version) { - var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10) - - defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary' - } else { - defaultEncoding = 'utf-8' - } - module.exports = defaultEncoding - - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"_process":353}],350:[function(require,module,exports){ - var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs - - module.exports = function (iterations, keylen) { - if (typeof iterations !== 'number') { - throw new TypeError('Iterations not a number') - } - - if (iterations < 0) { - throw new TypeError('Bad iterations') - } - - if (typeof keylen !== 'number') { - throw new TypeError('Key length not a number') - } - - if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */ - throw new TypeError('Bad key length') - } - } - - },{}],351:[function(require,module,exports){ - var md5 = require('create-hash/md5') - var RIPEMD160 = require('ripemd160') - var sha = require('sha.js') - var Buffer = require('safe-buffer').Buffer - - var checkParameters = require('./precondition') - var defaultEncoding = require('./default-encoding') - var toBuffer = require('./to-buffer') - - var ZEROS = Buffer.alloc(128) - var sizes = { - md5: 16, - sha1: 20, - sha224: 28, - sha256: 32, - sha384: 48, - sha512: 64, - rmd160: 20, - ripemd160: 20 - } - - function Hmac (alg, key, saltLen) { - var hash = getDigest(alg) - var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 - - if (key.length > blocksize) { - key = hash(key) - } else if (key.length < blocksize) { - key = Buffer.concat([key, ZEROS], blocksize) - } - - var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]) - var opad = Buffer.allocUnsafe(blocksize + sizes[alg]) - for (var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - - var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4) - ipad.copy(ipad1, 0, 0, blocksize) - this.ipad1 = ipad1 - this.ipad2 = ipad - this.opad = opad - this.alg = alg - this.blocksize = blocksize - this.hash = hash - this.size = sizes[alg] - } - - Hmac.prototype.run = function (data, ipad) { - data.copy(ipad, this.blocksize) - var h = this.hash(ipad) - h.copy(this.opad, this.blocksize) - return this.hash(this.opad) - } - - function getDigest (alg) { - function shaFunc (data) { - return sha(alg).update(data).digest() - } - function rmd160Func (data) { - return new RIPEMD160().update(data).digest() - } - - if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func - if (alg === 'md5') return md5 - return shaFunc - } - - function pbkdf2 (password, salt, iterations, keylen, digest) { - checkParameters(iterations, keylen) - password = toBuffer(password, defaultEncoding, 'Password') - salt = toBuffer(salt, defaultEncoding, 'Salt') - - digest = digest || 'sha1' - - var hmac = new Hmac(digest, password, salt.length) - - var DK = Buffer.allocUnsafe(keylen) - var block1 = Buffer.allocUnsafe(salt.length + 4) - salt.copy(block1, 0, 0, salt.length) - - var destPos = 0 - var hLen = sizes[digest] - var l = Math.ceil(keylen / hLen) - - for (var i = 1; i <= l; i++) { - block1.writeUInt32BE(i, salt.length) - - var T = hmac.run(block1, hmac.ipad1) - var U = T - - for (var j = 1; j < iterations; j++) { - U = hmac.run(U, hmac.ipad2) - for (var k = 0; k < hLen; k++) T[k] ^= U[k] - } - - T.copy(DK, destPos) - destPos += hLen - } - - return DK - } - - module.exports = pbkdf2 - - },{"./default-encoding":349,"./precondition":350,"./to-buffer":352,"create-hash/md5":271,"ripemd160":363,"safe-buffer":364,"sha.js":367}],352:[function(require,module,exports){ - var Buffer = require('safe-buffer').Buffer - - module.exports = function (thing, encoding, name) { - if (Buffer.isBuffer(thing)) { - return thing - } else if (typeof thing === 'string') { - return Buffer.from(thing, encoding) - } else if (ArrayBuffer.isView(thing)) { - return Buffer.from(thing.buffer) - } else { - throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView') - } - } - - },{"safe-buffer":364}],353:[function(require,module,exports){ - // shim for using process in browser - var process = module.exports = {}; - - // cached from whatever global is present so that test runners that stub it - // don't break things. But we need to wrap it in a try catch in case it is - // wrapped in strict mode code which doesn't define any globals. It's inside a - // function because try/catches deoptimize in certain engines. - - var cachedSetTimeout; - var cachedClearTimeout; - - function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); - } - function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); - } - (function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } - } ()) - function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - - } - function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - - } - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } - } - - function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); - } - - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } - }; - - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - process.prependListener = noop; - process.prependOnceListener = noop; - - process.listeners = function (name) { return [] } - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; - - },{}],354:[function(require,module,exports){ - exports.publicEncrypt = require('./publicEncrypt') - exports.privateDecrypt = require('./privateDecrypt') - - exports.privateEncrypt = function privateEncrypt (key, buf) { - return exports.publicEncrypt(key, buf, true) - } - - exports.publicDecrypt = function publicDecrypt (key, buf) { - return exports.privateDecrypt(key, buf, true) - } - - },{"./privateDecrypt":357,"./publicEncrypt":358}],355:[function(require,module,exports){ - var createHash = require('create-hash') - var Buffer = require('safe-buffer').Buffer - - module.exports = function (seed, len) { - var t = Buffer.alloc(0) - var i = 0 - var c - while (t.length < len) { - c = i2ops(i++) - t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]) - } - return t.slice(0, len) - } - - function i2ops (c) { - var out = Buffer.allocUnsafe(4) - out.writeUInt32BE(c, 0) - return out - } - - },{"create-hash":270,"safe-buffer":364}],356:[function(require,module,exports){ - arguments[4][45][0].apply(exports,arguments) - },{"buffer":222,"dup":45}],357:[function(require,module,exports){ - var parseKeys = require('parse-asn1') - var mgf = require('./mgf') - var xor = require('./xor') - var BN = require('bn.js') - var crt = require('browserify-rsa') - var createHash = require('create-hash') - var withPublic = require('./withPublic') - var Buffer = require('safe-buffer').Buffer - - module.exports = function privateDecrypt (privateKey, enc, reverse) { - var padding - if (privateKey.padding) { - padding = privateKey.padding - } else if (reverse) { - padding = 1 - } else { - padding = 4 - } - - var key = parseKeys(privateKey) - var k = key.modulus.byteLength() - if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) { - throw new Error('decryption error') - } - var msg - if (reverse) { - msg = withPublic(new BN(enc), key) - } else { - msg = crt(enc, key) - } - var zBuffer = Buffer.alloc(k - msg.length) - msg = Buffer.concat([zBuffer, msg], k) - if (padding === 4) { - return oaep(key, msg) - } else if (padding === 1) { - return pkcs1(key, msg, reverse) - } else if (padding === 3) { - return msg - } else { - throw new Error('unknown padding') - } - } - - function oaep (key, msg) { - var k = key.modulus.byteLength() - var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() - var hLen = iHash.length - if (msg[0] !== 0) { - throw new Error('decryption error') - } - var maskedSeed = msg.slice(1, hLen + 1) - var maskedDb = msg.slice(hLen + 1) - var seed = xor(maskedSeed, mgf(maskedDb, hLen)) - var db = xor(maskedDb, mgf(seed, k - hLen - 1)) - if (compare(iHash, db.slice(0, hLen))) { - throw new Error('decryption error') - } - var i = hLen - while (db[i] === 0) { - i++ - } - if (db[i++] !== 1) { - throw new Error('decryption error') - } - return db.slice(i) - } - - function pkcs1 (key, msg, reverse) { - var p1 = msg.slice(0, 2) - var i = 2 - var status = 0 - while (msg[i++] !== 0) { - if (i >= msg.length) { - status++ - break - } - } - var ps = msg.slice(2, i - 1) - - if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) { - status++ - } - if (ps.length < 8) { - status++ - } - if (status) { - throw new Error('decryption error') - } - return msg.slice(i) - } - function compare (a, b) { - a = Buffer.from(a) - b = Buffer.from(b) - var dif = 0 - var len = a.length - if (a.length !== b.length) { - dif++ - len = Math.min(a.length, b.length) - } - var i = -1 - while (++i < len) { - dif += (a[i] ^ b[i]) - } - return dif - } - - },{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,"safe-buffer":364}],358:[function(require,module,exports){ - var parseKeys = require('parse-asn1') - var randomBytes = require('randombytes') - var createHash = require('create-hash') - var mgf = require('./mgf') - var xor = require('./xor') - var BN = require('bn.js') - var withPublic = require('./withPublic') - var crt = require('browserify-rsa') - var Buffer = require('safe-buffer').Buffer - - module.exports = function publicEncrypt (publicKey, msg, reverse) { - var padding - if (publicKey.padding) { - padding = publicKey.padding - } else if (reverse) { - padding = 1 - } else { - padding = 4 - } - var key = parseKeys(publicKey) - var paddedMsg - if (padding === 4) { - paddedMsg = oaep(key, msg) - } else if (padding === 1) { - paddedMsg = pkcs1(key, msg, reverse) - } else if (padding === 3) { - paddedMsg = new BN(msg) - if (paddedMsg.cmp(key.modulus) >= 0) { - throw new Error('data too long for modulus') - } - } else { - throw new Error('unknown padding') - } - if (reverse) { - return crt(paddedMsg, key) - } else { - return withPublic(paddedMsg, key) - } - } - - function oaep (key, msg) { - var k = key.modulus.byteLength() - var mLen = msg.length - var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() - var hLen = iHash.length - var hLen2 = 2 * hLen - if (mLen > k - hLen2 - 2) { - throw new Error('message too long') - } - var ps = Buffer.alloc(k - mLen - hLen2 - 2) - var dblen = k - hLen - 1 - var seed = randomBytes(hLen) - var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen)) - var maskedSeed = xor(seed, mgf(maskedDb, hLen)) - return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k)) - } - function pkcs1 (key, msg, reverse) { - var mLen = msg.length - var k = key.modulus.byteLength() - if (mLen > k - 11) { - throw new Error('message too long') - } - var ps - if (reverse) { - ps = Buffer.alloc(k - mLen - 3, 0xff) - } else { - ps = nonZero(k - mLen - 3) - } - return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k)) - } - function nonZero (len) { - var out = Buffer.allocUnsafe(len) - var i = 0 - var cache = randomBytes(len * 2) - var cur = 0 - var num - while (i < len) { - if (cur === cache.length) { - cache = randomBytes(len * 2) - cur = 0 - } - num = cache[cur++] - if (num) { - out[i++] = num - } - } - return out - } - - },{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,"randombytes":361,"safe-buffer":364}],359:[function(require,module,exports){ - var BN = require('bn.js') - var Buffer = require('safe-buffer').Buffer - - function withPublic (paddedMsg, key) { - return Buffer.from(paddedMsg - .toRed(BN.mont(key.modulus)) - .redPow(new BN(key.publicExponent)) - .fromRed() - .toArray()) - } - - module.exports = withPublic - - },{"bn.js":356,"safe-buffer":364}],360:[function(require,module,exports){ - module.exports = function xor (a, b) { - var len = a.length - var i = -1 - while (++i < len) { - a[i] ^= b[i] - } - return a - } - - },{}],361:[function(require,module,exports){ - arguments[4][105][0].apply(exports,arguments) - },{"_process":353,"dup":105,"safe-buffer":364}],362:[function(require,module,exports){ - (function (process,global){(function (){ - 'use strict' - - function oldBrowser () { - throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') - } - var safeBuffer = require('safe-buffer') - var randombytes = require('randombytes') - var Buffer = safeBuffer.Buffer - var kBufferMaxLength = safeBuffer.kMaxLength - var crypto = global.crypto || global.msCrypto - var kMaxUint32 = Math.pow(2, 32) - 1 - function assertOffset (offset, length) { - if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare - throw new TypeError('offset must be a number') - } - - if (offset > kMaxUint32 || offset < 0) { - throw new TypeError('offset must be a uint32') - } - - if (offset > kBufferMaxLength || offset > length) { - throw new RangeError('offset out of range') - } - } - - function assertSize (size, offset, length) { - if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare - throw new TypeError('size must be a number') - } - - if (size > kMaxUint32 || size < 0) { - throw new TypeError('size must be a uint32') - } - - if (size + offset > length || size > kBufferMaxLength) { - throw new RangeError('buffer too small') - } - } - if ((crypto && crypto.getRandomValues) || !process.browser) { - exports.randomFill = randomFill - exports.randomFillSync = randomFillSync - } else { - exports.randomFill = oldBrowser - exports.randomFillSync = oldBrowser - } - function randomFill (buf, offset, size, cb) { - if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { - throw new TypeError('"buf" argument must be a Buffer or Uint8Array') - } - - if (typeof offset === 'function') { - cb = offset - offset = 0 - size = buf.length - } else if (typeof size === 'function') { - cb = size - size = buf.length - offset - } else if (typeof cb !== 'function') { - throw new TypeError('"cb" argument must be a function') - } - assertOffset(offset, buf.length) - assertSize(size, offset, buf.length) - return actualFill(buf, offset, size, cb) - } - - function actualFill (buf, offset, size, cb) { - if (process.browser) { - var ourBuf = buf.buffer - var uint = new Uint8Array(ourBuf, offset, size) - crypto.getRandomValues(uint) - if (cb) { - process.nextTick(function () { - cb(null, buf) - }) - return - } - return buf - } - if (cb) { - randombytes(size, function (err, bytes) { - if (err) { - return cb(err) - } - bytes.copy(buf, offset) - cb(null, buf) - }) - return - } - var bytes = randombytes(size) - bytes.copy(buf, offset) - return buf - } - function randomFillSync (buf, offset, size) { - if (typeof offset === 'undefined') { - offset = 0 - } - if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { - throw new TypeError('"buf" argument must be a Buffer or Uint8Array') - } - - assertOffset(offset, buf.length) - - if (size === undefined) size = buf.length - offset - - assertSize(size, offset, buf.length) - - return actualFill(buf, offset, size) - } - - }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - },{"_process":353,"randombytes":361,"safe-buffer":364}],363:[function(require,module,exports){ - arguments[4][121][0].apply(exports,arguments) - },{"buffer":266,"dup":121,"hash-base":305,"inherits":335}],364:[function(require,module,exports){ - arguments[4][122][0].apply(exports,arguments) - },{"buffer":266,"dup":122}],365:[function(require,module,exports){ - arguments[4][123][0].apply(exports,arguments) - },{"_process":353,"buffer":266,"dup":123}],366:[function(require,module,exports){ - arguments[4][127][0].apply(exports,arguments) - },{"dup":127,"safe-buffer":364}],367:[function(require,module,exports){ - arguments[4][128][0].apply(exports,arguments) - },{"./sha":368,"./sha1":369,"./sha224":370,"./sha256":371,"./sha384":372,"./sha512":373,"dup":128}],368:[function(require,module,exports){ - arguments[4][129][0].apply(exports,arguments) - },{"./hash":366,"dup":129,"inherits":335,"safe-buffer":364}],369:[function(require,module,exports){ - arguments[4][130][0].apply(exports,arguments) - },{"./hash":366,"dup":130,"inherits":335,"safe-buffer":364}],370:[function(require,module,exports){ - arguments[4][131][0].apply(exports,arguments) - },{"./hash":366,"./sha256":371,"dup":131,"inherits":335,"safe-buffer":364}],371:[function(require,module,exports){ - arguments[4][132][0].apply(exports,arguments) - },{"./hash":366,"dup":132,"inherits":335,"safe-buffer":364}],372:[function(require,module,exports){ - arguments[4][133][0].apply(exports,arguments) - },{"./hash":366,"./sha512":373,"dup":133,"inherits":335,"safe-buffer":364}],373:[function(require,module,exports){ - arguments[4][134][0].apply(exports,arguments) - },{"./hash":366,"dup":134,"inherits":335,"safe-buffer":364}],374:[function(require,module,exports){ - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - module.exports = Stream; - - var EE = require('events').EventEmitter; - var inherits = require('inherits'); - - inherits(Stream, EE); - Stream.Readable = require('readable-stream/lib/_stream_readable.js'); - Stream.Writable = require('readable-stream/lib/_stream_writable.js'); - Stream.Duplex = require('readable-stream/lib/_stream_duplex.js'); - Stream.Transform = require('readable-stream/lib/_stream_transform.js'); - Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js'); - Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js') - Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js') - - // Backwards-compat with node 0.4.x - Stream.Stream = Stream; - - - - // old-style streams. Note that the pipe method (the only relevant - // part of this class) is overridden in the Readable class. - - function Stream() { - EE.call(this); - } - - Stream.prototype.pipe = function(dest, options) { - var source = this; - - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } - - source.on('data', ondata); - - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } - - dest.on('drain', ondrain); - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } - - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; - - dest.end(); - } - - - function onclose() { - if (didOnEnd) return; - didOnEnd = true; - - if (typeof dest.destroy === 'function') dest.destroy(); - } - - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. - } - } - - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); - - source.removeListener('end', onend); - source.removeListener('close', onclose); - - source.removeListener('error', onerror); - dest.removeListener('error', onerror); - - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); - - dest.removeListener('close', cleanup); - } - - source.on('end', cleanup); - source.on('close', cleanup); - - dest.on('close', cleanup); - - dest.emit('pipe', source); - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; - }; - - },{"events":303,"inherits":335,"readable-stream/lib/_stream_duplex.js":376,"readable-stream/lib/_stream_passthrough.js":377,"readable-stream/lib/_stream_readable.js":378,"readable-stream/lib/_stream_transform.js":379,"readable-stream/lib/_stream_writable.js":380,"readable-stream/lib/internal/streams/end-of-stream.js":384,"readable-stream/lib/internal/streams/pipeline.js":386}],375:[function(require,module,exports){ - arguments[4][106][0].apply(exports,arguments) - },{"dup":106}],376:[function(require,module,exports){ - arguments[4][107][0].apply(exports,arguments) - },{"./_stream_readable":378,"./_stream_writable":380,"_process":353,"dup":107,"inherits":335}],377:[function(require,module,exports){ - arguments[4][108][0].apply(exports,arguments) - },{"./_stream_transform":379,"dup":108,"inherits":335}],378:[function(require,module,exports){ - arguments[4][109][0].apply(exports,arguments) - },{"../errors":375,"./_stream_duplex":376,"./internal/streams/async_iterator":381,"./internal/streams/buffer_list":382,"./internal/streams/destroy":383,"./internal/streams/from":385,"./internal/streams/state":387,"./internal/streams/stream":388,"_process":353,"buffer":266,"dup":109,"events":303,"inherits":335,"string_decoder/":389,"util":222}],379:[function(require,module,exports){ - arguments[4][110][0].apply(exports,arguments) - },{"../errors":375,"./_stream_duplex":376,"dup":110,"inherits":335}],380:[function(require,module,exports){ - arguments[4][111][0].apply(exports,arguments) - },{"../errors":375,"./_stream_duplex":376,"./internal/streams/destroy":383,"./internal/streams/state":387,"./internal/streams/stream":388,"_process":353,"buffer":266,"dup":111,"inherits":335,"util-deprecate":390}],381:[function(require,module,exports){ - arguments[4][112][0].apply(exports,arguments) - },{"./end-of-stream":384,"_process":353,"dup":112}],382:[function(require,module,exports){ - arguments[4][113][0].apply(exports,arguments) - },{"buffer":266,"dup":113,"util":222}],383:[function(require,module,exports){ - arguments[4][114][0].apply(exports,arguments) - },{"_process":353,"dup":114}],384:[function(require,module,exports){ - arguments[4][115][0].apply(exports,arguments) - },{"../../../errors":375,"dup":115}],385:[function(require,module,exports){ - arguments[4][116][0].apply(exports,arguments) - },{"dup":116}],386:[function(require,module,exports){ - arguments[4][117][0].apply(exports,arguments) - },{"../../../errors":375,"./end-of-stream":384,"dup":117}],387:[function(require,module,exports){ - arguments[4][118][0].apply(exports,arguments) - },{"../../../errors":375,"dup":118}],388:[function(require,module,exports){ - arguments[4][119][0].apply(exports,arguments) - },{"dup":119,"events":303}],389:[function(require,module,exports){ - arguments[4][135][0].apply(exports,arguments) - },{"dup":135,"safe-buffer":364}],390:[function(require,module,exports){ - arguments[4][179][0].apply(exports,arguments) - },{"dup":179}]},{},[181])(181) - }); - \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).casper=e()}}(function(){return function(){return function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){return i(t[a][1][e]||e)},c,c.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a0&&(10===arguments[0]?c||(c=!0,u.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?u.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",a.Logger.errors.UNEXPECTED_ARGUMENT,{}):u.throwError("BigNumber.toString does not accept parameters",a.Logger.errors.UNEXPECTED_ARGUMENT,{})),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.prototype.toJSON=function(e){return{type:"BigNumber",hex:this.toHexString()}},e.from=function(t){if(t instanceof e)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new e(f,l(t)):t.match(/^-?[0-9]+$/)?new e(f,l(new i(t))):u.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&y("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&y("overflow","BigNumber.from",t),e.from(String(t));var r,n=t;if("bigint"==typeof n)return e.from(n.toString());if(o.isBytes(n))return e.from(o.hexlify(n));if(n)if(n.toHexString){if("string"==typeof(r=n.toHexString()))return e.from(r)}else if(null==(r=n._hex)&&"BigNumber"===n.type&&(r=n.hex),"string"==typeof r&&(o.isHexString(r)||"-"===r[0]&&o.isHexString(r.substring(1))))return e.from(r);return u.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function l(e){if("string"!=typeof e)return l(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&u.throwArgumentError("invalid hex","value",e),"0x00"===(e=l(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return h.from(l(e))}function p(e){var t=h.from(e).toHexString();return"-"===t[0]?new i("-"+t.substring(3),16):new i(t.substring(2),16)}function y(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),u.throwError(e,a.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=h,r._base36To16=function(e){return new i(e,36).toString(16)},r._base16To36=function(e){return new i(e,16).toString(36)}},{"./_version":1,"@ethersproject/bytes":6,"@ethersproject/logger":13,"bn.js":45}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FixedNumber=r.FixedFormat=r.parseFixed=r.formatFixed=void 0;var n=e("@ethersproject/bytes"),i=e("@ethersproject/logger"),o=e("./_version"),a=new i.Logger(o.version),s=e("./bignumber"),u={},f=s.BigNumber.from(0),c=s.BigNumber.from(-1);function h(e,t,r,n){var o={fault:t,operation:r};return void 0!==n&&(o.value=n),a.throwError(e,i.Logger.errors.NUMERIC_FAULT,o)}for(var l="0";l.length<256;)l+=l;function d(e){if("number"!=typeof e)try{e=s.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+l.substring(0,e):a.throwArgumentError("invalid decimal size","decimals",e)}function p(e,t){null==t&&(t=0);var r=d(t),n=(e=s.BigNumber.from(e)).lt(f);n&&(e=e.mul(c));for(var i=e.mod(r).toString();i.length2&&a.throwArgumentError("too many decimal points","value",e);var o=i[0],u=i[1];for(o||(o="0"),u||(u="0"),u.length>r.length-1&&h("fractional component exceeds decimals","underflow","parseFixed");u.length80&&a.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new e(u,r,n,i)},e}();r.FixedFormat=b;var m=function(){function e(t,r,n,o){var s=this.constructor;a.checkNew(s,e),t!==u&&a.throwError("cannot use FixedNumber constructor; use FixedNumber.from",i.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=o,this._hex=r,this._value=n,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&a.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=y(this._value,this.format.decimals),n=y(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=y(this._value,this.format.decimals),n=y(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=y(this._value,this.format.decimals),n=y(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=y(this._value,this.format.decimals),n=y(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.floor=function(){var t=this.toString().split("."),r=e.from(t[0],this.format),n=!t[1].match(/^(0*)$/);return this.isNegative()&&n&&(r=r.subUnsafe(v)),r},e.prototype.ceiling=function(){var t=this.toString().split("."),r=e.from(t[0],this.format),n=!t[1].match(/^(0*)$/);return!this.isNegative()&&n&&(r=r.addUnsafe(v)),r},e.prototype.round=function(t){null==t&&(t=0);var r=this.toString().split(".");if((t<0||t>80||t%1)&&a.throwArgumentError("invalid decimal count","decimals",t),r[1].length<=t)return this;var n=e.from("1"+l.substring(0,t));return this.mulUnsafe(n).addUnsafe(g).floor().divUnsafe(n)},e.prototype.isZero=function(){return"0.0"===this._value},e.prototype.isNegative=function(){return"-"===this._value[0]},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&a.throwArgumentError("invalid byte width","width",e);var t=s.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return n.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||s.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(p(t,r),b.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var i=b.from(r),o=y(t,i.decimals);!i.signed&&o.lt(f)&&h("unsigned value cannot be negative","overflow","value",t);var a=null;i.signed?a=o.toTwos(i.width).toHexString():(a=o.toHexString(),a=n.hexZeroPad(a,i.width/8));var s=p(o,i.decimals);return new e(u,a,s,i)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=b.from(r);if(n.arrayify(t).length>i.width/8)throw new Error("overflow");var o=s.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),f=p(o,i.decimals);return new e(u,a,f,i)},e.from=function(t,r){if("string"==typeof t)return e.fromString(t,r);if(n.isBytes(t))return e.fromBytes(t,r);try{return e.fromValue(t,0,r)}catch(e){if(e.code!==i.Logger.errors.INVALID_ARGUMENT)throw e}return a.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();r.FixedNumber=m;var v=m.from(1),g=m.from("0.5")},{"./_version":1,"./bignumber":2,"@ethersproject/bytes":6,"@ethersproject/logger":13}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r._base36To16=r._base16To36=r.parseFixed=r.FixedNumber=r.FixedFormat=r.formatFixed=r.BigNumber=void 0;var n=e("./bignumber");Object.defineProperty(r,"BigNumber",{enumerable:!0,get:function(){return n.BigNumber}});var i=e("./fixednumber");Object.defineProperty(r,"formatFixed",{enumerable:!0,get:function(){return i.formatFixed}}),Object.defineProperty(r,"FixedFormat",{enumerable:!0,get:function(){return i.FixedFormat}}),Object.defineProperty(r,"FixedNumber",{enumerable:!0,get:function(){return i.FixedNumber}}),Object.defineProperty(r,"parseFixed",{enumerable:!0,get:function(){return i.parseFixed}});var o=e("./bignumber");Object.defineProperty(r,"_base16To36",{enumerable:!0,get:function(){return o._base16To36}}),Object.defineProperty(r,"_base36To16",{enumerable:!0,get:function(){return o._base36To16}})},{"./bignumber":2,"./fixednumber":3}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version=void 0,r.version="bytes/5.1.0"},{}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.joinSignature=r.splitSignature=r.hexZeroPad=r.hexStripZeros=r.hexValue=r.hexConcat=r.hexDataSlice=r.hexDataLength=r.hexlify=r.isHexString=r.zeroPad=r.stripZeros=r.concat=r.arrayify=r.isBytes=r.isBytesLike=void 0;var n=e("@ethersproject/logger"),i=e("./_version"),o=new n.Logger(i.version);function a(e){return!!e.toHexString}function s(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return s(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function u(e){return d(e)&&!(e.length%2)||f(e)}function f(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function c(e,t){if(t||(t={}),"number"==typeof e){o.checkSafeUint53(e,"invalid arrayify value");for(var r=[];e;)r.unshift(255&e),e=parseInt(String(e/256));return 0===r.length&&r.push(0),s(new Uint8Array(r))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),a(e)&&(e=e.toHexString()),d(e)){var n=e.substring(2);n.length%2&&("left"===t.hexPad?n="0x0"+n.substring(2):"right"===t.hexPad?n+="0":o.throwArgumentError("hex data is odd-length","value",e));r=[];for(var i=0;it&&o.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(t);return r.set(e,t-e.length),s(r)}function d(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}r.isBytesLike=u,r.isBytes=f,r.arrayify=c,r.concat=h,r.stripZeros=function(e){var t=c(e);if(0===t.length)return t;for(var r=0;r>4]+p[15&s]}return n}return o.throwArgumentError("invalid hexlify value","value",e)}function b(e){"string"!=typeof e&&(e=y(e)),d(e)||o.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&o.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function v(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(u(e)){var r=c(e);65!==r.length&&o.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=y(r.slice(0,32)),t.s=y(r.slice(32,64)),t.v=r[64],t.v<27&&(0===t.v||1===t.v?t.v+=27:o.throwArgumentError("signature invalid v byte","signature",e)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(r[32]|=128),t._vs=y(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t._vs){var n=l(c(t._vs),32);t._vs=y(n);var i=n[0]>=128?1:0;null==t.recoveryParam?t.recoveryParam=i:t.recoveryParam!==i&&o.throwArgumentError("signature recoveryParam mismatch _vs","signature",e),n[0]&=127;var a=y(n);null==t.s?t.s=a:t.s!==a&&o.throwArgumentError("signature v mismatch _vs","signature",e)}null==t.recoveryParam?null==t.v?o.throwArgumentError("signature missing v and recoveryParam","signature",e):0===t.v||1===t.v?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2:null==t.v?t.v=27+t.recoveryParam:t.recoveryParam!==1-t.v%2&&o.throwArgumentError("signature recoveryParam mismatch v","signature",e),null!=t.r&&d(t.r)?t.r=m(t.r,32):o.throwArgumentError("signature missing or invalid r","signature",e),null!=t.s&&d(t.s)?t.s=m(t.s,32):o.throwArgumentError("signature missing or invalid s","signature",e);var s=c(t.s);s[0]>=128&&o.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(s[0]|=128);var f=y(s);t._vs&&(d(t._vs)||o.throwArgumentError("signature invalid _vs","signature",e),t._vs=m(t._vs,32)),null==t._vs?t._vs=f:t._vs!==f&&o.throwArgumentError("signature _vs mismatch v and s","signature",e)}return t}r.hexlify=y,r.hexDataLength=function(e){if("string"!=typeof e)e=y(e);else if(!d(e)||e.length%2)return null;return(e.length-2)/2},r.hexDataSlice=function(e,t,r){return"string"!=typeof e?e=y(e):(!d(e)||e.length%2)&&o.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)},r.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=y(e).substring(2)}),t},r.hexValue=function(e){var t=b(y(e,{hexPad:"left"}));return"0x"===t?"0x0":t},r.hexStripZeros=b,r.hexZeroPad=m,r.splitSignature=v,r.joinSignature=function(e){return y(h([(e=v(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./_version":5,"@ethersproject/logger":13}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.AddressZero=void 0,r.AddressZero="0x0000000000000000000000000000000000000000"},{}],8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.MaxUint256=r.WeiPerEther=r.Two=r.One=r.Zero=r.NegativeOne=void 0;var n=e("@ethersproject/bignumber"),i=n.BigNumber.from(-1);r.NegativeOne=i;var o=n.BigNumber.from(0);r.Zero=o;var a=n.BigNumber.from(1);r.One=a;var s=n.BigNumber.from(2);r.Two=s;var u=n.BigNumber.from("1000000000000000000");r.WeiPerEther=u;var f=n.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");r.MaxUint256=f},{"@ethersproject/bignumber":4}],9:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HashZero=void 0,r.HashZero="0x0000000000000000000000000000000000000000000000000000000000000000"},{}],10:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EtherSymbol=r.HashZero=r.MaxUint256=r.WeiPerEther=r.Two=r.One=r.Zero=r.NegativeOne=r.AddressZero=void 0;var n=e("./addresses");Object.defineProperty(r,"AddressZero",{enumerable:!0,get:function(){return n.AddressZero}});var i=e("./bignumbers");Object.defineProperty(r,"NegativeOne",{enumerable:!0,get:function(){return i.NegativeOne}}),Object.defineProperty(r,"Zero",{enumerable:!0,get:function(){return i.Zero}}),Object.defineProperty(r,"One",{enumerable:!0,get:function(){return i.One}}),Object.defineProperty(r,"Two",{enumerable:!0,get:function(){return i.Two}}),Object.defineProperty(r,"WeiPerEther",{enumerable:!0,get:function(){return i.WeiPerEther}}),Object.defineProperty(r,"MaxUint256",{enumerable:!0,get:function(){return i.MaxUint256}});var o=e("./hashes");Object.defineProperty(r,"HashZero",{enumerable:!0,get:function(){return o.HashZero}});var a=e("./strings");Object.defineProperty(r,"EtherSymbol",{enumerable:!0,get:function(){return a.EtherSymbol}})},{"./addresses":7,"./bignumbers":8,"./hashes":9,"./strings":11}],11:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EtherSymbol=void 0,r.EtherSymbol="Ξ"},{}],12:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version=void 0,r.version="logger/5.1.0"},{}],13:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Logger=r.ErrorCode=r.LogLevel=void 0;var n=!1,i=!1,o={debug:1,default:2,info:2,warning:3,error:4,off:5},a=o.default,s=e("./_version"),u=null;var f,c,h=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(f=r.LogLevel||(r.LogLevel={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT"}(c=r.ErrorCode||(r.ErrorCode={}));var l=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype._log=function(e,t){var r=e.toLowerCase();null==o[r]&&this.throwArgumentError("invalid log level name","logLevel",e),a>o[r]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return u||(u=new e(s.version)),u},e.setCensorship=function(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),n){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}i=!!t,n=!!r},e.setLogLevel=function(t){var r=o[t.toLowerCase()];null!=r?a=r:e.globalLogger().warn("invalid log level - "+t)},e.from=function(t){return new e(t)},e.errors=c,e.levels=f,e}();r.Logger=l},{"./_version":12}],14:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)return n[0]},e.prototype.resolveRes=function(e,t){var r,n=e.id,o=e.error,a=this.pendingRequest[n];return a?(delete this.pendingRequest[n],this.processResult(e,a),void this.transportEventChannel.emit("response",e)):void 0!==n||void 0!==o?(o&&(r=i.convertJSONToRPCError(e)),t&&o&&r&&this.transportEventChannel.emit("error",r),r):void this.transportEventChannel.emit("notification",e)},e.prototype.setRequestTimeout=function(e,t,r){var n=this;setTimeout(function(){delete n.pendingRequest[e],r(new i.JSONRPCError("Request timeout request took longer than "+t+" ms to resolve",i.ERR_TIMEOUT))},t)},e}();r.TransportRequestManager=o},{"../Error":15,events:303}],25:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=a.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128){const e=i.alloc(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let s=1;for(let e=n.length;e>=256;e>>=8)s++;const u=i.alloc(2+s);u[0]=o,u[1]=128|s;for(let e=1+s,t=n.length;t>0;e--,t>>=8)u[e]=255&t;return this._createEncoderBuffer([u,n])},u.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=i.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const o=i.alloc(n);let a=o.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(o[a--]=127&r;(r>>=7)>0;)o[a--]=128|127&r}return this._createEncoderBuffer(o)},u.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[f(n.getUTCFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getUTCFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=i.from(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=i.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(i.from(n))},u.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},u.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},u.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);e[r];){var h=t[e.charCodeAt(r)];if(255===h)return;for(var l=0,d=a-1;(0!==h||l>>0,c[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==e[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var y=n.allocUnsafe(i+(a-p));y.fill(0,0,i);for(var b=i;p!==a;)y[b++]=c[p++];return y}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,a=t.length;o!==a&&0===t[o];)o++,r++;for(var f=(a-o)*c+1>>>0,h=new Uint8Array(f);o!==a;){for(var l=t[o],d=0,p=f-1;(0!==l||d>>0,h[p]=l%s>>>0,l=l/s>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var y=f-i;y!==f&&0===h[y];)y++;for(var b=u.repeat(r);y=4294967296&&i++,e[t]=n,e[t+1]=i}function o(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var o=e[t+1]+n;i>=4294967296&&o++,e[t]=i,e[t+1]=o}function a(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function s(e,t,r,n,a,s){var u=h[a],f=h[a+1],l=h[s],d=h[s+1];i(c,e,t),o(c,e,u,f);var p=c[n]^c[e],y=c[n+1]^c[e+1];c[n]=y,c[n+1]=p,i(c,r,n),p=c[t]^c[r],y=c[t+1]^c[r+1],c[t]=p>>>24^y<<8,c[t+1]=y>>>24^p<<8,i(c,e,t),o(c,e,l,d),p=c[n]^c[e],y=c[n+1]^c[e+1],c[n]=p>>>16^y<<16,c[n+1]=y>>>16^p<<16,i(c,r,n),p=c[t]^c[r],y=c[t+1]^c[r+1],c[t]=y>>>31^p<<1,c[t+1]=p>>>31^y<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),f=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(e){return 2*e})),c=new Uint32Array(32),h=new Uint32Array(32);function l(e,t){var r=0;for(r=0;r<16;r++)c[r]=e.h[r],c[r+16]=u[r];for(c[24]=c[24]^e.t,c[25]=c[25]^e.t/4294967296,t&&(c[28]=~c[28],c[29]=~c[29]),r=0;r<32;r++)h[r]=a(e.b,4*r);for(r=0;r<12;r++)s(0,8,16,24,f[16*r+0],f[16*r+1]),s(2,10,18,26,f[16*r+2],f[16*r+3]),s(4,12,20,28,f[16*r+4],f[16*r+5]),s(6,14,22,30,f[16*r+6],f[16*r+7]),s(0,10,20,30,f[16*r+8],f[16*r+9]),s(2,12,22,24,f[16*r+10],f[16*r+11]),s(4,14,16,26,f[16*r+12],f[16*r+13]),s(6,8,18,28,f[16*r+14],f[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^c[r]^c[r+16]}function d(e,t){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=u[n];var i=t?t.length:0;return r.h[0]^=16842752^i<<8^e,t&&(p(r,t),r.c=128),r}function p(e,t){for(var r=0;r>2]>>8*(3&r);return t}function b(e,t,r){r=r||64,e=n.normalizeInput(e);var i=d(r,t);return p(i,e),y(i)}t.exports={blake2b:b,blake2bHex:function(e,t,r){var i=b(e,t,r);return n.toHex(i)},blake2bInit:d,blake2bUpdate:p,blake2bFinal:y}},{"./util":44}],42:[function(e,t,r){var n=e("./util");function i(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function o(e,t,r,n,i,o){f[e]=f[e]+f[t]+i,f[n]=a(f[n]^f[e],16),f[r]=f[r]+f[n],f[t]=a(f[t]^f[r],12),f[e]=f[e]+f[t]+o,f[n]=a(f[n]^f[e],8),f[r]=f[r]+f[n],f[t]=a(f[t]^f[r],7)}function a(e,t){return e>>>t^e<<32-t}var s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=new Uint32Array(16),c=new Uint32Array(16);function h(e,t){var r=0;for(r=0;r<8;r++)f[r]=e.h[r],f[r+8]=s[r];for(f[12]^=e.t,f[13]^=e.t/4294967296,t&&(f[14]=~f[14]),r=0;r<16;r++)c[r]=i(e.b,4*r);for(r=0;r<10;r++)o(0,4,8,12,c[u[16*r+0]],c[u[16*r+1]]),o(1,5,9,13,c[u[16*r+2]],c[u[16*r+3]]),o(2,6,10,14,c[u[16*r+4]],c[u[16*r+5]]),o(3,7,11,15,c[u[16*r+6]],c[u[16*r+7]]),o(0,5,10,15,c[u[16*r+8]],c[u[16*r+9]]),o(1,6,11,12,c[u[16*r+10]],c[u[16*r+11]]),o(2,7,8,13,c[u[16*r+12]],c[u[16*r+13]]),o(3,4,9,14,c[u[16*r+14]],c[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=f[r]^f[r+8]}function l(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(s),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(d(n,t),n.c=64),n}function d(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function y(e,t,r){r=r||32,e=n.normalizeInput(e);var i=l(r,t);return d(i,e),p(i)}t.exports={blake2s:y,blake2sHex:function(e,t,r){var i=y(e,t,r);return n.toHex(i)},blake2sInit:l,blake2sUpdate:d,blake2sFinal:p}},{"./util":44}],43:[function(e,t,r){var n=e("./blake2b"),i=e("./blake2s");t.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:i.blake2s,blake2sHex:i.blake2sHex,blake2sInit:i.blake2sInit,blake2sUpdate:i.blake2sUpdate,blake2sFinal:i.blake2sFinal}},{"./blake2b":41,"./blake2s":42}],44:[function(e,t,r){(function(e){(function(){var r="Input must be an string, Buffer or Uint8Array";function n(e){return(4294967296+e).toString(16).substring(1)}t.exports={normalizeInput:function(t){var n;if(t instanceof Uint8Array)n=t;else if(t instanceof e)n=new Uint8Array(t);else{if("string"!=typeof t)throw new Error(r);n=new Uint8Array(e.from(t,"utf8"))}return n},toHex:function(e){return Array.prototype.map.call(e,function(e){return(e<16?"0":"")+e.toString(16)}).join("")},debugPrint:function(e,t,r){for(var i="\n"+e+" = ",o=0;o=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function f(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,h=67108863&u,l=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=l;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[f]=0|h,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=h[e],d=l[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:c[f-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,y=d>>>13,b=0|a[2],m=8191&b,v=b>>>13,g=0|a[3],w=8191&g,_=g>>>13,M=0|a[4],S=8191&M,E=M>>>13,A=0|a[5],k=8191&A,B=A>>>13,T=0|a[6],j=8191&T,x=T>>>13,P=0|a[7],O=8191&P,R=P>>>13,I=0|a[8],C=8191&I,N=I>>>13,U=0|a[9],D=8191&U,L=U>>>13,K=0|s[0],z=8191&K,q=K>>>13,H=0|s[1],F=8191&H,V=H>>>13,W=0|s[2],J=8191&W,Z=W>>>13,G=0|s[3],X=8191&G,Y=G>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],he=8191&ce,le=ce>>>13,de=0|s[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(f+(n=Math.imul(h,z))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,z)|0))<<13)|0;f=((o=Math.imul(l,q))+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,q))+Math.imul(y,z)|0,o=Math.imul(y,q);var me=(f+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,F)|0))<<13)|0;f=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,z),i=(i=Math.imul(m,q))+Math.imul(v,z)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(y,F)|0,o=o+Math.imul(y,V)|0;var ve=(f+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;f=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,q))+Math.imul(_,z)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Z)|0;var ge=(f+(n=n+Math.imul(h,X)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,X)|0))<<13)|0;f=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(S,z),i=(i=Math.imul(S,q))+Math.imul(E,z)|0,o=Math.imul(E,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,Y)|0;var we=(f+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;f=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(k,z),i=(i=Math.imul(k,q))+Math.imul(B,z)|0,o=Math.imul(B,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(E,F)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;f=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,q))+Math.imul(x,z)|0,o=Math.imul(x,q),n=n+Math.imul(k,F)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,V)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Me=(f+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;f=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,q))+Math.imul(R,z)|0,o=Math.imul(R,q),n=n+Math.imul(j,F)|0,i=(i=i+Math.imul(j,V)|0)+Math.imul(x,F)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,Y)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0;var Se=(f+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(l,ue)|0))<<13)|0;f=((o=o+Math.imul(l,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,q))+Math.imul(N,z)|0,o=Math.imul(N,q),n=n+Math.imul(O,F)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(j,J)|0,i=(i=i+Math.imul(j,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,fe)|0;var Ee=(f+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;f=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(D,z),i=(i=Math.imul(D,q))+Math.imul(L,z)|0,o=Math.imul(L,q),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(N,F)|0,o=o+Math.imul(N,V)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(j,X)|0,i=(i=i+Math.imul(j,Y)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,le)|0;var Ae=(f+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(l,pe)|0))<<13)|0;f=((o=o+Math.imul(l,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,V))+Math.imul(L,F)|0,o=Math.imul(L,V),n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,Z)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,Y)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(j,Q)|0,i=(i=i+Math.imul(j,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var ke=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,Z))+Math.imul(L,J)|0,o=Math.imul(L,Z),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(j,re)|0,i=(i=i+Math.imul(j,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,fe)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Be=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,Y))+Math.imul(L,X)|0,o=Math.imul(L,Y),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(j,oe)|0,i=(i=i+Math.imul(j,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(B,ue)|0,o=o+Math.imul(B,fe)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(E,he)|0,o=o+Math.imul(E,le)|0;var Te=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,ee))+Math.imul(L,Q)|0,o=Math.imul(L,ee),n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(j,ue)|0,i=(i=i+Math.imul(j,fe)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,fe)|0,n=n+Math.imul(k,he)|0,i=(i=i+Math.imul(k,le)|0)+Math.imul(B,he)|0,o=o+Math.imul(B,le)|0;var je=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(E,pe)|0))<<13)|0;f=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(j,he)|0,i=(i=i+Math.imul(j,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(B,pe)|0))<<13)|0;f=((o=o+Math.imul(B,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(O,he)|0,i=(i=i+Math.imul(O,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Pe=(f+(n=n+Math.imul(j,pe)|0)|0)+((8191&(i=(i=i+Math.imul(j,ye)|0)+Math.imul(x,pe)|0))<<13)|0;f=((o=o+Math.imul(x,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,ue),i=(i=Math.imul(D,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(C,he)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,le)|0;var Oe=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(L,he)|0,o=Math.imul(L,le);var Re=(f+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,ye)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ie=(f+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,ye))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ye))+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,u[0]=be,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Me,u[7]=Se,u[8]=Ee,u[9]=Ae,u[10]=ke,u[11]=Be,u[12]=Te,u[13]=je,u[14]=xe,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ie,0!==f&&(u[19]=f,r.length++),r};function y(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):y(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var h=0|this.words[f];this.words[f]=c<<26-o|h>>>o,c=h&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new S(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var m={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(g,v),g.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},g.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(m[e])return m[e];var t;if("k256"===e)t=new g;else if("p224"===e)t=new w;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new M}return m[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var h=this.pow(c,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var y=d,b=0;0!==y.cmp(s);b++)y=y.redSqr();n(b=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var h=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,S),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:222}],46:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;rr)?t=("rmd160"===e?new u:f(e)).update(t).digest():t.lengths?t=e(t):t.length0&&e.compare(u)<0);var t}function l(e){var t=new Uint8Array(e);return void 0===o.getRandomValues?n.from(s.randomBytes(e)):(o.getRandomValues(t),n.from(t))}function d(e){return new Promise(function(t){var r=s.createHash("sha512").update(e).digest();t(new Uint8Array(r))})}function p(e){return function(t,r,i){return new Promise(function(o){if(a){return a.importKey("raw",r,{name:"AES-CBC"},!1,[e]).then(function(r){var n={name:"AES-CBC",iv:t};return a[e](n,r,i)}).then(function(e){o(n.from(new Uint8Array(e)))})}if("encrypt"===e){var u=s.createCipheriv("aes-256-cbc",r,t);let e=u.update(i),a=u.final();o(n.concat([e,a]))}else if("decrypt"===e){var f=s.createDecipheriv("aes-256-cbc",r,t);let e=f.update(i),a=f.final();o(n.concat([e,a]))}})}}var y=p("encrypt"),b=p("decrypt");r.generatePrivate=function(){for(var e=l(32);!h(e);)e=l(32);return e};var m=r.getPublic=function(e){return c(32===e.length,"Bad private key"),c(h(e),"Bad private key"),n.from(i.keyFromPrivate(e).getPublic("arr"))};r.getPublicCompressed=function(e){c(32===e.length,"Bad private key"),c(h(e),"Bad private key");return n.from(i.keyFromPrivate(e).getPublic(!0,"arr"))};r.sign=function(e,t){return new Promise(function(r){c(32===e.length,"Bad private key"),c(h(e),"Bad private key"),c(t.length>0,"Message should not be empty"),c(t.length<=32,"Message is too long"),r(n.from(i.sign(t,e,{canonical:!0}).toDER()))})},r.verify=function(e,t,r){return new Promise(function(n,o){c(65===e.length||33===e.length,"Bad public key"),65===e.length&&c(4===e[0],"Bad public key"),33===e.length&&c(2===e[0]||3===e[0],"Bad public key"),c(t.length>0,"Message should not be empty"),c(t.length<=32,"Message is too long"),i.verify(t,r,e)?n(null):o(new Error("Bad signature"))})};var v=r.derive=function(e,t){return new Promise(function(r){c(n.isBuffer(e),"Bad private key"),c(n.isBuffer(t),"Bad public key"),c(32===e.length,"Bad private key"),c(h(e),"Bad private key"),c(65===t.length||33===t.length,"Bad public key"),65===t.length&&c(4===t[0],"Bad public key"),33===t.length&&c(2===t[0]||3===t[0],"Bad public key");var o=i.keyFromPrivate(e),a=i.keyFromPublic(t),s=o.derive(a.getPublic());r(n.from(s.toArray()))})};r.encrypt=function(e,t,r){var i,o,a,u;return r=r||{},new Promise(function(t){for(var n=r.ephemPrivateKey||l(32);!h(n);)n=r.ephemPrivateKey||l(32);o=m(n),t(v(n,e))}).then(function(e){return d(e)}).then(function(e){i=r.iv||l(16);var n=e.slice(0,32);return u=e.slice(32),y(i,n,t)}).then(function(e){a=e;var t,r,f=n.concat([i,o,a]);return t=u,r=f,new Promise(function(e){var i=s.createHmac("sha256",n.from(t));i.update(r),e(i.digest())})}).then(function(e){return{iv:i,ephemPublicKey:o,ciphertext:a,mac:e}})},r.decrypt=function(e,t){var r;return v(e,t.ephemPublicKey).then(function(e){return d(e)}).then(function(e){r=e.slice(0,32);var i,o,a,u=e.slice(32),f=n.concat([t.iv,t.ephemPublicKey,t.ciphertext]);return i=u,o=f,a=t.mac,new Promise(function(e){var t=s.createHmac("sha256",n.from(i));t.update(o),e(function(e,t){if(e.length!==t.length)return!1;for(var r=0,n=0;n0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=a;c--)u=(u<<1)+n[c];f.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(a=0;a=0;f--){for(var c=0;f>=0&&0===a[f];f--)c++;if(f>=0&&c++,u=u.dblp(c),f<0)break;var h=a[f];s(0!==h),u="affine"===e.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){var s,u,f,c=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(s=0;s=1;s-=2){var y=s-1,b=s;if(1===c[y]&&1===c[b]){var m=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(m[1]=t[y].add(t[b]),m[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(m[1]=t[y].toJ().mixedAdd(t[b]),m[2]=t[y].add(t[b].neg())):(m[1]=t[y].toJ().mixedAdd(t[b]),m[2]=t[y].toJ().mixedAdd(t[b].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],g=a(r[y],r[b]);for(d=Math.max(g[0].length,d),l[y]=new Array(d),l[b]=new Array(d),u=0;u=0;s--){for(var E=0;s>=0;){var A=!0;for(u=0;u=0&&E++,M=M.dblp(E),s<0)break;for(u=0;u0?f=h[u][k-1>>1]:k<0&&(f=h[u][-k-1>>1].neg()),M="affine"===f.type?M.mixedAdd(f):M.add(f))}}for(s=0;s=Math.ceil((e.bitLength()+1)/t.step)},f.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),f=o.redMul(s),c=i.redMul(s),h=a.redMul(o);return this.curve.point(u,f,h,c)},f.prototype._projDbl=function(){var e,t,r,n,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var f=(n=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(f.redSub(this.curve.two)),t=f.redMul(n.redSub(u)),r=f.redSqr().redSub(f).redSub(f)):(i=this.z.redSqr(),o=f.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=f.redMul(n.redSub(u)),r=f.redMul(o))}else n=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(s.redISub(u)),r=n.redMul(o);return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),f=o.redMul(a),c=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(f,c,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),f=i.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(c);return this.curve.twisted?(t=n.redMul(f).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(f)):(t=n.redMul(f).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(f)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../utils":70,"./base":57,"bn.js":45,inherits:97}],59:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":57,"./edwards":58,"./mont":60,"./short":61}],60:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("inherits"),o=e("./base"),a=e("../utils");function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),t.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(u,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new u(this,e,t)},s.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":70,"./base":57,"bn.js":45,inherits:97}],61:[function(e,t,r){"use strict";var n=e("../utils"),i=e("bn.js"),o=e("inherits"),a=e("./base"),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),t.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new i(e.a,16),b:new i(e.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,f,c,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new i(1),y=new i(0),b=new i(0),m=new i(1),v=0;0!==l.cmpn(0);){var g=d.div(l);f=d.sub(g.mul(l)),c=b.sub(g.mul(p));var w=m.sub(g.mul(y));if(!n&&f.cmp(h)<0)t=u.neg(),r=p,n=f.neg(),o=c;else if(n&&2==++v)break;u=f,d=l,l=f,b=p,p=c,m=y,y=w}a=f.neg(),s=c;var _=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a:a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new c(this,e,t,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),h=n.redMul(f),l=u.redSqr().redIAdd(c).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),h=s.redSqr().redIAdd(f).redISub(c).redISub(c),l=s.redMul(c.redISub(h)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":70,"./base":57,"bn.js":45,inherits:97}],62:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("./curve"),s=e("./utils").assert;function u(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":59,"./precomputed/secp256k1":69,"./utils":70,"hash.js":83}],63:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../utils"),a=e("../curves"),s=e("brorand"),u=o.assert,f=e("./key"),c=e("./signature");function h(e){if(!(this instanceof h))return new h(e);"string"==typeof e&&(u(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=h,h.prototype.keyPair=function(e){return new f(this,e)},h.prototype.keyFromPrivate=function(e,t){return f.fromPrivate(this,e,t)},h.prototype.keyFromPublic=function(e,t){return f.fromPublic(this,e,t)},h.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(o)>0))return a.iaddn(1),this.keyFromPrivate(a)}},h.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},h.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var y=p.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var m=d.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new c({r:b,s:m,recoveryParam:v})}}}}}},h.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),f=u.mul(e).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),s=t.r,f=t.s,h=1&r,l=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");s=l?this.curve.pointFromX(s.add(this.curve.n),h):this.curve.pointFromX(s,h);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),y=f.mul(d).umod(o);return this.g.mulAdd(p,s,y)},h.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":62,"../utils":70,"./key":64,"./signature":65,"bn.js":45,brorand:46,"hmac-drbg":95}],64:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../utils").assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.validate()||i(e.validate(),"public point not validated"),e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../utils":70,"bn.js":45}],65:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../utils"),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function f(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var f=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var c=u(e,r);if(!1===c)return!1;if(e.length!==c+r.place)return!1;var h=e.slice(r.place,c+r.place);if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new n(f),this.s=new n(h),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=f(t),r=f(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../utils":70,"bn.js":45}],66:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../curves"),o=e("../utils"),a=o.assert,s=o.parseBytes,u=e("./key"),f=e("./signature");function c(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=c,c.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},c.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},c.prototype.hashInt=function(){for(var e=this.hash(),t=0;t(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var a,s,u=e.andln(3)+i&3,f=t.andln(3)+o&3;3===u&&(u=-1),3===f&&(f=-1),a=0==(1&u)?0:3!=(n=e.andln(7)+i&7)&&5!==n||2!==f?u:-u,r[0].push(a),s=0==(1&f)?0:3!=(n=t.andln(7)+o&7)&&5!==n||2!==u?f:-f,r[1].push(s),2*i===a+1&&(i=1-i),2*o===s+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":45,"minimalistic-assert":103,"minimalistic-crypto-utils":104}],71:[function(e,t,r){t.exports={_args:[["elliptic@6.5.4","/Users/apple/casper"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/browserify-sign","/create-ecdh","/eccrypto","/eccrypto/secp256k1","/key-encoder","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/apple/casper",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],72:[function(e,t,r){(function(e){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createHashFunction=function(t){return function(r){var n=t();return n.update(r),e.from(n.digest())}}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:266}],73:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./vendor/hdkey-without-crypto");r.HDKey=n},{"./vendor/hdkey-without-crypto":78}],74:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("hash.js/lib/hash/ripemd").ripemd160,i=e("../hash-utils");r.ripemd160=i.createHashFunction(function(){return new n})},{"../hash-utils":72,"hash.js/lib/hash/ripemd":86}],75:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("hash.js/lib/hash/sha/256"),i=e("../hash-utils");r.sha256=i.createHashFunction(function(){return new n})},{"../hash-utils":72,"hash.js/lib/hash/sha/256":90}],76:[function(e,t,r){(function(t){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("../ripemd160"),i=e("../sha256");r.createHmac=e("create-hmac"),r.randomBytes=e("randombytes");var o=function(){function e(e){this.hashFunction=e,this.buffers=[]}return e.prototype.update=function(e){if(!t.isBuffer(e))throw new Error("hdkey-crypto shim is outdated");return this.buffers.push(e),this},e.prototype.digest=function(e){if(e)throw new Error("hdkey-crypto shim is outdated");return this.hashFunction(t.concat(this.buffers))},e}();r.createHash=function(e){if("ripemd160"===e)return new o(n.ripemd160);if("sha256"===e)return new o(i.sha256);throw new Error("hdkey-crypto shim is outdated")}}).call(this)}).call(this,e("buffer").Buffer)},{"../ripemd160":74,"../sha256":75,buffer:266,"create-hmac":53,randombytes:105}],77:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(e("../../shims/hdkey-secp256k1v3"))},{"../../shims/hdkey-secp256k1v3":81}],78:[function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=n(e("assert")),o=n(e("safe-buffer")),a=n(e("bs58check")),s=e("../shims/hdkey-crypto"),u=e("../shims/hdkey-secp256k1v3"),f=o.Buffer,c=f.from("Bitcoin seed","utf8"),h=78,l={private:76066276,public:76067358};function d(e){this.versions=e||l,this.depth=0,this.index=0,this._privateKey=null,this._publicKey=null,this.chainCode=null,this._fingerprint=0,this.parentFingerprint=0}function p(e,t,r){var n=f.allocUnsafe(h);n.writeUInt32BE(t,0),n.writeUInt8(e.depth,4);var i=e.depth?e.parentFingerprint:0;return n.writeUInt32BE(i,5),n.writeUInt32BE(e.index,9),e.chainCode.copy(n,13),r.copy(n,45),n}function y(e){var t=s.createHash("sha256").update(e).digest();return s.createHash("ripemd160").update(t).digest()}Object.defineProperty(d.prototype,"fingerprint",{get:function(){return this._fingerprint}}),Object.defineProperty(d.prototype,"identifier",{get:function(){return this._identifier}}),Object.defineProperty(d.prototype,"pubKeyHash",{get:function(){return this.identifier}}),Object.defineProperty(d.prototype,"privateKey",{get:function(){return this._privateKey},set:function(e){i.equal(e.length,32,"Private key must be 32 bytes."),i(!0===u.privateKeyVerify(e),"Invalid private key"),this._privateKey=e,this._publicKey=u.publicKeyCreate(e,!0),this._identifier=y(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0)}}),Object.defineProperty(d.prototype,"publicKey",{get:function(){return this._publicKey},set:function(e){i(33===e.length||65===e.length,"Public key must be 33 or 65 bytes."),i(!0===u.publicKeyVerify(e),"Invalid public key"),this._publicKey=u.publicKeyConvert(e,!0),this._identifier=y(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0),this._privateKey=null}}),Object.defineProperty(d.prototype,"privateExtendedKey",{get:function(){return this._privateKey?a.encode(p(this,this.versions.private,f.concat([f.alloc(1,0),this.privateKey]))):null}}),Object.defineProperty(d.prototype,"publicExtendedKey",{get:function(){return a.encode(p(this,this.versions.public,this.publicKey))}}),d.prototype.derive=function(e){if("m"===e||"M"===e||"m'"===e||"M'"===e)return this;var t=e.split("/"),r=this;return t.forEach(function(e,t){if(0!==t){var n=e.length>1&&"'"===e[e.length-1],o=parseInt(e,10);i(o<2147483648,"Invalid index"),n&&(o+=2147483648),r=r.deriveChild(o)}else i(/^[mM]{1}/.test(e),'Path must start with "m" or "M"')}),r},d.prototype.deriveChild=function(e){var t,r=e>=2147483648,n=f.allocUnsafe(4);if(n.writeUInt32BE(e,0),r){i(this.privateKey,"Could not derive hardened child key");var o=this.privateKey,a=f.alloc(1,0);o=f.concat([a,o]),t=f.concat([o,n])}else t=f.concat([this.publicKey,n]);var c=s.createHmac("sha512",this.chainCode).update(t).digest(),h=c.slice(0,32),l=c.slice(32),p=new d(this.versions);if(this.privateKey)try{p.privateKey=u.privateKeyTweakAdd(this.privateKey,h)}catch(t){return this.deriveChild(e+1)}else try{p.publicKey=u.publicKeyTweakAdd(this.publicKey,h,!0)}catch(t){return this.deriveChild(e+1)}return p.chainCode=l,p.depth=this.depth+1,p.parentFingerprint=this.fingerprint,p.index=e,p},d.prototype.sign=function(e){return u.sign(e,this.privateKey).signature},d.prototype.verify=function(e,t){return u.verify(e,t,this.publicKey)},d.prototype.wipePrivateData=function(){return this._privateKey&&s.randomBytes(this._privateKey.length).copy(this._privateKey),this._privateKey=null,this},d.prototype.toJSON=function(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}},d.fromMasterSeed=function(e,t){var r=s.createHmac("sha512",c).update(e).digest(),n=r.slice(0,32),i=r.slice(32),o=new d(t);return o.chainCode=i,o.privateKey=n,o},d.fromExtendedKey=function(e,t){var r=new d(t=t||l),n=a.decode(e),o=n.readUInt32BE(0);i(o===t.private||o===t.public,"Version mismatch: does not match private or public"),r.depth=n.readUInt8(4),r.parentFingerprint=n.readUInt32BE(5),r.index=n.readUInt32BE(9),r.chainCode=n.slice(13,45);var s=n.slice(45);return 0===s.readUInt8(0)?(i(o===t.private,"Version mismatch: version does not match private"),r.privateKey=s.slice(1)):(i(o===t.public,"Version mismatch: version does not match public"),r.publicKey=s),r},d.fromJSON=function(e){return d.fromExtendedKey(e.xpriv)},d.HARDENED_OFFSET=2147483648;var b=d;t.exports=b},{"../shims/hdkey-crypto":76,"../shims/hdkey-secp256k1v3":77,assert:215,bs58check:49,"safe-buffer":122}],79:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("randombytes");r.getRandomBytes=function(e){return new Promise(function(t,r){n(e,function(e,n){e?r(e):t(n)})})},r.getRandomBytesSync=function(e){return n(e)}},{randombytes:105}],80:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:97,"readable-stream":120,"safe-buffer":122}],83:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":84,"./hash/hmac":85,"./hash/ripemd":86,"./hash/sha":87,"./hash/utils":94}],84:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){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}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":94}],94:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,f){var c=0,h=t;return c+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:97,"minimalistic-assert":103}],95:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length2&&e<11?"دقائق":"دقيقة"},s:function(e){return 1===e?"ثانية":"ثواني"},ms:function(e){return 1===e?"جزء من الثانية":"أجزاء من الثانية"},decimal:","},bg:{y:function(e){return["години","година","години"][u(e)]},mo:function(e){return["месеца","месец","месеца"][u(e)]},w:function(e){return["седмици","седмица","седмици"][u(e)]},d:function(e){return["дни","ден","дни"][u(e)]},h:function(e){return["часа","час","часа"][u(e)]},m:function(e){return["минути","минута","минути"][u(e)]},s:function(e){return["секунди","секунда","секунди"][u(e)]},ms:function(e){return["милисекунди","милисекунда","милисекунди"][u(e)]},decimal:","},ca:{y:function(e){return"any"+(1===e?"":"s")},mo:function(e){return"mes"+(1===e?"":"os")},w:function(e){return"setman"+(1===e?"a":"es")},d:function(e){return"di"+(1===e?"a":"es")},h:function(e){return"hor"+(1===e?"a":"es")},m:function(e){return"minut"+(1===e?"":"s")},s:function(e){return"segon"+(1===e?"":"s")},ms:function(e){return"milisegon"+(1===e?"":"s")},decimal:","},cs:{y:function(e){return["rok","roku","roky","let"][f(e)]},mo:function(e){return["měsíc","měsíce","měsíce","měsíců"][f(e)]},w:function(e){return["týden","týdne","týdny","týdnů"][f(e)]},d:function(e){return["den","dne","dny","dní"][f(e)]},h:function(e){return["hodina","hodiny","hodiny","hodin"][f(e)]},m:function(e){return["minuta","minuty","minuty","minut"][f(e)]},s:function(e){return["sekunda","sekundy","sekundy","sekund"][f(e)]},ms:function(e){return["milisekunda","milisekundy","milisekundy","milisekund"][f(e)]},decimal:","},da:{y:"år",mo:function(e){return"måned"+(1===e?"":"er")},w:function(e){return"uge"+(1===e?"":"r")},d:function(e){return"dag"+(1===e?"":"e")},h:function(e){return"time"+(1===e?"":"r")},m:function(e){return"minut"+(1===e?"":"ter")},s:function(e){return"sekund"+(1===e?"":"er")},ms:function(e){return"millisekund"+(1===e?"":"er")},decimal:","},de:{y:function(e){return"Jahr"+(1===e?"":"e")},mo:function(e){return"Monat"+(1===e?"":"e")},w:function(e){return"Woche"+(1===e?"":"n")},d:function(e){return"Tag"+(1===e?"":"e")},h:function(e){return"Stunde"+(1===e?"":"n")},m:function(e){return"Minute"+(1===e?"":"n")},s:function(e){return"Sekunde"+(1===e?"":"n")},ms:function(e){return"Millisekunde"+(1===e?"":"n")},decimal:","},el:e,en:{y:function(e){return"year"+(1===e?"":"s")},mo:function(e){return"month"+(1===e?"":"s")},w:function(e){return"week"+(1===e?"":"s")},d:function(e){return"day"+(1===e?"":"s")},h:function(e){return"hour"+(1===e?"":"s")},m:function(e){return"minute"+(1===e?"":"s")},s:function(e){return"second"+(1===e?"":"s")},ms:function(e){return"millisecond"+(1===e?"":"s")},decimal:"."},es:{y:function(e){return"año"+(1===e?"":"s")},mo:function(e){return"mes"+(1===e?"":"es")},w:function(e){return"semana"+(1===e?"":"s")},d:function(e){return"día"+(1===e?"":"s")},h:function(e){return"hora"+(1===e?"":"s")},m:function(e){return"minuto"+(1===e?"":"s")},s:function(e){return"segundo"+(1===e?"":"s")},ms:function(e){return"milisegundo"+(1===e?"":"s")},decimal:","},et:{y:function(e){return"aasta"+(1===e?"":"t")},mo:function(e){return"kuu"+(1===e?"":"d")},w:function(e){return"nädal"+(1===e?"":"at")},d:function(e){return"päev"+(1===e?"":"a")},h:function(e){return"tund"+(1===e?"":"i")},m:function(e){return"minut"+(1===e?"":"it")},s:function(e){return"sekund"+(1===e?"":"it")},ms:function(e){return"millisekund"+(1===e?"":"it")},decimal:","},fa:{y:"سال",mo:"ماه",w:"هفته",d:"روز",h:"ساعت",m:"دقیقه",s:"ثانیه",ms:"میلی ثانیه",decimal:"."},fi:{y:function(e){return 1===e?"vuosi":"vuotta"},mo:function(e){return 1===e?"kuukausi":"kuukautta"},w:function(e){return"viikko"+(1===e?"":"a")},d:function(e){return"päivä"+(1===e?"":"ä")},h:function(e){return"tunti"+(1===e?"":"a")},m:function(e){return"minuutti"+(1===e?"":"a")},s:function(e){return"sekunti"+(1===e?"":"a")},ms:function(e){return"millisekunti"+(1===e?"":"a")},decimal:","},fo:{y:"ár",mo:function(e){return 1===e?"mánaður":"mánaðir"},w:function(e){return 1===e?"vika":"vikur"},d:function(e){return 1===e?"dagur":"dagar"},h:function(e){return 1===e?"tími":"tímar"},m:function(e){return 1===e?"minuttur":"minuttir"},s:"sekund",ms:"millisekund",decimal:","},fr:{y:function(e){return"an"+(e>=2?"s":"")},mo:"mois",w:function(e){return"semaine"+(e>=2?"s":"")},d:function(e){return"jour"+(e>=2?"s":"")},h:function(e){return"heure"+(e>=2?"s":"")},m:function(e){return"minute"+(e>=2?"s":"")},s:function(e){return"seconde"+(e>=2?"s":"")},ms:function(e){return"milliseconde"+(e>=2?"s":"")},decimal:","},gr:e,he:{y:function(e){return 1===e?"שנה":"שנים"},mo:function(e){return 1===e?"חודש":"חודשים"},w:function(e){return 1===e?"שבוע":"שבועות"},d:function(e){return 1===e?"יום":"ימים"},h:function(e){return 1===e?"שעה":"שעות"},m:function(e){return 1===e?"דקה":"דקות"},s:function(e){return 1===e?"שניה":"שניות"},ms:function(e){return 1===e?"מילישנייה":"מילישניות"},decimal:"."},hr:{y:function(e){return e%10==2||e%10==3||e%10==4?"godine":"godina"},mo:function(e){return 1===e?"mjesec":2===e||3===e||4===e?"mjeseca":"mjeseci"},w:function(e){return e%10==1&&11!==e?"tjedan":"tjedna"},d:function(e){return 1===e?"dan":"dana"},h:function(e){return 1===e?"sat":2===e||3===e||4===e?"sata":"sati"},m:function(e){var t=e%10;return 2!==t&&3!==t&&4!==t||!(e<10||e>14)?"minuta":"minute"},s:function(e){var t=e%10;return 5===t||Math.floor(e)===e&&e>=10&&e<=19?"sekundi":1===t?"sekunda":2===t||3===t||4===t?"sekunde":"sekundi"},ms:function(e){return 1===e?"milisekunda":e%10==2||e%10==3||e%10==4?"milisekunde":"milisekundi"},decimal:","},hi:{y:"साल",mo:function(e){return 1===e?"महीना":"महीने"},w:function(e){return 1===e?"हफ़्ता":"हफ्ते"},d:"दिन",h:function(e){return 1===e?"घंटा":"घंटे"},m:"मिनट",s:"सेकंड",ms:"मिलीसेकंड",decimal:"."},hu:{y:"év",mo:"hónap",w:"hét",d:"nap",h:"óra",m:"perc",s:"másodperc",ms:"ezredmásodperc",decimal:","},id:{y:"tahun",mo:"bulan",w:"minggu",d:"hari",h:"jam",m:"menit",s:"detik",ms:"milidetik",decimal:"."},is:{y:"ár",mo:function(e){return"mánuð"+(1===e?"ur":"ir")},w:function(e){return"vik"+(1===e?"a":"ur")},d:function(e){return"dag"+(1===e?"ur":"ar")},h:function(e){return"klukkutím"+(1===e?"i":"ar")},m:function(e){return"mínút"+(1===e?"a":"ur")},s:function(e){return"sekúnd"+(1===e?"a":"ur")},ms:function(e){return"millisekúnd"+(1===e?"a":"ur")},decimal:"."},it:{y:function(e){return"ann"+(1===e?"o":"i")},mo:function(e){return"mes"+(1===e?"e":"i")},w:function(e){return"settiman"+(1===e?"a":"e")},d:function(e){return"giorn"+(1===e?"o":"i")},h:function(e){return"or"+(1===e?"a":"e")},m:function(e){return"minut"+(1===e?"o":"i")},s:function(e){return"second"+(1===e?"o":"i")},ms:function(e){return"millisecond"+(1===e?"o":"i")},decimal:","},ja:{y:"年",mo:"月",w:"週",d:"日",h:"時間",m:"分",s:"秒",ms:"ミリ秒",decimal:"."},ko:{y:"년",mo:"개월",w:"주일",d:"일",h:"시간",m:"분",s:"초",ms:"밀리 초",decimal:"."},lo:{y:"ປີ",mo:"ເດືອນ",w:"ອາທິດ",d:"ມື້",h:"ຊົ່ວໂມງ",m:"ນາທີ",s:"ວິນາທີ",ms:"ມິນລິວິນາທີ",decimal:","},lt:{y:function(e){return e%10==0||e%100>=10&&e%100<=20?"metų":"metai"},mo:function(e){return["mėnuo","mėnesiai","mėnesių"][c(e)]},w:function(e){return["savaitė","savaitės","savaičių"][c(e)]},d:function(e){return["diena","dienos","dienų"][c(e)]},h:function(e){return["valanda","valandos","valandų"][c(e)]},m:function(e){return["minutė","minutės","minučių"][c(e)]},s:function(e){return["sekundė","sekundės","sekundžių"][c(e)]},ms:function(e){return["milisekundė","milisekundės","milisekundžių"][c(e)]},decimal:","},lv:{y:function(e){return h(e)?"gads":"gadi"},mo:function(e){return h(e)?"mēnesis":"mēneši"},w:function(e){return h(e)?"nedēļa":"nedēļas"},d:function(e){return h(e)?"diena":"dienas"},h:function(e){return h(e)?"stunda":"stundas"},m:function(e){return h(e)?"minūte":"minūtes"},s:function(e){return h(e)?"sekunde":"sekundes"},ms:function(e){return h(e)?"milisekunde":"milisekundes"},decimal:","},ms:{y:"tahun",mo:"bulan",w:"minggu",d:"hari",h:"jam",m:"minit",s:"saat",ms:"milisaat",decimal:"."},nl:{y:"jaar",mo:function(e){return 1===e?"maand":"maanden"},w:function(e){return 1===e?"week":"weken"},d:function(e){return 1===e?"dag":"dagen"},h:"uur",m:function(e){return 1===e?"minuut":"minuten"},s:function(e){return 1===e?"seconde":"seconden"},ms:function(e){return 1===e?"milliseconde":"milliseconden"},decimal:","},no:{y:"år",mo:function(e){return"måned"+(1===e?"":"er")},w:function(e){return"uke"+(1===e?"":"r")},d:function(e){return"dag"+(1===e?"":"er")},h:function(e){return"time"+(1===e?"":"r")},m:function(e){return"minutt"+(1===e?"":"er")},s:function(e){return"sekund"+(1===e?"":"er")},ms:function(e){return"millisekund"+(1===e?"":"er")},decimal:","},pl:{y:function(e){return["rok","roku","lata","lat"][s(e)]},mo:function(e){return["miesiąc","miesiąca","miesiące","miesięcy"][s(e)]},w:function(e){return["tydzień","tygodnia","tygodnie","tygodni"][s(e)]},d:function(e){return["dzień","dnia","dni","dni"][s(e)]},h:function(e){return["godzina","godziny","godziny","godzin"][s(e)]},m:function(e){return["minuta","minuty","minuty","minut"][s(e)]},s:function(e){return["sekunda","sekundy","sekundy","sekund"][s(e)]},ms:function(e){return["milisekunda","milisekundy","milisekundy","milisekund"][s(e)]},decimal:","},pt:{y:function(e){return"ano"+(1===e?"":"s")},mo:function(e){return 1===e?"mês":"meses"},w:function(e){return"semana"+(1===e?"":"s")},d:function(e){return"dia"+(1===e?"":"s")},h:function(e){return"hora"+(1===e?"":"s")},m:function(e){return"minuto"+(1===e?"":"s")},s:function(e){return"segundo"+(1===e?"":"s")},ms:function(e){return"milissegundo"+(1===e?"":"s")},decimal:","},ro:{y:function(e){return 1===e?"an":"ani"},mo:function(e){return 1===e?"lună":"luni"},w:function(e){return 1===e?"săptămână":"săptămâni"},d:function(e){return 1===e?"zi":"zile"},h:function(e){return 1===e?"oră":"ore"},m:function(e){return 1===e?"minut":"minute"},s:function(e){return 1===e?"secundă":"secunde"},ms:function(e){return 1===e?"milisecundă":"milisecunde"},decimal:","},ru:{y:function(e){return["лет","год","года"][u(e)]},mo:function(e){return["месяцев","месяц","месяца"][u(e)]},w:function(e){return["недель","неделя","недели"][u(e)]},d:function(e){return["дней","день","дня"][u(e)]},h:function(e){return["часов","час","часа"][u(e)]},m:function(e){return["минут","минута","минуты"][u(e)]},s:function(e){return["секунд","секунда","секунды"][u(e)]},ms:function(e){return["миллисекунд","миллисекунда","миллисекунды"][u(e)]},decimal:","},uk:{y:function(e){return["років","рік","роки"][u(e)]},mo:function(e){return["місяців","місяць","місяці"][u(e)]},w:function(e){return["тижнів","тиждень","тижні"][u(e)]},d:function(e){return["днів","день","дні"][u(e)]},h:function(e){return["годин","година","години"][u(e)]},m:function(e){return["хвилин","хвилина","хвилини"][u(e)]},s:function(e){return["секунд","секунда","секунди"][u(e)]},ms:function(e){return["мілісекунд","мілісекунда","мілісекунди"][u(e)]},decimal:","},ur:{y:"سال",mo:function(e){return 1===e?"مہینہ":"مہینے"},w:function(e){return 1===e?"ہفتہ":"ہفتے"},d:"دن",h:function(e){return 1===e?"گھنٹہ":"گھنٹے"},m:"منٹ",s:"سیکنڈ",ms:"ملی سیکنڈ",decimal:"."},sk:{y:function(e){return["rok","roky","roky","rokov"][f(e)]},mo:function(e){return["mesiac","mesiace","mesiace","mesiacov"][f(e)]},w:function(e){return["týždeň","týždne","týždne","týždňov"][f(e)]},d:function(e){return["deň","dni","dni","dní"][f(e)]},h:function(e){return["hodina","hodiny","hodiny","hodín"][f(e)]},m:function(e){return["minúta","minúty","minúty","minút"][f(e)]},s:function(e){return["sekunda","sekundy","sekundy","sekúnd"][f(e)]},ms:function(e){return["milisekunda","milisekundy","milisekundy","milisekúnd"][f(e)]},decimal:","},sl:{y:function(e){return e%10==1?"leto":e%100==2?"leti":e%100==3||e%100==4||Math.floor(e)!==e&&e%100<=5?"leta":"let"},mo:function(e){return e%10==1?"mesec":e%100==2||Math.floor(e)!==e&&e%100<=5?"meseca":e%10==3||e%10==4?"mesece":"mesecev"},w:function(e){return e%10==1?"teden":e%10==2||Math.floor(e)!==e&&e%100<=4?"tedna":e%10==3||e%10==4?"tedne":"tednov"},d:function(e){return e%100==1?"dan":"dni"},h:function(e){return e%10==1?"ura":e%100==2?"uri":e%10==3||e%10==4||Math.floor(e)!==e?"ure":"ur"},m:function(e){return e%10==1?"minuta":e%10==2?"minuti":e%10==3||e%10==4||Math.floor(e)!==e&&e%100<=4?"minute":"minut"},s:function(e){return e%10==1?"sekunda":e%100==2?"sekundi":e%100==3||e%100==4||Math.floor(e)!==e?"sekunde":"sekund"},ms:function(e){return e%10==1?"milisekunda":e%100==2?"milisekundi":e%100==3||e%100==4||Math.floor(e)!==e?"milisekunde":"milisekund"},decimal:","},sv:{y:"år",mo:function(e){return"månad"+(1===e?"":"er")},w:function(e){return"veck"+(1===e?"a":"or")},d:function(e){return"dag"+(1===e?"":"ar")},h:function(e){return"timm"+(1===e?"e":"ar")},m:function(e){return"minut"+(1===e?"":"er")},s:function(e){return"sekund"+(1===e?"":"er")},ms:function(e){return"millisekund"+(1===e?"":"er")},decimal:","},sw:{y:function(e){return 1===e?"mwaka":"miaka"},mo:function(e){return 1===e?"mwezi":"miezi"},w:"wiki",d:function(e){return 1===e?"siku":"masiku"},h:function(e){return 1===e?"saa":"masaa"},m:"dakika",s:"sekunde",ms:"milisekunde",decimal:"."},tr:{y:"yıl",mo:"ay",w:"hafta",d:"gün",h:"saat",m:"dakika",s:"saniye",ms:"milisaniye",decimal:","},th:{y:"ปี",mo:"เดือน",w:"สัปดาห์",d:"วัน",h:"ชั่วโมง",m:"นาที",s:"วินาที",ms:"มิลลิวินาที",decimal:"."},vi:{y:"năm",mo:"tháng",w:"tuần",d:"ngày",h:"giờ",m:"phút",s:"giây",ms:"mili giây",decimal:","},zh_CN:{y:"年",mo:"个月",w:"周",d:"天",h:"小时",m:"分钟",s:"秒",ms:"毫秒",decimal:"."},zh_TW:{y:"年",mo:"個月",w:"周",d:"天",h:"小時",m:"分鐘",s:"秒",ms:"毫秒",decimal:"."}};function n(e){var t=function(e,n){return function(e,t){var n,i,a;e=Math.abs(e);var s,u,f,c=function(e){var t=[e.language];if(d(e,"fallbacks")){if(!l(e.fallbacks)||!e.fallbacks.length)throw new Error("fallbacks must be an array with at least one element");t=t.concat(e.fallbacks)}for(var n=0;n=0&&((a=h[n]).unitCount=Math.round(a.unitCount),0!==n);n--)m=h[n-1],b=t.unitMeasures[m.unitName]/t.unitMeasures[a.unitName],(a.unitCount%b==0||t.largest&&t.largest-12)return g.slice(0,-1).join(t.delimiter)+(t.serialComma?",":"")+t.conjunction+g.slice(-1)}(e,a({},t,n||{}))};return a(t,{language:"en",delimiter:", ",spacer:" ",conjunction:"",serialComma:!0,units:["y","mo","w","d","h","m","s"],languages:{},round:!1,unitMeasures:{y:315576e5,mo:26298e5,w:6048e5,d:864e5,h:36e5,m:6e4,s:1e3,ms:1}},e)}var i=n({});function o(e,t,r,n){var i;i=d(n,"decimal")?n.decimal:d(r,"decimal")?r.decimal:".";var o,a=e.toString().replace(".",i),s=r[t];return o="function"==typeof s?s(e):s,a+n.spacer+o}function a(e){for(var t,r=1;r=2&&e%10<=4&&!(e%100>10&&e%100<20)?2:3}function u(e){return Math.floor(e)!==e?2:e%100>=5&&e%100<=20||e%10>=5&&e%10<=9||e%10==0?0:e%10==1?1:e>1?2:0}function f(e){return 1===e?0:Math.floor(e)!==e?1:e%10>=2&&e%10<=4&&e%100<10?2:3}function c(e){return 1===e||e%10==1&&e%100>20?0:Math.floor(e)!==e||e%10>=2&&e%100>20||e%10>=2&&e%100<10?1:2}function h(e){return e%10==1&&e%100!=11}var l=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function d(e,t){return Object.prototype.hasOwnProperty.call(e,t)}i.getSupportedLanguages=function(){var e=[];for(var t in r)d(r,t)&&"gr"!==t&&e.push(t);return e},i.humanizer=n,void 0!==t&&t.exports?t.exports=i:this.humanizeDuration=i}()},{}],97:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],98:[function(e,t,r){e("whatwg-fetch"),t.exports=self.fetch.bind(self)},{"whatwg-fetch":180}],99:[function(e,t,r){(function(e){(function(){var r=null;"undefined"!=typeof WebSocket?r=WebSocket:"undefined"!=typeof MozWebSocket?r=MozWebSocket:void 0!==e?r=e.WebSocket||e.MozWebSocket:"undefined"!=typeof window?r=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(r=self.WebSocket||self.MozWebSocket),t.exports=r}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],100:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=e("./key-encoder");r.default=n.default},{"./key-encoder":101}],101:[function(e,t,r){(function(t){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=e("elliptic"),i=e("asn1.js"),o=e("bn.js"),a=i.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).objid().optional(),this.key("publicKey").explicit(1).bitstr().optional())}),s=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("curve").objid()),this.key("pub").bitstr())}),u={secp256k1:{curveParameters:[1,3,132,0,10],privatePEMOptions:{label:"EC PRIVATE KEY"},publicPEMOptions:{label:"PUBLIC KEY"},curve:new n.ec("secp256k1")}};class f{constructor(e){if("string"==typeof e){if("secp256k1"!==e)throw new Error("Unknown curve "+e);e=u[e]}this.options=e,this.algorithmID=[1,2,840,10045,2,1]}privateKeyObject(e,r){const n={version:new o(1),privateKey:t.from(e,"hex"),parameters:this.options.curveParameters};return r&&(n.publicKey={unused:0,data:t.from(r,"hex")}),n}publicKeyObject(e){return{algorithm:{id:this.algorithmID,curve:this.options.curveParameters},pub:{unused:0,data:t.from(e,"hex")}}}encodePrivate(e,r,n){let i;if("raw"===r){if("string"!=typeof e)throw"private key must be a string";let t=this.options.curve.keyFromPrivate(e,"hex").getPublic("hex");i=this.privateKeyObject(e,t)}else if("der"===r){if("string"!=typeof e);else{if("string"!=typeof e)throw"private key must be a buffer or a string";e=t.from(e,"hex")}i=a.decode(e,"der")}else{if("pem"!==r)throw"invalid private key format";if("string"!=typeof e)throw"private key must be a string";i=a.decode(e,"pem",this.options.privatePEMOptions)}if("raw"===n)return i.privateKey.toString("hex");if("der"===n)return a.encode(i,"der").toString("hex");if("pem"===n)return a.encode(i,"pem",this.options.privatePEMOptions);throw"invalid destination format for private key"}encodePublic(e,r,n){let i;if("raw"===r){if("string"!=typeof e)throw"public key must be a string";i=this.publicKeyObject(e)}else if("der"===r){if("string"!=typeof e);else{if("string"!=typeof e)throw"public key must be a buffer or a string";e=t.from(e,"hex")}i=s.decode(e,"der")}else{if("pem"!==r)throw"invalid public key format";if("string"!=typeof e)throw"public key must be a string";i=s.decode(e,"pem",this.options.publicPEMOptions)}if("raw"===n)return i.pub.data.toString("hex");if("der"===n)return s.encode(i,"der").toString("hex");if("pem"===n)return s.encode(i,"pem",this.options.publicPEMOptions);throw"invalid destination format for public key"}}r.default=f,f.ECPrivateKeyASN=a,f.SubjectPublicKeyInfoASN=s}).call(this)}).call(this,e("buffer").Buffer)},{"asn1.js":26,"bn.js":45,buffer:266,elliptic:56}],102:[function(e,t,r){"use strict";var n=e("inherits"),i=e("hash-base"),o=e("safe-buffer").Buffer,a=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(e,t){return e<>>32-t}function f(e,t,r,n,i,o,a){return u(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return u(e+(t&n|r&~n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return u(e+(t^r^n)+i+o|0,a)+t|0}function l(e,t,r,n,i,o,a){return u(e+(r^(t|~n))+i+o|0,a)+t|0}n(s,i),s.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d;r=f(r,n,i,o,e[0],3614090360,7),o=f(o,r,n,i,e[1],3905402710,12),i=f(i,o,r,n,e[2],606105819,17),n=f(n,i,o,r,e[3],3250441966,22),r=f(r,n,i,o,e[4],4118548399,7),o=f(o,r,n,i,e[5],1200080426,12),i=f(i,o,r,n,e[6],2821735955,17),n=f(n,i,o,r,e[7],4249261313,22),r=f(r,n,i,o,e[8],1770035416,7),o=f(o,r,n,i,e[9],2336552879,12),i=f(i,o,r,n,e[10],4294925233,17),n=f(n,i,o,r,e[11],2304563134,22),r=f(r,n,i,o,e[12],1804603682,7),o=f(o,r,n,i,e[13],4254626195,12),i=f(i,o,r,n,e[14],2792965006,17),r=c(r,n=f(n,i,o,r,e[15],1236535329,22),i,o,e[1],4129170786,5),o=c(o,r,n,i,e[6],3225465664,9),i=c(i,o,r,n,e[11],643717713,14),n=c(n,i,o,r,e[0],3921069994,20),r=c(r,n,i,o,e[5],3593408605,5),o=c(o,r,n,i,e[10],38016083,9),i=c(i,o,r,n,e[15],3634488961,14),n=c(n,i,o,r,e[4],3889429448,20),r=c(r,n,i,o,e[9],568446438,5),o=c(o,r,n,i,e[14],3275163606,9),i=c(i,o,r,n,e[3],4107603335,14),n=c(n,i,o,r,e[8],1163531501,20),r=c(r,n,i,o,e[13],2850285829,5),o=c(o,r,n,i,e[2],4243563512,9),i=c(i,o,r,n,e[7],1735328473,14),r=h(r,n=c(n,i,o,r,e[12],2368359562,20),i,o,e[5],4294588738,4),o=h(o,r,n,i,e[8],2272392833,11),i=h(i,o,r,n,e[11],1839030562,16),n=h(n,i,o,r,e[14],4259657740,23),r=h(r,n,i,o,e[1],2763975236,4),o=h(o,r,n,i,e[4],1272893353,11),i=h(i,o,r,n,e[7],4139469664,16),n=h(n,i,o,r,e[10],3200236656,23),r=h(r,n,i,o,e[13],681279174,4),o=h(o,r,n,i,e[0],3936430074,11),i=h(i,o,r,n,e[3],3572445317,16),n=h(n,i,o,r,e[6],76029189,23),r=h(r,n,i,o,e[9],3654602809,4),o=h(o,r,n,i,e[12],3873151461,11),i=h(i,o,r,n,e[15],530742520,16),r=l(r,n=h(n,i,o,r,e[2],3299628645,23),i,o,e[0],4096336452,6),o=l(o,r,n,i,e[7],1126891415,10),i=l(i,o,r,n,e[14],2878612391,15),n=l(n,i,o,r,e[5],4237533241,21),r=l(r,n,i,o,e[12],1700485571,6),o=l(o,r,n,i,e[3],2399980690,10),i=l(i,o,r,n,e[10],4293915773,15),n=l(n,i,o,r,e[1],2240044497,21),r=l(r,n,i,o,e[8],1873313359,6),o=l(o,r,n,i,e[15],4264355552,10),i=l(i,o,r,n,e[6],2734768916,15),n=l(n,i,o,r,e[13],1309151649,21),r=l(r,n,i,o,e[4],4149444226,6),o=l(o,r,n,i,e[11],3174756917,10),i=l(i,o,r,n,e[2],718787259,15),n=l(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=s},{"hash-base":82,inherits:97,"safe-buffer":122}],103:[function(e,t,r){function n(e,t){if(!e)throw new Error(t||"Assertion failed")}t.exports=n,n.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},{}],104:[function(e,t,r){"use strict";var n=r;function i(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",r=0;r>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],105:[function(e,t,r){(function(r,n){(function(){"use strict";var i=65536,o=4294967295;var a=e("safe-buffer").Buffer,s=n.crypto||n.msCrypto;s&&s.getRandomValues?t.exports=function(e,t){if(e>o)throw new RangeError("requested too many random bytes");var n=a.allocUnsafe(e);if(e>0)if(e>i)for(var u=0;u2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},{}],107:[function(e,t,r){(function(r){(function(){"use strict";var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=f;var i=e("./_stream_readable"),o=e("./_stream_writable");e("inherits")(f,i);for(var a=n(o.prototype),s=0;s0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),n)a.endEmitted?M(e,new _):B(e,a,t,!0);else if(a.ended)M(e,new g);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?B(e,a,t,!1):O(e,a)):B(e,a,t,!1)}else n||(a.reading=!1,O(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;f("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(P,e))}function P(e){var t=e._readableState;f("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,U(e)}function O(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){f("readable nexttick read 0"),e.read(0)}function N(e,t){f("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),U(e),t.flowing&&!t.reading&&e.read(0)}function U(e){var t=e._readableState;for(f("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function L(e){var t=e._readableState;f("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(K,t,e))}function K(e,t){if(f("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function z(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?L(this):x(this),null;if(0===(e=j(e,t))&&t.ended)return 0===t.length&&L(this),null;var n,i=t.needReadable;return f("need readable",i),(0===t.length||t.length-e0?D(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&L(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){M(this,new w("_read()"))},A.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,f("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?u:b;function s(t,r){f("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,f("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",b),n.removeListener("data",l),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function u(){f("onend"),e.end()}i.endEmitted?r.nextTick(a):n.once("end",a),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",c);var h=!1;function l(t){f("ondata");var r=e.write(t);f("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==z(i.pipes,e))&&!h&&(f("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(t){f("onerror",t),b(),e.removeListener("error",d),0===o(e,"error")&&M(e,t)}function p(){e.removeListener("finish",y),b()}function y(){f("onfinish"),e.removeListener("close",p),b()}function b(){f("unpipe"),n.unpipe(e)}return n.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",n),i.flowing||(f("pipe resume"),n.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,f("on readable",i.length,i.reading),i.length?x(this):i.reading||r.nextTick(C,this))),n},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var n=a.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(I,this),n},A.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(I,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(f("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(N,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return f("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(f("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",function(){if(f("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(f("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new y("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,n){var i=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,n){t.ending=!0,P(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,i,n),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=h.destroy,A.prototype._undestroy=h.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":106,"./_stream_duplex":107,"./internal/streams/destroy":114,"./internal/streams/state":118,"./internal/streams/stream":119,_process:353,buffer:266,inherits:97,"util-deprecate":179}],112:[function(e,t,r){(function(r){(function(){"use strict";var n;function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=e("./end-of-stream"),a=Symbol("lastResolve"),s=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),c=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[a];if(null!==t){var r=e[l].read();null!==r&&(e[c]=null,e[a]=null,e[s]=null,t(d(r,!1)))}}var y=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[f])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(t,n){r.nextTick(function(){e[u]?n(e[u]):t(d(void 0,!0))})});var n,i=this[c];if(i)n=new Promise(function(e,t){return function(r,n){e.then(function(){t[f]?r(d(void 0,!0)):t[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[c]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var e=this;return new Promise(function(t,r){e[l].destroy(null,function(e){e?r(e):t(d(void 0,!0))})})}),n),y);t.exports=function(e){var t,n=Object.create(b,(i(t={},l,{value:e,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,f,{value:e._readableState.endEmitted,writable:!0}),i(t,h,{value:function(e,t){var r=n[l].read();r?(n[c]=null,n[a]=null,n[s]=null,e(d(r,!1))):(n[a]=e,n[s]=t)},writable:!0}),t));return n[c]=null,o(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[s];return null!==t&&(n[c]=null,n[a]=null,n[s]=null,t(e)),void(n[u]=e)}var r=n[a];null!==r&&(n[c]=null,n[a]=null,n[s]=null,r(d(void 0,!0))),n[f]=!0}),e.on("readable",function(e){r.nextTick(p,e)}.bind(null,n)),n}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":115,_process:353}],113:[function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return a.alloc(0);for(var t,r,n,i=a.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,a.prototype.copy.call(t,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0===(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=a.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0===(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:u,value:function(e,t){return s(this,function(e){for(var t=1;t0,function(e){c||(c=e),e&&l.forEach(u),o||(l.forEach(u),h(c))})});return r.reduce(f)}},{"../../../errors":106,"./end-of-stream":115}],118:[function(e,t,r){"use strict";var n=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,r,i){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},{"../../../errors":106}],119:[function(e,t,r){t.exports=e("events").EventEmitter},{events:303}],120:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":107,"./lib/_stream_passthrough.js":108,"./lib/_stream_readable.js":109,"./lib/_stream_transform.js":110,"./lib/_stream_writable.js":111,"./lib/internal/streams/end-of-stream.js":115,"./lib/internal/streams/pipeline.js":117}],121:[function(e,t,r){"use strict";var n=e("buffer").Buffer,i=e("inherits"),o=e("hash-base"),a=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],u=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],f=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function d(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<>>32-t}function y(e,t,r,n,i,o,a,s){return p(e+(t^r^n)+o+a|0,s)+i|0}function b(e,t,r,n,i,o,a,s){return p(e+(t&r|~t&n)+o+a|0,s)+i|0}function m(e,t,r,n,i,o,a,s){return p(e+((t|~r)^n)+o+a|0,s)+i|0}function v(e,t,r,n,i,o,a,s){return p(e+(t&n|r&~n)+o+a|0,s)+i|0}function g(e,t,r,n,i,o,a,s){return p(e+(t^(r|~n))+o+a|0,s)+i|0}i(d,o),d.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,d=0|this._e,w=0|this._a,_=0|this._b,M=0|this._c,S=0|this._d,E=0|this._e,A=0;A<80;A+=1){var k,B;A<16?(k=y(r,n,i,o,d,e[s[A]],h[0],f[A]),B=g(w,_,M,S,E,e[u[A]],l[0],c[A])):A<32?(k=b(r,n,i,o,d,e[s[A]],h[1],f[A]),B=v(w,_,M,S,E,e[u[A]],l[1],c[A])):A<48?(k=m(r,n,i,o,d,e[s[A]],h[2],f[A]),B=m(w,_,M,S,E,e[u[A]],l[2],c[A])):A<64?(k=v(r,n,i,o,d,e[s[A]],h[3],f[A]),B=b(w,_,M,S,E,e[u[A]],l[3],c[A])):(k=g(r,n,i,o,d,e[s[A]],h[4],f[A]),B=y(w,_,M,S,E,e[u[A]],l[4],c[A])),r=d,d=o,o=p(i,10),i=n,n=k,w=E,E=S,S=p(M,10),M=_,_=B}var T=this._b+i+S|0;this._b=this._c+o+E|0,this._c=this._d+d+w|0,this._d=this._e+r+_|0,this._e=this._a+n+M|0,this._a=T},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=d},{buffer:266,"hash-base":82,inherits:97}],122:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:266}],123:[function(e,t,r){(function(r){(function(){"use strict";var n,i=e("buffer"),o=i.Buffer,a={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(a[n]=i[n]);var s=a.Buffer={};for(n in o)o.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=o[n]);if(a.Buffer.prototype=o.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(e,t,r){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return o(e,t,r)}),s.alloc||(s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=o(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!a.kStringMaxLength)try{a.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(e){}a.constants||(a.constants={MAX_LENGTH:a.kMaxLength},a.kStringMaxLength&&(a.constants.MAX_STRING_LENGTH=a.kStringMaxLength)),t.exports=a}).call(this)}).call(this,e("_process"))},{_process:353,buffer:266}],124:[function(e,t,r){t.exports=e("./lib")(e("./lib/elliptic"))},{"./lib":126,"./lib/elliptic":125}],125:[function(e,t,r){const n=new(0,e("elliptic").ec)("secp256k1"),i=n.curve,o=i.n.constructor;function a(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new o(t);if(r.cmp(i.p)>=0)return null;let a=(r=r.toRed(i.red)).redSqr().redIMul(r).redIAdd(i.b).redSqrt();return 3===e!==a.isOdd()&&(a=a.redNeg()),n.keyPair({pub:{x:r,y:a}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let a=new o(t),s=new o(r);if(a.cmp(i.p)>=0||s.cmp(i.p)>=0)return null;if(a=a.toRed(i.red),s=s.toRed(i.red),(6===e||7===e)&&s.isOdd()!==(7===e))return null;const u=a.redSqr().redIMul(a);return s.redSqr().redISub(u.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:a,y:s}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function s(e,t){const r=t.encode(null,33===e.length);for(let t=0;t0,privateKeyVerify(e){const t=new o(e);return t.cmp(i.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new o(e),r=i.n.sub(t).umod(i.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new o(t);if(r.cmp(i.n)>=0)return 1;if(r.iadd(new o(e)),r.cmp(i.n)>=0&&r.isub(i.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new o(t);if(r.cmp(i.n)>=0||r.isZero())return 1;r.imul(new o(e)),r.cmp(i.n)>=0&&(r=r.umod(i.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===a(e)?1:0,publicKeyCreate(e,t){const r=new o(t);return r.cmp(i.n)>=0||r.isZero()?1:(s(e,n.keyFromPrivate(t).getPublic()),0)},publicKeyConvert(e,t){const r=a(t);return null===r?1:(s(e,r.getPublic()),0)},publicKeyNegate(e,t){const r=a(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),s(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e=0)return 2;const u=n.getPublic().add(i.g.mul(r));return u.isInfinity()?2:(s(e,u),0)},publicKeyTweakMul(e,t,r){const n=a(t);return null===n?1:(r=new o(r)).cmp(i.n)>=0||r.isZero()?2:(s(e,n.getPublic().mul(r)),0)},signatureNormalize(e){const t=new o(e.subarray(0,32)),r=new o(e.subarray(32,64));return t.cmp(i.n)>=0||r.cmp(i.n)>=0?1:(1===r.cmp(n.nh)&&e.set(i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),n=t.subarray(32,64);if(new o(r).cmp(i.n)>=0)return 1;if(new o(n).cmp(i.n)>=0)return 1;const{output:a}=e;let s=a.subarray(4,37);s[0]=0,s.set(r,1);let u=33,f=0;for(;u>1&&0===s[f]&&!(128&s[f+1]);--u,++f);if(128&(s=s.subarray(f))[0])return 1;if(u>1&&0===s[0]&&!(128&s[1]))return 1;let c=a.subarray(39,72);c[0]=0,c.set(n,1);let h=33,l=0;for(;h>1&&0===c[l]&&!(128&c[l+1]);--h,++l);return 128&(c=c.subarray(l))[0]?1:h>1&&0===c[0]&&!(128&c[1])?1:(e.outputlen=6+u+h,a[0]=48,a[1]=e.outputlen-2,a[2]=2,a[3]=s.length,a.set(s,4),a[4+u]=2,a[5+u]=c.length,a.set(c,6+u),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const n=t[5+r];if(0===n)return 1;if(6+r+n!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(n>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let a=t.subarray(4,4+r);if(33===a.length&&0===a[0]&&(a=a.subarray(1)),a.length>32)return 1;let s=t.subarray(6+r);if(33===s.length&&0===s[0]&&(s=s.slice(1)),s.length>32)throw new Error("S length is too long");let u=new o(a);u.cmp(i.n)>=0&&(u=new o(0));let f=new o(t.subarray(6+r));return f.cmp(i.n)>=0&&(f=new o(0)),e.set(u.toArrayLike(Uint8Array,"be",32),0),e.set(f.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,a,s){if(s){const e=s;s=(n=>{const i=e(t,r,null,a,n);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new o(i)})}const u=new o(r);if(u.cmp(i.n)>=0||u.isZero())return 1;let f;try{f=n.sign(t,r,{canonical:!0,k:s,pers:a})}catch(e){return 1}return e.signature.set(f.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(f.s.toArrayLike(Uint8Array,"be",32),32),e.recid=f.recoveryParam,0},ecdsaVerify(e,t,r){const s={r:e.subarray(0,32),s:e.subarray(32,64)},u=new o(s.r),f=new o(s.s);if(u.cmp(i.n)>=0||f.cmp(i.n)>=0)return 1;if(1===f.cmp(n.nh)||u.isZero()||f.isZero())return 3;const c=a(r);if(null===c)return 2;const h=c.getPublic();return n.verify(t,s,h)?0:3},ecdsaRecover(e,t,r,a){const u={r:t.slice(0,32),s:t.slice(32,64)},f=new o(u.r),c=new o(u.s);if(f.cmp(i.n)>=0||c.cmp(i.n)>=0)return 1;if(f.isZero()||c.isZero())return 2;let h;try{h=n.recoverPubKey(a,u,r)}catch(e){return 2}return s(e,h),0},ecdh(e,t,r,s,u,f,c){const h=a(t);if(null===h)return 1;const l=new o(r);if(l.cmp(i.n)>=0||l.isZero())return 2;const d=h.getPublic().mul(l);if(void 0===u){const t=d.encode(null,!0),r=n.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{f||(f=new Uint8Array(32));const t=d.getX().toArray("be",32);for(let e=0;e<32;++e)f[e]=t[e];c||(c=new Uint8Array(32));const r=d.getY().toArray("be",32);for(let e=0;e<32;++e)c[e]=r[e];const n=u(f,c,s);if(!(n instanceof Uint8Array&&n.length===e.length))return 2;e.set(n)}return 0}}},{elliptic:56}],126:[function(e,t,r){const n="Impossible case. Please create issue.",i="The tweak was out of range or the resulted private key is invalid",o="The tweak was out of range or equal to zero",a="Unknow error on context randomization",s="Private Key is invalid",u="Public Key could not be parsed",f="Public Key serialization error",c="The sum of the public keys is not valid",h="Signature could not be parsed",l="The nonce generation function failed, or the private key was invalid",d="Public key could not be recover",p="Scalar was invalid (zero or overflow)";function y(e,t){if(!e)throw new Error(t)}function b(e,t,r){if(y(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;y(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;y(t.length===r,n)}}function m(e){y("Boolean"===g(e),"Expected compressed to be a Boolean")}function v(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),b("output",e,t),e}function g(e){return Object.prototype.toString.call(e).slice(8,-1)}t.exports=(e=>({contextRandomize(t){switch(y(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&b("seed",t,32),e.contextRandomize(t)){case 1:throw new Error(a)}},privateKeyVerify:t=>(b("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(b("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(n)}},privateKeyTweakAdd(t,r){switch(b("private key",t,32),b("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(i)}},privateKeyTweakMul(t,r){switch(b("private key",t,32),b("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(o)}},publicKeyVerify:t=>(b("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(b("private key",t,32),m(r),n=v(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error(s);case 2:throw new Error(f)}},publicKeyConvert(t,r=!0,n){switch(b("public key",t,[33,65]),m(r),n=v(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(u);case 2:throw new Error(f)}},publicKeyNegate(t,r=!0,i){switch(b("public key",t,[33,65]),m(r),i=v(i,r?33:65),e.publicKeyNegate(i,t)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(n);case 3:throw new Error(f)}},publicKeyCombine(t,r=!0,n){y(Array.isArray(t),"Expected public keys to be an Array"),y(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)b("public key",e,[33,65]);switch(m(r),n=v(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(u);case 2:throw new Error(c);case 3:throw new Error(f)}},publicKeyTweakAdd(t,r,n=!0,o){switch(b("public key",t,[33,65]),b("tweak",r,32),m(n),o=v(o,n?33:65),e.publicKeyTweakAdd(o,t,r)){case 0:return o;case 1:throw new Error(u);case 2:throw new Error(i)}},publicKeyTweakMul(t,r,n=!0,i){switch(b("public key",t,[33,65]),b("tweak",r,32),m(n),i=v(i,n?33:65),e.publicKeyTweakMul(i,t,r)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(o)}},signatureNormalize(t){switch(b("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(h)}},signatureExport(t,r){b("signature",t,64);const i={output:r=v(r,72),outputlen:72};switch(e.signatureExport(i,t)){case 0:return r.slice(0,i.outputlen);case 1:throw new Error(h);case 2:throw new Error(n)}},signatureImport(t,r){switch(b("signature",t),r=v(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(h);case 2:throw new Error(n)}},ecdsaSign(t,r,i={},o){b("message",t,32),b("private key",r,32),y("Object"===g(i),"Expected options to be an Object"),void 0!==i.data&&b("options.data",i.data),void 0!==i.noncefn&&y("Function"===g(i.noncefn),"Expected options.noncefn to be a Function");const a={signature:o=v(o,64),recid:null};switch(e.ecdsaSign(a,t,r,i.data,i.noncefn)){case 0:return a;case 1:throw new Error(l);case 2:throw new Error(n)}},ecdsaVerify(t,r,n){switch(b("signature",t,64),b("message",r,32),b("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(h);case 2:throw new Error(u)}},ecdsaRecover(t,r,i,o=!0,a){switch(b("signature",t,64),y("Number"===g(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),b("message",i,32),m(o),a=v(a,o?33:65),e.ecdsaRecover(a,t,r,i)){case 0:return a;case 1:throw new Error(h);case 2:throw new Error(d);case 3:throw new Error(n)}},ecdh(t,r,n={},i){switch(b("public key",t,[33,65]),b("private key",r,32),y("Object"===g(n),"Expected options to be an Object"),void 0!==n.data&&b("options.data",n.data),void 0!==n.hashfn?(y("Function"===g(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&b("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&b("options.ybuf",n.ybuf,32),b("output",i)):i=v(i,32),e.ecdh(i,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(p)}}}))},{}],127:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":122}],128:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":129,"./sha1":130,"./sha224":131,"./sha256":132,"./sha384":133,"./sha512":134}],129:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(e){return e<<30|e>>>2}function c(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+c(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=f(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":127,inherits:97,"safe-buffer":122}],130:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(e){return e<<5|e>>>27}function c(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),y=f(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=c(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":127,inherits:97,"safe-buffer":122}],131:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":127,"./sha256":132,inherits:97,"safe-buffer":122}],132:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[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],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function f(e,t,r){return r^e&(t^r)}function c(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,y=0|this._g,b=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=b+l(u)+f(u,p,y)+a[v]+r[v]|0,w=h(n)+c(n,i,o)|0;b=y,y=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":127,inherits:97,"safe-buffer":122}],133:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":127,"./sha512":134,inherits:97,"safe-buffer":122}],134:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[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],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function f(e,t,r){return r^e&(t^r)}function c(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,M=0|this._cl,S=0|this._dl,E=0|this._el,A=0|this._fl,k=0|this._gl,B=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var j=t[T-30],x=t[T-30+1],P=d(j,x),O=p(x,j),R=y(j=t[T-4],x=t[T-4+1]),I=b(x,j),C=t[T-14],N=t[T-14+1],U=t[T-32],D=t[T-32+1],L=O+N|0,K=P+C+m(L,O)|0;K=(K=K+R+m(L=L+I|0,I)|0)+U+m(L=L+D|0,D)|0,t[T]=K,t[T+1]=L}for(var z=0;z<160;z+=2){K=t[z],L=t[z+1];var q=c(r,n,i),H=c(w,_,M),F=h(r,w),V=h(w,r),W=l(s,E),J=l(E,s),Z=a[z],G=a[z+1],X=f(s,u,v),Y=f(E,A,k),$=B+J|0,Q=g+W+m($,B)|0;Q=(Q=(Q=Q+X+m($=$+Y|0,Y)|0)+Z+m($=$+G|0,G)|0)+K+m($=$+L|0,L)|0;var ee=V+H|0,te=F+q+m(ee,V)|0;g=v,B=k,v=u,k=A,u=s,A=E,s=o+Q+m(E=S+$|0,S)|0,o=i,S=M,i=n,M=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+M|0,this._dl=this._dl+S|0,this._el=this._el+E|0,this._fl=this._fl+A|0,this._gl=this._gl+k|0,this._hl=this._hl+B|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,M)|0,this._dh=this._dh+o+m(this._dl,S)|0,this._eh=this._eh+s+m(this._el,E)|0,this._fh=this._fh+u+m(this._fl,A)|0,this._gh=this._gh+v+m(this._gl,k)|0,this._hh=this._hh+g+m(this._hl,B)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":127,inherits:97,"safe-buffer":122}],135:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=f,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=c,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function f(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":122}],136:[function(e,t,r){!function(n){if("object"==typeof t&&"object"==typeof t.exports){var i=n(e,r);void 0!==i&&(t.exports=i)}else 0}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=e("tslib");r.__exportStar(e("./result"),t),r.__exportStar(e("./option"),t)})},{"./option":137,"./result":138,tslib:140}],137:[function(e,t,r){!function(n){if("object"==typeof t&&"object"==typeof t.exports){var i=n(e,r);void 0!==i&&(t.exports=i)}else 0}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Option=t.Some=t.None=void 0;var r=e("./utils"),n=function(){function e(){this.some=!1,this.none=!0}return e.prototype[Symbol.iterator]=function(){return{next:function(){return{done:!0,value:void 0}}}},e.prototype.unwrapOr=function(e){return e},e.prototype.expect=function(e){throw new Error(""+e)},e.prototype.unwrap=function(){throw new Error("Tried to unwrap None")},e.prototype.map=function(e){return this},e.prototype.andThen=function(e){return this},e.prototype.toString=function(){return"None"},e}();t.None=new n,Object.freeze(t.None);var i=function(){function e(t){if(!(this instanceof e))return new e(t);this.some=!0,this.none=!1,this.val=t}return e.prototype[Symbol.iterator]=function(){var e=Object(this.val);return Symbol.iterator in e?e[Symbol.iterator]():{next:function(){return{done:!0,value:void 0}}}},e.prototype.unwrapOr=function(e){return this.val},e.prototype.expect=function(e){return this.val},e.prototype.unwrap=function(){return this.val},e.prototype.map=function(e){return t.Some(e(this.val))},e.prototype.andThen=function(e){return e(this.val)},e.prototype.safeUnwrap=function(){return this.val},e.prototype.toString=function(){return"Some("+r.toString(this.val)+")"},e.EMPTY=new e(void 0),e}();t.Some=i,function(e){e.all=function(){for(var e=[],r=0;r=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},a=function(e,t){return function(r,n){t(r,n,e)}},s=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},f=function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},l=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},d=function(){for(var e=[],t=0;t1||s(e,t)})})}function s(e,t){try{(r=i[e](t)).value instanceof y?Promise.resolve(r.value.v).then(u,f):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function u(e){s("next",e)}function f(e){s("throw",e)}function c(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}},m=function(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:y(e[n](t)),done:"return"===n}:i?i(t):t}:i}},v=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=h(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}},g=function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},w=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},_=function(e){return e&&e.__esModule?e:{default:e}},M=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)},S=function(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r},e("__extends",r),e("__assign",n),e("__rest",i),e("__decorate",o),e("__param",a),e("__metadata",s),e("__awaiter",u),e("__generator",f),e("__exportStar",c),e("__createBinding",E),e("__values",h),e("__read",l),e("__spread",d),e("__spreadArrays",p),e("__await",y),e("__asyncGenerator",b),e("__asyncDelegator",m),e("__asyncValues",v),e("__makeTemplateObject",g),e("__importStar",w),e("__importDefault",_),e("__classPrivateFieldGet",M),e("__classPrivateFieldSet",S)})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],141:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ByteArray=function(e){return new Uint8Array(e)},r.HalfArray=function(e){return new Uint16Array(e)},r.WordArray=function(e){return new Uint32Array(e)},r.IntArray=function(e){return new Int32Array(e)},r.NumArray=function(e){return new Float64Array(e)}},{}],142:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array"),i=e("./hash");r.auth=function(e,t){var r=n.ByteArray(32);return r.set(s(e,t).subarray(0,32)),r};var o=128,a=64;function s(e,t){var r,s,u=n.ByteArray(o+Math.max(a,e.length));for(t.length>o&&(t=i.hash(t)),r=0;r64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r=n.WordArray(16),i=0;i<16;i++)r[i]=s[i];var a=t?t.length:0;r[0]^=16842752^a<<8^e;var u={b:n.ByteArray(128),h:r,t:0,c:0,outlen:e};return t&&(o(u,t),u.c=128),u}function o(e,t){for(var r=0;r>2]>>8*(3&r);return t}r.blake2b=function(e,t,r){void 0===r&&(r=64);var n=i(r,t);return o(n,e),a(n)},r.blake2b_init=i,r.blake2b_update=o,r.blake2b_final=a;var s=n.WordArray([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=n.ByteArray([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map(function(e){return 2*e})),f=n.WordArray(32),c=n.WordArray(32);function h(e,t){var r;for(r=0;r<16;r++)f[r]=e.h[r],f[r+16]=s[r];for(f[24]=f[24]^e.t,f[25]=f[25]^e.t/4294967296,t&&(f[28]=~f[28],f[29]=~f[29]),r=0;r<32;r++)c[r]=p(e.b,4*r);for(r=0;r<12;r++)y(0,8,16,24,u[16*r+0],u[16*r+1]),y(2,10,18,26,u[16*r+2],u[16*r+3]),y(4,12,20,28,u[16*r+4],u[16*r+5]),y(6,14,22,30,u[16*r+6],u[16*r+7]),y(0,10,20,30,u[16*r+8],u[16*r+9]),y(2,12,22,24,u[16*r+10],u[16*r+11]),y(4,14,16,26,u[16*r+12],u[16*r+13]),y(6,8,18,28,u[16*r+14],u[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^f[r]^f[r+16]}function l(e,t,r){var n=e[t]+e[r],i=e[t+1]+e[r+1];n>=4294967296&&i++,e[t]=n,e[t+1]=i}function d(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var o=e[t+1]+n;i>=4294967296&&o++,e[t]=i,e[t+1]=o}function p(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function y(e,t,r,n,i,o){var a=c[i],s=c[i+1],u=c[o],h=c[o+1];l(f,e,t),d(f,e,a,s);var p=f[n]^f[e],y=f[n+1]^f[e+1];f[n]=y,f[n+1]=p,l(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=p>>>24^y<<8,f[t+1]=y>>>24^p<<8,l(f,e,t),d(f,e,u,h),p=f[n]^f[e],y=f[n+1]^f[e+1],f[n]=p>>>16^y<<16,f[n+1]=y>>>16^p<<16,l(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=y>>>31^p<<1,f[t+1]=p>>>31^y<<1}},{"./array":141}],144:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array");function i(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var i={h:n.WordArray(s),b:n.WordArray(64),c:0,t:0,outlen:e};return i.h[0]^=16842752^r<<8^e,r&&(o(i,t),i.c=64),i}function o(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}r.blake2s=function(e,t,r){void 0===r&&(r=32);var n=i(r,t);return o(n,e),a(n)},r.blake2s_init=i,r.blake2s_update=o,r.blake2s_final=a;var s=n.WordArray([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=n.ByteArray([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),f=n.WordArray(16),c=n.WordArray(16);function h(e,t){var r=0;for(r=0;r<8;r++)f[r]=e.h[r],f[r+8]=s[r];for(f[12]^=e.t,f[13]^=e.t/4294967296,t&&(f[14]=~f[14]),r=0;r<16;r++)c[r]=l(e.b,4*r);for(r=0;r<10;r++)d(0,4,8,12,c[u[16*r+0]],c[u[16*r+1]]),d(1,5,9,13,c[u[16*r+2]],c[u[16*r+3]]),d(2,6,10,14,c[u[16*r+4]],c[u[16*r+5]]),d(3,7,11,15,c[u[16*r+6]],c[u[16*r+7]]),d(0,5,10,15,c[u[16*r+8]],c[u[16*r+9]]),d(1,6,11,12,c[u[16*r+10]],c[u[16*r+11]]),d(2,7,8,13,c[u[16*r+12]],c[u[16*r+13]]),d(3,4,9,14,c[u[16*r+14]],c[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=f[r]^f[r+8]}function l(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function d(e,t,r,n,i,o){f[e]=f[e]+f[t]+i,f[n]=p(f[n]^f[e],16),f[r]=f[r]+f[n],f[t]=p(f[t]^f[r],12),f[e]=f[e]+f[t]+o,f[n]=p(f[n]^f[e],8),f[r]=f[r]+f[n],f[t]=p(f[t]^f[r],7)}function p(e,t){return e>>>t^e<<32-t}},{"./array":141}],145:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array"),i=e("./core"),o=e("./random"),a=e("./salsa20"),s=e("./scalarmult"),u=e("./secretbox"),f=e("./check");function c(e,t){f.checkArrayTypes(e,t),f.checkBoxLengths(e,t);var r=n.ByteArray(32);return function(e,t,r){var o=n.ByteArray(32);s._scalarMult(o,r,t),a._hsalsa20(e,i._0,o,a._sigma)}(r,e,t),r}r.box=function(e,t,r,n){var i=c(r,n);return u.secretbox(e,t,i)},r.box_before=c,r.box_after=u.secretbox,r.box_open=function(e,t,r,n){var i=c(r,n);return u.secretbox_open(e,t,i)},r.box_open_after=u.secretbox_open,r.box_keyPair=function(){var e,t,r=n.ByteArray(32),i=n.ByteArray(32);return e=r,t=i,o._randomBytes(t,32),s._scalarMult_base(e,t),{publicKey:r,secretKey:i}},r.box_keyPair_fromSecretKey=function(e){if(f.checkArrayTypes(e),32!==e.length)throw new Error("bad secret key size");var t=n.ByteArray(32);return s._scalarMult_base(t,e),{publicKey:t,secretKey:n.ByteArray(e)}}},{"./array":141,"./check":146,"./core":150,"./random":155,"./salsa20":156,"./scalarmult":157,"./secretbox":159}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.checkLengths=function(e,t){if(32!=e.length)throw new Error("bad key size");if(24!=t.length)throw new Error("bad nonce size")},r.checkBoxLengths=function(e,t){if(32!=e.length)throw new Error("bad public key size");if(32!=t.length)throw new Error("bad secret key size")},r.checkArrayTypes=function(){for(var e=[],t=0;t>8),t[i+1]=a(15&e[r]);return o.apply(void 0,t)},r.decodeHex=function(e){i.validateHex(e);for(var t=n.ByteArray(e.length>>1),r=0;r>16&1),u[r-1]&=65535;u[15]=f[15]-32767-(u[14]>>16&1),i=u[15]>>16&1,u[14]&=65535,s(f,u,1-i)}for(r=0;r<16;r++)e[2*r]=255&f[r],e[2*r+1]=f[r]>>8}r.set25519=function(e,t){for(var r=0;r<16;r++)e[r]=0|t[r]},r.sel25519=s,r.pack25519=u,r.neq25519=function(e,t){var r=n.ByteArray(32),o=n.ByteArray(32);return u(r,e),u(o,t),i._verify_32(r,0,o,0)},r.par25519=function(e){var t=n.ByteArray(32);return u(t,e),1&t[0]},r.unpack25519=function(e,t){for(var r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767},r.inv25519=function(e,t){var r,n=o.gf();for(r=0;r<16;r++)n[r]=t[r];for(r=253;r>=0;r--)o.S(n,n),2!==r&&4!==r&&o.M(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}},{"./array":141,"./core":150,"./verify":162}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array"),i=e("./check");function o(e,t,r){var i,o=n.IntArray(8),a=n.IntArray(8),f=n.ByteArray(256),c=r;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,s(o,a,t,r),r%=128,i=0;i=128;){for(E=0;E<16;E++)A=8*E+X,O[E]=r[A+0]<<24|r[A+1]<<16|r[A+2]<<8|r[A+3],R[E]=r[A+4]<<24|r[A+5]<<16|r[A+6]<<8|r[A+7];for(E=0;E<80;E++)if(o=I,s=C,u=N,f=U,c=D,h=L,l=K,z,p=q,y=H,b=F,m=V,v=W,g=J,w=Z,G,T=65535&(B=G),j=B>>>16,x=65535&(k=z),P=k>>>16,T+=65535&(B=(W>>>14|D<<18)^(W>>>18|D<<14)^(D>>>9|W<<23)),j+=B>>>16,x+=65535&(k=(D>>>14|W<<18)^(D>>>18|W<<14)^(W>>>9|D<<23)),P+=k>>>16,T+=65535&(B=W&J^~W&Z),j+=B>>>16,x+=65535&(k=D&L^~D&K),P+=k>>>16,k=a[2*E],T+=65535&(B=a[2*E+1]),j+=B>>>16,x+=65535&k,P+=k>>>16,k=O[E%16],j+=(B=R[E%16])>>>16,x+=65535&k,P+=k>>>16,x+=(j+=(T+=65535&B)>>>16)>>>16,T=65535&(B=S=65535&T|j<<16),j=B>>>16,x=65535&(k=M=65535&x|(P+=x>>>16)<<16),P=k>>>16,T+=65535&(B=(q>>>28|I<<4)^(I>>>2|q<<30)^(I>>>7|q<<25)),j+=B>>>16,x+=65535&(k=(I>>>28|q<<4)^(q>>>2|I<<30)^(q>>>7|I<<25)),P+=k>>>16,j+=(B=q&H^q&F^H&F)>>>16,x+=65535&(k=I&C^I&N^C&N),P+=k>>>16,d=65535&(x+=(j+=(T+=65535&B)>>>16)>>>16)|(P+=x>>>16)<<16,_=65535&T|j<<16,T=65535&(B=m),j=B>>>16,x=65535&(k=f),P=k>>>16,j+=(B=S)>>>16,x+=65535&(k=M),P+=k>>>16,C=o,N=s,U=u,D=f=65535&(x+=(j+=(T+=65535&B)>>>16)>>>16)|(P+=x>>>16)<<16,L=c,K=h,z=l,I=d,H=p,F=y,V=b,W=m=65535&T|j<<16,J=v,Z=g,G=w,q=_,E%16==15)for(A=0;A<16;A++)k=O[A],T=65535&(B=R[A]),j=B>>>16,x=65535&k,P=k>>>16,k=O[(A+9)%16],T+=65535&(B=R[(A+9)%16]),j+=B>>>16,x+=65535&k,P+=k>>>16,M=O[(A+1)%16],T+=65535&(B=((S=R[(A+1)%16])>>>1|M<<31)^(S>>>8|M<<24)^(S>>>7|M<<25)),j+=B>>>16,x+=65535&(k=(M>>>1|S<<31)^(M>>>8|S<<24)^M>>>7),P+=k>>>16,M=O[(A+14)%16],j+=(B=((S=R[(A+14)%16])>>>19|M<<13)^(M>>>29|S<<3)^(S>>>6|M<<26))>>>16,x+=65535&(k=(M>>>19|S<<13)^(S>>>29|M<<3)^M>>>6),P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,O[A]=65535&x|P<<16,R[A]=65535&T|j<<16;T=65535&(B=q),j=B>>>16,x=65535&(k=I),P=k>>>16,k=e[0],j+=(B=t[0])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[0]=I=65535&x|P<<16,t[0]=q=65535&T|j<<16,T=65535&(B=H),j=B>>>16,x=65535&(k=C),P=k>>>16,k=e[1],j+=(B=t[1])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[1]=C=65535&x|P<<16,t[1]=H=65535&T|j<<16,T=65535&(B=F),j=B>>>16,x=65535&(k=N),P=k>>>16,k=e[2],j+=(B=t[2])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[2]=N=65535&x|P<<16,t[2]=F=65535&T|j<<16,T=65535&(B=V),j=B>>>16,x=65535&(k=U),P=k>>>16,k=e[3],j+=(B=t[3])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[3]=U=65535&x|P<<16,t[3]=V=65535&T|j<<16,T=65535&(B=W),j=B>>>16,x=65535&(k=D),P=k>>>16,k=e[4],j+=(B=t[4])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[4]=D=65535&x|P<<16,t[4]=W=65535&T|j<<16,T=65535&(B=J),j=B>>>16,x=65535&(k=L),P=k>>>16,k=e[5],j+=(B=t[5])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[5]=L=65535&x|P<<16,t[5]=J=65535&T|j<<16,T=65535&(B=Z),j=B>>>16,x=65535&(k=K),P=k>>>16,k=e[6],j+=(B=t[6])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[6]=K=65535&x|P<<16,t[6]=Z=65535&T|j<<16,T=65535&(B=G),j=B>>>16,x=65535&(k=z),P=k>>>16,k=e[7],j+=(B=t[7])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(j+=(T+=65535&B)>>>16)>>>16)>>>16,e[7]=z=65535&x|P<<16,t[7]=G=65535&T|j<<16,X+=128,i-=128}return i}function u(e,t,r,n){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}},{"./array":141,"./check":146}],153:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("tslib");n.__exportStar(e("./array"),r),n.__exportStar(e("./validate"),r),n.__exportStar(e("./convert"),r),n.__exportStar(e("./verify"),r),n.__exportStar(e("./random"),r),n.__exportStar(e("./scalarmult"),r),n.__exportStar(e("./secretbox"),r),n.__exportStar(e("./box"),r),n.__exportStar(e("./sign"),r),n.__exportStar(e("./hash"),r),n.__exportStar(e("./auth"),r),n.__exportStar(e("./blake2s"),r),n.__exportStar(e("./blake2b"),r),n.__exportStar(e("./sealedbox"),r)},{"./array":141,"./auth":142,"./blake2b":143,"./blake2s":144,"./box":145,"./convert":149,"./hash":152,"./random":155,"./scalarmult":157,"./sealedbox":158,"./secretbox":159,"./sign":160,"./validate":161,"./verify":162,tslib:140}],154:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array");function i(e,t,r,n){for(var i,o,a,s,u,f,c,h,l,d,p,y,b,m,v,g,w,_,M,S=e.fin?0:2048,E=e.h,A=e.r,k=E[0],B=E[1],T=E[2],j=E[3],x=E[4],P=E[5],O=E[6],R=E[7],I=E[8],C=E[9],N=A[0],U=A[1],D=A[2],L=A[3],K=A[4],z=A[5],q=A[6],H=A[7],F=A[8],V=A[9];n>=16;)d=l=0,d+=(k+=8191&(i=255&t[r+0]|(255&t[r+1])<<8))*N,d+=(B+=8191&(i>>>13|(o=255&t[r+2]|(255&t[r+3])<<8)<<3))*(5*V),d+=(T+=8191&(o>>>10|(a=255&t[r+4]|(255&t[r+5])<<8)<<6))*(5*F),d+=(j+=8191&(a>>>7|(s=255&t[r+6]|(255&t[r+7])<<8)<<9))*(5*H),l=(d+=(x+=8191&(s>>>4|(u=255&t[r+8]|(255&t[r+9])<<8)<<12))*(5*q))>>>13,d&=8191,d+=(P+=u>>>1&8191)*(5*z),d+=(O+=8191&(u>>>14|(f=255&t[r+10]|(255&t[r+11])<<8)<<2))*(5*K),d+=(R+=8191&(f>>>11|(c=255&t[r+12]|(255&t[r+13])<<8)<<5))*(5*L),d+=(I+=8191&(c>>>8|(h=255&t[r+14]|(255&t[r+15])<<8)<<8))*(5*D),p=l+=(d+=(C+=h>>>5|S)*(5*U))>>>13,p+=k*U,p+=B*N,p+=T*(5*V),p+=j*(5*F),l=(p+=x*(5*H))>>>13,p&=8191,p+=P*(5*q),p+=O*(5*z),p+=R*(5*K),p+=I*(5*L),l+=(p+=C*(5*D))>>>13,p&=8191,y=l,y+=k*D,y+=B*U,y+=T*N,y+=j*(5*V),l=(y+=x*(5*F))>>>13,y&=8191,y+=P*(5*H),y+=O*(5*q),y+=R*(5*z),y+=I*(5*K),b=l+=(y+=C*(5*L))>>>13,b+=k*L,b+=B*D,b+=T*U,b+=j*N,l=(b+=x*(5*V))>>>13,b&=8191,b+=P*(5*F),b+=O*(5*H),b+=R*(5*q),b+=I*(5*z),m=l+=(b+=C*(5*K))>>>13,m+=k*K,m+=B*L,m+=T*D,m+=j*U,l=(m+=x*N)>>>13,m&=8191,m+=P*(5*V),m+=O*(5*F),m+=R*(5*H),m+=I*(5*q),v=l+=(m+=C*(5*z))>>>13,v+=k*z,v+=B*K,v+=T*L,v+=j*D,l=(v+=x*U)>>>13,v&=8191,v+=P*N,v+=O*(5*V),v+=R*(5*F),v+=I*(5*H),g=l+=(v+=C*(5*q))>>>13,g+=k*q,g+=B*z,g+=T*K,g+=j*L,l=(g+=x*D)>>>13,g&=8191,g+=P*U,g+=O*N,g+=R*(5*V),g+=I*(5*F),w=l+=(g+=C*(5*H))>>>13,w+=k*H,w+=B*q,w+=T*z,w+=j*K,l=(w+=x*L)>>>13,w&=8191,w+=P*D,w+=O*U,w+=R*N,w+=I*(5*V),_=l+=(w+=C*(5*F))>>>13,_+=k*F,_+=B*H,_+=T*q,_+=j*z,l=(_+=x*K)>>>13,_&=8191,_+=P*L,_+=O*D,_+=R*U,_+=I*N,M=l+=(_+=C*(5*V))>>>13,M+=k*V,M+=B*F,M+=T*H,M+=j*q,l=(M+=x*z)>>>13,M&=8191,M+=P*K,M+=O*L,M+=R*D,M+=I*U,k=d=8191&(l=(l=((l+=(M+=C*N)>>>13)<<2)+l|0)+(d&=8191)|0),B=p+=l>>>=13,T=y&=8191,j=b&=8191,x=m&=8191,P=v&=8191,O=g&=8191,R=w&=8191,I=_&=8191,C=M&=8191,r+=16,n-=16;E[0]=k,E[1]=B,E[2]=T,E[3]=j,E[4]=x,E[5]=P,E[6]=O,E[7]=R,E[8]=I,E[9]=C}r.poly1305_init=function(e){var t,r,i,o,a,s,u,f,c=n.HalfArray(10),h=n.HalfArray(8);return t=255&e[0]|(255&e[1])<<8,c[0]=8191&t,r=255&e[2]|(255&e[3])<<8,c[1]=8191&(t>>>13|r<<3),i=255&e[4]|(255&e[5])<<8,c[2]=7939&(r>>>10|i<<6),o=255&e[6]|(255&e[7])<<8,c[3]=8191&(i>>>7|o<<9),a=255&e[8]|(255&e[9])<<8,c[4]=255&(o>>>4|a<<12),c[5]=a>>>1&8190,s=255&e[10]|(255&e[11])<<8,c[6]=8191&(a>>>14|s<<2),u=255&e[12]|(255&e[13])<<8,c[7]=8065&(s>>>11|u<<5),f=255&e[14]|(255&e[15])<<8,c[8]=8191&(u>>>8|f<<8),c[9]=f>>>5&127,h[0]=255&e[16]|(255&e[17])<<8,h[1]=255&e[18]|(255&e[19])<<8,h[2]=255&e[20]|(255&e[21])<<8,h[3]=255&e[22]|(255&e[23])<<8,h[4]=255&e[24]|(255&e[25])<<8,h[5]=255&e[26]|(255&e[27])<<8,h[6]=255&e[28]|(255&e[29])<<8,h[7]=255&e[30]|(255&e[31])<<8,{buffer:n.ByteArray(16),r:c,h:n.HalfArray(10),pad:h,leftover:0,fin:0}},r.poly1305_blocks=i,r.poly1305_finish=function(e,t,r){var o,a,s,u,f=n.HalfArray(10),c=e.buffer,h=e.h,l=e.pad,d=e.leftover;if(d){for(u=d,c[u++]=1;u<16;u++)c[u]=0;e.fin=1,i(e,c,0,16)}for(o=h[1]>>>13,h[1]&=8191,u=2;u<10;u++)h[u]+=o,o=h[u]>>>13,h[u]&=8191;for(h[0]+=5*o,o=h[0]>>>13,h[0]&=8191,h[1]+=o,o=h[1]>>>13,h[1]&=8191,h[2]+=o,f[0]=h[0]+5,o=f[0]>>>13,f[0]&=8191,u=1;u<10;u++)f[u]=h[u]+o,o=f[u]>>>13,f[u]&=8191;for(f[9]-=8192,a=(1^o)-1,u=0;u<10;u++)f[u]&=a;for(a=~a,u=0;u<10;u++)h[u]=h[u]&a|f[u];for(h[0]=65535&(h[0]|h[1]<<13),h[1]=65535&(h[1]>>>3|h[2]<<10),h[2]=65535&(h[2]>>>6|h[3]<<7),h[3]=65535&(h[3]>>>9|h[4]<<4),h[4]=65535&(h[4]>>>12|h[5]<<1|h[6]<<14),h[5]=65535&(h[6]>>>2|h[7]<<11),h[6]=65535&(h[7]>>>5|h[8]<<8),h[7]=65535&(h[8]>>>8|h[9]<<5),s=h[0]+l[0],h[0]=65535&s,u=1;u<8;u++)s=(h[u]+l[u]|0)+(s>>>16)|0,h[u]=65535&s;t[r+0]=h[0]>>>0&255,t[r+1]=h[0]>>>8&255,t[r+2]=h[1]>>>0&255,t[r+3]=h[1]>>>8&255,t[r+4]=h[2]>>>0&255,t[r+5]=h[2]>>>8&255,t[r+6]=h[3]>>>0&255,t[r+7]=h[3]>>>8&255,t[r+8]=h[4]>>>0&255,t[r+9]=h[4]>>>8&255,t[r+10]=h[5]>>>0&255,t[r+11]=h[5]>>>8&255,t[r+12]=h[6]>>>0&255,t[r+13]=h[6]>>>8&255,t[r+14]=h[7]>>>0&255,t[r+15]=h[7]>>>8&255},r.poly1305_update=function(e,t,r,n){var o,a,s=e.buffer;if(e.leftover){for((a=16-e.leftover)>n&&(a=n),o=0;o=16&&(i(e,t,r,a=n-n%16),r+=a,n-=a),n){for(o=0;o>>25)+_|0)<<9|i>>>23)+A|0)<<13|i>>>19)+j|0)<<18|i>>>14,k^=(i=(M^=(i=(I^=(i=(x^=(i=k+M|0)<<7|i>>>25)+k|0)<<9|i>>>23)+x|0)<<13|i>>>19)+I|0)<<18|i>>>14,P^=(i=(B^=(i=(S^=(i=(C^=(i=P+B|0)<<7|i>>>25)+P|0)<<9|i>>>23)+C|0)<<13|i>>>19)+S|0)<<18|i>>>14,N^=(i=(O^=(i=(T^=(i=(E^=(i=N+O|0)<<7|i>>>25)+N|0)<<9|i>>>23)+E|0)<<13|i>>>19)+T|0)<<18|i>>>14,_^=(i=(E^=(i=(S^=(i=(M^=(i=_+E|0)<<7|i>>>25)+_|0)<<9|i>>>23)+M|0)<<13|i>>>19)+S|0)<<18|i>>>14,k^=(i=(A^=(i=(T^=(i=(B^=(i=k+A|0)<<7|i>>>25)+k|0)<<9|i>>>23)+B|0)<<13|i>>>19)+T|0)<<18|i>>>14,P^=(i=(x^=(i=(j^=(i=(O^=(i=P+x|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+j|0)<<18|i>>>14,N^=(i=(C^=(i=(I^=(i=(R^=(i=N+C|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+I|0)<<18|i>>>14;_=_+o|0,M=M+a|0,S=S+s|0,E=E+u|0,A=A+f|0,k=k+c|0,B=B+h|0,T=T+l|0,j=j+d|0,x=x+p|0,P=P+y|0,O=O+b|0,R=R+m|0,I=I+v|0,C=C+g|0,N=N+w|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=M>>>0&255,e[5]=M>>>8&255,e[6]=M>>>16&255,e[7]=M>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=k>>>0&255,e[21]=k>>>8&255,e[22]=k>>>16&255,e[23]=k>>>24&255,e[24]=B>>>0&255,e[25]=B>>>8&255,e[26]=B>>>16&255,e[27]=B>>>24&255,e[28]=T>>>0&255,e[29]=T>>>8&255,e[30]=T>>>16&255,e[31]=T>>>24&255,e[32]=j>>>0&255,e[33]=j>>>8&255,e[34]=j>>>16&255,e[35]=j>>>24&255,e[36]=x>>>0&255,e[37]=x>>>8&255,e[38]=x>>>16&255,e[39]=x>>>24&255,e[40]=P>>>0&255,e[41]=P>>>8&255,e[42]=P>>>16&255,e[43]=P>>>24&255,e[44]=O>>>0&255,e[45]=O>>>8&255,e[46]=O>>>16&255,e[47]=O>>>24&255,e[48]=R>>>0&255,e[49]=R>>>8&255,e[50]=R>>>16&255,e[51]=R>>>24&255,e[52]=I>>>0&255,e[53]=I>>>8&255,e[54]=I>>>16&255,e[55]=I>>>24&255,e[56]=C>>>0&255,e[57]=C>>>8&255,e[58]=C>>>16&255,e[59]=C>>>24&255,e[60]=N>>>0&255,e[61]=N>>>8&255,e[62]=N>>>16&255,e[63]=N>>>24&255}function o(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,f=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,c=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,v=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,g=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=0;_<20;_+=2)o^=(i=(m^=(i=(d^=(i=(f^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+f|0)<<13|i>>>19)+d|0)<<18|i>>>14,c^=(i=(a^=(i=(v^=(i=(p^=(i=c+a|0)<<7|i>>>25)+c|0)<<9|i>>>23)+p|0)<<13|i>>>19)+v|0)<<18|i>>>14,y^=(i=(h^=(i=(s^=(i=(g^=(i=y+h|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|0)<<13|i>>>19)+s|0)<<18|i>>>14,w^=(i=(b^=(i=(l^=(i=(u^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+u|0)<<13|i>>>19)+l|0)<<18|i>>>14,o^=(i=(u^=(i=(s^=(i=(a^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+a|0)<<13|i>>>19)+s|0)<<18|i>>>14,c^=(i=(f^=(i=(l^=(i=(h^=(i=c+f|0)<<7|i>>>25)+c|0)<<9|i>>>23)+h|0)<<13|i>>>19)+l|0)<<18|i>>>14,y^=(i=(p^=(i=(d^=(i=(b^=(i=y+p|0)<<7|i>>>25)+y|0)<<9|i>>>23)+b|0)<<13|i>>>19)+d|0)<<18|i>>>14,w^=(i=(g^=(i=(v^=(i=(m^=(i=w+g|0)<<7|i>>>25)+w|0)<<9|i>>>23)+m|0)<<13|i>>>19)+v|0)<<18|i>>>14;e[0]=o>>>0&255,e[1]=o>>>8&255,e[2]=o>>>16&255,e[3]=o>>>24&255,e[4]=c>>>0&255,e[5]=c>>>8&255,e[6]=c>>>16&255,e[7]=c>>>24&255,e[8]=y>>>0&255,e[9]=y>>>8&255,e[10]=y>>>16&255,e[11]=y>>>24&255,e[12]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=l>>>0&255,e[21]=l>>>8&255,e[22]=l>>>16&255,e[23]=l>>>24&255,e[24]=d>>>0&255,e[25]=d>>>8&255,e[26]=d>>>16&255,e[27]=d>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}r._salsa20=i,r._hsalsa20=o,r._sigma=n.ByteArray([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]),r._stream=function(e,t,a,s,u){var f=n.ByteArray(32),c=n.ByteArray(8);o(f,s,u,r._sigma);for(var h=0;h<8;h++)c[h]=s[h+16];return function(e,t,o,a,s){var u,f,c=n.ByteArray(16),h=n.ByteArray(64);for(f=0;f<16;f++)c[f]=0;for(f=0;f<8;f++)c[f]=a[f];for(;o>=64;){for(i(h,c,s,r._sigma),f=0;f<64;f++)e[t+f]=h[f];for(u=1,f=8;f<16;f++)u=u+(255&c[f])|0,c[f]=255&u,u>>>=8;o-=64,t+=64}if(o>0)for(i(h,c,s,r._sigma),f=0;f=64;){for(i(d,l,f,r._sigma),h=0;h<64;h++)e[t+h]=o[a+h]^d[h];for(c=1,h=8;h<16;h++)c=c+(255&l[h])|0,l[h]=255&c,c>>>=8;s-=64,t+=64,a+=64}if(s>0)for(i(d,l,f,r._sigma),h=0;h=0;--s)a=u[s>>>3]>>>(7&s)&1,o.sel25519(c,h,a),o.sel25519(l,d,a),i.A(p,c,l),i.Z(c,c,l),i.A(l,h,d),i.Z(h,h,d),i.S(d,p),i.S(y,c),i.M(c,l,c),i.M(l,h,p),i.A(p,c,l),i.Z(c,c,l),i.S(h,c),i.Z(l,d,y),i.M(c,l,i._121665),i.A(c,c,d),i.M(l,l,c),i.M(c,d,y),i.M(d,h,f),i.S(h,p),o.sel25519(c,h,a),o.sel25519(l,d,a);for(s=0;s<16;s++)f[s+16]=c[s],f[s+32]=l[s],f[s+48]=h[s],f[s+64]=d[s];var b=f.subarray(32),m=f.subarray(16);return o.inv25519(b,b),i.M(m,m,b),o.pack25519(e,m),0}function u(e,t){return s(e,t,i._9)}r.scalarMult=function(e,t){if(a.checkArrayTypes(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=n.ByteArray(32);return s(r,e,t),r},r.scalarMult_base=function(e){if(a.checkArrayTypes(e),32!==e.length)throw new Error("bad n size");var t=n.ByteArray(32);return u(t,e),t},r._scalarMult=s,r._scalarMult_base=u},{"./array":141,"./check":146,"./core":150,"./curve25519":151}],158:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./array"),i=e("./box"),o=e("./blake2b");function a(e,t){var r=o.blake2b_init(24);return o.blake2b_update(r,e),o.blake2b_update(r,t),o.blake2b_final(r)}r.sealedbox=function(e,t){var r=n.ByteArray(48+e.length),o=i.box_keyPair();r.set(o.publicKey);var s=a(o.publicKey,t),u=i.box(e,s,t,o.secretKey);r.set(u,o.publicKey.length);for(var f=0;f=0;r--)o.S(n,n),1!==r&&o.M(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}(r,r),o.M(r,r,i),o.M(r,r,a),o.M(r,r,a),o.M(e[0],r,a),o.S(n,e[0]),o.M(n,n,a),s.neq25519(n,i)&&o.M(e[0],e[0],o.I);if(o.S(n,e[0]),o.M(n,n,a),s.neq25519(n,i))return-1;s.par25519(e[0])===t[31]>>7&&o.Z(e[0],o.gf0,e[0]);return o.M(e[3],e[0],e[1]),0}(m,a))return-1;for(f=0;f=0;--i)w(e,t,n=r[i/8|0]>>(7&i)&1),g(t,e),g(e,e),w(e,t,n)}function y(e,t){var r=o.gf(),n=o.gf(),i=o.gf();s.inv25519(i,t[2]),o.M(r,t[0],i),o.M(n,t[1],i),s.pack25519(e,n),e[31]^=s.par25519(r)<<7}function b(e){var t,r=n.NumArray(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;v(e,r)}r.sign=c,r.sign_open=function(e,t){if(f.checkArrayTypes(e,t),32!==t.length)throw new Error("bad public key size");var r=n.ByteArray(e.length),i=l(r,e,e.length,t);if(!(i<0)){for(var o=n.ByteArray(i),a=0;a=0},r.sign_keyPair=function(){var e=n.ByteArray(32),t=n.ByteArray(64);return h(e,t,!1),{publicKey:e,secretKey:t}},r.sign_keyPair_fromSecretKey=function(e){if(f.checkArrayTypes(e),64!==e.length)throw new Error("bad secret key size");for(var t=n.ByteArray(32),r=0;r=32;--n){for(r=0,i=n-32,o=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*m[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*m[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function g(e,t){var r=o.gf(),n=o.gf(),i=o.gf(),a=o.gf(),s=o.gf(),u=o.gf(),f=o.gf(),c=o.gf(),h=o.gf();o.Z(r,e[1],e[0]),o.Z(h,t[1],t[0]),o.M(r,r,h),o.A(n,e[0],e[1]),o.A(h,t[0],t[1]),o.M(n,n,h),o.M(i,e[3],t[3]),o.M(i,i,o.D2),o.M(a,e[2],t[2]),o.A(a,a,a),o.Z(s,n,r),o.Z(u,a,i),o.A(f,a,i),o.A(c,n,r),o.M(e[0],s,u),o.M(e[1],c,f),o.M(e[2],f,u),o.M(e[3],s,c)}function w(e,t,r){for(var n=0;n<4;n++)s.sel25519(e[n],t[n],r)}},{"./array":141,"./check":146,"./core":150,"./curve25519":151,"./hash":152,"./random":155,"./verify":162}],161:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateBase64=function(e){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid base64 string")},r.validateHex=function(e){if(!/^(?:[A-Fa-f0-9]{2})+$/.test(e))throw new TypeError("invalid hex string")}},{}],162:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./check");function i(e,t,r,n,i){var o,a=0;for(o=0;o>>8)-1}r._verify_16=function(e,t,r,n){return i(e,t,r,n,16)},r._verify_32=function(e,t,r,n){return i(e,t,r,n,32)},r.verify=function(e,t){return n.checkArrayTypes(e,t),e.length>0&&t.length>0&&e.length==t.length&&0==i(e,0,t,0,e.length)}},{"./check":146}],163:[function(e,t,r){(function(e){(function(){!function(e,r){"use strict";void 0!==t&&t.exports?t.exports=r():e.nacl?e.nacl.util=r():(e.nacl={},e.nacl.util=r())}(this,function(){"use strict";var t={};function r(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return t.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(t=0;t=2&&'"'===e[0]&&'"'===e[e.length-1];if(t===Date){var i=!isNaN(Number(e.trim()));return!n&&!i}return r&&!n}r.LAZY_TYPE_EXPLANATION="If the type is not yet defined, for example due to circular references, add '() => ' before it. E.g. @jsonMember(() => Foo)",r.MISSING_REFLECT_CONF_MSG='Make sure that you have both "experimentalDecorators" and "emitDecoratorMetadata" enabled in your tsconfig.json',r.isDirectlySerializableNativeType=function(e){return-1!==[Date,Number,String,Boolean].indexOf(e)},r.isDirectlyDeserializableNativeType=function(e){return-1!==[Number,String,Boolean].indexOf(e)},r.isTypeTypedArray=function(e){return-1!==[Float32Array,Float64Array,Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array].indexOf(e)},r.isObject=o,r.shouldOmitParseString=a,r.parseToJSObject=function(e,t){return"string"!=typeof e||a(e,t)?e:JSON.parse(e)},r.isSubtypeOf=function(e,t){return e===t||e.prototype instanceof t},r.logError=function(e){for(var t=[],r=1;r-1}).reduce(function(t,r){return t[r]=e[r],t},{});return Object.keys(t).length>0?t:void 0},r.getDefaultOptionOf=o,r.getOptionValue=function(e,t){return null!=t&&null!=t[e]?t[e]:o(e)},r.mergeOptions=function(e,t){return null==t?e:n(n({},e),t)}},{}],174:[function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function h(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function l(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=l(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=l(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=f(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(h)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function b(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},d.call(y.prototype),d.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},m.error=function(){var e=new m(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];m.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new m(null,{status:t,headers:{location:e}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function g(n,i){return new Promise(function(o,s){var f=new y(n,i);if(f.signal&&f.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var c=new XMLHttpRequest;function h(){c.abort()}c.onload=function(){var e,t,r={status:c.status,statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e}).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in c?c.responseURL:r.headers.get("X-Request-URL");var n="response"in c?c.response:c.responseText;setTimeout(function(){o(new m(n,r))},0)},c.onerror=function(){setTimeout(function(){s(new TypeError("Network request failed"))},0)},c.ontimeout=function(){setTimeout(function(){s(new TypeError("Network request failed"))},0)},c.onabort=function(){setTimeout(function(){s(new e.DOMException("Aborted","AbortError"))},0)},c.open(f.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(f.url),!0),"include"===f.credentials?c.withCredentials=!0:"omit"===f.credentials&&(c.withCredentials=!1),"responseType"in c&&(r.blob?c.responseType="blob":r.arrayBuffer&&f.headers.get("Content-Type")&&-1!==f.headers.get("Content-Type").indexOf("application/octet-stream")&&(c.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof u?f.headers.forEach(function(e,t){c.setRequestHeader(t,e)}):Object.getOwnPropertyNames(i.headers).forEach(function(e){c.setRequestHeader(e,a(i.headers[e]))}),f.signal&&(f.signal.addEventListener("abort",h),c.onreadystatechange=function(){4===c.readyState&&f.signal.removeEventListener("abort",h)}),c.send(void 0===f._bodyInit?null:f._bodyInit)})}g.polyfill=!0,t.fetch||(t.fetch=g,t.Headers=u,t.Request=y,t.Response=m),e.Headers=u,e.Request=y,e.Response=m,e.fetch=g,Object.defineProperty(e,"__esModule",{value:!0})}("object"==typeof r&&void 0!==t?r:n.WHATWGFetch={})},{}],181:[function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),i(e("./services"),r),i(e("./lib"),r);var o=e("./lib/Conversions");Object.defineProperty(r,"base64to16",{enumerable:!0,get:function(){return o.base64to16}}),Object.defineProperty(r,"encodeBase16",{enumerable:!0,get:function(){return o.encodeBase16}}),Object.defineProperty(r,"decodeBase16",{enumerable:!0,get:function(){return o.decodeBase16}}),Object.defineProperty(r,"encodeBase64",{enumerable:!0,get:function(){return o.encodeBase64}}),Object.defineProperty(r,"decodeBase64",{enumerable:!0,get:function(){return o.decodeBase64}})},{"./lib":194,"./lib/Conversions":186,"./services":198}],182:[function(e,t,r){(function(t){(function(){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.URef=r.AccessRights=r.KeyValue=r.AccountHash=r.KeyVariant=r.CLValue=r.CLTypedAndToBytesHelper=r.CLTypeHelper=r.OptionType=r.MapValue=r.PublicKey=r.Tuple3=r.Tuple2=r.Tuple1=r.List=r.fromBytesByCLType=r.StringValue=r.Unit=r.U512=r.U128=r.I64=r.U64=r.I32=r.U32=r.U8=r.Bool=r.Result=r.FromBytesError=r.SimpleType=r.staticImplements=r.CLTypedAndToBytes=void 0;var s=e("@ethersproject/bytes"),u=e("./byterepr"),f=e("@ethersproject/bignumber"),c=e("./Conversions"),h=e("./option"),l=e("./Contracts"),d=e("./Keys"),p=e("typedjson"),y=function(){function e(){}return e.prototype.clTypeEncoded=function(){return G.toBytesHelper(this.clType())},e}();function b(){return function(e){}}r.CLTypedAndToBytes=y,r.staticImplements=b;var m,v,g;!function(e){e[e.Bool=0]="Bool",e[e.I32=1]="I32",e[e.I64=2]="I64",e[e.U8=3]="U8",e[e.U32=4]="U32",e[e.U64=5]="U64",e[e.U128=6]="U128",e[e.U256=7]="U256",e[e.U512=8]="U512",e[e.Unit=9]="Unit",e[e.String=10]="String",e[e.Key=11]="Key",e[e.URef=12]="URef",e[e.PublicKey=22]="PublicKey"}(m=r.SimpleType||(r.SimpleType={})),function(e){e[e.Option=13]="Option",e[e.List=14]="List",e[e.ByteArray=15]="ByteArray",e[e.Result=16]="Result",e[e.Map=17]="Map",e[e.Tuple1=18]="Tuple1",e[e.Tuple2=19]="Tuple2",e[e.Tuple3=20]="Tuple3",e[e.Any=21]="Any"}(v||(v={})),function(e){e[e.Ok=0]="Ok",e[e.EarlyEndOfStream=1]="EarlyEndOfStream",e[e.FormattingError=2]="FormattingError"}(g=r.FromBytesError||(r.FromBytesError={}));var w=function(){function e(e,t,r){this.val=e,this.rem=t,this.error=r}return e.Err=function(t){return new e(null,null,t)},e.Ok=function(t,r){return new e(t,r,g.Ok)},e.prototype.remainder=function(){if(null===this.rem)throw new Error("Don't have remainder");return this.rem},e.prototype.value=function(){if(!this.hasValue())throw new Error("Don't have value");return this.val},e.prototype.hasValue=function(){return null!==this.val},e.prototype.hasError=function(){return this.error!==g.Ok},e}();r.Result=w;var _=function(e){function t(t){var r=e.call(this)||this;return r.val=t,r}var r;return i(t,e),r=t,t.prototype.toBytes=function(){return new Uint8Array([this.val?1:0])},t.prototype.clType=function(){return m.Bool},t.fromBytes=function(e){return 0===e.length?w.Err(g.EarlyEndOfStream):1===e[0]?w.Ok(new r(!0),e.subarray(1)):0===e[0]?w.Ok(new r(!1),e.subarray(1)):w.Err(g.FormattingError)},t=r=o([function(e){},a("design:paramtypes",[Boolean])],t)}(y);r.Bool=_;var M=function(e){function t(t,r,n){var i=e.call(this)||this;return i.toBytes=function(){return u.toBytesNumber(i.bitSize,i.signed,i.val)},i.name=(r?"i":"u")+t,i.bitSize=t,i.signed=r,i.val=f.BigNumber.from(n),i}return i(t,e),t}(y),S=function(e){function t(t){return e.call(this,8,!1,t)||this}var r;return i(t,e),r=t,t.prototype.clType=function(){return m.U8},t.fromBytes=function(e){return 0===e.length?w.Err(g.EarlyEndOfStream):w.Ok(new r(e[0]),e.subarray(1))},t=r=o([function(e){},a("design:paramtypes",[Number])],t)}(M);r.U8=S;var E=function(e){function r(t){return e.call(this,32,!1,t)||this}var n;return i(r,e),n=r,r.prototype.clType=function(){return m.U32},r.fromBytes=function(e){if(e.length<4)return w.Err(g.EarlyEndOfStream);var r=t.from(e.subarray(0,4)).readUInt32LE(0);return w.Ok(new n(r),e.subarray(4))},r=n=o([function(e){},a("design:paramtypes",[Number])],r)}(M);r.U32=E;var A=function(e){function r(t){return e.call(this,32,!0,t)||this}var n;return i(r,e),n=r,r.prototype.clType=function(){return m.I32},r.fromBytes=function(e){if(e.length<4)return w.Err(g.EarlyEndOfStream);var r=t.from(e.subarray(0,4)).readInt32LE(0);return w.Ok(new n(r),e.subarray(4))},r=n=o([function(e){},a("design:paramtypes",[Number])],r)}(M);r.I32=A;var k=function(e){function t(t){return e.call(this,64,!1,t)||this}var r;return i(t,e),r=t,t.prototype.clType=function(){return m.U64},t.fromBytes=function(e){var t=Uint8Array.from(e);if(e.length<8)return w.Err(g.EarlyEndOfStream);var n=t.subarray(0,8),i=t.subarray(8);return w.Ok(new r(f.BigNumber.from(n.reverse())),i)},t=r=o([function(e){},a("design:paramtypes",[Object])],t)}(M);r.U64=k;var B=function(e){function t(t){return e.call(this,64,!0,t)||this}var r;return i(t,e),r=t,t.prototype.clType=function(){return m.I64},t.fromBytes=function(e){if(e.length<8)return w.Err(g.EarlyEndOfStream);var t=Uint8Array.from(e),n=t.subarray(0,8),i=t.subarray(8);return w.Ok(new r(f.BigNumber.from(n.reverse()).fromTwos(64)),i)},t=r=o([function(e){},a("design:paramtypes",[Object])],t)}(M);r.I64=B;var T=function(e){function t(t){return e.call(this,128,!1,t)||this}return i(t,e),t.prototype.clType=function(){return m.U128},t.fromBytes=function(e){return z(e,128)},t=o([function(e){},a("design:paramtypes",[Object])],t)}(M);r.U128=T;var j=function(e){function t(t){return e.call(this,256,!1,t)||this}return i(t,e),t.prototype.clType=function(){return m.U256},t.fromBytes=function(e){return z(e,256)},t=o([function(e){},a("design:paramtypes",[Object])],t)}(M),x=function(e){function t(t){return e.call(this,512,!1,t)||this}return i(t,e),t.prototype.clType=function(){return m.U512},t.fromBytes=function(e){return z(e,512)},t=o([function(e){},a("design:paramtypes",[Object])],t)}(M);r.U512=x;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}var r;return i(t,e),r=t,t.prototype.clType=function(){return m.Unit},t.prototype.toBytes=function(){return Uint8Array.from([])},t.fromBytes=function(e){return w.Ok(new r,e)},t=r=o([function(e){}],t)}(y);r.Unit=P;var O=function(e){function r(t){var r=e.call(this)||this;return r.val=t,r.toBytes=function(){return u.toBytesString(r.val)},r}var n;return i(r,e),n=r,r.prototype.clType=function(){return m.String},r.fromBytes=function(e){var r=E.fromBytes(e);if(r.hasError())return w.Err(r.error);var i=r.value().val.toNumber(),o=t.from(r.remainder().subarray(0,i)).toString("utf8");return w.Ok(new n(o),r.remainder().subarray(i))},r=n=o([function(e){},a("design:paramtypes",[String])],r)}(y);r.StringValue=O,r.fromBytesByCLType=function(e,t){return e instanceof H?I.fromBytes(e,t):e instanceof W?C.fromBytes(e,t):e instanceof J?N.fromBytes(e,t):e instanceof Z?U.fromBytes(e,t):e instanceof F?K.fromBytes(t):e instanceof V?L.fromBytes(e,t):e instanceof q?h.Option.fromBytes(e,t):R(e,t)};var R=function(e,t){var r;switch(e){case m.Bool:r=_.fromBytes(t);break;case m.I32:r=A.fromBytes(t);break;case m.I64:r=B.fromBytes(t);break;case m.U8:r=S.fromBytes(t);break;case m.U32:r=E.fromBytes(t);break;case m.U64:r=k.fromBytes(t);break;case m.U128:r=T.fromBytes(t);break;case m.U256:r=j.fromBytes(t);break;case m.U512:r=x.fromBytes(t);break;case m.Unit:r=P.fromBytes(t);break;case m.String:r=O.fromBytes(t);break;case m.Key:r=ne.fromBytes(t);break;case m.URef:r=oe.fromBytes(t);break;case m.PublicKey:r=D.fromBytes(t);break;default:r=w.Err(g.FormattingError)}return r.hasError()?w.Err(r.error):w.Ok(r.value(),r.remainder())},I=function(e){function t(t){var r=e.call(this)||this;if(r.vec=t,0===t.length)throw new Error("Can't create instance for empty list");return r}return i(t,e),t.prototype.clType=function(){return G.list(this.vec[0].clType())},t.prototype.toBytes=function(){return u.toBytesVecT(this.vec)},t.fromBytes=function(e,n){var i=E.fromBytes(n);if(i.hasError())return w.Err(i.error);for(var o=i.value().val.toNumber(),a=[],s=i.remainder(),u=0;ur)return w.Err(g.FormattingError);if(o+1>e.length)return w.Err(g.EarlyEndOfStream);n=0===o?[0]:i.subarray(1,1+o);var a=i.subarray(1+o);return 128===t?w.Ok(new T(f.BigNumber.from(n.reverse())),a):256===t?w.Ok(new j(f.BigNumber.from(n.reverse())),a):512===t?w.Ok(new x(f.BigNumber.from(n.reverse())),a):w.Err(g.FormattingError)},q=function(){function e(e){this.innerType=e,this.tag=v.Option}return e.prototype.toJSON=function(){var t,r=Y(this.innerType);return(t={})[e.TypeId]=r,t},e.TypeId="Option",e}();r.OptionType=q;var H=function(){function e(e){this.tag=v.List,this.innerType=e}return e.prototype.toJSON=function(){var t,r=Y(this.innerType);return(t={})[e.TypeId]=r,t},e.TypeId="List",e}(),F=function(){function e(e){this.size=e,this.tag=v.ByteArray}return e.prototype.toJSON=function(){var t;return(t={})[e.TypeId]=this.size,t},e.TypeId="ByteArray",e}(),V=function(){function e(e,t){this.keyType=e,this.valueType=t,this.tag=v.Map}return e.prototype.toJSON=function(){var t;return(t={})[e.TypeId]={key:Y(this.keyType),value:Y(this.valueType)},t},e.TypeId="Map",e}(),W=function(){function e(e){this.t0=e,this.tag=v.Tuple1}return e.prototype.toJSON=function(){var t,r=Y(this.t0);return(t={})[e.TypeId]=r,t},e.TypeId="Tuple1",e}(),J=function(){function e(e,t){this.t0=e,this.t1=t,this.tag=v.Tuple2}return e.prototype.toJSON=function(){var t,r=Y(this.t0),n=Y(this.t1);return(t={})[e.TypeId]=[r,n],t},e.TypeId="Tuple2",e}(),Z=function(){function e(e,t,r){this.t0=e,this.t1=t,this.t2=r,this.tag=v.Tuple3}return e.prototype.toJSON=function(){var t,r=Y(this.t0),n=Y(this.t1),i=Y(this.t2);return(t={})[e.TypeId]=[r,n,i],t},e.TypeId="Tuple3",e}(),G=function(){function e(){}return e.u8=function(){return m.U8},e.u32=function(){return m.U32},e.u64=function(){return m.U64},e.u128=function(){return m.U128},e.u256=function(){return m.U256},e.u512=function(){return m.U512},e.i32=function(){return m.I32},e.i64=function(){return m.I64},e.bool=function(){return m.Bool},e.unit=function(){return m.Unit},e.string=function(){return m.String},e.key=function(){return m.Key},e.publicKey=function(){return m.PublicKey},e.uRef=function(){return m.URef},e.option=function(e){return new q(e)},e.list=function(e){return new H(e)},e.byteArray=function(e){return new F(e)},e.map=function(e,t){return new V(e,t)},e.tuple1=function(e){return new W(e)},e.tuple2=function(e,t){return new J(e,t)},e.tuple3=function(e,t,r){return new Z(e,t,r)},e.fromBytes=function(t){if(t.length<1)return w.Err(g.EarlyEndOfStream);var r=t[0],n=t.subarray(1);switch(r){case m.Bool:case m.I32:case m.I64:case m.U8:case m.U32:case m.U64:case m.U256:case m.U512:case m.Unit:case m.String:case m.Key:case m.URef:case m.PublicKey:return w.Ok(r,n);case v.Option:return(s=e.fromBytes(n)).hasError()?w.Err(s.error):w.Ok(e.option(s.value()),s.remainder());case v.List:return(s=e.fromBytes(n)).hasError()?w.Err(s.error):w.Ok(e.list(s.value()),s.remainder());case v.ByteArray:var i=E.fromBytes(n);return i.hasError()?w.Err(i.error):w.Ok(e.byteArray(i.value().val.toNumber()),i.remainder());case v.Result:throw new Error("Result type is unsupported now");case v.Map:var o=e.fromBytes(n);if(o.hasError())return w.Err(o.error);var a=e.fromBytes(o.remainder());return a.hasError()?w.Err(a.error):w.Ok(e.map(o.value(),a.value()),a.remainder());case v.Tuple1:var s;return(s=e.fromBytes(n)).hasError()?w.Err(s.error):w.Ok(e.tuple1(s.value()),s.remainder());case v.Tuple2:return(u=e.fromBytes(n)).hasError()?w.Err(u.error):(f=e.fromBytes(u.remainder())).hasError()?w.Err(f.error):w.Ok(e.tuple2(u.value(),f.value()),f.remainder());case v.Tuple3:var u,f;if((u=e.fromBytes(n)).hasError())return w.Err(u.error);if((f=e.fromBytes(u.remainder())).hasError())return w.Err(f.error);var c=e.fromBytes(u.remainder());return c.hasError()?w.Err(c.error):w.Ok(e.tuple3(u.value(),f.value(),c.value()),c.remainder());case v.Any:throw new Error("Any type is unsupported now");default:return w.Err(g.FormattingError)}},e.toBytesHelper=function(t){if(t instanceof H)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.innerType)]);if(t instanceof W)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.t0)]);if(t instanceof J)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.t0),e.toBytesHelper(t.t1)]);if(t instanceof Z)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.t0),e.toBytesHelper(t.t1),e.toBytesHelper(t.t2)]);if(t instanceof F)return s.concat([Uint8Array.from([t.tag]),u.toBytesU32(t.size)]);if(t instanceof V)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.keyType),e.toBytesHelper(t.valueType)]);if(t instanceof q)return s.concat([Uint8Array.from([t.tag]),e.toBytesHelper(t.innerType)]);switch(t){case m.Bool:case m.I32:case m.I64:case m.U8:case m.U32:case m.U64:case m.U128:case m.U256:case m.U512:case m.Unit:case m.String:case m.Key:case m.URef:case m.PublicKey:return Uint8Array.from([t]);default:throw new Error("Wrong type")}},e}();r.CLTypeHelper=G;var X=function(){function e(){}return e.list=function(e){return new I(e)},e.tuple1=function(e){return new C(e)},e.tuple2=function(e,t){return new N(e,t)},e.tuple3=function(e,t,r){return new U(e,t,r)},e.option=function(e,t){return new h.Option(e,t)},e.map=function(e){return new L(e)},e.publicKey=function(e){return D.fromEd25519(e)},e.bytes=function(e){return new K(e)},e.bool=function(e){return new _(e)},e.u8=function(e){return new S(e)},e.u32=function(e){return new E(e)},e.i32=function(e){return new A(e)},e.u64=function(e){return new k(e)},e.i64=function(e){return new B(e)},e.u128=function(e){return new T(e)},e.u256=function(e){return new j(e)},e.u512=function(e){return new x(e)},e.unit=function(){return new P},e.string=function(e){return new O(e)},e}();r.CLTypedAndToBytesHelper=X;var Y=function(e){return e instanceof H||e instanceof W||e instanceof J||e instanceof Z||e instanceof F||e instanceof V||e instanceof q?e.toJSON():function(e){switch(e){case m.Bool:return"Bool";case m.I32:return"I32";case m.I64:return"I64";case m.U8:return"U8";case m.U32:return"U32";case m.U64:return"U64";case m.U128:return"U128";case m.U256:return"U256";case m.U512:return"U512";case m.Unit:return"Unit";case m.String:return"String";case m.Key:return"Key";case m.URef:return"URef";case m.PublicKey:return"PublicKey"}}(e)},$=function(e){if("string"==typeof e)return function(e){switch(e){case"Bool":return m.Bool;case"I32":return m.I32;case"I64":return m.I64;case"U8":return m.U8;case"U32":return m.U32;case"U64":return m.U64;case"U128":return m.U128;case"U256":return m.U256;case"U512":return m.U512;case"Unit":return m.Unit;case"String":return m.String;case"Key":return m.Key;case"URef":return m.URef;case"PublicKey":return m.PublicKey;default:throw new Error("The type "+e+" is not supported")}}(e);if(typeof e==typeof{}){if(H.TypeId in e){var t=$(e[H.TypeId]);return G.list(t)}if(W.TypeId in e){var r=$(e[W.TypeId][0]);return G.tuple1(r)}if(J.TypeId in e){var n=e[J.TypeId],i=(r=$(n[0]),$(n[1]));return G.tuple2(r,i)}if(Z.TypeId in e){n=e[J.TypeId],r=$(n[0]),i=$(n[1]);var o=$(n[2]);return G.tuple3(r,i,o)}if(F.TypeId in e){var a=e[F.TypeId];return G.byteArray(a)}if(q.TypeId in e){t=$(e[q.TypeId]);return G.option(t)}if(V.TypeId in e){var s=$(e[V.TypeId].key),u=$(e[V.TypeId].value);return G.map(s,u)}throw new Error("The type "+e+" is not supported")}throw new Error("The type "+e+" is not supported")};function Q(e,t){var n=r.fromBytesByCLType(e.clType,c.decodeBase16(e.bytes));return te.fromT(n.value())}var ee,te=function(){function e(e,t){this.value=e,this.clType=t,this.bytes=c.encodeBase16(this.value.toBytes())}var t;return t=e,e.prototype.clValueBytes=function(){return this.value.toBytes()},e.fromT=function(e){return new t(e,e.clType())},e.prototype.toBytes=function(){return s.concat([u.toBytesArrayU8(this.clValueBytes()),G.toBytesHelper(this.clType)])},e.fromBytes=function(e){var n=K.fromBytes(e);if(n.hasError())return w.Err(n.error);var i=G.fromBytes(n.remainder());if(i.hasError())return w.Err(i.error);var o=r.fromBytesByCLType(i.value(),n.value().rawBytes),a=new t(o.value(),i.value());return w.Ok(a,i.remainder())},e.prototype.reconstruct=function(){var e=r.fromBytesByCLType(this.clType,c.decodeBase16(this.bytes));if(e.hasError())throw new Error("Failed to deserialize CLValue");this.value=e.value()},e.list=function(e){return t.fromT(new I(e))},e.tuple1=function(e){return t.fromT(new C(e))},e.tuple2=function(e,r){return t.fromT(new N(e,r))},e.tuple3=function(e,r,n){return t.fromT(new U(e,r,n))},e.option=function(e,r){return t.fromT(new h.Option(e,r))},e.map=function(e){return t.fromT(new L(e))},e.publicKey=function(e){return t.fromT(e)},e.byteArray=function(e){return t.fromT(new K(e))},e.prototype.isBigNumber=function(){return this.clType===m.U8||this.clType===m.I32||this.clType===m.I64||this.clType===m.U32||this.clType===m.U64||this.clType===m.U128||this.clType===m.U256||this.clType===m.U512},e.prototype.asBigNumber=function(){if(this.isBigNumber()){var e=this.value;return f.BigNumber.from(e.val)}throw new Error("The CLValue is not an instance of BigNumber")},e.prototype.isBoolean=function(){return this.clType===m.Bool},e.prototype.asBoolean=function(){if(!this.isBoolean())throw new Error("The CLValue is not an instance of Boolean");return this.value.val},e.prototype.isString=function(){return this.clType===m.String},e.prototype.asString=function(){if(!this.isString())throw new Error("The CLValue is not an instance of String");return this.value.val},e.prototype.isPublicKey=function(){return this.clType===m.PublicKey},e.prototype.asPublicKey=function(){if(!this.isPublicKey())throw new Error("The CLValue is not an instance of PublicKey");return this.value},e.prototype.isKey=function(){return this.clType===m.Key},e.prototype.asKey=function(){if(!this.isKey())throw new Error("The CLValue is not an instance of Key");return this.value},e.prototype.isURef=function(){return this.clType===m.URef},e.prototype.asURef=function(){if(!this.isURef())throw new Error("The CLValue is not an instance of URef");return this.value},e.prototype.isBytesArray=function(){return this.clType instanceof F},e.prototype.asBytesArray=function(){if(!this.isBytesArray())throw new Error("The CLValue is not an instance of BytesArray");return this.value.toBytes()},e.prototype.isOption=function(){return this.clType instanceof q},e.prototype.asOption=function(){if(!this.isOption())throw new Error("The CLValue is not an instance of Option");return this.value},e.prototype.isList=function(){return this.clType instanceof H},e.prototype.asList=function(){if(!this.isList())throw new Error("The CLValue is not an instance of List");var e=this.clType,r=I.fromBytes(e,this.clValueBytes());if(r.hasError())throw new Error("The CLValue can not be parsed to list.");return r.value().vec.map(function(e){return t.fromT(e)})},e.bool=function(e){return t.fromT(new _(e))},e.u8=function(e){return t.fromT(new S(e))},e.u32=function(e){return t.fromT(new E(e))},e.i32=function(e){return t.fromT(new A(e))},e.u64=function(e){return t.fromT(new k(e))},e.i64=function(e){return t.fromT(new B(e))},e.u128=function(e){return t.fromT(new T(e))},e.u256=function(e){return t.fromT(new j(e))},e.u512=function(e){return t.fromT(new x(e))},e.unit=function(){return t.fromT(new P)},e.string=function(e){return t.fromT(new O(e))},e.key=function(e){return t.fromT(e)},e.uref=function(e){return t.fromT(e)},e.stringList=function(e){var r=X.list(e.map(function(e){return X.string(e)}));return new t(r,G.list(m.String))},o([p.jsonMember({name:"cl_type",serializer:Y,deserializer:$}),a("design:type",Object)],e.prototype,"clType",void 0),o([p.jsonMember({constructor:String}),a("design:type",String)],e.prototype,"bytes",void 0),o([p.jsonMember({serializer:function(e){return"null"},deserializer:function(e){return null}}),a("design:type",Object)],e.prototype,"parsed",void 0),e=t=o([p.jsonObject({initializer:function(e,t){return Q(e)}}),a("design:paramtypes",[y,Object])],e)}();r.CLValue=te,function(e){e[e.ACCOUNT_ID=0]="ACCOUNT_ID",e[e.HASH_ID=1]="HASH_ID",e[e.UREF_ID=2]="UREF_ID"}(ee=r.KeyVariant||(r.KeyVariant={}));var re=function(e){function t(t){var r=e.call(this)||this;return r.bytes=t,r}var r;return i(t,e),r=t,t.prototype.toBytes=function(){return this.bytes},t.prototype.clType=function(){return G.byteArray(32)},t.fromBytes=function(e){if(e.length<32)return w.Err(g.EarlyEndOfStream);var t=e.subarray(0,32),n=new r(t);return w.Ok(n,e.subarray(32))},t=r=o([function(e){},a("design:paramtypes",[Uint8Array])],t)}(y);r.AccountHash=re;var ne=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}var r;return i(t,e),r=t,t.prototype.isHash=function(){return this.variant===ee.HASH_ID},t.prototype.isURef=function(){return this.variant===ee.UREF_ID},t.prototype.isAccount=function(){return this.variant===ee.ACCOUNT_ID},t.fromURef=function(e){var t=new r;return t.variant=ee.UREF_ID,t.uRef=e,t},t.fromHash=function(e){var t=new r;return t.variant=ee.HASH_ID,t.hash=e,t},t.fromAccount=function(e){var t=new r;return t.variant=ee.ACCOUNT_ID,t.account=e,t},t.prototype.clType=function(){return m.Key},t.prototype.toBytes=function(){if(this.variant===ee.ACCOUNT_ID)return s.concat([Uint8Array.from([this.variant]),this.account.toBytes()]);if(this.variant===ee.HASH_ID)return s.concat([Uint8Array.from([this.variant]),this.hash]);if(this.variant===ee.UREF_ID)return s.concat([Uint8Array.from([this.variant]),this.uRef.toBytes()]);throw new Error("Unknown variant")},t.fromBytes=function(e){if(e.length<1)return w.Err(g.EarlyEndOfStream);var t=e[0],n=1;if(t===ee.HASH_ID){var i=e.subarray(n,32+n);n+=32;var o=r.fromHash(i);return w.Ok(o,e.subarray(n))}if(t===ee.UREF_ID){var a=e.subarray(1),s=oe.fromBytes(a);if(s.hasError())return w.Err(s.error);o=r.fromURef(s.value());return w.Ok(o,s.remainder())}if(t===ee.ACCOUNT_ID){var u=e.subarray(1),f=re.fromBytes(u);if(f.hasError())return w.Err(f.error);o=r.fromAccount(f.value());return w.Ok(o,f.remainder())}return w.Err(g.FormattingError)},t=r=o([function(e){}],t)}(y);r.KeyValue=ne;var ie="uref-";!function(e){e[e.None=0]="None",e[e.READ=1]="READ",e[e.WRITE=2]="WRITE",e[e.ADD=4]="ADD",e[e.READ_WRITE=3]="READ_WRITE",e[e.READ_ADD=5]="READ_ADD",e[e.ADD_WRITE=6]="ADD_WRITE",e[e.READ_ADD_WRITE=7]="READ_ADD_WRITE"}(r.AccessRights||(r.AccessRights={}));var oe=function(e){function t(t,r){var n=e.call(this)||this;if(n.uRefAddr=t,n.accessRights=r,32!==n.uRefAddr.byteLength)throw new Error("The length of URefAddr should be 32");return n}var r;return i(t,e),r=t,t.fromFormattedStr=function(e){if(!e.startsWith(ie))throw new Error("prefix is not 'uref-'");var t=e.substring(ie.length).split("-",2);if(2!==t.length)throw new Error("no access rights as suffix");var n=c.decodeBase16(t[0]),i=parseInt(t[1],8);return new r(n,i)},t.prototype.toFormattedStr=function(){return[ie,c.encodeBase16(this.uRefAddr),this.accessRights.toString(8)].join("-")},t.prototype.toBytes=function(){return s.concat([this.uRefAddr,Uint8Array.from([this.accessRights])])},t.prototype.clType=function(){return G.uRef()},t.fromBytes=function(e){if(e.length<33)return w.Err(g.EarlyEndOfStream);var t=e.subarray(0,32),n=e[32],i=new r(t,n);return w.Ok(i,e.subarray(33))},t=r=o([function(e){},a("design:paramtypes",[Uint8Array,Number])],t)}(y);r.URef=oe}).call(this)}).call(this,e("buffer").Buffer)},{"./Contracts":185,"./Conversions":186,"./Keys":188,"./byterepr":193,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,buffer:266,typedjson:166}],183:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.deployToBytes=r.validateDeploy=r.deploySizeInBytes=r.addArgToDeploy=r.deployFromJson=r.deployToJson=r.standardPayment=r.setSignature=r.signDeploy=r.makeDeploy=r.DeployParams=r.ContractType=r.serializeApprovals=r.serializeBody=r.serializeHeader=r.Deploy=r.ExecutableDeployItem=r.Transfer=r.StoredVersionedContractByHash=r.StoredVersionedContractByName=r.StoredContractByName=r.StoredContractByHash=r.ModuleBytes=r.Approval=r.DeployHeader=r.UniqAddress=r.dehumanizerTTL=r.humanizerTTL=void 0;var u=e("@ethersproject/bytes"),f=s(e("blakejs")),c=e("./option"),h=e("./Conversions"),l=s(e("humanize-duration")),d=e("./CLValue"),p=e("./byterepr"),y=e("./RuntimeArgs"),b=e("./index"),m=e("./Keys"),v=e("@ethersproject/bignumber"),g=e("typedjson"),w=e("tweetnacl-ts"),_=e("ts-results"),M=l.default.humanizer({spacer:"",serialComma:!1,conjunction:" ",delimiter:" ",language:"shortEn",languages:{shortEn:{d:function(){return"day"},h:function(){return"h"},m:function(){return"m"},s:function(){return"s"},ms:function(){return"ms"}}}}),S=function(e){return h.encodeBase16(e)},E=function(e){return h.decodeBase16(e)};r.humanizerTTL=function(e){return M(e)},r.dehumanizerTTL=function(e){return e.split(" ").map(function(e){if(e.includes("ms"))return Number(e.replace("ms",""));if(e.includes("s")&&!e.includes("m"))return 1e3*Number(e.replace("s",""));if(e.includes("m")&&!e.includes("s"))return 60*Number(e.replace("m",""))*1e3;if(e.includes("h"))return 60*Number(e.replace("h",""))*60*1e3;if(e.includes("day"))return 24*Number(e.replace("day",""))*60*60*1e3;throw Error("Unsuported TTL unit")}).reduce(function(e,t){return e+t})};var A=function(){function e(e,t){if(!(e instanceof d.PublicKey))throw new Error("publicKey is not an instance of PublicKey");var r=v.BigNumber.from(t);if(r.gt("18446744073709551615"))throw new Error("transferId max value is U64");this.transferId=r,this.publicKey=e}return e.prototype.toString=function(){return this.publicKey.toAccountHex()+"-"+this.transferId.toHexString()},e.fromString=function(t){var r=t.split("-"),n=r[0],i=r[1];return new e(d.PublicKey.fromHex(n),i)},e}();r.UniqAddress=A;var k=function(){function e(e,t,r,n,i,o,a){this.account=e,this.timestamp=t,this.ttl=r,this.gasPrice=n,this.bodyHash=i,this.dependencies=o,this.chainName=a}return e.prototype.toBytes=function(){return u.concat([this.account.toBytes(),p.toBytesU64(this.timestamp),p.toBytesU64(this.ttl),p.toBytesU64(this.gasPrice),p.toBytesDeployHash(this.bodyHash),p.toBytesVecT(this.dependencies.map(function(e){return new B(e)})),p.toBytesString(this.chainName)])},o([g.jsonMember({serializer:function(e){return e.toAccountHex()},deserializer:function(e){return d.PublicKey.fromHex(e)}}),a("design:type",d.PublicKey)],e.prototype,"account",void 0),o([g.jsonMember({serializer:function(e){return new Date(e).toISOString()},deserializer:function(e){return Date.parse(e)}}),a("design:type",Number)],e.prototype,"timestamp",void 0),o([g.jsonMember({serializer:r.humanizerTTL,deserializer:r.dehumanizerTTL}),a("design:type",Number)],e.prototype,"ttl",void 0),o([g.jsonMember({constructor:Number,name:"gas_price"}),a("design:type",Number)],e.prototype,"gasPrice",void 0),o([g.jsonMember({name:"body_hash",serializer:S,deserializer:E}),a("design:type",Uint8Array)],e.prototype,"bodyHash",void 0),o([g.jsonArrayMember(w.ByteArray,{serializer:function(e){return e.map(function(e){return S(e)})},deserializer:function(e){return e.map(function(e){return E(e)})}}),a("design:type",Array)],e.prototype,"dependencies",void 0),o([g.jsonMember({name:"chain_name",constructor:String}),a("design:type",String)],e.prototype,"chainName",void 0),e=o([g.jsonObject,a("design:paramtypes",[d.PublicKey,Number,Number,Number,Uint8Array,Array,String])],e)}();r.DeployHeader=k;var B=function(){function e(e){this.hash=e}return e.prototype.toBytes=function(){return p.toBytesDeployHash(this.hash)},e}(),T=function(){function e(){}return o([g.jsonMember({constructor:String}),a("design:type",String)],e.prototype,"signer",void 0),o([g.jsonMember({constructor:String}),a("design:type",String)],e.prototype,"signature",void 0),e=o([g.jsonObject],e)}();r.Approval=T;var j=function(){function e(){}return e.prototype.getArgByName=function(e){return this.args.args.get(e)},e.prototype.setArg=function(e,t){this.args.args.set(e,t)},e}(),x=function(e){var t={args:e};return new g.TypedJSON(y.RuntimeArgs).parse(t)},P=function(e){var t=new g.TypedJSON(y.RuntimeArgs).toPlainJson(e);return Object.values(t)[0]},O=function(e){function t(t,r){var n=e.call(this)||this;return n.tag=0,n.moduleBytes=t,n.args=r,n}return i(t,e),t.prototype.toBytes=function(){return u.concat([Uint8Array.from([this.tag]),p.toBytesArrayU8(this.moduleBytes),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({name:"module_bytes",serializer:S,deserializer:E}),a("design:type",Uint8Array)],t.prototype,"moduleBytes",void 0),o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[Uint8Array,y.RuntimeArgs])],t)}(j);r.ModuleBytes=O;var R=function(e){function t(t,r,n){var i=e.call(this)||this;return i.tag=1,i.entryPoint=r,i.args=n,i.hash=t,i}return i(t,e),t.prototype.toBytes=function(){return u.concat([Uint8Array.from([this.tag]),p.toBytesBytesArray(this.hash),p.toBytesString(this.entryPoint),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({serializer:S,deserializer:E}),a("design:type",Uint8Array)],t.prototype,"hash",void 0),o([g.jsonMember({name:"entry_point",constructor:String}),a("design:type",String)],t.prototype,"entryPoint",void 0),o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[Uint8Array,String,y.RuntimeArgs])],t)}(j);r.StoredContractByHash=R;var I=function(e){function t(t,r,n){var i=e.call(this)||this;return i.tag=2,i.name=t,i.entryPoint=r,i.args=n,i}return i(t,e),t.prototype.toBytes=function(){return u.concat([Uint8Array.from([this.tag]),p.toBytesString(this.name),p.toBytesString(this.entryPoint),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({constructor:String}),a("design:type",String)],t.prototype,"name",void 0),o([g.jsonMember({name:"entry_point",constructor:String}),a("design:type",String)],t.prototype,"entryPoint",void 0),o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[String,String,y.RuntimeArgs])],t)}(j);r.StoredContractByName=I;var C=function(e){function t(t,r,n,i){var o=e.call(this)||this;return o.tag=4,o.name=t,o.version=r,o.entryPoint=n,o.args=i,o}return i(t,e),t.prototype.toBytes=function(){var e;return e=null===this.version?new c.Option(null,d.CLTypeHelper.u32()):new c.Option(new d.U32(this.version)),u.concat([Uint8Array.from([this.tag]),p.toBytesString(this.name),e.toBytes(),p.toBytesString(this.entryPoint),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({constructor:String}),a("design:type",String)],t.prototype,"name",void 0),o([g.jsonMember({constructor:Number,preserveNull:!0}),a("design:type",Object)],t.prototype,"version",void 0),o([g.jsonMember({name:"entry_point",constructor:String}),a("design:type",String)],t.prototype,"entryPoint",void 0),o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[String,Object,String,y.RuntimeArgs])],t)}(j);r.StoredVersionedContractByName=C;var N=function(e){function t(t,r,n,i){var o=e.call(this)||this;return o.tag=3,o.hash=t,o.version=r,o.entryPoint=n,o.args=i,o}return i(t,e),t.prototype.toBytes=function(){var e;return e=null===this.version?new c.Option(null,d.CLTypeHelper.u32()):new c.Option(new d.U32(this.version)),u.concat([Uint8Array.from([this.tag]),p.toBytesBytesArray(this.hash),e.toBytes(),p.toBytesString(this.entryPoint),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({serializer:S,deserializer:E}),a("design:type",Uint8Array)],t.prototype,"hash",void 0),o([g.jsonMember({constructor:Number,preserveNull:!0}),a("design:type",Object)],t.prototype,"version",void 0),o([g.jsonMember({name:"entry_point",constructor:String}),a("design:type",String)],t.prototype,"entryPoint",void 0),o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[Uint8Array,Object,String,y.RuntimeArgs])],t)}(j);r.StoredVersionedContractByHash=N;var U=function(e){function t(t){var r=e.call(this)||this;return r.tag=5,r.args=t,r}return i(t,e),t.prototype.toBytes=function(){return u.concat([Uint8Array.from([this.tag]),p.toBytesBytesArray(this.args.toBytes())])},o([g.jsonMember({deserializer:x,serializer:P}),a("design:type",y.RuntimeArgs)],t.prototype,"args",void 0),t=o([g.jsonObject,a("design:paramtypes",[y.RuntimeArgs])],t)}(j);r.Transfer=U;var D=function(){function e(){}var t;return t=e,e.prototype.toBytes=function(){if(this.isModuleBytes())return this.moduleBytes.toBytes();if(this.isStoredContractByHash())return this.storedContractByHash.toBytes();if(this.isStoredContractByName())return this.storedContractByName.toBytes();if(this.isStoredVersionContractByHash())return this.storedVersionedContractByHash.toBytes();if(this.isStoredVersionContractByName())return this.storedVersionedContractByName.toBytes();if(this.isTransfer())return this.transfer.toBytes();throw new Error("failed to serialize ExecutableDeployItemJsonWrapper")},e.prototype.getArgByName=function(e){if(this.isModuleBytes())return this.moduleBytes.getArgByName(e);if(this.isStoredContractByHash())return this.storedContractByHash.getArgByName(e);if(this.isStoredContractByName())return this.storedContractByName.getArgByName(e);if(this.isStoredVersionContractByHash())return this.storedVersionedContractByHash.getArgByName(e);if(this.isStoredVersionContractByName())return this.storedVersionedContractByName.getArgByName(e);if(this.isTransfer())return this.transfer.getArgByName(e);throw new Error("failed to serialize ExecutableDeployItemJsonWrapper")},e.prototype.setArg=function(e,t){if(this.isModuleBytes())return this.moduleBytes.setArg(e,t);if(this.isStoredContractByHash())return this.storedContractByHash.setArg(e,t);if(this.isStoredContractByName())return this.storedContractByName.setArg(e,t);if(this.isStoredVersionContractByHash())return this.storedVersionedContractByHash.setArg(e,t);if(this.isStoredVersionContractByName())return this.storedVersionedContractByName.setArg(e,t);if(this.isTransfer())return this.transfer.setArg(e,t);throw new Error("failed to serialize ExecutableDeployItemJsonWrapper")},e.fromExecutableDeployItemInternal=function(e){var r=new t;switch(e.tag){case 0:r.moduleBytes=e;break;case 1:r.storedContractByHash=e;break;case 2:r.storedContractByName=e;break;case 3:r.storedVersionedContractByHash=e;break;case 4:r.storedVersionedContractByName=e;break;case 5:r.transfer=e}return r},e.newModuleBytes=function(e,r){return t.fromExecutableDeployItemInternal(new O(e,r))},e.newStoredContractByHash=function(e,r,n){return t.fromExecutableDeployItemInternal(new R(e,r,n))},e.newStoredContractByName=function(e,r,n){return t.fromExecutableDeployItemInternal(new I(e,r,n))},e.newStoredVersionContractByHash=function(e,r,n,i){return t.fromExecutableDeployItemInternal(new N(e,r,n,i))},e.newStoredVersionContractByName=function(e,r,n,i){return t.fromExecutableDeployItemInternal(new C(e,r,n,i))},e.newTransfer=function(e,r,n,i){void 0===n&&(n=null);var o=y.RuntimeArgs.fromMap({});if(o.insert("amount",d.CLValue.u512(e)),n&&o.insert("source",d.CLValue.uref(n)),r instanceof b.URef)o.insert("target",d.CLValue.uref(r));else{if(!(r instanceof d.PublicKey))throw new Error("Please specify target");o.insert("target",d.CLValue.byteArray(r.toAccountHash()))}if(void 0===i)throw new Error("transfer-id missing in new transfer.");return o.insert("id",d.CLValue.option(d.CLTypedAndToBytesHelper.u64(i),d.CLTypeHelper.u64())),t.fromExecutableDeployItemInternal(new U(o))},e.newTransferWithOptionalTransferId=function(e,r,n,i){var o=y.RuntimeArgs.fromMap({});if(o.insert("amount",d.CLValue.u512(e)),n&&o.insert("source",d.CLValue.uref(n)),r instanceof b.URef)o.insert("target",d.CLValue.uref(r));else{if(!(r instanceof d.PublicKey))throw new Error("Please specify target");o.insert("target",d.CLValue.byteArray(r.toAccountHash()))}return null!=i?o.insert("id",d.CLValue.option(d.CLTypedAndToBytesHelper.u64(i),d.CLTypeHelper.u64())):o.insert("id",d.CLValue.option(null,d.CLTypeHelper.u64())),t.fromExecutableDeployItemInternal(new U(o))},e.newTransferToUniqAddress=function(e,t,r,n,i,o,a,s){void 0===o&&(o=1),void 0===a&&(a=18e5);var u=new b.DeployUtil.DeployParams(e,i,o,a),f=b.DeployUtil.standardPayment(n),c=b.DeployUtil.ExecutableDeployItem.newTransfer(r,t.publicKey,s,t.transferId);return b.DeployUtil.makeDeploy(u,c,f)},e.prototype.isModuleBytes=function(){return!!this.moduleBytes},e.prototype.asModuleBytes=function(){return this.moduleBytes},e.prototype.isStoredContractByHash=function(){return!!this.storedContractByHash},e.prototype.asStoredContractByHash=function(){return this.storedContractByHash},e.prototype.isStoredContractByName=function(){return!!this.storedContractByName},e.prototype.asStoredContractByName=function(){return this.storedContractByName},e.prototype.isStoredVersionContractByName=function(){return!!this.storedVersionedContractByName},e.prototype.asStoredVersionContractByName=function(){return this.storedVersionedContractByName},e.prototype.isStoredVersionContractByHash=function(){return!!this.storedVersionedContractByHash},e.prototype.asStoredVersionContractByHash=function(){return this.storedVersionedContractByHash},e.prototype.isTransfer=function(){return!!this.transfer},e.prototype.asTransfer=function(){return this.transfer},o([g.jsonMember({name:"ModuleBytes",constructor:O}),a("design:type",O)],e.prototype,"moduleBytes",void 0),o([g.jsonMember({name:"StoredContractByHash",constructor:R}),a("design:type",R)],e.prototype,"storedContractByHash",void 0),o([g.jsonMember({name:"StoredContractByName",constructor:I}),a("design:type",I)],e.prototype,"storedContractByName",void 0),o([g.jsonMember({name:"StoredVersionedContractByHash",constructor:N}),a("design:type",N)],e.prototype,"storedVersionedContractByHash",void 0),o([g.jsonMember({name:"StoredVersionedContractByName",constructor:C}),a("design:type",C)],e.prototype,"storedVersionedContractByName",void 0),o([g.jsonMember({name:"Transfer",constructor:U}),a("design:type",U)],e.prototype,"transfer",void 0),e=t=o([g.jsonObject],e)}();r.ExecutableDeployItem=D;var L=function(){function e(e,t,r,n,i){this.approvals=i,this.session=n,this.payment=r,this.header=t,this.hash=e}return e.prototype.isTransfer=function(){return this.session.isTransfer()},e.prototype.isStandardPayment=function(){var e;return!!this.payment.isModuleBytes()&&0===(null===(e=this.payment.asModuleBytes())||void 0===e?void 0:e.moduleBytes.length)},o([g.jsonMember({serializer:S,deserializer:E}),a("design:type",Uint8Array)],e.prototype,"hash",void 0),o([g.jsonMember({constructor:k}),a("design:type",k)],e.prototype,"header",void 0),o([g.jsonMember({constructor:D}),a("design:type",D)],e.prototype,"payment",void 0),o([g.jsonMember({constructor:D}),a("design:type",D)],e.prototype,"session",void 0),o([g.jsonArrayMember(T),a("design:type",Array)],e.prototype,"approvals",void 0),e=o([g.jsonObject,a("design:paramtypes",[Uint8Array,k,D,D,Array])],e)}();r.Deploy=L,r.serializeHeader=function(e){return e.toBytes()},r.serializeBody=function(e,t){return u.concat([e.toBytes(),t.toBytes()])},r.serializeApprovals=function(e){var r=p.toBytesU32(e.length),n=u.concat(e.map(function(e){return u.concat([Uint8Array.from(t.from(e.signer,"hex")),Uint8Array.from(t.from(e.signature,"hex"))])}));return u.concat([r,n])},function(e){e.WASM="WASM",e.Hash="Hash",e.Name="Name"}(r.ContractType||(r.ContractType={}));var K=function(){return function(e,t,r,n,i,o){void 0===r&&(r=1),void 0===n&&(n=18e5),void 0===i&&(i=[]),this.accountPublicKey=e,this.chainName=t,this.gasPrice=r,this.ttl=n,this.dependencies=i,this.timestamp=o,this.dependencies=i.filter(function(e){return i.filter(function(t){return h.encodeBase16(e)===h.encodeBase16(t)}).length<2}),o||(this.timestamp=Date.now())}}();function z(e,t,n){var i=r.serializeBody(n,t),o=f.default.blake2b(i,null,32),a=new k(e.accountPublicKey,e.timestamp,e.ttl,e.gasPrice,o,e.dependencies,e.chainName),s=r.serializeHeader(a),u=f.default.blake2b(s,null,32);return new L(u,a,n,t,[])}r.DeployParams=K,r.makeDeploy=z,r.signDeploy=function(e,t){var r=new T,n=t.sign(e.hash);switch(r.signer=t.accountHex(),t.signatureAlgorithm){case m.SignatureAlgorithm.Ed25519:r.signature=b.Keys.Ed25519.accountHex(n);break;case m.SignatureAlgorithm.Secp256K1:r.signature=b.Keys.Secp256K1.accountHex(n)}return e.approvals.push(r),e},r.setSignature=function(e,t,r){var n=new T;switch(n.signer=r.toAccountHex(),r.signatureAlgorithm()){case m.SignatureAlgorithm.Ed25519:n.signature=b.Keys.Ed25519.accountHex(t);break;case m.SignatureAlgorithm.Secp256K1:n.signature=b.Keys.Secp256K1.accountHex(t)}return e.approvals.push(n),e},r.standardPayment=function(e){var t=y.RuntimeArgs.fromMap({amount:d.CLValue.u512(e.toString())});return D.newModuleBytes(Uint8Array.from([]),t)},r.deployToJson=function(e){return{deploy:new g.TypedJSON(L).toPlainJson(e)}},r.deployFromJson=function(e){var t=new g.TypedJSON(L).parse(e.deploy);if(void 0!==t&&r.validateDeploy(t).ok)return t},r.addArgToDeploy=function(e,t,r){if(0!==e.approvals.length)throw Error("Can not add argument to already signed deploy.");var n=new b.DeployUtil.DeployParams(e.header.account,e.header.chainName,e.header.gasPrice,e.header.ttl,e.header.dependencies,e.header.timestamp),i=e.session;return i.setArg(t,r),z(n,i,e.payment)},r.deploySizeInBytes=function(e){var t=e.hash.length,n=r.serializeBody(e.payment,e.session).length;return t+r.serializeHeader(e.header).length+n+e.approvals.map(function(e){return(e.signature.length+e.signer.length)/2}).reduce(function(e,t){return e+t},0)},r.validateDeploy=function(e){var t=r.serializeBody(e.payment,e.session),n=f.default.blake2b(t,null,32);if(!q(e.header.bodyHash,n))return _.Err("Invalid deploy: bodyHash missmatch. Expected: "+n+", \n got: "+e.header.bodyHash+".");var i=r.serializeHeader(e.header),o=f.default.blake2b(i,null,32);return q(e.hash,o)?_.Ok(e):_.Err("Invalid deploy: hash missmatch. Expected: "+o+", \n got: "+e.hash+".")};var q=function(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})};r.deployToBytes=function(e){return u.concat([r.serializeHeader(e.header),e.hash,r.serializeBody(e.payment,e.session),r.serializeApprovals(e.approvals)])}}).call(this)}).call(this,e("buffer").Buffer)},{"./CLValue":182,"./Conversions":186,"./Keys":188,"./RuntimeArgs":189,"./byterepr":193,"./index":194,"./option":195,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,blakejs:43,buffer:266,"humanize-duration":96,"ts-results":136,"tweetnacl-ts":153,typedjson:166}],188:[function(e,t,r){(function(t){(function(){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&o(t,e,r);return a(t,e),t},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Secp256K1=r.Ed25519=r.AsymmetricKey=r.readBase64WithPEM=r.SignatureAlgorithm=void 0;var f,c=s(e("fs")),h=s(e("tweetnacl-ts")),l=e("tweetnacl-util"),d=e("../index"),p=e("../lib/index"),y=e("./Contracts"),b=u(e("eccrypto")),m=s(e("ethereum-cryptography/secp256k1")),v=u(e("key-encoder")),g=e("ethereum-cryptography/sha256"),w=new v.default("secp256k1");function _(e,r){var n=t.from([0]),i=t.concat([t.from(e),n]);return 0===r.length?t.from([]):y.byteHash(t.concat([i,t.from(r)]))}function M(e){var t=e.split(/\r?\n/).filter(function(e){return!e.startsWith("---")}).join("").trim();return l.decodeBase64(t)}!function(e){e.Ed25519="ed25519",e.Secp256K1="secp256k1"}(f=r.SignatureAlgorithm||(r.SignatureAlgorithm={})),r.readBase64WithPEM=M;var S=function(){function e(e,t,r){this.publicKey=p.PublicKey.from(e,r),this.privateKey=t,this.signatureAlgorithm=r}return e.prototype.accountHash=function(){return this.publicKey.toAccountHash()},e.prototype.accountHex=function(){return this.publicKey.toAccountHex()},e.prototype.toPem=function(e,t){return"-----BEGIN "+e+"-----\n"+t+"\n-----END "+e+"-----\n"},e}();r.AsymmetricKey=S;var E=function(e){function r(t){return e.call(this,t.publicKey,t.secretKey,f.Ed25519)||this}return i(r,e),r.new=function(){return new r(h.sign_keyPair())},r.accountHex=function(e){return"01"+d.encodeBase16(e)},r.parseKeyFiles=function(e,n){var i=r.parsePublicKeyFile(e),o=r.parsePrivateKeyFile(n);return new r({publicKey:i,secretKey:t.concat([o,i])})},r.accountHash=function(e){return _(f.Ed25519,e)},r.parseKeyPair=function(e,t){var n=r.parsePublicKey(e),i=r.parsePrivateKey(t),o=new Uint8Array(n.length+i.length);return o.set(i),o.set(n,i.length),new r({publicKey:n,secretKey:o})},r.parsePrivateKeyFile=function(e){return r.parsePrivateKey(r.readBase64File(e))},r.parsePublicKeyFile=function(e){return r.parsePublicKey(r.readBase64File(e))},r.parsePrivateKey=function(e){return r.parseKey(e,0,32)},r.parsePublicKey=function(e){return r.parseKey(e,32,64)},r.readBase64WithPEM=function(e){return M(e)},r.readBase64File=function(e){var t=c.readFileSync(e).toString();return r.readBase64WithPEM(t)},r.parseKey=function(e,r,n){var i=e.length,o=32===i?e:64===i?t.from(e).slice(r,n):i>32&&i<64?t.from(e).slice(i%32):null;if(null==o||32!==o.length)throw Error("Unexpected key length: "+i);return o},r.prototype.exportPrivateKeyInPem=function(){var e=t.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]),n=d.encodeBase64(t.concat([e,t.from(r.parsePrivateKey(this.privateKey))]));return this.toPem("PRIVATE KEY",n)},r.prototype.exportPublicKeyInPem=function(){var e=t.from([48,42,48,5,6,3,43,101,112,3,33,0]),r=d.encodeBase64(t.concat([e,t.from(this.publicKey.rawPublicKey)]));return this.toPem("PUBLIC KEY",r)},r.prototype.sign=function(e){return h.sign_detached(e,this.privateKey)},r.prototype.verify=function(e,t){return h.sign_detached_verify(t,e,this.publicKey.rawPublicKey)},r.privateToPublicKey=function(e){return 64===e.length?h.sign_keyPair_fromSecretKey(e).publicKey:h.sign_keyPair_fromSeed(e).publicKey},r.loadKeyPairFromPrivateFile=function(e){var t=r.parsePrivateKeyFile(e),n=r.privateToPublicKey(t);return r.parseKeyPair(n,t)},r}(S);r.Ed25519=E;var A=function(e){function r(t,r){return e.call(this,t,r,f.Secp256K1)||this}return i(r,e),r.new=function(){var e=b.default.generatePrivate();return new r(Uint8Array.from(b.default.getPublicCompressed(e)),e)},r.parseKeyFiles=function(e,t){var n=r.parsePublicKeyFile(e),i=r.parsePrivateKeyFile(t);return new r(n,i)},r.accountHash=function(e){return _(f.Secp256K1,e)},r.accountHex=function(e){return"02"+d.encodeBase16(e)},r.parseKeyPair=function(e,t,n){var i=r.parsePublicKey(e,n),o=r.parsePrivateKey(t,n);return new r(i,o)},r.parsePrivateKeyFile=function(e){return r.parsePrivateKey(r.readBase64File(e))},r.parsePublicKeyFile=function(e){return r.parsePublicKey(r.readBase64File(e))},r.parsePrivateKey=function(e,r){var n;return void 0===r&&(r="der"),n="der"===r?w.encodePrivate(t.from(e),"der","raw"):d.encodeBase16(e),t.from(n,"hex")},r.parsePublicKey=function(e,r){var n;return void 0===r&&(r="der"),n="der"===r?w.encodePublic(t.from(e),"der","raw"):d.encodeBase16(e),Uint8Array.from(t.from(n,"hex"))},r.readBase64WithPEM=function(e){return M(e)},r.readBase64File=function(e){var t=c.readFileSync(e).toString();return r.readBase64WithPEM(t)},r.prototype.exportPrivateKeyInPem=function(){return w.encodePrivate(d.encodeBase16(this.privateKey),"raw","pem")},r.prototype.exportPublicKeyInPem=function(){return w.encodePublic(d.encodeBase16(this.publicKey.rawPublicKey),"raw","pem")},r.prototype.sign=function(e){return m.ecdsaSign(g.sha256(t.from(e)),this.privateKey).signature},r.prototype.verify=function(e,r){return m.ecdsaVerify(e,g.sha256(t.from(r)),this.publicKey.rawPublicKey)},r.privateToPublicKey=function(e){return m.publicKeyCreate(e,!0)},r.loadKeyPairFromPrivateFile=function(e){var t=r.parsePrivateKeyFile(e),n=r.privateToPublicKey(t);return r.parseKeyPair(n,t,"raw")},r.deriveIndex=function(e,t){return e.deriveIndex(t)},r}(S);r.Secp256K1=A}).call(this)}).call(this,e("buffer").Buffer)},{"../index":181,"../lib/index":194,"./Contracts":185,buffer:266,eccrypto:55,"ethereum-cryptography/secp256k1":80,"ethereum-cryptography/sha256":75,fs:199,"key-encoder":100,"tweetnacl-ts":153,"tweetnacl-util":163}],189:[function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.RuntimeArgs=r.NamedArg=void 0;var o=e("./byterepr"),a=e("./CLValue"),s=e("@ethersproject/bytes"),u=e("typedjson"),f=function(){function e(e,t){this.name=e,this.value=t}return e.prototype.toBytes=function(){var e=o.toBytesString(this.name),t=this.value.toBytes();return s.concat([e,t])},e.fromBytes=function(t){var r=a.StringValue.fromBytes(t);if(r.hasError())return a.Result.Err(r.error);var n=a.CLValue.fromBytes(r.remainder());return n.hasError()?a.Result.Err(n.error):a.Result.Ok(new e(r.value().val,n.value()),n.remainder())},e}();r.NamedArg=f;var c=function(e){var t=new u.TypedJSON(a.CLValue);return new Map(Array.from(e,function(e){var r=e[0],n=e[1];return[r,t.parse(n)]}))},h=function(e){var t=new u.TypedJSON(a.CLValue);return Array.from(e,function(e){var r=e[0],n=e[1];return[r,t.toPlainJson(n)]})},l=function(){function e(e){this.args=e}var t;return t=e,e.fromMap=function(e){var r=new Map(Object.keys(e).map(function(t){return[t,e[t]]}));return new t(r)},e.fromNamedArgs=function(e){var r=e.reduce(function(e,t){return e[t.name]=t.value,e},{});return t.fromMap(r)},e.prototype.insert=function(e,t){this.args.set(e,t)},e.prototype.toBytes=function(){var e=Array.from(this.args.entries()).map(function(e){return new f(e[0],e[1])});return o.toBytesVecT(e)},e.fromBytes=function(e){var r=a.U32.fromBytes(e);if(r.hasError())return a.Result.Err(r.error);for(var n=r.value().val.toNumber(),i=r.remainder(),o=[],s=0;s0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.StoredValue=r.ContractMetadataJson=r.EraInfoJson=r.SeigniorageAllocation=r.DeployInfoJson=r.TransferJson=void 0;var o=e("typedjson"),a=e("./CLValue"),s=function(){function e(){}return n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"name",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"key",void 0),e=n([o.jsonObject],e)}(),u=function(){function e(){}return n([o.jsonMember({name:"account_hash",constructor:String}),i("design:type",String)],e.prototype,"accountHash",void 0),n([o.jsonMember({constructor:Number}),i("design:type",Number)],e.prototype,"weight",void 0),e=n([o.jsonObject],e)}(),f=function(){function e(){}return n([o.jsonMember({constructor:Number}),i("design:type",Number)],e.prototype,"deployment",void 0),n([o.jsonMember({name:"key_management",constructor:Number}),i("design:type",Number)],e.prototype,"keyManagement",void 0),e=n([o.jsonObject],e)}(),c=function(){function e(){}return e.prototype.accountHash=function(){return this._accountHash},n([o.jsonMember({name:"account_hash",constructor:String}),i("design:type",String)],e.prototype,"_accountHash",void 0),n([o.jsonArrayMember(s,{name:"named_keys"}),i("design:type",Array)],e.prototype,"namedKeys",void 0),n([o.jsonMember({name:"main_purse",constructor:String}),i("design:type",String)],e.prototype,"mainPurse",void 0),n([o.jsonArrayMember(u,{name:"associated_keys"}),i("design:type",Array)],e.prototype,"associatedKeys",void 0),n([o.jsonMember({name:"action_thresholds",constructor:f}),i("design:type",f)],e.prototype,"actionThresholds",void 0),e=n([o.jsonObject],e)}(),h=function(){function e(){}return n([o.jsonMember({name:"deploy_hash",constructor:String}),i("design:type",String)],e.prototype,"deployHash",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"from",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"source",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"target",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"amount",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"gas",void 0),n([o.jsonMember({constructor:String,preserveNull:!0}),i("design:type",Object)],e.prototype,"id",void 0),e=n([o.jsonObject],e)}();r.TransferJson=h;var l=function(){function e(){}return n([o.jsonMember({name:"deploy_hash",constructor:String}),i("design:type",String)],e.prototype,"deployHash",void 0),n([o.jsonArrayMember(String),i("design:type",Array)],e.prototype,"transfers",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"from",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"source",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"gas",void 0),e=n([o.jsonObject],e)}();r.DeployInfoJson=l;var d=function(){function e(){}return n([o.jsonMember({name:"validator_public_key",constructor:String}),i("design:type",String)],e.prototype,"validatorPublicKey",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"amount",void 0),e=n([o.jsonObject],e)}(),p=function(){function e(){}return n([o.jsonMember({name:"delegator_public_key",constructor:String}),i("design:type",String)],e.prototype,"delegatorPublicKey",void 0),n([o.jsonMember({name:"validator_public_key",constructor:String}),i("design:type",String)],e.prototype,"validatorPublicKey",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"amount",void 0),e=n([o.jsonObject],e)}(),y=function(){function e(){}return n([o.jsonMember({constructor:d}),i("design:type",d)],e.prototype,"Validator",void 0),n([o.jsonMember({constructor:p}),i("design:type",p)],e.prototype,"Delegator",void 0),e=n([o.jsonObject],e)}();r.SeigniorageAllocation=y;var b=function(){function e(){}return n([o.jsonArrayMember(y,{name:"seigniorage_allocations"}),i("design:type",Array)],e.prototype,"seigniorageAllocations",void 0),e=n([o.jsonObject],e)}();r.EraInfoJson=b;var m=function(){function e(){}return n([o.jsonMember({name:"contract_package_hash",constructor:String}),i("design:type",String)],e.prototype,"contractPackageHash",void 0),n([o.jsonMember({name:"contract_wasm_hash",constructor:String}),i("design:type",String)],e.prototype,"contractWasmHash",void 0),n([o.jsonMember({name:"protocol_version",constructor:String}),i("design:type",String)],e.prototype,"protocolVersion",void 0),e=n([o.jsonObject],e)}();r.ContractMetadataJson=m;var v=function(){function e(){}return n([o.jsonMember({constructor:a.CLValue}),i("design:type",a.CLValue)],e.prototype,"CLValue",void 0),n([o.jsonMember({constructor:c}),i("design:type",c)],e.prototype,"Account",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"ContractWASM",void 0),n([o.jsonMember({constructor:m}),i("design:type",m)],e.prototype,"Contract",void 0),n([o.jsonMember({constructor:String}),i("design:type",String)],e.prototype,"ContractPackage",void 0),n([o.jsonMember({constructor:h}),i("design:type",h)],e.prototype,"Transfer",void 0),n([o.jsonMember({constructor:l}),i("design:type",l)],e.prototype,"DeployInfo",void 0),n([o.jsonMember({constructor:b}),i("design:type",b)],e.prototype,"EraInfo",void 0),e=n([o.jsonObject],e)}();r.StoredValue=v},{"./CLValue":182,typedjson:166}],193:[function(e,t,r){(function(t){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.toBytesStringList=r.toBytesVecT=r.toBytesBytesArray=r.toBytesArrayU8=r.toBytesString=r.toBytesU512=r.toBytesDeployHash=r.toBytesU256=r.toBytesU128=r.toBytesI64=r.toBytesU64=r.toBytesU32=r.toBytesI32=r.toBytesU8=r.toBytesNumber=void 0;var n=e("@ethersproject/bignumber"),i=e("@ethersproject/constants"),o=e("@ethersproject/bytes"),a=e("./CLValue");function s(e){return r.toBytesNumber(32,!1,e)}function u(e){return e}function f(e){var t=e.map(function(e){return e.toBytes()});return t.splice(0,0,s(e.length)),o.concat(t)}r.toBytesNumber=function(e,t,r){var a=n.BigNumber.from(r),s=i.MaxUint256.mask(e);if(t){var u=s.mask(e-1);if(a.gt(u)||a.lt(u.add(i.One).mul(i.NegativeOne)))throw new Error("value out-of-bounds, value: "+r)}else if(a.lt(i.Zero)||a.gt(s.mask(e)))throw new Error("value out-of-bounds, value: "+r);a=a.toTwos(e).mask(e);var f=o.arrayify(a);if(a.gte(0)){if(e>64)return o.concat([f,Uint8Array.from([f.length])]).reverse();var c=e/8;return o.concat([f.reverse(),new Uint8Array(c-f.length)])}return f.reverse()},r.toBytesU8=function(e){return r.toBytesNumber(8,!1,e)},r.toBytesI32=function(e){return r.toBytesNumber(32,!0,e)},r.toBytesU32=s,r.toBytesU64=function(e){return r.toBytesNumber(64,!1,e)},r.toBytesI64=function(e){return r.toBytesNumber(64,!0,e)},r.toBytesU128=function(e){return r.toBytesNumber(128,!1,e)},r.toBytesU256=function(e){return r.toBytesNumber(256,!1,e)},r.toBytesDeployHash=function(e){return u(e)},r.toBytesU512=function(e){return r.toBytesNumber(512,!1,e)},r.toBytesString=function(e){var r=Uint8Array.from(t.from(e));return o.concat([s(r.byteLength),r])},r.toBytesArrayU8=function(e){return o.concat([s(e.length),e])},r.toBytesBytesArray=u,r.toBytesVecT=f,r.toBytesStringList=function(e){return f(e.map(function(e){return a.CLValue.string(e)}))}}).call(this)}).call(this,e("buffer").Buffer)},{"./CLValue":182,"@ethersproject/bignumber":4,"@ethersproject/bytes":6,"@ethersproject/constants":10,buffer:266}],194:[function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.Signer=r.DeployUtil=r.Serialization=r.Keys=r.Contracts=void 0;var s=o(e("./Contracts"));r.Contracts=s;var u=o(e("./DeployUtil"));r.DeployUtil=u;var f=o(e("./Keys"));r.Keys=f;var c=o(e("./Serialization"));r.Serialization=c;var h=o(e("./Signer"));r.Signer=h,a(e("./CLValue"),r),a(e("./RuntimeArgs"),r),a(e("./CasperClient"),r),a(e("./option"),r)},{"./CLValue":182,"./CasperClient":183,"./Contracts":185,"./DeployUtil":187,"./Keys":188,"./RuntimeArgs":189,"./Serialization":190,"./Signer":191,"./option":195}],195:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0}),r.Option=void 0;var o=e("./CLValue"),a=e("@ethersproject/bytes"),s=function(e){function t(t,r){var n=e.call(this)||this;if(n.t=t,null===t){if(!r)throw new Error("You had to assign innerType for None");n.innerType=r}else n.innerType=t.clType();return n}return i(t,e),t.prototype.isNone=function(){return null===this.t},t.prototype.isSome=function(){return null!==this.t},t.prototype.getSome=function(){if(!this.isSome())throw new Error("Value is None");return o.CLValue.fromT(this.t)},t.prototype.toBytes=function(){return null===this.t?Uint8Array.from([0]):a.concat([Uint8Array.from([1]),this.t.toBytes()])},t.prototype.clType=function(){return o.CLTypeHelper.option(this.innerType)},t.fromBytes=function(e,r){var n=o.U8.fromBytes(r);if(n.hasError())return o.Result.Err(n.error);var i=n.value().val.toNumber();if(0===i)return o.Result.Ok(new t(null,e.innerType),n.remainder());if(1===i){var a=o.fromBytesByCLType(e.innerType,n.remainder());return a.hasError()?o.Result.Err(a.error):o.Result.Ok(new t(a.value(),e.innerType),a.remainder())}return o.Result.Err(o.FromBytesError.FormattingError)},t}(o.CLTypedAndToBytes);r.Option=s},{"./CLValue":182,"@ethersproject/bytes":6}],196:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1048576)throw Error("Deploy can not be send, because it's too large: "+t+" bytes. Max size is 1 megabyte.");return[4,this.client.request({method:"account_put_deploy",params:s.deployToJson(e)})];case 1:return[2,r.sent()]}})})},e}();r.CasperServiceByJsonRPC=h},{"..":181,"../lib/DeployUtil":187,"../lib/StoredValue":192,"@ethersproject/bignumber":4,"@open-rpc/client-js":18,typedjson:166}],198:[function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),i(e("./CasperServiceByJsonRPC"),r),i(e("./BalanceServiceByJsonRPC"),r)},{"./BalanceServiceByJsonRPC":196,"./CasperServiceByJsonRPC":197}],199:[function(e,t,r){},{}],200:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{"./asn1/api":201,"./asn1/base":203,"./asn1/constants":207,"./asn1/decoders":209,"./asn1/encoders":212,"bn.js":214,dup:26}],201:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{"./decoders":209,"./encoders":212,dup:27,inherits:335}],202:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{"../base/reporter":205,dup:28,inherits:335,"safer-buffer":365}],203:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{"./buffer":202,"./node":204,"./reporter":205,dup:29}],204:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{"../base/buffer":202,"../base/reporter":205,dup:30,"minimalistic-assert":339}],205:[function(e,t,r){arguments[4][31][0].apply(r,arguments)},{dup:31,inherits:335}],206:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],207:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{"./der":206,dup:33}],208:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{"../base/buffer":202,"../base/node":204,"../constants/der":206,"bn.js":214,dup:34,inherits:335}],209:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./der":208,"./pem":210,dup:35}],210:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./der":208,dup:36,inherits:335,"safer-buffer":365}],211:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{"../base/node":204,"../constants/der":206,dup:37,inherits:335,"safer-buffer":365}],212:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{"./der":211,"./pem":213,dup:38}],213:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{"./der":211,dup:39,inherits:335}],214:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{buffer:222,dup:45}],215:[function(e,t,r){(function(r){(function(){"use strict";var n=e("object-assign");function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;f--)if(c[f]!==h[f])return!1;for(f=c.length-1;f>=0;f--)if(s=c[f],!g(e[s],t[s],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function M(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!e&&i&&!r;if((!e&&a.isError(i)&&o&&_(i,r)||s)&&m(i,r,"Got unwanted exception"+n),e&&i&&r&&!_(i,r)||!e&&i)throw i}l.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=y(b((t=this).actual),128)+" "+t.operator+" "+y(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},a.inherits(l.AssertionError,Error),l.fail=m,l.ok=v,l.equal=function(e,t,r){e!=t&&m(e,t,r,"==",l.equal)},l.notEqual=function(e,t,r){e==t&&m(e,t,r,"!=",l.notEqual)},l.deepEqual=function(e,t,r){g(e,t,!1)||m(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){g(e,t,!0)||m(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){g(e,t,!1)&&m(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){g(t,r,!0)&&m(t,r,n,"notDeepStrictEqual",e)},l.strictEqual=function(e,t,r){e!==t&&m(e,t,r,"===",l.strictEqual)},l.notStrictEqual=function(e,t,r){e===t&&m(e,t,r,"!==",l.notStrictEqual)},l.throws=function(e,t,r){M(!0,e,t,r)},l.doesNotThrow=function(e,t,r){M(!1,e,t,r)},l.ifError=function(e){if(e)throw e},l.strict=n(function e(t,r){t||m(t,!0,r,"==",e)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":341,"util/":218}],216:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],217:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],218:[function(e,t,r){(function(t,n){(function(){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),c(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function f(e,t){return e}function c(e,t,n){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=c(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),M(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(S(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(M(t))return h(t)}var f,w="",E=!1,A=["{","}"];(d(t)&&(E=!0,A=["[","]"]),S(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),M(t)&&(w=" "+h(t)),0!==a.length||E&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=E?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,w,A)):A[0]+w+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),B(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=y(r)?c(e,u.value,null):c(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function y(e){return null===e}function b(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===E(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===E(e)}function M(e){return w(e)&&("[object Error]"===E(e)||e instanceof Error)}function S(e){return"function"==typeof e}function E(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=y,r.isNullOrUndefined=function(e){return null==e},r.isNumber=b,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=M,r.isFunction=S,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),k[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":217,_process:353,inherits:216}],219:[function(e,t,r){"use strict";r.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=f(e),a=n[0],s=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),c=0,h=s>0?a-4:a;for(r=0;r>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],220:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function s(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+e)}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function f(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?f-49+10:f>=17?f-17+10:f,n(f>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(e){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?l[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=d[e],c=p[e];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modrn(c).toString(e);r=(h=h.idivn(c)).isZero()?y+r:l[f-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function y(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,h=67108863&u,l=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=l;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[f]=0|h,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,y=d>>>13,b=0|a[2],m=8191&b,v=b>>>13,g=0|a[3],w=8191&g,_=g>>>13,M=0|a[4],S=8191&M,E=M>>>13,A=0|a[5],k=8191&A,B=A>>>13,T=0|a[6],j=8191&T,x=T>>>13,P=0|a[7],O=8191&P,R=P>>>13,I=0|a[8],C=8191&I,N=I>>>13,U=0|a[9],D=8191&U,L=U>>>13,K=0|s[0],z=8191&K,q=K>>>13,H=0|s[1],F=8191&H,V=H>>>13,W=0|s[2],J=8191&W,Z=W>>>13,G=0|s[3],X=8191&G,Y=G>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],he=8191&ce,le=ce>>>13,de=0|s[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(f+(n=Math.imul(h,z))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,z)|0))<<13)|0;f=((o=Math.imul(l,q))+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,q))+Math.imul(y,z)|0,o=Math.imul(y,q);var me=(f+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,F)|0))<<13)|0;f=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,z),i=(i=Math.imul(m,q))+Math.imul(v,z)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(y,F)|0,o=o+Math.imul(y,V)|0;var ve=(f+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;f=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,q))+Math.imul(_,z)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Z)|0;var ge=(f+(n=n+Math.imul(h,X)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,X)|0))<<13)|0;f=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(S,z),i=(i=Math.imul(S,q))+Math.imul(E,z)|0,o=Math.imul(E,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,Y)|0;var we=(f+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;f=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(k,z),i=(i=Math.imul(k,q))+Math.imul(B,z)|0,o=Math.imul(B,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(E,F)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;f=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,q))+Math.imul(x,z)|0,o=Math.imul(x,q),n=n+Math.imul(k,F)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,V)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Me=(f+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;f=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,q))+Math.imul(R,z)|0,o=Math.imul(R,q),n=n+Math.imul(j,F)|0,i=(i=i+Math.imul(j,V)|0)+Math.imul(x,F)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,Y)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0;var Se=(f+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(l,ue)|0))<<13)|0;f=((o=o+Math.imul(l,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,q))+Math.imul(N,z)|0,o=Math.imul(N,q),n=n+Math.imul(O,F)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(j,J)|0,i=(i=i+Math.imul(j,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,fe)|0;var Ee=(f+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;f=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(D,z),i=(i=Math.imul(D,q))+Math.imul(L,z)|0,o=Math.imul(L,q),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(N,F)|0,o=o+Math.imul(N,V)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(j,X)|0,i=(i=i+Math.imul(j,Y)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,le)|0;var Ae=(f+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(l,pe)|0))<<13)|0;f=((o=o+Math.imul(l,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,V))+Math.imul(L,F)|0,o=Math.imul(L,V),n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,Z)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,Y)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(j,Q)|0,i=(i=i+Math.imul(j,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var ke=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,Z))+Math.imul(L,J)|0,o=Math.imul(L,Z),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(j,re)|0,i=(i=i+Math.imul(j,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,fe)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Be=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,Y))+Math.imul(L,X)|0,o=Math.imul(L,Y),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(j,oe)|0,i=(i=i+Math.imul(j,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(B,ue)|0,o=o+Math.imul(B,fe)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(E,he)|0,o=o+Math.imul(E,le)|0;var Te=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,ee))+Math.imul(L,Q)|0,o=Math.imul(L,ee),n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(j,ue)|0,i=(i=i+Math.imul(j,fe)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,fe)|0,n=n+Math.imul(k,he)|0,i=(i=i+Math.imul(k,le)|0)+Math.imul(B,he)|0,o=o+Math.imul(B,le)|0;var je=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(E,pe)|0))<<13)|0;f=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(j,he)|0,i=(i=i+Math.imul(j,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(B,pe)|0))<<13)|0;f=((o=o+Math.imul(B,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(O,he)|0,i=(i=i+Math.imul(O,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Pe=(f+(n=n+Math.imul(j,pe)|0)|0)+((8191&(i=(i=i+Math.imul(j,ye)|0)+Math.imul(x,pe)|0))<<13)|0;f=((o=o+Math.imul(x,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,ue),i=(i=Math.imul(D,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(C,he)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,le)|0;var Oe=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(L,he)|0,o=Math.imul(L,le);var Re=(f+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,ye)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ie=(f+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,ye))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ye))+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,u[0]=be,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Me,u[7]=Se,u[8]=Ee,u[9]=Ae,u[10]=ke,u[11]=Be,u[12]=Te,u[13]=je,u[14]=xe,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ie,0!==f&&(u[19]=f,r.length++),r};function m(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function v(e,t,r){return m(e,t,r)}function g(e,t){this.x=e,this.y=t}Math.imul||(b=y),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):r<63?y(this,e,t):r<1024?m(this,e,t):v(this,e,t)},g.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},g.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var h=0|this.words[f];this.words[f]=c<<26-o|h>>>o,c=h&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new k(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function _(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){_.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){_.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){_.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){_.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function B(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}_.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},_.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},_.prototype.split=function(e,t){e.iushrn(this.n,0,t)},_.prototype.imulK=function(e){return e.imul(this.k)},i(M,_),M.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},M.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new M;else if("p224"===e)t=new S;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new A}return w[e]=t,t},k.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},k.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(c(e,e.umod(this.m)._forceRed(this)),e)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},k.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var h=this.pow(c,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var y=d,b=0;0!==y.cmp(s);b++)y=y.redSqr();n(b=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var h=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new B(e)},i(B,k),B.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},B.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},B.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},B.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},B.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:222}],221:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{crypto:222,dup:46}],222:[function(e,t,r){arguments[4][199][0].apply(r,arguments)},{dup:199}],223:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e){n.isBuffer(e)||(e=n.from(e));for(var t=e.length/4|0,r=new Array(t),i=0;i>>24]^c[p>>>16&255]^h[y>>>8&255]^l[255&b]^t[m++],a=f[p>>>24]^c[y>>>16&255]^h[b>>>8&255]^l[255&d]^t[m++],s=f[y>>>24]^c[b>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=f[b>>>24]^c[d>>>16&255]^h[p>>>8&255]^l[255&y]^t[m++],d=o,p=a,y=s,b=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[y>>>8&255]<<8|n[255&b])^t[m++],a=(n[p>>>24]<<24|n[y>>>16&255]<<16|n[b>>>8&255]<<8|n[255&d])^t[m++],s=(n[y>>>24]<<24|n[b>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[b>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&y])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,r[a]=f,n[f]=a;var c=e[a],h=e[c],l=e[h],d=257*e[f]^16843008*f;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*c^16843008*a,o[0][f]=d<<24|d>>>8,o[1][f]=d<<16|d>>>16,o[2][f]=d<<8|d>>>24,o[3][f]=d,0===a?a=s=1:(a=c^e[e[e[l^c]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function f(e){this._key=i(e),this._reset()}f.blockSize=16,f.keySize=32,f.prototype.blockSize=f.blockSize,f.prototype.keySize=f.keySize,f.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var f=[],c=0;c>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=f},f.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},f.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},f.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},f.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=f},{"safe-buffer":364}],224:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),f=e("./incr32");function c(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var c=this._cipher.encryptBlock(u);this._ghash=new s(c),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,c=i.alloc(8);c.writeUIntBE(u,0,8),n.update(c),e._finID=n.state;var h=i.from(e._finID);return f(h),h}(this,r,c),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(c,o),c.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=f(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":223,"./authCipher":224,"./modes":236,"./streamCipher":239,"cipher-base":267,evp_bytestokey:304,inherits:335,"safe-buffer":364}],227:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),f=e("evp_bytestokey");function c(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(c,s),c.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new c(s.module,t,r)}c.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":364}],229:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],230:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":265}],231:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":265,"safe-buffer":364}],232:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function a(e,t){var i=function(e){var t=o(e);return{blinder:t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),a=t.modulus.byteLength(),s=new n(e).mul(i.blinder).umod(t.modulus),u=s.toRed(n.mont(t.prime1)),f=s.toRed(n.mont(t.prime2)),c=t.coefficient,h=t.prime1,l=t.prime2,d=u.redPow(t.exponent1).fromRed(),p=f.redPow(t.exponent2).fromRed(),y=d.isub(p).imul(c).umod(h).imul(l);return p.iadd(y).imul(i.unblinder).umod(t.modulus).toArrayLike(r,"be",a)}a.getr=o,t.exports=a}).call(this)}).call(this,e("buffer").Buffer)},{"bn.js":220,buffer:266,randombytes:361}],244:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":245}],245:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],246:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],247:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("readable-stream"),a=e("inherits"),s=e("./sign"),u=e("./verify"),f=e("./algorithms.json");function c(e){o.Writable.call(this);var t=f[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=i(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){o.Writable.call(this);var t=f[e];if(!t)throw new Error("Unknown message digest");this._hash=i(t.hash),this._tag=t.id,this._signType=t.sign}function l(e){return new c(e)}function d(e){return new h(e)}Object.keys(f).forEach(function(e){f[e].id=n.from(f[e].id,"hex"),f[e.toLowerCase()]=f[e]}),a(c,o.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=n.from(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=s(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},a(h,o.Writable),h.prototype._write=function(e,t,r){this._hash.update(e),r()},h.prototype.update=function(e,t){return"string"==typeof e&&(e=n.from(e,t)),this._hash.update(e),this},h.prototype.verify=function(e,t,r){"string"==typeof t&&(t=n.from(t,r)),this.end();var i=this._hash.digest();return u(t,i,e,this._signType,this._tag)},t.exports={Sign:l,Verify:d,createSign:l,createVerify:d}},{"./algorithms.json":245,"./sign":248,"./verify":249,"create-hash":270,inherits:335,"readable-stream":264,"safe-buffer":364}],248:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("create-hmac"),o=e("browserify-rsa"),a=e("elliptic").ec,s=e("bn.js"),u=e("parse-asn1"),f=e("./curves.json");function c(e,t,r,o){if((e=n.from(e.toArray())).length0&&r.ishrn(n),r}function l(e,t,r){var o,a;do{for(o=n.alloc(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,r,f,c){var h=a(r);if("ec"===h.type){if("ecdsa"!==f&&"ecdsa/rsa"!==f)throw new Error("wrong public key type");return function(e,t,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var i=new o(n),a=r.data.subjectPrivateKey.data;return i.verify(t,e,a)}(e,t,h)}if("dsa"===h.type){if("dsa"!==f)throw new Error("wrong public key type");return function(e,t,r){var n=r.data.p,o=r.data.q,s=r.data.g,f=r.data.pub_key,c=a.signature.decode(e,"der"),h=c.s,l=c.r;u(h,o),u(l,o);var d=i.mont(n),p=h.invm(o);return 0===s.toRed(d).redPow(new i(t).mul(p).mod(o)).fromRed().mul(f.toRed(d).redPow(l.mul(p).mod(o)).fromRed()).mod(n).mod(o).cmp(l)}(e,t,h)}if("rsa"!==f&&"ecdsa/rsa"!==f)throw new Error("wrong public key type");t=n.concat([c,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2i)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return f(e)}return s(e,t,r)}function s(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),n=o(r),i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(L(e,ArrayBuffer)||e&&L(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function l(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||L(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(e).length;default:if(i)return n?-1:N(e).length;t=(""+t).toLowerCase(),i=!0}}function d(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function p(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),K(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function M(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+h<=r)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return M(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},a.prototype.compare=function(e,t,r,n,i){if(L(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),u=Math.min(o,s),f=this.slice(n,i),c=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return m(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return g(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function A(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function P(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(e,t,r,i,o){return t=+t,r>>>=0,o||P(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function R(e,t,r,i,o){return t=+t,r>>>=0,o||P(e,0,r,8),n.write(e,t,r,i,52,8),r+8}a.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return O(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return O(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function L(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":219,buffer:266,ieee754:334}],267:[function(e,t,r){arguments[4][50][0].apply(r,arguments)},{dup:50,inherits:335,"safe-buffer":364,stream:374,string_decoder:389}],268:[function(e,t,r){(function(r){(function(){var n=e("elliptic"),i=e("bn.js");t.exports=function(e){return new a(e)};var o={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function a(e){this.curveType=o[e],this.curveType||(this.curveType={name:e}),this.curve=new n.ec(this.curveType.name),this.keys=void 0}function s(e,t,n){Array.isArray(e)||(e=e.toArray());var i=new r(e);if(n&&i.length0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=o.r28shl(r,s),i=o.r28shl(i,s),o.pc2(r,i,e.keys,a)}},u.prototype._update=function(e,t,r,n){var i=this._desState,a=o.readUInt32BE(e,t),s=o.readUInt32BE(e,t+4);o.ip(a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,a,s,i.tmp,0):this._decrypt(i,a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],o.writeUInt32BE(r,a,n),o.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,a=l}o.rip(s,a,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var a=r,s=t,u=e.keys.length-2;u>=0;u-=2){var f=e.keys[u],c=e.keys[u+1];o.expand(a,e.tmp,0),f^=e.tmp[0],c^=e.tmp[1];var h=o.substitute(f,c),l=a;a=(s^o.permute(h))>>>0,s=l}o.rip(a,s,n,i)}},{"./cipher":277,"./utils":280,inherits:335,"minimalistic-assert":339}],279:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("./cipher"),a=e("./des");function s(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[a.create({type:"encrypt",key:r}),a.create({type:"decrypt",key:i}),a.create({type:"encrypt",key:o})]:[a.create({type:"decrypt",key:o}),a.create({type:"encrypt",key:i}),a.create({type:"decrypt",key:r})]}function u(e){o.call(this,e);var t=new s(this.type,this.options.key);this._edeState=t}i(u,o),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=a.prototype._pad,u.prototype._unpad=a.prototype._unpad},{"./cipher":277,"./des":278,inherits:335,"minimalistic-assert":339}],280:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(f))for(;r.mod(c).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(b(p=r.shrn(1))&&b(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":285,"miller-rabin":337,randombytes:361}],284:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],285:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{buffer:222,dup:45}],286:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"../package.json":302,"./elliptic/curve":289,"./elliptic/curves":292,"./elliptic/ec":293,"./elliptic/eddsa":296,"./elliptic/utils":300,brorand:221,dup:56}],287:[function(e,t,r){arguments[4][57][0].apply(r,arguments)},{"../utils":300,"bn.js":301,dup:57}],288:[function(e,t,r){arguments[4][58][0].apply(r,arguments)},{"../utils":300,"./base":287,"bn.js":301,dup:58,inherits:335}],289:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{"./base":287,"./edwards":288,"./mont":290,"./short":291,dup:59}],290:[function(e,t,r){arguments[4][60][0].apply(r,arguments)},{"../utils":300,"./base":287,"bn.js":301,dup:60,inherits:335}],291:[function(e,t,r){arguments[4][61][0].apply(r,arguments)},{"../utils":300,"./base":287,"bn.js":301,dup:61,inherits:335}],292:[function(e,t,r){arguments[4][62][0].apply(r,arguments)},{"./curve":289,"./precomputed/secp256k1":299,"./utils":300,dup:62,"hash.js":321}],293:[function(e,t,r){arguments[4][63][0].apply(r,arguments)},{"../curves":292,"../utils":300,"./key":294,"./signature":295,"bn.js":301,brorand:221,dup:63,"hmac-drbg":333}],294:[function(e,t,r){arguments[4][64][0].apply(r,arguments)},{"../utils":300,"bn.js":301,dup:64}],295:[function(e,t,r){arguments[4][65][0].apply(r,arguments)},{"../utils":300,"bn.js":301,dup:65}],296:[function(e,t,r){arguments[4][66][0].apply(r,arguments)},{"../curves":292,"../utils":300,"./key":297,"./signature":298,dup:66,"hash.js":321}],297:[function(e,t,r){arguments[4][67][0].apply(r,arguments)},{"../utils":300,dup:67}],298:[function(e,t,r){arguments[4][68][0].apply(r,arguments)},{"../utils":300,"bn.js":301,dup:68}],299:[function(e,t,r){arguments[4][69][0].apply(r,arguments)},{dup:69}],300:[function(e,t,r){arguments[4][70][0].apply(r,arguments)},{"bn.js":301,dup:70,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],301:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{buffer:222,dup:45}],302:[function(e,t,r){t.exports={_from:"elliptic@^6.5.3",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/browserify/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.5.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.5.3",saveSpec:null,fetchSpec:"^6.5.3"},_requiredBy:["/browserify/browserify-sign","/browserify/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_shasum:"da37cebd31e79a1367e941b592ed1fbebd58abbb",_spec:"elliptic@^6.5.3",_where:"/usr/local/lib/node_modules/browserify/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],303:[function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}b(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&b(e,"error",t,r)}(e,i,{once:!0})})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var u=10;function f(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,r,n){var i,o,a,s;if(f(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=c(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var f=u.length,c=y(u,f);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},s.prototype.listenerCount=p,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],304:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),f=n.alloc(0);a>0||o>0;){var c=new i;c.update(f),c.update(e),t&&c.update(t),f=c.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,f.length),f.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,f.length-h);f.copy(u,d,h,h+p),o-=p}}return f.fill(0),{key:s,iv:u}}},{"md5.js":336,"safe-buffer":364}],305:[function(e,t,r){arguments[4][82][0].apply(r,arguments)},{dup:82,inherits:335,"readable-stream":320,"safe-buffer":364}],306:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106}],307:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{"./_stream_readable":309,"./_stream_writable":311,_process:353,dup:107,inherits:335}],308:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{"./_stream_transform":310,dup:108,inherits:335}],309:[function(e,t,r){arguments[4][109][0].apply(r,arguments)},{"../errors":306,"./_stream_duplex":307,"./internal/streams/async_iterator":312,"./internal/streams/buffer_list":313,"./internal/streams/destroy":314,"./internal/streams/from":316,"./internal/streams/state":318,"./internal/streams/stream":319,_process:353,buffer:266,dup:109,events:303,inherits:335,"string_decoder/":389,util:222}],310:[function(e,t,r){arguments[4][110][0].apply(r,arguments)},{"../errors":306,"./_stream_duplex":307,dup:110,inherits:335}],311:[function(e,t,r){arguments[4][111][0].apply(r,arguments)},{"../errors":306,"./_stream_duplex":307,"./internal/streams/destroy":314,"./internal/streams/state":318,"./internal/streams/stream":319,_process:353,buffer:266,dup:111,inherits:335,"util-deprecate":390}],312:[function(e,t,r){arguments[4][112][0].apply(r,arguments)},{"./end-of-stream":315,_process:353,dup:112}],313:[function(e,t,r){arguments[4][113][0].apply(r,arguments)},{buffer:266,dup:113,util:222}],314:[function(e,t,r){arguments[4][114][0].apply(r,arguments)},{_process:353,dup:114}],315:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{"../../../errors":306,dup:115}],316:[function(e,t,r){arguments[4][116][0].apply(r,arguments)},{dup:116}],317:[function(e,t,r){arguments[4][117][0].apply(r,arguments)},{"../../../errors":306,"./end-of-stream":315,dup:117}],318:[function(e,t,r){arguments[4][118][0].apply(r,arguments)},{"../../../errors":306,dup:118}],319:[function(e,t,r){arguments[4][119][0].apply(r,arguments)},{dup:119,events:303}],320:[function(e,t,r){arguments[4][120][0].apply(r,arguments)},{"./lib/_stream_duplex.js":307,"./lib/_stream_passthrough.js":308,"./lib/_stream_readable.js":309,"./lib/_stream_transform.js":310,"./lib/_stream_writable.js":311,"./lib/internal/streams/end-of-stream.js":315,"./lib/internal/streams/pipeline.js":317,dup:120}],321:[function(e,t,r){arguments[4][83][0].apply(r,arguments)},{"./hash/common":322,"./hash/hmac":323,"./hash/ripemd":324,"./hash/sha":325,"./hash/utils":332,dup:83}],322:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{"./utils":332,dup:84,"minimalistic-assert":339}],323:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{"./utils":332,dup:85,"minimalistic-assert":339}],324:[function(e,t,r){arguments[4][86][0].apply(r,arguments)},{"./common":322,"./utils":332,dup:86}],325:[function(e,t,r){arguments[4][87][0].apply(r,arguments)},{"./sha/1":326,"./sha/224":327,"./sha/256":328,"./sha/384":329,"./sha/512":330,dup:87}],326:[function(e,t,r){arguments[4][88][0].apply(r,arguments)},{"../common":322,"../utils":332,"./common":331,dup:88}],327:[function(e,t,r){arguments[4][89][0].apply(r,arguments)},{"../utils":332,"./256":328,dup:89}],328:[function(e,t,r){arguments[4][90][0].apply(r,arguments)},{"../common":322,"../utils":332,"./common":331,dup:90,"minimalistic-assert":339}],329:[function(e,t,r){arguments[4][91][0].apply(r,arguments)},{"../utils":332,"./512":330,dup:91}],330:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{"../common":322,"../utils":332,dup:92,"minimalistic-assert":339}],331:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{"../utils":332,dup:93}],332:[function(e,t,r){arguments[4][94][0].apply(r,arguments)},{dup:94,inherits:335,"minimalistic-assert":339}],333:[function(e,t,r){arguments[4][95][0].apply(r,arguments)},{dup:95,"hash.js":321,"minimalistic-assert":339,"minimalistic-crypto-utils":340}],334:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=l,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+e[t+h],h+=l,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,f-=8);e[r+d-p]|=128*y}},{}],335:[function(e,t,r){arguments[4][97][0].apply(r,arguments)},{dup:97}],336:[function(e,t,r){arguments[4][102][0].apply(r,arguments)},{dup:102,"hash-base":305,inherits:335,"safe-buffer":364}],337:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var f=e.shrn(u),c=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(f);if(0!==l.cmp(a)&&0!==l.cmp(c)){for(var d=1;d0;t--){var c=this._randrange(new n(2),a),h=e.gcd(c);if(0!==h.cmpn(1))return h;var l=c.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var d=1;d=6?"utf-8":"binary"}else n="utf-8";t.exports=n}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:353}],350:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],351:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("safe-buffer").Buffer,s=e("./precondition"),u=e("./default-encoding"),f=e("./to-buffer"),c=a.alloc(128),h={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,r){var s=function(e){return"rmd160"===e||"ripemd160"===e?function(e){return(new i).update(e).digest()}:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),u="sha512"===e||"sha384"===e?128:64;t.length>u?t=s(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=r?f(new a(t),d):s(t,d);var y=c.alloc(p-l.length);if(l=c.concat([y,l],p),4===h)return function(e,t){var r=e.modulus.byteLength(),n=u("sha1").update(c.alloc(0)).digest(),a=n.length;if(0!==t[0])throw new Error("decryption error");var s=t.slice(1,a+1),f=t.slice(a+1),h=o(s,i(f,a)),l=o(f,i(h,r-a-1));if(function(e,t){e=c.from(e),t=c.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var a=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,r);if(3===h)return l;throw new Error("unknown padding")}},{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,"safe-buffer":364}],358:[function(e,t,r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),f=e("./withPublic"),c=e("browserify-rsa"),h=e("safe-buffer").Buffer;t.exports=function(e,t,r){var l;l=e.padding?e.padding:r?1:4;var d,p=n(e);if(4===l)d=function(e,t){var r=e.modulus.byteLength(),n=t.length,f=o("sha1").update(h.alloc(0)).digest(),c=f.length,l=2*c;if(n>r-l-2)throw new Error("message too long");var d=h.alloc(r-n-l-2),p=r-c-1,y=i(c),b=s(h.concat([f,d,h.alloc(1,1),t],p),a(y,p)),m=s(y,a(b,c));return new u(h.concat([h.alloc(1),m,b],r))}(p,t);else if(1===l)d=function(e,t,r){var n,o=t.length,a=e.modulus.byteLength();if(o>a-11)throw new Error("message too long");n=r?h.alloc(a-o-3,255):function(e){var t,r=h.allocUnsafe(e),n=0,o=i(2*e),a=0;for(;n=0)throw new Error("data too long for modulus")}return r?c(d,p):f(d,p)}},{"./mgf":355,"./withPublic":359,"./xor":360,"bn.js":356,"browserify-rsa":243,"create-hash":270,"parse-asn1":346,randombytes:361,"safe-buffer":364}],359:[function(e,t,r){var n=e("bn.js"),i=e("safe-buffer").Buffer;t.exports=function(e,t){return i.from(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}},{"bn.js":356,"safe-buffer":364}],360:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++nc||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>c||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return f.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}f&&f.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:353,randombytes:361,"safe-buffer":364}],363:[function(e,t,r){arguments[4][121][0].apply(r,arguments)},{buffer:266,dup:121,"hash-base":305,inherits:335}],364:[function(e,t,r){arguments[4][122][0].apply(r,arguments)},{buffer:266,dup:122}],365:[function(e,t,r){arguments[4][123][0].apply(r,arguments)},{_process:353,buffer:266,dup:123}],366:[function(e,t,r){arguments[4][127][0].apply(r,arguments)},{dup:127,"safe-buffer":364}],367:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{"./sha":368,"./sha1":369,"./sha224":370,"./sha256":371,"./sha384":372,"./sha512":373,dup:128}],368:[function(e,t,r){arguments[4][129][0].apply(r,arguments)},{"./hash":366,dup:129,inherits:335,"safe-buffer":364}],369:[function(e,t,r){arguments[4][130][0].apply(r,arguments)},{"./hash":366,dup:130,inherits:335,"safe-buffer":364}],370:[function(e,t,r){arguments[4][131][0].apply(r,arguments)},{"./hash":366,"./sha256":371,dup:131,inherits:335,"safe-buffer":364}],371:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{"./hash":366,dup:132,inherits:335,"safe-buffer":364}],372:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./hash":366,"./sha512":373,dup:133,inherits:335,"safe-buffer":364}],373:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{"./hash":366,dup:134,inherits:335,"safe-buffer":364}],374:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/lib/_stream_readable.js"),i.Writable=e("readable-stream/lib/_stream_writable.js"),i.Duplex=e("readable-stream/lib/_stream_duplex.js"),i.Transform=e("readable-stream/lib/_stream_transform.js"),i.PassThrough=e("readable-stream/lib/_stream_passthrough.js"),i.finished=e("readable-stream/lib/internal/streams/end-of-stream.js"),i.pipeline=e("readable-stream/lib/internal/streams/pipeline.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(c(),0===n.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",f),e.on("error",f),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},{events:303,inherits:335,"readable-stream/lib/_stream_duplex.js":376,"readable-stream/lib/_stream_passthrough.js":377,"readable-stream/lib/_stream_readable.js":378,"readable-stream/lib/_stream_transform.js":379,"readable-stream/lib/_stream_writable.js":380,"readable-stream/lib/internal/streams/end-of-stream.js":384,"readable-stream/lib/internal/streams/pipeline.js":386}],375:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106}],376:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{"./_stream_readable":378,"./_stream_writable":380,_process:353,dup:107,inherits:335}],377:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{"./_stream_transform":379,dup:108,inherits:335}],378:[function(e,t,r){arguments[4][109][0].apply(r,arguments)},{"../errors":375,"./_stream_duplex":376,"./internal/streams/async_iterator":381,"./internal/streams/buffer_list":382,"./internal/streams/destroy":383,"./internal/streams/from":385,"./internal/streams/state":387,"./internal/streams/stream":388,_process:353,buffer:266,dup:109,events:303,inherits:335,"string_decoder/":389,util:222}],379:[function(e,t,r){arguments[4][110][0].apply(r,arguments)},{"../errors":375,"./_stream_duplex":376,dup:110,inherits:335}],380:[function(e,t,r){arguments[4][111][0].apply(r,arguments)},{"../errors":375,"./_stream_duplex":376,"./internal/streams/destroy":383,"./internal/streams/state":387,"./internal/streams/stream":388,_process:353,buffer:266,dup:111,inherits:335,"util-deprecate":390}],381:[function(e,t,r){arguments[4][112][0].apply(r,arguments)},{"./end-of-stream":384,_process:353,dup:112}],382:[function(e,t,r){arguments[4][113][0].apply(r,arguments)},{buffer:266,dup:113,util:222}],383:[function(e,t,r){arguments[4][114][0].apply(r,arguments)},{_process:353,dup:114}],384:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{"../../../errors":375,dup:115}],385:[function(e,t,r){arguments[4][116][0].apply(r,arguments)},{dup:116}],386:[function(e,t,r){arguments[4][117][0].apply(r,arguments)},{"../../../errors":375,"./end-of-stream":384,dup:117}],387:[function(e,t,r){arguments[4][118][0].apply(r,arguments)},{"../../../errors":375,dup:118}],388:[function(e,t,r){arguments[4][119][0].apply(r,arguments)},{dup:119,events:303}],389:[function(e,t,r){arguments[4][135][0].apply(r,arguments)},{dup:135,"safe-buffer":364}],390:[function(e,t,r){arguments[4][179][0].apply(r,arguments)},{dup:179}]},{},[181])(181)}); \ No newline at end of file From b49a038adb88ed3cc31df5d3ade36b2fff38e589 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Mon, 19 Jul 2021 15:22:00 +0100 Subject: [PATCH 15/22] serialize deploy to / fro --- app/assets/v2/js/pages/bounty_detail/casper_extension.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 2e62451bbbd..4bd6fe9a207 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -35,8 +35,10 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const payment = DeployUtil.standardPayment(paymentAmount); const deploy = DeployUtil.makeDeploy(deployParams, session, payment); + const deployJson = DeployUtil.deployToJson(deploy); - const signedDeploy = await Signer.sign(deploy, fromPublicKey, toPublicKey); + const signedDeployJson = await Signer.sign(deployJson, selectedAddress, to_address); + const signedDeploy = DeployUtil.deployFromJson(signedDeployJson); try { const deployHash = await casperClient.putDeploy(signedDeploy); @@ -44,7 +46,7 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { callback(null, selectedAddress, deployHash); } catch (e) { modal.closeModal(); - callback(err); + callback(e); } function callback(error, from_address, txn) { From b9f56336535e2dc90337b69e608b86489a92b8f9 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Tue, 20 Jul 2021 20:27:32 +0100 Subject: [PATCH 16/22] add payout forwarder endpoint --- app/app/urls.py | 1 + .../pages/bounty_detail/casper_extension.js | 3 ++- app/dashboard/views.py | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/app/urls.py b/app/app/urls.py index 8584b4a3f90..452e88383da 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -71,6 +71,7 @@ url('^api/v1/bounty/fulfill', dashboard.views.fulfill_bounty_v1, name='fulfill_bounty_v1'), path('api/v1/bounty//close', dashboard.views.close_bounty_v1, name='close_bounty_v1'), path('api/v1/bounty/payout/', dashboard.views.payout_bounty_v1, name='payout_bounty_v1'), + path('api/v1/bounty/payout/broadcast/', dashboard.views.payout_tx_forwarder_v1, name='payout_tx_forwarder_v1'), re_path(r'.*api/v0.1/video/presence$', townsquare.views.video_presence, name='video_presence'), # inbox diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 4bd6fe9a207..61dace34128 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -2,9 +2,10 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const amount = vm.fulfillment_context.amount; const token_name = vm.bounty.token_name; + const tenant = vm.getTenant(token_name, vm.bounty.web3_type); const { CasperClient, DeployUtil, PublicKey, Signer } = casper; - const casperClient = new CasperClient('http://3.142.224.108:7777/rpc'); + const casperClient = new CasperClient(`/api/v1/bounty/payout/broadcast/${tenant}`); const isConnected = await Signer.isConnected(); diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 0237baef034..cf0fc583344 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -6549,6 +6549,30 @@ def payout_bounty_v1(request, fulfillment_id): return JsonResponse(response) +@csrf_exempt +@require_POST +def payout_tx_forwarder_v1(request, tenant): + ''' + Proxy payout transaction to external node to bypass CORS restriction on browser. + ''' + import requests + + if tenant.upper() == 'CASPER': + # casper + url = 'http://3.142.224.108:7777/rpc' + else: + return JsonResponse({'error': 'invalid tenant'}, status=400) + + data = json.loads(request.body) + + try: + response = requests.post(url, json=data).json() + except Exception: + response = {} + + return JsonResponse(response) + + @csrf_exempt @require_POST def close_bounty_v1(request, bounty_id): From 591b5df0b22458285faf02bccf68996968ce1d3b Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 21 Jul 2021 03:50:01 +0100 Subject: [PATCH 17/22] handle rpc error --- app/dashboard/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index cf0fc583344..cc51dff3027 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -6567,8 +6567,11 @@ def payout_tx_forwarder_v1(request, tenant): try: response = requests.post(url, json=data).json() + + if response.get("error", False): + return JsonResponse({'error': response["error"]}, status=422) except Exception: - response = {} + return JsonResponse({'error': 'something went wrong!'}, status=422) return JsonResponse(response) From 9510c069fb76bf5640168c57b3a78379fde45b56 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 21 Jul 2021 04:11:43 +0100 Subject: [PATCH 18/22] final fixes --- app/assets/v2/js/pages/bounty_detail/casper_extension.js | 2 +- app/dashboard/sync/casper.py | 3 --- app/dashboard/sync/tezos.py | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 61dace34128..090ae997fcc 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -30,7 +30,7 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const session = DeployUtil.ExecutableDeployItem.newTransfer( amount * 10 ** vm.decimals, toPublicKey, - fromPublicKey, + null, id ); diff --git a/app/dashboard/sync/casper.py b/app/dashboard/sync/casper.py index 80fb0acaa41..a85b9fe9a54 100644 --- a/app/dashboard/sync/casper.py +++ b/app/dashboard/sync/casper.py @@ -34,9 +34,6 @@ def get_casper_txn_status(fulfillment): if ( result["deploy"]["hash"] == txnid and result["deploy"]["header"]["account"] == funderAddress - and [ - x for x in result["deploy"]["session"]["Transfer"]["args"] if x[0] == 'target' - ][0][1]['parsed'] == payeeAddress and float([ x for x in result["deploy"]["session"]["Transfer"]["args"] if x[0] == 'amount' ][0][1]['parsed']) == float(amount) * 10 ** 9 diff --git a/app/dashboard/sync/tezos.py b/app/dashboard/sync/tezos.py index 258c7a9bc93..a992145f9ca 100644 --- a/app/dashboard/sync/tezos.py +++ b/app/dashboard/sync/tezos.py @@ -59,7 +59,6 @@ def get_tezos_txn_status(fulfillment): ): if tx_response['status'] == 'applied' and confirmations > 0: return 'success' - return 'expired' return None @@ -79,7 +78,5 @@ def sync_tezos_payout(fulfillment): fulfillment.accepted_on = timezone.now() fulfillment.accepted = True record_payout_activity(fulfillment) - elif txn_status == 'expired': - fulfillment.payout_status = 'expired' fulfillment.save() From 01e9eb061f1972258a531597ef448034db6a91cb Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 21 Jul 2021 08:07:09 +0100 Subject: [PATCH 19/22] review fixes --- app/app/urls.py | 2 +- .../v2/js/pages/bounty_detail/casper_extension.js | 12 +++++++++--- app/dashboard/views.py | 3 +-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/app/urls.py b/app/app/urls.py index 452e88383da..d24851172f3 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -71,7 +71,7 @@ url('^api/v1/bounty/fulfill', dashboard.views.fulfill_bounty_v1, name='fulfill_bounty_v1'), path('api/v1/bounty//close', dashboard.views.close_bounty_v1, name='close_bounty_v1'), path('api/v1/bounty/payout/', dashboard.views.payout_bounty_v1, name='payout_bounty_v1'), - path('api/v1/bounty/payout/broadcast/', dashboard.views.payout_tx_forwarder_v1, name='payout_tx_forwarder_v1'), + path('api/v1/reverse-proxy/', dashboard.views.reverse_proxy_rpc_v1, name='payout_tx_forwarder_v1'), re_path(r'.*api/v0.1/video/presence$', townsquare.views.video_presence, name='video_presence'), # inbox diff --git a/app/assets/v2/js/pages/bounty_detail/casper_extension.js b/app/assets/v2/js/pages/bounty_detail/casper_extension.js index 090ae997fcc..9996b44da31 100644 --- a/app/assets/v2/js/pages/bounty_detail/casper_extension.js +++ b/app/assets/v2/js/pages/bounty_detail/casper_extension.js @@ -5,7 +5,7 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { const tenant = vm.getTenant(token_name, vm.bounty.web3_type); const { CasperClient, DeployUtil, PublicKey, Signer } = casper; - const casperClient = new CasperClient(`/api/v1/bounty/payout/broadcast/${tenant}`); + const casperClient = new CasperClient(`/api/v1/reverse-proxy/${tenant}`); const isConnected = await Signer.isConnected(); @@ -14,18 +14,24 @@ const payWithCasperExtension = async(fulfillment_id, to_address, vm, modal) => { Signer.sendConnectionRequest(); } catch (e) { _alert({ message: gettext('Please download or enable CasperLabs Signer extension.') }, 'danger'); + return; } } const selectedAddress = await Signer.getActivePublicKey(); - const paymentAmount = 10000; + const paymentAmount = 10000; // for native-transfers the payment price is fixed const id = fulfillment_id; + const gasPrice = 1; // gasPrice for native transfers can be set to 1 + + // time that the deploy will remain valid for, in milliseconds + // the default value is 1800000 ms (30 minutes) const ttl = 1800000; + const fromPublicKey = PublicKey.fromHex(selectedAddress); const toPublicKey = PublicKey.fromHex(to_address); - let deployParams = new DeployUtil.DeployParams(fromPublicKey, 'casper', ttl); + let deployParams = new DeployUtil.DeployParams(fromPublicKey, 'casper', gasPrice, ttl); const session = DeployUtil.ExecutableDeployItem.newTransfer( amount * 10 ** vm.decimals, diff --git a/app/dashboard/views.py b/app/dashboard/views.py index cc51dff3027..3b5083abf16 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -6551,11 +6551,10 @@ def payout_bounty_v1(request, fulfillment_id): @csrf_exempt @require_POST -def payout_tx_forwarder_v1(request, tenant): +def reverse_proxy_rpc_v1(request, tenant): ''' Proxy payout transaction to external node to bypass CORS restriction on browser. ''' - import requests if tenant.upper() == 'CASPER': # casper From 4d4bb80308b09fa6b7d2bca54f05986ce95278a0 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Wed, 21 Jul 2021 08:19:44 +0100 Subject: [PATCH 20/22] less complexity --- app/app/bundle_context.py | 1 + app/dashboard/admin.py | 2 +- app/dashboard/management/commands/bundle.py | 3 +-- app/dashboard/sync/casper.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/app/bundle_context.py b/app/app/bundle_context.py index be87622a344..a79d285bf8f 100644 --- a/app/app/bundle_context.py +++ b/app/app/bundle_context.py @@ -21,6 +21,7 @@ from cacheops import cached_as from perftools.models import JSONStore + @cached_as(JSONStore.objects.filter(view='bundleTags', key='bundleTags'), timeout=60) def templateTags(): diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 438e4097eaf..dacd14703be 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -25,6 +25,7 @@ from django.utils.safestring import mark_safe from adminsortable2.admin import SortableInlineAdminMixin +from perftools.management.commands import create_page_cache from .models import ( Activity, Answer, BlockedIP, BlockedURLFilter, BlockedUser, Bounty, BountyEvent, BountyFulfillment, BountyInvites, @@ -35,7 +36,6 @@ TransactionHistory, TribeMember, TribesSubscription, UserAction, UserVerificationModel, ) -from perftools.management.commands import create_page_cache class BountyEventAdmin(admin.ModelAdmin): list_display = ['created_on', '__str__', 'event_type'] diff --git a/app/dashboard/management/commands/bundle.py b/app/dashboard/management/commands/bundle.py index b32d6ba8cab..126d4b4b50d 100644 --- a/app/dashboard/management/commands/bundle.py +++ b/app/dashboard/management/commands/bundle.py @@ -7,9 +7,8 @@ from django.template import Context, Template from django.template.loaders.app_directories import get_app_template_dirs -from dashboard.templatetags.bundle import render - from app.bundle_context import context, templateTags +from dashboard.templatetags.bundle import render def rmdir(loc, depth=1): diff --git a/app/dashboard/sync/casper.py b/app/dashboard/sync/casper.py index a85b9fe9a54..ffe05a030da 100644 --- a/app/dashboard/sync/casper.py +++ b/app/dashboard/sync/casper.py @@ -31,11 +31,12 @@ def get_casper_txn_status(fulfillment): result = casper_response['result'] if result: + transfer_args = result["deploy"]["session"]["Transfer"]["args"] if ( result["deploy"]["hash"] == txnid and result["deploy"]["header"]["account"] == funderAddress and float([ - x for x in result["deploy"]["session"]["Transfer"]["args"] if x[0] == 'amount' + arg for arg in transfer_args if arg[0] == 'amount' ][0][1]['parsed']) == float(amount) * 10 ** 9 ): if result["execution_results"][0]["result"].get("Success", False) != False: From d299067b99d2825107c3ad9917c0774dc5c4a562 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Thu, 22 Jul 2021 02:48:33 +0100 Subject: [PATCH 21/22] restore tx expiry in tezos --- app/dashboard/sync/tezos.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/dashboard/sync/tezos.py b/app/dashboard/sync/tezos.py index a992145f9ca..258c7a9bc93 100644 --- a/app/dashboard/sync/tezos.py +++ b/app/dashboard/sync/tezos.py @@ -59,6 +59,7 @@ def get_tezos_txn_status(fulfillment): ): if tx_response['status'] == 'applied' and confirmations > 0: return 'success' + return 'expired' return None @@ -78,5 +79,7 @@ def sync_tezos_payout(fulfillment): fulfillment.accepted_on = timezone.now() fulfillment.accepted = True record_payout_activity(fulfillment) + elif txn_status == 'expired': + fulfillment.payout_status = 'expired' fulfillment.save() From ea4d1246254d46d485033fb2f49013d01dd3f9b3 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Fri, 23 Jul 2021 17:42:18 +0100 Subject: [PATCH 22/22] review update --- app/dashboard/sync/casper.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/dashboard/sync/casper.py b/app/dashboard/sync/casper.py index ffe05a030da..0323f607d3b 100644 --- a/app/dashboard/sync/casper.py +++ b/app/dashboard/sync/casper.py @@ -13,7 +13,6 @@ def get_casper_txn_status(fulfillment): token_name = fulfillment.token_name funderAddress = fulfillment.funder_address amount = fulfillment.payout_amount - payeeAddress = fulfillment.fulfiller_address if token_name != 'CSPR' or not txnid: return None @@ -25,8 +24,8 @@ def get_casper_txn_status(fulfillment): 'method': 'info_get_deploy', 'params': [ txnid ] } - - casper_response = requests.post('http://3.142.224.108:7777/rpc', json=data).json() + casper_rpc_url = 'http://3.142.224.108:7777/rpc' + casper_response = requests.post(casper_rpc_url, json=data).json() result = casper_response['result']