From 12d04bfcebc0496b3efe2b3d8b7d7143fb66579d Mon Sep 17 00:00:00 2001 From: hieu-w Date: Thu, 23 Jan 2025 10:14:07 +0700 Subject: [PATCH] Restore docs --- docs/e2e.js | 21412 +++++++++++++++++++++++------------------------ docs/iframe.js | 19829 +++++++++++++++++++++---------------------- docs/index.js | 19819 +++++++++++++++++++++---------------------- docs/worker.js | 21390 +++++++++++++++++++++++----------------------- 4 files changed, 39958 insertions(+), 42492 deletions(-) diff --git a/docs/e2e.js b/docs/e2e.js index 3a7b5778..80302e15 100644 --- a/docs/e2e.js +++ b/docs/e2e.js @@ -1,11 +1,9 @@ (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 Promise.all(this._befC.map(fn => fn()))) // close the channel - .then(() => this.method.close ? this.method.close(this._state) : Promise.resolve()); + .then(() => this.method.close(this._state)); }, get type() { return this.method.type; @@ -166,7 +164,6 @@ function _post(broadcastChannel, type, msg) { // add/remove to unsend messages list broadcastChannel._uMP.add(sendPromise); - // eslint-disable-next-line promise/valid-params sendPromise.catch().then(() => broadcastChannel._uMP.delete(sendPromise)); return sendPromise; }); @@ -181,7 +178,6 @@ function _prepareChannel(channel) { await new Promise(res => setTimeout(res, this.options.prepareDelay)); }*/ channel._state = s; - return; }); } else { channel._state = maybePromise; @@ -220,7 +216,7 @@ function _startListening(channel) { if (msgObj.time >= listenerObject.time) { listenerObject.fn(msgObj.data); - } else if (channel.method.type === "server") { + } else if (channel.method.type === 'server') { // server msg might lag based on connection. listenerObject.fn(msgObj.data); } @@ -231,7 +227,6 @@ function _startListening(channel) { channel._prepP.then(() => { channel._iL = true; channel.method.onMessage(channel._state, listenerFn, time); - return; }); } else { channel._iL = true; @@ -255,18 +250,18 @@ exports.enforceOptions = enforceOptions; },{"./method-chooser.js":3,"./options.js":9,"./util.js":10}],2:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var broadcastChannel = require('./broadcast-channel.js'); var methodChooser = require('./method-chooser.js'); +exports.NativeMethod = native; exports.IndexedDbMethod = indexedDb; exports.LocalstorageMethod = localstorage; -exports.NativeMethod = native; exports.ServerMethod = server; exports.BroadcastChannel = broadcastChannel.BroadcastChannel; exports.OPEN_BROADCAST_CHANNELS = broadcastChannel.OPEN_BROADCAST_CHANNELS; @@ -276,9 +271,9 @@ exports.chooseMethod = methodChooser.chooseMethod; },{"./broadcast-channel.js":1,"./method-chooser.js":3,"./methods/indexed-db.js":4,"./methods/localstorage.js":5,"./methods/native.js":6,"./methods/server.js":7}],3:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var simulate = require('./methods/simulate.js'); @@ -291,12 +286,12 @@ function chooseMethod(options) { // directly chosen if (options.type) { - if (options.type === "simulate") { + if (options.type === 'simulate') { // only use simulate-method if directly chosen return simulate; } const ret = chooseMethods.find(m => m.type === options.type); - if (!ret) throw new Error("method-type " + options.type + " not found");else return ret; + if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret; } /** @@ -304,7 +299,7 @@ function chooseMethod(options) { * remove idb from the list so that localstorage is been chosen */ if (!options.webWorkerSupport) { - chooseMethods = chooseMethods.filter(m => m.type !== "idb"); + chooseMethods = chooseMethods.filter(m => m.type !== 'idb'); } const useMethod = chooseMethods.find(method => method.canBeUsed(options)); if (!useMethod) throw new Error(`No useable method found in ${JSON.stringify(METHODS.map(m => m.type))}`);else return useMethod; @@ -329,23 +324,23 @@ var options = require('../options.js'); */ const microSeconds = util.microSeconds; -const DB_PREFIX = "pubkey.broadcast-channel-0-"; -const OBJECT_STORE_ID = "messages"; +const DB_PREFIX = 'pubkey.broadcast-channel-0-'; +const OBJECT_STORE_ID = 'messages'; /** * Use relaxed durability for faster performance on all transactions. * @link https://nolanlawson.com/2021/08/22/speeding-up-indexeddb-reads-and-writes/ */ const TRANSACTION_SETTINGS = { - durability: "relaxed" + durability: 'relaxed' }; -const type = "idb"; +const type = 'idb'; function getIdb() { - if (typeof indexedDB !== "undefined") return indexedDB; - if (typeof window !== "undefined") { - if (typeof window.mozIndexedDB !== "undefined") return window.mozIndexedDB; - if (typeof window.webkitIndexedDB !== "undefined") return window.webkitIndexedDB; - if (typeof window.msIndexedDB !== "undefined") return window.msIndexedDB; + if (typeof indexedDB !== 'undefined') return indexedDB; + if (typeof window !== 'undefined') { + if (typeof window.mozIndexedDB !== 'undefined') return window.mozIndexedDB; + if (typeof window.webkitIndexedDB !== 'undefined') return window.webkitIndexedDB; + if (typeof window.msIndexedDB !== 'undefined') return window.msIndexedDB; } return false; } @@ -375,14 +370,14 @@ function createDatabase(channelName) { openRequest.onupgradeneeded = ev => { const db = ev.target.result; db.createObjectStore(OBJECT_STORE_ID, { - keyPath: "id", + keyPath: 'id', autoIncrement: true }); }; - const dbPromise = new Promise((resolve, reject) => { - openRequest.onerror = ev => reject(ev); + const dbPromise = new Promise((res, rej) => { + openRequest.onerror = ev => rej(ev); openRequest.onsuccess = () => { - resolve(openRequest.result); + res(openRequest.result); }; }); return dbPromise; @@ -399,20 +394,20 @@ function writeMessage(db, readerUuid, messageJson) { time, data: messageJson }; - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); - return new Promise((resolve, reject) => { - tx.oncomplete = () => resolve(); - tx.onerror = ev => reject(ev); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); + return new Promise((res, rej) => { + tx.oncomplete = () => res(); + tx.onerror = ev => rej(ev); const objectStore = tx.objectStore(OBJECT_STORE_ID); objectStore.add(writeObject); commitIndexedDBTransaction(tx); }); } function getAllMessages(db) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -421,13 +416,13 @@ function getAllMessages(db) { cursor.continue(); } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function getMessagesHigherThan(db, lastCursorId) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; let keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); @@ -439,10 +434,10 @@ function getMessagesHigherThan(db, lastCursorId) { */ if (objectStore.getAll) { const getAllRequest = objectStore.getAll(keyRangeValue); - return new Promise((resolve, reject) => { - getAllRequest.onerror = err => reject(err); + return new Promise((res, rej) => { + getAllRequest.onerror = err => rej(err); getAllRequest.onsuccess = function (e) { - resolve(e.target.result); + res(e.target.result); }; }); } @@ -453,13 +448,13 @@ function getMessagesHigherThan(db, lastCursorId) { try { keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); return objectStore.openCursor(keyRangeValue); - } catch { + } catch (e) { return objectStore.openCursor(); } } - return new Promise((resolve, reject) => { + return new Promise((res, rej) => { const openCursorRequest = openCursor(); - openCursorRequest.onerror = err => reject(err); + openCursorRequest.onerror = err => rej(err); openCursorRequest.onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -471,27 +466,27 @@ function getMessagesHigherThan(db, lastCursorId) { } } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function removeMessagesById(db, ids) { - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); return Promise.all(ids.map(id => { const deleteRequest = objectStore.delete(id); - return new Promise(resolve => { - deleteRequest.onsuccess = () => resolve(); + return new Promise(res => { + deleteRequest.onsuccess = () => res(); }); })); } function getOldMessages(db, ttl) { const olderThen = Date.now() - ttl; - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -503,11 +498,11 @@ function getOldMessages(db, ttl) { } else { // no more old messages, commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); return; } } else { - resolve(ret); + res(ret); } }; }); @@ -562,8 +557,6 @@ function create(channelName, options$1) { } function _readLoop(state) { if (state.closed) return; - - // eslint-disable-next-line promise/catch-or-return readNewMessages(state).then(() => util.sleep(state.options.idb.fallbackInterval)).then(() => _readLoop(state)); } function _filterMessage(msgObj, state) { @@ -609,7 +602,6 @@ function close(channelState) { } function postMessage(channelState, messageJson) { channelState.writeBlockPromise = channelState.writeBlockPromise.then(() => writeMessage(channelState.db, channelState.uuid, messageJson)).then(() => { - // eslint-disable-next-line promise/always-return if (util.randomInt(0, 10) === 0) { /* await (do not await) */ cleanOldMessages(channelState.db, channelState.options.idb.ttl); @@ -650,7 +642,7 @@ exports.removeMessagesById = removeMessagesById; exports.type = type; exports.writeMessage = writeMessage; -},{"../options.js":9,"../util.js":10,"oblivious-set":503}],5:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":484}],5:[function(require,module,exports){ 'use strict'; var obliviousSet = require('oblivious-set'); @@ -666,8 +658,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "localstorage"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'localstorage'; /** * copied from crosstab @@ -675,11 +667,11 @@ const type = "localstorage"; */ function getLocalStorage() { let localStorage; - if (typeof window === "undefined") return null; + if (typeof window === 'undefined') return null; try { localStorage = window.localStorage; - localStorage = window["ie8-eventlistener/storage"] || window.localStorage; - } catch { + localStorage = window['ie8-eventlistener/storage'] || window.localStorage; + } catch (e) { // New versions of Firefox throw a Security exception // if cookies are disabled. See // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153 @@ -695,8 +687,7 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise(resolve => { - // eslint-disable-next-line promise/catch-or-return, promise/always-return + return new Promise(res => { util.sleep().then(() => { const key = storageKey(channelState.channelName); const writeObj = { @@ -713,12 +704,12 @@ function postMessage(channelState, messageJson) { * in the window that changes the state of the local storage. * So we fire it manually */ - const ev = document.createEvent("Event"); - ev.initEvent("storage", true, true); + const ev = document.createEvent('Event'); + ev.initEvent('storage', true, true); ev.key = key; ev.newValue = value; window.dispatchEvent(ev); - resolve(); + res(); }); }); } @@ -729,16 +720,16 @@ function addStorageEventListener(channelName, fn) { fn(JSON.parse(ev.newValue)); } }; - window.addEventListener("storage", listener); + window.addEventListener('storage', listener); return listener; } function removeStorageEventListener(listener) { - window.removeEventListener("storage", listener); + window.removeEventListener('storage', listener); } function create(channelName, options$1) { options$1 = options.fillOptionsWithDefaults(options$1); if (!canBeUsed()) { - throw new Error("BroadcastChannel: localstorage cannot be used"); + throw new Error('BroadcastChannel: localstorage cannot be used'); } const uuid = util.randomToken(); @@ -776,10 +767,10 @@ function canBeUsed() { const ls = getLocalStorage(); if (!ls) return false; try { - const key = "__broadcastchannel_check"; - ls.setItem(key, "works"); + const key = '__broadcastchannel_check'; + ls.setItem(key, 'works'); ls.removeItem(key); - } catch { + } catch (e) { // Safari 10 in private mode will not allow write access to local // storage and fail with a QuotaExceededError. See // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes @@ -790,7 +781,7 @@ function canBeUsed() { function averageResponseTime() { const defaultTime = 120; const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes("safari") && !userAgent.includes("chrome")) { + if (userAgent.includes('safari') && !userAgent.includes('chrome')) { // safari is much slower so this time is higher return defaultTime * 2; } @@ -810,13 +801,13 @@ exports.removeStorageEventListener = removeStorageEventListener; exports.storageKey = storageKey; exports.type = type; -},{"../options.js":9,"../util.js":10,"oblivious-set":503}],6:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":484}],6:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "native"; +const type = 'native'; function create(channelName) { const state = { time: util.microSeconds(), @@ -851,10 +842,10 @@ function canBeUsed() { * in the electron-renderer, isNode will be true even if we are in browser-context * so we also check if window is undefined */ - if (typeof window === "undefined") return false; - if (typeof BroadcastChannel === "function") { + if (typeof window === 'undefined') return false; + if (typeof BroadcastChannel === 'function') { if (BroadcastChannel._pubkey) { - throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"); + throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill'); } return true; } else return false; @@ -876,12 +867,12 @@ exports.type = type; (function (Buffer){(function (){ 'use strict'; -var eccrypto = require('@toruslabs/eccrypto'); -var metadataHelpers = require('@toruslabs/metadata-helpers'); var obliviousSet = require('oblivious-set'); var socket_ioClient = require('socket.io-client'); -var options = require('../options.js'); +var eccrypto = require('@toruslabs/eccrypto'); +var metadataHelpers = require('@toruslabs/metadata-helpers'); var util = require('../util.js'); +var options = require('../options.js'); /** * A localStorage-only method which uses localstorage and its 'storage'-event @@ -892,8 +883,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "server"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'server'; let SOCKET_CONN_INSTANCE = null; // used to decide to reconnect socket e.g. when socket connection is disconnected unexpectedly const runningChannels = new Set(); @@ -906,12 +897,11 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise((resolve, reject) => { - // eslint-disable-next-line promise/catch-or-return + return new Promise((res, rej) => { util.sleep().then(async () => { const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString("hex"), { + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString('hex'), { token: util.randomToken(), time: Date.now(), data: messageJson, @@ -920,18 +910,18 @@ function postMessage(channelState, messageJson) { const body = { sameOriginCheck: true, sameIpCheck: true, - key: eccrypto.getPublic(channelEncPrivKey).toString("hex"), + key: eccrypto.getPublic(channelEncPrivKey).toString('hex'), data: encData, - signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, "utf8")))).toString("hex") + signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, 'utf8')))).toString('hex') }; if (channelState.timeout) body.timeout = channelState.timeout; - return fetch(channelState.serverUrl + "/channel/set", { - method: "POST", + return fetch(channelState.serverUrl + '/channel/set', { + method: 'POST', body: JSON.stringify(body), headers: { - "Content-Type": "application/json; charset=utf-8" + 'Content-Type': 'application/json; charset=utf-8' } - }).then(resolve).catch(reject); + }).then(res).catch(rej); }); }); } @@ -940,33 +930,33 @@ function getSocketInstance(serverUrl) { return SOCKET_CONN_INSTANCE; } const SOCKET_CONN = socket_ioClient.io(serverUrl, { - transports: ["websocket", "polling"], + transports: ['websocket', 'polling'], // use WebSocket first, if available withCredentials: true, reconnectionDelayMax: 10000, reconnectionAttempts: 10 }); - SOCKET_CONN.on("connect_error", err => { + SOCKET_CONN.on('connect_error', err => { // revert to classic upgrade - SOCKET_CONN.io.opts.transports = ["polling", "websocket"]; - util.log.error("connect error", err); + SOCKET_CONN.io.opts.transports = ['polling', 'websocket']; + util.log.error('connect error', err); }); - SOCKET_CONN.on("connect", async () => { + SOCKET_CONN.on('connect', async () => { const { engine } = SOCKET_CONN.io; - util.log.debug("initially connected to", engine.transport.name); // in most cases, prints "polling" - engine.once("upgrade", () => { + util.log.debug('initially connected to', engine.transport.name); // in most cases, prints "polling" + engine.once('upgrade', () => { // called when the transport is upgraded (i.e. from HTTP long-polling to WebSocket) - util.log.debug("upgraded", engine.transport.name); // in most cases, prints "websocket" + util.log.debug('upgraded', engine.transport.name); // in most cases, prints "websocket" }); - engine.once("close", reason => { + engine.once('close', reason => { // called when the underlying connection is closed - util.log.debug("connection closed", reason); + util.log.debug('connection closed', reason); }); }); - SOCKET_CONN.on("error", err => { - util.log.error("socket errored", err); + SOCKET_CONN.on('error', err => { + util.log.error('socket errored', err); SOCKET_CONN.disconnect(); }); SOCKET_CONN_INSTANCE = SOCKET_CONN; @@ -975,26 +965,26 @@ function getSocketInstance(serverUrl) { function setupSocketConnection(serverUrl, channelState, fn) { const socketConn = getSocketInstance(serverUrl); const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString("hex"); + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString('hex'); if (socketConn.connected) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); } else { - socketConn.once("connect", () => { - util.log.debug("connected with socket"); - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.once('connect', () => { + util.log.debug('connected with socket'); + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); }); } const reconnect = () => { - socketConn.once("connect", async () => { + socketConn.once('connect', async () => { if (runningChannels.has(channelState.channelName)) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); @@ -1004,32 +994,32 @@ function setupSocketConnection(serverUrl, channelState, fn) { const visibilityListener = () => { // if channel is closed, then remove the listener. if (!socketConn || !runningChannels.has(channelState.channelName)) { - document.removeEventListener("visibilitychange", visibilityListener); + document.removeEventListener('visibilitychange', visibilityListener); return; } // if not connected, then wait for connection and ping server for latest msg. - if (!socketConn.connected && document.visibilityState === "visible") { + if (!socketConn.connected && document.visibilityState === 'visible') { reconnect(); } }; const listener = async ev => { try { - const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString("hex"), ev); + const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString('hex'), ev); util.log.info(decData); fn(decData); } catch (error) { util.log.error(error); } }; - socketConn.on("disconnect", () => { - util.log.debug("socket disconnected"); + socketConn.on('disconnect', () => { + util.log.debug('socket disconnected'); if (runningChannels.has(channelState.channelName)) { - util.log.error("socket disconnected unexpectedly, reconnecting socket"); + util.log.error('socket disconnected unexpectedly, reconnecting socket'); reconnect(); } }); socketConn.on(`${channelPubKey}_success`, listener); - if (typeof document !== "undefined") document.addEventListener("visibilitychange", visibilityListener); + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', visibilityListener); return socketConn; } function removeStorageEventListener() { @@ -1104,13 +1094,13 @@ exports.storageKey = storageKey; exports.type = type; }).call(this)}).call(this,require("buffer").Buffer) -},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":27,"@toruslabs/metadata-helpers":30,"buffer":56,"oblivious-set":503,"socket.io-client":520}],8:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":27,"@toruslabs/metadata-helpers":30,"buffer":56,"oblivious-set":484,"socket.io-client":497}],8:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "simulate"; +const type = 'simulate'; const SIMULATE_CHANNELS = new Set(); const SIMULATE_DELAY_TIME = 5; function create(channelName) { @@ -1126,7 +1116,7 @@ function close(channelState) { SIMULATE_CHANNELS.delete(channelState); } function postMessage(channelState, messageJson) { - return new Promise(resolve => setTimeout(() => { + return new Promise(res => setTimeout(() => { const channelArray = Array.from(SIMULATE_CHANNELS); channelArray.forEach(channel => { if (channel.name === channelState.name && @@ -1140,7 +1130,7 @@ function postMessage(channelState, messageJson) { channel.messagesCallback(messageJson); } }); - resolve(); + res(); }, SIMULATE_DELAY_TIME)); } function onMessage(channelState, fn) { @@ -1170,7 +1160,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { const options = JSON.parse(JSON.stringify(originalOptions)); // main - if (typeof options.webWorkerSupport === "undefined") options.webWorkerSupport = true; + if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db if (!options.idb) options.idb = {}; @@ -1178,7 +1168,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { if (!options.idb.ttl) options.idb.ttl = 1000 * 45; if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events. - if (originalOptions.idb && typeof originalOptions.idb.onclose === "function") options.idb.onclose = originalOptions.idb.onclose; + if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage if (!options.localstorage) options.localstorage = {}; @@ -1186,7 +1176,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { // server if (!options.server) options.server = {}; - if (!options.server.url) options.server.url = "https://session.web3auth.io"; + if (!options.server.url) options.server.url = 'https://session.web3auth.io'; if (!options.server.removeTimeout) options.server.removeTimeout = 1000 * 60 * 5; // 5 minutes // custom methods @@ -1207,7 +1197,7 @@ var loglevel = require('loglevel'); * returns true if the given object is a promise */ function isPromise(obj) { - if (obj && typeof obj.then === "function") { + if (obj && typeof obj.then === 'function') { return true; } else { return false; @@ -1218,7 +1208,7 @@ Promise.resolve(true); const PROMISE_RESOLVED_VOID = Promise.resolve(); function sleep(time, resolveWith) { if (!time) time = 0; - return new Promise(resolve => setTimeout(() => resolve(resolveWith), time)); + return new Promise(res => setTimeout(() => res(resolveWith), time)); } function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); @@ -1272,8 +1262,8 @@ function microSeconds() { // return thirdPartyCookieSupport; // } -const log = loglevel.getLogger("broadcast-channel"); -log.setLevel("error"); +const log = loglevel.getLogger('broadcast-channel'); +log.setLevel('error'); exports.PROMISE_RESOLVED_VOID = PROMISE_RESOLVED_VOID; exports.isPromise = isPromise; @@ -1283,7 +1273,7 @@ exports.randomInt = randomInt; exports.randomToken = randomToken; exports.sleep = sleep; -},{"loglevel":479}],11:[function(require,module,exports){ +},{"loglevel":468}],11:[function(require,module,exports){ "use strict"; require("./noConflict"); @@ -1297,7 +1287,7 @@ if (_global["default"]._babelPolyfill && typeof console !== "undefined" && conso } _global["default"]._babelPolyfill = true; -},{"./noConflict":12,"core-js/library/fn/global":79}],12:[function(require,module,exports){ +},{"./noConflict":12,"core-js/library/fn/global":72}],12:[function(require,module,exports){ "use strict"; require("core-js/es6"); @@ -1327,7 +1317,7 @@ require("core-js/fn/promise/finally"); require("core-js/web"); require("regenerator-runtime/runtime"); -},{"core-js/es6":67,"core-js/fn/array/flat-map":68,"core-js/fn/array/includes":69,"core-js/fn/object/entries":70,"core-js/fn/object/get-own-property-descriptors":71,"core-js/fn/object/values":72,"core-js/fn/promise/finally":73,"core-js/fn/string/pad-end":74,"core-js/fn/string/pad-start":75,"core-js/fn/string/trim-end":76,"core-js/fn/string/trim-start":77,"core-js/fn/symbol/async-iterator":78,"core-js/web":370,"regenerator-runtime/runtime":507}],13:[function(require,module,exports){ +},{"core-js/es6":60,"core-js/fn/array/flat-map":61,"core-js/fn/array/includes":62,"core-js/fn/object/entries":63,"core-js/fn/object/get-own-property-descriptors":64,"core-js/fn/object/values":65,"core-js/fn/promise/finally":66,"core-js/fn/string/pad-end":67,"core-js/fn/string/pad-start":68,"core-js/fn/string/trim-end":69,"core-js/fn/string/trim-start":70,"core-js/fn/symbol/async-iterator":71,"core-js/web":363,"regenerator-runtime/runtime":488}],13:[function(require,module,exports){ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), @@ -1719,11 +1709,11 @@ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports function _typeof(o) { "@babel/helpers - typeof"; - return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; },{}],20:[function(require,module,exports){ @@ -1746,44 +1736,44 @@ try { },{"../helpers/regeneratorRuntime":16}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isBytes = isBytes; -exports.number = number; -exports.bool = bool; -exports.bytes = bytes; -exports.hash = hash; -exports.exists = exists; -exports.output = output; +exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = exports.isBytes = void 0; function number(n) { if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); } +exports.number = number; function bool(b) { if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`); } +exports.bool = bool; // copied from utils function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; function bytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); } +exports.bytes = bytes; function hash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); number(h.outputLen); number(h.blockLen); } +exports.hash = hash; function exists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } +exports.exists = exists; function output(out, instance) { bytes(out); const min = instance.outputLen; @@ -1791,16 +1781,14 @@ function output(out, instance) { throw new Error(`digestInto() expects output buffer of length at least ${min}`); } } +exports.output = output; const assert = { number, bool, bytes, hash, exists, output }; exports.default = assert; },{}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = void 0; -exports.fromBig = fromBig; -exports.split = split; -exports.add = add; +exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.add = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = exports.split = exports.fromBig = void 0; const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); // We are not using BigUint64Array, because they are extremely slow as per 2022 @@ -1809,6 +1797,7 @@ function fromBig(n, le = false) { return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; } +exports.fromBig = fromBig; function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); @@ -1818,6 +1807,7 @@ function split(lst, le = false) { } return [Ah, Al]; } +exports.split = split; const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); exports.toBig = toBig; // for Shift in [0, 32) @@ -1856,6 +1846,7 @@ function add(Ah, Al, Bh, Bl) { const l = (Al >>> 0) + (Bl >>> 0); return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; } +exports.add = add; // Addition with more than 2 elements const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); exports.add3L = add3L; @@ -1889,8 +1880,7 @@ exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? glob },{}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0; -exports.keccakP = keccakP; +exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0; const _assert_js_1 = require("./_assert.js"); const _u64_js_1 = require("./_u64.js"); const utils_js_1 = require("./utils.js"); @@ -1971,6 +1961,7 @@ function keccakP(s, rounds = 24) { } B.fill(0); } +exports.keccakP = keccakP; class Keccak extends utils_js_1.Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { @@ -2110,20 +2101,7 @@ exports.shake256 = genShake(0x1f, 136, 256 / 8); "use strict"; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0; -exports.isBytes = isBytes; -exports.byteSwap32 = byteSwap32; -exports.bytesToHex = bytesToHex; -exports.hexToBytes = hexToBytes; -exports.asyncLoop = asyncLoop; -exports.utf8ToBytes = utf8ToBytes; -exports.toBytes = toBytes; -exports.concatBytes = concatBytes; -exports.checkOpts = checkOpts; -exports.wrapConstructor = wrapConstructor; -exports.wrapConstructorWithOpts = wrapConstructorWithOpts; -exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; -exports.randomBytes = randomBytes; +exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.byteSwap32 = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = exports.isBytes = void 0; // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. // node.js versions earlier than v19 don't declare it in global scope. // For node.js, package.json#exports field mapping rewrites import @@ -2138,6 +2116,7 @@ function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; // Cast array to different type const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); exports.u8 = u8; @@ -2167,6 +2146,7 @@ function byteSwap32(arr) { arr[i] = (0, exports.byteSwap)(arr[i]); } } +exports.byteSwap32 = byteSwap32; // Array where index 0xf0 (240) is mapped to string 'f0' const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); /** @@ -2181,6 +2161,7 @@ function bytesToHex(bytes) { } return hex; } +exports.bytesToHex = bytesToHex; // We use optimized technique to convert hex string to byte array const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; function asciiToBase16(char) { @@ -2214,6 +2195,7 @@ function hexToBytes(hex) { } return array; } +exports.hexToBytes = hexToBytes; // There is no setImmediate in browser and setTimeout is slow. // call of async fn will return Promise, which will be fullfiled only on // next scheduler queue processing step and this is exactly what we need. @@ -2232,6 +2214,7 @@ async function asyncLoop(iters, tick, cb) { ts += diff; } } +exports.asyncLoop = asyncLoop; /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ @@ -2240,6 +2223,7 @@ function utf8ToBytes(str) { throw new Error(`utf8ToBytes expected string, got ${typeof str}`); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } +exports.utf8ToBytes = utf8ToBytes; /** * Normalizes (non-hex) string or Uint8Array to Uint8Array. * Warning: when Uint8Array is passed, it would NOT get copied. @@ -2251,6 +2235,7 @@ function toBytes(data) { (0, _assert_js_1.bytes)(data); return data; } +exports.toBytes = toBytes; /** * Copies several Uint8Arrays into one. */ @@ -2269,6 +2254,7 @@ function concatBytes(...arrays) { } return res; } +exports.concatBytes = concatBytes; // For runtime check if class implements interface class Hash { // Safe version that clones internal state @@ -2284,6 +2270,7 @@ function checkOpts(defaults, opts) { const merged = Object.assign(defaults, opts); return merged; } +exports.checkOpts = checkOpts; function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); @@ -2292,6 +2279,7 @@ function wrapConstructor(hashCons) { hashC.create = () => hashCons(); return hashC; } +exports.wrapConstructor = wrapConstructor; function wrapConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -2300,6 +2288,7 @@ function wrapConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapConstructorWithOpts = wrapConstructorWithOpts; function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -2308,6 +2297,7 @@ function wrapXOFConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; /** * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. */ @@ -2315,12 +2305,9 @@ function randomBytes(bytesLength = 32) { if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); } - // Legacy Node.js compatibility - if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { - return crypto_1.crypto.randomBytes(bytesLength); - } throw new Error('crypto.getRandomValues must be defined'); } +exports.randomBytes = randomBytes; },{"./_assert.js":21,"@noble/hashes/crypto":23}],26:[function(require,module,exports){ @@ -2546,26 +2533,18 @@ function equalConstTime(b1, b2) { not, since the functions are different and does not convert using browserify */ function randomBytes(size) { - if (typeof browserCrypto.getRandomValues === "undefined") { - return Buffer.from(browserCrypto.randomBytes(size)); - } const arr = new Uint8Array(size); browserCrypto.getRandomValues(arr); return Buffer.from(arr); } async function sha512(msg) { - if (!browserCrypto.createHash) { - const hash = await subtle.digest("SHA-512", msg); - const result = new Uint8Array(hash); - return result; - } - const hash = browserCrypto.createHash("sha512"); - const result = hash.update(msg).digest(); - return new Uint8Array(result); + const hash = await subtle.digest("SHA-512", msg); + const result = new Uint8Array(hash); + return result; } function getAes(op) { return async function (iv, key, data) { - if (subtle && subtle[op] && subtle.importKey) { + if (subtle) { const importAlgorithm = { name: "AES-CBC" }; @@ -2574,20 +2553,8 @@ function getAes(op) { name: "AES-CBC", iv }; - // encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. const result = await subtle[op](encAlgorithm, cryptoKey, data); return Buffer.from(new Uint8Array(result)); - } else if (op === "encrypt" && browserCrypto.createCipheriv) { - // This is available if crypto is polyfilled in react native environment - const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); - const firstChunk = cipher.update(data); - const secondChunk = cipher.final(); - return Buffer.concat([firstChunk, secondChunk]); - } else if (op === "decrypt" && browserCrypto.createDecipheriv) { - const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); - const firstChunk = decipher.update(data); - const secondChunk = decipher.final(); - return Buffer.concat([firstChunk, secondChunk]); } throw new Error(`Unsupported operation: ${op}`); }; @@ -2595,21 +2562,15 @@ function getAes(op) { const aesCbcEncrypt = getAes("encrypt"); const aesCbcDecrypt = getAes("decrypt"); async function hmacSha256Sign(key, msg) { - if (!browserCrypto.createHmac) { - const importAlgorithm = { - name: "HMAC", - hash: { - name: "SHA-256" - } - }; - const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); - const sig = await subtle.sign("HMAC", cryptoKey, msg); - const result = Buffer.from(new Uint8Array(sig)); - return result; - } - const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); - hmac.update(msg); - const result = hmac.digest(); + const importAlgorithm = { + name: "HMAC", + hash: { + name: "SHA-256" + } + }; + const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); + const sig = await subtle.sign("HMAC", cryptoKey, msg); + const result = Buffer.from(new Uint8Array(sig)); return result; } async function hmacSha256Verify(key, msg, sig) { @@ -2767,7 +2728,7 @@ exports.sign = sign; exports.verify = verify; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":56,"elliptic":376}],28:[function(require,module,exports){ +},{"buffer":56,"elliptic":370}],28:[function(require,module,exports){ 'use strict'; var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); @@ -2776,9 +2737,6 @@ var logLevel = require('loglevel'); const log = logLevel.getLogger("http-helpers"); log.setLevel(logLevel.levels.INFO); - -// eslint-disable-next-line @typescript-eslint/no-empty-object-type - let apiKey = "torus-default"; let embedHost = ""; @@ -2821,9 +2779,7 @@ async function fetchAndTrace(url, init) { let _url = null; try { _url = new URL(url); - } catch { - // ignore - } + } catch (error) {} if (sentry && _url && (tracingOrigins.includes(_url.origin) || tracingPaths.includes(_url.pathname))) { const result = await sentry.startSpan({ name: url, @@ -2887,7 +2843,7 @@ const get = async (url, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2926,7 +2882,7 @@ const post = (url, data = {}, options_ = {}, customOptions = {}) => { } if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2965,7 +2921,7 @@ const patch = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -3003,7 +2959,7 @@ const put = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -3039,7 +2995,7 @@ const remove = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -3078,7 +3034,7 @@ exports.setAPIKey = setAPIKey; exports.setEmbedHost = setEmbedHost; exports.setLogLevel = setLogLevel; -},{"@babel/runtime/helpers/objectSpread2":15,"deepmerge":372,"loglevel":479}],29:[function(require,module,exports){ +},{"@babel/runtime/helpers/objectSpread2":15,"deepmerge":367,"loglevel":468}],29:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -3092,8 +3048,8 @@ class MetadataStorageLayer { // ms constructor(metadataHost = "https://metadata.tor.us", serverTimeOffset = 0) { - _defineProperty(this, "metadataHost", undefined); - _defineProperty(this, "serverTimeOffset", undefined); + _defineProperty(this, "metadataHost", void 0); + _defineProperty(this, "serverTimeOffset", void 0); this.metadataHost = metadataHost; this.serverTimeOffset = serverTimeOffset; } @@ -3115,7 +3071,7 @@ class MetadataStorageLayer { pub_key_X: key.getPublic().getX().toString(16, 64), pub_key_Y: key.getPublic().getY().toString(16, 64), set_data: setData, - signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === undefined ? undefined : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== undefined ? _sig$recoveryParam$to : "00"), "hex").toString("base64") + signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === void 0 ? void 0 : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== void 0 ? _sig$recoveryParam$to : "00"), "hex").toString("base64") }; } generatePubKeyParams(privateKeyHex) { @@ -3148,7 +3104,7 @@ class MetadataStorageLayer { exports.MetadataStorageLayer = MetadataStorageLayer; }).call(this)}).call(this,require("buffer").Buffer) -},{"./utils.js":31,"@babel/runtime/helpers/defineProperty":14,"@babel/runtime/helpers/objectSpread2":15,"@toruslabs/http-helpers":28,"buffer":56,"json-stable-stringify":475}],30:[function(require,module,exports){ +},{"./utils.js":31,"@babel/runtime/helpers/defineProperty":14,"@babel/runtime/helpers/objectSpread2":15,"@toruslabs/http-helpers":28,"buffer":56,"json-stable-stringify":464}],30:[function(require,module,exports){ 'use strict'; var MetadataStorageLayer = require('./MetadataStorageLayer.js'); @@ -3187,7 +3143,7 @@ exports.ec = ec; exports.keccak256 = keccak256; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":56,"elliptic":376,"ethereum-cryptography/keccak":424}],32:[function(require,module,exports){ +},{"buffer":56,"elliptic":370,"ethereum-cryptography/keccak":416}],32:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -3307,7 +3263,7 @@ exports.setTorusShare = setTorusShare; },{"./utils.js":31,"@toruslabs/eccrypto":27,"buffer":56}],33:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true); var isArrayBuffer = require('is-array-buffer'); @@ -3320,7 +3276,7 @@ module.exports = function byteLength(ab) { return $byteLength ? $byteLength(ab) : ab.byteLength; }; // in node < 0.11, byteLength is an own nonconfigurable property -},{"call-bound":65,"is-array-buffer":459}],34:[function(require,module,exports){ +},{"call-bind/callBound":57,"is-array-buffer":448}],34:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3385,7 +3341,7 @@ Object.defineProperty(exports, "__esModule", { exports["default"] = void 0; var _clone = _interopRequireDefault(require("clone")); var _default = exports["default"] = _clone["default"]; -},{"@babel/runtime/helpers/interopRequireDefault":51,"clone":66}],36:[function(require,module,exports){ +},{"@babel/runtime/helpers/interopRequireDefault":51,"clone":59}],36:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3395,7 +3351,7 @@ Object.defineProperty(exports, "__esModule", { exports["default"] = void 0; var _deepEqual = _interopRequireDefault(require("deep-equal")); var _default = exports["default"] = _deepEqual["default"]; -},{"@babel/runtime/helpers/interopRequireDefault":51,"deep-equal":371}],37:[function(require,module,exports){ +},{"@babel/runtime/helpers/interopRequireDefault":51,"deep-equal":366}],37:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3565,7 +3521,7 @@ function performanceNow() { } else perf = window.performance; return perf.now(); } -},{"./require-on-node-only":55,"@babel/runtime/helpers/interopRequireDefault":51,"is-node":465}],40:[function(require,module,exports){ +},{"./require-on-node-only":55,"@babel/runtime/helpers/interopRequireDefault":51,"is-node":454}],40:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3857,7 +3813,7 @@ module.exports = function availableTypedArrays() { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"possible-typed-array-names":505}],53:[function(require,module,exports){ +},{"possible-typed-array-names":486}],53:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -5859,66 +5815,7 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":53,"buffer":56,"ieee754":455}],57:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); - -var $apply = require('./functionApply'); -var $call = require('./functionCall'); -var $reflectApply = require('./reflectApply'); - -/** @type {import('./actualApply')} */ -module.exports = $reflectApply || bind.call($call, $apply); - -},{"./functionApply":59,"./functionCall":60,"./reflectApply":62,"function-bind":428}],58:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $apply = require('./functionApply'); -var actualApply = require('./actualApply'); - -/** @type {import('./applyBind')} */ -module.exports = function applyBind() { - return actualApply(bind, $apply, arguments); -}; - -},{"./actualApply":57,"./functionApply":59,"function-bind":428}],59:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionApply')} */ -module.exports = Function.prototype.apply; - -},{}],60:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionCall')} */ -module.exports = Function.prototype.call; - -},{}],61:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $TypeError = require('es-errors/type'); - -var $call = require('./functionCall'); -var $actualApply = require('./actualApply'); - -/** @type {import('.')} */ -module.exports = function callBindBasic(args) { - if (args.length < 1 || typeof args[0] !== 'function') { - throw new $TypeError('a function is required'); - } - return $actualApply(bind, $call, args); -}; - -},{"./actualApply":57,"./functionCall":60,"es-errors/type":420,"function-bind":428}],62:[function(require,module,exports){ -'use strict'; - -/** @type {import('./reflectApply')} */ -module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply; - -},{}],63:[function(require,module,exports){ +},{"base64-js":53,"buffer":56,"ieee754":444}],57:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -5935,53 +5832,44 @@ module.exports = function callBoundIntrinsic(name, allowMissing) { return intrinsic; }; -},{"./":64,"get-intrinsic":430}],64:[function(require,module,exports){ +},{"./":58,"get-intrinsic":422}],58:[function(require,module,exports){ 'use strict'; +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); var setFunctionLength = require('set-function-length'); -var $defineProperty = require('es-define-property'); +var $TypeError = require('es-errors/type'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); -var callBindBasic = require('call-bind-apply-helpers'); -var applyBind = require('call-bind-apply-helpers/applyBind'); +var $defineProperty = require('es-define-property'); +var $max = GetIntrinsic('%Math.max%'); module.exports = function callBind(originalFunction) { - var func = callBindBasic(arguments); - var adjustedLength = originalFunction.length - (arguments.length - 1); + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); return setFunctionLength( func, - 1 + (adjustedLength > 0 ? adjustedLength : 0), + 1 + $max(0, originalFunction.length - (arguments.length - 1)), true ); }; +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + if ($defineProperty) { $defineProperty(module.exports, 'apply', { value: applyBind }); } else { module.exports.apply = applyBind; } -},{"call-bind-apply-helpers":61,"call-bind-apply-helpers/applyBind":58,"es-define-property":414,"set-function-length":513}],65:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); - -var callBindBasic = require('call-bind-apply-helpers'); - -/** @type {(thisArg: string, searchString: string, position?: number) => number} */ -var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]); - -/** @type {import('.')} */ -module.exports = function callBoundIntrinsic(name, allowMissing) { - // eslint-disable-next-line no-extra-parens - var intrinsic = /** @type {Parameters[0][0]} */ (GetIntrinsic(name, !!allowMissing)); - if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { - return callBindBasic([intrinsic]); - } - return intrinsic; -}; - -},{"call-bind-apply-helpers":61,"get-intrinsic":430}],66:[function(require,module,exports){ +},{"es-define-property":407,"es-errors/type":413,"function-bind":420,"get-intrinsic":422,"set-function-length":493}],59:[function(require,module,exports){ (function (Buffer){(function (){ var clone = (function() { 'use strict'; @@ -6242,7 +6130,7 @@ if (typeof module === 'object' && module.exports) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":56}],67:[function(require,module,exports){ +},{"buffer":56}],60:[function(require,module,exports){ require('../modules/es6.symbol'); require('../modules/es6.object.create'); require('../modules/es6.object.define-property'); @@ -6383,74 +6271,74 @@ require('../modules/es6.reflect.set'); require('../modules/es6.reflect.set-prototype-of'); module.exports = require('../modules/_core'); -},{"../modules/_core":116,"../modules/es6.array.copy-within":218,"../modules/es6.array.every":219,"../modules/es6.array.fill":220,"../modules/es6.array.filter":221,"../modules/es6.array.find":223,"../modules/es6.array.find-index":222,"../modules/es6.array.for-each":224,"../modules/es6.array.from":225,"../modules/es6.array.index-of":226,"../modules/es6.array.is-array":227,"../modules/es6.array.iterator":228,"../modules/es6.array.join":229,"../modules/es6.array.last-index-of":230,"../modules/es6.array.map":231,"../modules/es6.array.of":232,"../modules/es6.array.reduce":234,"../modules/es6.array.reduce-right":233,"../modules/es6.array.slice":235,"../modules/es6.array.some":236,"../modules/es6.array.sort":237,"../modules/es6.array.species":238,"../modules/es6.date.now":239,"../modules/es6.date.to-iso-string":240,"../modules/es6.date.to-json":241,"../modules/es6.date.to-primitive":242,"../modules/es6.date.to-string":243,"../modules/es6.function.bind":244,"../modules/es6.function.has-instance":245,"../modules/es6.function.name":246,"../modules/es6.map":247,"../modules/es6.math.acosh":248,"../modules/es6.math.asinh":249,"../modules/es6.math.atanh":250,"../modules/es6.math.cbrt":251,"../modules/es6.math.clz32":252,"../modules/es6.math.cosh":253,"../modules/es6.math.expm1":254,"../modules/es6.math.fround":255,"../modules/es6.math.hypot":256,"../modules/es6.math.imul":257,"../modules/es6.math.log10":258,"../modules/es6.math.log1p":259,"../modules/es6.math.log2":260,"../modules/es6.math.sign":261,"../modules/es6.math.sinh":262,"../modules/es6.math.tanh":263,"../modules/es6.math.trunc":264,"../modules/es6.number.constructor":265,"../modules/es6.number.epsilon":266,"../modules/es6.number.is-finite":267,"../modules/es6.number.is-integer":268,"../modules/es6.number.is-nan":269,"../modules/es6.number.is-safe-integer":270,"../modules/es6.number.max-safe-integer":271,"../modules/es6.number.min-safe-integer":272,"../modules/es6.number.parse-float":273,"../modules/es6.number.parse-int":274,"../modules/es6.number.to-fixed":275,"../modules/es6.number.to-precision":276,"../modules/es6.object.assign":277,"../modules/es6.object.create":278,"../modules/es6.object.define-properties":279,"../modules/es6.object.define-property":280,"../modules/es6.object.freeze":281,"../modules/es6.object.get-own-property-descriptor":282,"../modules/es6.object.get-own-property-names":283,"../modules/es6.object.get-prototype-of":284,"../modules/es6.object.is":288,"../modules/es6.object.is-extensible":285,"../modules/es6.object.is-frozen":286,"../modules/es6.object.is-sealed":287,"../modules/es6.object.keys":289,"../modules/es6.object.prevent-extensions":290,"../modules/es6.object.seal":291,"../modules/es6.object.set-prototype-of":292,"../modules/es6.object.to-string":293,"../modules/es6.parse-float":294,"../modules/es6.parse-int":295,"../modules/es6.promise":296,"../modules/es6.reflect.apply":297,"../modules/es6.reflect.construct":298,"../modules/es6.reflect.define-property":299,"../modules/es6.reflect.delete-property":300,"../modules/es6.reflect.enumerate":301,"../modules/es6.reflect.get":304,"../modules/es6.reflect.get-own-property-descriptor":302,"../modules/es6.reflect.get-prototype-of":303,"../modules/es6.reflect.has":305,"../modules/es6.reflect.is-extensible":306,"../modules/es6.reflect.own-keys":307,"../modules/es6.reflect.prevent-extensions":308,"../modules/es6.reflect.set":310,"../modules/es6.reflect.set-prototype-of":309,"../modules/es6.regexp.constructor":311,"../modules/es6.regexp.exec":312,"../modules/es6.regexp.flags":313,"../modules/es6.regexp.match":314,"../modules/es6.regexp.replace":315,"../modules/es6.regexp.search":316,"../modules/es6.regexp.split":317,"../modules/es6.regexp.to-string":318,"../modules/es6.set":319,"../modules/es6.string.anchor":320,"../modules/es6.string.big":321,"../modules/es6.string.blink":322,"../modules/es6.string.bold":323,"../modules/es6.string.code-point-at":324,"../modules/es6.string.ends-with":325,"../modules/es6.string.fixed":326,"../modules/es6.string.fontcolor":327,"../modules/es6.string.fontsize":328,"../modules/es6.string.from-code-point":329,"../modules/es6.string.includes":330,"../modules/es6.string.italics":331,"../modules/es6.string.iterator":332,"../modules/es6.string.link":333,"../modules/es6.string.raw":334,"../modules/es6.string.repeat":335,"../modules/es6.string.small":336,"../modules/es6.string.starts-with":337,"../modules/es6.string.strike":338,"../modules/es6.string.sub":339,"../modules/es6.string.sup":340,"../modules/es6.string.trim":341,"../modules/es6.symbol":342,"../modules/es6.typed.array-buffer":343,"../modules/es6.typed.data-view":344,"../modules/es6.typed.float32-array":345,"../modules/es6.typed.float64-array":346,"../modules/es6.typed.int16-array":347,"../modules/es6.typed.int32-array":348,"../modules/es6.typed.int8-array":349,"../modules/es6.typed.uint16-array":350,"../modules/es6.typed.uint32-array":351,"../modules/es6.typed.uint8-array":352,"../modules/es6.typed.uint8-clamped-array":353,"../modules/es6.weak-map":354,"../modules/es6.weak-set":355}],68:[function(require,module,exports){ +},{"../modules/_core":109,"../modules/es6.array.copy-within":211,"../modules/es6.array.every":212,"../modules/es6.array.fill":213,"../modules/es6.array.filter":214,"../modules/es6.array.find":216,"../modules/es6.array.find-index":215,"../modules/es6.array.for-each":217,"../modules/es6.array.from":218,"../modules/es6.array.index-of":219,"../modules/es6.array.is-array":220,"../modules/es6.array.iterator":221,"../modules/es6.array.join":222,"../modules/es6.array.last-index-of":223,"../modules/es6.array.map":224,"../modules/es6.array.of":225,"../modules/es6.array.reduce":227,"../modules/es6.array.reduce-right":226,"../modules/es6.array.slice":228,"../modules/es6.array.some":229,"../modules/es6.array.sort":230,"../modules/es6.array.species":231,"../modules/es6.date.now":232,"../modules/es6.date.to-iso-string":233,"../modules/es6.date.to-json":234,"../modules/es6.date.to-primitive":235,"../modules/es6.date.to-string":236,"../modules/es6.function.bind":237,"../modules/es6.function.has-instance":238,"../modules/es6.function.name":239,"../modules/es6.map":240,"../modules/es6.math.acosh":241,"../modules/es6.math.asinh":242,"../modules/es6.math.atanh":243,"../modules/es6.math.cbrt":244,"../modules/es6.math.clz32":245,"../modules/es6.math.cosh":246,"../modules/es6.math.expm1":247,"../modules/es6.math.fround":248,"../modules/es6.math.hypot":249,"../modules/es6.math.imul":250,"../modules/es6.math.log10":251,"../modules/es6.math.log1p":252,"../modules/es6.math.log2":253,"../modules/es6.math.sign":254,"../modules/es6.math.sinh":255,"../modules/es6.math.tanh":256,"../modules/es6.math.trunc":257,"../modules/es6.number.constructor":258,"../modules/es6.number.epsilon":259,"../modules/es6.number.is-finite":260,"../modules/es6.number.is-integer":261,"../modules/es6.number.is-nan":262,"../modules/es6.number.is-safe-integer":263,"../modules/es6.number.max-safe-integer":264,"../modules/es6.number.min-safe-integer":265,"../modules/es6.number.parse-float":266,"../modules/es6.number.parse-int":267,"../modules/es6.number.to-fixed":268,"../modules/es6.number.to-precision":269,"../modules/es6.object.assign":270,"../modules/es6.object.create":271,"../modules/es6.object.define-properties":272,"../modules/es6.object.define-property":273,"../modules/es6.object.freeze":274,"../modules/es6.object.get-own-property-descriptor":275,"../modules/es6.object.get-own-property-names":276,"../modules/es6.object.get-prototype-of":277,"../modules/es6.object.is":281,"../modules/es6.object.is-extensible":278,"../modules/es6.object.is-frozen":279,"../modules/es6.object.is-sealed":280,"../modules/es6.object.keys":282,"../modules/es6.object.prevent-extensions":283,"../modules/es6.object.seal":284,"../modules/es6.object.set-prototype-of":285,"../modules/es6.object.to-string":286,"../modules/es6.parse-float":287,"../modules/es6.parse-int":288,"../modules/es6.promise":289,"../modules/es6.reflect.apply":290,"../modules/es6.reflect.construct":291,"../modules/es6.reflect.define-property":292,"../modules/es6.reflect.delete-property":293,"../modules/es6.reflect.enumerate":294,"../modules/es6.reflect.get":297,"../modules/es6.reflect.get-own-property-descriptor":295,"../modules/es6.reflect.get-prototype-of":296,"../modules/es6.reflect.has":298,"../modules/es6.reflect.is-extensible":299,"../modules/es6.reflect.own-keys":300,"../modules/es6.reflect.prevent-extensions":301,"../modules/es6.reflect.set":303,"../modules/es6.reflect.set-prototype-of":302,"../modules/es6.regexp.constructor":304,"../modules/es6.regexp.exec":305,"../modules/es6.regexp.flags":306,"../modules/es6.regexp.match":307,"../modules/es6.regexp.replace":308,"../modules/es6.regexp.search":309,"../modules/es6.regexp.split":310,"../modules/es6.regexp.to-string":311,"../modules/es6.set":312,"../modules/es6.string.anchor":313,"../modules/es6.string.big":314,"../modules/es6.string.blink":315,"../modules/es6.string.bold":316,"../modules/es6.string.code-point-at":317,"../modules/es6.string.ends-with":318,"../modules/es6.string.fixed":319,"../modules/es6.string.fontcolor":320,"../modules/es6.string.fontsize":321,"../modules/es6.string.from-code-point":322,"../modules/es6.string.includes":323,"../modules/es6.string.italics":324,"../modules/es6.string.iterator":325,"../modules/es6.string.link":326,"../modules/es6.string.raw":327,"../modules/es6.string.repeat":328,"../modules/es6.string.small":329,"../modules/es6.string.starts-with":330,"../modules/es6.string.strike":331,"../modules/es6.string.sub":332,"../modules/es6.string.sup":333,"../modules/es6.string.trim":334,"../modules/es6.symbol":335,"../modules/es6.typed.array-buffer":336,"../modules/es6.typed.data-view":337,"../modules/es6.typed.float32-array":338,"../modules/es6.typed.float64-array":339,"../modules/es6.typed.int16-array":340,"../modules/es6.typed.int32-array":341,"../modules/es6.typed.int8-array":342,"../modules/es6.typed.uint16-array":343,"../modules/es6.typed.uint32-array":344,"../modules/es6.typed.uint8-array":345,"../modules/es6.typed.uint8-clamped-array":346,"../modules/es6.weak-map":347,"../modules/es6.weak-set":348}],61:[function(require,module,exports){ require('../../modules/es7.array.flat-map'); module.exports = require('../../modules/_core').Array.flatMap; -},{"../../modules/_core":116,"../../modules/es7.array.flat-map":356}],69:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.array.flat-map":349}],62:[function(require,module,exports){ require('../../modules/es7.array.includes'); module.exports = require('../../modules/_core').Array.includes; -},{"../../modules/_core":116,"../../modules/es7.array.includes":357}],70:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.array.includes":350}],63:[function(require,module,exports){ require('../../modules/es7.object.entries'); module.exports = require('../../modules/_core').Object.entries; -},{"../../modules/_core":116,"../../modules/es7.object.entries":358}],71:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.object.entries":351}],64:[function(require,module,exports){ require('../../modules/es7.object.get-own-property-descriptors'); module.exports = require('../../modules/_core').Object.getOwnPropertyDescriptors; -},{"../../modules/_core":116,"../../modules/es7.object.get-own-property-descriptors":359}],72:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.object.get-own-property-descriptors":352}],65:[function(require,module,exports){ require('../../modules/es7.object.values'); module.exports = require('../../modules/_core').Object.values; -},{"../../modules/_core":116,"../../modules/es7.object.values":360}],73:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.object.values":353}],66:[function(require,module,exports){ 'use strict'; require('../../modules/es6.promise'); require('../../modules/es7.promise.finally'); module.exports = require('../../modules/_core').Promise['finally']; -},{"../../modules/_core":116,"../../modules/es6.promise":296,"../../modules/es7.promise.finally":361}],74:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es6.promise":289,"../../modules/es7.promise.finally":354}],67:[function(require,module,exports){ require('../../modules/es7.string.pad-end'); module.exports = require('../../modules/_core').String.padEnd; -},{"../../modules/_core":116,"../../modules/es7.string.pad-end":362}],75:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.string.pad-end":355}],68:[function(require,module,exports){ require('../../modules/es7.string.pad-start'); module.exports = require('../../modules/_core').String.padStart; -},{"../../modules/_core":116,"../../modules/es7.string.pad-start":363}],76:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.string.pad-start":356}],69:[function(require,module,exports){ require('../../modules/es7.string.trim-right'); module.exports = require('../../modules/_core').String.trimRight; -},{"../../modules/_core":116,"../../modules/es7.string.trim-right":365}],77:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.string.trim-right":358}],70:[function(require,module,exports){ require('../../modules/es7.string.trim-left'); module.exports = require('../../modules/_core').String.trimLeft; -},{"../../modules/_core":116,"../../modules/es7.string.trim-left":364}],78:[function(require,module,exports){ +},{"../../modules/_core":109,"../../modules/es7.string.trim-left":357}],71:[function(require,module,exports){ require('../../modules/es7.symbol.async-iterator'); module.exports = require('../../modules/_wks-ext').f('asyncIterator'); -},{"../../modules/_wks-ext":215,"../../modules/es7.symbol.async-iterator":366}],79:[function(require,module,exports){ +},{"../../modules/_wks-ext":208,"../../modules/es7.symbol.async-iterator":359}],72:[function(require,module,exports){ require('../modules/es7.global'); module.exports = require('../modules/_core').global; -},{"../modules/_core":82,"../modules/es7.global":96}],80:[function(require,module,exports){ +},{"../modules/_core":75,"../modules/es7.global":89}],73:[function(require,module,exports){ module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; -},{}],81:[function(require,module,exports){ +},{}],74:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; -},{"./_is-object":92}],82:[function(require,module,exports){ +},{"./_is-object":85}],75:[function(require,module,exports){ var core = module.exports = { version: '2.6.12' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -},{}],83:[function(require,module,exports){ +},{}],76:[function(require,module,exports){ // optional / simple context binding var aFunction = require('./_a-function'); module.exports = function (fn, that, length) { @@ -6472,13 +6360,13 @@ module.exports = function (fn, that, length) { }; }; -},{"./_a-function":80}],84:[function(require,module,exports){ +},{"./_a-function":73}],77:[function(require,module,exports){ // Thank's IE8 for his funny defineProperty module.exports = !require('./_fails')(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_fails":87}],85:[function(require,module,exports){ +},{"./_fails":80}],78:[function(require,module,exports){ var isObject = require('./_is-object'); var document = require('./_global').document; // typeof document.createElement is 'object' in old IE @@ -6487,7 +6375,7 @@ module.exports = function (it) { return is ? document.createElement(it) : {}; }; -},{"./_global":88,"./_is-object":92}],86:[function(require,module,exports){ +},{"./_global":81,"./_is-object":85}],79:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var ctx = require('./_ctx'); @@ -6551,7 +6439,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":82,"./_ctx":83,"./_global":88,"./_has":89,"./_hide":90}],87:[function(require,module,exports){ +},{"./_core":75,"./_ctx":76,"./_global":81,"./_has":82,"./_hide":83}],80:[function(require,module,exports){ module.exports = function (exec) { try { return !!exec(); @@ -6560,7 +6448,7 @@ module.exports = function (exec) { } }; -},{}],88:[function(require,module,exports){ +},{}],81:[function(require,module,exports){ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self @@ -6568,13 +6456,13 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -},{}],89:[function(require,module,exports){ +},{}],82:[function(require,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; -},{}],90:[function(require,module,exports){ +},{}],83:[function(require,module,exports){ var dP = require('./_object-dp'); var createDesc = require('./_property-desc'); module.exports = require('./_descriptors') ? function (object, key, value) { @@ -6584,17 +6472,17 @@ module.exports = require('./_descriptors') ? function (object, key, value) { return object; }; -},{"./_descriptors":84,"./_object-dp":93,"./_property-desc":94}],91:[function(require,module,exports){ +},{"./_descriptors":77,"./_object-dp":86,"./_property-desc":87}],84:[function(require,module,exports){ module.exports = !require('./_descriptors') && !require('./_fails')(function () { return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_descriptors":84,"./_dom-create":85,"./_fails":87}],92:[function(require,module,exports){ +},{"./_descriptors":77,"./_dom-create":78,"./_fails":80}],85:[function(require,module,exports){ module.exports = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -},{}],93:[function(require,module,exports){ +},{}],86:[function(require,module,exports){ var anObject = require('./_an-object'); var IE8_DOM_DEFINE = require('./_ie8-dom-define'); var toPrimitive = require('./_to-primitive'); @@ -6612,7 +6500,7 @@ exports.f = require('./_descriptors') ? Object.defineProperty : function defineP return O; }; -},{"./_an-object":81,"./_descriptors":84,"./_ie8-dom-define":91,"./_to-primitive":95}],94:[function(require,module,exports){ +},{"./_an-object":74,"./_descriptors":77,"./_ie8-dom-define":84,"./_to-primitive":88}],87:[function(require,module,exports){ module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -6622,7 +6510,7 @@ module.exports = function (bitmap, value) { }; }; -},{}],95:[function(require,module,exports){ +},{}],88:[function(require,module,exports){ // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = require('./_is-object'); // instead of the ES6 spec version, we didn't implement @@toPrimitive case @@ -6636,22 +6524,22 @@ module.exports = function (it, S) { throw TypeError("Can't convert object to primitive value"); }; -},{"./_is-object":92}],96:[function(require,module,exports){ +},{"./_is-object":85}],89:[function(require,module,exports){ // https://github.com/tc39/proposal-global var $export = require('./_export'); $export($export.G, { global: require('./_global') }); -},{"./_export":86,"./_global":88}],97:[function(require,module,exports){ -arguments[4][80][0].apply(exports,arguments) -},{"dup":80}],98:[function(require,module,exports){ +},{"./_export":79,"./_global":81}],90:[function(require,module,exports){ +arguments[4][73][0].apply(exports,arguments) +},{"dup":73}],91:[function(require,module,exports){ var cof = require('./_cof'); module.exports = function (it, msg) { if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg); return +it; }; -},{"./_cof":112}],99:[function(require,module,exports){ +},{"./_cof":105}],92:[function(require,module,exports){ // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = require('./_wks')('unscopables'); var ArrayProto = Array.prototype; @@ -6660,7 +6548,7 @@ module.exports = function (key) { ArrayProto[UNSCOPABLES][key] = true; }; -},{"./_hide":136,"./_wks":216}],100:[function(require,module,exports){ +},{"./_hide":129,"./_wks":209}],93:[function(require,module,exports){ 'use strict'; var at = require('./_string-at')(true); @@ -6670,16 +6558,16 @@ module.exports = function (S, index, unicode) { return index + (unicode ? at(S, index).length : 1); }; -},{"./_string-at":193}],101:[function(require,module,exports){ +},{"./_string-at":186}],94:[function(require,module,exports){ module.exports = function (it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { throw TypeError(name + ': incorrect invocation!'); } return it; }; -},{}],102:[function(require,module,exports){ -arguments[4][81][0].apply(exports,arguments) -},{"./_is-object":145,"dup":81}],103:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ +arguments[4][74][0].apply(exports,arguments) +},{"./_is-object":138,"dup":74}],96:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -6707,7 +6595,7 @@ module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* } return O; }; -},{"./_to-absolute-index":201,"./_to-length":205,"./_to-object":206}],104:[function(require,module,exports){ +},{"./_to-absolute-index":194,"./_to-length":198,"./_to-object":199}],97:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -6724,7 +6612,7 @@ module.exports = function fill(value /* , start = 0, end = @length */) { return O; }; -},{"./_to-absolute-index":201,"./_to-length":205,"./_to-object":206}],105:[function(require,module,exports){ +},{"./_to-absolute-index":194,"./_to-length":198,"./_to-object":199}],98:[function(require,module,exports){ // false -> Array#indexOf // true -> Array#includes var toIObject = require('./_to-iobject'); @@ -6749,7 +6637,7 @@ module.exports = function (IS_INCLUDES) { }; }; -},{"./_to-absolute-index":201,"./_to-iobject":204,"./_to-length":205}],106:[function(require,module,exports){ +},{"./_to-absolute-index":194,"./_to-iobject":197,"./_to-length":198}],99:[function(require,module,exports){ // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter @@ -6795,7 +6683,7 @@ module.exports = function (TYPE, $create) { }; }; -},{"./_array-species-create":109,"./_ctx":118,"./_iobject":141,"./_to-length":205,"./_to-object":206}],107:[function(require,module,exports){ +},{"./_array-species-create":102,"./_ctx":111,"./_iobject":134,"./_to-length":198,"./_to-object":199}],100:[function(require,module,exports){ var aFunction = require('./_a-function'); var toObject = require('./_to-object'); var IObject = require('./_iobject'); @@ -6825,7 +6713,7 @@ module.exports = function (that, callbackfn, aLen, memo, isRight) { return memo; }; -},{"./_a-function":97,"./_iobject":141,"./_to-length":205,"./_to-object":206}],108:[function(require,module,exports){ +},{"./_a-function":90,"./_iobject":134,"./_to-length":198,"./_to-object":199}],101:[function(require,module,exports){ var isObject = require('./_is-object'); var isArray = require('./_is-array'); var SPECIES = require('./_wks')('species'); @@ -6843,7 +6731,7 @@ module.exports = function (original) { } return C === undefined ? Array : C; }; -},{"./_is-array":143,"./_is-object":145,"./_wks":216}],109:[function(require,module,exports){ +},{"./_is-array":136,"./_is-object":138,"./_wks":209}],102:[function(require,module,exports){ // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var speciesConstructor = require('./_array-species-constructor'); @@ -6851,7 +6739,7 @@ module.exports = function (original, length) { return new (speciesConstructor(original))(length); }; -},{"./_array-species-constructor":108}],110:[function(require,module,exports){ +},{"./_array-species-constructor":101}],103:[function(require,module,exports){ 'use strict'; var aFunction = require('./_a-function'); var isObject = require('./_is-object'); @@ -6878,7 +6766,7 @@ module.exports = Function.bind || function bind(that /* , ...args */) { return bound; }; -},{"./_a-function":97,"./_invoke":140,"./_is-object":145}],111:[function(require,module,exports){ +},{"./_a-function":90,"./_invoke":133,"./_is-object":138}],104:[function(require,module,exports){ // getting tag from 19.1.3.6 Object.prototype.toString() var cof = require('./_cof'); var TAG = require('./_wks')('toStringTag'); @@ -6903,14 +6791,14 @@ module.exports = function (it) { : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; -},{"./_cof":112,"./_wks":216}],112:[function(require,module,exports){ +},{"./_cof":105,"./_wks":209}],105:[function(require,module,exports){ var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; -},{}],113:[function(require,module,exports){ +},{}],106:[function(require,module,exports){ 'use strict'; var dP = require('./_object-dp').f; var create = require('./_object-create'); @@ -7056,7 +6944,7 @@ module.exports = { } }; -},{"./_an-instance":101,"./_ctx":118,"./_descriptors":122,"./_for-of":132,"./_iter-define":149,"./_iter-step":151,"./_meta":158,"./_object-create":162,"./_object-dp":163,"./_redefine-all":181,"./_set-species":187,"./_validate-collection":213}],114:[function(require,module,exports){ +},{"./_an-instance":94,"./_ctx":111,"./_descriptors":115,"./_for-of":125,"./_iter-define":142,"./_iter-step":144,"./_meta":151,"./_object-create":155,"./_object-dp":156,"./_redefine-all":174,"./_set-species":180,"./_validate-collection":206}],107:[function(require,module,exports){ 'use strict'; var redefineAll = require('./_redefine-all'); var getWeak = require('./_meta').getWeak; @@ -7143,7 +7031,7 @@ module.exports = { ufstore: uncaughtFrozenStore }; -},{"./_an-instance":101,"./_an-object":102,"./_array-methods":106,"./_for-of":132,"./_has":135,"./_is-object":145,"./_meta":158,"./_redefine-all":181,"./_validate-collection":213}],115:[function(require,module,exports){ +},{"./_an-instance":94,"./_an-object":95,"./_array-methods":99,"./_for-of":125,"./_has":128,"./_is-object":138,"./_meta":151,"./_redefine-all":174,"./_validate-collection":206}],108:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var $export = require('./_export'); @@ -7230,9 +7118,9 @@ module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { return C; }; -},{"./_an-instance":101,"./_export":126,"./_fails":128,"./_for-of":132,"./_global":134,"./_inherit-if-required":139,"./_is-object":145,"./_iter-detect":150,"./_meta":158,"./_redefine":182,"./_redefine-all":181,"./_set-to-string-tag":188}],116:[function(require,module,exports){ -arguments[4][82][0].apply(exports,arguments) -},{"dup":82}],117:[function(require,module,exports){ +},{"./_an-instance":94,"./_export":119,"./_fails":121,"./_for-of":125,"./_global":127,"./_inherit-if-required":132,"./_is-object":138,"./_iter-detect":143,"./_meta":151,"./_redefine":175,"./_redefine-all":174,"./_set-to-string-tag":181}],109:[function(require,module,exports){ +arguments[4][75][0].apply(exports,arguments) +},{"dup":75}],110:[function(require,module,exports){ 'use strict'; var $defineProperty = require('./_object-dp'); var createDesc = require('./_property-desc'); @@ -7242,9 +7130,9 @@ module.exports = function (object, index, value) { else object[index] = value; }; -},{"./_object-dp":163,"./_property-desc":180}],118:[function(require,module,exports){ -arguments[4][83][0].apply(exports,arguments) -},{"./_a-function":97,"dup":83}],119:[function(require,module,exports){ +},{"./_object-dp":156,"./_property-desc":173}],111:[function(require,module,exports){ +arguments[4][76][0].apply(exports,arguments) +},{"./_a-function":90,"dup":76}],112:[function(require,module,exports){ 'use strict'; // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var fails = require('./_fails'); @@ -7272,7 +7160,7 @@ module.exports = (fails(function () { ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; } : $toISOString; -},{"./_fails":128}],120:[function(require,module,exports){ +},{"./_fails":121}],113:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); var toPrimitive = require('./_to-primitive'); @@ -7283,24 +7171,24 @@ module.exports = function (hint) { return toPrimitive(anObject(this), hint != NUMBER); }; -},{"./_an-object":102,"./_to-primitive":207}],121:[function(require,module,exports){ +},{"./_an-object":95,"./_to-primitive":200}],114:[function(require,module,exports){ // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; -},{}],122:[function(require,module,exports){ -arguments[4][84][0].apply(exports,arguments) -},{"./_fails":128,"dup":84}],123:[function(require,module,exports){ -arguments[4][85][0].apply(exports,arguments) -},{"./_global":134,"./_is-object":145,"dup":85}],124:[function(require,module,exports){ +},{}],115:[function(require,module,exports){ +arguments[4][77][0].apply(exports,arguments) +},{"./_fails":121,"dup":77}],116:[function(require,module,exports){ +arguments[4][78][0].apply(exports,arguments) +},{"./_global":127,"./_is-object":138,"dup":78}],117:[function(require,module,exports){ // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); -},{}],125:[function(require,module,exports){ +},{}],118:[function(require,module,exports){ // all enumerable object keys, includes symbols var getKeys = require('./_object-keys'); var gOPS = require('./_object-gops'); @@ -7317,7 +7205,7 @@ module.exports = function (it) { } return result; }; -},{"./_object-gops":168,"./_object-keys":171,"./_object-pie":172}],126:[function(require,module,exports){ +},{"./_object-gops":161,"./_object-keys":164,"./_object-pie":165}],119:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var hide = require('./_hide'); @@ -7362,7 +7250,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":116,"./_ctx":118,"./_global":134,"./_hide":136,"./_redefine":182}],127:[function(require,module,exports){ +},{"./_core":109,"./_ctx":111,"./_global":127,"./_hide":129,"./_redefine":175}],120:[function(require,module,exports){ var MATCH = require('./_wks')('match'); module.exports = function (KEY) { var re = /./; @@ -7376,9 +7264,9 @@ module.exports = function (KEY) { } return true; }; -},{"./_wks":216}],128:[function(require,module,exports){ -arguments[4][87][0].apply(exports,arguments) -},{"dup":87}],129:[function(require,module,exports){ +},{"./_wks":209}],121:[function(require,module,exports){ +arguments[4][80][0].apply(exports,arguments) +},{"dup":80}],122:[function(require,module,exports){ 'use strict'; require('./es6.regexp.exec'); var redefine = require('./_redefine'); @@ -7476,7 +7364,7 @@ module.exports = function (KEY, length, exec) { } }; -},{"./_defined":121,"./_fails":128,"./_hide":136,"./_redefine":182,"./_regexp-exec":184,"./_wks":216,"./es6.regexp.exec":312}],130:[function(require,module,exports){ +},{"./_defined":114,"./_fails":121,"./_hide":129,"./_redefine":175,"./_regexp-exec":177,"./_wks":209,"./es6.regexp.exec":305}],123:[function(require,module,exports){ 'use strict'; // 21.2.5.3 get RegExp.prototype.flags var anObject = require('./_an-object'); @@ -7491,7 +7379,7 @@ module.exports = function () { return result; }; -},{"./_an-object":102}],131:[function(require,module,exports){ +},{"./_an-object":95}],124:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray var isArray = require('./_is-array'); @@ -7532,7 +7420,7 @@ function flattenIntoArray(target, original, source, sourceLen, start, depth, map module.exports = flattenIntoArray; -},{"./_ctx":118,"./_is-array":143,"./_is-object":145,"./_to-length":205,"./_wks":216}],132:[function(require,module,exports){ +},{"./_ctx":111,"./_is-array":136,"./_is-object":138,"./_to-length":198,"./_wks":209}],125:[function(require,module,exports){ var ctx = require('./_ctx'); var call = require('./_iter-call'); var isArrayIter = require('./_is-array-iter'); @@ -7559,22 +7447,22 @@ var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) exports.BREAK = BREAK; exports.RETURN = RETURN; -},{"./_an-object":102,"./_ctx":118,"./_is-array-iter":142,"./_iter-call":147,"./_to-length":205,"./core.get-iterator-method":217}],133:[function(require,module,exports){ +},{"./_an-object":95,"./_ctx":111,"./_is-array-iter":135,"./_iter-call":140,"./_to-length":198,"./core.get-iterator-method":210}],126:[function(require,module,exports){ module.exports = require('./_shared')('native-function-to-string', Function.toString); -},{"./_shared":190}],134:[function(require,module,exports){ -arguments[4][88][0].apply(exports,arguments) -},{"dup":88}],135:[function(require,module,exports){ -arguments[4][89][0].apply(exports,arguments) -},{"dup":89}],136:[function(require,module,exports){ -arguments[4][90][0].apply(exports,arguments) -},{"./_descriptors":122,"./_object-dp":163,"./_property-desc":180,"dup":90}],137:[function(require,module,exports){ +},{"./_shared":183}],127:[function(require,module,exports){ +arguments[4][81][0].apply(exports,arguments) +},{"dup":81}],128:[function(require,module,exports){ +arguments[4][82][0].apply(exports,arguments) +},{"dup":82}],129:[function(require,module,exports){ +arguments[4][83][0].apply(exports,arguments) +},{"./_descriptors":115,"./_object-dp":156,"./_property-desc":173,"dup":83}],130:[function(require,module,exports){ var document = require('./_global').document; module.exports = document && document.documentElement; -},{"./_global":134}],138:[function(require,module,exports){ -arguments[4][91][0].apply(exports,arguments) -},{"./_descriptors":122,"./_dom-create":123,"./_fails":128,"dup":91}],139:[function(require,module,exports){ +},{"./_global":127}],131:[function(require,module,exports){ +arguments[4][84][0].apply(exports,arguments) +},{"./_descriptors":115,"./_dom-create":116,"./_fails":121,"dup":84}],132:[function(require,module,exports){ var isObject = require('./_is-object'); var setPrototypeOf = require('./_set-proto').set; module.exports = function (that, target, C) { @@ -7585,7 +7473,7 @@ module.exports = function (that, target, C) { } return that; }; -},{"./_is-object":145,"./_set-proto":186}],140:[function(require,module,exports){ +},{"./_is-object":138,"./_set-proto":179}],133:[function(require,module,exports){ // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function (fn, args, that) { var un = that === undefined; @@ -7603,7 +7491,7 @@ module.exports = function (fn, args, that) { } return fn.apply(that, args); }; -},{}],141:[function(require,module,exports){ +},{}],134:[function(require,module,exports){ // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = require('./_cof'); // eslint-disable-next-line no-prototype-builtins @@ -7611,7 +7499,7 @@ module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; -},{"./_cof":112}],142:[function(require,module,exports){ +},{"./_cof":105}],135:[function(require,module,exports){ // check on default Array iterator var Iterators = require('./_iterators'); var ITERATOR = require('./_wks')('iterator'); @@ -7621,14 +7509,14 @@ module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; -},{"./_iterators":152,"./_wks":216}],143:[function(require,module,exports){ +},{"./_iterators":145,"./_wks":209}],136:[function(require,module,exports){ // 7.2.2 IsArray(argument) var cof = require('./_cof'); module.exports = Array.isArray || function isArray(arg) { return cof(arg) == 'Array'; }; -},{"./_cof":112}],144:[function(require,module,exports){ +},{"./_cof":105}],137:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var isObject = require('./_is-object'); var floor = Math.floor; @@ -7636,9 +7524,9 @@ module.exports = function isInteger(it) { return !isObject(it) && isFinite(it) && floor(it) === it; }; -},{"./_is-object":145}],145:[function(require,module,exports){ -arguments[4][92][0].apply(exports,arguments) -},{"dup":92}],146:[function(require,module,exports){ +},{"./_is-object":138}],138:[function(require,module,exports){ +arguments[4][85][0].apply(exports,arguments) +},{"dup":85}],139:[function(require,module,exports){ // 7.2.8 IsRegExp(argument) var isObject = require('./_is-object'); var cof = require('./_cof'); @@ -7648,7 +7536,7 @@ module.exports = function (it) { return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); }; -},{"./_cof":112,"./_is-object":145,"./_wks":216}],147:[function(require,module,exports){ +},{"./_cof":105,"./_is-object":138,"./_wks":209}],140:[function(require,module,exports){ // call something on iterator step with safe closing on error var anObject = require('./_an-object'); module.exports = function (iterator, fn, value, entries) { @@ -7662,7 +7550,7 @@ module.exports = function (iterator, fn, value, entries) { } }; -},{"./_an-object":102}],148:[function(require,module,exports){ +},{"./_an-object":95}],141:[function(require,module,exports){ 'use strict'; var create = require('./_object-create'); var descriptor = require('./_property-desc'); @@ -7677,7 +7565,7 @@ module.exports = function (Constructor, NAME, next) { setToStringTag(Constructor, NAME + ' Iterator'); }; -},{"./_hide":136,"./_object-create":162,"./_property-desc":180,"./_set-to-string-tag":188,"./_wks":216}],149:[function(require,module,exports){ +},{"./_hide":129,"./_object-create":155,"./_property-desc":173,"./_set-to-string-tag":181,"./_wks":209}],142:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var $export = require('./_export'); @@ -7748,7 +7636,7 @@ module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE return methods; }; -},{"./_export":126,"./_hide":136,"./_iter-create":148,"./_iterators":152,"./_library":153,"./_object-gpo":169,"./_redefine":182,"./_set-to-string-tag":188,"./_wks":216}],150:[function(require,module,exports){ +},{"./_export":119,"./_hide":129,"./_iter-create":141,"./_iterators":145,"./_library":146,"./_object-gpo":162,"./_redefine":175,"./_set-to-string-tag":181,"./_wks":209}],143:[function(require,module,exports){ var ITERATOR = require('./_wks')('iterator'); var SAFE_CLOSING = false; @@ -7772,18 +7660,18 @@ module.exports = function (exec, skipClosing) { return safe; }; -},{"./_wks":216}],151:[function(require,module,exports){ +},{"./_wks":209}],144:[function(require,module,exports){ module.exports = function (done, value) { return { value: value, done: !!done }; }; -},{}],152:[function(require,module,exports){ +},{}],145:[function(require,module,exports){ module.exports = {}; -},{}],153:[function(require,module,exports){ +},{}],146:[function(require,module,exports){ module.exports = false; -},{}],154:[function(require,module,exports){ +},{}],147:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $expm1 = Math.expm1; module.exports = (!$expm1 @@ -7795,7 +7683,7 @@ module.exports = (!$expm1 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; } : $expm1; -},{}],155:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var sign = require('./_math-sign'); var pow = Math.pow; @@ -7820,20 +7708,20 @@ module.exports = Math.fround || function fround(x) { return $sign * result; }; -},{"./_math-sign":157}],156:[function(require,module,exports){ +},{"./_math-sign":150}],149:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) module.exports = Math.log1p || function log1p(x) { return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); }; -},{}],157:[function(require,module,exports){ +},{}],150:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) module.exports = Math.sign || function sign(x) { // eslint-disable-next-line no-self-compare return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; }; -},{}],158:[function(require,module,exports){ +},{}],151:[function(require,module,exports){ var META = require('./_uid')('meta'); var isObject = require('./_is-object'); var has = require('./_has'); @@ -7888,7 +7776,7 @@ var meta = module.exports = { onFreeze: onFreeze }; -},{"./_fails":128,"./_has":135,"./_is-object":145,"./_object-dp":163,"./_uid":211}],159:[function(require,module,exports){ +},{"./_fails":121,"./_has":128,"./_is-object":138,"./_object-dp":156,"./_uid":204}],152:[function(require,module,exports){ var global = require('./_global'); var macrotask = require('./_task').set; var Observer = global.MutationObserver || global.WebKitMutationObserver; @@ -7959,7 +7847,7 @@ module.exports = function () { }; }; -},{"./_cof":112,"./_global":134,"./_task":200}],160:[function(require,module,exports){ +},{"./_cof":105,"./_global":127,"./_task":193}],153:[function(require,module,exports){ 'use strict'; // 25.4.1.5 NewPromiseCapability(C) var aFunction = require('./_a-function'); @@ -7979,7 +7867,7 @@ module.exports.f = function (C) { return new PromiseCapability(C); }; -},{"./_a-function":97}],161:[function(require,module,exports){ +},{"./_a-function":90}],154:[function(require,module,exports){ 'use strict'; // 19.1.2.1 Object.assign(target, source, ...) var DESCRIPTORS = require('./_descriptors'); @@ -8019,7 +7907,7 @@ module.exports = !$assign || require('./_fails')(function () { } return T; } : $assign; -},{"./_descriptors":122,"./_fails":128,"./_iobject":141,"./_object-gops":168,"./_object-keys":171,"./_object-pie":172,"./_to-object":206}],162:[function(require,module,exports){ +},{"./_descriptors":115,"./_fails":121,"./_iobject":134,"./_object-gops":161,"./_object-keys":164,"./_object-pie":165,"./_to-object":199}],155:[function(require,module,exports){ // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = require('./_an-object'); var dPs = require('./_object-dps'); @@ -8062,9 +7950,9 @@ module.exports = Object.create || function create(O, Properties) { return Properties === undefined ? result : dPs(result, Properties); }; -},{"./_an-object":102,"./_dom-create":123,"./_enum-bug-keys":124,"./_html":137,"./_object-dps":164,"./_shared-key":189}],163:[function(require,module,exports){ -arguments[4][93][0].apply(exports,arguments) -},{"./_an-object":102,"./_descriptors":122,"./_ie8-dom-define":138,"./_to-primitive":207,"dup":93}],164:[function(require,module,exports){ +},{"./_an-object":95,"./_dom-create":116,"./_enum-bug-keys":117,"./_html":130,"./_object-dps":157,"./_shared-key":182}],156:[function(require,module,exports){ +arguments[4][86][0].apply(exports,arguments) +},{"./_an-object":95,"./_descriptors":115,"./_ie8-dom-define":131,"./_to-primitive":200,"dup":86}],157:[function(require,module,exports){ var dP = require('./_object-dp'); var anObject = require('./_an-object'); var getKeys = require('./_object-keys'); @@ -8079,7 +7967,7 @@ module.exports = require('./_descriptors') ? Object.defineProperties : function return O; }; -},{"./_an-object":102,"./_descriptors":122,"./_object-dp":163,"./_object-keys":171}],165:[function(require,module,exports){ +},{"./_an-object":95,"./_descriptors":115,"./_object-dp":156,"./_object-keys":164}],158:[function(require,module,exports){ var pIE = require('./_object-pie'); var createDesc = require('./_property-desc'); var toIObject = require('./_to-iobject'); @@ -8097,7 +7985,7 @@ exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); }; -},{"./_descriptors":122,"./_has":135,"./_ie8-dom-define":138,"./_object-pie":172,"./_property-desc":180,"./_to-iobject":204,"./_to-primitive":207}],166:[function(require,module,exports){ +},{"./_descriptors":115,"./_has":128,"./_ie8-dom-define":131,"./_object-pie":165,"./_property-desc":173,"./_to-iobject":197,"./_to-primitive":200}],159:[function(require,module,exports){ // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window var toIObject = require('./_to-iobject'); var gOPN = require('./_object-gopn').f; @@ -8118,7 +8006,7 @@ module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); }; -},{"./_object-gopn":167,"./_to-iobject":204}],167:[function(require,module,exports){ +},{"./_object-gopn":160,"./_to-iobject":197}],160:[function(require,module,exports){ // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = require('./_object-keys-internal'); var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype'); @@ -8127,10 +8015,10 @@ exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return $keys(O, hiddenKeys); }; -},{"./_enum-bug-keys":124,"./_object-keys-internal":170}],168:[function(require,module,exports){ +},{"./_enum-bug-keys":117,"./_object-keys-internal":163}],161:[function(require,module,exports){ exports.f = Object.getOwnPropertySymbols; -},{}],169:[function(require,module,exports){ +},{}],162:[function(require,module,exports){ // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = require('./_has'); var toObject = require('./_to-object'); @@ -8145,7 +8033,7 @@ module.exports = Object.getPrototypeOf || function (O) { } return O instanceof Object ? ObjectProto : null; }; -},{"./_has":135,"./_shared-key":189,"./_to-object":206}],170:[function(require,module,exports){ +},{"./_has":128,"./_shared-key":182,"./_to-object":199}],163:[function(require,module,exports){ var has = require('./_has'); var toIObject = require('./_to-iobject'); var arrayIndexOf = require('./_array-includes')(false); @@ -8164,7 +8052,7 @@ module.exports = function (object, names) { return result; }; -},{"./_array-includes":105,"./_has":135,"./_shared-key":189,"./_to-iobject":204}],171:[function(require,module,exports){ +},{"./_array-includes":98,"./_has":128,"./_shared-key":182,"./_to-iobject":197}],164:[function(require,module,exports){ // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = require('./_object-keys-internal'); var enumBugKeys = require('./_enum-bug-keys'); @@ -8173,10 +8061,10 @@ module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; -},{"./_enum-bug-keys":124,"./_object-keys-internal":170}],172:[function(require,module,exports){ +},{"./_enum-bug-keys":117,"./_object-keys-internal":163}],165:[function(require,module,exports){ exports.f = {}.propertyIsEnumerable; -},{}],173:[function(require,module,exports){ +},{}],166:[function(require,module,exports){ // most Object methods by ES6 should accept primitives var $export = require('./_export'); var core = require('./_core'); @@ -8188,7 +8076,7 @@ module.exports = function (KEY, exec) { $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); }; -},{"./_core":116,"./_export":126,"./_fails":128}],174:[function(require,module,exports){ +},{"./_core":109,"./_export":119,"./_fails":121}],167:[function(require,module,exports){ var DESCRIPTORS = require('./_descriptors'); var getKeys = require('./_object-keys'); var toIObject = require('./_to-iobject'); @@ -8211,7 +8099,7 @@ module.exports = function (isEntries) { }; }; -},{"./_descriptors":122,"./_object-keys":171,"./_object-pie":172,"./_to-iobject":204}],175:[function(require,module,exports){ +},{"./_descriptors":115,"./_object-keys":164,"./_object-pie":165,"./_to-iobject":197}],168:[function(require,module,exports){ // all object keys, includes non-enumerable and symbols var gOPN = require('./_object-gopn'); var gOPS = require('./_object-gops'); @@ -8223,7 +8111,7 @@ module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { return getSymbols ? keys.concat(getSymbols(it)) : keys; }; -},{"./_an-object":102,"./_global":134,"./_object-gopn":167,"./_object-gops":168}],176:[function(require,module,exports){ +},{"./_an-object":95,"./_global":127,"./_object-gopn":160,"./_object-gops":161}],169:[function(require,module,exports){ var $parseFloat = require('./_global').parseFloat; var $trim = require('./_string-trim').trim; @@ -8233,7 +8121,7 @@ module.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? return result === 0 && string.charAt(0) == '-' ? -0 : result; } : $parseFloat; -},{"./_global":134,"./_string-trim":198,"./_string-ws":199}],177:[function(require,module,exports){ +},{"./_global":127,"./_string-trim":191,"./_string-ws":192}],170:[function(require,module,exports){ var $parseInt = require('./_global').parseInt; var $trim = require('./_string-trim').trim; var ws = require('./_string-ws'); @@ -8244,7 +8132,7 @@ module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? f return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); } : $parseInt; -},{"./_global":134,"./_string-trim":198,"./_string-ws":199}],178:[function(require,module,exports){ +},{"./_global":127,"./_string-trim":191,"./_string-ws":192}],171:[function(require,module,exports){ module.exports = function (exec) { try { return { e: false, v: exec() }; @@ -8253,7 +8141,7 @@ module.exports = function (exec) { } }; -},{}],179:[function(require,module,exports){ +},{}],172:[function(require,module,exports){ var anObject = require('./_an-object'); var isObject = require('./_is-object'); var newPromiseCapability = require('./_new-promise-capability'); @@ -8267,16 +8155,16 @@ module.exports = function (C, x) { return promiseCapability.promise; }; -},{"./_an-object":102,"./_is-object":145,"./_new-promise-capability":160}],180:[function(require,module,exports){ -arguments[4][94][0].apply(exports,arguments) -},{"dup":94}],181:[function(require,module,exports){ +},{"./_an-object":95,"./_is-object":138,"./_new-promise-capability":153}],173:[function(require,module,exports){ +arguments[4][87][0].apply(exports,arguments) +},{"dup":87}],174:[function(require,module,exports){ var redefine = require('./_redefine'); module.exports = function (target, src, safe) { for (var key in src) redefine(target, key, src[key], safe); return target; }; -},{"./_redefine":182}],182:[function(require,module,exports){ +},{"./_redefine":175}],175:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var has = require('./_has'); @@ -8309,7 +8197,7 @@ require('./_core').inspectSource = function (it) { return typeof this == 'function' && this[SRC] || $toString.call(this); }); -},{"./_core":116,"./_function-to-string":133,"./_global":134,"./_has":135,"./_hide":136,"./_uid":211}],183:[function(require,module,exports){ +},{"./_core":109,"./_function-to-string":126,"./_global":127,"./_has":128,"./_hide":129,"./_uid":204}],176:[function(require,module,exports){ 'use strict'; var classof = require('./_classof'); @@ -8332,7 +8220,7 @@ module.exports = function (R, S) { return builtinExec.call(R, S); }; -},{"./_classof":111}],184:[function(require,module,exports){ +},{"./_classof":104}],177:[function(require,module,exports){ 'use strict'; var regexpFlags = require('./_flags'); @@ -8392,14 +8280,14 @@ if (PATCH) { module.exports = patchedExec; -},{"./_flags":130}],185:[function(require,module,exports){ +},{"./_flags":123}],178:[function(require,module,exports){ // 7.2.9 SameValue(x, y) module.exports = Object.is || function is(x, y) { // eslint-disable-next-line no-self-compare return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; }; -},{}],186:[function(require,module,exports){ +},{}],179:[function(require,module,exports){ // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ var isObject = require('./_is-object'); @@ -8426,7 +8314,7 @@ module.exports = { check: check }; -},{"./_an-object":102,"./_ctx":118,"./_is-object":145,"./_object-gopd":165}],187:[function(require,module,exports){ +},{"./_an-object":95,"./_ctx":111,"./_is-object":138,"./_object-gopd":158}],180:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var dP = require('./_object-dp'); @@ -8441,7 +8329,7 @@ module.exports = function (KEY) { }); }; -},{"./_descriptors":122,"./_global":134,"./_object-dp":163,"./_wks":216}],188:[function(require,module,exports){ +},{"./_descriptors":115,"./_global":127,"./_object-dp":156,"./_wks":209}],181:[function(require,module,exports){ var def = require('./_object-dp').f; var has = require('./_has'); var TAG = require('./_wks')('toStringTag'); @@ -8450,14 +8338,14 @@ module.exports = function (it, tag, stat) { if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); }; -},{"./_has":135,"./_object-dp":163,"./_wks":216}],189:[function(require,module,exports){ +},{"./_has":128,"./_object-dp":156,"./_wks":209}],182:[function(require,module,exports){ var shared = require('./_shared')('keys'); var uid = require('./_uid'); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; -},{"./_shared":190,"./_uid":211}],190:[function(require,module,exports){ +},{"./_shared":183,"./_uid":204}],183:[function(require,module,exports){ var core = require('./_core'); var global = require('./_global'); var SHARED = '__core-js_shared__'; @@ -8471,7 +8359,7 @@ var store = global[SHARED] || (global[SHARED] = {}); copyright: '© 2020 Denis Pushkarev (zloirock.ru)' }); -},{"./_core":116,"./_global":134,"./_library":153}],191:[function(require,module,exports){ +},{"./_core":109,"./_global":127,"./_library":146}],184:[function(require,module,exports){ // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = require('./_an-object'); var aFunction = require('./_a-function'); @@ -8482,7 +8370,7 @@ module.exports = function (O, D) { return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; -},{"./_a-function":97,"./_an-object":102,"./_wks":216}],192:[function(require,module,exports){ +},{"./_a-function":90,"./_an-object":95,"./_wks":209}],185:[function(require,module,exports){ 'use strict'; var fails = require('./_fails'); @@ -8493,7 +8381,7 @@ module.exports = function (method, arg) { }); }; -},{"./_fails":128}],193:[function(require,module,exports){ +},{"./_fails":121}],186:[function(require,module,exports){ var toInteger = require('./_to-integer'); var defined = require('./_defined'); // true -> String#at @@ -8512,7 +8400,7 @@ module.exports = function (TO_STRING) { }; }; -},{"./_defined":121,"./_to-integer":203}],194:[function(require,module,exports){ +},{"./_defined":114,"./_to-integer":196}],187:[function(require,module,exports){ // helper for String#{startsWith, endsWith, includes} var isRegExp = require('./_is-regexp'); var defined = require('./_defined'); @@ -8522,7 +8410,7 @@ module.exports = function (that, searchString, NAME) { return String(defined(that)); }; -},{"./_defined":121,"./_is-regexp":146}],195:[function(require,module,exports){ +},{"./_defined":114,"./_is-regexp":139}],188:[function(require,module,exports){ var $export = require('./_export'); var fails = require('./_fails'); var defined = require('./_defined'); @@ -8543,7 +8431,7 @@ module.exports = function (NAME, exec) { }), 'String', O); }; -},{"./_defined":121,"./_export":126,"./_fails":128}],196:[function(require,module,exports){ +},{"./_defined":114,"./_export":119,"./_fails":121}],189:[function(require,module,exports){ // https://github.com/tc39/proposal-string-pad-start-end var toLength = require('./_to-length'); var repeat = require('./_string-repeat'); @@ -8561,7 +8449,7 @@ module.exports = function (that, maxLength, fillString, left) { return left ? stringFiller + S : S + stringFiller; }; -},{"./_defined":121,"./_string-repeat":197,"./_to-length":205}],197:[function(require,module,exports){ +},{"./_defined":114,"./_string-repeat":190,"./_to-length":198}],190:[function(require,module,exports){ 'use strict'; var toInteger = require('./_to-integer'); var defined = require('./_defined'); @@ -8575,7 +8463,7 @@ module.exports = function repeat(count) { return res; }; -},{"./_defined":121,"./_to-integer":203}],198:[function(require,module,exports){ +},{"./_defined":114,"./_to-integer":196}],191:[function(require,module,exports){ var $export = require('./_export'); var defined = require('./_defined'); var fails = require('./_fails'); @@ -8607,11 +8495,11 @@ var trim = exporter.trim = function (string, TYPE) { module.exports = exporter; -},{"./_defined":121,"./_export":126,"./_fails":128,"./_string-ws":199}],199:[function(require,module,exports){ +},{"./_defined":114,"./_export":119,"./_fails":121,"./_string-ws":192}],192:[function(require,module,exports){ module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -},{}],200:[function(require,module,exports){ +},{}],193:[function(require,module,exports){ var ctx = require('./_ctx'); var invoke = require('./_invoke'); var html = require('./_html'); @@ -8697,7 +8585,7 @@ module.exports = { clear: clearTask }; -},{"./_cof":112,"./_ctx":118,"./_dom-create":123,"./_global":134,"./_html":137,"./_invoke":140}],201:[function(require,module,exports){ +},{"./_cof":105,"./_ctx":111,"./_dom-create":116,"./_global":127,"./_html":130,"./_invoke":133}],194:[function(require,module,exports){ var toInteger = require('./_to-integer'); var max = Math.max; var min = Math.min; @@ -8706,7 +8594,7 @@ module.exports = function (index, length) { return index < 0 ? max(index + length, 0) : min(index, length); }; -},{"./_to-integer":203}],202:[function(require,module,exports){ +},{"./_to-integer":196}],195:[function(require,module,exports){ // https://tc39.github.io/ecma262/#sec-toindex var toInteger = require('./_to-integer'); var toLength = require('./_to-length'); @@ -8718,7 +8606,7 @@ module.exports = function (it) { return length; }; -},{"./_to-integer":203,"./_to-length":205}],203:[function(require,module,exports){ +},{"./_to-integer":196,"./_to-length":198}],196:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; @@ -8726,7 +8614,7 @@ module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],204:[function(require,module,exports){ +},{}],197:[function(require,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = require('./_iobject'); var defined = require('./_defined'); @@ -8734,7 +8622,7 @@ module.exports = function (it) { return IObject(defined(it)); }; -},{"./_defined":121,"./_iobject":141}],205:[function(require,module,exports){ +},{"./_defined":114,"./_iobject":134}],198:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./_to-integer'); var min = Math.min; @@ -8742,16 +8630,16 @@ module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./_to-integer":203}],206:[function(require,module,exports){ +},{"./_to-integer":196}],199:[function(require,module,exports){ // 7.1.13 ToObject(argument) var defined = require('./_defined'); module.exports = function (it) { return Object(defined(it)); }; -},{"./_defined":121}],207:[function(require,module,exports){ -arguments[4][95][0].apply(exports,arguments) -},{"./_is-object":145,"dup":95}],208:[function(require,module,exports){ +},{"./_defined":114}],200:[function(require,module,exports){ +arguments[4][88][0].apply(exports,arguments) +},{"./_is-object":138,"dup":88}],201:[function(require,module,exports){ 'use strict'; if (require('./_descriptors')) { var LIBRARY = require('./_library'); @@ -9233,7 +9121,7 @@ if (require('./_descriptors')) { }; } else module.exports = function () { /* empty */ }; -},{"./_an-instance":101,"./_array-copy-within":103,"./_array-fill":104,"./_array-includes":105,"./_array-methods":106,"./_classof":111,"./_ctx":118,"./_descriptors":122,"./_export":126,"./_fails":128,"./_global":134,"./_has":135,"./_hide":136,"./_is-array-iter":142,"./_is-object":145,"./_iter-detect":150,"./_iterators":152,"./_library":153,"./_object-create":162,"./_object-dp":163,"./_object-gopd":165,"./_object-gopn":167,"./_object-gpo":169,"./_property-desc":180,"./_redefine-all":181,"./_set-species":187,"./_species-constructor":191,"./_to-absolute-index":201,"./_to-index":202,"./_to-integer":203,"./_to-length":205,"./_to-object":206,"./_to-primitive":207,"./_typed":210,"./_typed-buffer":209,"./_uid":211,"./_wks":216,"./core.get-iterator-method":217,"./es6.array.iterator":228}],209:[function(require,module,exports){ +},{"./_an-instance":94,"./_array-copy-within":96,"./_array-fill":97,"./_array-includes":98,"./_array-methods":99,"./_classof":104,"./_ctx":111,"./_descriptors":115,"./_export":119,"./_fails":121,"./_global":127,"./_has":128,"./_hide":129,"./_is-array-iter":135,"./_is-object":138,"./_iter-detect":143,"./_iterators":145,"./_library":146,"./_object-create":155,"./_object-dp":156,"./_object-gopd":158,"./_object-gopn":160,"./_object-gpo":162,"./_property-desc":173,"./_redefine-all":174,"./_set-species":180,"./_species-constructor":184,"./_to-absolute-index":194,"./_to-index":195,"./_to-integer":196,"./_to-length":198,"./_to-object":199,"./_to-primitive":200,"./_typed":203,"./_typed-buffer":202,"./_uid":204,"./_wks":209,"./core.get-iterator-method":210,"./es6.array.iterator":221}],202:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var DESCRIPTORS = require('./_descriptors'); @@ -9511,7 +9399,7 @@ hide($DataView[PROTOTYPE], $typed.VIEW, true); exports[ARRAY_BUFFER] = $ArrayBuffer; exports[DATA_VIEW] = $DataView; -},{"./_an-instance":101,"./_array-fill":104,"./_descriptors":122,"./_fails":128,"./_global":134,"./_hide":136,"./_library":153,"./_object-dp":163,"./_object-gopn":167,"./_redefine-all":181,"./_set-to-string-tag":188,"./_to-index":202,"./_to-integer":203,"./_to-length":205,"./_typed":210}],210:[function(require,module,exports){ +},{"./_an-instance":94,"./_array-fill":97,"./_descriptors":115,"./_fails":121,"./_global":127,"./_hide":129,"./_library":146,"./_object-dp":156,"./_object-gopn":160,"./_redefine-all":174,"./_set-to-string-tag":181,"./_to-index":195,"./_to-integer":196,"./_to-length":198,"./_typed":203}],203:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var uid = require('./_uid'); @@ -9541,27 +9429,27 @@ module.exports = { VIEW: VIEW }; -},{"./_global":134,"./_hide":136,"./_uid":211}],211:[function(require,module,exports){ +},{"./_global":127,"./_hide":129,"./_uid":204}],204:[function(require,module,exports){ var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],212:[function(require,module,exports){ +},{}],205:[function(require,module,exports){ var global = require('./_global'); var navigator = global.navigator; module.exports = navigator && navigator.userAgent || ''; -},{"./_global":134}],213:[function(require,module,exports){ +},{"./_global":127}],206:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it, TYPE) { if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); return it; }; -},{"./_is-object":145}],214:[function(require,module,exports){ +},{"./_is-object":138}],207:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var LIBRARY = require('./_library'); @@ -9572,10 +9460,10 @@ module.exports = function (name) { if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); }; -},{"./_core":116,"./_global":134,"./_library":153,"./_object-dp":163,"./_wks-ext":215}],215:[function(require,module,exports){ +},{"./_core":109,"./_global":127,"./_library":146,"./_object-dp":156,"./_wks-ext":208}],208:[function(require,module,exports){ exports.f = require('./_wks'); -},{"./_wks":216}],216:[function(require,module,exports){ +},{"./_wks":209}],209:[function(require,module,exports){ var store = require('./_shared')('wks'); var uid = require('./_uid'); var Symbol = require('./_global').Symbol; @@ -9588,7 +9476,7 @@ var $exports = module.exports = function (name) { $exports.store = store; -},{"./_global":134,"./_shared":190,"./_uid":211}],217:[function(require,module,exports){ +},{"./_global":127,"./_shared":183,"./_uid":204}],210:[function(require,module,exports){ var classof = require('./_classof'); var ITERATOR = require('./_wks')('iterator'); var Iterators = require('./_iterators'); @@ -9598,7 +9486,7 @@ module.exports = require('./_core').getIteratorMethod = function (it) { || Iterators[classof(it)]; }; -},{"./_classof":111,"./_core":116,"./_iterators":152,"./_wks":216}],218:[function(require,module,exports){ +},{"./_classof":104,"./_core":109,"./_iterators":145,"./_wks":209}],211:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) var $export = require('./_export'); @@ -9606,7 +9494,7 @@ $export($export.P, 'Array', { copyWithin: require('./_array-copy-within') }); require('./_add-to-unscopables')('copyWithin'); -},{"./_add-to-unscopables":99,"./_array-copy-within":103,"./_export":126}],219:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_array-copy-within":96,"./_export":119}],212:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $every = require('./_array-methods')(4); @@ -9618,7 +9506,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].every, true), 'A } }); -},{"./_array-methods":106,"./_export":126,"./_strict-method":192}],220:[function(require,module,exports){ +},{"./_array-methods":99,"./_export":119,"./_strict-method":185}],213:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) var $export = require('./_export'); @@ -9626,7 +9514,7 @@ $export($export.P, 'Array', { fill: require('./_array-fill') }); require('./_add-to-unscopables')('fill'); -},{"./_add-to-unscopables":99,"./_array-fill":104,"./_export":126}],221:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_array-fill":97,"./_export":119}],214:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $filter = require('./_array-methods')(2); @@ -9638,7 +9526,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].filter, true), ' } }); -},{"./_array-methods":106,"./_export":126,"./_strict-method":192}],222:[function(require,module,exports){ +},{"./_array-methods":99,"./_export":119,"./_strict-method":185}],215:[function(require,module,exports){ 'use strict'; // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) var $export = require('./_export'); @@ -9654,7 +9542,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":99,"./_array-methods":106,"./_export":126}],223:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_array-methods":99,"./_export":119}],216:[function(require,module,exports){ 'use strict'; // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) var $export = require('./_export'); @@ -9670,7 +9558,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":99,"./_array-methods":106,"./_export":126}],224:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_array-methods":99,"./_export":119}],217:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $forEach = require('./_array-methods')(0); @@ -9683,7 +9571,7 @@ $export($export.P + $export.F * !STRICT, 'Array', { } }); -},{"./_array-methods":106,"./_export":126,"./_strict-method":192}],225:[function(require,module,exports){ +},{"./_array-methods":99,"./_export":119,"./_strict-method":185}],218:[function(require,module,exports){ 'use strict'; var ctx = require('./_ctx'); var $export = require('./_export'); @@ -9722,7 +9610,7 @@ $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Arr } }); -},{"./_create-property":117,"./_ctx":118,"./_export":126,"./_is-array-iter":142,"./_iter-call":147,"./_iter-detect":150,"./_to-length":205,"./_to-object":206,"./core.get-iterator-method":217}],226:[function(require,module,exports){ +},{"./_create-property":110,"./_ctx":111,"./_export":119,"./_is-array-iter":135,"./_iter-call":140,"./_iter-detect":143,"./_to-length":198,"./_to-object":199,"./core.get-iterator-method":210}],219:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $indexOf = require('./_array-includes')(false); @@ -9739,13 +9627,13 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_array-includes":105,"./_export":126,"./_strict-method":192}],227:[function(require,module,exports){ +},{"./_array-includes":98,"./_export":119,"./_strict-method":185}],220:[function(require,module,exports){ // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) var $export = require('./_export'); $export($export.S, 'Array', { isArray: require('./_is-array') }); -},{"./_export":126,"./_is-array":143}],228:[function(require,module,exports){ +},{"./_export":119,"./_is-array":136}],221:[function(require,module,exports){ 'use strict'; var addToUnscopables = require('./_add-to-unscopables'); var step = require('./_iter-step'); @@ -9781,7 +9669,7 @@ addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"./_add-to-unscopables":99,"./_iter-define":149,"./_iter-step":151,"./_iterators":152,"./_to-iobject":204}],229:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_iter-define":142,"./_iter-step":144,"./_iterators":145,"./_to-iobject":197}],222:[function(require,module,exports){ 'use strict'; // 22.1.3.13 Array.prototype.join(separator) var $export = require('./_export'); @@ -9795,7 +9683,7 @@ $export($export.P + $export.F * (require('./_iobject') != Object || !require('./ } }); -},{"./_export":126,"./_iobject":141,"./_strict-method":192,"./_to-iobject":204}],230:[function(require,module,exports){ +},{"./_export":119,"./_iobject":134,"./_strict-method":185,"./_to-iobject":197}],223:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toIObject = require('./_to-iobject'); @@ -9819,7 +9707,7 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_export":126,"./_strict-method":192,"./_to-integer":203,"./_to-iobject":204,"./_to-length":205}],231:[function(require,module,exports){ +},{"./_export":119,"./_strict-method":185,"./_to-integer":196,"./_to-iobject":197,"./_to-length":198}],224:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $map = require('./_array-methods')(1); @@ -9831,7 +9719,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Arr } }); -},{"./_array-methods":106,"./_export":126,"./_strict-method":192}],232:[function(require,module,exports){ +},{"./_array-methods":99,"./_export":119,"./_strict-method":185}],225:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var createProperty = require('./_create-property'); @@ -9852,7 +9740,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_create-property":117,"./_export":126,"./_fails":128}],233:[function(require,module,exports){ +},{"./_create-property":110,"./_export":119,"./_fails":121}],226:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -9864,7 +9752,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduceRight, tru } }); -},{"./_array-reduce":107,"./_export":126,"./_strict-method":192}],234:[function(require,module,exports){ +},{"./_array-reduce":100,"./_export":119,"./_strict-method":185}],227:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -9876,7 +9764,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduce, true), ' } }); -},{"./_array-reduce":107,"./_export":126,"./_strict-method":192}],235:[function(require,module,exports){ +},{"./_array-reduce":100,"./_export":119,"./_strict-method":185}],228:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var html = require('./_html'); @@ -9906,7 +9794,7 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_cof":112,"./_export":126,"./_fails":128,"./_html":137,"./_to-absolute-index":201,"./_to-length":205}],236:[function(require,module,exports){ +},{"./_cof":105,"./_export":119,"./_fails":121,"./_html":130,"./_to-absolute-index":194,"./_to-length":198}],229:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $some = require('./_array-methods')(3); @@ -9918,7 +9806,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Ar } }); -},{"./_array-methods":106,"./_export":126,"./_strict-method":192}],237:[function(require,module,exports){ +},{"./_array-methods":99,"./_export":119,"./_strict-method":185}],230:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -9943,16 +9831,16 @@ $export($export.P + $export.F * (fails(function () { } }); -},{"./_a-function":97,"./_export":126,"./_fails":128,"./_strict-method":192,"./_to-object":206}],238:[function(require,module,exports){ +},{"./_a-function":90,"./_export":119,"./_fails":121,"./_strict-method":185,"./_to-object":199}],231:[function(require,module,exports){ require('./_set-species')('Array'); -},{"./_set-species":187}],239:[function(require,module,exports){ +},{"./_set-species":180}],232:[function(require,module,exports){ // 20.3.3.1 / 15.9.4.4 Date.now() var $export = require('./_export'); $export($export.S, 'Date', { now: function () { return new Date().getTime(); } }); -},{"./_export":126}],240:[function(require,module,exports){ +},{"./_export":119}],233:[function(require,module,exports){ // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var $export = require('./_export'); var toISOString = require('./_date-to-iso-string'); @@ -9962,7 +9850,7 @@ $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'D toISOString: toISOString }); -},{"./_date-to-iso-string":119,"./_export":126}],241:[function(require,module,exports){ +},{"./_date-to-iso-string":112,"./_export":119}],234:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toObject = require('./_to-object'); @@ -9980,13 +9868,13 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_export":126,"./_fails":128,"./_to-object":206,"./_to-primitive":207}],242:[function(require,module,exports){ +},{"./_export":119,"./_fails":121,"./_to-object":199,"./_to-primitive":200}],235:[function(require,module,exports){ var TO_PRIMITIVE = require('./_wks')('toPrimitive'); var proto = Date.prototype; if (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive')); -},{"./_date-to-primitive":120,"./_hide":136,"./_wks":216}],243:[function(require,module,exports){ +},{"./_date-to-primitive":113,"./_hide":129,"./_wks":209}],236:[function(require,module,exports){ var DateProto = Date.prototype; var INVALID_DATE = 'Invalid Date'; var TO_STRING = 'toString'; @@ -10000,13 +9888,13 @@ if (new Date(NaN) + '' != INVALID_DATE) { }); } -},{"./_redefine":182}],244:[function(require,module,exports){ +},{"./_redefine":175}],237:[function(require,module,exports){ // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) var $export = require('./_export'); $export($export.P, 'Function', { bind: require('./_bind') }); -},{"./_bind":110,"./_export":126}],245:[function(require,module,exports){ +},{"./_bind":103,"./_export":119}],238:[function(require,module,exports){ 'use strict'; var isObject = require('./_is-object'); var getPrototypeOf = require('./_object-gpo'); @@ -10021,7 +9909,7 @@ if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, H return false; } }); -},{"./_is-object":145,"./_object-dp":163,"./_object-gpo":169,"./_wks":216}],246:[function(require,module,exports){ +},{"./_is-object":138,"./_object-dp":156,"./_object-gpo":162,"./_wks":209}],239:[function(require,module,exports){ var dP = require('./_object-dp').f; var FProto = Function.prototype; var nameRE = /^\s*function ([^ (]*)/; @@ -10039,7 +9927,7 @@ NAME in FProto || require('./_descriptors') && dP(FProto, NAME, { } }); -},{"./_descriptors":122,"./_object-dp":163}],247:[function(require,module,exports){ +},{"./_descriptors":115,"./_object-dp":156}],240:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -10060,7 +9948,7 @@ module.exports = require('./_collection')(MAP, function (get) { } }, strong, true); -},{"./_collection":115,"./_collection-strong":113,"./_validate-collection":213}],248:[function(require,module,exports){ +},{"./_collection":108,"./_collection-strong":106,"./_validate-collection":206}],241:[function(require,module,exports){ // 20.2.2.3 Math.acosh(x) var $export = require('./_export'); var log1p = require('./_math-log1p'); @@ -10080,7 +9968,7 @@ $export($export.S + $export.F * !($acosh } }); -},{"./_export":126,"./_math-log1p":156}],249:[function(require,module,exports){ +},{"./_export":119,"./_math-log1p":149}],242:[function(require,module,exports){ // 20.2.2.5 Math.asinh(x) var $export = require('./_export'); var $asinh = Math.asinh; @@ -10092,7 +9980,7 @@ function asinh(x) { // Tor Browser bug: Math.asinh(0) -> -0 $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh }); -},{"./_export":126}],250:[function(require,module,exports){ +},{"./_export":119}],243:[function(require,module,exports){ // 20.2.2.7 Math.atanh(x) var $export = require('./_export'); var $atanh = Math.atanh; @@ -10104,7 +9992,7 @@ $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { } }); -},{"./_export":126}],251:[function(require,module,exports){ +},{"./_export":119}],244:[function(require,module,exports){ // 20.2.2.9 Math.cbrt(x) var $export = require('./_export'); var sign = require('./_math-sign'); @@ -10115,7 +10003,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":126,"./_math-sign":157}],252:[function(require,module,exports){ +},{"./_export":119,"./_math-sign":150}],245:[function(require,module,exports){ // 20.2.2.11 Math.clz32(x) var $export = require('./_export'); @@ -10125,7 +10013,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],253:[function(require,module,exports){ +},{"./_export":119}],246:[function(require,module,exports){ // 20.2.2.12 Math.cosh(x) var $export = require('./_export'); var exp = Math.exp; @@ -10136,20 +10024,20 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],254:[function(require,module,exports){ +},{"./_export":119}],247:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $export = require('./_export'); var $expm1 = require('./_math-expm1'); $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 }); -},{"./_export":126,"./_math-expm1":154}],255:[function(require,module,exports){ +},{"./_export":119,"./_math-expm1":147}],248:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var $export = require('./_export'); $export($export.S, 'Math', { fround: require('./_math-fround') }); -},{"./_export":126,"./_math-fround":155}],256:[function(require,module,exports){ +},{"./_export":119,"./_math-fround":148}],249:[function(require,module,exports){ // 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) var $export = require('./_export'); var abs = Math.abs; @@ -10176,7 +10064,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],257:[function(require,module,exports){ +},{"./_export":119}],250:[function(require,module,exports){ // 20.2.2.18 Math.imul(x, y) var $export = require('./_export'); var $imul = Math.imul; @@ -10195,7 +10083,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":126,"./_fails":128}],258:[function(require,module,exports){ +},{"./_export":119,"./_fails":121}],251:[function(require,module,exports){ // 20.2.2.21 Math.log10(x) var $export = require('./_export'); @@ -10205,13 +10093,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],259:[function(require,module,exports){ +},{"./_export":119}],252:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) var $export = require('./_export'); $export($export.S, 'Math', { log1p: require('./_math-log1p') }); -},{"./_export":126,"./_math-log1p":156}],260:[function(require,module,exports){ +},{"./_export":119,"./_math-log1p":149}],253:[function(require,module,exports){ // 20.2.2.22 Math.log2(x) var $export = require('./_export'); @@ -10221,13 +10109,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],261:[function(require,module,exports){ +},{"./_export":119}],254:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) var $export = require('./_export'); $export($export.S, 'Math', { sign: require('./_math-sign') }); -},{"./_export":126,"./_math-sign":157}],262:[function(require,module,exports){ +},{"./_export":119,"./_math-sign":150}],255:[function(require,module,exports){ // 20.2.2.30 Math.sinh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -10244,7 +10132,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":126,"./_fails":128,"./_math-expm1":154}],263:[function(require,module,exports){ +},{"./_export":119,"./_fails":121,"./_math-expm1":147}],256:[function(require,module,exports){ // 20.2.2.33 Math.tanh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -10258,7 +10146,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":126,"./_math-expm1":154}],264:[function(require,module,exports){ +},{"./_export":119,"./_math-expm1":147}],257:[function(require,module,exports){ // 20.2.2.34 Math.trunc(x) var $export = require('./_export'); @@ -10268,7 +10156,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":126}],265:[function(require,module,exports){ +},{"./_export":119}],258:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var has = require('./_has'); @@ -10339,13 +10227,13 @@ if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { require('./_redefine')(global, NUMBER, $Number); } -},{"./_cof":112,"./_descriptors":122,"./_fails":128,"./_global":134,"./_has":135,"./_inherit-if-required":139,"./_object-create":162,"./_object-dp":163,"./_object-gopd":165,"./_object-gopn":167,"./_redefine":182,"./_string-trim":198,"./_to-primitive":207}],266:[function(require,module,exports){ +},{"./_cof":105,"./_descriptors":115,"./_fails":121,"./_global":127,"./_has":128,"./_inherit-if-required":132,"./_object-create":155,"./_object-dp":156,"./_object-gopd":158,"./_object-gopn":160,"./_redefine":175,"./_string-trim":191,"./_to-primitive":200}],259:[function(require,module,exports){ // 20.1.2.1 Number.EPSILON var $export = require('./_export'); $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); -},{"./_export":126}],267:[function(require,module,exports){ +},{"./_export":119}],260:[function(require,module,exports){ // 20.1.2.2 Number.isFinite(number) var $export = require('./_export'); var _isFinite = require('./_global').isFinite; @@ -10356,13 +10244,13 @@ $export($export.S, 'Number', { } }); -},{"./_export":126,"./_global":134}],268:[function(require,module,exports){ +},{"./_export":119,"./_global":127}],261:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var $export = require('./_export'); $export($export.S, 'Number', { isInteger: require('./_is-integer') }); -},{"./_export":126,"./_is-integer":144}],269:[function(require,module,exports){ +},{"./_export":119,"./_is-integer":137}],262:[function(require,module,exports){ // 20.1.2.4 Number.isNaN(number) var $export = require('./_export'); @@ -10373,7 +10261,7 @@ $export($export.S, 'Number', { } }); -},{"./_export":126}],270:[function(require,module,exports){ +},{"./_export":119}],263:[function(require,module,exports){ // 20.1.2.5 Number.isSafeInteger(number) var $export = require('./_export'); var isInteger = require('./_is-integer'); @@ -10385,31 +10273,31 @@ $export($export.S, 'Number', { } }); -},{"./_export":126,"./_is-integer":144}],271:[function(require,module,exports){ +},{"./_export":119,"./_is-integer":137}],264:[function(require,module,exports){ // 20.1.2.6 Number.MAX_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); -},{"./_export":126}],272:[function(require,module,exports){ +},{"./_export":119}],265:[function(require,module,exports){ // 20.1.2.10 Number.MIN_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); -},{"./_export":126}],273:[function(require,module,exports){ +},{"./_export":119}],266:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 20.1.2.12 Number.parseFloat(string) $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat }); -},{"./_export":126,"./_parse-float":176}],274:[function(require,module,exports){ +},{"./_export":119,"./_parse-float":169}],267:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 20.1.2.13 Number.parseInt(string, radix) $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt }); -},{"./_export":126,"./_parse-int":177}],275:[function(require,module,exports){ +},{"./_export":119,"./_parse-int":170}],268:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toInteger = require('./_to-integer'); @@ -10525,7 +10413,7 @@ $export($export.P + $export.F * (!!$toFixed && ( } }); -},{"./_a-number-value":98,"./_export":126,"./_fails":128,"./_string-repeat":197,"./_to-integer":203}],276:[function(require,module,exports){ +},{"./_a-number-value":91,"./_export":119,"./_fails":121,"./_string-repeat":190,"./_to-integer":196}],269:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $fails = require('./_fails'); @@ -10545,28 +10433,28 @@ $export($export.P + $export.F * ($fails(function () { } }); -},{"./_a-number-value":98,"./_export":126,"./_fails":128}],277:[function(require,module,exports){ +},{"./_a-number-value":91,"./_export":119,"./_fails":121}],270:[function(require,module,exports){ // 19.1.3.1 Object.assign(target, source) var $export = require('./_export'); $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') }); -},{"./_export":126,"./_object-assign":161}],278:[function(require,module,exports){ +},{"./_export":119,"./_object-assign":154}],271:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) $export($export.S, 'Object', { create: require('./_object-create') }); -},{"./_export":126,"./_object-create":162}],279:[function(require,module,exports){ +},{"./_export":119,"./_object-create":155}],272:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') }); -},{"./_descriptors":122,"./_export":126,"./_object-dps":164}],280:[function(require,module,exports){ +},{"./_descriptors":115,"./_export":119,"./_object-dps":157}],273:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f }); -},{"./_descriptors":122,"./_export":126,"./_object-dp":163}],281:[function(require,module,exports){ +},{"./_descriptors":115,"./_export":119,"./_object-dp":156}],274:[function(require,module,exports){ // 19.1.2.5 Object.freeze(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10577,7 +10465,7 @@ require('./_object-sap')('freeze', function ($freeze) { }; }); -},{"./_is-object":145,"./_meta":158,"./_object-sap":173}],282:[function(require,module,exports){ +},{"./_is-object":138,"./_meta":151,"./_object-sap":166}],275:[function(require,module,exports){ // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) var toIObject = require('./_to-iobject'); var $getOwnPropertyDescriptor = require('./_object-gopd').f; @@ -10588,13 +10476,13 @@ require('./_object-sap')('getOwnPropertyDescriptor', function () { }; }); -},{"./_object-gopd":165,"./_object-sap":173,"./_to-iobject":204}],283:[function(require,module,exports){ +},{"./_object-gopd":158,"./_object-sap":166,"./_to-iobject":197}],276:[function(require,module,exports){ // 19.1.2.7 Object.getOwnPropertyNames(O) require('./_object-sap')('getOwnPropertyNames', function () { return require('./_object-gopn-ext').f; }); -},{"./_object-gopn-ext":166,"./_object-sap":173}],284:[function(require,module,exports){ +},{"./_object-gopn-ext":159,"./_object-sap":166}],277:[function(require,module,exports){ // 19.1.2.9 Object.getPrototypeOf(O) var toObject = require('./_to-object'); var $getPrototypeOf = require('./_object-gpo'); @@ -10605,7 +10493,7 @@ require('./_object-sap')('getPrototypeOf', function () { }; }); -},{"./_object-gpo":169,"./_object-sap":173,"./_to-object":206}],285:[function(require,module,exports){ +},{"./_object-gpo":162,"./_object-sap":166,"./_to-object":199}],278:[function(require,module,exports){ // 19.1.2.11 Object.isExtensible(O) var isObject = require('./_is-object'); @@ -10615,7 +10503,7 @@ require('./_object-sap')('isExtensible', function ($isExtensible) { }; }); -},{"./_is-object":145,"./_object-sap":173}],286:[function(require,module,exports){ +},{"./_is-object":138,"./_object-sap":166}],279:[function(require,module,exports){ // 19.1.2.12 Object.isFrozen(O) var isObject = require('./_is-object'); @@ -10625,7 +10513,7 @@ require('./_object-sap')('isFrozen', function ($isFrozen) { }; }); -},{"./_is-object":145,"./_object-sap":173}],287:[function(require,module,exports){ +},{"./_is-object":138,"./_object-sap":166}],280:[function(require,module,exports){ // 19.1.2.13 Object.isSealed(O) var isObject = require('./_is-object'); @@ -10635,12 +10523,12 @@ require('./_object-sap')('isSealed', function ($isSealed) { }; }); -},{"./_is-object":145,"./_object-sap":173}],288:[function(require,module,exports){ +},{"./_is-object":138,"./_object-sap":166}],281:[function(require,module,exports){ // 19.1.3.10 Object.is(value1, value2) var $export = require('./_export'); $export($export.S, 'Object', { is: require('./_same-value') }); -},{"./_export":126,"./_same-value":185}],289:[function(require,module,exports){ +},{"./_export":119,"./_same-value":178}],282:[function(require,module,exports){ // 19.1.2.14 Object.keys(O) var toObject = require('./_to-object'); var $keys = require('./_object-keys'); @@ -10651,7 +10539,7 @@ require('./_object-sap')('keys', function () { }; }); -},{"./_object-keys":171,"./_object-sap":173,"./_to-object":206}],290:[function(require,module,exports){ +},{"./_object-keys":164,"./_object-sap":166,"./_to-object":199}],283:[function(require,module,exports){ // 19.1.2.15 Object.preventExtensions(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10662,7 +10550,7 @@ require('./_object-sap')('preventExtensions', function ($preventExtensions) { }; }); -},{"./_is-object":145,"./_meta":158,"./_object-sap":173}],291:[function(require,module,exports){ +},{"./_is-object":138,"./_meta":151,"./_object-sap":166}],284:[function(require,module,exports){ // 19.1.2.17 Object.seal(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10673,12 +10561,12 @@ require('./_object-sap')('seal', function ($seal) { }; }); -},{"./_is-object":145,"./_meta":158,"./_object-sap":173}],292:[function(require,module,exports){ +},{"./_is-object":138,"./_meta":151,"./_object-sap":166}],285:[function(require,module,exports){ // 19.1.3.19 Object.setPrototypeOf(O, proto) var $export = require('./_export'); $export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set }); -},{"./_export":126,"./_set-proto":186}],293:[function(require,module,exports){ +},{"./_export":119,"./_set-proto":179}],286:[function(require,module,exports){ 'use strict'; // 19.1.3.6 Object.prototype.toString() var classof = require('./_classof'); @@ -10690,19 +10578,19 @@ if (test + '' != '[object z]') { }, true); } -},{"./_classof":111,"./_redefine":182,"./_wks":216}],294:[function(require,module,exports){ +},{"./_classof":104,"./_redefine":175,"./_wks":209}],287:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 18.2.4 parseFloat(string) $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat }); -},{"./_export":126,"./_parse-float":176}],295:[function(require,module,exports){ +},{"./_export":119,"./_parse-float":169}],288:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 18.2.5 parseInt(string, radix) $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt }); -},{"./_export":126,"./_parse-int":177}],296:[function(require,module,exports){ +},{"./_export":119,"./_parse-int":170}],289:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var global = require('./_global'); @@ -10990,7 +10878,7 @@ $export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(functi } }); -},{"./_a-function":97,"./_an-instance":101,"./_classof":111,"./_core":116,"./_ctx":118,"./_export":126,"./_for-of":132,"./_global":134,"./_is-object":145,"./_iter-detect":150,"./_library":153,"./_microtask":159,"./_new-promise-capability":160,"./_perform":178,"./_promise-resolve":179,"./_redefine-all":181,"./_set-species":187,"./_set-to-string-tag":188,"./_species-constructor":191,"./_task":200,"./_user-agent":212,"./_wks":216}],297:[function(require,module,exports){ +},{"./_a-function":90,"./_an-instance":94,"./_classof":104,"./_core":109,"./_ctx":111,"./_export":119,"./_for-of":125,"./_global":127,"./_is-object":138,"./_iter-detect":143,"./_library":146,"./_microtask":152,"./_new-promise-capability":153,"./_perform":171,"./_promise-resolve":172,"./_redefine-all":174,"./_set-species":180,"./_set-to-string-tag":181,"./_species-constructor":184,"./_task":193,"./_user-agent":205,"./_wks":209}],290:[function(require,module,exports){ // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -11008,7 +10896,7 @@ $export($export.S + $export.F * !require('./_fails')(function () { } }); -},{"./_a-function":97,"./_an-object":102,"./_export":126,"./_fails":128,"./_global":134}],298:[function(require,module,exports){ +},{"./_a-function":90,"./_an-object":95,"./_export":119,"./_fails":121,"./_global":127}],291:[function(require,module,exports){ // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) var $export = require('./_export'); var create = require('./_object-create'); @@ -11057,7 +10945,7 @@ $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { } }); -},{"./_a-function":97,"./_an-object":102,"./_bind":110,"./_export":126,"./_fails":128,"./_global":134,"./_is-object":145,"./_object-create":162}],299:[function(require,module,exports){ +},{"./_a-function":90,"./_an-object":95,"./_bind":103,"./_export":119,"./_fails":121,"./_global":127,"./_is-object":138,"./_object-create":155}],292:[function(require,module,exports){ // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) var dP = require('./_object-dp'); var $export = require('./_export'); @@ -11082,7 +10970,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_an-object":102,"./_export":126,"./_fails":128,"./_object-dp":163,"./_to-primitive":207}],300:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_fails":121,"./_object-dp":156,"./_to-primitive":200}],293:[function(require,module,exports){ // 26.1.4 Reflect.deleteProperty(target, propertyKey) var $export = require('./_export'); var gOPD = require('./_object-gopd').f; @@ -11095,7 +10983,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126,"./_object-gopd":165}],301:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_object-gopd":158}],294:[function(require,module,exports){ 'use strict'; // 26.1.5 Reflect.enumerate(target) var $export = require('./_export'); @@ -11123,7 +11011,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126,"./_iter-create":148}],302:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_iter-create":141}],295:[function(require,module,exports){ // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) var gOPD = require('./_object-gopd'); var $export = require('./_export'); @@ -11135,7 +11023,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126,"./_object-gopd":165}],303:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_object-gopd":158}],296:[function(require,module,exports){ // 26.1.8 Reflect.getPrototypeOf(target) var $export = require('./_export'); var getProto = require('./_object-gpo'); @@ -11147,7 +11035,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126,"./_object-gpo":169}],304:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_object-gpo":162}],297:[function(require,module,exports){ // 26.1.6 Reflect.get(target, propertyKey [, receiver]) var gOPD = require('./_object-gopd'); var getPrototypeOf = require('./_object-gpo'); @@ -11170,7 +11058,7 @@ function get(target, propertyKey /* , receiver */) { $export($export.S, 'Reflect', { get: get }); -},{"./_an-object":102,"./_export":126,"./_has":135,"./_is-object":145,"./_object-gopd":165,"./_object-gpo":169}],305:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_has":128,"./_is-object":138,"./_object-gopd":158,"./_object-gpo":162}],298:[function(require,module,exports){ // 26.1.9 Reflect.has(target, propertyKey) var $export = require('./_export'); @@ -11180,7 +11068,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_export":126}],306:[function(require,module,exports){ +},{"./_export":119}],299:[function(require,module,exports){ // 26.1.10 Reflect.isExtensible(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -11193,13 +11081,13 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126}],307:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119}],300:[function(require,module,exports){ // 26.1.11 Reflect.ownKeys(target) var $export = require('./_export'); $export($export.S, 'Reflect', { ownKeys: require('./_own-keys') }); -},{"./_export":126,"./_own-keys":175}],308:[function(require,module,exports){ +},{"./_export":119,"./_own-keys":168}],301:[function(require,module,exports){ // 26.1.12 Reflect.preventExtensions(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -11217,7 +11105,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":102,"./_export":126}],309:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119}],302:[function(require,module,exports){ // 26.1.14 Reflect.setPrototypeOf(target, proto) var $export = require('./_export'); var setProto = require('./_set-proto'); @@ -11234,7 +11122,7 @@ if (setProto) $export($export.S, 'Reflect', { } }); -},{"./_export":126,"./_set-proto":186}],310:[function(require,module,exports){ +},{"./_export":119,"./_set-proto":179}],303:[function(require,module,exports){ // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) var dP = require('./_object-dp'); var gOPD = require('./_object-gopd'); @@ -11269,7 +11157,7 @@ function set(target, propertyKey, V /* , receiver */) { $export($export.S, 'Reflect', { set: set }); -},{"./_an-object":102,"./_export":126,"./_has":135,"./_is-object":145,"./_object-dp":163,"./_object-gopd":165,"./_object-gpo":169,"./_property-desc":180}],311:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_has":128,"./_is-object":138,"./_object-dp":156,"./_object-gopd":158,"./_object-gpo":162,"./_property-desc":173}],304:[function(require,module,exports){ var global = require('./_global'); var inheritIfRequired = require('./_inherit-if-required'); var dP = require('./_object-dp').f; @@ -11314,7 +11202,7 @@ if (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function ( require('./_set-species')('RegExp'); -},{"./_descriptors":122,"./_fails":128,"./_flags":130,"./_global":134,"./_inherit-if-required":139,"./_is-regexp":146,"./_object-dp":163,"./_object-gopn":167,"./_redefine":182,"./_set-species":187,"./_wks":216}],312:[function(require,module,exports){ +},{"./_descriptors":115,"./_fails":121,"./_flags":123,"./_global":127,"./_inherit-if-required":132,"./_is-regexp":139,"./_object-dp":156,"./_object-gopn":160,"./_redefine":175,"./_set-species":180,"./_wks":209}],305:[function(require,module,exports){ 'use strict'; var regexpExec = require('./_regexp-exec'); require('./_export')({ @@ -11325,14 +11213,14 @@ require('./_export')({ exec: regexpExec }); -},{"./_export":126,"./_regexp-exec":184}],313:[function(require,module,exports){ +},{"./_export":119,"./_regexp-exec":177}],306:[function(require,module,exports){ // 21.2.5.3 get RegExp.prototype.flags() if (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', { configurable: true, get: require('./_flags') }); -},{"./_descriptors":122,"./_flags":130,"./_object-dp":163}],314:[function(require,module,exports){ +},{"./_descriptors":115,"./_flags":123,"./_object-dp":156}],307:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11374,7 +11262,7 @@ require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCall ]; }); -},{"./_advance-string-index":100,"./_an-object":102,"./_fix-re-wks":129,"./_regexp-exec-abstract":183,"./_to-length":205}],315:[function(require,module,exports){ +},{"./_advance-string-index":93,"./_an-object":95,"./_fix-re-wks":122,"./_regexp-exec-abstract":176,"./_to-length":198}],308:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11494,7 +11382,7 @@ require('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, may } }); -},{"./_advance-string-index":100,"./_an-object":102,"./_fix-re-wks":129,"./_regexp-exec-abstract":183,"./_to-integer":203,"./_to-length":205,"./_to-object":206}],316:[function(require,module,exports){ +},{"./_advance-string-index":93,"./_an-object":95,"./_fix-re-wks":122,"./_regexp-exec-abstract":176,"./_to-integer":196,"./_to-length":198,"./_to-object":199}],309:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11527,7 +11415,7 @@ require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeC ]; }); -},{"./_an-object":102,"./_fix-re-wks":129,"./_regexp-exec-abstract":183,"./_same-value":185}],317:[function(require,module,exports){ +},{"./_an-object":95,"./_fix-re-wks":122,"./_regexp-exec-abstract":176,"./_same-value":178}],310:[function(require,module,exports){ 'use strict'; var isRegExp = require('./_is-regexp'); @@ -11663,7 +11551,7 @@ require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCall ]; }); -},{"./_advance-string-index":100,"./_an-object":102,"./_fails":128,"./_fix-re-wks":129,"./_is-regexp":146,"./_regexp-exec":184,"./_regexp-exec-abstract":183,"./_species-constructor":191,"./_to-length":205}],318:[function(require,module,exports){ +},{"./_advance-string-index":93,"./_an-object":95,"./_fails":121,"./_fix-re-wks":122,"./_is-regexp":139,"./_regexp-exec":177,"./_regexp-exec-abstract":176,"./_species-constructor":184,"./_to-length":198}],311:[function(require,module,exports){ 'use strict'; require('./es6.regexp.flags'); var anObject = require('./_an-object'); @@ -11690,7 +11578,7 @@ if (require('./_fails')(function () { return $toString.call({ source: 'a', flags }); } -},{"./_an-object":102,"./_descriptors":122,"./_fails":128,"./_flags":130,"./_redefine":182,"./es6.regexp.flags":313}],319:[function(require,module,exports){ +},{"./_an-object":95,"./_descriptors":115,"./_fails":121,"./_flags":123,"./_redefine":175,"./es6.regexp.flags":306}],312:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -11706,7 +11594,7 @@ module.exports = require('./_collection')(SET, function (get) { } }, strong); -},{"./_collection":115,"./_collection-strong":113,"./_validate-collection":213}],320:[function(require,module,exports){ +},{"./_collection":108,"./_collection-strong":106,"./_validate-collection":206}],313:[function(require,module,exports){ 'use strict'; // B.2.3.2 String.prototype.anchor(name) require('./_string-html')('anchor', function (createHTML) { @@ -11715,7 +11603,7 @@ require('./_string-html')('anchor', function (createHTML) { }; }); -},{"./_string-html":195}],321:[function(require,module,exports){ +},{"./_string-html":188}],314:[function(require,module,exports){ 'use strict'; // B.2.3.3 String.prototype.big() require('./_string-html')('big', function (createHTML) { @@ -11724,7 +11612,7 @@ require('./_string-html')('big', function (createHTML) { }; }); -},{"./_string-html":195}],322:[function(require,module,exports){ +},{"./_string-html":188}],315:[function(require,module,exports){ 'use strict'; // B.2.3.4 String.prototype.blink() require('./_string-html')('blink', function (createHTML) { @@ -11733,7 +11621,7 @@ require('./_string-html')('blink', function (createHTML) { }; }); -},{"./_string-html":195}],323:[function(require,module,exports){ +},{"./_string-html":188}],316:[function(require,module,exports){ 'use strict'; // B.2.3.5 String.prototype.bold() require('./_string-html')('bold', function (createHTML) { @@ -11742,7 +11630,7 @@ require('./_string-html')('bold', function (createHTML) { }; }); -},{"./_string-html":195}],324:[function(require,module,exports){ +},{"./_string-html":188}],317:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $at = require('./_string-at')(false); @@ -11753,7 +11641,7 @@ $export($export.P, 'String', { } }); -},{"./_export":126,"./_string-at":193}],325:[function(require,module,exports){ +},{"./_export":119,"./_string-at":186}],318:[function(require,module,exports){ // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) 'use strict'; var $export = require('./_export'); @@ -11775,7 +11663,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'Strin } }); -},{"./_export":126,"./_fails-is-regexp":127,"./_string-context":194,"./_to-length":205}],326:[function(require,module,exports){ +},{"./_export":119,"./_fails-is-regexp":120,"./_string-context":187,"./_to-length":198}],319:[function(require,module,exports){ 'use strict'; // B.2.3.6 String.prototype.fixed() require('./_string-html')('fixed', function (createHTML) { @@ -11784,7 +11672,7 @@ require('./_string-html')('fixed', function (createHTML) { }; }); -},{"./_string-html":195}],327:[function(require,module,exports){ +},{"./_string-html":188}],320:[function(require,module,exports){ 'use strict'; // B.2.3.7 String.prototype.fontcolor(color) require('./_string-html')('fontcolor', function (createHTML) { @@ -11793,7 +11681,7 @@ require('./_string-html')('fontcolor', function (createHTML) { }; }); -},{"./_string-html":195}],328:[function(require,module,exports){ +},{"./_string-html":188}],321:[function(require,module,exports){ 'use strict'; // B.2.3.8 String.prototype.fontsize(size) require('./_string-html')('fontsize', function (createHTML) { @@ -11802,7 +11690,7 @@ require('./_string-html')('fontsize', function (createHTML) { }; }); -},{"./_string-html":195}],329:[function(require,module,exports){ +},{"./_string-html":188}],322:[function(require,module,exports){ var $export = require('./_export'); var toAbsoluteIndex = require('./_to-absolute-index'); var fromCharCode = String.fromCharCode; @@ -11827,7 +11715,7 @@ $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1) } }); -},{"./_export":126,"./_to-absolute-index":201}],330:[function(require,module,exports){ +},{"./_export":119,"./_to-absolute-index":194}],323:[function(require,module,exports){ // 21.1.3.7 String.prototype.includes(searchString, position = 0) 'use strict'; var $export = require('./_export'); @@ -11841,7 +11729,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String } }); -},{"./_export":126,"./_fails-is-regexp":127,"./_string-context":194}],331:[function(require,module,exports){ +},{"./_export":119,"./_fails-is-regexp":120,"./_string-context":187}],324:[function(require,module,exports){ 'use strict'; // B.2.3.9 String.prototype.italics() require('./_string-html')('italics', function (createHTML) { @@ -11850,7 +11738,7 @@ require('./_string-html')('italics', function (createHTML) { }; }); -},{"./_string-html":195}],332:[function(require,module,exports){ +},{"./_string-html":188}],325:[function(require,module,exports){ 'use strict'; var $at = require('./_string-at')(true); @@ -11869,7 +11757,7 @@ require('./_iter-define')(String, 'String', function (iterated) { return { value: point, done: false }; }); -},{"./_iter-define":149,"./_string-at":193}],333:[function(require,module,exports){ +},{"./_iter-define":142,"./_string-at":186}],326:[function(require,module,exports){ 'use strict'; // B.2.3.10 String.prototype.link(url) require('./_string-html')('link', function (createHTML) { @@ -11878,7 +11766,7 @@ require('./_string-html')('link', function (createHTML) { }; }); -},{"./_string-html":195}],334:[function(require,module,exports){ +},{"./_string-html":188}],327:[function(require,module,exports){ var $export = require('./_export'); var toIObject = require('./_to-iobject'); var toLength = require('./_to-length'); @@ -11898,7 +11786,7 @@ $export($export.S, 'String', { } }); -},{"./_export":126,"./_to-iobject":204,"./_to-length":205}],335:[function(require,module,exports){ +},{"./_export":119,"./_to-iobject":197,"./_to-length":198}],328:[function(require,module,exports){ var $export = require('./_export'); $export($export.P, 'String', { @@ -11906,7 +11794,7 @@ $export($export.P, 'String', { repeat: require('./_string-repeat') }); -},{"./_export":126,"./_string-repeat":197}],336:[function(require,module,exports){ +},{"./_export":119,"./_string-repeat":190}],329:[function(require,module,exports){ 'use strict'; // B.2.3.11 String.prototype.small() require('./_string-html')('small', function (createHTML) { @@ -11915,7 +11803,7 @@ require('./_string-html')('small', function (createHTML) { }; }); -},{"./_string-html":195}],337:[function(require,module,exports){ +},{"./_string-html":188}],330:[function(require,module,exports){ // 21.1.3.18 String.prototype.startsWith(searchString [, position ]) 'use strict'; var $export = require('./_export'); @@ -11935,7 +11823,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'Str } }); -},{"./_export":126,"./_fails-is-regexp":127,"./_string-context":194,"./_to-length":205}],338:[function(require,module,exports){ +},{"./_export":119,"./_fails-is-regexp":120,"./_string-context":187,"./_to-length":198}],331:[function(require,module,exports){ 'use strict'; // B.2.3.12 String.prototype.strike() require('./_string-html')('strike', function (createHTML) { @@ -11944,7 +11832,7 @@ require('./_string-html')('strike', function (createHTML) { }; }); -},{"./_string-html":195}],339:[function(require,module,exports){ +},{"./_string-html":188}],332:[function(require,module,exports){ 'use strict'; // B.2.3.13 String.prototype.sub() require('./_string-html')('sub', function (createHTML) { @@ -11953,7 +11841,7 @@ require('./_string-html')('sub', function (createHTML) { }; }); -},{"./_string-html":195}],340:[function(require,module,exports){ +},{"./_string-html":188}],333:[function(require,module,exports){ 'use strict'; // B.2.3.14 String.prototype.sup() require('./_string-html')('sup', function (createHTML) { @@ -11962,7 +11850,7 @@ require('./_string-html')('sup', function (createHTML) { }; }); -},{"./_string-html":195}],341:[function(require,module,exports){ +},{"./_string-html":188}],334:[function(require,module,exports){ 'use strict'; // 21.1.3.25 String.prototype.trim() require('./_string-trim')('trim', function ($trim) { @@ -11971,7 +11859,7 @@ require('./_string-trim')('trim', function ($trim) { }; }); -},{"./_string-trim":198}],342:[function(require,module,exports){ +},{"./_string-trim":191}],335:[function(require,module,exports){ 'use strict'; // ECMAScript 6 symbols shim var global = require('./_global'); @@ -12219,7 +12107,7 @@ setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] setToStringTag(global.JSON, 'JSON', true); -},{"./_an-object":102,"./_descriptors":122,"./_enum-keys":125,"./_export":126,"./_fails":128,"./_global":134,"./_has":135,"./_hide":136,"./_is-array":143,"./_is-object":145,"./_library":153,"./_meta":158,"./_object-create":162,"./_object-dp":163,"./_object-gopd":165,"./_object-gopn":167,"./_object-gopn-ext":166,"./_object-gops":168,"./_object-keys":171,"./_object-pie":172,"./_property-desc":180,"./_redefine":182,"./_set-to-string-tag":188,"./_shared":190,"./_to-iobject":204,"./_to-object":206,"./_to-primitive":207,"./_uid":211,"./_wks":216,"./_wks-define":214,"./_wks-ext":215}],343:[function(require,module,exports){ +},{"./_an-object":95,"./_descriptors":115,"./_enum-keys":118,"./_export":119,"./_fails":121,"./_global":127,"./_has":128,"./_hide":129,"./_is-array":136,"./_is-object":138,"./_library":146,"./_meta":151,"./_object-create":155,"./_object-dp":156,"./_object-gopd":158,"./_object-gopn":160,"./_object-gopn-ext":159,"./_object-gops":161,"./_object-keys":164,"./_object-pie":165,"./_property-desc":173,"./_redefine":175,"./_set-to-string-tag":181,"./_shared":183,"./_to-iobject":197,"./_to-object":199,"./_to-primitive":200,"./_uid":204,"./_wks":209,"./_wks-define":207,"./_wks-ext":208}],336:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $typed = require('./_typed'); @@ -12267,76 +12155,76 @@ $export($export.P + $export.U + $export.F * require('./_fails')(function () { require('./_set-species')(ARRAY_BUFFER); -},{"./_an-object":102,"./_export":126,"./_fails":128,"./_global":134,"./_is-object":145,"./_set-species":187,"./_species-constructor":191,"./_to-absolute-index":201,"./_to-length":205,"./_typed":210,"./_typed-buffer":209}],344:[function(require,module,exports){ +},{"./_an-object":95,"./_export":119,"./_fails":121,"./_global":127,"./_is-object":138,"./_set-species":180,"./_species-constructor":184,"./_to-absolute-index":194,"./_to-length":198,"./_typed":203,"./_typed-buffer":202}],337:[function(require,module,exports){ var $export = require('./_export'); $export($export.G + $export.W + $export.F * !require('./_typed').ABV, { DataView: require('./_typed-buffer').DataView }); -},{"./_export":126,"./_typed":210,"./_typed-buffer":209}],345:[function(require,module,exports){ +},{"./_export":119,"./_typed":203,"./_typed-buffer":202}],338:[function(require,module,exports){ require('./_typed-array')('Float32', 4, function (init) { return function Float32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],346:[function(require,module,exports){ +},{"./_typed-array":201}],339:[function(require,module,exports){ require('./_typed-array')('Float64', 8, function (init) { return function Float64Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],347:[function(require,module,exports){ +},{"./_typed-array":201}],340:[function(require,module,exports){ require('./_typed-array')('Int16', 2, function (init) { return function Int16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],348:[function(require,module,exports){ +},{"./_typed-array":201}],341:[function(require,module,exports){ require('./_typed-array')('Int32', 4, function (init) { return function Int32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],349:[function(require,module,exports){ +},{"./_typed-array":201}],342:[function(require,module,exports){ require('./_typed-array')('Int8', 1, function (init) { return function Int8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],350:[function(require,module,exports){ +},{"./_typed-array":201}],343:[function(require,module,exports){ require('./_typed-array')('Uint16', 2, function (init) { return function Uint16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],351:[function(require,module,exports){ +},{"./_typed-array":201}],344:[function(require,module,exports){ require('./_typed-array')('Uint32', 4, function (init) { return function Uint32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],352:[function(require,module,exports){ +},{"./_typed-array":201}],345:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":208}],353:[function(require,module,exports){ +},{"./_typed-array":201}],346:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8ClampedArray(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }, true); -},{"./_typed-array":208}],354:[function(require,module,exports){ +},{"./_typed-array":201}],347:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var each = require('./_array-methods')(0); @@ -12398,7 +12286,7 @@ if (NATIVE_WEAK_MAP && IS_IE11) { }); } -},{"./_array-methods":106,"./_collection":115,"./_collection-weak":114,"./_global":134,"./_is-object":145,"./_meta":158,"./_object-assign":161,"./_redefine":182,"./_validate-collection":213}],355:[function(require,module,exports){ +},{"./_array-methods":99,"./_collection":108,"./_collection-weak":107,"./_global":127,"./_is-object":138,"./_meta":151,"./_object-assign":154,"./_redefine":175,"./_validate-collection":206}],348:[function(require,module,exports){ 'use strict'; var weak = require('./_collection-weak'); var validate = require('./_validate-collection'); @@ -12414,7 +12302,7 @@ require('./_collection')(WEAK_SET, function (get) { } }, weak, false, true); -},{"./_collection":115,"./_collection-weak":114,"./_validate-collection":213}],356:[function(require,module,exports){ +},{"./_collection":108,"./_collection-weak":107,"./_validate-collection":206}],349:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap var $export = require('./_export'); @@ -12438,7 +12326,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('flatMap'); -},{"./_a-function":97,"./_add-to-unscopables":99,"./_array-species-create":109,"./_export":126,"./_flatten-into-array":131,"./_to-length":205,"./_to-object":206}],357:[function(require,module,exports){ +},{"./_a-function":90,"./_add-to-unscopables":92,"./_array-species-create":102,"./_export":119,"./_flatten-into-array":124,"./_to-length":198,"./_to-object":199}],350:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/Array.prototype.includes var $export = require('./_export'); @@ -12452,7 +12340,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('includes'); -},{"./_add-to-unscopables":99,"./_array-includes":105,"./_export":126}],358:[function(require,module,exports){ +},{"./_add-to-unscopables":92,"./_array-includes":98,"./_export":119}],351:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $entries = require('./_object-to-array')(true); @@ -12463,7 +12351,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":126,"./_object-to-array":174}],359:[function(require,module,exports){ +},{"./_export":119,"./_object-to-array":167}],352:[function(require,module,exports){ // https://github.com/tc39/proposal-object-getownpropertydescriptors var $export = require('./_export'); var ownKeys = require('./_own-keys'); @@ -12487,7 +12375,7 @@ $export($export.S, 'Object', { } }); -},{"./_create-property":117,"./_export":126,"./_object-gopd":165,"./_own-keys":175,"./_to-iobject":204}],360:[function(require,module,exports){ +},{"./_create-property":110,"./_export":119,"./_object-gopd":158,"./_own-keys":168,"./_to-iobject":197}],353:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $values = require('./_object-to-array')(false); @@ -12498,7 +12386,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":126,"./_object-to-array":174}],361:[function(require,module,exports){ +},{"./_export":119,"./_object-to-array":167}],354:[function(require,module,exports){ // https://github.com/tc39/proposal-promise-finally 'use strict'; var $export = require('./_export'); @@ -12520,7 +12408,7 @@ $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { ); } }); -},{"./_core":116,"./_export":126,"./_global":134,"./_promise-resolve":179,"./_species-constructor":191}],362:[function(require,module,exports){ +},{"./_core":109,"./_export":119,"./_global":127,"./_promise-resolve":172,"./_species-constructor":184}],355:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -12536,7 +12424,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":126,"./_string-pad":196,"./_user-agent":212}],363:[function(require,module,exports){ +},{"./_export":119,"./_string-pad":189,"./_user-agent":205}],356:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -12552,7 +12440,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":126,"./_string-pad":196,"./_user-agent":212}],364:[function(require,module,exports){ +},{"./_export":119,"./_string-pad":189,"./_user-agent":205}],357:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimLeft', function ($trim) { @@ -12561,7 +12449,7 @@ require('./_string-trim')('trimLeft', function ($trim) { }; }, 'trimStart'); -},{"./_string-trim":198}],365:[function(require,module,exports){ +},{"./_string-trim":191}],358:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimRight', function ($trim) { @@ -12570,10 +12458,10 @@ require('./_string-trim')('trimRight', function ($trim) { }; }, 'trimEnd'); -},{"./_string-trim":198}],366:[function(require,module,exports){ +},{"./_string-trim":191}],359:[function(require,module,exports){ require('./_wks-define')('asyncIterator'); -},{"./_wks-define":214}],367:[function(require,module,exports){ +},{"./_wks-define":207}],360:[function(require,module,exports){ var $iterators = require('./es6.array.iterator'); var getKeys = require('./_object-keys'); var redefine = require('./_redefine'); @@ -12633,7 +12521,7 @@ for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++ } } -},{"./_global":134,"./_hide":136,"./_iterators":152,"./_object-keys":171,"./_redefine":182,"./_wks":216,"./es6.array.iterator":228}],368:[function(require,module,exports){ +},{"./_global":127,"./_hide":129,"./_iterators":145,"./_object-keys":164,"./_redefine":175,"./_wks":209,"./es6.array.iterator":221}],361:[function(require,module,exports){ var $export = require('./_export'); var $task = require('./_task'); $export($export.G + $export.B, { @@ -12641,7 +12529,7 @@ $export($export.G + $export.B, { clearImmediate: $task.clear }); -},{"./_export":126,"./_task":200}],369:[function(require,module,exports){ +},{"./_export":119,"./_task":193}],362:[function(require,module,exports){ // ie9- setTimeout & setInterval additional parameters fix var global = require('./_global'); var $export = require('./_export'); @@ -12663,10625 +12551,10391 @@ $export($export.G + $export.B + $export.F * MSIE, { setInterval: wrap(global.setInterval) }); -},{"./_export":126,"./_global":134,"./_user-agent":212}],370:[function(require,module,exports){ +},{"./_export":119,"./_global":127,"./_user-agent":205}],363:[function(require,module,exports){ require('../modules/web.timers'); require('../modules/web.immediate'); require('../modules/web.dom.iterable'); module.exports = require('../modules/_core'); -},{"../modules/_core":116,"../modules/web.dom.iterable":367,"../modules/web.immediate":368,"../modules/web.timers":369}],371:[function(require,module,exports){ -'use strict'; - -var assign = require('object.assign'); -var callBound = require('call-bind/callBound'); -var flags = require('regexp.prototype.flags'); -var GetIntrinsic = require('get-intrinsic'); -var getIterator = require('es-get-iterator'); -var getSideChannel = require('side-channel'); -var is = require('object-is'); -var isArguments = require('is-arguments'); -var isArray = require('isarray'); -var isArrayBuffer = require('is-array-buffer'); -var isDate = require('is-date-object'); -var isRegex = require('is-regex'); -var isSharedArrayBuffer = require('is-shared-array-buffer'); -var objectKeys = require('object-keys'); -var whichBoxedPrimitive = require('which-boxed-primitive'); -var whichCollection = require('which-collection'); -var whichTypedArray = require('which-typed-array'); -var byteLength = require('array-buffer-byte-length'); - -var sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); - -var $getTime = callBound('Date.prototype.getTime'); -var gPO = Object.getPrototypeOf; -var $objToString = callBound('Object.prototype.toString'); +},{"../modules/_core":109,"../modules/web.dom.iterable":360,"../modules/web.immediate":361,"../modules/web.timers":362}],364:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-env browser */ -var $Set = GetIntrinsic('%Set%', true); -var $mapHas = callBound('Map.prototype.has', true); -var $mapGet = callBound('Map.prototype.get', true); -var $mapSize = callBound('Map.prototype.size', true); -var $setAdd = callBound('Set.prototype.add', true); -var $setDelete = callBound('Set.prototype.delete', true); -var $setHas = callBound('Set.prototype.has', true); -var $setSize = callBound('Set.prototype.size', true); +/** + * This is the web browser implementation of `debug()`. + */ -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414 -function setHasEqualElement(set, val1, opts, channel) { - var i = getIterator(set); - var result; - while ((result = i.next()) && !result.done) { - if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define - // Remove the matching element to make sure we do not check that again. - $setDelete(set, result.value); - return true; - } - } +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; - return false; -} + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439 -function findLooseMatchingPrimitives(prim) { - if (typeof prim === 'undefined') { - return null; - } - if (typeof prim === 'object') { // Only pass in null as object! - return void 0; - } - if (typeof prim === 'symbol') { - return false; - } - if (typeof prim === 'string' || typeof prim === 'number') { - // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN. - return +prim === +prim; // eslint-disable-line no-implicit-coercion - } - return true; -} +/** + * Colors. + */ -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460 -function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) { - var altValue = findLooseMatchingPrimitives(prim); - if (altValue != null) { - return altValue; - } - var curB = $mapGet(b, altValue); - var looseOpts = assign({}, opts, { strict: false }); - if ( - (typeof curB === 'undefined' && !$mapHas(b, altValue)) - // eslint-disable-next-line no-use-before-define - || !internalDeepEqual(item, curB, looseOpts, channel) - ) { - return false; - } - // eslint-disable-next-line no-use-before-define - return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel); -} +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447 -function setMightHaveLoosePrim(a, b, prim) { - var altValue = findLooseMatchingPrimitives(prim); - if (altValue != null) { - return altValue; - } +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ - return $setHas(b, altValue) && !$setHas(a, altValue); -} +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533 -function mapHasEqualEntry(set, map, key1, item1, opts, channel) { - var i = getIterator(set); - var result; - var key2; - while ((result = i.next()) && !result.done) { - key2 = result.value; - if ( - // eslint-disable-next-line no-use-before-define - internalDeepEqual(key1, key2, opts, channel) - // eslint-disable-next-line no-use-before-define - && internalDeepEqual(item1, $mapGet(map, key2), opts, channel) - ) { - $setDelete(set, key2); - return true; - } - } + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } - return false; + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } -function internalDeepEqual(actual, expected, options, channel) { - var opts = options || {}; - - // 7.1. All identical values are equivalent, as determined by ===. - if (opts.strict ? is(actual, expected) : actual === expected) { - return true; - } +/** + * Colorize log arguments if enabled. + * + * @api public + */ - var actualBoxed = whichBoxedPrimitive(actual); - var expectedBoxed = whichBoxedPrimitive(expected); - if (actualBoxed !== expectedBoxed) { - return false; - } +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); - // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==. - if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) { - return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq - } + if (!this.useColors) { + return; + } - /* - * 7.4. 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. - */ - // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); - var hasActual = channel.has(actual); - var hasExpected = channel.has(expected); - var sentinel; - if (hasActual && hasExpected) { - if (channel.get(actual) === channel.get(expected)) { - return true; - } - } else { - sentinel = {}; - } - if (!hasActual) { channel.set(actual, sentinel); } - if (!hasExpected) { channel.set(expected, sentinel); } + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); - // eslint-disable-next-line no-use-before-define - return objEquiv(actual, expected, opts, channel); + args.splice(lastC, 0, c); } -function isBuffer(x) { - if (!x || typeof x !== 'object' || typeof x.length !== 'number') { - return false; - } - if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { - return false; - } - if (x.length > 0 && typeof x[0] !== 'number') { - return false; - } +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); - return !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x)); +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } -function setEquiv(a, b, opts, channel) { - if ($setSize(a) !== $setSize(b)) { - return false; - } - var iA = getIterator(a); - var iB = getIterator(b); - var resultA; - var resultB; - var set; - while ((resultA = iA.next()) && !resultA.done) { - if (resultA.value && typeof resultA.value === 'object') { - if (!set) { set = new $Set(); } - $setAdd(set, resultA.value); - } else if (!$setHas(b, resultA.value)) { - if (opts.strict) { return false; } - if (!setMightHaveLoosePrim(a, b, resultA.value)) { - return false; - } - if (!set) { set = new $Set(); } - $setAdd(set, resultA.value); - } - } - if (set) { - while ((resultB = iB.next()) && !resultB.done) { - // We have to check if a primitive value is already matching and only if it's not, go hunting for it. - if (resultB.value && typeof resultB.value === 'object') { - if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) { - return false; - } - } else if ( - !opts.strict - && !$setHas(a, resultB.value) - && !setHasEqualElement(set, resultB.value, opts.strict, channel) - ) { - return false; - } - } - return $setSize(set) === 0; - } - return true; +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; } -function mapEquiv(a, b, opts, channel) { - if ($mapSize(a) !== $mapSize(b)) { - return false; - } - var iA = getIterator(a); - var iB = getIterator(b); - var resultA; - var resultB; - var set; - var key; - var item1; - var item2; - while ((resultA = iA.next()) && !resultA.done) { - key = resultA.value[0]; - item1 = resultA.value[1]; - if (key && typeof key === 'object') { - if (!set) { set = new $Set(); } - $setAdd(set, key); - } else { - item2 = $mapGet(b, key); - if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) { - if (opts.strict) { - return false; - } - if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) { - return false; - } - if (!set) { set = new $Set(); } - $setAdd(set, key); - } - } - } +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ - if (set) { - while ((resultB = iB.next()) && !resultB.done) { - key = resultB.value[0]; - item2 = resultB.value[1]; - if (key && typeof key === 'object') { - if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) { - return false; - } - } else if ( - !opts.strict - && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel)) - && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel) - ) { - return false; - } - } - return $setSize(set) === 0; - } - return true; +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } -function objEquiv(a, b, opts, channel) { - /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5], max-lines: [2, 400] */ - var i, key; +module.exports = require('./common')(exports); - if (typeof a !== typeof b) { return false; } - if (a == null || b == null) { return false; } +const {formatters} = module.exports; - if ($objToString(a) !== $objToString(b)) { return false; } +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ - if (isArguments(a) !== isArguments(b)) { return false; } +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } +}; - var aIsArray = isArray(a); - var bIsArray = isArray(b); - if (aIsArray !== bIsArray) { return false; } +}).call(this)}).call(this,require('_process')) +},{"./common":365,"_process":487}],365:[function(require,module,exports){ - // TODO: replace when a cross-realm brand check is available - var aIsError = a instanceof Error; - var bIsError = b instanceof Error; - if (aIsError !== bIsError) { return false; } - if (aIsError || bIsError) { - if (a.name !== b.name || a.message !== b.message) { return false; } - } +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - var aIsRegex = isRegex(a); - var bIsRegex = isRegex(b); - if (aIsRegex !== bIsRegex) { return false; } - if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) { - return false; - } +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + createDebug.destroy = destroy; - var aIsDate = isDate(a); - var bIsDate = isDate(b); - if (aIsDate !== bIsDate) { return false; } - if (aIsDate || bIsDate) { // && would work too, because both are true or both false here - if ($getTime(a) !== $getTime(b)) { return false; } - } - if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; } + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); - var aWhich = whichTypedArray(a); - var bWhich = whichTypedArray(b); - if (aWhich !== bWhich) { - return false; - } - if (aWhich || bWhich) { // && would work too, because both are true or both false here - if (a.length !== b.length) { return false; } - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { return false; } - } - return true; - } + /** + * The currently active debug mode names, and names to skip. + */ - var aIsBuffer = isBuffer(a); - var bIsBuffer = isBuffer(b); - if (aIsBuffer !== bIsBuffer) { return false; } - if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here - if (a.length !== b.length) { return false; } - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { return false; } - } - return true; - } + createDebug.names = []; + createDebug.skips = []; - var aIsArrayBuffer = isArrayBuffer(a); - var bIsArrayBuffer = isArrayBuffer(b); - if (aIsArrayBuffer !== bIsArrayBuffer) { return false; } - if (aIsArrayBuffer || bIsArrayBuffer) { // && would work too, because both are true or both false here - if (byteLength(a) !== byteLength(b)) { return false; } - return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); - } + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; - var aIsSAB = isSharedArrayBuffer(a); - var bIsSAB = isSharedArrayBuffer(b); - if (aIsSAB !== bIsSAB) { return false; } - if (aIsSAB || bIsSAB) { // && would work too, because both are true or both false here - if (sabByteLength(a) !== sabByteLength(b)) { return false; } - return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); - } + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; - if (typeof a !== typeof b) { return false; } + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } - var ka = objectKeys(a); - var kb = objectKeys(b); - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (ka.length !== kb.length) { return false; } + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; - // 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; } // eslint-disable-line eqeqeq - } - - // equivalent values for every corresponding key, and ~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; } - } + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; - var aCollection = whichCollection(a); - var bCollection = whichCollection(b); - if (aCollection !== bCollection) { - return false; - } - if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection - return setEquiv(a, b, opts, channel); - } - if (aCollection === 'Map') { // aCollection === bCollection - return mapEquiv(a, b, opts, channel); - } + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } - return true; -} + const self = debug; -module.exports = function deepEqual(a, b, opts) { - return internalDeepEqual(a, b, opts, getSideChannel()); -}; + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; -},{"array-buffer-byte-length":33,"call-bind/callBound":63,"es-get-iterator":422,"get-intrinsic":430,"is-arguments":458,"is-array-buffer":459,"is-date-object":463,"is-regex":467,"is-shared-array-buffer":469,"isarray":474,"object-is":493,"object-keys":497,"object.assign":500,"regexp.prototype.flags":509,"side-channel":518,"which-boxed-primitive":533,"which-collection":534,"which-typed-array":535}],372:[function(require,module,exports){ -'use strict'; + args[0] = createDebug.coerce(args[0]); -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) - && !isSpecial(value) -}; + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } -function isNonNullObject(value) { - return !!value && typeof value === 'object' -} + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); - return stringValue === '[object RegExp]' - || stringValue === '[object Date]' - || isReactElement(value) -} + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE -} + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. -function emptyTarget(val) { - return Array.isArray(val) ? [] : {} -} + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } -function cloneUnlessOtherwiseSpecified(value, options) { - return (options.clone !== false && options.isMergeableObject(value)) - ? deepmerge(emptyTarget(value), value, options) - : value -} + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options) - }) -} + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } -function getMergeFunction(key, options) { - if (!options.customMerge) { - return deepmerge + return debug; } - var customMerge = options.customMerge(key); - return typeof customMerge === 'function' ? customMerge : deepmerge -} - -function getEnumerableOwnPropertySymbols(target) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return Object.propertyIsEnumerable.call(target, symbol) - }) - : [] -} - -function getKeys(target) { - return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) -} -function propertyIsOnObject(object, property) { - try { - return property in object - } catch(_) { - return false + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; } -} -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { - return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. -} + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) { - getKeys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); - } - getKeys(source).forEach(function(key) { - if (propertyIsUnsafe(target, key)) { - return - } + createDebug.names = []; + createDebug.skips = []; - if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { - destination[key] = getMergeFunction(key, options)(target[key], source[key], options); - } else { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } - }); - return destination -} + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() - // implementations can use it. The caller may not replace it. - options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; + namespaces = split[i].replace(/\*/g, '.*?'); - if (!sourceAndTargetTypesMatch) { - return cloneUnlessOtherwiseSpecified(source, options) - } else if (sourceIsArray) { - return options.arrayMerge(target, source, options) - } else { - return mergeObject(target, source, options) + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } } -} -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) { - throw new Error('first argument should be an array') + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; } - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options) - }, {}) -}; - -var deepmerge_1 = deepmerge; - -module.exports = deepmerge_1; - -},{}],373:[function(require,module,exports){ -'use strict'; + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } -var $defineProperty = require('es-define-property'); + let i; + let len; -var $SyntaxError = require('es-errors/syntax'); -var $TypeError = require('es-errors/type'); + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } -var gopd = require('gopd'); + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } -/** @type {import('.')} */ -module.exports = function defineDataProperty( - obj, - property, - value -) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new $TypeError('`obj` must be an object or a function`'); - } - if (typeof property !== 'string' && typeof property !== 'symbol') { - throw new $TypeError('`property` must be a string or a symbol`'); - } - if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { - throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); - } - if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { - throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); - } - if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { - throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); - } - if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { - throw new $TypeError('`loose`, if provided, must be a boolean'); + return false; } - var nonEnumerable = arguments.length > 3 ? arguments[3] : null; - var nonWritable = arguments.length > 4 ? arguments[4] : null; - var nonConfigurable = arguments.length > 5 ? arguments[5] : null; - var loose = arguments.length > 6 ? arguments[6] : false; - - /* @type {false | TypedPropertyDescriptor} */ - var desc = !!gopd && gopd(obj, property); - - if ($defineProperty) { - $defineProperty(obj, property, { - configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, - enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, - value: value, - writable: nonWritable === null && desc ? desc.writable : !nonWritable - }); - } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { - // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable - obj[property] = value; // eslint-disable-line no-param-reassign - } else { - throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); } -}; - -},{"es-define-property":414,"es-errors/syntax":419,"es-errors/type":420,"gopd":435}],374:[function(require,module,exports){ -'use strict'; - -var keys = require('object-keys'); -var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; -var toStr = Object.prototype.toString; -var concat = Array.prototype.concat; -var defineDataProperty = require('define-data-property'); - -var isFunction = function (fn) { - return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; -}; - -var supportsDescriptors = require('has-property-descriptors')(); - -var defineProperty = function (object, name, value, predicate) { - if (name in object) { - if (predicate === true) { - if (object[name] === value) { - return; - } - } else if (!isFunction(predicate) || !predicate()) { - return; + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; } + return val; } - if (supportsDescriptors) { - defineDataProperty(object, name, value, true); - } else { - defineDataProperty(object, name, value); + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } -}; -var defineProperties = function (object, map) { - var predicates = arguments.length > 2 ? arguments[2] : {}; - var props = keys(map); - if (hasSymbols) { - props = concat.call(props, Object.getOwnPropertySymbols(map)); - } - for (var i = 0; i < props.length; i += 1) { - defineProperty(object, props[i], map[props[i]], predicates[props[i]]); - } -}; + createDebug.enable(createDebug.load()); -defineProperties.supportsDescriptors = !!supportsDescriptors; + return createDebug; +} -module.exports = defineProperties; +module.exports = setup; -},{"define-data-property":373,"has-property-descriptors":437,"object-keys":497}],375:[function(require,module,exports){ +},{"ms":471}],366:[function(require,module,exports){ 'use strict'; -var callBind = require('call-bind-apply-helpers'); -var gOPD = require('gopd'); +var assign = require('object.assign'); +var callBound = require('call-bind/callBound'); +var flags = require('regexp.prototype.flags'); +var GetIntrinsic = require('get-intrinsic'); +var getIterator = require('es-get-iterator'); +var getSideChannel = require('side-channel'); +var is = require('object-is'); +var isArguments = require('is-arguments'); +var isArray = require('isarray'); +var isArrayBuffer = require('is-array-buffer'); +var isDate = require('is-date-object'); +var isRegex = require('is-regex'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var objectKeys = require('object-keys'); +var whichBoxedPrimitive = require('which-boxed-primitive'); +var whichCollection = require('which-collection'); +var whichTypedArray = require('which-typed-array'); +var byteLength = require('array-buffer-byte-length'); -var hasProtoAccessor; -try { - // eslint-disable-next-line no-extra-parens, no-proto - hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype; -} catch (e) { - if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') { - throw e; - } -} +var sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); -// eslint-disable-next-line no-extra-parens -var desc = !!hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__')); +var $getTime = callBound('Date.prototype.getTime'); +var gPO = Object.getPrototypeOf; +var $objToString = callBound('Object.prototype.toString'); -var $Object = Object; -var $getPrototypeOf = $Object.getPrototypeOf; - -/** @type {import('./get')} */ -module.exports = desc && typeof desc.get === 'function' - ? callBind([desc.get]) - : typeof $getPrototypeOf === 'function' - ? /** @type {import('./get')} */ function getDunder(value) { - // eslint-disable-next-line eqeqeq - return $getPrototypeOf(value == null ? value : $Object(value)); - } - : false; +var $Set = GetIntrinsic('%Set%', true); +var $mapHas = callBound('Map.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSize = callBound('Map.prototype.size', true); +var $setAdd = callBound('Set.prototype.add', true); +var $setDelete = callBound('Set.prototype.delete', true); +var $setHas = callBound('Set.prototype.has', true); +var $setSize = callBound('Set.prototype.size', true); -},{"call-bind-apply-helpers":61,"gopd":435}],376:[function(require,module,exports){ -'use strict'; +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414 +function setHasEqualElement(set, val1, opts, channel) { + var i = getIterator(set); + var result; + while ((result = i.next()) && !result.done) { + if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define + // Remove the matching element to make sure we do not check that again. + $setDelete(set, result.value); + return true; + } + } -var elliptic = exports; + return false; +} -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'); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439 +function findLooseMatchingPrimitives(prim) { + if (typeof prim === 'undefined') { + return null; + } + if (typeof prim === 'object') { // Only pass in null as object! + return void 0; + } + if (typeof prim === 'symbol') { + return false; + } + if (typeof prim === 'string' || typeof prim === 'number') { + // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN. + return +prim === +prim; // eslint-disable-line no-implicit-coercion + } + return true; +} -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460 +function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } + var curB = $mapGet(b, altValue); + var looseOpts = assign({}, opts, { strict: false }); + if ( + (typeof curB === 'undefined' && !$mapHas(b, altValue)) + // eslint-disable-next-line no-use-before-define + || !internalDeepEqual(item, curB, looseOpts, channel) + ) { + return false; + } + // eslint-disable-next-line no-use-before-define + return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel); +} -},{"../package.json":392,"./elliptic/curve":379,"./elliptic/curves":382,"./elliptic/ec":383,"./elliptic/eddsa":386,"./elliptic/utils":390,"brorand":54}],377:[function(require,module,exports){ -'use strict'; +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447 +function setMightHaveLoosePrim(a, b, prim) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } -var BN = require('bn.js'); -var utils = require('../utils'); -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; + return $setHas(b, altValue) && !$setHas(a, altValue); +} -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533 +function mapHasEqualEntry(set, map, key1, item1, opts, channel) { + var i = getIterator(set); + var result; + var key2; + while ((result = i.next()) && !result.done) { + key2 = result.value; + if ( + // eslint-disable-next-line no-use-before-define + internalDeepEqual(key1, key2, opts, channel) + // eslint-disable-next-line no-use-before-define + && internalDeepEqual(item1, $mapGet(map, key2), opts, channel) + ) { + $setDelete(set, key2); + return true; + } + } - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + return false; +} - // 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); +function internalDeepEqual(actual, expected, options, channel) { + var opts = options || {}; - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + // 7.1. All identical values are equivalent, as determined by ===. + if (opts.strict ? is(actual, expected) : actual === expected) { + return true; + } - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + var actualBoxed = whichBoxedPrimitive(actual); + var expectedBoxed = whichBoxedPrimitive(expected); + if (actualBoxed !== expectedBoxed) { + return false; + } - this._bitLength = this.n ? this.n.bitLength() : 0; + // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==. + if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) { + return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq + } - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; + /* + * 7.4. 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. + */ + // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration + + var hasActual = channel.has(actual); + var hasExpected = channel.has(expected); + var sentinel; + if (hasActual && hasExpected) { + if (channel.get(actual) === channel.get(expected)) { + return true; + } } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); + sentinel = {}; } -} -module.exports = BaseCurve; + if (!hasActual) { channel.set(actual, sentinel); } + if (!hasExpected) { channel.set(expected, sentinel); } -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; + // eslint-disable-next-line no-use-before-define + return objEquiv(actual, expected, opts, channel); +} -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; +function isBuffer(x) { + if (!x || typeof x !== 'object' || typeof x.length !== 'number') { + return false; + } + if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { + return false; + } + if (x.length > 0 && typeof x[0] !== 'number') { + return false; + } -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); + return !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x)); +} - var naf = getNAF(k, 1, this._bitLength); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; +function setEquiv(a, b, opts, channel) { + if ($setSize(a) !== $setSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + while ((resultA = iA.next()) && !resultA.done) { + if (resultA.value && typeof resultA.value === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } else if (!$setHas(b, resultA.value)) { + if (opts.strict) { return false; } + if (!setMightHaveLoosePrim(a, b, resultA.value)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } + } + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + // We have to check if a primitive value is already matching and only if it's not, go hunting for it. + if (resultB.value && typeof resultB.value === 'object') { + if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) { + return false; + } + } else if ( + !opts.strict + && !$setHas(a, resultB.value) + && !setHasEqualElement(set, resultB.value, opts.strict, channel) + ) { + return false; + } + } + return $setSize(set) === 0; + } + return true; +} - // 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); +function mapEquiv(a, b, opts, channel) { + if ($mapSize(a) !== $mapSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + var key; + var item1; + var item2; + while ((resultA = iA.next()) && !resultA.done) { + key = resultA.value[0]; + item1 = resultA.value[1]; + if (key && typeof key === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, key); + } else { + item2 = $mapGet(b, key); + if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) { + if (opts.strict) { + return false; + } + if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, key); + } + } } - 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()); + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + key = resultB.value[0]; + item2 = resultB.value[1]; + if (key && typeof key === 'object') { + if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) { + return false; + } + } else if ( + !opts.strict + && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel)) + && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel) + ) { + return false; + } } - a = a.add(b); + return $setSize(set) === 0; } - return a.toP(); -}; + return true; +} -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; +function objEquiv(a, b, opts, channel) { + /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5], max-lines: [2, 400] */ + var i, key; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + if (typeof a !== typeof b) { return false; } + if (a == null || b == null) { return false; } - // Get NAF form - var naf = getNAF(k, w, this._bitLength); + if ($objToString(a) !== $objToString(b)) { return false; } - // 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 (isArguments(a) !== isArguments(b)) { return false; } - 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()); - } + var aIsArray = isArray(a); + var bIsArray = isArray(b); + if (aIsArray !== bIsArray) { return false; } + + // TODO: replace when a cross-realm brand check is available + var aIsError = a instanceof Error; + var bIsError = b instanceof Error; + if (aIsError !== bIsError) { return false; } + if (aIsError || bIsError) { + if (a.name !== b.name || a.message !== b.message) { return false; } } - 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; + var aIsRegex = isRegex(a); + var bIsRegex = isRegex(b); + if (aIsRegex !== bIsRegex) { return false; } + if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) { + return false; + } - // 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; + var aIsDate = isDate(a); + var bIsDate = isDate(b); + if (aIsDate !== bIsDate) { return false; } + if (aIsDate || bIsDate) { // && would work too, because both are true or both false here + if ($getTime(a) !== $getTime(b)) { return false; } } + if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; } - // 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 aWhich = whichTypedArray(a); + var bWhich = whichTypedArray(b); + if (aWhich !== bWhich) { + return false; + } + if (aWhich || bWhich) { // && would work too, because both are true or both false here + if (a.length !== b.length) { return false; } + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } } + return true; + } - 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 aIsBuffer = isBuffer(a); + var bIsBuffer = isBuffer(b); + if (aIsBuffer !== bIsBuffer) { return false; } + if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here + if (a.length !== b.length) { return false; } + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } } + return true; + } - 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; + var aIsArrayBuffer = isArrayBuffer(a); + var bIsArrayBuffer = isArrayBuffer(b); + if (aIsArrayBuffer !== bIsArrayBuffer) { return false; } + if (aIsArrayBuffer || bIsArrayBuffer) { // && would work too, because both are true or both false here + if (byteLength(a) !== byteLength(b)) { return false; } + return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); + } - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } + var aIsSAB = isSharedArrayBuffer(a); + var bIsSAB = isSharedArrayBuffer(b); + if (aIsSAB !== bIsSAB) { return false; } + if (aIsSAB || bIsSAB) { // && would work too, because both are true or both false here + if (sabByteLength(a) !== sabByteLength(b)) { return false; } + return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); } - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (i = max; i >= 0; i--) { - var k = 0; + if (typeof a !== typeof b) { return false; } - 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; + var ka = objectKeys(a); + var kb = objectKeys(b); + // having the same number of owned properties (keys incorporates hasOwnProperty) + if (ka.length !== kb.length) { return false; } - 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(); + // 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; } // eslint-disable-line eqeqeq + } - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } + // equivalent values for every corresponding key, and ~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; } } - // Zeroify references - for (i = 0; i < len; i++) - wnd[i] = null; - if (jacobianResult) - return acc; - else - return acc.toP(); -}; + var aCollection = whichCollection(a); + var bCollection = whichCollection(b); + if (aCollection !== bCollection) { + return false; + } + if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection + return setEquiv(a, b, opts, channel); + } + if (aCollection === 'Map') { // aCollection === bCollection + return mapEquiv(a, b, opts, channel); + } -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; + return true; } -BaseCurve.BasePoint = BasePoint; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); +module.exports = function deepEqual(a, b, opts) { + return internalDeepEqual(a, b, opts, getSideChannel()); }; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +},{"array-buffer-byte-length":33,"call-bind/callBound":57,"es-get-iterator":415,"get-intrinsic":422,"is-arguments":447,"is-array-buffer":448,"is-date-object":452,"is-regex":456,"is-shared-array-buffer":458,"isarray":463,"object-is":474,"object-keys":478,"object.assign":481,"regexp.prototype.flags":490,"side-channel":495,"which-boxed-primitive":506,"which-collection":507,"which-typed-array":508}],367:[function(require,module,exports){ +'use strict'; + +var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) + && !isSpecial(value) }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +function isNonNullObject(value) { + return !!value && typeof value === 'object' +} - var len = this.p.byteLength(); +function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); - // 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); + return stringValue === '[object RegExp]' + || stringValue === '[object Date]' + || isReactElement(value) +} - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); +// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 +var canUseSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - 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'); -}; +function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE +} -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; +function emptyTarget(val) { + return Array.isArray(val) ? [] : {} +} -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +function cloneUnlessOtherwiseSpecified(value, options) { + return (options.clone !== false && options.isMergeableObject(value)) + ? deepmerge(emptyTarget(value), value, options) + : value +} - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); +function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options) + }) +} - return [ 0x04 ].concat(x, this.getY().toArray('be', len)); -}; +function getMergeFunction(key, options) { + if (!options.customMerge) { + return deepmerge + } + var customMerge = options.customMerge(key); + return typeof customMerge === 'function' ? customMerge : deepmerge +} -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; +function getEnumerableOwnPropertySymbols(target) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(target).filter(function(symbol) { + return Object.propertyIsEnumerable.call(target, symbol) + }) + : [] +} -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; +function getKeys(target) { + return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) +} - 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; +function propertyIsOnObject(object, property) { + try { + return property in object + } catch(_) { + return false + } +} - return this; -}; +// Protects from prototype poisoning and unexpected merging up the prototype chain. +function propertyIsUnsafe(target, key) { + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, + && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, + && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. +} -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; +function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) { + getKeys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + } + getKeys(source).forEach(function(key) { + if (propertyIsUnsafe(target, key)) { + return + } - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { + destination[key] = getMergeFunction(key, options)(target[key], source[key], options); + } else { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + } + }); + return destination +} - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; +function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() + // implementations can use it. The caller may not replace it. + options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; - 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, - }; -}; + if (!sourceAndTargetTypesMatch) { + return cloneUnlessOtherwiseSpecified(source, options) + } else if (sourceIsArray) { + return options.arrayMerge(target, source, options) + } else { + return mergeObject(target, source, options) + } +} -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; +deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) { + throw new Error('first argument should be an array') + } - 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, - }; + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options) + }, {}) }; -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; +var deepmerge_1 = deepmerge; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +module.exports = deepmerge_1; -},{"../utils":390,"bn.js":391}],378:[function(require,module,exports){ +},{}],368:[function(require,module,exports){ 'use strict'; -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); +var $defineProperty = require('es-define-property'); -var assert = utils.assert; +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); -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; +var gopd = require('gopd'); - Base.call(this, 'edwards', conf); +/** @type {import('.')} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } - 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); + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); - else - return this.a.redMul(num); + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } }; -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); -}; +},{"es-define-property":407,"es-errors/syntax":412,"es-errors/type":413,"gopd":423}],369:[function(require,module,exports){ +'use strict'; -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); +var keys = require('object-keys'); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; + +var toStr = Object.prototype.toString; +var concat = Array.prototype.concat; +var defineDataProperty = require('define-data-property'); + +var isFunction = function (fn) { + return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; }; -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); +var supportsDescriptors = require('has-property-descriptors')(); - 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 defineProperty = function (object, name, value, predicate) { + if (name in object) { + if (predicate === true) { + if (object[name] === value) { + return; + } + } else if (!isFunction(predicate) || !predicate()) { + return; + } + } - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + if (supportsDescriptors) { + defineDataProperty(object, name, value, true); + } else { + defineDataProperty(object, name, value); + } +}; - return this.point(x, y); +var defineProperties = function (object, map) { + var predicates = arguments.length > 2 ? arguments[2] : {}; + var props = keys(map); + if (hasSymbols) { + props = concat.call(props, Object.getOwnPropertySymbols(map)); + } + for (var i = 0; i < props.length; i += 1) { + defineProperty(object, props[i], map[props[i]], predicates[props[i]]); + } }; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); +defineProperties.supportsDescriptors = !!supportsDescriptors; - // 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()); +module.exports = defineProperties; - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } +},{"define-data-property":368,"has-property-descriptors":425,"object-keys":478}],370:[function(require,module,exports){ +'use strict'; - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +var elliptic = exports; - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); +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'); - return this.point(x, y); -}; +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; +},{"../package.json":386,"./elliptic/curve":373,"./elliptic/curves":376,"./elliptic/ec":377,"./elliptic/eddsa":380,"./elliptic/utils":384,"brorand":54}],371:[function(require,module,exports){ +'use strict'; - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; - 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))); +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - return lhs.cmp(rhs) === 0; -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -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; + // 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); - // 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()); - } + // 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); } } -inherits(Point, Base.BasePoint); - -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; +module.exports = BaseCurve; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); -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)); -}; + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S + // 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); + } - // 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); + 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(); }; -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 +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; - // 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(); + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; - 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); + // 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 { - // 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); + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); } - } 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); + return p.type === 'affine' ? acc.toP() : acc; }; -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; - // 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); + // 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; } - return this.curve.point(nx, ny, nz); -}; -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; + // 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; + } - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; + // 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()); + } -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; + 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 */ + ]; -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + 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; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } - // 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; -}; + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; + 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; -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; + 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(); -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; + if (jacobianResult) + return acc; + else + return acc.toP(); }; -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; +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); }; -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; -},{"../utils":390,"./base":377,"bn.js":391,"inherits":456}],379:[function(require,module,exports){ -'use strict'; +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); -var curve = exports; + var len = this.p.byteLength(); -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + // 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); -},{"./base":377,"./edwards":378,"./mont":380,"./short":381}],380:[function(require,module,exports){ -'use strict'; + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + 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'); +}; -var utils = require('../utils'); +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; -function MontCurve(conf) { - Base.call(this, 'mont', conf); +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); - 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; + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); -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 [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; - return y.redSqr().cmp(rhs) === 0; +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); }; -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); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; + 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; -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); + return this; }; -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; -Point.prototype.precompute = function precompute() { - // No-op -}; + var doubles = this.precomputed.doubles; + if (!doubles) + return false; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; + 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, + }; }; -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A + 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, + }; +}; - // 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); +BasePoint.prototype._getBeta = function _getBeta() { + return null; }; -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; }; -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A +},{"../utils":384,"bn.js":385}],372:[function(require,module,exports){ +'use strict'; - // 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); -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -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 +var assert = utils.assert; - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); +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; - 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; -}; + Base.call(this, 'edwards', conf); -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); -}; + 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); -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); + 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); }; -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); }; -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); }; -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - return this.x.fromRed(); + 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); }; -},{"../utils":390,"./base":377,"bn.js":391,"inherits":456}],381:[function(require,module,exports){ -'use strict'; +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + // 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()); -var assert = utils.assert; + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } -function ShortCurve(conf) { - Base.call(this, 'short', conf); + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - 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(); + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + return this.point(x, y); +}; - // 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; +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); - // 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); - } - } + 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))); - // 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), - }; - }); + 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 { - basis = this._getEndoBasis(lambda); + 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); - return { - beta: beta, - lambda: lambda, - basis: basis, - }; +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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); +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); }; -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); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // 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; +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)); +}; - 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)); +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; + // 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); +}; - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; +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 - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } + // 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(); - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); + 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 [ - { a: a1, b: b1 }, - { a: a2, b: b2 }, - ]; + return this.curve.point(nx, ny, nz); }; -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); +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); }; -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(); +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return this.point(x, y); + // 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); }; -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; -}; +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S -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; + // 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 { - 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), - }, - }; + // 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 beta; + return this.curve.point(nx, ny, nz); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; - 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), - }, - } ]; + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); }; -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.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; - - // P + O = P - if (p.inf) +Point.prototype.normalize = function normalize() { + if (this.zOne) 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); + // 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.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.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.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.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; }; -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.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; -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); -}; + 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; -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); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } }; -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - 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; -}; +},{"../utils":384,"./base":371,"bn.js":385,"inherits":445}],373:[function(require,module,exports){ +'use strict'; -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +var curve = exports; - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); + +},{"./base":371,"./edwards":372,"./mont":374,"./short":375}],374:[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 JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); + this.z = this.curve.zero; } 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.z.red) + this.z = this.z.toRed(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); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; } -inherits(JPoint, Base.BasePoint); +inherits(Point, Base.BasePoint); -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); }; -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); +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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); +Point.prototype.precompute = function precompute() { + // No-op +}; - 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); +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; - return this.curve.jpoint(nx, ny, nz); +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P +Point.prototype.inspect = function inspect() { if (this.isInfinity()) - return p.toJ(); + return ''; + return ''; +}; - // P + O = P - if (p.isInfinity()) - return this; +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; - // 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); +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - 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(); - } + // 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); +}; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - 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); +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A - return this.curve.jpoint(nx, ny, nz); + // 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); }; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +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 - var i; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (i = 0; i < pow; i++) - r = r.dbl(); - return r; + 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; +}; - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - // 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)); +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - 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); +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; - jx = nx; - jz = nz; - jyd = dny; - } +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + return this.x.fromRed(); }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +},{"../utils":384,"./base":371,"bn.js":385,"inherits":445}],375:[function(require,module,exports){ +'use strict'; - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -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 +var assert = utils.assert; - // 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); +function ShortCurve(conf) { + Base.call(this, 'short', conf); - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); + 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(); - // 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 + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - // 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(); + // 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; - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - // 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); + // 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); + } } - return this.curve.jpoint(nx, ny, nz); + // 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, + }; }; -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 +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(); - // 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); - } + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - return this.curve.jpoint(nx, ny, nz); + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; }; -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); + // 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); - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); + // 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 c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + 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)); - 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); + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - 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); + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; - return this.curve.jpoint(nx, ny, nz); -}; + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; - // 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); +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - return this.curve.jpoint(nx, ny, nz); -}; + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); - return this.curve._wnafMul(this, k); + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - if (this === p) - return true; + 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'); - // 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; + // 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(); - // 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; + return this.point(x, y); }; -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) +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) 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 ''; -}; + var x = point.x; + var y = point.y; -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; + 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; }; -},{"../utils":390,"./base":377,"bn.js":391,"inherits":456}],382:[function(require,module,exports){ -'use strict'; - -var curves = exports; +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(); -var hash = require('hash.js'); -var curve = require('./curve'); -var utils = require('./utils'); - -var assert = utils.assert; + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } -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; + 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); - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; -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; - }, - }); +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); -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', - ], -}); +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; -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', - ], -}); +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; -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', - ], -}); +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; -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', - ], -}); + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; -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', - ], -}); + 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; +}; -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', - ], -}); +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; -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', + 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), + }, + } ]; +}; - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658', - ], -}); +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; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; -} + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } -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', + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15', + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), }, - ], + }; + return res; +}; - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre, - ], -}); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; -},{"./curve":379,"./precomputed/secp256k1":389,"./utils":390,"hash.js":441}],383:[function(require,module,exports){ -'use strict'; +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; -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; +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; -var KeyPair = require('./key'); -var Signature = require('./signature'); + // P + O = P + if (p.inf) + return this; -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); + // P + P = 2P + if (this.eq(p)) + return this.dbl(); - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(Object.prototype.hasOwnProperty.call(curves, options), - 'Unknown curve ' + options); + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); - options = curves[options]; - } + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof curves.PresetCurve) - options = { curve: options }; + 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); +}; - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; -} -module.exports = EC; + var a = this.curve.a; -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); + 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); }; -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); +Point.prototype.getX = function getX() { + return this.x.fromRed(); }; -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(), - }); +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; - 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; +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); +}; - priv.iaddn(1); - return this.keyFromPrivate(priv); - } +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); }; -EC.prototype._truncateToN = function _truncateToN(msg, truncOnly, bitLength) { - var byteLength; - if (BN.isBN(msg) || typeof msg === 'number') { - msg = new BN(msg, 16); - byteLength = msg.byteLength(); - } else if (typeof msg === 'object') { - // BN assumes an array-like input and asserts length - byteLength = msg.length; - msg = new BN(msg, 16); - } else { - // BN converts the value to string - var str = msg.toString(); - // HEX encoding - byteLength = (str.length + 1) >>> 1; - msg = new BN(str, 16); - } - // Allow overriding - if (typeof bitLength !== 'number') { - bitLength = byteLength * 8; - } - var delta = bitLength - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); +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 msg; + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; +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; - if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) { - assert(typeof msg === 'object' && msg && typeof msg.length === 'number', - 'Expected message to be an array-like, a hex string, or a BN instance'); - assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer - for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]); + 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; +}; - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(msg, false, options.msgBitLength); +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - // Would fail further checks, but let's make the error message clear - assert(!msg.isNeg(), 'Can not sign a negative message'); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); +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); - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); - // Recheck nonce to be bijective to msg - assert((new BN(nonce)).eq(msg), 'Can not sign message'); +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; - // 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); +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); - } + return this.curve.point(ax, ay); }; -EC.prototype.verify = function verify(msg, signature, key, enc, options) { - if (!options) - options = {}; - - msg = this._truncateToN(msg, false, options.msgBitLength); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; - // 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; +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; - // 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; + // P + O = P + if (p.isInfinity()) + return this; - if (!this.curve._maxwellTrick) { - p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + // 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)); - return p.getX().umod(this.n).cmp(r) === 0; + 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(); } - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + 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); - // 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); + return this.curve.jpoint(nx, ny, nz); }; -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); +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; + // P + O = P + if (p.isInfinity()) + return this; - // 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'); + // 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); - // 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 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 rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; + 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); -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; + return this.curve.jpoint(nx, ny, nz); +}; - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; - } +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); - if (Qprime.eq(Q)) - return i; + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; } - throw new Error('Unable to find valid recovery factor'); -}; -},{"../curves":382,"../utils":390,"./key":384,"./signature":385,"bn.js":391,"brorand":54,"hmac-drbg":454}],384:[function(require,module,exports){ -'use strict'; + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; + // 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)); - // 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; + 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); -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; + jx = nx; + jz = nz; + jyd = dny; + } - return new KeyPair(ec, { - pub: pub, - pubEnc: enc, - }); + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - return new KeyPair(ec, { - priv: priv, - privEnc: enc, - }); + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); }; -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); +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 - 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' }; + // 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); - return { result: true, reason: null }; -}; + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; - } + // 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 - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); + // 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(); - if (!enc) - return this.pub; + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); - return this.pub.encode(enc, compact); -}; + // 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); + } -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); - else - return this.priv; + return this.curve.jpoint(nx, ny, nz); }; -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); -}; +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 -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); -}; + // 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 -// ECDH -KeyPair.prototype.derive = function derive(pub) { - if(!pub.validate()) { - assert(pub.validate(), 'public point not validated'); + // 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 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, options) { - return this.ec.verify(msg, signature, this, undefined, options); -}; -KeyPair.prototype.inspect = function inspect() { - return ''; + return this.curve.jpoint(nx, ny, nz); }; -},{"../utils":390,"bn.js":391}],385:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); - -var utils = require('../utils'); -var assert = utils.assert; +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; -function Signature(options, enc) { - if (options instanceof Signature) - return options; + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - if (this._importDER(options, enc)) - return; + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); - 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; + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); -function Position() { - this.place = 0; -} + 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); -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; + 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); - // Indefinite length or overflow - if (octetLen === 0 || octetLen > 4) { - return false; - } + return this.curve.jpoint(nx, ny, nz); +}; - if(buf[p.place] === 0x00) { - return false; - } +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - val >>>= 0; - } + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - // Leading zeroes - if (val <= 0x7f) { - return false; - } + // 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); - p.place = off; - return val; -} + return this.curve.jpoint(nx, ny, nz); +}; -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); -} +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); -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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - } + return this.curve._wnafMul(this, k); +}; - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); - return true; -}; + if (this === p) + 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); -} + // 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; -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); + // 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; +}; - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); +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; - r = rmPadding(r); - s = rmPadding(s); + 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; - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - 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":390,"bn.js":391}],386:[function(require,module,exports){ +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":384,"./base":371,"bn.js":385,"inherits":445}],376:[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'); +var curves = exports; -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); - if (!(this instanceof EDDSA)) - return new EDDSA(curve); +var assert = utils.assert; - curve = curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); +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; - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); } +curves.PresetCurve = PresetCurve; -module.exports = EDDSA; +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; + }, + }); +} -/** -* @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); - if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) { - return false; - } - 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); -}; +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', + ], +}); -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); -}; +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', + ], +}); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; +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', + ], +}); -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; +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', + ], +}); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; +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', + ], +}); -/** -* * 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; -}; +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', + ], +}); -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); +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', - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; +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, -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -},{"../curves":382,"../utils":390,"./key":387,"./signature":388,"hash.js":441}],387:[function(require,module,exports){ +},{"./curve":373,"./precomputed/secp256k1":383,"./utils":384,"hash.js":430}],377:[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 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); -} +var KeyPair = require('./key'); +var Signature = require('./signature'); -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); +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); }; -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); }; -KeyPair.prototype.secret = function secret() { - return this._secret; +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); }; -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + // 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(), + }); -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + 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; - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + priv.iaddn(1); + return this.keyFromPrivate(priv); + } +}; - return a; -}); +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; +}; -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; + 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; -module.exports = KeyPair; + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; -},{"../utils":390}],388:[function(require,module,exports){ -'use strict'; + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -/** -* @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; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); - if (typeof sig !== 'object') - sig = parseBytes(sig); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } - if (Array.isArray(sig)) { - assert(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size'); - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength), - }; + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } +}; - assert(sig.R && sig.S, 'Signature without R or S'); +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'); - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; + // 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; - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} + // 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; -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); + return p.getX().umod(this.n).cmp(r) === 0; + } -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); + // 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); }; -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); -}; +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); -module.exports = Signature; + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; -},{"../utils":390,"bn.js":391}],389:[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', - ], - ], - }, -}; - -},{}],390:[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); - var i; - for (i = 0; i < naf.length; i += 1) { - naf[i] = 0; - } - - var ws = 1 << (w + 1); - var k = num.clone(); - - for (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":391,"minimalistic-assert":488,"minimalistic-crypto-utils":489}],391:[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; - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - } - 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(); - }; + // 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'); - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; + // 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 a = this.clone(); - var b = num; + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - // 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; - } + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; - // Initialize quotient - var m = a.length - b.length; - var q; +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - 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; - } + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); +},{"../curves":376,"../utils":384,"./key":378,"./signature":379,"bn.js":385,"brorand":54,"hmac-drbg":443}],378:[function(require,module,exports){ +'use strict'; - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; - 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(); +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } + // 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; - return { - div: q || null, - mod: a - }; - }; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - // 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()); + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); +}; - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); +}; - if (mode !== 'mod') { - div = res.div.neg(); - } +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } + 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 { - div: div, - mod: mod - }; - } + return { result: true, reason: null }; +}; - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } - if (mode !== 'mod') { - div = res.div.neg(); - } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); - return { - div: div, - mod: res.mod - }; - } + if (!enc) + return this.pub; - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); + return this.pub.encode(enc, compact); +}; - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; - return { - div: res.div, - mod: mod - }; - } +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - // Both numbers are positive at this point + // 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); +}; - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; +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); +}; - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; - return this._wordDiv(num, mode); - }; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; +},{"../utils":384,"bn.js":385}],379:[function(require,module,exports){ +'use strict'; - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; +var BN = require('bn.js'); - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; +var utils = require('../utils'); +var assert = utils.assert; - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); +function Signature(options, enc) { + if (options instanceof Signature) + return options; - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; + if (this._importDER(options, enc)) + return; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + 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; - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); +function Position() { + this.place = 0; +} - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } + // Leading zeroes + if (val <= 0x7f) { + return false; + } - return acc; - }; + p.place = off; + return val; +} - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); +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); +} - 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; +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; } + } - return this.strip(); - }; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; + return true; +}; - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); +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); +} - var x = this; - var y = p.clone(); +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); + r = rmPadding(r); + s = rmPadding(s); - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); + 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); +}; - var g = 0; +},{"../utils":384,"bn.js":385}],380:[function(require,module,exports){ +'use strict'; - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } +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'); - var yp = y.clone(); - var xp = x.clone(); +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - 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); - } + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - A.iushrn(1); - B.iushrn(1); - } - } + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 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); - } + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - C.iushrn(1); - D.iushrn(1); - } - } +module.exports = EDDSA; - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } +/** +* @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 }); +}; - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; +/** +* @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); +}; - // 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()); +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); +}; - var a = this; - var b = p.clone(); +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; - var x1 = new BN(1); - var x2 = new BN(0); +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - var delta = b.clone(); +/** +* * 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; +}; - 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); - } +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - x1.iushrn(1); - } - } + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - 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); - } + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - x2.iushrn(1); - } - } +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; - if (res.cmpn(0) < 0) { - res.iadd(p); - } +},{"../curves":376,"../utils":384,"./key":381,"./signature":382,"hash.js":430}],381:[function(require,module,exports){ +'use strict'; - return res; - }; +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); +/** +* @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); +} - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); +}; - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - 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; - } +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - a.isub(b); - } while (true); +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - return b.iushln(shift); - }; +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; + return a; +}); - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - // 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; +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, 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; - }; +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; +module.exports = KeyPair; - this.strip(); +},{"../utils":384}],382:[function(require,module,exports){ +'use strict'; - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - assert(num <= 0x3ffffff, 'Number is too big'); +/** +* @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; - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; + if (typeof sig !== 'object') + sig = parseBytes(sig); - // 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; + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; + assert(sig.R && sig.S, 'Signature without R or S'); - // 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; + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); +}; - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; + +module.exports = Signature; + +},{"../utils":384,"bn.js":385}],383:[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', + ], + ], + }, +}; - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; +},{}],384:[function(require,module,exports){ +'use strict'; - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + var i; + for (i = 0; i < naf.length; i += 1) { + naf[i] = 0; + } - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; + var ws = 1 << (w + 1); + var k = num.clone(); - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; + for (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; + } - 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); - }; + naf[i] = z; + k.iushrn(1); + } - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; + return naf; +} +utils.getNAF = getNAF; - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; + 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); - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; + 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); - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; + return jsf; +} +utils.getJSF = getJSF; - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); +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; - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; - 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); - }; +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; - 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.js":385,"minimalistic-assert":469,"minimalistic-crypto-utils":470}],385:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } - // 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); - }; + // 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.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; + // BN - // 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); - }; + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; + this.negative = 0; + this.words = null; + this.length = 0; - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; + // Reduction context + this.red = 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); + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - this.tmp = this._tmp(); + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; } - 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); + BN.BN = BN; + BN.wordSize = 26; - 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); + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; } else { - if (r.strip !== undefined) { - // r is BN v4 instance - r.strip(); - } else { - // r is BN v5 instance - r._strip(); - } + Buffer = require('buffer').Buffer; } + } catch (e) { + } - return r; + 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); }; - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; }; - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; }; - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; + if (base === 'hex') { + base = 16; } - output.length = outLen; + assert(base === (base | 0) && base >= 2 && base <= 36); - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; } - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; + 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); + } + } + } + }; - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; + 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 { - input.length -= 9; + 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); }; - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; + 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; + } - // 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); + 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; } - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; + 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 num; + return this.strip(); }; - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + 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; + } } - inherits(P224, MPrime); - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; } - inherits(P192, MPrime); - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + 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; } - 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; + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; - num.words[i] = lo; - carry = hi; + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; } - if (carry !== 0) { - num.words[num.length++] = carry; + 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); + } } - 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]; + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - 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); + 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); + } } - primes[name] = prime; - return prime; + this.strip(); }; - // - // 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; + 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; + }; - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; }; - 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'); + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; }; - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(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(); }; - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; } + return this; + }; - return this.m.sub(a)._forceRed(this); + BN.prototype.inspect = function inspect () { + return (this.red ? ''; }; - 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); + 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; } - return res._forceRed(this); - }; + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } - 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; - }; + 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' + ]; - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); + 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 res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); + 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; } - return res._forceRed(this); - }; - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); + 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); - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); + 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; } - return res; - }; - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); + assert(false, 'Base should be between 2 and 36'); }; - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); + 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; }; - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); + BN.prototype.toJSON = function toJSON () { + return this.toString(16); }; - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); }; - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); }; - 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); + 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'); - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); - 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(); + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; } - 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; - }; + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); + res[reqLength - i - 1] = b; + } } 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; - } + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + res[i] = b; + } - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; + for (; i < reqLength; i++) { + res[i] = 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); + 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; + }; } - inherits(Mont, Red); - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; + 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; }; - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } + // 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; + }; - 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; + function toBitArray (num) { + var w = new Array(num.bitLength()); - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); + 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 res._forceRed(this); - }; + return w; + } - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - 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); + 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 res._forceRed(this); + return r; }; - 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); + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); }; -})(typeof module === 'undefined' || module, this); - -},{"buffer":55}],392:[function(require,module,exports){ -module.exports={ - "name": "elliptic", - "version": "6.6.1", - "description": "EC cryptography", - "main": "lib/elliptic.js", - "files": [ - "lib" - ], - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "test": "npm run lint && npm run unit", - "version": "grunt dist && git add dist/" - }, - "repository": { - "type": "git", - "url": "git@github.com:indutny/elliptic" - }, - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "author": "Fedor Indutny ", - "license": "MIT", - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "homepage": "https://github.com/indutny/elliptic", - "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" - }, - "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" - } -} - -},{}],393:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hasCORS = void 0; -// imported from https://github.com/component/has-cors -let value = false; -try { - value = typeof XMLHttpRequest !== 'undefined' && - 'withCredentials' in new XMLHttpRequest(); -} -catch (err) { - // if XMLHttp support is disabled in IE then it will throw - // when trying to create -} -exports.hasCORS = value; -},{}],394:[function(require,module,exports){ -"use strict"; -// imported from https://github.com/galkn/querystring -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encode = encode; -exports.decode = decode; -function encode(obj) { - let str = ''; - for (let i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) - str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - return str; -} -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ -function decode(qs) { - let qry = {}; - let pairs = qs.split('&'); - for (let i = 0, l = pairs.length; i < l; i++) { - let pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); } - return qry; -} + return this.clone(); + }; -},{}],395:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.parse = parse; -// imported from https://github.com/galkn/parseuri -/** - * Parses a URI - * - * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. - * - * See: - * - https://developer.mozilla.org/en-US/docs/Web/API/URL - * - https://caniuse.com/url - * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B - * - * History of the parse() method: - * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c - * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 - * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 - * - * @author Steven Levithan (MIT license) - * @api private - */ -const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; -const parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; -function parse(str) { - if (str.length > 8000) { - throw "URI too long"; - } - const src = str, b = str.indexOf('['), e = str.indexOf(']'); - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); - } - let m = re.exec(str || ''), uri = {}, i = 14; - while (i--) { - uri[parts[i]] = m[i] || ''; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); } - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; + 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; } - uri.pathNames = pathNames(uri, uri['path']); - uri.queryKey = queryKey(uri, uri['query']); - return uri; -} -function pathNames(obj, path) { - const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); - if (path.slice(0, 1) == '/' || path.length === 0) { - names.splice(0, 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; } - if (path.slice(-1) == '/') { - names.splice(names.length - 1, 1); + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; } - return names; -} -function queryKey(uri, query) { - const data = {}; - query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { - if ($1) { - data[$1] = $2; - } - }); - return data; -} -},{}],396:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.defaultBinaryType = exports.globalThisShim = exports.nextTick = void 0; -exports.createCookieJar = createCookieJar; -exports.nextTick = (() => { - const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; - if (isPromiseAvailable) { - return (cb) => Promise.resolve().then(cb); + 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; } - else { - return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; } -})(); -exports.globalThisShim = (() => { - if (typeof self !== "undefined") { - return self; + + 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; } - else if (typeof window !== "undefined") { - return window; + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; } - else { - return Function("return this")(); + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } } -})(); -exports.defaultBinaryType = "arraybuffer"; -function createCookieJar() { } -},{}],397:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0; -const socket_js_1 = require("./socket.js"); -Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); -var socket_js_2 = require("./socket.js"); -Object.defineProperty(exports, "SocketWithoutUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }); -Object.defineProperty(exports, "SocketWithUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }); -exports.protocol = socket_js_1.Socket.protocol; -var transport_js_1 = require("./transport.js"); -Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); -Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); -var index_js_1 = require("./transports/index.js"); -Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); -var util_js_1 = require("./util.js"); -Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); -var parseuri_js_1 = require("./contrib/parseuri.js"); -Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); -var globals_node_js_1 = require("./globals.node.js"); -Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return globals_node_js_1.nextTick; } }); -var polling_fetch_js_1 = require("./transports/polling-fetch.js"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return polling_fetch_js_1.Fetch; } }); -var polling_xhr_node_js_1 = require("./transports/polling-xhr.node.js"); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return polling_xhr_node_js_1.XHR; } }); -var polling_xhr_js_1 = require("./transports/polling-xhr.js"); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return polling_xhr_js_1.XHR; } }); -var websocket_node_js_1 = require("./transports/websocket.node.js"); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return websocket_node_js_1.WS; } }); -var websocket_js_1 = require("./transports/websocket.js"); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return websocket_js_1.WS; } }); -var webtransport_js_1 = require("./transports/webtransport.js"); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return webtransport_js_1.WT; } }); - -},{"./contrib/parseuri.js":395,"./globals.node.js":396,"./socket.js":398,"./transport.js":399,"./transports/index.js":400,"./transports/polling-fetch.js":401,"./transports/polling-xhr.js":402,"./transports/polling-xhr.node.js":402,"./transports/websocket.js":404,"./transports/websocket.node.js":404,"./transports/webtransport.js":405,"./util.js":406}],398:[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.Socket = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = void 0; -const index_js_1 = require("./transports/index.js"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const parseuri_js_1 = require("./contrib/parseuri.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("./globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() -const withEventListeners = typeof addEventListener === "function" && - typeof removeEventListener === "function"; -const OFFLINE_EVENT_LISTENERS = []; -if (withEventListeners) { - // within a ServiceWorker, any event handler for the 'offline' event must be added on the initial evaluation of the - // script, so we create one single event listener here which will forward the event to the socket instances - addEventListener("offline", () => { - debug("closing %d connection(s) because the network was lost", OFFLINE_EVENT_LISTENERS.length); - OFFLINE_EVENT_LISTENERS.forEach((listener) => listener()); - }, false); -} -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that - * successfully establishes the connection. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithoutUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithoutUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithUpgrade - * @see Socket - */ -class SocketWithoutUpgrade extends component_emitter_1.Emitter { - /** - * Socket constructor. - * - * @param {String|Object} uri - uri or options - * @param {Object} opts - options - */ - constructor(uri, opts) { - super(); - this.binaryType = globals_node_js_1.defaultBinaryType; - this.writeBuffer = []; - this._prevBufferLen = 0; - this._pingInterval = -1; - this._pingTimeout = -1; - this._maxPayload = -1; - /** - * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the - * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked. - */ - this._pingTimeoutTime = Infinity; - if (uri && "object" === typeof uri) { - opts = uri; - uri = null; - } - if (uri) { - const parsedUri = (0, parseuri_js_1.parse)(uri); - opts.hostname = parsedUri.host; - opts.secure = - parsedUri.protocol === "https" || parsedUri.protocol === "wss"; - opts.port = parsedUri.port; - if (parsedUri.query) - opts.query = parsedUri.query; - } - else if (opts.host) { - opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; - } - (0, util_js_1.installTimerFunctions)(this, opts); - this.secure = - null != opts.secure - ? opts.secure - : typeof location !== "undefined" && "https:" === location.protocol; - if (opts.hostname && !opts.port) { - // if no port is specified manually, use the protocol default - opts.port = this.secure ? "443" : "80"; - } - this.hostname = - opts.hostname || - (typeof location !== "undefined" ? location.hostname : "localhost"); - this.port = - opts.port || - (typeof location !== "undefined" && location.port - ? location.port - : this.secure - ? "443" - : "80"); - this.transports = []; - this._transportsByName = {}; - opts.transports.forEach((t) => { - const transportName = t.prototype.name; - this.transports.push(transportName); - this._transportsByName[transportName] = t; - }); - this.opts = Object.assign({ - path: "/engine.io", - agent: false, - withCredentials: false, - upgrade: true, - timestampParam: "t", - rememberUpgrade: false, - addTrailingSlash: true, - rejectUnauthorized: true, - perMessageDeflate: { - threshold: 1024, - }, - transportOptions: {}, - closeOnBeforeunload: false, - }, opts); - this.opts.path = - this.opts.path.replace(/\/$/, "") + - (this.opts.addTrailingSlash ? "/" : ""); - if (typeof this.opts.query === "string") { - this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); - } - if (withEventListeners) { - if (this.opts.closeOnBeforeunload) { - // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener - // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is - // closed/reloaded) - this._beforeunloadEventListener = () => { - if (this.transport) { - // silently close the transport - this.transport.removeAllListeners(); - this.transport.close(); - } - }; - addEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this.hostname !== "localhost") { - debug("adding listener for the 'offline' event"); - this._offlineEventListener = () => { - this._onClose("transport close", { - description: "network connection lost", - }); - }; - OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener); - } - } - if (this.opts.withCredentials) { - this._cookieJar = (0, globals_node_js_1.createCookieJar)(); - } - this._open(); + 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--; } - /** - * Creates transport of the given type. - * - * @param {String} name - transport name - * @return {Transport} - * @private - */ - createTransport(name) { - debug('creating transport "%s"', name); - const query = Object.assign({}, this.opts.query); - // append engine.io protocol identifier - query.EIO = engine_io_parser_1.protocol; - // transport name - query.transport = name; - // session id if we already have one - if (this.id) - query.sid = this.id; - const opts = Object.assign({}, this.opts, { - query, - socket: this, - hostname: this.hostname, - secure: this.secure, - port: this.port, - }, this.opts.transportOptions[name]); - debug("options: %j", opts); - return new this._transportsByName[name](opts); + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; } - /** - * Initializes transport to use and starts probe. - * - * @private - */ - _open() { - if (this.transports.length === 0) { - // Emit error on next tick so it can be listened to - this.setTimeoutFn(() => { - this.emitReserved("error", "No transports available"); - }, 0); - return; - } - const transportName = this.opts.rememberUpgrade && - SocketWithoutUpgrade.priorWebsocketSuccess && - this.transports.indexOf("websocket") !== -1 - ? "websocket" - : this.transports[0]; - this.readyState = "opening"; - const transport = this.createTransport(transportName); - transport.open(); - this.setTransport(transport); + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); } - /** - * Sets the current transport. Disables the existing one (if any). - * - * @private - */ - setTransport(transport) { - debug("setting transport %s", transport.name); - if (this.transport) { - debug("clearing existing transport %s", this.transport.name); - this.transport.removeAllListeners(); - } - // set up transport - this.transport = transport; - // set up transport listeners - transport - .on("drain", this._onDrain.bind(this)) - .on("packet", this._onPacket.bind(this)) - .on("error", this._onError.bind(this)) - .on("close", (reason) => this._onClose("transport close", reason)); + + // 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); } - /** - * Called when connection is deemed open. - * - * @private - */ - onOpen() { - debug("socket open"); - this.readyState = "open"; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === this.transport.name; - this.emitReserved("open"); - this.flush(); + + 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(); } - /** - * Handles a packet. - * - * @private - */ - _onPacket(packet) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket receive: type "%s", data "%s"', packet.type, packet.data); - this.emitReserved("packet", packet); - // Socket is live - any packet counts - this.emitReserved("heartbeat"); - switch (packet.type) { - case "open": - this.onHandshake(JSON.parse(packet.data)); - break; - case "ping": - this._sendPacket("pong"); - this.emitReserved("ping"); - this.emitReserved("pong"); - this._resetPingTimeout(); - break; - case "error": - const err = new Error("server error"); - // @ts-ignore - err.code = packet.data; - this._onError(err); - break; - case "message": - this.emitReserved("data", packet.data); - this.emitReserved("message", packet.data); - break; - } - } - else { - debug('packet received with socket readyState "%s"', this.readyState); - } + + // 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; } - /** - * Called upon handshake completion. - * - * @param {Object} data - handshake obj - * @private - */ - onHandshake(data) { - this.emitReserved("handshake", data); - this.id = data.sid; - this.transport.query.sid = data.sid; - this._pingInterval = data.pingInterval; - this._pingTimeout = data.pingTimeout; - this._maxPayload = data.maxPayload; - this.onOpen(); - // In case open handler closes socket - if ("closed" === this.readyState) - return; - this._resetPingTimeout(); + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; } - /** - * Sets and resets ping timeout timer based on server pings. - * - * @private - */ - _resetPingTimeout() { - this.clearTimeoutFn(this._pingTimeoutTimer); - const delay = this._pingInterval + this._pingTimeout; - this._pingTimeoutTime = Date.now() + delay; - this._pingTimeoutTimer = this.setTimeoutFn(() => { - this._onClose("ping timeout"); - }, delay); - if (this.opts.autoUnref) { - this._pingTimeoutTimer.unref(); - } + + 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; } - /** - * Called on `drain` event - * - * @private - */ - _onDrain() { - this.writeBuffer.splice(0, this._prevBufferLen); - // setting prevBufferLen = 0 is very important - // for example, when upgrading, upgrade packet is sent over, - // and a nonzero prevBufferLen could cause problems on `drain` - this._prevBufferLen = 0; - if (0 === this.writeBuffer.length) { - this.emitReserved("drain"); - } - else { - this.flush(); - } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; } - /** - * Flush write buffers. - * - * @private - */ - flush() { - if ("closed" !== this.readyState && - this.transport.writable && - !this.upgrading && - this.writeBuffer.length) { - const packets = this._getWritablePackets(); - debug("flushing %d packets in socket", packets.length); - this.transport.send(packets); - // keep track of current length of writeBuffer - // splice writeBuffer and callbackBuffer on `drain` - this._prevBufferLen = packets.length; - this.emitReserved("flush"); - } + + // 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++; } - /** - * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP - * long-polling) - * - * @private - */ - _getWritablePackets() { - const shouldCheckPayloadSize = this._maxPayload && - this.transport.name === "polling" && - this.writeBuffer.length > 1; - if (!shouldCheckPayloadSize) { - return this.writeBuffer; - } - let payloadSize = 1; // first packet type - for (let i = 0; i < this.writeBuffer.length; i++) { - const data = this.writeBuffer[i].data; - if (data) { - payloadSize += (0, util_js_1.byteLength)(data); - } - if (i > 0 && payloadSize > this._maxPayload) { - debug("only send %d out of %d packets", i, this.writeBuffer.length); - return this.writeBuffer.slice(0, i); - } - payloadSize += 2; // separator + packet type - } - debug("payload size is %d (max: %d)", payloadSize, this._maxPayload); - return this.writeBuffer; + 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; } - /** - * Checks whether the heartbeat timer has expired but the socket has not yet been notified. - * - * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the - * `write()` method then the message would not be buffered by the Socket.IO client. - * - * @return {boolean} - * @private - */ - /* private */ _hasPingExpired() { - if (!this._pingTimeoutTime) - return true; - const hasExpired = Date.now() > this._pingTimeoutTime; - if (hasExpired) { - debug("throttled timer detected, scheduling connection close"); - this._pingTimeoutTime = 0; - (0, globals_node_js_1.nextTick)(() => { - this._onClose("ping timeout"); - }, this.setTimeoutFn); - } - return hasExpired; + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; } - /** - * Sends a message. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - write(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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); } - /** - * Sends a message. Alias of {@link Socket#write}. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - send(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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); } - /** - * Sends a packet. - * - * @param {String} type: packet type. - * @param {String} data. - * @param {Object} options. - * @param {Function} fn - callback function. - * @private - */ - _sendPacket(type, data, options, fn) { - if ("function" === typeof data) { - fn = data; - data = undefined; - } - if ("function" === typeof options) { - fn = options; - options = null; - } - if ("closing" === this.readyState || "closed" === this.readyState) { - return; - } - options = options || {}; - options.compress = false !== options.compress; - const packet = { - type: type, - data: data, - options: options, - }; - this.emitReserved("packetCreate", packet); - this.writeBuffer.push(packet); - if (fn) - this.once("flush", fn); - this.flush(); + + 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; } - /** - * Closes the connection. - */ - close() { - const close = () => { - this._onClose("forced close"); - debug("socket closing - telling transport to close"); - this.transport.close(); - }; - const cleanupAndClose = () => { - this.off("upgrade", cleanupAndClose); - this.off("upgradeError", cleanupAndClose); - close(); - }; - const waitForUpgrade = () => { - // wait for upgrade to finish since we can't send packets while pausing a transport - this.once("upgrade", cleanupAndClose); - this.once("upgradeError", cleanupAndClose); - }; - if ("opening" === this.readyState || "open" === this.readyState) { - this.readyState = "closing"; - if (this.writeBuffer.length) { - this.once("drain", () => { - if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - }); - } - else if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - } - return this; + + 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]]; } - /** - * Called upon transport error - * - * @private - */ - _onError(err) { - debug("socket error %j", err); - SocketWithoutUpgrade.priorWebsocketSuccess = false; - if (this.opts.tryAllTransports && - this.transports.length > 1 && - this.readyState === "opening") { - debug("trying next transport"); - this.transports.shift(); - return this._open(); + }; + + 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; + } } - this.emitReserved("error", err); - this._onClose("transport error", err); + } + } + }; + + 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; + } } - /** - * Called upon transport close. - * - * @private - */ - _onClose(reason, description) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket close with reason: "%s"', reason); - // clear timers - this.clearTimeoutFn(this._pingTimeoutTimer); - // stop event from firing again for transport - this.transport.removeAllListeners("close"); - // ensure transport won't stay open - this.transport.close(); - // ignore further transport communication - this.transport.removeAllListeners(); - if (withEventListeners) { - if (this._beforeunloadEventListener) { - removeEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this._offlineEventListener) { - const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener); - if (i !== -1) { - debug("removing listener for the 'offline' event"); - OFFLINE_EVENT_LISTENERS.splice(i, 1); - } - } - } - // set ready state - this.readyState = "closed"; - // clear session id - this.id = null; - // emit close event - this.emitReserved("close", reason, description); - // clean buffers after, so users can still - // grab the buffers on `close` event - this.writeBuffer = []; - this._prevBufferLen = 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; } -} -exports.SocketWithoutUpgrade = SocketWithoutUpgrade; -SocketWithoutUpgrade.protocol = engine_io_parser_1.protocol; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see Socket - */ -class SocketWithUpgrade extends SocketWithoutUpgrade { - constructor() { - super(...arguments); - this._upgrades = []; + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; } - onOpen() { - super.onOpen(); - if ("open" === this.readyState && this.opts.upgrade) { - debug("starting upgrade probes"); - for (let i = 0; i < this._upgrades.length; i++) { - this._probe(this._upgrades[i]); - } - } + + 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; } - /** - * Probes a transport. - * - * @param {String} name - transport name - * @private - */ - _probe(name) { - debug('probing transport "%s"', name); - let transport = this.createTransport(name); - let failed = false; - SocketWithoutUpgrade.priorWebsocketSuccess = false; - const onTransportOpen = () => { - if (failed) - return; - debug('probe transport "%s" opened', name); - transport.send([{ type: "ping", data: "probe" }]); - transport.once("packet", (msg) => { - if (failed) - return; - if ("pong" === msg.type && "probe" === msg.data) { - debug('probe transport "%s" pong', name); - this.upgrading = true; - this.emitReserved("upgrading", transport); - if (!transport) - return; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === transport.name; - debug('pausing current transport "%s"', this.transport.name); - this.transport.pause(() => { - if (failed) - return; - if ("closed" === this.readyState) - return; - debug("changing transport and sending upgrade packet"); - cleanup(); - this.setTransport(transport); - transport.send([{ type: "upgrade" }]); - this.emitReserved("upgrade", transport); - transport = null; - this.upgrading = false; - this.flush(); - }); - } - else { - debug('probe transport "%s" failed', name); - const err = new Error("probe error"); - // @ts-ignore - err.transport = transport.name; - this.emitReserved("upgradeError", err); - } - }); - }; - function freezeTransport() { - if (failed) - return; - // Any callback called by transport should be ignored since now - failed = true; - cleanup(); - transport.close(); - transport = null; - } - // Handle any error that happens while probing - const onerror = (err) => { - const error = new Error("probe error: " + err); - // @ts-ignore - error.transport = transport.name; - freezeTransport(); - debug('probe transport "%s" failed because of error: %s', name, err); - this.emitReserved("upgradeError", error); - }; - function onTransportClose() { - onerror("transport closed"); - } - // When the socket is closed while we're probing - function onclose() { - onerror("socket closed"); - } - // When the socket is upgraded while we're probing - function onupgrade(to) { - if (transport && to.name !== transport.name) { - debug('"%s" works - aborting "%s"', to.name, transport.name); - freezeTransport(); - } - } - // Remove all listeners on the transport and on self - const cleanup = () => { - transport.removeListener("open", onTransportOpen); - transport.removeListener("error", onerror); - transport.removeListener("close", onTransportClose); - this.off("close", onclose); - this.off("upgrading", onupgrade); - }; - transport.once("open", onTransportOpen); - transport.once("error", onerror); - transport.once("close", onTransportClose); - this.once("close", onclose); - this.once("upgrading", onupgrade); - if (this._upgrades.indexOf("webtransport") !== -1 && - name !== "webtransport") { - // favor WebTransport - this.setTimeoutFn(() => { - if (!failed) { - transport.open(); - } - }, 200); - } - else { - transport.open(); - } + + 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; } - onHandshake(data) { - this._upgrades = this._filterUpgrades(data.upgrades); - super.onHandshake(data); + + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Filters upgrades, returning only those matching client transports. - * - * @param {Array} upgrades - server upgrades - * @private - */ - _filterUpgrades(upgrades) { - const filteredUpgrades = []; - for (let i = 0; i < upgrades.length; i++) { - if (~this.transports.indexOf(upgrades[i])) - filteredUpgrades.push(upgrades[i]); - } - return filteredUpgrades; + + 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; } -} -exports.SocketWithUpgrade = SocketWithUpgrade; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * @example - * import { Socket } from "engine.io-client"; - * - * const socket = new Socket(); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see SocketWithUpgrade - */ -class Socket extends SocketWithUpgrade { - constructor(uri, opts = {}) { - const o = typeof uri === "object" ? uri : opts; - if (!o.transports || - (o.transports && typeof o.transports[0] === "string")) { - o.transports = (o.transports || ["polling", "websocket", "webtransport"]) - .map((transportName) => index_js_1.transports[transportName]) - .filter((t) => !!t); - } - super(uri, o); + + 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); + } } -} -exports.Socket = Socket; -},{"./contrib/parseqs.js":394,"./contrib/parseuri.js":395,"./globals.node.js":396,"./transports/index.js":400,"./util.js":406,"@socket.io/component-emitter":26,"debug":407,"engine.io-parser":413}],399:[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.Transport = exports.TransportError = void 0; -const engine_io_parser_1 = require("engine.io-parser"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() -class TransportError extends Error { - constructor(reason, description, context) { - super(reason); - this.description = description; - this.context = context; - this.type = "TransportError"; + 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++; + } } -} -exports.TransportError = TransportError; -class Transport extends component_emitter_1.Emitter { - /** - * Transport abstract constructor. - * - * @param {Object} opts - options - * @protected - */ - constructor(opts) { - super(); - this.writable = false; - (0, util_js_1.installTimerFunctions)(this, opts); - this.opts = opts; - this.query = opts.query; - this.socket = opts.socket; - this.supportsBinary = !opts.forceBase64; + + 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; } - /** - * Emits an error. - * - * @param {String} reason - * @param description - * @param context - the error context - * @return {Transport} for chaining - * @protected - */ - onError(reason, description, context) { - super.emitReserved("error", new TransportError(reason, description, context)); - return this; + + if (r !== 0) { + s++; } - /** - * Opens the transport. - */ - open() { - this.readyState = "opening"; - this.doOpen(); - return this; + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; } - /** - * Closes the transport. - */ - close() { - if (this.readyState === "opening" || this.readyState === "open") { - this.doClose(); - this.onClose(); - } + + 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; } - /** - * Sends multiple packets. - * - * @param {Array} packets - */ - send(packets) { - if (this.readyState === "open") { - this.write(packets); - } - else { - // this might happen if the transport was silently closed in the beforeunload event handler - debug("transport is not open, discarding packets"); - } + + // 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]++; + } } - /** - * Called upon open - * - * @protected - */ - onOpen() { - this.readyState = "open"; - this.writable = true; - super.emitReserved("open"); + 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; } - /** - * Called with data. - * - * @param {String} data - * @protected - */ - onData(data) { - const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); - this.onPacket(packet); + + 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; + } } - /** - * Called with a decoded packet. - * - * @protected - */ - onPacket(packet) { - super.emitReserved("packet", packet); + + 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; } - /** - * Called upon close. - * - * @protected - */ - onClose(details) { - this.readyState = "closed"; - super.emitReserved("close", details); + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; } - /** - * Pauses the transport, in order not to lose packets during an upgrade. - * - * @param onPause - */ - pause(onPause) { } - createUri(schema, query = {}) { - return (schema + - "://" + - this._hostname() + - this._port() + - this.opts.path + - this._query(query)); + + 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; } - _hostname() { - const hostname = this.opts.hostname; - return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + 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; } - _port() { - if (this.opts.port && - ((this.opts.secure && Number(this.opts.port !== 443)) || - (!this.opts.secure && Number(this.opts.port) !== 80))) { - return ":" + this.opts.port; - } - else { - return ""; - } + + // 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; + } } - _query(query) { - const encodedQuery = (0, parseqs_js_1.encode)(query); - return encodedQuery.length ? "?" + encodedQuery : ""; + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } } -} -exports.Transport = Transport; -},{"./contrib/parseqs.js":394,"./util.js":406,"@socket.io/component-emitter":26,"debug":407,"engine.io-parser":413}],400:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transports = void 0; -const polling_xhr_node_js_1 = require("./polling-xhr.node.js"); -const websocket_node_js_1 = require("./websocket.node.js"); -const webtransport_js_1 = require("./webtransport.js"); -exports.transports = { - websocket: websocket_node_js_1.WS, - webtransport: webtransport_js_1.WT, - polling: polling_xhr_node_js_1.XHR, -}; + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); -},{"./polling-xhr.node.js":402,"./websocket.node.js":404,"./webtransport.js":405}],401:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Fetch = void 0; -const polling_js_1 = require("./polling.js"); -/** - * HTTP long-polling based on the built-in `fetch()` method. - * - * Usage: browser, Node.js (since v18), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch - * @see https://caniuse.com/fetch - * @see https://nodejs.org/api/globals.html#fetch - */ -class Fetch extends polling_js_1.Polling { - doPoll() { - this._fetch() - .then((res) => { - if (!res.ok) { - return this.onError("fetch read error", res.status, res); - } - res.text().then((data) => this.onData(data)); - }) - .catch((err) => { - this.onError("fetch read error", err); - }); - } - doWrite(data, callback) { - this._fetch(data) - .then((res) => { - if (!res.ok) { - return this.onError("fetch write error", res.status, res); - } - callback(); - }) - .catch((err) => { - this.onError("fetch write error", err); - }); - } - _fetch(data) { - var _a; - const isPost = data !== undefined; - const headers = new Headers(this.opts.extraHeaders); - if (isPost) { - headers.set("content-type", "text/plain;charset=UTF-8"); - } - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.appendCookies(headers); - return fetch(this.uri(), { - method: isPost ? "POST" : "GET", - body: isPost ? data : null, - headers, - credentials: this.opts.withCredentials ? "include" : "omit", - }).then((res) => { - var _a; - // @ts-ignore getSetCookie() was added in Node.js v19.7.0 - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(res.headers.getSetCookie()); - return res; - }); - } -} -exports.Fetch = Fetch; + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); -},{"./polling.js":403}],402:[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.XHR = exports.Request = exports.BaseXHR = void 0; -const polling_js_1 = require("./polling.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("../util.js"); -const globals_node_js_1 = require("../globals.node.js"); -const has_cors_js_1 = require("../contrib/has-cors.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -function empty() { } -class BaseXHR extends polling_js_1.Polling { - /** - * XHR Polling constructor. - * - * @param {Object} opts - * @package - */ - constructor(opts) { - super(opts); - if (typeof location !== "undefined") { - const isSSL = "https:" === location.protocol; - let port = location.port; - // some user agents have empty `location.port` - if (!port) { - port = isSSL ? "443" : "80"; - } - this.xd = - (typeof location !== "undefined" && - opts.hostname !== location.hostname) || - port !== opts.port; + 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; + } } - /** - * Sends data. - * - * @param {String} data to send. - * @param {Function} called upon flush. - * @private - */ - doWrite(data, fn) { - const req = this.request({ - method: "POST", - data: data, - }); - req.on("success", fn); - req.on("error", (xhrStatus, context) => { - this.onError("xhr post error", xhrStatus, context); - }); + if (q) { + q.strip(); } - /** - * Starts a poll cycle. - * - * @private - */ - doPoll() { - debug("xhr poll"); - const req = this.request(); - req.on("data", this.onData.bind(this)); - req.on("error", (xhrStatus, context) => { - this.onError("xhr poll error", xhrStatus, context); - }); - this.pollXhr = req; + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); } -} -exports.BaseXHR = BaseXHR; -class Request extends component_emitter_1.Emitter { - /** - * Request constructor - * - * @param {Object} options - * @package - */ - constructor(createRequest, uri, opts) { - super(); - this.createRequest = createRequest; - (0, util_js_1.installTimerFunctions)(this, opts); - this._opts = opts; - this._method = opts.method || "GET"; - this._uri = uri; - this._data = undefined !== opts.data ? opts.data : null; - this._create(); + + 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) + }; } - /** - * Creates the XHR object and sends the request. - * - * @private - */ - _create() { - var _a; - const opts = (0, util_js_1.pick)(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); - opts.xdomain = !!this._opts.xd; - const xhr = (this._xhr = this.createRequest(opts)); - try { - debug("xhr open %s: %s", this._method, this._uri); - xhr.open(this._method, this._uri, true); - try { - if (this._opts.extraHeaders) { - // @ts-ignore - xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); - for (let i in this._opts.extraHeaders) { - if (this._opts.extraHeaders.hasOwnProperty(i)) { - xhr.setRequestHeader(i, this._opts.extraHeaders[i]); - } - } - } - } - catch (e) { } - if ("POST" === this._method) { - try { - xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); - } - catch (e) { } - } - try { - xhr.setRequestHeader("Accept", "*/*"); - } - catch (e) { } - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); - // ie6 check - if ("withCredentials" in xhr) { - xhr.withCredentials = this._opts.withCredentials; - } - if (this._opts.requestTimeout) { - xhr.timeout = this._opts.requestTimeout; - } - xhr.onreadystatechange = () => { - var _a; - if (xhr.readyState === 3) { - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies( - // @ts-ignore - xhr.getResponseHeader("set-cookie")); - } - if (4 !== xhr.readyState) - return; - if (200 === xhr.status || 1223 === xhr.status) { - this._onLoad(); - } - else { - // make sure the `error` event handler that's user-set - // does not throw in the same tick and gets caught here - this.setTimeoutFn(() => { - this._onError(typeof xhr.status === "number" ? xhr.status : 0); - }, 0); - } - }; - debug("xhr data %s", this._data); - xhr.send(this._data); - } - catch (e) { - // Need to defer since .create() is called directly from the constructor - // and thus the 'error' event can only be only bound *after* this exception - // occurs. Therefore, also, we cannot throw here at all. - this.setTimeoutFn(() => { - this._onError(e); - }, 0); - return; - } - if (typeof document !== "undefined") { - this._index = Request.requestsCount++; - Request.requests[this._index] = this; + + 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 + }; } - /** - * Called upon error. - * - * @private - */ - _onError(err) { - this.emitReserved("error", err, this._xhr); - this._cleanup(true); - } - /** - * Cleans up house. - * - * @private - */ - _cleanup(fromError) { - if ("undefined" === typeof this._xhr || null === this._xhr) { - return; - } - this._xhr.onreadystatechange = empty; - if (fromError) { - try { - this._xhr.abort(); - } - catch (e) { } - } - if (typeof document !== "undefined") { - delete Request.requests[this._index]; - } - this._xhr = null; + + 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 + }; } - /** - * Called upon load. - * - * @private - */ - _onLoad() { - const data = this._xhr.responseText; - if (data !== null) { - this.emitReserved("data", data); - this.emitReserved("success"); - this._cleanup(); + + 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 + }; } - /** - * Aborts the request. - * - * @package - */ - abort() { - this._cleanup(); + + // 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 + }; } -} -exports.Request = Request; -Request.requestsCount = 0; -Request.requests = {}; -/** - * Aborts pending requests when unloading the window. This is needed to prevent - * memory leaks (e.g. when using IE) and to ensure that no spurious error is - * emitted. - */ -if (typeof document !== "undefined") { - // @ts-ignore - if (typeof attachEvent === "function") { - // @ts-ignore - attachEvent("onunload", unloadHandler); + + // 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])) + }; } - else if (typeof addEventListener === "function") { - const terminationEvent = "onpagehide" in globals_node_js_1.globalThisShim ? "pagehide" : "unload"; - addEventListener(terminationEvent, unloadHandler, false); + + 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; } -} -function unloadHandler() { - for (let i in Request.requests) { - if (Request.requests.hasOwnProperty(i)) { - Request.requests[i].abort(); - } + + 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; } -} -const hasXHR2 = (function () { - const xhr = newRequest({ - xdomain: false, - }); - return xhr && xhr.responseType !== null; -})(); -/** - * HTTP long-polling based on the built-in `XMLHttpRequest` object. - * - * Usage: browser - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - */ -class XHR extends BaseXHR { - constructor(opts) { - super(opts); - const forceBase64 = opts && opts.forceBase64; - this.supportsBinary = hasXHR2 && !forceBase64; + + 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(); } - request(opts = {}) { - Object.assign(opts, { xd: this.xd }, this.opts); - return new Request(newRequest, this.uri(), opts); + + // 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; } -} -exports.XHR = XHR; -function newRequest(opts) { - const xdomain = opts.xdomain; - // XMLHttpRequest can be disabled on IE - try { - if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { - return new XMLHttpRequest(); + + 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); } - } - catch (e) { } - if (!xdomain) { - try { - return new globals_node_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + + 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); } - catch (e) { } - } -} + } -},{"../contrib/has-cors.js":393,"../globals.node.js":396,"../util.js":406,"./polling.js":403,"@socket.io/component-emitter":26,"debug":407}],403:[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.Polling = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -class Polling extends transport_js_1.Transport { - constructor() { - super(...arguments); - this._polling = false; - } - get name() { - return "polling"; + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } } - /** - * Opens the socket (triggers polling). We write a PING message to determine - * when the transport is open. - * - * @protected - */ - doOpen() { - this._poll(); + + 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(); } - /** - * Pauses polling. - * - * @param {Function} onPause - callback upon buffers are flushed and transport is paused - * @package - */ - pause(onPause) { - this.readyState = "pausing"; - const pause = () => { - debug("paused"); - this.readyState = "paused"; - onPause(); - }; - if (this._polling || !this.writable) { - let total = 0; - if (this._polling) { - debug("we are currently polling - waiting to pause"); - total++; - this.once("pollComplete", function () { - debug("pre-pause polling complete"); - --total || pause(); - }); - } - if (!this.writable) { - debug("we are currently writing - waiting to pause"); - total++; - this.once("drain", function () { - debug("pre-pause writing complete"); - --total || pause(); - }); - } + + 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); } - else { - pause(); + } + + 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); + } } - /** - * Starts polling cycle. - * - * @private - */ - _poll() { - debug("polling"); - this._polling = true; - this.doPoll(); - this.emitReserved("poll"); + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; } - /** - * Overloads onData to detect payloads. - * - * @protected - */ - onData(data) { - debug("polling got data %s", data); - const callback = (packet) => { - // if its the first message we consider the transport open - if ("opening" === this.readyState && packet.type === "open") { - this.onOpen(); - } - // if its a close packet, we close the ongoing requests - if ("close" === packet.type) { - this.onClose({ description: "transport closed by the server" }); - return false; - } - // otherwise bypass onData and handle the message - this.onPacket(packet); - }; - // decode payload - (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); - // if an event did not trigger closing - if ("closed" !== this.readyState) { - // if we got data we're not polling - this._polling = false; - this.emitReserved("pollComplete"); - if ("open" === this.readyState) { - this._poll(); - } - else { - debug('ignoring poll - transport state "%s"', this.readyState); - } - } + + if (res.cmpn(0) < 0) { + res.iadd(p); } - /** - * For polling, send a close packet. - * - * @protected - */ - doClose() { - const close = () => { - debug("writing close packet"); - this.write([{ type: "close" }]); - }; - if ("open" === this.readyState) { - debug("transport open - closing"); - close(); - } - else { - // in case we're trying to close while - // handshaking is in progress (GH-164) - debug("transport not open - deferring close"); - this.once("open", close); - } + + 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); } - /** - * Writes a packets payload. - * - * @param {Array} packets - data packets - * @protected - */ - write(packets) { - this.writable = false; - (0, engine_io_parser_1.encodePayload)(packets, (data) => { - this.doWrite(data, () => { - this.writable = true; - this.emitReserved("drain"); - }); - }); + + 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; } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "https" : "http"; - const query = this.query || {}; - // cache busting is forced - if (false !== this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - if (!this.supportsBinary && !query.sid) { - query.b64 = 1; - } - return this.createUri(schema, query); + if (carry !== 0) { + this.words[i] = carry; + this.length++; } -} -exports.Polling = Polling; + 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; + }; -},{"../transport.js":399,"../util.js":406,"debug":407,"engine.io-parser":413}],404:[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.WS = exports.BaseWS = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("../globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() -// detect ReactNative environment -const isReactNative = typeof navigator !== "undefined" && - typeof navigator.product === "string" && - navigator.product.toLowerCase() === "reactnative"; -class BaseWS extends transport_js_1.Transport { - get name() { - return "websocket"; - } - doOpen() { - const uri = this.uri(); - const protocols = this.opts.protocols; - // React Native only supports the 'headers' option, and will print a warning if anything else is passed - const opts = isReactNative - ? {} - : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); - if (this.opts.extraHeaders) { - opts.headers = this.opts.extraHeaders; - } - try { - this.ws = this.createSocket(uri, protocols, opts); - } - catch (err) { - return this.emitReserved("error", err); - } - this.ws.binaryType = this.socket.binaryType; - this.addEventListeners(); - } - /** - * Adds event listeners to the socket - * - * @private - */ - addEventListeners() { - this.ws.onopen = () => { - if (this.opts.autoUnref) { - this.ws._socket.unref(); - } - this.onOpen(); - }; - this.ws.onclose = (closeEvent) => this.onClose({ - description: "websocket connection closed", - context: closeEvent, - }); - this.ws.onmessage = (ev) => this.onData(ev.data); - this.ws.onerror = (e) => this.onError("websocket error", e); - } - write(packets) { - this.writable = false; - // encodePacket efficient as it uses WS framing - // no need for encodePayload - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { - // Sometimes the websocket has already been closed but the browser didn't - // have a chance of informing us about it yet, in that case send will - // throw an error - try { - this.doWrite(packet, data); - } - catch (e) { - debug("websocket closed before onclose event"); - } - if (lastPacket) { - // fake drain - // defer to next tick to allow Socket to clear writeBuffer - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } - } - doClose() { - if (typeof this.ws !== "undefined") { - this.ws.onerror = () => { }; - this.ws.close(); - this.ws = null; - } - } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "wss" : "ws"; - const query = this.query || {}; - // append timestamp to URI - if (this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - // communicate binary support capabilities - if (!this.supportsBinary) { - query.b64 = 1; - } - return this.createUri(schema, query); - } -} -exports.BaseWS = BaseWS; -const WebSocketCtor = globals_node_js_1.globalThisShim.WebSocket || globals_node_js_1.globalThisShim.MozWebSocket; -/** - * WebSocket transport based on the built-in `WebSocket` object. - * - * Usage: browser, Node.js (since v21), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket - * @see https://caniuse.com/mdn-api_websocket - * @see https://nodejs.org/api/globals.html#websocket - */ -class WS extends BaseWS { - createSocket(uri, protocols, opts) { - return !isReactNative - ? protocols - ? new WebSocketCtor(uri, protocols) - : new WebSocketCtor(uri) - : new WebSocketCtor(uri, protocols, opts); - } - doWrite(_packet, data) { - this.ws.send(data); - } -} -exports.WS = WS; + 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; -},{"../globals.node.js":396,"../transport.js":399,"../util.js":406,"debug":407,"engine.io-parser":413}],405:[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.WT = void 0; -const transport_js_1 = require("../transport.js"); -const globals_node_js_1 = require("../globals.node.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() -/** - * WebTransport transport based on the built-in `WebTransport` object. - * - * Usage: browser, Node.js (with the `@fails-components/webtransport` package) - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport - * @see https://caniuse.com/webtransport - */ -class WT extends transport_js_1.Transport { - get name() { - return "webtransport"; - } - doOpen() { - try { - // @ts-ignore - this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); - } - catch (err) { - return this.emitReserved("error", err); - } - this._transport.closed - .then(() => { - debug("transport closed gracefully"); - this.onClose(); - }) - .catch((err) => { - debug("transport closed due to %s", err); - this.onError("webtransport error", err); - }); - // note: we could have used async/await, but that would require some additional polyfills - this._transport.ready.then(() => { - this._transport.createBidirectionalStream().then((stream) => { - const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); - const reader = stream.readable.pipeThrough(decoderStream).getReader(); - const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); - encoderStream.readable.pipeTo(stream.writable); - this._writer = encoderStream.writable.getWriter(); - const read = () => { - reader - .read() - .then(({ done, value }) => { - if (done) { - debug("session is closed"); - return; - } - debug("received chunk: %o", value); - this.onPacket(value); - read(); - }) - .catch((err) => { - debug("an error occurred while reading: %s", err); - }); - }; - read(); - const packet = { type: "open" }; - if (this.query.sid) { - packet.data = `{"sid":"${this.query.sid}"}`; - } - this._writer.write(packet).then(() => this.onOpen()); - }); - }); + 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(); + } } - write(packets) { - this.writable = false; - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - this._writer.write(packet).then(() => { - if (lastPacket) { - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } + + 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]; } - doClose() { - var _a; - (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close(); + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; } -} -exports.WT = WT; -},{"../globals.node.js":396,"../transport.js":399,"debug":407,"engine.io-parser":413}],406:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.pick = pick; -exports.installTimerFunctions = installTimerFunctions; -exports.byteLength = byteLength; -exports.randomString = randomString; -const globals_node_js_1 = require("./globals.node.js"); -function pick(obj, ...attr) { - return attr.reduce((acc, k) => { - if (obj.hasOwnProperty(k)) { - acc[k] = obj[k]; - } - return acc; - }, {}); -} -// Keep a reference to the real timeout functions so they can be used when overridden -const NATIVE_SET_TIMEOUT = globals_node_js_1.globalThisShim.setTimeout; -const NATIVE_CLEAR_TIMEOUT = globals_node_js_1.globalThisShim.clearTimeout; -function installTimerFunctions(obj, opts) { - if (opts.useNativeTimers) { - obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globals_node_js_1.globalThisShim); + // 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; } - else { - obj.setTimeoutFn = globals_node_js_1.globalThisShim.setTimeout.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = globals_node_js_1.globalThisShim.clearTimeout.bind(globals_node_js_1.globalThisShim); + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; } -} -// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) -const BASE64_OVERHEAD = 1.33; -// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 -function byteLength(obj) { - if (typeof obj === "string") { - return utf8Length(obj); + }; + + 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); } - // arraybuffer or blob - return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); -} -function utf8Length(str) { - let c = 0, length = 0; - for (let i = 0, l = str.length; i < l; i++) { - c = str.charCodeAt(i); - if (c < 0x80) { - length += 1; - } - else if (c < 0x800) { - length += 2; - } - else if (c < 0xd800 || c >= 0xe000) { - length += 3; - } - else { - i++; - length += 4; - } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } } - return length; -} -/** - * Generates a random 8-characters string. - */ -function randomString() { - return (Date.now().toString(36).substring(3) + - Math.random().toString(36).substring(2, 5)); -} + return num; + }; -},{"./globals.node.js":396}],407:[function(require,module,exports){ -(function (process){(function (){ -/* eslint-env browser */ + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); -/** - * This is the web browser implementation of `debug()`. - */ + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); + 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; -/** - * Colors. - */ + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; + // 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; + } + } -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } + 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'); + }; - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; - let m; + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + return this.m.sub(a)._forceRed(this); + }; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + Red.prototype.add = function add (a, b) { + this._verify2(a, b); -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; - if (!this.useColors) { - return; - } + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); - args.splice(lastC, 0, c); -} + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; - return r; -} + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; -module.exports = require('./common')(exports); + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); -const {formatters} = module.exports; + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; + // 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)); -}).call(this)}).call(this,require('_process')) -},{"./common":408,"_process":506}],408:[function(require,module,exports){ + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ + return r; + }; -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - createDebug.destroy = destroy; + 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); + } + }; - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); - /** - * The currently active debug mode names, and names to skip. - */ + 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); + } - createDebug.names = []; - createDebug.skips = []; + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + 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); + } - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; + return res; + }; - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); - const self = debug; + return r === num ? r.clone() : r; + }; - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; - args[0] = createDebug.coerce(args[0]); + // + // Montgomery method engine + // - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } + BN.mont = function mont (num) { + return new Mont(num); + }; - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); + function Mont (m) { + Red.call(this, m); - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } + 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); - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } + 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; - return debug; - } + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } + return res._forceRed(this); + }; - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; + 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); + } - createDebug.names = []; - createDebug.skips = []; + return res._forceRed(this); + }; - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; + 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); - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } +},{"buffer":55}],386:[function(require,module,exports){ +module.exports={ + "name": "elliptic", + "version": "6.5.5", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "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" + }, + "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" + } +} - namespaces = split[i].replace(/\*/g, '.*?'); +},{}],387:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hasCORS = void 0; +// imported from https://github.com/component/has-cors +let value = false; +try { + value = typeof XMLHttpRequest !== 'undefined' && + 'withCredentials' in new XMLHttpRequest(); +} +catch (err) { + // if XMLHttp support is disabled in IE then it will throw + // when trying to create +} +exports.hasCORS = value; - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } +},{}],388:[function(require,module,exports){ +"use strict"; +// imported from https://github.com/galkn/querystring +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decode = exports.encode = void 0; +function encode(obj) { + let str = ''; + for (let i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) + str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + return str; +} +exports.encode = encode; +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ +function decode(qs) { + let qry = {}; + let pairs = qs.split('&'); + for (let i = 0, l = pairs.length; i < l; i++) { + let pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +} +exports.decode = decode; - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } +},{}],389:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parse = void 0; +// imported from https://github.com/galkn/parseuri +/** + * Parses a URI + * + * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. + * + * See: + * - https://developer.mozilla.org/en-US/docs/Web/API/URL + * - https://caniuse.com/url + * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B + * + * History of the parse() method: + * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c + * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 + * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 + * + * @author Steven Levithan (MIT license) + * @api private + */ +const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; +const parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; +function parse(str) { + if (str.length > 2000) { + throw "URI too long"; + } + const src = str, b = str.indexOf('['), e = str.indexOf(']'); + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + let m = re.exec(str || ''), uri = {}, i = 14; + while (i--) { + uri[parts[i]] = m[i] || ''; + } + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + return uri; +} +exports.parse = parse; +function pathNames(obj, path) { + const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); + if (path.slice(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.slice(-1) == '/') { + names.splice(names.length - 1, 1); + } + return names; +} +function queryKey(uri, query) { + const data = {}; + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + return data; +} - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } +},{}],390:[function(require,module,exports){ +// imported from https://github.com/unshiftio/yeast +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.yeast = exports.decode = exports.encode = void 0; +const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''), length = 64, map = {}; +let seed = 0, i = 0, prev; +/** + * Return a string representing the specified number. + * + * @param {Number} num The number to convert. + * @returns {String} The string representation of the number. + * @api public + */ +function encode(num) { + let encoded = ''; + do { + encoded = alphabet[num % length] + encoded; + num = Math.floor(num / length); + } while (num > 0); + return encoded; +} +exports.encode = encode; +/** + * Return the integer value specified by the given string. + * + * @param {String} str The string to convert. + * @returns {Number} The integer value represented by the string. + * @api public + */ +function decode(str) { + let decoded = 0; + for (i = 0; i < str.length; i++) { + decoded = decoded * length + map[str.charAt(i)]; + } + return decoded; +} +exports.decode = decode; +/** + * Yeast: A tiny growing id generator. + * + * @returns {String} A unique id. + * @api public + */ +function yeast() { + const now = encode(+new Date()); + if (now !== prev) + return seed = 0, prev = now; + return now + '.' + encode(seed++); +} +exports.yeast = yeast; +// +// Map each character to its index. +// +for (; i < length; i++) + map[alphabet[i]] = i; - let i; - let len; +},{}],391:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalThisShim = void 0; +exports.globalThisShim = (() => { + if (typeof self !== "undefined") { + return self; + } + else if (typeof window !== "undefined") { + return window; + } + else { + return Function("return this")(); + } +})(); - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } +},{}],392:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0; +const socket_js_1 = require("./socket.js"); +Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); +exports.protocol = socket_js_1.Socket.protocol; +var transport_js_1 = require("./transport.js"); +Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); +Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); +var index_js_1 = require("./transports/index.js"); +Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); +var util_js_1 = require("./util.js"); +Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); +var parseuri_js_1 = require("./contrib/parseuri.js"); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); +var websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return websocket_constructor_js_1.nextTick; } }); + +},{"./contrib/parseuri.js":389,"./socket.js":393,"./transport.js":394,"./transports/index.js":395,"./transports/websocket-constructor.js":397,"./util.js":401}],393:[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.Socket = void 0; +const index_js_1 = require("./transports/index.js"); +const util_js_1 = require("./util.js"); +const parseqs_js_1 = require("./contrib/parseqs.js"); +const parseuri_js_1 = require("./contrib/parseuri.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const component_emitter_1 = require("@socket.io/component-emitter"); +const engine_io_parser_1 = require("engine.io-parser"); +const websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() +class Socket extends component_emitter_1.Emitter { + /** + * Socket constructor. + * + * @param {String|Object} uri - uri or options + * @param {Object} opts - options + */ + constructor(uri, opts = {}) { + super(); + this.binaryType = websocket_constructor_js_1.defaultBinaryType; + this.writeBuffer = []; + if (uri && "object" === typeof uri) { + opts = uri; + uri = null; + } + if (uri) { + uri = (0, parseuri_js_1.parse)(uri); + opts.hostname = uri.host; + opts.secure = uri.protocol === "https" || uri.protocol === "wss"; + opts.port = uri.port; + if (uri.query) + opts.query = uri.query; + } + else if (opts.host) { + opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; + } + (0, util_js_1.installTimerFunctions)(this, opts); + this.secure = + null != opts.secure + ? opts.secure + : typeof location !== "undefined" && "https:" === location.protocol; + if (opts.hostname && !opts.port) { + // if no port is specified manually, use the protocol default + opts.port = this.secure ? "443" : "80"; + } + this.hostname = + opts.hostname || + (typeof location !== "undefined" ? location.hostname : "localhost"); + this.port = + opts.port || + (typeof location !== "undefined" && location.port + ? location.port + : this.secure + ? "443" + : "80"); + this.transports = opts.transports || [ + "polling", + "websocket", + "webtransport", + ]; + this.writeBuffer = []; + this.prevBufferLen = 0; + this.opts = Object.assign({ + path: "/engine.io", + agent: false, + withCredentials: false, + upgrade: true, + timestampParam: "t", + rememberUpgrade: false, + addTrailingSlash: true, + rejectUnauthorized: true, + perMessageDeflate: { + threshold: 1024, + }, + transportOptions: {}, + closeOnBeforeunload: false, + }, opts); + this.opts.path = + this.opts.path.replace(/\/$/, "") + + (this.opts.addTrailingSlash ? "/" : ""); + if (typeof this.opts.query === "string") { + this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); + } + // set on handshake + this.id = null; + this.upgrades = null; + this.pingInterval = null; + this.pingTimeout = null; + // set on heartbeat + this.pingTimeoutTimer = null; + if (typeof addEventListener === "function") { + if (this.opts.closeOnBeforeunload) { + // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener + // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is + // closed/reloaded) + this.beforeunloadEventListener = () => { + if (this.transport) { + // silently close the transport + this.transport.removeAllListeners(); + this.transport.close(); + } + }; + addEventListener("beforeunload", this.beforeunloadEventListener, false); + } + if (this.hostname !== "localhost") { + this.offlineEventListener = () => { + this.onClose("transport close", { + description: "network connection lost", + }); + }; + addEventListener("offline", this.offlineEventListener, false); + } + } + this.open(); + } + /** + * Creates transport of the given type. + * + * @param {String} name - transport name + * @return {Transport} + * @private + */ + createTransport(name) { + debug('creating transport "%s"', name); + const query = Object.assign({}, this.opts.query); + // append engine.io protocol identifier + query.EIO = engine_io_parser_1.protocol; + // transport name + query.transport = name; + // session id if we already have one + if (this.id) + query.sid = this.id; + const opts = Object.assign({}, this.opts, { + query, + socket: this, + hostname: this.hostname, + secure: this.secure, + port: this.port, + }, this.opts.transportOptions[name]); + debug("options: %j", opts); + return new index_js_1.transports[name](opts); + } + /** + * Initializes transport to use and starts probe. + * + * @private + */ + open() { + let transport; + if (this.opts.rememberUpgrade && + Socket.priorWebsocketSuccess && + this.transports.indexOf("websocket") !== -1) { + transport = "websocket"; + } + else if (0 === this.transports.length) { + // Emit error on next tick so it can be listened to + this.setTimeoutFn(() => { + this.emitReserved("error", "No transports available"); + }, 0); + return; + } + else { + transport = this.transports[0]; + } + this.readyState = "opening"; + // Retry with the next transport if the transport is disabled (jsonp: false) + try { + transport = this.createTransport(transport); + } + catch (e) { + debug("error while creating transport: %s", e); + this.transports.shift(); + this.open(); + return; + } + transport.open(); + this.setTransport(transport); + } + /** + * Sets the current transport. Disables the existing one (if any). + * + * @private + */ + setTransport(transport) { + debug("setting transport %s", transport.name); + if (this.transport) { + debug("clearing existing transport %s", this.transport.name); + this.transport.removeAllListeners(); + } + // set up transport + this.transport = transport; + // set up transport listeners + transport + .on("drain", this.onDrain.bind(this)) + .on("packet", this.onPacket.bind(this)) + .on("error", this.onError.bind(this)) + .on("close", (reason) => this.onClose("transport close", reason)); + } + /** + * Probes a transport. + * + * @param {String} name - transport name + * @private + */ + probe(name) { + debug('probing transport "%s"', name); + let transport = this.createTransport(name); + let failed = false; + Socket.priorWebsocketSuccess = false; + const onTransportOpen = () => { + if (failed) + return; + debug('probe transport "%s" opened', name); + transport.send([{ type: "ping", data: "probe" }]); + transport.once("packet", (msg) => { + if (failed) + return; + if ("pong" === msg.type && "probe" === msg.data) { + debug('probe transport "%s" pong', name); + this.upgrading = true; + this.emitReserved("upgrading", transport); + if (!transport) + return; + Socket.priorWebsocketSuccess = "websocket" === transport.name; + debug('pausing current transport "%s"', this.transport.name); + this.transport.pause(() => { + if (failed) + return; + if ("closed" === this.readyState) + return; + debug("changing transport and sending upgrade packet"); + cleanup(); + this.setTransport(transport); + transport.send([{ type: "upgrade" }]); + this.emitReserved("upgrade", transport); + transport = null; + this.upgrading = false; + this.flush(); + }); + } + else { + debug('probe transport "%s" failed', name); + const err = new Error("probe error"); + // @ts-ignore + err.transport = transport.name; + this.emitReserved("upgradeError", err); + } + }); + }; + function freezeTransport() { + if (failed) + return; + // Any callback called by transport should be ignored since now + failed = true; + cleanup(); + transport.close(); + transport = null; + } + // Handle any error that happens while probing + const onerror = (err) => { + const error = new Error("probe error: " + err); + // @ts-ignore + error.transport = transport.name; + freezeTransport(); + debug('probe transport "%s" failed because of error: %s', name, err); + this.emitReserved("upgradeError", error); + }; + function onTransportClose() { + onerror("transport closed"); + } + // When the socket is closed while we're probing + function onclose() { + onerror("socket closed"); + } + // When the socket is upgraded while we're probing + function onupgrade(to) { + if (transport && to.name !== transport.name) { + debug('"%s" works - aborting "%s"', to.name, transport.name); + freezeTransport(); + } + } + // Remove all listeners on the transport and on self + const cleanup = () => { + transport.removeListener("open", onTransportOpen); + transport.removeListener("error", onerror); + transport.removeListener("close", onTransportClose); + this.off("close", onclose); + this.off("upgrading", onupgrade); + }; + transport.once("open", onTransportOpen); + transport.once("error", onerror); + transport.once("close", onTransportClose); + this.once("close", onclose); + this.once("upgrading", onupgrade); + if (this.upgrades.indexOf("webtransport") !== -1 && + name !== "webtransport") { + // favor WebTransport + this.setTimeoutFn(() => { + if (!failed) { + transport.open(); + } + }, 200); + } + else { + transport.open(); + } + } + /** + * Called when connection is deemed open. + * + * @private + */ + onOpen() { + debug("socket open"); + this.readyState = "open"; + Socket.priorWebsocketSuccess = "websocket" === this.transport.name; + this.emitReserved("open"); + this.flush(); + // we check for `readyState` in case an `open` + // listener already closed the socket + if ("open" === this.readyState && this.opts.upgrade) { + debug("starting upgrade probes"); + let i = 0; + const l = this.upgrades.length; + for (; i < l; i++) { + this.probe(this.upgrades[i]); + } + } + } + /** + * Handles a packet. + * + * @private + */ + onPacket(packet) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket receive: type "%s", data "%s"', packet.type, packet.data); + this.emitReserved("packet", packet); + // Socket is live - any packet counts + this.emitReserved("heartbeat"); + this.resetPingTimeout(); + switch (packet.type) { + case "open": + this.onHandshake(JSON.parse(packet.data)); + break; + case "ping": + this.sendPacket("pong"); + this.emitReserved("ping"); + this.emitReserved("pong"); + break; + case "error": + const err = new Error("server error"); + // @ts-ignore + err.code = packet.data; + this.onError(err); + break; + case "message": + this.emitReserved("data", packet.data); + this.emitReserved("message", packet.data); + break; + } + } + else { + debug('packet received with socket readyState "%s"', this.readyState); + } + } + /** + * Called upon handshake completion. + * + * @param {Object} data - handshake obj + * @private + */ + onHandshake(data) { + this.emitReserved("handshake", data); + this.id = data.sid; + this.transport.query.sid = data.sid; + this.upgrades = this.filterUpgrades(data.upgrades); + this.pingInterval = data.pingInterval; + this.pingTimeout = data.pingTimeout; + this.maxPayload = data.maxPayload; + this.onOpen(); + // In case open handler closes socket + if ("closed" === this.readyState) + return; + this.resetPingTimeout(); + } + /** + * Sets and resets ping timeout timer based on server pings. + * + * @private + */ + resetPingTimeout() { + this.clearTimeoutFn(this.pingTimeoutTimer); + this.pingTimeoutTimer = this.setTimeoutFn(() => { + this.onClose("ping timeout"); + }, this.pingInterval + this.pingTimeout); + if (this.opts.autoUnref) { + this.pingTimeoutTimer.unref(); + } + } + /** + * Called on `drain` event + * + * @private + */ + onDrain() { + this.writeBuffer.splice(0, this.prevBufferLen); + // setting prevBufferLen = 0 is very important + // for example, when upgrading, upgrade packet is sent over, + // and a nonzero prevBufferLen could cause problems on `drain` + this.prevBufferLen = 0; + if (0 === this.writeBuffer.length) { + this.emitReserved("drain"); + } + else { + this.flush(); + } + } + /** + * Flush write buffers. + * + * @private + */ + flush() { + if ("closed" !== this.readyState && + this.transport.writable && + !this.upgrading && + this.writeBuffer.length) { + const packets = this.getWritablePackets(); + debug("flushing %d packets in socket", packets.length); + this.transport.send(packets); + // keep track of current length of writeBuffer + // splice writeBuffer and callbackBuffer on `drain` + this.prevBufferLen = packets.length; + this.emitReserved("flush"); + } + } + /** + * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP + * long-polling) + * + * @private + */ + getWritablePackets() { + const shouldCheckPayloadSize = this.maxPayload && + this.transport.name === "polling" && + this.writeBuffer.length > 1; + if (!shouldCheckPayloadSize) { + return this.writeBuffer; + } + let payloadSize = 1; // first packet type + for (let i = 0; i < this.writeBuffer.length; i++) { + const data = this.writeBuffer[i].data; + if (data) { + payloadSize += (0, util_js_1.byteLength)(data); + } + if (i > 0 && payloadSize > this.maxPayload) { + debug("only send %d out of %d packets", i, this.writeBuffer.length); + return this.writeBuffer.slice(0, i); + } + payloadSize += 2; // separator + packet type + } + debug("payload size is %d (max: %d)", payloadSize, this.maxPayload); + return this.writeBuffer; + } + /** + * Sends a message. + * + * @param {String} msg - message. + * @param {Object} options. + * @param {Function} callback function. + * @return {Socket} for chaining. + */ + write(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + send(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + /** + * Sends a packet. + * + * @param {String} type: packet type. + * @param {String} data. + * @param {Object} options. + * @param {Function} fn - callback function. + * @private + */ + sendPacket(type, data, options, fn) { + if ("function" === typeof data) { + fn = data; + data = undefined; + } + if ("function" === typeof options) { + fn = options; + options = null; + } + if ("closing" === this.readyState || "closed" === this.readyState) { + return; + } + options = options || {}; + options.compress = false !== options.compress; + const packet = { + type: type, + data: data, + options: options, + }; + this.emitReserved("packetCreate", packet); + this.writeBuffer.push(packet); + if (fn) + this.once("flush", fn); + this.flush(); + } + /** + * Closes the connection. + */ + close() { + const close = () => { + this.onClose("forced close"); + debug("socket closing - telling transport to close"); + this.transport.close(); + }; + const cleanupAndClose = () => { + this.off("upgrade", cleanupAndClose); + this.off("upgradeError", cleanupAndClose); + close(); + }; + const waitForUpgrade = () => { + // wait for upgrade to finish since we can't send packets while pausing a transport + this.once("upgrade", cleanupAndClose); + this.once("upgradeError", cleanupAndClose); + }; + if ("opening" === this.readyState || "open" === this.readyState) { + this.readyState = "closing"; + if (this.writeBuffer.length) { + this.once("drain", () => { + if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + }); + } + else if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + } + return this; + } + /** + * Called upon transport error + * + * @private + */ + onError(err) { + debug("socket error %j", err); + Socket.priorWebsocketSuccess = false; + this.emitReserved("error", err); + this.onClose("transport error", err); + } + /** + * Called upon transport close. + * + * @private + */ + onClose(reason, description) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket close with reason: "%s"', reason); + // clear timers + this.clearTimeoutFn(this.pingTimeoutTimer); + // stop event from firing again for transport + this.transport.removeAllListeners("close"); + // ensure transport won't stay open + this.transport.close(); + // ignore further transport communication + this.transport.removeAllListeners(); + if (typeof removeEventListener === "function") { + removeEventListener("beforeunload", this.beforeunloadEventListener, false); + removeEventListener("offline", this.offlineEventListener, false); + } + // set ready state + this.readyState = "closed"; + // clear session id + this.id = null; + // emit close event + this.emitReserved("close", reason, description); + // clean buffers after, so users can still + // grab the buffers on `close` event + this.writeBuffer = []; + this.prevBufferLen = 0; + } + } + /** + * Filters upgrades, returning only those matching client transports. + * + * @param {Array} upgrades - server upgrades + * @private + */ + filterUpgrades(upgrades) { + const filteredUpgrades = []; + let i = 0; + const j = upgrades.length; + for (; i < j; i++) { + if (~this.transports.indexOf(upgrades[i])) + filteredUpgrades.push(upgrades[i]); + } + return filteredUpgrades; + } +} +exports.Socket = Socket; +Socket.protocol = engine_io_parser_1.protocol; - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } +},{"./contrib/parseqs.js":388,"./contrib/parseuri.js":389,"./transports/index.js":395,"./transports/websocket-constructor.js":397,"./util.js":401,"@socket.io/component-emitter":26,"debug":364,"engine.io-parser":406}],394:[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.Transport = exports.TransportError = void 0; +const engine_io_parser_1 = require("engine.io-parser"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("./util.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const parseqs_js_1 = require("./contrib/parseqs.js"); +const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() +class TransportError extends Error { + constructor(reason, description, context) { + super(reason); + this.description = description; + this.context = context; + this.type = "TransportError"; + } +} +exports.TransportError = TransportError; +class Transport extends component_emitter_1.Emitter { + /** + * Transport abstract constructor. + * + * @param {Object} opts - options + * @protected + */ + constructor(opts) { + super(); + this.writable = false; + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.query = opts.query; + this.socket = opts.socket; + } + /** + * Emits an error. + * + * @param {String} reason + * @param description + * @param context - the error context + * @return {Transport} for chaining + * @protected + */ + onError(reason, description, context) { + super.emitReserved("error", new TransportError(reason, description, context)); + return this; + } + /** + * Opens the transport. + */ + open() { + this.readyState = "opening"; + this.doOpen(); + return this; + } + /** + * Closes the transport. + */ + close() { + if (this.readyState === "opening" || this.readyState === "open") { + this.doClose(); + this.onClose(); + } + return this; + } + /** + * Sends multiple packets. + * + * @param {Array} packets + */ + send(packets) { + if (this.readyState === "open") { + this.write(packets); + } + else { + // this might happen if the transport was silently closed in the beforeunload event handler + debug("transport is not open, discarding packets"); + } + } + /** + * Called upon open + * + * @protected + */ + onOpen() { + this.readyState = "open"; + this.writable = true; + super.emitReserved("open"); + } + /** + * Called with data. + * + * @param {String} data + * @protected + */ + onData(data) { + const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); + this.onPacket(packet); + } + /** + * Called with a decoded packet. + * + * @protected + */ + onPacket(packet) { + super.emitReserved("packet", packet); + } + /** + * Called upon close. + * + * @protected + */ + onClose(details) { + this.readyState = "closed"; + super.emitReserved("close", details); + } + /** + * Pauses the transport, in order not to lose packets during an upgrade. + * + * @param onPause + */ + pause(onPause) { } + createUri(schema, query = {}) { + return (schema + + "://" + + this._hostname() + + this._port() + + this.opts.path + + this._query(query)); + } + _hostname() { + const hostname = this.opts.hostname; + return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + } + _port() { + if (this.opts.port && + ((this.opts.secure && Number(this.opts.port !== 443)) || + (!this.opts.secure && Number(this.opts.port) !== 80))) { + return ":" + this.opts.port; + } + else { + return ""; + } + } + _query(query) { + const encodedQuery = (0, parseqs_js_1.encode)(query); + return encodedQuery.length ? "?" + encodedQuery : ""; + } +} +exports.Transport = Transport; - return false; - } +},{"./contrib/parseqs.js":388,"./util.js":401,"@socket.io/component-emitter":26,"debug":364,"engine.io-parser":406}],395:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.transports = void 0; +const polling_js_1 = require("./polling.js"); +const websocket_js_1 = require("./websocket.js"); +const webtransport_js_1 = require("./webtransport.js"); +exports.transports = { + websocket: websocket_js_1.WS, + webtransport: webtransport_js_1.WT, + polling: polling_js_1.Polling, +}; - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } +},{"./polling.js":396,"./websocket.js":398,"./webtransport.js":399}],396:[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.Request = exports.Polling = void 0; +const transport_js_1 = require("../transport.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const yeast_js_1 = require("../contrib/yeast.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const xmlhttprequest_js_1 = require("./xmlhttprequest.js"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("../util.js"); +const globalThis_js_1 = require("../globalThis.js"); +const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() +function empty() { } +const hasXHR2 = (function () { + const xhr = new xmlhttprequest_js_1.XHR({ + xdomain: false, + }); + return null != xhr.responseType; +})(); +class Polling extends transport_js_1.Transport { + /** + * XHR Polling constructor. + * + * @param {Object} opts + * @package + */ + constructor(opts) { + super(opts); + this.polling = false; + if (typeof location !== "undefined") { + const isSSL = "https:" === location.protocol; + let port = location.port; + // some user agents have empty `location.port` + if (!port) { + port = isSSL ? "443" : "80"; + } + this.xd = + (typeof location !== "undefined" && + opts.hostname !== location.hostname) || + port !== opts.port; + } + /** + * XHR supports binary + */ + const forceBase64 = opts && opts.forceBase64; + this.supportsBinary = hasXHR2 && !forceBase64; + if (this.opts.withCredentials) { + this.cookieJar = (0, xmlhttprequest_js_1.createCookieJar)(); + } + } + get name() { + return "polling"; + } + /** + * Opens the socket (triggers polling). We write a PING message to determine + * when the transport is open. + * + * @protected + */ + doOpen() { + this.poll(); + } + /** + * Pauses polling. + * + * @param {Function} onPause - callback upon buffers are flushed and transport is paused + * @package + */ + pause(onPause) { + this.readyState = "pausing"; + const pause = () => { + debug("paused"); + this.readyState = "paused"; + onPause(); + }; + if (this.polling || !this.writable) { + let total = 0; + if (this.polling) { + debug("we are currently polling - waiting to pause"); + total++; + this.once("pollComplete", function () { + debug("pre-pause polling complete"); + --total || pause(); + }); + } + if (!this.writable) { + debug("we are currently writing - waiting to pause"); + total++; + this.once("drain", function () { + debug("pre-pause writing complete"); + --total || pause(); + }); + } + } + else { + pause(); + } + } + /** + * Starts polling cycle. + * + * @private + */ + poll() { + debug("polling"); + this.polling = true; + this.doPoll(); + this.emitReserved("poll"); + } + /** + * Overloads onData to detect payloads. + * + * @protected + */ + onData(data) { + debug("polling got data %s", data); + const callback = (packet) => { + // if its the first message we consider the transport open + if ("opening" === this.readyState && packet.type === "open") { + this.onOpen(); + } + // if its a close packet, we close the ongoing requests + if ("close" === packet.type) { + this.onClose({ description: "transport closed by the server" }); + return false; + } + // otherwise bypass onData and handle the message + this.onPacket(packet); + }; + // decode payload + (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); + // if an event did not trigger closing + if ("closed" !== this.readyState) { + // if we got data we're not polling + this.polling = false; + this.emitReserved("pollComplete"); + if ("open" === this.readyState) { + this.poll(); + } + else { + debug('ignoring poll - transport state "%s"', this.readyState); + } + } + } + /** + * For polling, send a close packet. + * + * @protected + */ + doClose() { + const close = () => { + debug("writing close packet"); + this.write([{ type: "close" }]); + }; + if ("open" === this.readyState) { + debug("transport open - closing"); + close(); + } + else { + // in case we're trying to close while + // handshaking is in progress (GH-164) + debug("transport not open - deferring close"); + this.once("open", close); + } + } + /** + * Writes a packets payload. + * + * @param {Array} packets - data packets + * @protected + */ + write(packets) { + this.writable = false; + (0, engine_io_parser_1.encodePayload)(packets, (data) => { + this.doWrite(data, () => { + this.writable = true; + this.emitReserved("drain"); + }); + }); + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "https" : "http"; + const query = this.query || {}; + // cache busting is forced + if (false !== this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + if (!this.supportsBinary && !query.sid) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Creates a request. + * + * @param {String} method + * @private + */ + request(opts = {}) { + Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts); + return new Request(this.uri(), opts); + } + /** + * Sends data. + * + * @param {String} data to send. + * @param {Function} called upon flush. + * @private + */ + doWrite(data, fn) { + const req = this.request({ + method: "POST", + data: data, + }); + req.on("success", fn); + req.on("error", (xhrStatus, context) => { + this.onError("xhr post error", xhrStatus, context); + }); + } + /** + * Starts a poll cycle. + * + * @private + */ + doPoll() { + debug("xhr poll"); + const req = this.request(); + req.on("data", this.onData.bind(this)); + req.on("error", (xhrStatus, context) => { + this.onError("xhr poll error", xhrStatus, context); + }); + this.pollXhr = req; + } +} +exports.Polling = Polling; +class Request extends component_emitter_1.Emitter { + /** + * Request constructor + * + * @param {Object} options + * @package + */ + constructor(uri, opts) { + super(); + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.method = opts.method || "GET"; + this.uri = uri; + this.data = undefined !== opts.data ? opts.data : null; + this.create(); + } + /** + * Creates the XHR object and sends the request. + * + * @private + */ + create() { + var _a; + const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); + opts.xdomain = !!this.opts.xd; + const xhr = (this.xhr = new xmlhttprequest_js_1.XHR(opts)); + try { + debug("xhr open %s: %s", this.method, this.uri); + xhr.open(this.method, this.uri, true); + try { + if (this.opts.extraHeaders) { + xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); + for (let i in this.opts.extraHeaders) { + if (this.opts.extraHeaders.hasOwnProperty(i)) { + xhr.setRequestHeader(i, this.opts.extraHeaders[i]); + } + } + } + } + catch (e) { } + if ("POST" === this.method) { + try { + xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); + } + catch (e) { } + } + try { + xhr.setRequestHeader("Accept", "*/*"); + } + catch (e) { } + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); + // ie6 check + if ("withCredentials" in xhr) { + xhr.withCredentials = this.opts.withCredentials; + } + if (this.opts.requestTimeout) { + xhr.timeout = this.opts.requestTimeout; + } + xhr.onreadystatechange = () => { + var _a; + if (xhr.readyState === 3) { + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr); + } + if (4 !== xhr.readyState) + return; + if (200 === xhr.status || 1223 === xhr.status) { + this.onLoad(); + } + else { + // make sure the `error` event handler that's user-set + // does not throw in the same tick and gets caught here + this.setTimeoutFn(() => { + this.onError(typeof xhr.status === "number" ? xhr.status : 0); + }, 0); + } + }; + debug("xhr data %s", this.data); + xhr.send(this.data); + } + catch (e) { + // Need to defer since .create() is called directly from the constructor + // and thus the 'error' event can only be only bound *after* this exception + // occurs. Therefore, also, we cannot throw here at all. + this.setTimeoutFn(() => { + this.onError(e); + }, 0); + return; + } + if (typeof document !== "undefined") { + this.index = Request.requestsCount++; + Request.requests[this.index] = this; + } + } + /** + * Called upon error. + * + * @private + */ + onError(err) { + this.emitReserved("error", err, this.xhr); + this.cleanup(true); + } + /** + * Cleans up house. + * + * @private + */ + cleanup(fromError) { + if ("undefined" === typeof this.xhr || null === this.xhr) { + return; + } + this.xhr.onreadystatechange = empty; + if (fromError) { + try { + this.xhr.abort(); + } + catch (e) { } + } + if (typeof document !== "undefined") { + delete Request.requests[this.index]; + } + this.xhr = null; + } + /** + * Called upon load. + * + * @private + */ + onLoad() { + const data = this.xhr.responseText; + if (data !== null) { + this.emitReserved("data", data); + this.emitReserved("success"); + this.cleanup(); + } + } + /** + * Aborts the request. + * + * @package + */ + abort() { + this.cleanup(); + } +} +exports.Request = Request; +Request.requestsCount = 0; +Request.requests = {}; +/** + * Aborts pending requests when unloading the window. This is needed to prevent + * memory leaks (e.g. when using IE) and to ensure that no spurious error is + * emitted. + */ +if (typeof document !== "undefined") { + // @ts-ignore + if (typeof attachEvent === "function") { + // @ts-ignore + attachEvent("onunload", unloadHandler); + } + else if (typeof addEventListener === "function") { + const terminationEvent = "onpagehide" in globalThis_js_1.globalThisShim ? "pagehide" : "unload"; + addEventListener(terminationEvent, unloadHandler, false); + } +} +function unloadHandler() { + for (let i in Request.requests) { + if (Request.requests.hasOwnProperty(i)) { + Request.requests[i].abort(); + } + } +} - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } +},{"../contrib/yeast.js":390,"../globalThis.js":391,"../transport.js":394,"../util.js":401,"./xmlhttprequest.js":400,"@socket.io/component-emitter":26,"debug":364,"engine.io-parser":406}],397:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0; +const globalThis_js_1 = require("../globalThis.js"); +exports.nextTick = (() => { + const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; + if (isPromiseAvailable) { + return (cb) => Promise.resolve().then(cb); + } + else { + return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + } +})(); +exports.WebSocket = globalThis_js_1.globalThisShim.WebSocket || globalThis_js_1.globalThisShim.MozWebSocket; +exports.usingBrowserWebSocket = true; +exports.defaultBinaryType = "arraybuffer"; - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } +},{"../globalThis.js":391}],398:[function(require,module,exports){ +(function (Buffer){(function (){ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WS = void 0; +const transport_js_1 = require("../transport.js"); +const yeast_js_1 = require("../contrib/yeast.js"); +const util_js_1 = require("../util.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const engine_io_parser_1 = require("engine.io-parser"); +const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() +// detect ReactNative environment +const isReactNative = typeof navigator !== "undefined" && + typeof navigator.product === "string" && + navigator.product.toLowerCase() === "reactnative"; +class WS extends transport_js_1.Transport { + /** + * WebSocket transport constructor. + * + * @param {Object} opts - connection options + * @protected + */ + constructor(opts) { + super(opts); + this.supportsBinary = !opts.forceBase64; + } + get name() { + return "websocket"; + } + doOpen() { + if (!this.check()) { + // let probe timeout + return; + } + const uri = this.uri(); + const protocols = this.opts.protocols; + // React Native only supports the 'headers' option, and will print a warning if anything else is passed + const opts = isReactNative + ? {} + : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); + if (this.opts.extraHeaders) { + opts.headers = this.opts.extraHeaders; + } + try { + this.ws = + websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative + ? protocols + ? new websocket_constructor_js_1.WebSocket(uri, protocols) + : new websocket_constructor_js_1.WebSocket(uri) + : new websocket_constructor_js_1.WebSocket(uri, protocols, opts); + } + catch (err) { + return this.emitReserved("error", err); + } + this.ws.binaryType = this.socket.binaryType; + this.addEventListeners(); + } + /** + * Adds event listeners to the socket + * + * @private + */ + addEventListeners() { + this.ws.onopen = () => { + if (this.opts.autoUnref) { + this.ws._socket.unref(); + } + this.onOpen(); + }; + this.ws.onclose = (closeEvent) => this.onClose({ + description: "websocket connection closed", + context: closeEvent, + }); + this.ws.onmessage = (ev) => this.onData(ev.data); + this.ws.onerror = (e) => this.onError("websocket error", e); + } + write(packets) { + this.writable = false; + // encodePacket efficient as it uses WS framing + // no need for encodePayload + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { + // always create a new object (GH-437) + const opts = {}; + if (!websocket_constructor_js_1.usingBrowserWebSocket) { + if (packet.options) { + opts.compress = packet.options.compress; + } + if (this.opts.perMessageDeflate) { + const len = + // @ts-ignore + "string" === typeof data ? Buffer.byteLength(data) : data.length; + if (len < this.opts.perMessageDeflate.threshold) { + opts.compress = false; + } + } + } + // Sometimes the websocket has already been closed but the browser didn't + // have a chance of informing us about it yet, in that case send will + // throw an error + try { + if (websocket_constructor_js_1.usingBrowserWebSocket) { + // TypeError is thrown when passing the second argument on Safari + this.ws.send(data); + } + else { + this.ws.send(data, opts); + } + } + catch (e) { + debug("websocket closed before onclose event"); + } + if (lastPacket) { + // fake drain + // defer to next tick to allow Socket to clear writeBuffer + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + if (typeof this.ws !== "undefined") { + this.ws.close(); + this.ws = null; + } + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "wss" : "ws"; + const query = this.query || {}; + // append timestamp to URI + if (this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + // communicate binary support capabilities + if (!this.supportsBinary) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Feature detection for WebSocket. + * + * @return {Boolean} whether this transport is available. + * @private + */ + check() { + return !!websocket_constructor_js_1.WebSocket; + } +} +exports.WS = WS; - createDebug.enable(createDebug.load()); +}).call(this)}).call(this,require("buffer").Buffer) +},{"../contrib/yeast.js":390,"../transport.js":394,"../util.js":401,"./websocket-constructor.js":397,"buffer":56,"debug":364,"engine.io-parser":406}],399:[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.WT = void 0; +const transport_js_1 = require("../transport.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const debug_1 = __importDefault(require("debug")); // debug() +const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() +class WT extends transport_js_1.Transport { + get name() { + return "webtransport"; + } + doOpen() { + // @ts-ignore + if (typeof WebTransport !== "function") { + return; + } + // @ts-ignore + this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); + this.transport.closed + .then(() => { + debug("transport closed gracefully"); + this.onClose(); + }) + .catch((err) => { + debug("transport closed due to %s", err); + this.onError("webtransport error", err); + }); + // note: we could have used async/await, but that would require some additional polyfills + this.transport.ready.then(() => { + this.transport.createBidirectionalStream().then((stream) => { + const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); + const reader = stream.readable.pipeThrough(decoderStream).getReader(); + const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); + encoderStream.readable.pipeTo(stream.writable); + this.writer = encoderStream.writable.getWriter(); + const read = () => { + reader + .read() + .then(({ done, value }) => { + if (done) { + debug("session is closed"); + return; + } + debug("received chunk: %o", value); + this.onPacket(value); + read(); + }) + .catch((err) => { + debug("an error occurred while reading: %s", err); + }); + }; + read(); + const packet = { type: "open" }; + if (this.query.sid) { + packet.data = `{"sid":"${this.query.sid}"}`; + } + this.writer.write(packet).then(() => this.onOpen()); + }); + }); + } + write(packets) { + this.writable = false; + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + this.writer.write(packet).then(() => { + if (lastPacket) { + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + var _a; + (_a = this.transport) === null || _a === void 0 ? void 0 : _a.close(); + } +} +exports.WT = WT; - return createDebug; +},{"../transport.js":394,"./websocket-constructor.js":397,"debug":364,"engine.io-parser":406}],400:[function(require,module,exports){ +"use strict"; +// browser shim for xmlhttprequest module +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createCookieJar = exports.XHR = void 0; +const has_cors_js_1 = require("../contrib/has-cors.js"); +const globalThis_js_1 = require("../globalThis.js"); +function XHR(opts) { + const xdomain = opts.xdomain; + // XMLHttpRequest can be disabled on IE + try { + if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { + return new XMLHttpRequest(); + } + } + catch (e) { } + if (!xdomain) { + try { + return new globalThis_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + catch (e) { } + } } +exports.XHR = XHR; +function createCookieJar() { } +exports.createCookieJar = createCookieJar; -module.exports = setup; +},{"../contrib/has-cors.js":387,"../globalThis.js":391}],401:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.byteLength = exports.installTimerFunctions = exports.pick = void 0; +const globalThis_js_1 = require("./globalThis.js"); +function pick(obj, ...attr) { + return attr.reduce((acc, k) => { + if (obj.hasOwnProperty(k)) { + acc[k] = obj[k]; + } + return acc; + }, {}); +} +exports.pick = pick; +// Keep a reference to the real timeout functions so they can be used when overridden +const NATIVE_SET_TIMEOUT = globalThis_js_1.globalThisShim.setTimeout; +const NATIVE_CLEAR_TIMEOUT = globalThis_js_1.globalThisShim.clearTimeout; +function installTimerFunctions(obj, opts) { + if (opts.useNativeTimers) { + obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.globalThisShim); + } + else { + obj.setTimeoutFn = globalThis_js_1.globalThisShim.setTimeout.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = globalThis_js_1.globalThisShim.clearTimeout.bind(globalThis_js_1.globalThisShim); + } +} +exports.installTimerFunctions = installTimerFunctions; +// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) +const BASE64_OVERHEAD = 1.33; +// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 +function byteLength(obj) { + if (typeof obj === "string") { + return utf8Length(obj); + } + // arraybuffer or blob + return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); +} +exports.byteLength = byteLength; +function utf8Length(str) { + let c = 0, length = 0; + for (let i = 0, l = str.length; i < l; i++) { + c = str.charCodeAt(i); + if (c < 0x80) { + length += 1; + } + else if (c < 0x800) { + length += 2; + } + else if (c < 0xd800 || c >= 0xe000) { + length += 3; + } + else { + i++; + length += 4; + } + } + return length; +} -},{"ms":490}],409:[function(require,module,exports){ +},{"./globalThis.js":391}],402:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0; @@ -23302,7 +22956,7 @@ Object.keys(PACKET_TYPES).forEach((key) => { const ERROR_PACKET = { type: "error", data: "parser error" }; exports.ERROR_PACKET = ERROR_PACKET; -},{}],410:[function(require,module,exports){ +},{}],403:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decode = exports.encode = void 0; @@ -23352,7 +23006,7 @@ const decode = (base64) => { }; exports.decode = decode; -},{}],411:[function(require,module,exports){ +},{}],404:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodePacket = void 0; @@ -23420,11 +23074,10 @@ const mapBinary = (data, binaryType) => { } }; -},{"./commons.js":409,"./contrib/base64-arraybuffer.js":410}],412:[function(require,module,exports){ +},{"./commons.js":402,"./contrib/base64-arraybuffer.js":403}],405:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodePacket = void 0; -exports.encodePacketToBinary = encodePacketToBinary; +exports.encodePacket = exports.encodePacketToBinary = void 0; const commons_js_1 = require("./commons.js"); const withNativeBlob = typeof Blob === "function" || (typeof Blob !== "undefined" && @@ -23493,13 +23146,12 @@ function encodePacketToBinary(packet, callback) { callback(TEXT_ENCODER.encode(encoded)); }); } +exports.encodePacketToBinary = encodePacketToBinary; -},{"./commons.js":409}],413:[function(require,module,exports){ +},{"./commons.js":402}],406:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; -exports.createPacketEncoderStream = createPacketEncoderStream; -exports.createPacketDecoderStream = createPacketDecoderStream; +exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0; const encodePacket_js_1 = require("./encodePacket.js"); Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }); const decodePacket_js_1 = require("./decodePacket.js"); @@ -23536,6 +23188,7 @@ const decodePayload = (encodedPayload, binaryType) => { }; exports.decodePayload = decodePayload; function createPacketEncoderStream() { + // @ts-expect-error return new TransformStream({ transform(packet, controller) { (0, encodePacket_js_1.encodePacketToBinary)(packet, (encodedPacket) => { @@ -23568,6 +23221,7 @@ function createPacketEncoderStream() { }, }); } +exports.createPacketEncoderStream = createPacketEncoderStream; let TEXT_DECODER; function totalLength(chunks) { return chunks.reduce((acc, chunk) => acc + chunk.length, 0); @@ -23595,14 +23249,15 @@ function createPacketDecoderStream(maxPayload, binaryType) { TEXT_DECODER = new TextDecoder(); } const chunks = []; - let state = 0 /* State.READ_HEADER */; + let state = 0 /* READ_HEADER */; let expectedLength = -1; let isBinary = false; + // @ts-expect-error return new TransformStream({ transform(chunk, controller) { chunks.push(chunk); while (true) { - if (state === 0 /* State.READ_HEADER */) { + if (state === 0 /* READ_HEADER */) { if (totalLength(chunks) < 1) { break; } @@ -23610,24 +23265,24 @@ function createPacketDecoderStream(maxPayload, binaryType) { isBinary = (header[0] & 0x80) === 0x80; expectedLength = header[0] & 0x7f; if (expectedLength < 126) { - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else if (expectedLength === 126) { - state = 1 /* State.READ_EXTENDED_LENGTH_16 */; + state = 1 /* READ_EXTENDED_LENGTH_16 */; } else { - state = 2 /* State.READ_EXTENDED_LENGTH_64 */; + state = 2 /* READ_EXTENDED_LENGTH_64 */; } } - else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { + else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { if (totalLength(chunks) < 2) { break; } const headerArray = concatChunks(chunks, 2); expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } - else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { + else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { if (totalLength(chunks) < 8) { break; } @@ -23640,7 +23295,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { break; } expectedLength = n * Math.pow(2, 32) + view.getUint32(4); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else { if (totalLength(chunks) < expectedLength) { @@ -23648,7 +23303,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { } const data = concatChunks(chunks, expectedLength); controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); - state = 0 /* State.READ_HEADER */; + state = 0 /* READ_HEADER */; } if (expectedLength === 0 || expectedLength > maxPayload) { controller.enqueue(commons_js_1.ERROR_PACKET); @@ -23658,13 +23313,16 @@ function createPacketDecoderStream(maxPayload, binaryType) { }, }); } +exports.createPacketDecoderStream = createPacketDecoderStream; exports.protocol = 4; -},{"./commons.js":409,"./decodePacket.js":411,"./encodePacket.js":412}],414:[function(require,module,exports){ +},{"./commons.js":402,"./decodePacket.js":404,"./encodePacket.js":405}],407:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); + /** @type {import('.')} */ -var $defineProperty = Object.defineProperty || false; +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false; if ($defineProperty) { try { $defineProperty({}, 'a', { value: 1 }); @@ -23676,49 +23334,49 @@ if ($defineProperty) { module.exports = $defineProperty; -},{}],415:[function(require,module,exports){ +},{"get-intrinsic":422}],408:[function(require,module,exports){ 'use strict'; /** @type {import('./eval')} */ module.exports = EvalError; -},{}],416:[function(require,module,exports){ +},{}],409:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ module.exports = Error; -},{}],417:[function(require,module,exports){ +},{}],410:[function(require,module,exports){ 'use strict'; /** @type {import('./range')} */ module.exports = RangeError; -},{}],418:[function(require,module,exports){ +},{}],411:[function(require,module,exports){ 'use strict'; /** @type {import('./ref')} */ module.exports = ReferenceError; -},{}],419:[function(require,module,exports){ +},{}],412:[function(require,module,exports){ 'use strict'; /** @type {import('./syntax')} */ module.exports = SyntaxError; -},{}],420:[function(require,module,exports){ +},{}],413:[function(require,module,exports){ 'use strict'; /** @type {import('./type')} */ module.exports = TypeError; -},{}],421:[function(require,module,exports){ +},{}],414:[function(require,module,exports){ 'use strict'; /** @type {import('./uri')} */ module.exports = URIError; -},{}],422:[function(require,module,exports){ +},{}],415:[function(require,module,exports){ (function (process){(function (){ 'use strict'; @@ -23911,13 +23569,7 @@ if (require('has-symbols')() || require('has-symbols/shams')()) { } }).call(this)}).call(this,require('_process')) -},{"_process":506,"call-bind/callBound":63,"get-intrinsic":430,"has-symbols":438,"has-symbols/shams":439,"is-arguments":458,"is-map":464,"is-set":468,"is-string":470,"isarray":474,"stop-iteration-iterator":532}],423:[function(require,module,exports){ -'use strict'; - -/** @type {import('.')} */ -module.exports = Object; - -},{}],424:[function(require,module,exports){ +},{"_process":487,"call-bind/callBound":57,"get-intrinsic":422,"has-symbols":427,"has-symbols/shams":428,"is-arguments":447,"is-map":453,"is-set":457,"is-string":459,"isarray":463,"stop-iteration-iterator":505}],416:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keccak512 = exports.keccak384 = exports.keccak256 = exports.keccak224 = void 0; @@ -23932,17 +23584,13 @@ exports.keccak256 = (() => { exports.keccak384 = (0, utils_js_1.wrapHash)(sha3_1.keccak_384); exports.keccak512 = (0, utils_js_1.wrapHash)(sha3_1.keccak_512); -},{"./utils.js":425,"@noble/hashes/sha3":24}],425:[function(require,module,exports){ +},{"./utils.js":417,"@noble/hashes/sha3":24}],417:[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.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; -exports.bytesToUtf8 = bytesToUtf8; -exports.hexToBytes = hexToBytes; -exports.equalsBytes = equalsBytes; -exports.wrapHash = wrapHash; +exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; const _assert_1 = __importDefault(require("@noble/hashes/_assert")); const utils_1 = require("@noble/hashes/utils"); const assertBool = _assert_1.default.bool; @@ -23962,10 +23610,12 @@ function bytesToUtf8(data) { } return new TextDecoder().decode(data); } +exports.bytesToUtf8 = bytesToUtf8; function hexToBytes(data) { const sliced = data.startsWith("0x") ? data.substring(2) : data; return (0, utils_1.hexToBytes)(sliced); } +exports.hexToBytes = hexToBytes; // buf.equals(buf2) -> equalsBytes(buf, buf2) function equalsBytes(a, b) { if (a.length !== b.length) { @@ -23978,6 +23628,7 @@ function equalsBytes(a, b) { } return true; } +exports.equalsBytes = equalsBytes; // Internal utils function wrapHash(hash) { return (msg) => { @@ -23985,8 +23636,20 @@ function wrapHash(hash) { return hash(msg); }; } +exports.wrapHash = wrapHash; +// TODO(v3): switch away from node crypto, remove this unnecessary variable. +exports.crypto = (() => { + const webCrypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined; + const nodeRequire = typeof module !== "undefined" && + typeof module.require === "function" && + module.require.bind(module); + return { + node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined, + web: webCrypto + }; +})(); -},{"@noble/hashes/_assert":21,"@noble/hashes/utils":25}],426:[function(require,module,exports){ +},{"@noble/hashes/_assert":21,"@noble/hashes/utils":25}],418:[function(require,module,exports){ 'use strict'; var isCallable = require('is-callable'); @@ -24050,7 +23713,7 @@ var forEach = function forEach(list, iterator, thisArg) { module.exports = forEach; -},{"is-callable":462}],427:[function(require,module,exports){ +},{"is-callable":451}],419:[function(require,module,exports){ 'use strict'; /* eslint no-invalid-this: 1 */ @@ -24136,14 +23799,14 @@ module.exports = function bind(that) { return bound; }; -},{}],428:[function(require,module,exports){ +},{}],420:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":427}],429:[function(require,module,exports){ +},{"./implementation":419}],421:[function(require,module,exports){ 'use strict'; var functionsHaveNames = function functionsHaveNames() { @@ -24176,13 +23839,11 @@ functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() module.exports = functionsHaveNames; -},{}],430:[function(require,module,exports){ +},{}],422:[function(require,module,exports){ 'use strict'; var undefined; -var $Object = require('es-object-atoms'); - var $Error = require('es-errors'); var $EvalError = require('es-errors/eval'); var $RangeError = require('es-errors/range'); @@ -24191,14 +23852,6 @@ var $SyntaxError = require('es-errors/syntax'); var $TypeError = require('es-errors/type'); var $URIError = require('es-errors/uri'); -var abs = require('math-intrinsics/abs'); -var floor = require('math-intrinsics/floor'); -var max = require('math-intrinsics/max'); -var min = require('math-intrinsics/min'); -var pow = require('math-intrinsics/pow'); -var round = require('math-intrinsics/round'); -var sign = require('math-intrinsics/sign'); - var $Function = Function; // eslint-disable-next-line consistent-return @@ -24208,8 +23861,14 @@ var getEvalledConstructor = function (expressionSyntax) { } catch (e) {} }; -var $gOPD = require('gopd'); -var $defineProperty = require('es-define-property'); +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} var throwTypeError = function () { throw new $TypeError(); @@ -24232,13 +23891,13 @@ var ThrowTypeError = $gOPD : throwTypeError; var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); -var getProto = require('get-proto'); -var $ObjectGPO = require('get-proto/Object.getPrototypeOf'); -var $ReflectGPO = require('get-proto/Reflect.getPrototypeOf'); - -var $apply = require('call-bind-apply-helpers/functionApply'); -var $call = require('call-bind-apply-helpers/functionCall'); +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); var needsEval = {}; @@ -24285,8 +23944,7 @@ var INTRINSICS = { '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), '%Math%': Math, '%Number%': Number, - '%Object%': $Object, - '%Object.getOwnPropertyDescriptor%': $gOPD, + '%Object%': Object, '%parseFloat%': parseFloat, '%parseInt%': parseInt, '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, @@ -24312,20 +23970,7 @@ var INTRINSICS = { '%URIError%': $URIError, '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, - '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet, - - '%Function.prototype.call%': $call, - '%Function.prototype.apply%': $apply, - '%Object.defineProperty%': $defineProperty, - '%Object.getPrototypeOf%': $ObjectGPO, - '%Math.abs%': abs, - '%Math.floor%': floor, - '%Math.max%': max, - '%Math.min%': min, - '%Math.pow%': pow, - '%Math.round%': round, - '%Math.sign%': sign, - '%Reflect.getPrototypeOf%': $ReflectGPO + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet }; if (getProto) { @@ -24420,11 +24065,11 @@ var LEGACY_ALIASES = { var bind = require('function-bind'); var hasOwn = require('hasown'); -var $concat = bind.call($call, Array.prototype.concat); -var $spliceApply = bind.call($apply, Array.prototype.splice); -var $replace = bind.call($call, String.prototype.replace); -var $strSlice = bind.call($call, String.prototype.slice); -var $exec = bind.call($call, RegExp.prototype.exec); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; @@ -24555,60 +24200,12 @@ module.exports = function GetIntrinsic(name, allowMissing) { return value; }; -},{"call-bind-apply-helpers/functionApply":59,"call-bind-apply-helpers/functionCall":60,"es-define-property":414,"es-errors":416,"es-errors/eval":415,"es-errors/range":417,"es-errors/ref":418,"es-errors/syntax":419,"es-errors/type":420,"es-errors/uri":421,"es-object-atoms":423,"function-bind":428,"get-proto":433,"get-proto/Object.getPrototypeOf":431,"get-proto/Reflect.getPrototypeOf":432,"gopd":435,"has-symbols":438,"hasown":453,"math-intrinsics/abs":480,"math-intrinsics/floor":481,"math-intrinsics/max":483,"math-intrinsics/min":484,"math-intrinsics/pow":485,"math-intrinsics/round":486,"math-intrinsics/sign":487}],431:[function(require,module,exports){ -'use strict'; - -var $Object = require('es-object-atoms'); - -/** @type {import('./Object.getPrototypeOf')} */ -module.exports = $Object.getPrototypeOf || null; - -},{"es-object-atoms":423}],432:[function(require,module,exports){ +},{"es-errors":409,"es-errors/eval":408,"es-errors/range":410,"es-errors/ref":411,"es-errors/syntax":412,"es-errors/type":413,"es-errors/uri":414,"function-bind":420,"has-proto":426,"has-symbols":427,"hasown":442}],423:[function(require,module,exports){ 'use strict'; -/** @type {import('./Reflect.getPrototypeOf')} */ -module.exports = (typeof Reflect !== 'undefined' && Reflect.getPrototypeOf) || null; - -},{}],433:[function(require,module,exports){ -'use strict'; - -var reflectGetProto = require('./Reflect.getPrototypeOf'); -var originalGetProto = require('./Object.getPrototypeOf'); - -var getDunderProto = require('dunder-proto/get'); - -/** @type {import('.')} */ -module.exports = reflectGetProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return reflectGetProto(O); - } - : originalGetProto - ? function getProto(O) { - if (!O || (typeof O !== 'object' && typeof O !== 'function')) { - throw new TypeError('getProto: not an object'); - } - // @ts-expect-error TS can't narrow inside a closure, for some reason - return originalGetProto(O); - } - : getDunderProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return getDunderProto(O); - } - : null; - -},{"./Object.getPrototypeOf":431,"./Reflect.getPrototypeOf":432,"dunder-proto/get":375}],434:[function(require,module,exports){ -'use strict'; - -/** @type {import('./gOPD')} */ -module.exports = Object.getOwnPropertyDescriptor; - -},{}],435:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -/** @type {import('.')} */ -var $gOPD = require('./gOPD'); +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); if ($gOPD) { try { @@ -24621,12 +24218,11 @@ if ($gOPD) { module.exports = $gOPD; -},{"./gOPD":434}],436:[function(require,module,exports){ +},{"get-intrinsic":422}],424:[function(require,module,exports){ 'use strict'; var $BigInt = typeof BigInt !== 'undefined' && BigInt; -/** @type {import('.')} */ module.exports = function hasNativeBigInts() { return typeof $BigInt === 'function' && typeof BigInt === 'function' @@ -24634,7 +24230,7 @@ module.exports = function hasNativeBigInts() { && typeof BigInt(42) === 'bigint'; // eslint-disable-line no-magic-numbers }; -},{}],437:[function(require,module,exports){ +},{}],425:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -24658,13 +24254,29 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu module.exports = hasPropertyDescriptors; -},{"es-define-property":414}],438:[function(require,module,exports){ +},{"es-define-property":407}],426:[function(require,module,exports){ +'use strict'; + +var test = { + __proto__: null, + foo: {} +}; + +var $Object = Object; + +/** @type {import('.')} */ +module.exports = function hasProto() { + // @ts-expect-error: TS errors on an inherited property for some reason + return { __proto__: test }.foo === test.foo + && !(test instanceof $Object); +}; + +},{}],427:[function(require,module,exports){ 'use strict'; var origSymbol = typeof Symbol !== 'undefined' && Symbol; var hasSymbolSham = require('./shams'); -/** @type {import('.')} */ module.exports = function hasNativeSymbols() { if (typeof origSymbol !== 'function') { return false; } if (typeof Symbol !== 'function') { return false; } @@ -24674,16 +24286,14 @@ module.exports = function hasNativeSymbols() { return hasSymbolSham(); }; -},{"./shams":439}],439:[function(require,module,exports){ +},{"./shams":428}],428:[function(require,module,exports){ 'use strict'; -/** @type {import('./shams')} */ /* eslint complexity: [2, 18], max-statements: [2, 33] */ module.exports = function hasSymbols() { if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } if (typeof Symbol.iterator === 'symbol') { return true; } - /** @type {{ [k in symbol]?: unknown }} */ var obj = {}; var sym = Symbol('test'); var symObj = Object(sym); @@ -24702,7 +24312,7 @@ module.exports = function hasSymbols() { var symVal = 42; obj[sym] = symVal; - for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } @@ -24713,15 +24323,14 @@ module.exports = function hasSymbols() { if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } if (typeof Object.getOwnPropertyDescriptor === 'function') { - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym)); + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } } return true; }; -},{}],440:[function(require,module,exports){ +},{}],429:[function(require,module,exports){ 'use strict'; var hasSymbols = require('has-symbols/shams'); @@ -24731,7 +24340,7 @@ module.exports = function hasToStringTagShams() { return hasSymbols() && !!Symbol.toStringTag; }; -},{"has-symbols/shams":439}],441:[function(require,module,exports){ +},{"has-symbols/shams":428}],430:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -24748,7 +24357,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":442,"./hash/hmac":443,"./hash/ripemd":444,"./hash/sha":445,"./hash/utils":452}],442:[function(require,module,exports){ +},{"./hash/common":431,"./hash/hmac":432,"./hash/ripemd":433,"./hash/sha":434,"./hash/utils":441}],431:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -24842,7 +24451,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":452,"minimalistic-assert":488}],443:[function(require,module,exports){ +},{"./utils":441,"minimalistic-assert":469}],432:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -24891,7 +24500,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":452,"minimalistic-assert":488}],444:[function(require,module,exports){ +},{"./utils":441,"minimalistic-assert":469}],433:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -25039,7 +24648,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":442,"./utils":452}],445:[function(require,module,exports){ +},{"./common":431,"./utils":441}],434:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -25048,7 +24657,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":446,"./sha/224":447,"./sha/256":448,"./sha/384":449,"./sha/512":450}],446:[function(require,module,exports){ +},{"./sha/1":435,"./sha/224":436,"./sha/256":437,"./sha/384":438,"./sha/512":439}],435:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25124,7 +24733,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":442,"../utils":452,"./common":451}],447:[function(require,module,exports){ +},{"../common":431,"../utils":441,"./common":440}],436:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25156,7 +24765,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":452,"./256":448}],448:[function(require,module,exports){ +},{"../utils":441,"./256":437}],437:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25263,7 +24872,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":442,"../utils":452,"./common":451,"minimalistic-assert":488}],449:[function(require,module,exports){ +},{"../common":431,"../utils":441,"./common":440,"minimalistic-assert":469}],438:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25300,7 +24909,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":452,"./512":450}],450:[function(require,module,exports){ +},{"../utils":441,"./512":439}],439:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25632,7 +25241,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":442,"../utils":452,"minimalistic-assert":488}],451:[function(require,module,exports){ +},{"../common":431,"../utils":441,"minimalistic-assert":469}],440:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25683,7 +25292,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":452}],452:[function(require,module,exports){ +},{"../utils":441}],441:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -25963,7 +25572,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":456,"minimalistic-assert":488}],453:[function(require,module,exports){ +},{"inherits":445,"minimalistic-assert":469}],442:[function(require,module,exports){ 'use strict'; var call = Function.prototype.call; @@ -25973,7 +25582,7 @@ var bind = require('function-bind'); /** @type {import('.')} */ module.exports = bind.call(call, $hasOwn); -},{"function-bind":428}],454:[function(require,module,exports){ +},{"function-bind":420}],443:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -26088,7 +25697,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":441,"minimalistic-assert":488,"minimalistic-crypto-utils":489}],455:[function(require,module,exports){ +},{"hash.js":430,"minimalistic-assert":469,"minimalistic-crypto-utils":470}],444:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -26175,7 +25784,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],456:[function(require,module,exports){ +},{}],445:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -26204,19 +25813,14 @@ if (typeof Object.create === 'function') { } } -},{}],457:[function(require,module,exports){ +},{}],446:[function(require,module,exports){ 'use strict'; -/** @typedef {`$${import('.').InternalSlot}`} SaltedInternalSlot */ -/** @typedef {{ [k in SaltedInternalSlot]?: unknown }} SlotsObject */ - var hasOwn = require('hasown'); -/** @type {import('side-channel').Channel} */ var channel = require('side-channel')(); var $TypeError = require('es-errors/type'); -/** @type {import('.')} */ var SLOT = { assert: function (O, slot) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -26238,8 +25842,7 @@ var SLOT = { throw new $TypeError('`slot` must be a string'); } var slots = channel.get(O); - // eslint-disable-next-line no-extra-parens - return slots && slots[/** @type {SaltedInternalSlot} */ ('$' + slot)]; + return slots && slots['$' + slot]; }, has: function (O, slot) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -26249,8 +25852,7 @@ var SLOT = { throw new $TypeError('`slot` must be a string'); } var slots = channel.get(O); - // eslint-disable-next-line no-extra-parens - return !!slots && hasOwn(slots, /** @type {SaltedInternalSlot} */ ('$' + slot)); + return !!slots && hasOwn(slots, '$' + slot); }, set: function (O, slot, V) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -26264,8 +25866,7 @@ var SLOT = { slots = {}; channel.set(O, slots); } - // eslint-disable-next-line no-extra-parens - slots[/** @type {SaltedInternalSlot} */ ('$' + slot)] = V; + slots['$' + slot] = V; } }; @@ -26275,57 +25876,46 @@ if (Object.freeze) { module.exports = SLOT; -},{"es-errors/type":420,"hasown":453,"side-channel":518}],458:[function(require,module,exports){ +},{"es-errors/type":413,"hasown":442,"side-channel":495}],447:[function(require,module,exports){ 'use strict'; var hasToStringTag = require('has-tostringtag/shams')(); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $toString = callBound('Object.prototype.toString'); -/** @type {import('.')} */ var isStandardArguments = function isArguments(value) { - if ( - hasToStringTag - && value - && typeof value === 'object' - && Symbol.toStringTag in value - ) { + if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) { return false; } return $toString(value) === '[object Arguments]'; }; -/** @type {import('.')} */ var isLegacyArguments = function isArguments(value) { if (isStandardArguments(value)) { return true; } - return value !== null - && typeof value === 'object' - && 'length' in value - && typeof value.length === 'number' - && value.length >= 0 - && $toString(value) !== '[object Array]' - && 'callee' in value - && $toString(value.callee) === '[object Function]'; + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + $toString(value) !== '[object Array]' && + $toString(value.callee) === '[object Function]'; }; var supportsStandardArguments = (function () { return isStandardArguments(arguments); }()); -// @ts-expect-error TODO make this not error isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests -/** @type {import('.')} */ module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments; -},{"call-bound":65,"has-tostringtag/shams":440}],459:[function(require,module,exports){ +},{"call-bind/callBound":57,"has-tostringtag/shams":429}],448:[function(require,module,exports){ 'use strict'; var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var GetIntrinsic = require('get-intrinsic'); var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true); @@ -26361,19 +25951,17 @@ module.exports = $byteLength || $abSlice ? function isArrayBuffer(obj) { return $toString(obj) === '[object ArrayBuffer]'; } - // @ts-expect-error : function isArrayBuffer(obj) { // eslint-disable-line no-unused-vars return false; }; -},{"call-bind":64,"call-bound":65,"get-intrinsic":430}],460:[function(require,module,exports){ +},{"call-bind":58,"call-bind/callBound":57,"get-intrinsic":422}],449:[function(require,module,exports){ 'use strict'; var hasBigInts = require('has-bigints')(); if (hasBigInts) { var bigIntValueOf = BigInt.prototype.valueOf; - /** @type {(value: object) => value is BigInt} */ var tryBigInt = function tryBigIntObject(value) { try { bigIntValueOf.call(value); @@ -26383,7 +25971,6 @@ if (hasBigInts) { return false; }; - /** @type {import('.')} */ module.exports = function isBigInt(value) { if ( value === null @@ -26403,20 +25990,18 @@ if (hasBigInts) { return tryBigInt(value); }; } else { - /** @type {import('.')} */ module.exports = function isBigInt(value) { return false && value; }; } -},{"has-bigints":436}],461:[function(require,module,exports){ +},{"has-bigints":424}],450:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $boolToStr = callBound('Boolean.prototype.toString'); var $toString = callBound('Object.prototype.toString'); -/** @type {import('.')} */ var tryBooleanObject = function booleanBrandCheck(value) { try { $boolToStr(value); @@ -26428,7 +26013,6 @@ var tryBooleanObject = function booleanBrandCheck(value) { var boolClass = '[object Boolean]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isBoolean(value) { if (typeof value === 'boolean') { return true; @@ -26439,7 +26023,7 @@ module.exports = function isBoolean(value) { return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass; }; -},{"call-bound":65,"has-tostringtag/shams":440}],462:[function(require,module,exports){ +},{"call-bind/callBound":57,"has-tostringtag/shams":429}],451:[function(require,module,exports){ 'use strict'; var fnToStr = Function.prototype.toString; @@ -26542,36 +26126,31 @@ module.exports = reflectApply return tryFunctionObject(value); }; -},{}],463:[function(require,module,exports){ +},{}],452:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -var getDay = callBound('Date.prototype.getDay'); -/** @type {import('.')} */ +var getDay = Date.prototype.getDay; var tryDateObject = function tryDateGetDayCall(value) { try { - getDay(value); + getDay.call(value); return true; } catch (e) { return false; } }; -/** @type {(value: unknown) => string} */ -var toStr = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var dateClass = '[object Date]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isDateObject(value) { if (typeof value !== 'object' || value === null) { return false; } - return hasToStringTag ? tryDateObject(value) : toStr(value) === dateClass; + return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; }; -},{"call-bound":65,"has-tostringtag/shams":440}],464:[function(require,module,exports){ +},{"has-tostringtag/shams":429}],453:[function(require,module,exports){ 'use strict'; /** @const */ @@ -26620,7 +26199,7 @@ module.exports = exported || function isMap(x) { return false; }; -},{}],465:[function(require,module,exports){ +},{}],454:[function(require,module,exports){ (function (process){(function (){ // Coding standard for this project defined @ https://github.com/MatthewSH/standards/blob/master/JavaScript.md 'use strict'; @@ -26628,59 +26207,51 @@ module.exports = exported || function isMap(x) { exports = module.exports = !!(typeof process !== 'undefined' && process.versions && process.versions.node); }).call(this)}).call(this,require('_process')) -},{"_process":506}],466:[function(require,module,exports){ +},{"_process":487}],455:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -var $numToStr = callBound('Number.prototype.toString'); - -/** @type {import('.')} */ +var numToStr = Number.prototype.toString; var tryNumberObject = function tryNumberObject(value) { try { - $numToStr(value); + numToStr.call(value); return true; } catch (e) { return false; } }; -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var numClass = '[object Number]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isNumberObject(value) { if (typeof value === 'number') { return true; } - if (!value || typeof value !== 'object') { + if (typeof value !== 'object') { return false; } - return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass; + return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass; }; -},{"call-bound":65,"has-tostringtag/shams":440}],467:[function(require,module,exports){ +},{"has-tostringtag/shams":429}],456:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var hasToStringTag = require('has-tostringtag/shams')(); -var hasOwn = require('hasown'); -var gOPD = require('gopd'); - -/** @type {import('.')} */ -var fn; +var has; +var $exec; +var isRegexMarker; +var badStringifier; if (hasToStringTag) { - /** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ - var $exec = callBound('RegExp.prototype.exec'); - /** @type {object} */ - var isRegexMarker = {}; + has = callBound('Object.prototype.hasOwnProperty'); + $exec = callBound('RegExp.prototype.exec'); + isRegexMarker = {}; var throwRegexMarker = function () { throw isRegexMarker; }; - /** @type {{ toString(): never, valueOf(): never, [Symbol.toPrimitive]?(): never }} */ - var badStringifier = { + badStringifier = { toString: throwRegexMarker, valueOf: throwRegexMarker }; @@ -26688,37 +26259,32 @@ if (hasToStringTag) { if (typeof Symbol.toPrimitive === 'symbol') { badStringifier[Symbol.toPrimitive] = throwRegexMarker; } +} - /** @type {import('.')} */ - // @ts-expect-error TS can't figure out that the $exec call always throws +var $toString = callBound('Object.prototype.toString'); +var gOPD = Object.getOwnPropertyDescriptor; +var regexClass = '[object RegExp]'; + +module.exports = hasToStringTag // eslint-disable-next-line consistent-return - fn = function isRegex(value) { + ? function isRegex(value) { if (!value || typeof value !== 'object') { return false; } - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {NonNullable} */ (gOPD)(/** @type {{ lastIndex?: unknown }} */ (value), 'lastIndex'); - var hasLastIndexDataProperty = descriptor && hasOwn(descriptor, 'value'); + var descriptor = gOPD(value, 'lastIndex'); + var hasLastIndexDataProperty = descriptor && has(descriptor, 'value'); if (!hasLastIndexDataProperty) { return false; } try { - // eslint-disable-next-line no-extra-parens - $exec(value, /** @type {string} */ (/** @type {unknown} */ (badStringifier))); + $exec(value, badStringifier); } catch (e) { return e === isRegexMarker; } - }; -} else { - /** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ - var $toString = callBound('Object.prototype.toString'); - /** @const @type {'[object RegExp]'} */ - var regexClass = '[object RegExp]'; - - /** @type {import('.')} */ - fn = function isRegex(value) { + } + : function isRegex(value) { // In older browsers, typeof regex incorrectly returns 'function' if (!value || (typeof value !== 'object' && typeof value !== 'function')) { return false; @@ -26726,11 +26292,8 @@ if (hasToStringTag) { return $toString(value) === regexClass; }; -} - -module.exports = fn; -},{"call-bound":65,"gopd":435,"has-tostringtag/shams":440,"hasown":453}],468:[function(require,module,exports){ +},{"call-bind/callBound":57,"has-tostringtag/shams":429}],457:[function(require,module,exports){ 'use strict'; var $Map = typeof Map === 'function' && Map.prototype ? Map : null; @@ -26778,12 +26341,11 @@ module.exports = exported || function isSet(x) { return false; }; -},{}],469:[function(require,module,exports){ +},{}],458:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); -/** @type {undefined | ((thisArg: SharedArrayBuffer) => number)} */ var $byteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); /** @type {import('.')} */ @@ -26793,76 +26355,63 @@ module.exports = $byteLength return false; } try { - // @ts-expect-error TS can't figure out this closed-over variable is non-nullable, and it's fine that `obj` might not be a SAB $byteLength(obj); return true; } catch (e) { return false; } } - : function isSharedArrayBuffer(_obj) { // eslint-disable-line no-unused-vars + : function isSharedArrayBuffer(obj) { // eslint-disable-line no-unused-vars return false; }; -},{"call-bound":65}],470:[function(require,module,exports){ +},{"call-bind/callBound":57}],459:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -/** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ -var $strValueOf = callBound('String.prototype.valueOf'); - -/** @type {import('.')} */ +var strValue = String.prototype.valueOf; var tryStringObject = function tryStringObject(value) { try { - $strValueOf(value); + strValue.call(value); return true; } catch (e) { return false; } }; -/** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var strClass = '[object String]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isString(value) { if (typeof value === 'string') { return true; } - if (!value || typeof value !== 'object') { + if (typeof value !== 'object') { return false; } - return hasToStringTag ? tryStringObject(value) : $toString(value) === strClass; + return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; }; -},{"call-bound":65,"has-tostringtag/shams":440}],471:[function(require,module,exports){ +},{"has-tostringtag/shams":429}],460:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var hasSymbols = require('has-symbols')(); -var safeRegexTest = require('safe-regex-test'); if (hasSymbols) { - var $symToStr = callBound('Symbol.prototype.toString'); - var isSymString = safeRegexTest(/^Symbol\(.*\)$/); - - /** @type {(value: object) => value is Symbol} */ + var symToStr = Symbol.prototype.toString; + var symStringRegex = /^Symbol\(.*\)$/; var isSymbolObject = function isRealSymbolObject(value) { if (typeof value.valueOf() !== 'symbol') { return false; } - return isSymString($symToStr(value)); + return symStringRegex.test(symToStr.call(value)); }; - /** @type {import('.')} */ module.exports = function isSymbol(value) { if (typeof value === 'symbol') { return true; } - if (!value || typeof value !== 'object' || $toString(value) !== '[object Symbol]') { + if (toStr.call(value) !== '[object Symbol]') { return false; } try { @@ -26872,14 +26421,14 @@ if (hasSymbols) { } }; } else { - /** @type {import('.')} */ + module.exports = function isSymbol(value) { // this environment does not support Symbols. return false && value; }; } -},{"call-bound":65,"has-symbols":438,"safe-regex-test":512}],472:[function(require,module,exports){ +},{"has-symbols":427}],461:[function(require,module,exports){ 'use strict'; var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null; @@ -26927,19 +26476,17 @@ module.exports = exported || function isWeakMap(x) { return false; }; -},{}],473:[function(require,module,exports){ +},{}],462:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $WeakSet = GetIntrinsic('%WeakSet%', true); -/** @type {undefined | ((thisArg: Set, value: V) => boolean)} */ var $setHas = callBound('WeakSet.prototype.has', true); if ($setHas) { - /** @type {undefined | ((thisArg: WeakMap, key: K) => boolean)} */ var $mapHas = callBound('WeakMap.prototype.has', true); /** @type {import('.')} */ @@ -26948,11 +26495,9 @@ if ($setHas) { return false; } try { - // @ts-expect-error TS can't figure out that $setHas is always truthy here $setHas(x, $setHas); if ($mapHas) { try { - // @ts-expect-error this indeed might not be a weak collection $mapHas(x, $mapHas); } catch (e) { return true; @@ -26965,37 +26510,33 @@ if ($setHas) { }; } else { /** @type {import('.')} */ - // @ts-expect-error - module.exports = function isWeakSet(x) { // eslint-disable-line no-unused-vars + // eslint-disable-next-line no-unused-vars + module.exports = function isWeakSet(x) { // `WeakSet` does not exist, or does not have a `has` method return false; }; } -},{"call-bound":65,"get-intrinsic":430}],474:[function(require,module,exports){ +},{"call-bind/callBound":57,"get-intrinsic":422}],463:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],475:[function(require,module,exports){ +},{}],464:[function(require,module,exports){ 'use strict'; -/** @type {typeof JSON.stringify} */ var jsonStringify = (typeof JSON !== 'undefined' ? JSON : require('jsonify')).stringify; var isArray = require('isarray'); var objectKeys = require('object-keys'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $join = callBound('Array.prototype.join'); -var $indexOf = callBound('Array.prototype.indexOf'); -var $splice = callBound('Array.prototype.splice'); -var $sort = callBound('Array.prototype.sort'); +var $push = callBound('Array.prototype.push'); -/** @type {(n: number, char: string) => string} */ var strRepeat = function repeat(n, char) { var str = ''; for (var i = 0; i < n; i += 1) { @@ -27004,103 +26545,85 @@ var strRepeat = function repeat(n, char) { return str; }; -/** @type {(parent: import('.').Node, key: import('.').Key, value: unknown) => unknown} */ -var defaultReplacer = function (_parent, _key, value) { return value; }; +var defaultReplacer = function (parent, key, value) { return value; }; -/** @type {import('.')} */ module.exports = function stableStringify(obj) { - /** @type {Parameters[1]} */ var opts = arguments.length > 1 ? arguments[1] : void undefined; var space = (opts && opts.space) || ''; if (typeof space === 'number') { space = strRepeat(space, ' '); } var cycles = !!opts && typeof opts.cycles === 'boolean' && opts.cycles; - /** @type {undefined | typeof defaultReplacer} */ var replacer = opts && opts.replacer ? callBind(opts.replacer) : defaultReplacer; var cmpOpt = typeof opts === 'function' ? opts : opts && opts.cmp; - /** @type {undefined | ((node: T) => (a: Exclude, b: Exclude) => number)} */ var cmp = cmpOpt && function (node) { - // eslint-disable-next-line no-extra-parens - var get = /** @type {NonNullable} */ (cmpOpt).length > 2 - && /** @type {import('.').Getter['get']} */ function get(k) { return node[k]; }; + var get = cmpOpt.length > 2 && function get(k) { return node[k]; }; return function (a, b) { - // eslint-disable-next-line no-extra-parens - return /** @type {NonNullable} */ (cmpOpt)( + return cmpOpt( { key: a, value: node[a] }, { key: b, value: node[b] }, - // @ts-expect-error TS doesn't understand the optimization used here - get ? /** @type {import('.').Getter} */ { __proto__: null, get: get } : void undefined + get ? { __proto__: null, get: get } : void undefined ); }; }; - /** @type {import('.').Node[]} */ var seen = []; - return (/** @type {(parent: import('.').Node, key: string | number, node: unknown, level: number) => string | undefined} */ - function stringify(parent, key, node, level) { - var indent = space ? '\n' + strRepeat(level, space) : ''; - var colonSeparator = space ? ': ' : ':'; + return (function stringify(parent, key, node, level) { + var indent = space ? '\n' + strRepeat(level, space) : ''; + var colonSeparator = space ? ': ' : ':'; - // eslint-disable-next-line no-extra-parens - if (node && /** @type {{ toJSON?: unknown }} */ (node).toJSON && typeof /** @type {{ toJSON?: unknown }} */ (node).toJSON === 'function') { - // eslint-disable-next-line no-extra-parens - node = /** @type {{ toJSON: Function }} */ (node).toJSON(); - } + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON(); + } - node = replacer(parent, key, node); + node = replacer(parent, key, node); - if (node === undefined) { - return; - } - if (typeof node !== 'object' || node === null) { - return jsonStringify(node); - } - if (isArray(node)) { - var out = []; - for (var i = 0; i < node.length; i++) { - var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); - out[out.length] = indent + space + item; - } - return '[' + $join(out, ',') + indent + ']'; + if (node === undefined) { + return; + } + if (typeof node !== 'object' || node === null) { + return jsonStringify(node); + } + if (isArray(node)) { + var out = []; + for (var i = 0; i < node.length; i++) { + var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); + $push(out, indent + space + item); } + return '[' + $join(out, ',') + indent + ']'; + } - if ($indexOf(seen, node) !== -1) { - if (cycles) { return jsonStringify('__cycle__'); } - throw new TypeError('Converting circular structure to JSON'); - } else { - seen[seen.length] = /** @type {import('.').NonArrayNode} */ (node); - } + if (seen.indexOf(node) !== -1) { + if (cycles) { return jsonStringify('__cycle__'); } + throw new TypeError('Converting circular structure to JSON'); + } else { $push(seen, node); } - /** @type {import('.').Key[]} */ - // eslint-disable-next-line no-extra-parens - var keys = $sort(objectKeys(node), cmp && cmp(/** @type {import('.').NonArrayNode} */ (node))); - var out = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // eslint-disable-next-line no-extra-parens - var value = stringify(/** @type {import('.').Node} */ (node), key, /** @type {import('.').NonArrayNode} */ (node)[key], level + 1); + var keys = objectKeys(node).sort(cmp && cmp(node)); + var out = []; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = stringify(node, key, node[key], level + 1); - if (!value) { continue; } + if (!value) { continue; } - var keyValue = jsonStringify(key) - + colonSeparator - + value; + var keyValue = jsonStringify(key) + + colonSeparator + + value; - out[out.length] = indent + space + keyValue; - } - $splice(seen, $indexOf(seen, node), 1); - return '{' + $join(out, ',') + indent + '}'; - }({ '': obj }, '', obj, 0) - ); + $push(out, indent + space + keyValue); + } + seen.splice(seen.indexOf(node), 1); + return '{' + $join(out, ',') + indent + '}'; + + }({ '': obj }, '', obj, 0)); }; -},{"call-bind":64,"call-bound":65,"isarray":474,"jsonify":476,"object-keys":497}],476:[function(require,module,exports){ +},{"call-bind":58,"call-bind/callBound":57,"isarray":463,"jsonify":465,"object-keys":478}],465:[function(require,module,exports){ 'use strict'; exports.parse = require('./lib/parse'); exports.stringify = require('./lib/stringify'); -},{"./lib/parse":477,"./lib/stringify":478}],477:[function(require,module,exports){ +},{"./lib/parse":466,"./lib/stringify":467}],466:[function(require,module,exports){ 'use strict'; var at; // The index of the current character @@ -27363,7 +26886,7 @@ module.exports = function (source, reviver) { }({ '': result }, '')) : result; }; -},{}],478:[function(require,module,exports){ +},{}],467:[function(require,module,exports){ 'use strict'; var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; @@ -27516,7 +27039,7 @@ module.exports = function (value, replacer, space) { return str('', { '': value }); }; -},{}],479:[function(require,module,exports){ +},{}],468:[function(require,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -27875,64 +27398,7 @@ module.exports = function (value, replacer, space) { return defaultLogger; })); -},{}],480:[function(require,module,exports){ -'use strict'; - -/** @type {import('./abs')} */ -module.exports = Math.abs; - -},{}],481:[function(require,module,exports){ -'use strict'; - -/** @type {import('./floor')} */ -module.exports = Math.floor; - -},{}],482:[function(require,module,exports){ -'use strict'; - -/** @type {import('./isNaN')} */ -module.exports = Number.isNaN || function isNaN(a) { - return a !== a; -}; - -},{}],483:[function(require,module,exports){ -'use strict'; - -/** @type {import('./max')} */ -module.exports = Math.max; - -},{}],484:[function(require,module,exports){ -'use strict'; - -/** @type {import('./min')} */ -module.exports = Math.min; - -},{}],485:[function(require,module,exports){ -'use strict'; - -/** @type {import('./pow')} */ -module.exports = Math.pow; - -},{}],486:[function(require,module,exports){ -'use strict'; - -/** @type {import('./round')} */ -module.exports = Math.round; - -},{}],487:[function(require,module,exports){ -'use strict'; - -var $isNaN = require('./isNaN'); - -/** @type {import('./sign')} */ -module.exports = function sign(number) { - if ($isNaN(number) || number === 0) { - return number; - } - return number < 0 ? -1 : +1; -}; - -},{"./isNaN":482}],488:[function(require,module,exports){ +},{}],469:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -27945,7 +27411,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],489:[function(require,module,exports){ +},{}],470:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -28005,7 +27471,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],490:[function(require,module,exports){ +},{}],471:[function(require,module,exports){ /** * Helpers. */ @@ -28031,7 +27497,7 @@ var y = d * 365.25; * @api public */ -module.exports = function (val, options) { +module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { @@ -28169,7 +27635,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],491:[function(require,module,exports){ +},{}],472:[function(require,module,exports){ (function (global){(function (){ var hasMap = typeof Map === 'function' && Map.prototype; var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; @@ -28242,21 +27708,10 @@ var utilInspect = require('./util.inspect'); var inspectCustom = utilInspect.custom; var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null; -var quotes = { - __proto__: null, - 'double': '"', - single: "'" -}; -var quoteREs = { - __proto__: null, - 'double': /(["\\])/g, - single: /(['\\])/g -}; - module.exports = function inspect_(obj, options, depth, seen) { var opts = options || {}; - if (has(opts, 'quoteStyle') && !has(quotes, opts.quoteStyle)) { + if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) { throw new TypeError('option "quoteStyle" must be "single" or "double"'); } if ( @@ -28428,10 +27883,7 @@ module.exports = function inspect_(obj, options, depth, seen) { if (typeof window !== 'undefined' && obj === window) { return '{ [object Window] }'; } - if ( - (typeof globalThis !== 'undefined' && obj === globalThis) - || (typeof global !== 'undefined' && obj === global) - ) { + if (obj === global) { return '{ [object globalThis] }'; } if (!isDate(obj) && !isRegExp(obj)) { @@ -28451,8 +27903,7 @@ module.exports = function inspect_(obj, options, depth, seen) { }; function wrapQuotes(s, defaultStyle, opts) { - var style = opts.quoteStyle || defaultStyle; - var quoteChar = quotes[style]; + var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; return quoteChar + s + quoteChar; } @@ -28610,10 +28061,8 @@ function inspectString(str, opts) { var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : ''); return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer; } - var quoteRE = quoteREs[opts.quoteStyle || 'single']; - quoteRE.lastIndex = 0; // eslint-disable-next-line no-control-regex - var s = $replace.call($replace.call(str, quoteRE, '\\$1'), /[\x00-\x1f]/g, lowbyte); + var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte); return wrapQuotes(s, 'single', opts); } @@ -28714,7 +28163,7 @@ function arrObjKeys(obj, inspect) { } }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./util.inspect":55}],492:[function(require,module,exports){ +},{"./util.inspect":55}],473:[function(require,module,exports){ 'use strict'; var numberIsNaN = function (value) { @@ -28735,7 +28184,7 @@ module.exports = function is(a, b) { }; -},{}],493:[function(require,module,exports){ +},{}],474:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -28755,7 +28204,7 @@ define(polyfill, { module.exports = polyfill; -},{"./implementation":492,"./polyfill":494,"./shim":495,"call-bind":64,"define-properties":374}],494:[function(require,module,exports){ +},{"./implementation":473,"./polyfill":475,"./shim":476,"call-bind":58,"define-properties":369}],475:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -28764,7 +28213,7 @@ module.exports = function getPolyfill() { return typeof Object.is === 'function' ? Object.is : implementation; }; -},{"./implementation":492}],495:[function(require,module,exports){ +},{"./implementation":473}],476:[function(require,module,exports){ 'use strict'; var getPolyfill = require('./polyfill'); @@ -28780,7 +28229,7 @@ module.exports = function shimObjectIs() { return polyfill; }; -},{"./polyfill":494,"define-properties":374}],496:[function(require,module,exports){ +},{"./polyfill":475,"define-properties":369}],477:[function(require,module,exports){ 'use strict'; var keysShim; @@ -28904,7 +28353,7 @@ if (!Object.keys) { } module.exports = keysShim; -},{"./isArguments":498}],497:[function(require,module,exports){ +},{"./isArguments":479}],478:[function(require,module,exports){ 'use strict'; var slice = Array.prototype.slice; @@ -28938,7 +28387,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./implementation":496,"./isArguments":498}],498:[function(require,module,exports){ +},{"./implementation":477,"./isArguments":479}],479:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -28957,31 +28406,31 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],499:[function(require,module,exports){ +},{}],480:[function(require,module,exports){ 'use strict'; // modified from https://github.com/es-shims/es6-shim var objectKeys = require('object-keys'); var hasSymbols = require('has-symbols/shams')(); -var callBound = require('call-bound'); -var $Object = require('es-object-atoms'); +var callBound = require('call-bind/callBound'); +var toObject = Object; var $push = callBound('Array.prototype.push'); var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable'); -var originalGetSymbols = hasSymbols ? $Object.getOwnPropertySymbols : null; +var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null; // eslint-disable-next-line no-unused-vars module.exports = function assign(target, source1) { if (target == null) { throw new TypeError('target must be an object'); } - var to = $Object(target); // step 1 + var to = toObject(target); // step 1 if (arguments.length === 1) { return to; // step 2 } for (var s = 1; s < arguments.length; ++s) { - var from = $Object(arguments[s]); // step 3.a.i + var from = toObject(arguments[s]); // step 3.a.i // step 3.a.ii: var keys = objectKeys(from); - var getSymbols = hasSymbols && ($Object.getOwnPropertySymbols || originalGetSymbols); + var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols); if (getSymbols) { var syms = getSymbols(from); for (var j = 0; j < syms.length; ++j) { @@ -29005,7 +28454,7 @@ module.exports = function assign(target, source1) { return to; // step 4 }; -},{"call-bound":65,"es-object-atoms":423,"has-symbols/shams":439,"object-keys":497}],500:[function(require,module,exports){ +},{"call-bind/callBound":57,"has-symbols/shams":428,"object-keys":478}],481:[function(require,module,exports){ 'use strict'; var defineProperties = require('define-properties'); @@ -29029,7 +28478,7 @@ defineProperties(bound, { module.exports = bound; -},{"./implementation":499,"./polyfill":501,"./shim":502,"call-bind":64,"define-properties":374}],501:[function(require,module,exports){ +},{"./implementation":480,"./polyfill":482,"./shim":483,"call-bind":58,"define-properties":369}],482:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -29086,7 +28535,7 @@ module.exports = function getPolyfill() { return Object.assign; }; -},{"./implementation":499}],502:[function(require,module,exports){ +},{"./implementation":480}],483:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -29102,7 +28551,7 @@ module.exports = function shimAssign() { return polyfill; }; -},{"./polyfill":501,"define-properties":374}],503:[function(require,module,exports){ +},{"./polyfill":482,"define-properties":369}],484:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -29131,7 +28580,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const pkg = __importStar(require("./index.js")); module.exports = pkg; -},{"./index.js":504}],504:[function(require,module,exports){ +},{"./index.js":485}],485:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.now = exports.removeTooOldValues = exports.ObliviousSet = void 0; @@ -29208,7 +28657,7 @@ function now() { } exports.now = now; -},{}],505:[function(require,module,exports){ +},{}],486:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ @@ -29226,7 +28675,7 @@ module.exports = [ 'BigUint64Array' ]; -},{}],506:[function(require,module,exports){ +},{}],487:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -29412,7 +28861,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],507:[function(require,module,exports){ +},{}],488:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -30175,7 +29624,7 @@ try { } } -},{}],508:[function(require,module,exports){ +},{}],489:[function(require,module,exports){ 'use strict'; var setFunctionName = require('set-function-name'); @@ -30216,7 +29665,7 @@ module.exports = setFunctionName(function flags() { }, 'get flags', true); -},{"es-errors/type":420,"set-function-name":514}],509:[function(require,module,exports){ +},{"es-errors/type":413,"set-function-name":494}],490:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -30236,7 +29685,7 @@ define(flagsBound, { module.exports = flagsBound; -},{"./implementation":508,"./polyfill":510,"./shim":511,"call-bind":64,"define-properties":374}],510:[function(require,module,exports){ +},{"./implementation":489,"./polyfill":491,"./shim":492,"call-bind":58,"define-properties":369}],491:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -30250,8 +29699,8 @@ module.exports = function getPolyfill() { if ( descriptor && typeof descriptor.get === 'function' - && 'dotAll' in RegExp.prototype - && 'hasIndices' in RegExp.prototype + && typeof RegExp.prototype.dotAll === 'boolean' + && typeof RegExp.prototype.hasIndices === 'boolean' ) { /* eslint getter-return: 0 */ var calls = ''; @@ -30266,9 +29715,6 @@ module.exports = function getPolyfill() { calls += 'y'; } }); - - descriptor.get.call(o); - if (calls === 'dy') { return descriptor.get; } @@ -30277,20 +29723,20 @@ module.exports = function getPolyfill() { return implementation; }; -},{"./implementation":508,"define-properties":374}],511:[function(require,module,exports){ +},{"./implementation":489,"define-properties":369}],492:[function(require,module,exports){ 'use strict'; var supportsDescriptors = require('define-properties').supportsDescriptors; var getPolyfill = require('./polyfill'); -var gOPD = require('gopd'); +var gOPD = Object.getOwnPropertyDescriptor; var defineProperty = Object.defineProperty; -var $TypeError = require('es-errors'); -var getProto = require('get-proto'); +var TypeErr = TypeError; +var getProto = Object.getPrototypeOf; var regex = /a/; module.exports = function shimFlags() { if (!supportsDescriptors || !getProto) { - throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); + throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); } var polyfill = getPolyfill(); var proto = getProto(regex); @@ -30305,26 +29751,7 @@ module.exports = function shimFlags() { return polyfill; }; -},{"./polyfill":510,"define-properties":374,"es-errors":416,"get-proto":433,"gopd":435}],512:[function(require,module,exports){ -'use strict'; - -var callBound = require('call-bound'); -var isRegex = require('is-regex'); - -var $exec = callBound('RegExp.prototype.exec'); -var $TypeError = require('es-errors/type'); - -/** @type {import('.')} */ -module.exports = function regexTester(regex) { - if (!isRegex(regex)) { - throw new $TypeError('`regex` must be a RegExp'); - } - return function test(s) { - return $exec(regex, s) !== null; - }; -}; - -},{"call-bound":65,"es-errors/type":420,"is-regex":467}],513:[function(require,module,exports){ +},{"./polyfill":491,"define-properties":369}],493:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -30368,7 +29795,7 @@ module.exports = function setFunctionLength(fn, length) { return fn; }; -},{"define-data-property":373,"es-errors/type":420,"get-intrinsic":430,"gopd":435,"has-property-descriptors":437}],514:[function(require,module,exports){ +},{"define-data-property":368,"es-errors/type":413,"get-intrinsic":422,"gopd":423,"has-property-descriptors":425}],494:[function(require,module,exports){ 'use strict'; var define = require('define-data-property'); @@ -30393,323 +29820,138 @@ module.exports = function setFunctionName(fn, name) { return fn; }; -},{"define-data-property":373,"es-errors/type":420,"functions-have-names":429,"has-property-descriptors":437}],515:[function(require,module,exports){ +},{"define-data-property":368,"es-errors/type":413,"functions-have-names":421,"has-property-descriptors":425}],495:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); var inspect = require('object-inspect'); var $TypeError = require('es-errors/type'); +var $WeakMap = GetIntrinsic('%WeakMap%', true); +var $Map = GetIntrinsic('%Map%', true); + +var $weakMapGet = callBound('WeakMap.prototype.get', true); +var $weakMapSet = callBound('WeakMap.prototype.set', true); +var $weakMapHas = callBound('WeakMap.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSet = callBound('Map.prototype.set', true); +var $mapHas = callBound('Map.prototype.has', true); /* * This function traverses the list returning the node corresponding to the given key. * -* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. -* By doing so, all the recently used nodes can be accessed relatively quickly. +* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. By doing so, all the recently used nodes can be accessed relatively quickly. */ -/** @type {import('./list.d.ts').listGetNode} */ -// eslint-disable-next-line consistent-return -var listGetNode = function (list, key, isDelete) { +/** @type {import('.').listGetNode} */ +var listGetNode = function (list, key) { // eslint-disable-line consistent-return /** @type {typeof list | NonNullable<(typeof list)['next']>} */ var prev = list; /** @type {(typeof list)['next']} */ var curr; - // eslint-disable-next-line eqeqeq - for (; (curr = prev.next) != null; prev = curr) { + for (; (curr = prev.next) !== null; prev = curr) { if (curr.key === key) { prev.next = curr.next; - if (!isDelete) { - // eslint-disable-next-line no-extra-parens - curr.next = /** @type {NonNullable} */ (list.next); - list.next = curr; // eslint-disable-line no-param-reassign - } + // eslint-disable-next-line no-extra-parens + curr.next = /** @type {NonNullable} */ (list.next); + list.next = curr; // eslint-disable-line no-param-reassign return curr; } } }; -/** @type {import('./list.d.ts').listGet} */ +/** @type {import('.').listGet} */ var listGet = function (objects, key) { - if (!objects) { - return void undefined; - } var node = listGetNode(objects, key); return node && node.value; }; -/** @type {import('./list.d.ts').listSet} */ +/** @type {import('.').listSet} */ var listSet = function (objects, key, value) { var node = listGetNode(objects, key); if (node) { node.value = value; } else { // Prepend the new node to the beginning of the list - objects.next = /** @type {import('./list.d.ts').ListNode} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens + objects.next = /** @type {import('.').ListNode} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens key: key, next: objects.next, value: value }); } }; -/** @type {import('./list.d.ts').listHas} */ +/** @type {import('.').listHas} */ var listHas = function (objects, key) { - if (!objects) { - return false; - } return !!listGetNode(objects, key); }; -/** @type {import('./list.d.ts').listDelete} */ -// eslint-disable-next-line consistent-return -var listDelete = function (objects, key) { - if (objects) { - return listGetNode(objects, key, true); - } -}; - -/** @type {import('.')} */ -module.exports = function getSideChannelList() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {import('./list.d.ts').RootNode | undefined} */ var $o; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - var root = $o && $o.next; - var deletedNode = listDelete($o, key); - if (deletedNode && root && root === deletedNode) { - $o = void undefined; - } - return !!deletedNode; - }, - get: function (key) { - return listGet($o, key); - }, - has: function (key) { - return listHas($o, key); - }, - set: function (key, value) { - if (!$o) { - // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head - $o = { - next: void undefined - }; - } - // eslint-disable-next-line no-extra-parens - listSet(/** @type {NonNullable} */ ($o), key, value); - } - }; - // @ts-expect-error TODO: figure out why this is erroring - return channel; -}; - -},{"es-errors/type":420,"object-inspect":491}],516:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); -var inspect = require('object-inspect'); - -var $TypeError = require('es-errors/type'); -var $Map = GetIntrinsic('%Map%', true); - -/** @type {(thisArg: Map, key: K) => V} */ -var $mapGet = callBound('Map.prototype.get', true); -/** @type {(thisArg: Map, key: K, value: V) => void} */ -var $mapSet = callBound('Map.prototype.set', true); -/** @type {(thisArg: Map, key: K) => boolean} */ -var $mapHas = callBound('Map.prototype.has', true); -/** @type {(thisArg: Map, key: K) => boolean} */ -var $mapDelete = callBound('Map.prototype.delete', true); -/** @type {(thisArg: Map) => number} */ -var $mapSize = callBound('Map.prototype.size', true); /** @type {import('.')} */ -module.exports = !!$Map && /** @type {Exclude} */ function getSideChannelMap() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {Map | undefined} */ var $m; +module.exports = function getSideChannel() { + /** @type {WeakMap} */ var $wm; + /** @type {Map} */ var $m; + /** @type {import('.').RootNode} */ var $o; - /** @type {Channel} */ + /** @type {import('.').Channel} */ var channel = { assert: function (key) { if (!channel.has(key)) { throw new $TypeError('Side channel does not contain ' + inspect(key)); } }, - 'delete': function (key) { - if ($m) { - var result = $mapDelete($m, key); - if ($mapSize($m) === 0) { - $m = void undefined; - } - return result; - } - return false; - }, get: function (key) { // eslint-disable-line consistent-return - if ($m) { - return $mapGet($m, key); + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapGet($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapGet($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return listGet($o, key); + } } }, has: function (key) { - if ($m) { - return $mapHas($m, key); + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapHas($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapHas($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return listHas($o, key); + } } return false; }, set: function (key, value) { - if (!$m) { - // @ts-expect-error TS can't handle narrowing a variable inside a closure - $m = new $Map(); - } - $mapSet($m, key, value); - } - }; - - // @ts-expect-error TODO: figure out why TS is erroring here - return channel; -}; - -},{"call-bound":65,"es-errors/type":420,"get-intrinsic":430,"object-inspect":491}],517:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); -var inspect = require('object-inspect'); -var getSideChannelMap = require('side-channel-map'); - -var $TypeError = require('es-errors/type'); -var $WeakMap = GetIntrinsic('%WeakMap%', true); - -/** @type {(thisArg: WeakMap, key: K) => V} */ -var $weakMapGet = callBound('WeakMap.prototype.get', true); -/** @type {(thisArg: WeakMap, key: K, value: V) => void} */ -var $weakMapSet = callBound('WeakMap.prototype.set', true); -/** @type {(thisArg: WeakMap, key: K) => boolean} */ -var $weakMapHas = callBound('WeakMap.prototype.has', true); -/** @type {(thisArg: WeakMap, key: K) => boolean} */ -var $weakMapDelete = callBound('WeakMap.prototype.delete', true); - -/** @type {import('.')} */ -module.exports = $WeakMap - ? /** @type {Exclude} */ function getSideChannelWeakMap() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {WeakMap | undefined} */ var $wm; - /** @type {Channel | undefined} */ var $m; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapDelete($wm, key); - } - } else if (getSideChannelMap) { - if ($m) { - return $m['delete'](key); - } + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if (!$wm) { + $wm = new $WeakMap(); } - return false; - }, - get: function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapGet($wm, key); - } - } - return $m && $m.get(key); - }, - has: function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapHas($wm, key); - } + $weakMapSet($wm, key, value); + } else if ($Map) { + if (!$m) { + $m = new $Map(); } - return !!$m && $m.has(key); - }, - set: function (key, value) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if (!$wm) { - $wm = new $WeakMap(); - } - $weakMapSet($wm, key, value); - } else if (getSideChannelMap) { - if (!$m) { - $m = getSideChannelMap(); - } - // eslint-disable-next-line no-extra-parens - /** @type {NonNullable} */ ($m).set(key, value); + $mapSet($m, key, value); + } else { + if (!$o) { + // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head + $o = { key: {}, next: null }; } + listSet($o, key, value); } - }; - - // @ts-expect-error TODO: figure out why this is erroring - return channel; - } - : getSideChannelMap; - -},{"call-bound":65,"es-errors/type":420,"get-intrinsic":430,"object-inspect":491,"side-channel-map":516}],518:[function(require,module,exports){ -'use strict'; - -var $TypeError = require('es-errors/type'); -var inspect = require('object-inspect'); -var getSideChannelList = require('side-channel-list'); -var getSideChannelMap = require('side-channel-map'); -var getSideChannelWeakMap = require('side-channel-weakmap'); - -var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList; - -/** @type {import('.')} */ -module.exports = function getSideChannel() { - /** @typedef {ReturnType} Channel */ - - /** @type {Channel | undefined} */ var $channelData; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - return !!$channelData && $channelData['delete'](key); - }, - get: function (key) { - return $channelData && $channelData.get(key); - }, - has: function (key) { - return !!$channelData && $channelData.has(key); - }, - set: function (key, value) { - if (!$channelData) { - $channelData = makeChannel(); - } - - $channelData.set(key, value); } }; - // @ts-expect-error TODO: figure out why this is erroring return channel; }; -},{"es-errors/type":420,"object-inspect":491,"side-channel-list":515,"side-channel-map":516,"side-channel-weakmap":517}],519:[function(require,module,exports){ +},{"call-bind/callBound":57,"es-errors/type":413,"get-intrinsic":422,"object-inspect":472}],496:[function(require,module,exports){ "use strict"; /** * Initialize backoff timer with `opts`. @@ -30723,7 +29965,7 @@ module.exports = function getSideChannel() { * @api public */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Backoff = Backoff; +exports.Backoff = void 0; function Backoff(opts) { opts = opts || {}; this.ms = opts.min || 100; @@ -30732,6 +29974,7 @@ function Backoff(opts) { this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; this.attempts = 0; } +exports.Backoff = Backoff; /** * Return the backoff duration. * @@ -30780,23 +30023,20 @@ Backoff.prototype.setJitter = function (jitter) { this.jitter = jitter; }; -},{}],520:[function(require,module,exports){ +},{}],497:[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.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.Socket = exports.Manager = exports.protocol = void 0; -exports.io = lookup; -exports.connect = lookup; -exports.default = lookup; +exports.default = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0; const url_js_1 = require("./url.js"); const manager_js_1 = require("./manager.js"); Object.defineProperty(exports, "Manager", { enumerable: true, get: function () { return manager_js_1.Manager; } }); const socket_js_1 = require("./socket.js"); Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client"); // debug() +const debug = debug_1.default("socket.io-client"); // debug() /** * Managers cache. */ @@ -30807,7 +30047,7 @@ function lookup(uri, opts) { uri = undefined; } opts = opts || {}; - const parsed = (0, url_js_1.url)(uri, opts.path || "/socket.io"); + const parsed = url_js_1.url(uri, opts.path || "/socket.io"); const source = parsed.source; const id = parsed.id; const path = parsed.path; @@ -30833,6 +30073,9 @@ function lookup(uri, opts) { } return io.socket(parsed.path, opts); } +exports.io = lookup; +exports.connect = lookup; +exports.default = lookup; // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a // namespace (e.g. `io.connect(...)`), for backward compatibility Object.assign(lookup, { @@ -30848,25 +30091,14 @@ Object.assign(lookup, { */ var socket_io_parser_1 = require("socket.io-parser"); Object.defineProperty(exports, "protocol", { enumerable: true, get: function () { return socket_io_parser_1.protocol; } }); -var engine_io_client_1 = require("engine.io-client"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return engine_io_client_1.Fetch; } }); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return engine_io_client_1.NodeXHR; } }); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return engine_io_client_1.XHR; } }); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return engine_io_client_1.NodeWebSocket; } }); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return engine_io_client_1.WebSocket; } }); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return engine_io_client_1.WebTransport; } }); module.exports = lookup; -},{"./manager.js":521,"./socket.js":523,"./url.js":524,"debug":525,"engine.io-client":397,"socket.io-parser":528}],521:[function(require,module,exports){ +},{"./manager.js":498,"./socket.js":500,"./url.js":501,"debug":364,"socket.io-parser":503}],498:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); + 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]; @@ -30895,7 +30127,7 @@ const on_js_1 = require("./on.js"); const backo2_js_1 = require("./contrib/backo2.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:manager"); // debug() +const debug = debug_1.default("socket.io-client:manager"); // debug() class Manager extends component_emitter_1.Emitter { constructor(uri, opts) { var _a; @@ -30909,7 +30141,7 @@ class Manager extends component_emitter_1.Emitter { opts = opts || {}; opts.path = opts.path || "/socket.io"; this.opts = opts; - (0, engine_io_client_1.installTimerFunctions)(this, opts); + engine_io_client_1.installTimerFunctions(this, opts); this.reconnection(opts.reconnection !== false); this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); this.reconnectionDelay(opts.reconnectionDelay || 1000); @@ -30934,9 +30166,6 @@ class Manager extends component_emitter_1.Emitter { if (!arguments.length) return this._reconnection; this._reconnection = !!v; - if (!v) { - this.skipReconnect = true; - } return this; } reconnectionAttempts(v) { @@ -31008,7 +30237,7 @@ class Manager extends component_emitter_1.Emitter { this._readyState = "opening"; this.skipReconnect = false; // emit `open` - const openSubDestroy = (0, on_js_1.on)(socket, "open", function () { + const openSubDestroy = on_js_1.on(socket, "open", function () { self.onopen(); fn && fn(); }); @@ -31026,7 +30255,7 @@ class Manager extends component_emitter_1.Emitter { } }; // emit `error` - const errorSub = (0, on_js_1.on)(socket, "error", onError); + const errorSub = on_js_1.on(socket, "error", onError); if (false !== this._timeout) { const timeout = this._timeout; debug("connect attempt will timeout after %d", timeout); @@ -31071,9 +30300,7 @@ class Manager extends component_emitter_1.Emitter { this.emitReserved("open"); // add new subs const socket = this.engine; - this.subs.push((0, on_js_1.on)(socket, "ping", this.onping.bind(this)), (0, on_js_1.on)(socket, "data", this.ondata.bind(this)), (0, on_js_1.on)(socket, "error", this.onerror.bind(this)), (0, on_js_1.on)(socket, "close", this.onclose.bind(this)), - // @ts-ignore - (0, on_js_1.on)(this.decoder, "decoded", this.ondecoded.bind(this))); + this.subs.push(on_js_1.on(socket, "ping", this.onping.bind(this)), on_js_1.on(socket, "data", this.ondata.bind(this)), on_js_1.on(socket, "error", this.onerror.bind(this)), on_js_1.on(socket, "close", this.onclose.bind(this)), on_js_1.on(this.decoder, "decoded", this.ondecoded.bind(this))); } /** * Called upon a ping. @@ -31103,7 +30330,7 @@ class Manager extends component_emitter_1.Emitter { */ ondecoded(packet) { // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error" - (0, engine_io_client_1.nextTick)(() => { + engine_io_client_1.nextTick(() => { this.emitReserved("packet", packet); }, this.setTimeoutFn); } @@ -31184,6 +30411,8 @@ class Manager extends component_emitter_1.Emitter { this.skipReconnect = true; this._reconnecting = false; this.onclose("forced close"); + if (this.engine) + this.engine.close(); } /** * Alias for close() @@ -31194,19 +30423,13 @@ class Manager extends component_emitter_1.Emitter { return this._close(); } /** - * Called when: - * - * - the low-level engine is closed - * - the parser encountered a badly formatted packet - * - all sockets are disconnected + * Called upon engine close. * * @private */ onclose(reason, description) { - var _a; debug("closed due to %s", reason); this.cleanup(); - (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close(); this.backoff.reset(); this._readyState = "closed"; this.emitReserved("close", reason, description); @@ -31276,18 +30499,19 @@ class Manager extends component_emitter_1.Emitter { } exports.Manager = Manager; -},{"./contrib/backo2.js":519,"./on.js":522,"./socket.js":523,"@socket.io/component-emitter":26,"debug":525,"engine.io-client":397,"socket.io-parser":528}],522:[function(require,module,exports){ +},{"./contrib/backo2.js":496,"./on.js":499,"./socket.js":500,"@socket.io/component-emitter":26,"debug":364,"engine.io-client":392,"socket.io-parser":503}],499:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.on = on; +exports.on = void 0; function on(obj, ev, fn) { obj.on(ev, fn); return function subDestroy() { obj.off(ev, fn); }; } +exports.on = on; -},{}],523:[function(require,module,exports){ +},{}],500:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -31298,7 +30522,7 @@ const socket_io_parser_1 = require("socket.io-parser"); const on_js_1 = require("./on.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:socket"); // debug() +const debug = debug_1.default("socket.io-client:socket"); // debug() /** * Internal events. * These events can't be emitted by the user. @@ -31444,10 +30668,10 @@ class Socket extends component_emitter_1.Emitter { return; const io = this.io; this.subs = [ - (0, on_js_1.on)(io, "open", this.onopen.bind(this)), - (0, on_js_1.on)(io, "packet", this.onpacket.bind(this)), - (0, on_js_1.on)(io, "error", this.onerror.bind(this)), - (0, on_js_1.on)(io, "close", this.onclose.bind(this)), + on_js_1.on(io, "open", this.onopen.bind(this)), + on_js_1.on(io, "packet", this.onpacket.bind(this)), + on_js_1.on(io, "error", this.onerror.bind(this)), + on_js_1.on(io, "close", this.onclose.bind(this)), ]; } /** @@ -31534,7 +30758,6 @@ class Socket extends component_emitter_1.Emitter { * @return self */ emit(ev, ...args) { - var _a, _b, _c; if (RESERVED_EVENTS.hasOwnProperty(ev)) { throw new Error('"' + ev.toString() + '" is a reserved event name'); } @@ -31557,13 +30780,14 @@ class Socket extends component_emitter_1.Emitter { this._registerAckCallback(id, ack); packet.id = id; } - const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable; - const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired()); - const discardPacket = this.flags.volatile && !isTransportWritable; + const isTransportWritable = this.io.engine && + this.io.engine.transport && + this.io.engine.transport.writable; + const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected); if (discardPacket) { debug("discard packet as the transport is not currently writable"); } - else if (isConnected) { + else if (this.connected) { this.notifyOutgoingListeners(packet); this.packet(packet); } @@ -32199,16 +31423,16 @@ class Socket extends component_emitter_1.Emitter { } exports.Socket = Socket; -},{"./on.js":522,"@socket.io/component-emitter":26,"debug":525,"socket.io-parser":528}],524:[function(require,module,exports){ +},{"./on.js":499,"@socket.io/component-emitter":26,"debug":364,"socket.io-parser":503}],501:[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.url = url; +exports.url = void 0; const engine_io_client_1 = require("engine.io-client"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:url"); // debug() +const debug = debug_1.default("socket.io-client:url"); // debug() /** * URL parser. * @@ -32245,7 +31469,7 @@ function url(uri, path = "", loc) { } // parse debug("parse %s", uri); - obj = (0, engine_io_client_1.parse)(uri); + obj = engine_io_client_1.parse(uri); } // make sure we treat `localhost:80` and `localhost` equally if (!obj.port) { @@ -32269,12 +31493,9 @@ function url(uri, path = "", loc) { (loc && loc.port === obj.port ? "" : ":" + obj.port); return obj; } +exports.url = url; -},{"debug":525,"engine.io-client":397}],525:[function(require,module,exports){ -arguments[4][407][0].apply(exports,arguments) -},{"./common":526,"_process":506,"dup":407}],526:[function(require,module,exports){ -arguments[4][408][0].apply(exports,arguments) -},{"dup":408,"ms":490}],527:[function(require,module,exports){ +},{"debug":364,"engine.io-client":392}],502:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reconstructPacket = exports.deconstructPacket = void 0; @@ -32364,7 +31585,7 @@ function _reconstructPacket(data, buffers) { return data; } -},{"./is-binary.js":529}],528:[function(require,module,exports){ +},{"./is-binary.js":504}],503:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0; @@ -32687,7 +31908,7 @@ class BinaryReconstructor { } } -},{"./binary.js":527,"./is-binary.js":529,"@socket.io/component-emitter":26,"debug":530}],529:[function(require,module,exports){ +},{"./binary.js":502,"./is-binary.js":504,"@socket.io/component-emitter":26,"debug":364}],504:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasBinary = exports.isBinary = void 0; @@ -32744,19 +31965,14 @@ function hasBinary(obj, toJSON) { } exports.hasBinary = hasBinary; -},{}],530:[function(require,module,exports){ -arguments[4][407][0].apply(exports,arguments) -},{"./common":531,"_process":506,"dup":407}],531:[function(require,module,exports){ -arguments[4][408][0].apply(exports,arguments) -},{"dup":408,"ms":490}],532:[function(require,module,exports){ +},{}],505:[function(require,module,exports){ 'use strict'; var SLOT = require('internal-slot'); -var $SyntaxError = require('es-errors/syntax'); +var $SyntaxError = SyntaxError; var $StopIteration = typeof StopIteration === 'object' ? StopIteration : null; -/** @type {import('.')} */ module.exports = function getStopIterationIterator(origIterator) { if (!$StopIteration) { throw new $SyntaxError('this environment lacks StopIteration'); @@ -32764,18 +31980,14 @@ module.exports = function getStopIterationIterator(origIterator) { SLOT.set(origIterator, '[[Done]]', false); - /** @template T @typedef {T extends Iterator ? U : never} IteratorType */ - /** @typedef {IteratorType>} T */ var siIterator = { - next: /** @type {() => IteratorResult} */ function next() { - // eslint-disable-next-line no-extra-parens - var iterator = /** @type {typeof origIterator} */ (SLOT.get(this, '[[Iterator]]')); - var done = !!SLOT.get(iterator, '[[Done]]'); + next: function next() { + var iterator = SLOT.get(this, '[[Iterator]]'); + var done = SLOT.get(iterator, '[[Done]]'); try { return { done: done, - // eslint-disable-next-line no-extra-parens - value: done ? void undefined : /** @type {T} */ (iterator.next()) + value: done ? void undefined : iterator.next() }; } catch (e) { SLOT.set(iterator, '[[Done]]', true); @@ -32792,11 +32004,10 @@ module.exports = function getStopIterationIterator(origIterator) { SLOT.set(siIterator, '[[Iterator]]', origIterator); - // @ts-expect-error TODO FIXME return siIterator; }; -},{"es-errors/syntax":419,"internal-slot":457}],533:[function(require,module,exports){ +},{"internal-slot":446}],506:[function(require,module,exports){ 'use strict'; var isString = require('is-string'); @@ -32805,7 +32016,6 @@ var isBoolean = require('is-boolean-object'); var isSymbol = require('is-symbol'); var isBigInt = require('is-bigint'); -/** @type {import('.')} */ // eslint-disable-next-line consistent-return module.exports = function whichBoxedPrimitive(value) { // eslint-disable-next-line eqeqeq @@ -32829,7 +32039,7 @@ module.exports = function whichBoxedPrimitive(value) { } }; -},{"is-bigint":460,"is-boolean-object":461,"is-number-object":466,"is-string":470,"is-symbol":471}],534:[function(require,module,exports){ +},{"is-bigint":449,"is-boolean-object":450,"is-number-object":455,"is-string":459,"is-symbol":460}],507:[function(require,module,exports){ 'use strict'; var isMap = require('is-map'); @@ -32856,14 +32066,14 @@ module.exports = function whichCollection(/** @type {unknown} */ value) { return false; }; -},{"is-map":464,"is-set":468,"is-weakmap":472,"is-weakset":473}],535:[function(require,module,exports){ +},{"is-map":453,"is-set":457,"is-weakmap":461,"is-weakset":462}],508:[function(require,module,exports){ (function (global){(function (){ 'use strict'; var forEach = require('for-each'); var availableTypedArrays = require('available-typed-arrays'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var gOPD = require('gopd'); /** @type {(O: object) => string} */ @@ -32976,7 +32186,7 @@ module.exports = function whichTypedArray(value) { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"available-typed-arrays":52,"call-bind":64,"call-bound":65,"for-each":426,"gopd":435,"has-tostringtag/shams":440}],536:[function(require,module,exports){ +},{"available-typed-arrays":52,"call-bind":58,"call-bind/callBound":57,"for-each":418,"gopd":423,"has-tostringtag/shams":429}],509:[function(require,module,exports){ var _regeneratorRuntime = require("@babel/runtime/regenerator"); var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator")["default"]; /* eslint-disable */ @@ -33042,7 +32252,7 @@ function run() { if (useWorker && !answerPool.worker) return false; return true; } - window.startBroadcastChannel = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() { + window.startBroadcastChannel = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var rand, worker; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { @@ -33132,7 +32342,7 @@ function run() { })); // Worker test - window.startWorkerTest = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { + window.startWorkerTest = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { var worker, t, perRun, k, done, amountTime; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { @@ -33181,7 +32391,7 @@ function run() { } t--; _context3.next = 18; - return Promise.all(new Array(perRun).fill(0).map(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { + return Promise.all(new Array(perRun).fill(0).map( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { var msgId, waitForResponsePromise; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { @@ -33195,17 +32405,17 @@ function run() { case 3: msgId = 'worker-test-' + startTime + '-' + k++; waitForResponsePromise = new Promise(function (res) { - var _listener = function listener(msg) { + var listener = function listener(msg) { if (msg.answer == true && msg.original.id === msgId) { console.dir('msg for response:;:'); console.dir(msg); done++; messageCountWorkerContainer.innerHTML = done; - channel.removeEventListener('message', _listener); + channel.removeEventListener('message', listener); res(); } }; - channel.addEventListener('message', _listener); + channel.addEventListener('message', listener); }); channel.postMessage({ from: 'main-worker', @@ -33253,20 +32463,20 @@ try { console.log('error in run-function:'); console.error(error); } -},{"../../":2,"./util.js":537,"@babel/polyfill":11,"@babel/runtime/helpers/asyncToGenerator":13,"@babel/runtime/regenerator":20,"async-test-util":37}],537:[function(require,module,exports){ +},{"../../":2,"./util.js":510,"@babel/polyfill":11,"@babel/runtime/helpers/asyncToGenerator":13,"@babel/runtime/regenerator":20,"async-test-util":37}],510:[function(require,module,exports){ /* eslint no-useless-escape: "off" */ // https://stackoverflow.com/a/901144/3443137 function getParameterByName(name, url) { if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"); + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); var results = regex.exec(url); if (!results) return null; - if (!results[2]) return ""; - return decodeURIComponent(results[2].replace(/\+/g, " ")); + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); } module.exports = { getParameterByName: getParameterByName }; -},{}]},{},[536]); +},{}]},{},[509]); diff --git a/docs/iframe.js b/docs/iframe.js index 1b889b73..05e98a5b 100644 --- a/docs/iframe.js +++ b/docs/iframe.js @@ -1,11 +1,9 @@ (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 Promise.all(this._befC.map(fn => fn()))) // close the channel - .then(() => this.method.close ? this.method.close(this._state) : Promise.resolve()); + .then(() => this.method.close(this._state)); }, get type() { return this.method.type; @@ -166,7 +164,6 @@ function _post(broadcastChannel, type, msg) { // add/remove to unsend messages list broadcastChannel._uMP.add(sendPromise); - // eslint-disable-next-line promise/valid-params sendPromise.catch().then(() => broadcastChannel._uMP.delete(sendPromise)); return sendPromise; }); @@ -181,7 +178,6 @@ function _prepareChannel(channel) { await new Promise(res => setTimeout(res, this.options.prepareDelay)); }*/ channel._state = s; - return; }); } else { channel._state = maybePromise; @@ -220,7 +216,7 @@ function _startListening(channel) { if (msgObj.time >= listenerObject.time) { listenerObject.fn(msgObj.data); - } else if (channel.method.type === "server") { + } else if (channel.method.type === 'server') { // server msg might lag based on connection. listenerObject.fn(msgObj.data); } @@ -231,7 +227,6 @@ function _startListening(channel) { channel._prepP.then(() => { channel._iL = true; channel.method.onMessage(channel._state, listenerFn, time); - return; }); } else { channel._iL = true; @@ -255,18 +250,18 @@ exports.enforceOptions = enforceOptions; },{"./method-chooser.js":3,"./options.js":9,"./util.js":10}],2:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var broadcastChannel = require('./broadcast-channel.js'); var methodChooser = require('./method-chooser.js'); +exports.NativeMethod = native; exports.IndexedDbMethod = indexedDb; exports.LocalstorageMethod = localstorage; -exports.NativeMethod = native; exports.ServerMethod = server; exports.BroadcastChannel = broadcastChannel.BroadcastChannel; exports.OPEN_BROADCAST_CHANNELS = broadcastChannel.OPEN_BROADCAST_CHANNELS; @@ -276,9 +271,9 @@ exports.chooseMethod = methodChooser.chooseMethod; },{"./broadcast-channel.js":1,"./method-chooser.js":3,"./methods/indexed-db.js":4,"./methods/localstorage.js":5,"./methods/native.js":6,"./methods/server.js":7}],3:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var simulate = require('./methods/simulate.js'); @@ -291,12 +286,12 @@ function chooseMethod(options) { // directly chosen if (options.type) { - if (options.type === "simulate") { + if (options.type === 'simulate') { // only use simulate-method if directly chosen return simulate; } const ret = chooseMethods.find(m => m.type === options.type); - if (!ret) throw new Error("method-type " + options.type + " not found");else return ret; + if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret; } /** @@ -304,7 +299,7 @@ function chooseMethod(options) { * remove idb from the list so that localstorage is been chosen */ if (!options.webWorkerSupport) { - chooseMethods = chooseMethods.filter(m => m.type !== "idb"); + chooseMethods = chooseMethods.filter(m => m.type !== 'idb'); } const useMethod = chooseMethods.find(method => method.canBeUsed(options)); if (!useMethod) throw new Error(`No useable method found in ${JSON.stringify(METHODS.map(m => m.type))}`);else return useMethod; @@ -329,23 +324,23 @@ var options = require('../options.js'); */ const microSeconds = util.microSeconds; -const DB_PREFIX = "pubkey.broadcast-channel-0-"; -const OBJECT_STORE_ID = "messages"; +const DB_PREFIX = 'pubkey.broadcast-channel-0-'; +const OBJECT_STORE_ID = 'messages'; /** * Use relaxed durability for faster performance on all transactions. * @link https://nolanlawson.com/2021/08/22/speeding-up-indexeddb-reads-and-writes/ */ const TRANSACTION_SETTINGS = { - durability: "relaxed" + durability: 'relaxed' }; -const type = "idb"; +const type = 'idb'; function getIdb() { - if (typeof indexedDB !== "undefined") return indexedDB; - if (typeof window !== "undefined") { - if (typeof window.mozIndexedDB !== "undefined") return window.mozIndexedDB; - if (typeof window.webkitIndexedDB !== "undefined") return window.webkitIndexedDB; - if (typeof window.msIndexedDB !== "undefined") return window.msIndexedDB; + if (typeof indexedDB !== 'undefined') return indexedDB; + if (typeof window !== 'undefined') { + if (typeof window.mozIndexedDB !== 'undefined') return window.mozIndexedDB; + if (typeof window.webkitIndexedDB !== 'undefined') return window.webkitIndexedDB; + if (typeof window.msIndexedDB !== 'undefined') return window.msIndexedDB; } return false; } @@ -375,14 +370,14 @@ function createDatabase(channelName) { openRequest.onupgradeneeded = ev => { const db = ev.target.result; db.createObjectStore(OBJECT_STORE_ID, { - keyPath: "id", + keyPath: 'id', autoIncrement: true }); }; - const dbPromise = new Promise((resolve, reject) => { - openRequest.onerror = ev => reject(ev); + const dbPromise = new Promise((res, rej) => { + openRequest.onerror = ev => rej(ev); openRequest.onsuccess = () => { - resolve(openRequest.result); + res(openRequest.result); }; }); return dbPromise; @@ -399,20 +394,20 @@ function writeMessage(db, readerUuid, messageJson) { time, data: messageJson }; - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); - return new Promise((resolve, reject) => { - tx.oncomplete = () => resolve(); - tx.onerror = ev => reject(ev); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); + return new Promise((res, rej) => { + tx.oncomplete = () => res(); + tx.onerror = ev => rej(ev); const objectStore = tx.objectStore(OBJECT_STORE_ID); objectStore.add(writeObject); commitIndexedDBTransaction(tx); }); } function getAllMessages(db) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -421,13 +416,13 @@ function getAllMessages(db) { cursor.continue(); } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function getMessagesHigherThan(db, lastCursorId) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; let keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); @@ -439,10 +434,10 @@ function getMessagesHigherThan(db, lastCursorId) { */ if (objectStore.getAll) { const getAllRequest = objectStore.getAll(keyRangeValue); - return new Promise((resolve, reject) => { - getAllRequest.onerror = err => reject(err); + return new Promise((res, rej) => { + getAllRequest.onerror = err => rej(err); getAllRequest.onsuccess = function (e) { - resolve(e.target.result); + res(e.target.result); }; }); } @@ -453,13 +448,13 @@ function getMessagesHigherThan(db, lastCursorId) { try { keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); return objectStore.openCursor(keyRangeValue); - } catch { + } catch (e) { return objectStore.openCursor(); } } - return new Promise((resolve, reject) => { + return new Promise((res, rej) => { const openCursorRequest = openCursor(); - openCursorRequest.onerror = err => reject(err); + openCursorRequest.onerror = err => rej(err); openCursorRequest.onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -471,27 +466,27 @@ function getMessagesHigherThan(db, lastCursorId) { } } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function removeMessagesById(db, ids) { - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); return Promise.all(ids.map(id => { const deleteRequest = objectStore.delete(id); - return new Promise(resolve => { - deleteRequest.onsuccess = () => resolve(); + return new Promise(res => { + deleteRequest.onsuccess = () => res(); }); })); } function getOldMessages(db, ttl) { const olderThen = Date.now() - ttl; - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -503,11 +498,11 @@ function getOldMessages(db, ttl) { } else { // no more old messages, commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); return; } } else { - resolve(ret); + res(ret); } }; }); @@ -562,8 +557,6 @@ function create(channelName, options$1) { } function _readLoop(state) { if (state.closed) return; - - // eslint-disable-next-line promise/catch-or-return readNewMessages(state).then(() => util.sleep(state.options.idb.fallbackInterval)).then(() => _readLoop(state)); } function _filterMessage(msgObj, state) { @@ -609,7 +602,6 @@ function close(channelState) { } function postMessage(channelState, messageJson) { channelState.writeBlockPromise = channelState.writeBlockPromise.then(() => writeMessage(channelState.db, channelState.uuid, messageJson)).then(() => { - // eslint-disable-next-line promise/always-return if (util.randomInt(0, 10) === 0) { /* await (do not await) */ cleanOldMessages(channelState.db, channelState.options.idb.ttl); @@ -650,7 +642,7 @@ exports.removeMessagesById = removeMessagesById; exports.type = type; exports.writeMessage = writeMessage; -},{"../options.js":9,"../util.js":10,"oblivious-set":445}],5:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":427}],5:[function(require,module,exports){ 'use strict'; var obliviousSet = require('oblivious-set'); @@ -666,8 +658,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "localstorage"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'localstorage'; /** * copied from crosstab @@ -675,11 +667,11 @@ const type = "localstorage"; */ function getLocalStorage() { let localStorage; - if (typeof window === "undefined") return null; + if (typeof window === 'undefined') return null; try { localStorage = window.localStorage; - localStorage = window["ie8-eventlistener/storage"] || window.localStorage; - } catch { + localStorage = window['ie8-eventlistener/storage'] || window.localStorage; + } catch (e) { // New versions of Firefox throw a Security exception // if cookies are disabled. See // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153 @@ -695,8 +687,7 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise(resolve => { - // eslint-disable-next-line promise/catch-or-return, promise/always-return + return new Promise(res => { util.sleep().then(() => { const key = storageKey(channelState.channelName); const writeObj = { @@ -713,12 +704,12 @@ function postMessage(channelState, messageJson) { * in the window that changes the state of the local storage. * So we fire it manually */ - const ev = document.createEvent("Event"); - ev.initEvent("storage", true, true); + const ev = document.createEvent('Event'); + ev.initEvent('storage', true, true); ev.key = key; ev.newValue = value; window.dispatchEvent(ev); - resolve(); + res(); }); }); } @@ -729,16 +720,16 @@ function addStorageEventListener(channelName, fn) { fn(JSON.parse(ev.newValue)); } }; - window.addEventListener("storage", listener); + window.addEventListener('storage', listener); return listener; } function removeStorageEventListener(listener) { - window.removeEventListener("storage", listener); + window.removeEventListener('storage', listener); } function create(channelName, options$1) { options$1 = options.fillOptionsWithDefaults(options$1); if (!canBeUsed()) { - throw new Error("BroadcastChannel: localstorage cannot be used"); + throw new Error('BroadcastChannel: localstorage cannot be used'); } const uuid = util.randomToken(); @@ -776,10 +767,10 @@ function canBeUsed() { const ls = getLocalStorage(); if (!ls) return false; try { - const key = "__broadcastchannel_check"; - ls.setItem(key, "works"); + const key = '__broadcastchannel_check'; + ls.setItem(key, 'works'); ls.removeItem(key); - } catch { + } catch (e) { // Safari 10 in private mode will not allow write access to local // storage and fail with a QuotaExceededError. See // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes @@ -790,7 +781,7 @@ function canBeUsed() { function averageResponseTime() { const defaultTime = 120; const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes("safari") && !userAgent.includes("chrome")) { + if (userAgent.includes('safari') && !userAgent.includes('chrome')) { // safari is much slower so this time is higher return defaultTime * 2; } @@ -810,13 +801,13 @@ exports.removeStorageEventListener = removeStorageEventListener; exports.storageKey = storageKey; exports.type = type; -},{"../options.js":9,"../util.js":10,"oblivious-set":445}],6:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":427}],6:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "native"; +const type = 'native'; function create(channelName) { const state = { time: util.microSeconds(), @@ -851,10 +842,10 @@ function canBeUsed() { * in the electron-renderer, isNode will be true even if we are in browser-context * so we also check if window is undefined */ - if (typeof window === "undefined") return false; - if (typeof BroadcastChannel === "function") { + if (typeof window === 'undefined') return false; + if (typeof BroadcastChannel === 'function') { if (BroadcastChannel._pubkey) { - throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"); + throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill'); } return true; } else return false; @@ -876,12 +867,12 @@ exports.type = type; (function (Buffer){(function (){ 'use strict'; -var eccrypto = require('@toruslabs/eccrypto'); -var metadataHelpers = require('@toruslabs/metadata-helpers'); var obliviousSet = require('oblivious-set'); var socket_ioClient = require('socket.io-client'); -var options = require('../options.js'); +var eccrypto = require('@toruslabs/eccrypto'); +var metadataHelpers = require('@toruslabs/metadata-helpers'); var util = require('../util.js'); +var options = require('../options.js'); /** * A localStorage-only method which uses localstorage and its 'storage'-event @@ -892,8 +883,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "server"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'server'; let SOCKET_CONN_INSTANCE = null; // used to decide to reconnect socket e.g. when socket connection is disconnected unexpectedly const runningChannels = new Set(); @@ -906,12 +897,11 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise((resolve, reject) => { - // eslint-disable-next-line promise/catch-or-return + return new Promise((res, rej) => { util.sleep().then(async () => { const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString("hex"), { + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString('hex'), { token: util.randomToken(), time: Date.now(), data: messageJson, @@ -920,18 +910,18 @@ function postMessage(channelState, messageJson) { const body = { sameOriginCheck: true, sameIpCheck: true, - key: eccrypto.getPublic(channelEncPrivKey).toString("hex"), + key: eccrypto.getPublic(channelEncPrivKey).toString('hex'), data: encData, - signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, "utf8")))).toString("hex") + signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, 'utf8')))).toString('hex') }; if (channelState.timeout) body.timeout = channelState.timeout; - return fetch(channelState.serverUrl + "/channel/set", { - method: "POST", + return fetch(channelState.serverUrl + '/channel/set', { + method: 'POST', body: JSON.stringify(body), headers: { - "Content-Type": "application/json; charset=utf-8" + 'Content-Type': 'application/json; charset=utf-8' } - }).then(resolve).catch(reject); + }).then(res).catch(rej); }); }); } @@ -940,33 +930,33 @@ function getSocketInstance(serverUrl) { return SOCKET_CONN_INSTANCE; } const SOCKET_CONN = socket_ioClient.io(serverUrl, { - transports: ["websocket", "polling"], + transports: ['websocket', 'polling'], // use WebSocket first, if available withCredentials: true, reconnectionDelayMax: 10000, reconnectionAttempts: 10 }); - SOCKET_CONN.on("connect_error", err => { + SOCKET_CONN.on('connect_error', err => { // revert to classic upgrade - SOCKET_CONN.io.opts.transports = ["polling", "websocket"]; - util.log.error("connect error", err); + SOCKET_CONN.io.opts.transports = ['polling', 'websocket']; + util.log.error('connect error', err); }); - SOCKET_CONN.on("connect", async () => { + SOCKET_CONN.on('connect', async () => { const { engine } = SOCKET_CONN.io; - util.log.debug("initially connected to", engine.transport.name); // in most cases, prints "polling" - engine.once("upgrade", () => { + util.log.debug('initially connected to', engine.transport.name); // in most cases, prints "polling" + engine.once('upgrade', () => { // called when the transport is upgraded (i.e. from HTTP long-polling to WebSocket) - util.log.debug("upgraded", engine.transport.name); // in most cases, prints "websocket" + util.log.debug('upgraded', engine.transport.name); // in most cases, prints "websocket" }); - engine.once("close", reason => { + engine.once('close', reason => { // called when the underlying connection is closed - util.log.debug("connection closed", reason); + util.log.debug('connection closed', reason); }); }); - SOCKET_CONN.on("error", err => { - util.log.error("socket errored", err); + SOCKET_CONN.on('error', err => { + util.log.error('socket errored', err); SOCKET_CONN.disconnect(); }); SOCKET_CONN_INSTANCE = SOCKET_CONN; @@ -975,26 +965,26 @@ function getSocketInstance(serverUrl) { function setupSocketConnection(serverUrl, channelState, fn) { const socketConn = getSocketInstance(serverUrl); const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString("hex"); + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString('hex'); if (socketConn.connected) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); } else { - socketConn.once("connect", () => { - util.log.debug("connected with socket"); - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.once('connect', () => { + util.log.debug('connected with socket'); + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); }); } const reconnect = () => { - socketConn.once("connect", async () => { + socketConn.once('connect', async () => { if (runningChannels.has(channelState.channelName)) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); @@ -1004,32 +994,32 @@ function setupSocketConnection(serverUrl, channelState, fn) { const visibilityListener = () => { // if channel is closed, then remove the listener. if (!socketConn || !runningChannels.has(channelState.channelName)) { - document.removeEventListener("visibilitychange", visibilityListener); + document.removeEventListener('visibilitychange', visibilityListener); return; } // if not connected, then wait for connection and ping server for latest msg. - if (!socketConn.connected && document.visibilityState === "visible") { + if (!socketConn.connected && document.visibilityState === 'visible') { reconnect(); } }; const listener = async ev => { try { - const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString("hex"), ev); + const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString('hex'), ev); util.log.info(decData); fn(decData); } catch (error) { util.log.error(error); } }; - socketConn.on("disconnect", () => { - util.log.debug("socket disconnected"); + socketConn.on('disconnect', () => { + util.log.debug('socket disconnected'); if (runningChannels.has(channelState.channelName)) { - util.log.error("socket disconnected unexpectedly, reconnecting socket"); + util.log.error('socket disconnected unexpectedly, reconnecting socket'); reconnect(); } }); socketConn.on(`${channelPubKey}_success`, listener); - if (typeof document !== "undefined") document.addEventListener("visibilitychange", visibilityListener); + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', visibilityListener); return socketConn; } function removeStorageEventListener() { @@ -1104,13 +1094,13 @@ exports.storageKey = storageKey; exports.type = type; }).call(this)}).call(this,require("buffer").Buffer) -},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":33,"oblivious-set":445,"socket.io-client":451}],8:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":33,"oblivious-set":427,"socket.io-client":433}],8:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "simulate"; +const type = 'simulate'; const SIMULATE_CHANNELS = new Set(); const SIMULATE_DELAY_TIME = 5; function create(channelName) { @@ -1126,7 +1116,7 @@ function close(channelState) { SIMULATE_CHANNELS.delete(channelState); } function postMessage(channelState, messageJson) { - return new Promise(resolve => setTimeout(() => { + return new Promise(res => setTimeout(() => { const channelArray = Array.from(SIMULATE_CHANNELS); channelArray.forEach(channel => { if (channel.name === channelState.name && @@ -1140,7 +1130,7 @@ function postMessage(channelState, messageJson) { channel.messagesCallback(messageJson); } }); - resolve(); + res(); }, SIMULATE_DELAY_TIME)); } function onMessage(channelState, fn) { @@ -1170,7 +1160,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { const options = JSON.parse(JSON.stringify(originalOptions)); // main - if (typeof options.webWorkerSupport === "undefined") options.webWorkerSupport = true; + if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db if (!options.idb) options.idb = {}; @@ -1178,7 +1168,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { if (!options.idb.ttl) options.idb.ttl = 1000 * 45; if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events. - if (originalOptions.idb && typeof originalOptions.idb.onclose === "function") options.idb.onclose = originalOptions.idb.onclose; + if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage if (!options.localstorage) options.localstorage = {}; @@ -1186,7 +1176,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { // server if (!options.server) options.server = {}; - if (!options.server.url) options.server.url = "https://session.web3auth.io"; + if (!options.server.url) options.server.url = 'https://session.web3auth.io'; if (!options.server.removeTimeout) options.server.removeTimeout = 1000 * 60 * 5; // 5 minutes // custom methods @@ -1207,7 +1197,7 @@ var loglevel = require('loglevel'); * returns true if the given object is a promise */ function isPromise(obj) { - if (obj && typeof obj.then === "function") { + if (obj && typeof obj.then === 'function') { return true; } else { return false; @@ -1218,7 +1208,7 @@ Promise.resolve(true); const PROMISE_RESOLVED_VOID = Promise.resolve(); function sleep(time, resolveWith) { if (!time) time = 0; - return new Promise(resolve => setTimeout(() => resolve(resolveWith), time)); + return new Promise(res => setTimeout(() => res(resolveWith), time)); } function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); @@ -1272,8 +1262,8 @@ function microSeconds() { // return thirdPartyCookieSupport; // } -const log = loglevel.getLogger("broadcast-channel"); -log.setLevel("error"); +const log = loglevel.getLogger('broadcast-channel'); +log.setLevel('error'); exports.PROMISE_RESOLVED_VOID = PROMISE_RESOLVED_VOID; exports.isPromise = isPromise; @@ -1283,7 +1273,7 @@ exports.randomInt = randomInt; exports.randomToken = randomToken; exports.sleep = sleep; -},{"loglevel":430}],11:[function(require,module,exports){ +},{"loglevel":420}],11:[function(require,module,exports){ "use strict"; require("./noConflict"); @@ -1297,7 +1287,7 @@ if (_global["default"]._babelPolyfill && typeof console !== "undefined" && conso } _global["default"]._babelPolyfill = true; -},{"./noConflict":12,"core-js/library/fn/global":54}],12:[function(require,module,exports){ +},{"./noConflict":12,"core-js/library/fn/global":48}],12:[function(require,module,exports){ "use strict"; require("core-js/es6"); @@ -1327,7 +1317,7 @@ require("core-js/fn/promise/finally"); require("core-js/web"); require("regenerator-runtime/runtime"); -},{"core-js/es6":42,"core-js/fn/array/flat-map":43,"core-js/fn/array/includes":44,"core-js/fn/object/entries":45,"core-js/fn/object/get-own-property-descriptors":46,"core-js/fn/object/values":47,"core-js/fn/promise/finally":48,"core-js/fn/string/pad-end":49,"core-js/fn/string/pad-start":50,"core-js/fn/string/trim-end":51,"core-js/fn/string/trim-start":52,"core-js/fn/symbol/async-iterator":53,"core-js/web":345,"regenerator-runtime/runtime":448}],13:[function(require,module,exports){ +},{"core-js/es6":36,"core-js/fn/array/flat-map":37,"core-js/fn/array/includes":38,"core-js/fn/object/entries":39,"core-js/fn/object/get-own-property-descriptors":40,"core-js/fn/object/values":41,"core-js/fn/promise/finally":42,"core-js/fn/string/pad-end":43,"core-js/fn/string/pad-start":44,"core-js/fn/string/trim-end":45,"core-js/fn/string/trim-start":46,"core-js/fn/symbol/async-iterator":47,"core-js/web":339,"regenerator-runtime/runtime":430}],13:[function(require,module,exports){ var toPropertyKey = require("./toPropertyKey.js"); function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { @@ -1387,54 +1377,54 @@ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports function _typeof(o) { "@babel/helpers - typeof"; - return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; },{}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isBytes = isBytes; -exports.number = number; -exports.bool = bool; -exports.bytes = bytes; -exports.hash = hash; -exports.exists = exists; -exports.output = output; +exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = exports.isBytes = void 0; function number(n) { if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); } +exports.number = number; function bool(b) { if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`); } +exports.bool = bool; // copied from utils function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; function bytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); } +exports.bytes = bytes; function hash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); number(h.outputLen); number(h.blockLen); } +exports.hash = hash; function exists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } +exports.exists = exists; function output(out, instance) { bytes(out); const min = instance.outputLen; @@ -1442,16 +1432,14 @@ function output(out, instance) { throw new Error(`digestInto() expects output buffer of length at least ${min}`); } } +exports.output = output; const assert = { number, bool, bytes, hash, exists, output }; exports.default = assert; },{}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = void 0; -exports.fromBig = fromBig; -exports.split = split; -exports.add = add; +exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.add = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = exports.split = exports.fromBig = void 0; const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); // We are not using BigUint64Array, because they are extremely slow as per 2022 @@ -1460,6 +1448,7 @@ function fromBig(n, le = false) { return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; } +exports.fromBig = fromBig; function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); @@ -1469,6 +1458,7 @@ function split(lst, le = false) { } return [Ah, Al]; } +exports.split = split; const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); exports.toBig = toBig; // for Shift in [0, 32) @@ -1507,6 +1497,7 @@ function add(Ah, Al, Bh, Bl) { const l = (Al >>> 0) + (Bl >>> 0); return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; } +exports.add = add; // Addition with more than 2 elements const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); exports.add3L = add3L; @@ -1540,8 +1531,7 @@ exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? glob },{}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0; -exports.keccakP = keccakP; +exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0; const _assert_js_1 = require("./_assert.js"); const _u64_js_1 = require("./_u64.js"); const utils_js_1 = require("./utils.js"); @@ -1622,6 +1612,7 @@ function keccakP(s, rounds = 24) { } B.fill(0); } +exports.keccakP = keccakP; class Keccak extends utils_js_1.Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { @@ -1761,20 +1752,7 @@ exports.shake256 = genShake(0x1f, 136, 256 / 8); "use strict"; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0; -exports.isBytes = isBytes; -exports.byteSwap32 = byteSwap32; -exports.bytesToHex = bytesToHex; -exports.hexToBytes = hexToBytes; -exports.asyncLoop = asyncLoop; -exports.utf8ToBytes = utf8ToBytes; -exports.toBytes = toBytes; -exports.concatBytes = concatBytes; -exports.checkOpts = checkOpts; -exports.wrapConstructor = wrapConstructor; -exports.wrapConstructorWithOpts = wrapConstructorWithOpts; -exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; -exports.randomBytes = randomBytes; +exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.byteSwap32 = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = exports.isBytes = void 0; // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. // node.js versions earlier than v19 don't declare it in global scope. // For node.js, package.json#exports field mapping rewrites import @@ -1789,6 +1767,7 @@ function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; // Cast array to different type const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); exports.u8 = u8; @@ -1818,6 +1797,7 @@ function byteSwap32(arr) { arr[i] = (0, exports.byteSwap)(arr[i]); } } +exports.byteSwap32 = byteSwap32; // Array where index 0xf0 (240) is mapped to string 'f0' const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); /** @@ -1832,6 +1812,7 @@ function bytesToHex(bytes) { } return hex; } +exports.bytesToHex = bytesToHex; // We use optimized technique to convert hex string to byte array const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; function asciiToBase16(char) { @@ -1865,6 +1846,7 @@ function hexToBytes(hex) { } return array; } +exports.hexToBytes = hexToBytes; // There is no setImmediate in browser and setTimeout is slow. // call of async fn will return Promise, which will be fullfiled only on // next scheduler queue processing step and this is exactly what we need. @@ -1883,6 +1865,7 @@ async function asyncLoop(iters, tick, cb) { ts += diff; } } +exports.asyncLoop = asyncLoop; /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ @@ -1891,6 +1874,7 @@ function utf8ToBytes(str) { throw new Error(`utf8ToBytes expected string, got ${typeof str}`); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } +exports.utf8ToBytes = utf8ToBytes; /** * Normalizes (non-hex) string or Uint8Array to Uint8Array. * Warning: when Uint8Array is passed, it would NOT get copied. @@ -1902,6 +1886,7 @@ function toBytes(data) { (0, _assert_js_1.bytes)(data); return data; } +exports.toBytes = toBytes; /** * Copies several Uint8Arrays into one. */ @@ -1920,6 +1905,7 @@ function concatBytes(...arrays) { } return res; } +exports.concatBytes = concatBytes; // For runtime check if class implements interface class Hash { // Safe version that clones internal state @@ -1935,6 +1921,7 @@ function checkOpts(defaults, opts) { const merged = Object.assign(defaults, opts); return merged; } +exports.checkOpts = checkOpts; function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); @@ -1943,6 +1930,7 @@ function wrapConstructor(hashCons) { hashC.create = () => hashCons(); return hashC; } +exports.wrapConstructor = wrapConstructor; function wrapConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1951,6 +1939,7 @@ function wrapConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapConstructorWithOpts = wrapConstructorWithOpts; function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1959,6 +1948,7 @@ function wrapXOFConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; /** * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. */ @@ -1966,12 +1956,9 @@ function randomBytes(bytesLength = 32) { if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); } - // Legacy Node.js compatibility - if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { - return crypto_1.crypto.randomBytes(bytesLength); - } throw new Error('crypto.getRandomValues must be defined'); } +exports.randomBytes = randomBytes; },{"./_assert.js":18,"@noble/hashes/crypto":20}],23:[function(require,module,exports){ @@ -2197,26 +2184,18 @@ function equalConstTime(b1, b2) { not, since the functions are different and does not convert using browserify */ function randomBytes(size) { - if (typeof browserCrypto.getRandomValues === "undefined") { - return Buffer.from(browserCrypto.randomBytes(size)); - } const arr = new Uint8Array(size); browserCrypto.getRandomValues(arr); return Buffer.from(arr); } async function sha512(msg) { - if (!browserCrypto.createHash) { - const hash = await subtle.digest("SHA-512", msg); - const result = new Uint8Array(hash); - return result; - } - const hash = browserCrypto.createHash("sha512"); - const result = hash.update(msg).digest(); - return new Uint8Array(result); + const hash = await subtle.digest("SHA-512", msg); + const result = new Uint8Array(hash); + return result; } function getAes(op) { return async function (iv, key, data) { - if (subtle && subtle[op] && subtle.importKey) { + if (subtle) { const importAlgorithm = { name: "AES-CBC" }; @@ -2225,20 +2204,8 @@ function getAes(op) { name: "AES-CBC", iv }; - // encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. const result = await subtle[op](encAlgorithm, cryptoKey, data); return Buffer.from(new Uint8Array(result)); - } else if (op === "encrypt" && browserCrypto.createCipheriv) { - // This is available if crypto is polyfilled in react native environment - const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); - const firstChunk = cipher.update(data); - const secondChunk = cipher.final(); - return Buffer.concat([firstChunk, secondChunk]); - } else if (op === "decrypt" && browserCrypto.createDecipheriv) { - const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); - const firstChunk = decipher.update(data); - const secondChunk = decipher.final(); - return Buffer.concat([firstChunk, secondChunk]); } throw new Error(`Unsupported operation: ${op}`); }; @@ -2246,21 +2213,15 @@ function getAes(op) { const aesCbcEncrypt = getAes("encrypt"); const aesCbcDecrypt = getAes("decrypt"); async function hmacSha256Sign(key, msg) { - if (!browserCrypto.createHmac) { - const importAlgorithm = { - name: "HMAC", - hash: { - name: "SHA-256" - } - }; - const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); - const sig = await subtle.sign("HMAC", cryptoKey, msg); - const result = Buffer.from(new Uint8Array(sig)); - return result; - } - const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); - hmac.update(msg); - const result = hmac.digest(); + const importAlgorithm = { + name: "HMAC", + hash: { + name: "SHA-256" + } + }; + const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); + const sig = await subtle.sign("HMAC", cryptoKey, msg); + const result = Buffer.from(new Uint8Array(sig)); return result; } async function hmacSha256Verify(key, msg, sig) { @@ -2418,7 +2379,7 @@ exports.sign = sign; exports.verify = verify; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":33,"elliptic":349}],25:[function(require,module,exports){ +},{"buffer":33,"elliptic":344}],25:[function(require,module,exports){ 'use strict'; var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); @@ -2427,9 +2388,6 @@ var logLevel = require('loglevel'); const log = logLevel.getLogger("http-helpers"); log.setLevel(logLevel.levels.INFO); - -// eslint-disable-next-line @typescript-eslint/no-empty-object-type - let apiKey = "torus-default"; let embedHost = ""; @@ -2472,9 +2430,7 @@ async function fetchAndTrace(url, init) { let _url = null; try { _url = new URL(url); - } catch { - // ignore - } + } catch (error) {} if (sentry && _url && (tracingOrigins.includes(_url.origin) || tracingPaths.includes(_url.pathname))) { const result = await sentry.startSpan({ name: url, @@ -2538,7 +2494,7 @@ const get = async (url, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2577,7 +2533,7 @@ const post = (url, data = {}, options_ = {}, customOptions = {}) => { } if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2616,7 +2572,7 @@ const patch = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2654,7 +2610,7 @@ const put = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2690,7 +2646,7 @@ const remove = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2729,7 +2685,7 @@ exports.setAPIKey = setAPIKey; exports.setEmbedHost = setEmbedHost; exports.setLogLevel = setLogLevel; -},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":346,"loglevel":430}],26:[function(require,module,exports){ +},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":342,"loglevel":420}],26:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -2743,8 +2699,8 @@ class MetadataStorageLayer { // ms constructor(metadataHost = "https://metadata.tor.us", serverTimeOffset = 0) { - _defineProperty(this, "metadataHost", undefined); - _defineProperty(this, "serverTimeOffset", undefined); + _defineProperty(this, "metadataHost", void 0); + _defineProperty(this, "serverTimeOffset", void 0); this.metadataHost = metadataHost; this.serverTimeOffset = serverTimeOffset; } @@ -2766,7 +2722,7 @@ class MetadataStorageLayer { pub_key_X: key.getPublic().getX().toString(16, 64), pub_key_Y: key.getPublic().getY().toString(16, 64), set_data: setData, - signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === undefined ? undefined : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== undefined ? _sig$recoveryParam$to : "00"), "hex").toString("base64") + signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === void 0 ? void 0 : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== void 0 ? _sig$recoveryParam$to : "00"), "hex").toString("base64") }; } generatePubKeyParams(privateKeyHex) { @@ -2799,7 +2755,7 @@ class MetadataStorageLayer { exports.MetadataStorageLayer = MetadataStorageLayer; }).call(this)}).call(this,require("buffer").Buffer) -},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":33,"json-stable-stringify":426}],27:[function(require,module,exports){ +},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":33,"json-stable-stringify":416}],27:[function(require,module,exports){ 'use strict'; var MetadataStorageLayer = require('./MetadataStorageLayer.js'); @@ -2838,7 +2794,7 @@ exports.ec = ec; exports.keccak256 = keccak256; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":33,"elliptic":349,"ethereum-cryptography/keccak":396}],29:[function(require,module,exports){ +},{"buffer":33,"elliptic":344,"ethereum-cryptography/keccak":389}],29:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -4957,112 +4913,61 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":30,"buffer":33,"ieee754":423}],34:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); - -var $apply = require('./functionApply'); -var $call = require('./functionCall'); -var $reflectApply = require('./reflectApply'); - -/** @type {import('./actualApply')} */ -module.exports = $reflectApply || bind.call($call, $apply); - -},{"./functionApply":36,"./functionCall":37,"./reflectApply":39,"function-bind":399}],35:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $apply = require('./functionApply'); -var actualApply = require('./actualApply'); - -/** @type {import('./applyBind')} */ -module.exports = function applyBind() { - return actualApply(bind, $apply, arguments); -}; - -},{"./actualApply":34,"./functionApply":36,"function-bind":399}],36:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionApply')} */ -module.exports = Function.prototype.apply; - -},{}],37:[function(require,module,exports){ +},{"base64-js":30,"buffer":33,"ieee754":413}],34:[function(require,module,exports){ 'use strict'; -/** @type {import('./functionCall')} */ -module.exports = Function.prototype.call; - -},{}],38:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -var bind = require('function-bind'); -var $TypeError = require('es-errors/type'); +var callBind = require('./'); -var $call = require('./functionCall'); -var $actualApply = require('./actualApply'); +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); -/** @type {import('.')} */ -module.exports = function callBindBasic(args) { - if (args.length < 1 || typeof args[0] !== 'function') { - throw new $TypeError('a function is required'); +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { + return callBind(intrinsic); } - return $actualApply(bind, $call, args); + return intrinsic; }; -},{"./actualApply":34,"./functionCall":37,"es-errors/type":393,"function-bind":399}],39:[function(require,module,exports){ -'use strict'; - -/** @type {import('./reflectApply')} */ -module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply; - -},{}],40:[function(require,module,exports){ +},{"./":35,"get-intrinsic":393}],35:[function(require,module,exports){ 'use strict'; +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); var setFunctionLength = require('set-function-length'); -var $defineProperty = require('es-define-property'); +var $TypeError = require('es-errors/type'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); -var callBindBasic = require('call-bind-apply-helpers'); -var applyBind = require('call-bind-apply-helpers/applyBind'); +var $defineProperty = require('es-define-property'); +var $max = GetIntrinsic('%Math.max%'); module.exports = function callBind(originalFunction) { - var func = callBindBasic(arguments); - var adjustedLength = originalFunction.length - (arguments.length - 1); + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); return setFunctionLength( func, - 1 + (adjustedLength > 0 ? adjustedLength : 0), + 1 + $max(0, originalFunction.length - (arguments.length - 1)), true ); }; +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + if ($defineProperty) { $defineProperty(module.exports, 'apply', { value: applyBind }); } else { module.exports.apply = applyBind; } -},{"call-bind-apply-helpers":38,"call-bind-apply-helpers/applyBind":35,"es-define-property":387,"set-function-length":449}],41:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); - -var callBindBasic = require('call-bind-apply-helpers'); - -/** @type {(thisArg: string, searchString: string, position?: number) => number} */ -var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]); - -/** @type {import('.')} */ -module.exports = function callBoundIntrinsic(name, allowMissing) { - // eslint-disable-next-line no-extra-parens - var intrinsic = /** @type {Parameters[0][0]} */ (GetIntrinsic(name, !!allowMissing)); - if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { - return callBindBasic([intrinsic]); - } - return intrinsic; -}; - -},{"call-bind-apply-helpers":38,"get-intrinsic":400}],42:[function(require,module,exports){ +},{"es-define-property":381,"es-errors/type":387,"function-bind":392,"get-intrinsic":393,"set-function-length":431}],36:[function(require,module,exports){ require('../modules/es6.symbol'); require('../modules/es6.object.create'); require('../modules/es6.object.define-property'); @@ -5203,74 +5108,74 @@ require('../modules/es6.reflect.set'); require('../modules/es6.reflect.set-prototype-of'); module.exports = require('../modules/_core'); -},{"../modules/_core":91,"../modules/es6.array.copy-within":193,"../modules/es6.array.every":194,"../modules/es6.array.fill":195,"../modules/es6.array.filter":196,"../modules/es6.array.find":198,"../modules/es6.array.find-index":197,"../modules/es6.array.for-each":199,"../modules/es6.array.from":200,"../modules/es6.array.index-of":201,"../modules/es6.array.is-array":202,"../modules/es6.array.iterator":203,"../modules/es6.array.join":204,"../modules/es6.array.last-index-of":205,"../modules/es6.array.map":206,"../modules/es6.array.of":207,"../modules/es6.array.reduce":209,"../modules/es6.array.reduce-right":208,"../modules/es6.array.slice":210,"../modules/es6.array.some":211,"../modules/es6.array.sort":212,"../modules/es6.array.species":213,"../modules/es6.date.now":214,"../modules/es6.date.to-iso-string":215,"../modules/es6.date.to-json":216,"../modules/es6.date.to-primitive":217,"../modules/es6.date.to-string":218,"../modules/es6.function.bind":219,"../modules/es6.function.has-instance":220,"../modules/es6.function.name":221,"../modules/es6.map":222,"../modules/es6.math.acosh":223,"../modules/es6.math.asinh":224,"../modules/es6.math.atanh":225,"../modules/es6.math.cbrt":226,"../modules/es6.math.clz32":227,"../modules/es6.math.cosh":228,"../modules/es6.math.expm1":229,"../modules/es6.math.fround":230,"../modules/es6.math.hypot":231,"../modules/es6.math.imul":232,"../modules/es6.math.log10":233,"../modules/es6.math.log1p":234,"../modules/es6.math.log2":235,"../modules/es6.math.sign":236,"../modules/es6.math.sinh":237,"../modules/es6.math.tanh":238,"../modules/es6.math.trunc":239,"../modules/es6.number.constructor":240,"../modules/es6.number.epsilon":241,"../modules/es6.number.is-finite":242,"../modules/es6.number.is-integer":243,"../modules/es6.number.is-nan":244,"../modules/es6.number.is-safe-integer":245,"../modules/es6.number.max-safe-integer":246,"../modules/es6.number.min-safe-integer":247,"../modules/es6.number.parse-float":248,"../modules/es6.number.parse-int":249,"../modules/es6.number.to-fixed":250,"../modules/es6.number.to-precision":251,"../modules/es6.object.assign":252,"../modules/es6.object.create":253,"../modules/es6.object.define-properties":254,"../modules/es6.object.define-property":255,"../modules/es6.object.freeze":256,"../modules/es6.object.get-own-property-descriptor":257,"../modules/es6.object.get-own-property-names":258,"../modules/es6.object.get-prototype-of":259,"../modules/es6.object.is":263,"../modules/es6.object.is-extensible":260,"../modules/es6.object.is-frozen":261,"../modules/es6.object.is-sealed":262,"../modules/es6.object.keys":264,"../modules/es6.object.prevent-extensions":265,"../modules/es6.object.seal":266,"../modules/es6.object.set-prototype-of":267,"../modules/es6.object.to-string":268,"../modules/es6.parse-float":269,"../modules/es6.parse-int":270,"../modules/es6.promise":271,"../modules/es6.reflect.apply":272,"../modules/es6.reflect.construct":273,"../modules/es6.reflect.define-property":274,"../modules/es6.reflect.delete-property":275,"../modules/es6.reflect.enumerate":276,"../modules/es6.reflect.get":279,"../modules/es6.reflect.get-own-property-descriptor":277,"../modules/es6.reflect.get-prototype-of":278,"../modules/es6.reflect.has":280,"../modules/es6.reflect.is-extensible":281,"../modules/es6.reflect.own-keys":282,"../modules/es6.reflect.prevent-extensions":283,"../modules/es6.reflect.set":285,"../modules/es6.reflect.set-prototype-of":284,"../modules/es6.regexp.constructor":286,"../modules/es6.regexp.exec":287,"../modules/es6.regexp.flags":288,"../modules/es6.regexp.match":289,"../modules/es6.regexp.replace":290,"../modules/es6.regexp.search":291,"../modules/es6.regexp.split":292,"../modules/es6.regexp.to-string":293,"../modules/es6.set":294,"../modules/es6.string.anchor":295,"../modules/es6.string.big":296,"../modules/es6.string.blink":297,"../modules/es6.string.bold":298,"../modules/es6.string.code-point-at":299,"../modules/es6.string.ends-with":300,"../modules/es6.string.fixed":301,"../modules/es6.string.fontcolor":302,"../modules/es6.string.fontsize":303,"../modules/es6.string.from-code-point":304,"../modules/es6.string.includes":305,"../modules/es6.string.italics":306,"../modules/es6.string.iterator":307,"../modules/es6.string.link":308,"../modules/es6.string.raw":309,"../modules/es6.string.repeat":310,"../modules/es6.string.small":311,"../modules/es6.string.starts-with":312,"../modules/es6.string.strike":313,"../modules/es6.string.sub":314,"../modules/es6.string.sup":315,"../modules/es6.string.trim":316,"../modules/es6.symbol":317,"../modules/es6.typed.array-buffer":318,"../modules/es6.typed.data-view":319,"../modules/es6.typed.float32-array":320,"../modules/es6.typed.float64-array":321,"../modules/es6.typed.int16-array":322,"../modules/es6.typed.int32-array":323,"../modules/es6.typed.int8-array":324,"../modules/es6.typed.uint16-array":325,"../modules/es6.typed.uint32-array":326,"../modules/es6.typed.uint8-array":327,"../modules/es6.typed.uint8-clamped-array":328,"../modules/es6.weak-map":329,"../modules/es6.weak-set":330}],43:[function(require,module,exports){ +},{"../modules/_core":85,"../modules/es6.array.copy-within":187,"../modules/es6.array.every":188,"../modules/es6.array.fill":189,"../modules/es6.array.filter":190,"../modules/es6.array.find":192,"../modules/es6.array.find-index":191,"../modules/es6.array.for-each":193,"../modules/es6.array.from":194,"../modules/es6.array.index-of":195,"../modules/es6.array.is-array":196,"../modules/es6.array.iterator":197,"../modules/es6.array.join":198,"../modules/es6.array.last-index-of":199,"../modules/es6.array.map":200,"../modules/es6.array.of":201,"../modules/es6.array.reduce":203,"../modules/es6.array.reduce-right":202,"../modules/es6.array.slice":204,"../modules/es6.array.some":205,"../modules/es6.array.sort":206,"../modules/es6.array.species":207,"../modules/es6.date.now":208,"../modules/es6.date.to-iso-string":209,"../modules/es6.date.to-json":210,"../modules/es6.date.to-primitive":211,"../modules/es6.date.to-string":212,"../modules/es6.function.bind":213,"../modules/es6.function.has-instance":214,"../modules/es6.function.name":215,"../modules/es6.map":216,"../modules/es6.math.acosh":217,"../modules/es6.math.asinh":218,"../modules/es6.math.atanh":219,"../modules/es6.math.cbrt":220,"../modules/es6.math.clz32":221,"../modules/es6.math.cosh":222,"../modules/es6.math.expm1":223,"../modules/es6.math.fround":224,"../modules/es6.math.hypot":225,"../modules/es6.math.imul":226,"../modules/es6.math.log10":227,"../modules/es6.math.log1p":228,"../modules/es6.math.log2":229,"../modules/es6.math.sign":230,"../modules/es6.math.sinh":231,"../modules/es6.math.tanh":232,"../modules/es6.math.trunc":233,"../modules/es6.number.constructor":234,"../modules/es6.number.epsilon":235,"../modules/es6.number.is-finite":236,"../modules/es6.number.is-integer":237,"../modules/es6.number.is-nan":238,"../modules/es6.number.is-safe-integer":239,"../modules/es6.number.max-safe-integer":240,"../modules/es6.number.min-safe-integer":241,"../modules/es6.number.parse-float":242,"../modules/es6.number.parse-int":243,"../modules/es6.number.to-fixed":244,"../modules/es6.number.to-precision":245,"../modules/es6.object.assign":246,"../modules/es6.object.create":247,"../modules/es6.object.define-properties":248,"../modules/es6.object.define-property":249,"../modules/es6.object.freeze":250,"../modules/es6.object.get-own-property-descriptor":251,"../modules/es6.object.get-own-property-names":252,"../modules/es6.object.get-prototype-of":253,"../modules/es6.object.is":257,"../modules/es6.object.is-extensible":254,"../modules/es6.object.is-frozen":255,"../modules/es6.object.is-sealed":256,"../modules/es6.object.keys":258,"../modules/es6.object.prevent-extensions":259,"../modules/es6.object.seal":260,"../modules/es6.object.set-prototype-of":261,"../modules/es6.object.to-string":262,"../modules/es6.parse-float":263,"../modules/es6.parse-int":264,"../modules/es6.promise":265,"../modules/es6.reflect.apply":266,"../modules/es6.reflect.construct":267,"../modules/es6.reflect.define-property":268,"../modules/es6.reflect.delete-property":269,"../modules/es6.reflect.enumerate":270,"../modules/es6.reflect.get":273,"../modules/es6.reflect.get-own-property-descriptor":271,"../modules/es6.reflect.get-prototype-of":272,"../modules/es6.reflect.has":274,"../modules/es6.reflect.is-extensible":275,"../modules/es6.reflect.own-keys":276,"../modules/es6.reflect.prevent-extensions":277,"../modules/es6.reflect.set":279,"../modules/es6.reflect.set-prototype-of":278,"../modules/es6.regexp.constructor":280,"../modules/es6.regexp.exec":281,"../modules/es6.regexp.flags":282,"../modules/es6.regexp.match":283,"../modules/es6.regexp.replace":284,"../modules/es6.regexp.search":285,"../modules/es6.regexp.split":286,"../modules/es6.regexp.to-string":287,"../modules/es6.set":288,"../modules/es6.string.anchor":289,"../modules/es6.string.big":290,"../modules/es6.string.blink":291,"../modules/es6.string.bold":292,"../modules/es6.string.code-point-at":293,"../modules/es6.string.ends-with":294,"../modules/es6.string.fixed":295,"../modules/es6.string.fontcolor":296,"../modules/es6.string.fontsize":297,"../modules/es6.string.from-code-point":298,"../modules/es6.string.includes":299,"../modules/es6.string.italics":300,"../modules/es6.string.iterator":301,"../modules/es6.string.link":302,"../modules/es6.string.raw":303,"../modules/es6.string.repeat":304,"../modules/es6.string.small":305,"../modules/es6.string.starts-with":306,"../modules/es6.string.strike":307,"../modules/es6.string.sub":308,"../modules/es6.string.sup":309,"../modules/es6.string.trim":310,"../modules/es6.symbol":311,"../modules/es6.typed.array-buffer":312,"../modules/es6.typed.data-view":313,"../modules/es6.typed.float32-array":314,"../modules/es6.typed.float64-array":315,"../modules/es6.typed.int16-array":316,"../modules/es6.typed.int32-array":317,"../modules/es6.typed.int8-array":318,"../modules/es6.typed.uint16-array":319,"../modules/es6.typed.uint32-array":320,"../modules/es6.typed.uint8-array":321,"../modules/es6.typed.uint8-clamped-array":322,"../modules/es6.weak-map":323,"../modules/es6.weak-set":324}],37:[function(require,module,exports){ require('../../modules/es7.array.flat-map'); module.exports = require('../../modules/_core').Array.flatMap; -},{"../../modules/_core":91,"../../modules/es7.array.flat-map":331}],44:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.array.flat-map":325}],38:[function(require,module,exports){ require('../../modules/es7.array.includes'); module.exports = require('../../modules/_core').Array.includes; -},{"../../modules/_core":91,"../../modules/es7.array.includes":332}],45:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.array.includes":326}],39:[function(require,module,exports){ require('../../modules/es7.object.entries'); module.exports = require('../../modules/_core').Object.entries; -},{"../../modules/_core":91,"../../modules/es7.object.entries":333}],46:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.entries":327}],40:[function(require,module,exports){ require('../../modules/es7.object.get-own-property-descriptors'); module.exports = require('../../modules/_core').Object.getOwnPropertyDescriptors; -},{"../../modules/_core":91,"../../modules/es7.object.get-own-property-descriptors":334}],47:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.get-own-property-descriptors":328}],41:[function(require,module,exports){ require('../../modules/es7.object.values'); module.exports = require('../../modules/_core').Object.values; -},{"../../modules/_core":91,"../../modules/es7.object.values":335}],48:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.values":329}],42:[function(require,module,exports){ 'use strict'; require('../../modules/es6.promise'); require('../../modules/es7.promise.finally'); module.exports = require('../../modules/_core').Promise['finally']; -},{"../../modules/_core":91,"../../modules/es6.promise":271,"../../modules/es7.promise.finally":336}],49:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es6.promise":265,"../../modules/es7.promise.finally":330}],43:[function(require,module,exports){ require('../../modules/es7.string.pad-end'); module.exports = require('../../modules/_core').String.padEnd; -},{"../../modules/_core":91,"../../modules/es7.string.pad-end":337}],50:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.pad-end":331}],44:[function(require,module,exports){ require('../../modules/es7.string.pad-start'); module.exports = require('../../modules/_core').String.padStart; -},{"../../modules/_core":91,"../../modules/es7.string.pad-start":338}],51:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.pad-start":332}],45:[function(require,module,exports){ require('../../modules/es7.string.trim-right'); module.exports = require('../../modules/_core').String.trimRight; -},{"../../modules/_core":91,"../../modules/es7.string.trim-right":340}],52:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.trim-right":334}],46:[function(require,module,exports){ require('../../modules/es7.string.trim-left'); module.exports = require('../../modules/_core').String.trimLeft; -},{"../../modules/_core":91,"../../modules/es7.string.trim-left":339}],53:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.trim-left":333}],47:[function(require,module,exports){ require('../../modules/es7.symbol.async-iterator'); module.exports = require('../../modules/_wks-ext').f('asyncIterator'); -},{"../../modules/_wks-ext":190,"../../modules/es7.symbol.async-iterator":341}],54:[function(require,module,exports){ +},{"../../modules/_wks-ext":184,"../../modules/es7.symbol.async-iterator":335}],48:[function(require,module,exports){ require('../modules/es7.global'); module.exports = require('../modules/_core').global; -},{"../modules/_core":57,"../modules/es7.global":71}],55:[function(require,module,exports){ +},{"../modules/_core":51,"../modules/es7.global":65}],49:[function(require,module,exports){ module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; -},{}],56:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; -},{"./_is-object":67}],57:[function(require,module,exports){ +},{"./_is-object":61}],51:[function(require,module,exports){ var core = module.exports = { version: '2.6.12' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -},{}],58:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ // optional / simple context binding var aFunction = require('./_a-function'); module.exports = function (fn, that, length) { @@ -5292,13 +5197,13 @@ module.exports = function (fn, that, length) { }; }; -},{"./_a-function":55}],59:[function(require,module,exports){ +},{"./_a-function":49}],53:[function(require,module,exports){ // Thank's IE8 for his funny defineProperty module.exports = !require('./_fails')(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_fails":62}],60:[function(require,module,exports){ +},{"./_fails":56}],54:[function(require,module,exports){ var isObject = require('./_is-object'); var document = require('./_global').document; // typeof document.createElement is 'object' in old IE @@ -5307,7 +5212,7 @@ module.exports = function (it) { return is ? document.createElement(it) : {}; }; -},{"./_global":63,"./_is-object":67}],61:[function(require,module,exports){ +},{"./_global":57,"./_is-object":61}],55:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var ctx = require('./_ctx'); @@ -5371,7 +5276,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":57,"./_ctx":58,"./_global":63,"./_has":64,"./_hide":65}],62:[function(require,module,exports){ +},{"./_core":51,"./_ctx":52,"./_global":57,"./_has":58,"./_hide":59}],56:[function(require,module,exports){ module.exports = function (exec) { try { return !!exec(); @@ -5380,7 +5285,7 @@ module.exports = function (exec) { } }; -},{}],63:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self @@ -5388,13 +5293,13 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -},{}],64:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; -},{}],65:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ var dP = require('./_object-dp'); var createDesc = require('./_property-desc'); module.exports = require('./_descriptors') ? function (object, key, value) { @@ -5404,17 +5309,17 @@ module.exports = require('./_descriptors') ? function (object, key, value) { return object; }; -},{"./_descriptors":59,"./_object-dp":68,"./_property-desc":69}],66:[function(require,module,exports){ +},{"./_descriptors":53,"./_object-dp":62,"./_property-desc":63}],60:[function(require,module,exports){ module.exports = !require('./_descriptors') && !require('./_fails')(function () { return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_descriptors":59,"./_dom-create":60,"./_fails":62}],67:[function(require,module,exports){ +},{"./_descriptors":53,"./_dom-create":54,"./_fails":56}],61:[function(require,module,exports){ module.exports = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -},{}],68:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ var anObject = require('./_an-object'); var IE8_DOM_DEFINE = require('./_ie8-dom-define'); var toPrimitive = require('./_to-primitive'); @@ -5432,7 +5337,7 @@ exports.f = require('./_descriptors') ? Object.defineProperty : function defineP return O; }; -},{"./_an-object":56,"./_descriptors":59,"./_ie8-dom-define":66,"./_to-primitive":70}],69:[function(require,module,exports){ +},{"./_an-object":50,"./_descriptors":53,"./_ie8-dom-define":60,"./_to-primitive":64}],63:[function(require,module,exports){ module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -5442,7 +5347,7 @@ module.exports = function (bitmap, value) { }; }; -},{}],70:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = require('./_is-object'); // instead of the ES6 spec version, we didn't implement @@toPrimitive case @@ -5456,22 +5361,22 @@ module.exports = function (it, S) { throw TypeError("Can't convert object to primitive value"); }; -},{"./_is-object":67}],71:[function(require,module,exports){ +},{"./_is-object":61}],65:[function(require,module,exports){ // https://github.com/tc39/proposal-global var $export = require('./_export'); $export($export.G, { global: require('./_global') }); -},{"./_export":61,"./_global":63}],72:[function(require,module,exports){ -arguments[4][55][0].apply(exports,arguments) -},{"dup":55}],73:[function(require,module,exports){ +},{"./_export":55,"./_global":57}],66:[function(require,module,exports){ +arguments[4][49][0].apply(exports,arguments) +},{"dup":49}],67:[function(require,module,exports){ var cof = require('./_cof'); module.exports = function (it, msg) { if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg); return +it; }; -},{"./_cof":87}],74:[function(require,module,exports){ +},{"./_cof":81}],68:[function(require,module,exports){ // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = require('./_wks')('unscopables'); var ArrayProto = Array.prototype; @@ -5480,7 +5385,7 @@ module.exports = function (key) { ArrayProto[UNSCOPABLES][key] = true; }; -},{"./_hide":111,"./_wks":191}],75:[function(require,module,exports){ +},{"./_hide":105,"./_wks":185}],69:[function(require,module,exports){ 'use strict'; var at = require('./_string-at')(true); @@ -5490,16 +5395,16 @@ module.exports = function (S, index, unicode) { return index + (unicode ? at(S, index).length : 1); }; -},{"./_string-at":168}],76:[function(require,module,exports){ +},{"./_string-at":162}],70:[function(require,module,exports){ module.exports = function (it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { throw TypeError(name + ': incorrect invocation!'); } return it; }; -},{}],77:[function(require,module,exports){ -arguments[4][56][0].apply(exports,arguments) -},{"./_is-object":120,"dup":56}],78:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ +arguments[4][50][0].apply(exports,arguments) +},{"./_is-object":114,"dup":50}],72:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -5527,7 +5432,7 @@ module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* } return O; }; -},{"./_to-absolute-index":176,"./_to-length":180,"./_to-object":181}],79:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-length":174,"./_to-object":175}],73:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -5544,7 +5449,7 @@ module.exports = function fill(value /* , start = 0, end = @length */) { return O; }; -},{"./_to-absolute-index":176,"./_to-length":180,"./_to-object":181}],80:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-length":174,"./_to-object":175}],74:[function(require,module,exports){ // false -> Array#indexOf // true -> Array#includes var toIObject = require('./_to-iobject'); @@ -5569,7 +5474,7 @@ module.exports = function (IS_INCLUDES) { }; }; -},{"./_to-absolute-index":176,"./_to-iobject":179,"./_to-length":180}],81:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-iobject":173,"./_to-length":174}],75:[function(require,module,exports){ // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter @@ -5615,7 +5520,7 @@ module.exports = function (TYPE, $create) { }; }; -},{"./_array-species-create":84,"./_ctx":93,"./_iobject":116,"./_to-length":180,"./_to-object":181}],82:[function(require,module,exports){ +},{"./_array-species-create":78,"./_ctx":87,"./_iobject":110,"./_to-length":174,"./_to-object":175}],76:[function(require,module,exports){ var aFunction = require('./_a-function'); var toObject = require('./_to-object'); var IObject = require('./_iobject'); @@ -5645,7 +5550,7 @@ module.exports = function (that, callbackfn, aLen, memo, isRight) { return memo; }; -},{"./_a-function":72,"./_iobject":116,"./_to-length":180,"./_to-object":181}],83:[function(require,module,exports){ +},{"./_a-function":66,"./_iobject":110,"./_to-length":174,"./_to-object":175}],77:[function(require,module,exports){ var isObject = require('./_is-object'); var isArray = require('./_is-array'); var SPECIES = require('./_wks')('species'); @@ -5663,7 +5568,7 @@ module.exports = function (original) { } return C === undefined ? Array : C; }; -},{"./_is-array":118,"./_is-object":120,"./_wks":191}],84:[function(require,module,exports){ +},{"./_is-array":112,"./_is-object":114,"./_wks":185}],78:[function(require,module,exports){ // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var speciesConstructor = require('./_array-species-constructor'); @@ -5671,7 +5576,7 @@ module.exports = function (original, length) { return new (speciesConstructor(original))(length); }; -},{"./_array-species-constructor":83}],85:[function(require,module,exports){ +},{"./_array-species-constructor":77}],79:[function(require,module,exports){ 'use strict'; var aFunction = require('./_a-function'); var isObject = require('./_is-object'); @@ -5698,7 +5603,7 @@ module.exports = Function.bind || function bind(that /* , ...args */) { return bound; }; -},{"./_a-function":72,"./_invoke":115,"./_is-object":120}],86:[function(require,module,exports){ +},{"./_a-function":66,"./_invoke":109,"./_is-object":114}],80:[function(require,module,exports){ // getting tag from 19.1.3.6 Object.prototype.toString() var cof = require('./_cof'); var TAG = require('./_wks')('toStringTag'); @@ -5723,14 +5628,14 @@ module.exports = function (it) { : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; -},{"./_cof":87,"./_wks":191}],87:[function(require,module,exports){ +},{"./_cof":81,"./_wks":185}],81:[function(require,module,exports){ var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; -},{}],88:[function(require,module,exports){ +},{}],82:[function(require,module,exports){ 'use strict'; var dP = require('./_object-dp').f; var create = require('./_object-create'); @@ -5876,7 +5781,7 @@ module.exports = { } }; -},{"./_an-instance":76,"./_ctx":93,"./_descriptors":97,"./_for-of":107,"./_iter-define":124,"./_iter-step":126,"./_meta":133,"./_object-create":137,"./_object-dp":138,"./_redefine-all":156,"./_set-species":162,"./_validate-collection":188}],89:[function(require,module,exports){ +},{"./_an-instance":70,"./_ctx":87,"./_descriptors":91,"./_for-of":101,"./_iter-define":118,"./_iter-step":120,"./_meta":127,"./_object-create":131,"./_object-dp":132,"./_redefine-all":150,"./_set-species":156,"./_validate-collection":182}],83:[function(require,module,exports){ 'use strict'; var redefineAll = require('./_redefine-all'); var getWeak = require('./_meta').getWeak; @@ -5963,7 +5868,7 @@ module.exports = { ufstore: uncaughtFrozenStore }; -},{"./_an-instance":76,"./_an-object":77,"./_array-methods":81,"./_for-of":107,"./_has":110,"./_is-object":120,"./_meta":133,"./_redefine-all":156,"./_validate-collection":188}],90:[function(require,module,exports){ +},{"./_an-instance":70,"./_an-object":71,"./_array-methods":75,"./_for-of":101,"./_has":104,"./_is-object":114,"./_meta":127,"./_redefine-all":150,"./_validate-collection":182}],84:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var $export = require('./_export'); @@ -6050,9 +5955,9 @@ module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { return C; }; -},{"./_an-instance":76,"./_export":101,"./_fails":103,"./_for-of":107,"./_global":109,"./_inherit-if-required":114,"./_is-object":120,"./_iter-detect":125,"./_meta":133,"./_redefine":157,"./_redefine-all":156,"./_set-to-string-tag":163}],91:[function(require,module,exports){ -arguments[4][57][0].apply(exports,arguments) -},{"dup":57}],92:[function(require,module,exports){ +},{"./_an-instance":70,"./_export":95,"./_fails":97,"./_for-of":101,"./_global":103,"./_inherit-if-required":108,"./_is-object":114,"./_iter-detect":119,"./_meta":127,"./_redefine":151,"./_redefine-all":150,"./_set-to-string-tag":157}],85:[function(require,module,exports){ +arguments[4][51][0].apply(exports,arguments) +},{"dup":51}],86:[function(require,module,exports){ 'use strict'; var $defineProperty = require('./_object-dp'); var createDesc = require('./_property-desc'); @@ -6062,9 +5967,9 @@ module.exports = function (object, index, value) { else object[index] = value; }; -},{"./_object-dp":138,"./_property-desc":155}],93:[function(require,module,exports){ -arguments[4][58][0].apply(exports,arguments) -},{"./_a-function":72,"dup":58}],94:[function(require,module,exports){ +},{"./_object-dp":132,"./_property-desc":149}],87:[function(require,module,exports){ +arguments[4][52][0].apply(exports,arguments) +},{"./_a-function":66,"dup":52}],88:[function(require,module,exports){ 'use strict'; // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var fails = require('./_fails'); @@ -6092,7 +5997,7 @@ module.exports = (fails(function () { ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; } : $toISOString; -},{"./_fails":103}],95:[function(require,module,exports){ +},{"./_fails":97}],89:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); var toPrimitive = require('./_to-primitive'); @@ -6103,24 +6008,24 @@ module.exports = function (hint) { return toPrimitive(anObject(this), hint != NUMBER); }; -},{"./_an-object":77,"./_to-primitive":182}],96:[function(require,module,exports){ +},{"./_an-object":71,"./_to-primitive":176}],90:[function(require,module,exports){ // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; -},{}],97:[function(require,module,exports){ -arguments[4][59][0].apply(exports,arguments) -},{"./_fails":103,"dup":59}],98:[function(require,module,exports){ -arguments[4][60][0].apply(exports,arguments) -},{"./_global":109,"./_is-object":120,"dup":60}],99:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ +arguments[4][53][0].apply(exports,arguments) +},{"./_fails":97,"dup":53}],92:[function(require,module,exports){ +arguments[4][54][0].apply(exports,arguments) +},{"./_global":103,"./_is-object":114,"dup":54}],93:[function(require,module,exports){ // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); -},{}],100:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ // all enumerable object keys, includes symbols var getKeys = require('./_object-keys'); var gOPS = require('./_object-gops'); @@ -6137,7 +6042,7 @@ module.exports = function (it) { } return result; }; -},{"./_object-gops":143,"./_object-keys":146,"./_object-pie":147}],101:[function(require,module,exports){ +},{"./_object-gops":137,"./_object-keys":140,"./_object-pie":141}],95:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var hide = require('./_hide'); @@ -6182,7 +6087,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":91,"./_ctx":93,"./_global":109,"./_hide":111,"./_redefine":157}],102:[function(require,module,exports){ +},{"./_core":85,"./_ctx":87,"./_global":103,"./_hide":105,"./_redefine":151}],96:[function(require,module,exports){ var MATCH = require('./_wks')('match'); module.exports = function (KEY) { var re = /./; @@ -6196,9 +6101,9 @@ module.exports = function (KEY) { } return true; }; -},{"./_wks":191}],103:[function(require,module,exports){ -arguments[4][62][0].apply(exports,arguments) -},{"dup":62}],104:[function(require,module,exports){ +},{"./_wks":185}],97:[function(require,module,exports){ +arguments[4][56][0].apply(exports,arguments) +},{"dup":56}],98:[function(require,module,exports){ 'use strict'; require('./es6.regexp.exec'); var redefine = require('./_redefine'); @@ -6296,7 +6201,7 @@ module.exports = function (KEY, length, exec) { } }; -},{"./_defined":96,"./_fails":103,"./_hide":111,"./_redefine":157,"./_regexp-exec":159,"./_wks":191,"./es6.regexp.exec":287}],105:[function(require,module,exports){ +},{"./_defined":90,"./_fails":97,"./_hide":105,"./_redefine":151,"./_regexp-exec":153,"./_wks":185,"./es6.regexp.exec":281}],99:[function(require,module,exports){ 'use strict'; // 21.2.5.3 get RegExp.prototype.flags var anObject = require('./_an-object'); @@ -6311,7 +6216,7 @@ module.exports = function () { return result; }; -},{"./_an-object":77}],106:[function(require,module,exports){ +},{"./_an-object":71}],100:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray var isArray = require('./_is-array'); @@ -6352,7 +6257,7 @@ function flattenIntoArray(target, original, source, sourceLen, start, depth, map module.exports = flattenIntoArray; -},{"./_ctx":93,"./_is-array":118,"./_is-object":120,"./_to-length":180,"./_wks":191}],107:[function(require,module,exports){ +},{"./_ctx":87,"./_is-array":112,"./_is-object":114,"./_to-length":174,"./_wks":185}],101:[function(require,module,exports){ var ctx = require('./_ctx'); var call = require('./_iter-call'); var isArrayIter = require('./_is-array-iter'); @@ -6379,22 +6284,22 @@ var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) exports.BREAK = BREAK; exports.RETURN = RETURN; -},{"./_an-object":77,"./_ctx":93,"./_is-array-iter":117,"./_iter-call":122,"./_to-length":180,"./core.get-iterator-method":192}],108:[function(require,module,exports){ +},{"./_an-object":71,"./_ctx":87,"./_is-array-iter":111,"./_iter-call":116,"./_to-length":174,"./core.get-iterator-method":186}],102:[function(require,module,exports){ module.exports = require('./_shared')('native-function-to-string', Function.toString); -},{"./_shared":165}],109:[function(require,module,exports){ -arguments[4][63][0].apply(exports,arguments) -},{"dup":63}],110:[function(require,module,exports){ -arguments[4][64][0].apply(exports,arguments) -},{"dup":64}],111:[function(require,module,exports){ -arguments[4][65][0].apply(exports,arguments) -},{"./_descriptors":97,"./_object-dp":138,"./_property-desc":155,"dup":65}],112:[function(require,module,exports){ +},{"./_shared":159}],103:[function(require,module,exports){ +arguments[4][57][0].apply(exports,arguments) +},{"dup":57}],104:[function(require,module,exports){ +arguments[4][58][0].apply(exports,arguments) +},{"dup":58}],105:[function(require,module,exports){ +arguments[4][59][0].apply(exports,arguments) +},{"./_descriptors":91,"./_object-dp":132,"./_property-desc":149,"dup":59}],106:[function(require,module,exports){ var document = require('./_global').document; module.exports = document && document.documentElement; -},{"./_global":109}],113:[function(require,module,exports){ -arguments[4][66][0].apply(exports,arguments) -},{"./_descriptors":97,"./_dom-create":98,"./_fails":103,"dup":66}],114:[function(require,module,exports){ +},{"./_global":103}],107:[function(require,module,exports){ +arguments[4][60][0].apply(exports,arguments) +},{"./_descriptors":91,"./_dom-create":92,"./_fails":97,"dup":60}],108:[function(require,module,exports){ var isObject = require('./_is-object'); var setPrototypeOf = require('./_set-proto').set; module.exports = function (that, target, C) { @@ -6405,7 +6310,7 @@ module.exports = function (that, target, C) { } return that; }; -},{"./_is-object":120,"./_set-proto":161}],115:[function(require,module,exports){ +},{"./_is-object":114,"./_set-proto":155}],109:[function(require,module,exports){ // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function (fn, args, that) { var un = that === undefined; @@ -6423,7 +6328,7 @@ module.exports = function (fn, args, that) { } return fn.apply(that, args); }; -},{}],116:[function(require,module,exports){ +},{}],110:[function(require,module,exports){ // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = require('./_cof'); // eslint-disable-next-line no-prototype-builtins @@ -6431,7 +6336,7 @@ module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; -},{"./_cof":87}],117:[function(require,module,exports){ +},{"./_cof":81}],111:[function(require,module,exports){ // check on default Array iterator var Iterators = require('./_iterators'); var ITERATOR = require('./_wks')('iterator'); @@ -6441,14 +6346,14 @@ module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; -},{"./_iterators":127,"./_wks":191}],118:[function(require,module,exports){ +},{"./_iterators":121,"./_wks":185}],112:[function(require,module,exports){ // 7.2.2 IsArray(argument) var cof = require('./_cof'); module.exports = Array.isArray || function isArray(arg) { return cof(arg) == 'Array'; }; -},{"./_cof":87}],119:[function(require,module,exports){ +},{"./_cof":81}],113:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var isObject = require('./_is-object'); var floor = Math.floor; @@ -6456,9 +6361,9 @@ module.exports = function isInteger(it) { return !isObject(it) && isFinite(it) && floor(it) === it; }; -},{"./_is-object":120}],120:[function(require,module,exports){ -arguments[4][67][0].apply(exports,arguments) -},{"dup":67}],121:[function(require,module,exports){ +},{"./_is-object":114}],114:[function(require,module,exports){ +arguments[4][61][0].apply(exports,arguments) +},{"dup":61}],115:[function(require,module,exports){ // 7.2.8 IsRegExp(argument) var isObject = require('./_is-object'); var cof = require('./_cof'); @@ -6468,7 +6373,7 @@ module.exports = function (it) { return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); }; -},{"./_cof":87,"./_is-object":120,"./_wks":191}],122:[function(require,module,exports){ +},{"./_cof":81,"./_is-object":114,"./_wks":185}],116:[function(require,module,exports){ // call something on iterator step with safe closing on error var anObject = require('./_an-object'); module.exports = function (iterator, fn, value, entries) { @@ -6482,7 +6387,7 @@ module.exports = function (iterator, fn, value, entries) { } }; -},{"./_an-object":77}],123:[function(require,module,exports){ +},{"./_an-object":71}],117:[function(require,module,exports){ 'use strict'; var create = require('./_object-create'); var descriptor = require('./_property-desc'); @@ -6497,7 +6402,7 @@ module.exports = function (Constructor, NAME, next) { setToStringTag(Constructor, NAME + ' Iterator'); }; -},{"./_hide":111,"./_object-create":137,"./_property-desc":155,"./_set-to-string-tag":163,"./_wks":191}],124:[function(require,module,exports){ +},{"./_hide":105,"./_object-create":131,"./_property-desc":149,"./_set-to-string-tag":157,"./_wks":185}],118:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var $export = require('./_export'); @@ -6568,7 +6473,7 @@ module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE return methods; }; -},{"./_export":101,"./_hide":111,"./_iter-create":123,"./_iterators":127,"./_library":128,"./_object-gpo":144,"./_redefine":157,"./_set-to-string-tag":163,"./_wks":191}],125:[function(require,module,exports){ +},{"./_export":95,"./_hide":105,"./_iter-create":117,"./_iterators":121,"./_library":122,"./_object-gpo":138,"./_redefine":151,"./_set-to-string-tag":157,"./_wks":185}],119:[function(require,module,exports){ var ITERATOR = require('./_wks')('iterator'); var SAFE_CLOSING = false; @@ -6592,18 +6497,18 @@ module.exports = function (exec, skipClosing) { return safe; }; -},{"./_wks":191}],126:[function(require,module,exports){ +},{"./_wks":185}],120:[function(require,module,exports){ module.exports = function (done, value) { return { value: value, done: !!done }; }; -},{}],127:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ module.exports = {}; -},{}],128:[function(require,module,exports){ +},{}],122:[function(require,module,exports){ module.exports = false; -},{}],129:[function(require,module,exports){ +},{}],123:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $expm1 = Math.expm1; module.exports = (!$expm1 @@ -6615,7 +6520,7 @@ module.exports = (!$expm1 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; } : $expm1; -},{}],130:[function(require,module,exports){ +},{}],124:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var sign = require('./_math-sign'); var pow = Math.pow; @@ -6640,20 +6545,20 @@ module.exports = Math.fround || function fround(x) { return $sign * result; }; -},{"./_math-sign":132}],131:[function(require,module,exports){ +},{"./_math-sign":126}],125:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) module.exports = Math.log1p || function log1p(x) { return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); }; -},{}],132:[function(require,module,exports){ +},{}],126:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) module.exports = Math.sign || function sign(x) { // eslint-disable-next-line no-self-compare return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; }; -},{}],133:[function(require,module,exports){ +},{}],127:[function(require,module,exports){ var META = require('./_uid')('meta'); var isObject = require('./_is-object'); var has = require('./_has'); @@ -6708,7 +6613,7 @@ var meta = module.exports = { onFreeze: onFreeze }; -},{"./_fails":103,"./_has":110,"./_is-object":120,"./_object-dp":138,"./_uid":186}],134:[function(require,module,exports){ +},{"./_fails":97,"./_has":104,"./_is-object":114,"./_object-dp":132,"./_uid":180}],128:[function(require,module,exports){ var global = require('./_global'); var macrotask = require('./_task').set; var Observer = global.MutationObserver || global.WebKitMutationObserver; @@ -6779,7 +6684,7 @@ module.exports = function () { }; }; -},{"./_cof":87,"./_global":109,"./_task":175}],135:[function(require,module,exports){ +},{"./_cof":81,"./_global":103,"./_task":169}],129:[function(require,module,exports){ 'use strict'; // 25.4.1.5 NewPromiseCapability(C) var aFunction = require('./_a-function'); @@ -6799,7 +6704,7 @@ module.exports.f = function (C) { return new PromiseCapability(C); }; -},{"./_a-function":72}],136:[function(require,module,exports){ +},{"./_a-function":66}],130:[function(require,module,exports){ 'use strict'; // 19.1.2.1 Object.assign(target, source, ...) var DESCRIPTORS = require('./_descriptors'); @@ -6839,7 +6744,7 @@ module.exports = !$assign || require('./_fails')(function () { } return T; } : $assign; -},{"./_descriptors":97,"./_fails":103,"./_iobject":116,"./_object-gops":143,"./_object-keys":146,"./_object-pie":147,"./_to-object":181}],137:[function(require,module,exports){ +},{"./_descriptors":91,"./_fails":97,"./_iobject":110,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_to-object":175}],131:[function(require,module,exports){ // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = require('./_an-object'); var dPs = require('./_object-dps'); @@ -6882,9 +6787,9 @@ module.exports = Object.create || function create(O, Properties) { return Properties === undefined ? result : dPs(result, Properties); }; -},{"./_an-object":77,"./_dom-create":98,"./_enum-bug-keys":99,"./_html":112,"./_object-dps":139,"./_shared-key":164}],138:[function(require,module,exports){ -arguments[4][68][0].apply(exports,arguments) -},{"./_an-object":77,"./_descriptors":97,"./_ie8-dom-define":113,"./_to-primitive":182,"dup":68}],139:[function(require,module,exports){ +},{"./_an-object":71,"./_dom-create":92,"./_enum-bug-keys":93,"./_html":106,"./_object-dps":133,"./_shared-key":158}],132:[function(require,module,exports){ +arguments[4][62][0].apply(exports,arguments) +},{"./_an-object":71,"./_descriptors":91,"./_ie8-dom-define":107,"./_to-primitive":176,"dup":62}],133:[function(require,module,exports){ var dP = require('./_object-dp'); var anObject = require('./_an-object'); var getKeys = require('./_object-keys'); @@ -6899,7 +6804,7 @@ module.exports = require('./_descriptors') ? Object.defineProperties : function return O; }; -},{"./_an-object":77,"./_descriptors":97,"./_object-dp":138,"./_object-keys":146}],140:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_object-dp":132,"./_object-keys":140}],134:[function(require,module,exports){ var pIE = require('./_object-pie'); var createDesc = require('./_property-desc'); var toIObject = require('./_to-iobject'); @@ -6917,7 +6822,7 @@ exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); }; -},{"./_descriptors":97,"./_has":110,"./_ie8-dom-define":113,"./_object-pie":147,"./_property-desc":155,"./_to-iobject":179,"./_to-primitive":182}],141:[function(require,module,exports){ +},{"./_descriptors":91,"./_has":104,"./_ie8-dom-define":107,"./_object-pie":141,"./_property-desc":149,"./_to-iobject":173,"./_to-primitive":176}],135:[function(require,module,exports){ // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window var toIObject = require('./_to-iobject'); var gOPN = require('./_object-gopn').f; @@ -6938,7 +6843,7 @@ module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); }; -},{"./_object-gopn":142,"./_to-iobject":179}],142:[function(require,module,exports){ +},{"./_object-gopn":136,"./_to-iobject":173}],136:[function(require,module,exports){ // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = require('./_object-keys-internal'); var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype'); @@ -6947,10 +6852,10 @@ exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return $keys(O, hiddenKeys); }; -},{"./_enum-bug-keys":99,"./_object-keys-internal":145}],143:[function(require,module,exports){ +},{"./_enum-bug-keys":93,"./_object-keys-internal":139}],137:[function(require,module,exports){ exports.f = Object.getOwnPropertySymbols; -},{}],144:[function(require,module,exports){ +},{}],138:[function(require,module,exports){ // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = require('./_has'); var toObject = require('./_to-object'); @@ -6965,7 +6870,7 @@ module.exports = Object.getPrototypeOf || function (O) { } return O instanceof Object ? ObjectProto : null; }; -},{"./_has":110,"./_shared-key":164,"./_to-object":181}],145:[function(require,module,exports){ +},{"./_has":104,"./_shared-key":158,"./_to-object":175}],139:[function(require,module,exports){ var has = require('./_has'); var toIObject = require('./_to-iobject'); var arrayIndexOf = require('./_array-includes')(false); @@ -6984,7 +6889,7 @@ module.exports = function (object, names) { return result; }; -},{"./_array-includes":80,"./_has":110,"./_shared-key":164,"./_to-iobject":179}],146:[function(require,module,exports){ +},{"./_array-includes":74,"./_has":104,"./_shared-key":158,"./_to-iobject":173}],140:[function(require,module,exports){ // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = require('./_object-keys-internal'); var enumBugKeys = require('./_enum-bug-keys'); @@ -6993,10 +6898,10 @@ module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; -},{"./_enum-bug-keys":99,"./_object-keys-internal":145}],147:[function(require,module,exports){ +},{"./_enum-bug-keys":93,"./_object-keys-internal":139}],141:[function(require,module,exports){ exports.f = {}.propertyIsEnumerable; -},{}],148:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ // most Object methods by ES6 should accept primitives var $export = require('./_export'); var core = require('./_core'); @@ -7008,7 +6913,7 @@ module.exports = function (KEY, exec) { $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); }; -},{"./_core":91,"./_export":101,"./_fails":103}],149:[function(require,module,exports){ +},{"./_core":85,"./_export":95,"./_fails":97}],143:[function(require,module,exports){ var DESCRIPTORS = require('./_descriptors'); var getKeys = require('./_object-keys'); var toIObject = require('./_to-iobject'); @@ -7031,7 +6936,7 @@ module.exports = function (isEntries) { }; }; -},{"./_descriptors":97,"./_object-keys":146,"./_object-pie":147,"./_to-iobject":179}],150:[function(require,module,exports){ +},{"./_descriptors":91,"./_object-keys":140,"./_object-pie":141,"./_to-iobject":173}],144:[function(require,module,exports){ // all object keys, includes non-enumerable and symbols var gOPN = require('./_object-gopn'); var gOPS = require('./_object-gops'); @@ -7043,7 +6948,7 @@ module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { return getSymbols ? keys.concat(getSymbols(it)) : keys; }; -},{"./_an-object":77,"./_global":109,"./_object-gopn":142,"./_object-gops":143}],151:[function(require,module,exports){ +},{"./_an-object":71,"./_global":103,"./_object-gopn":136,"./_object-gops":137}],145:[function(require,module,exports){ var $parseFloat = require('./_global').parseFloat; var $trim = require('./_string-trim').trim; @@ -7053,7 +6958,7 @@ module.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? return result === 0 && string.charAt(0) == '-' ? -0 : result; } : $parseFloat; -},{"./_global":109,"./_string-trim":173,"./_string-ws":174}],152:[function(require,module,exports){ +},{"./_global":103,"./_string-trim":167,"./_string-ws":168}],146:[function(require,module,exports){ var $parseInt = require('./_global').parseInt; var $trim = require('./_string-trim').trim; var ws = require('./_string-ws'); @@ -7064,7 +6969,7 @@ module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? f return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); } : $parseInt; -},{"./_global":109,"./_string-trim":173,"./_string-ws":174}],153:[function(require,module,exports){ +},{"./_global":103,"./_string-trim":167,"./_string-ws":168}],147:[function(require,module,exports){ module.exports = function (exec) { try { return { e: false, v: exec() }; @@ -7073,7 +6978,7 @@ module.exports = function (exec) { } }; -},{}],154:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ var anObject = require('./_an-object'); var isObject = require('./_is-object'); var newPromiseCapability = require('./_new-promise-capability'); @@ -7087,16 +6992,16 @@ module.exports = function (C, x) { return promiseCapability.promise; }; -},{"./_an-object":77,"./_is-object":120,"./_new-promise-capability":135}],155:[function(require,module,exports){ -arguments[4][69][0].apply(exports,arguments) -},{"dup":69}],156:[function(require,module,exports){ +},{"./_an-object":71,"./_is-object":114,"./_new-promise-capability":129}],149:[function(require,module,exports){ +arguments[4][63][0].apply(exports,arguments) +},{"dup":63}],150:[function(require,module,exports){ var redefine = require('./_redefine'); module.exports = function (target, src, safe) { for (var key in src) redefine(target, key, src[key], safe); return target; }; -},{"./_redefine":157}],157:[function(require,module,exports){ +},{"./_redefine":151}],151:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var has = require('./_has'); @@ -7129,7 +7034,7 @@ require('./_core').inspectSource = function (it) { return typeof this == 'function' && this[SRC] || $toString.call(this); }); -},{"./_core":91,"./_function-to-string":108,"./_global":109,"./_has":110,"./_hide":111,"./_uid":186}],158:[function(require,module,exports){ +},{"./_core":85,"./_function-to-string":102,"./_global":103,"./_has":104,"./_hide":105,"./_uid":180}],152:[function(require,module,exports){ 'use strict'; var classof = require('./_classof'); @@ -7152,7 +7057,7 @@ module.exports = function (R, S) { return builtinExec.call(R, S); }; -},{"./_classof":86}],159:[function(require,module,exports){ +},{"./_classof":80}],153:[function(require,module,exports){ 'use strict'; var regexpFlags = require('./_flags'); @@ -7212,14 +7117,14 @@ if (PATCH) { module.exports = patchedExec; -},{"./_flags":105}],160:[function(require,module,exports){ +},{"./_flags":99}],154:[function(require,module,exports){ // 7.2.9 SameValue(x, y) module.exports = Object.is || function is(x, y) { // eslint-disable-next-line no-self-compare return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; }; -},{}],161:[function(require,module,exports){ +},{}],155:[function(require,module,exports){ // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ var isObject = require('./_is-object'); @@ -7246,7 +7151,7 @@ module.exports = { check: check }; -},{"./_an-object":77,"./_ctx":93,"./_is-object":120,"./_object-gopd":140}],162:[function(require,module,exports){ +},{"./_an-object":71,"./_ctx":87,"./_is-object":114,"./_object-gopd":134}],156:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var dP = require('./_object-dp'); @@ -7261,7 +7166,7 @@ module.exports = function (KEY) { }); }; -},{"./_descriptors":97,"./_global":109,"./_object-dp":138,"./_wks":191}],163:[function(require,module,exports){ +},{"./_descriptors":91,"./_global":103,"./_object-dp":132,"./_wks":185}],157:[function(require,module,exports){ var def = require('./_object-dp').f; var has = require('./_has'); var TAG = require('./_wks')('toStringTag'); @@ -7270,14 +7175,14 @@ module.exports = function (it, tag, stat) { if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); }; -},{"./_has":110,"./_object-dp":138,"./_wks":191}],164:[function(require,module,exports){ +},{"./_has":104,"./_object-dp":132,"./_wks":185}],158:[function(require,module,exports){ var shared = require('./_shared')('keys'); var uid = require('./_uid'); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; -},{"./_shared":165,"./_uid":186}],165:[function(require,module,exports){ +},{"./_shared":159,"./_uid":180}],159:[function(require,module,exports){ var core = require('./_core'); var global = require('./_global'); var SHARED = '__core-js_shared__'; @@ -7291,7 +7196,7 @@ var store = global[SHARED] || (global[SHARED] = {}); copyright: '© 2020 Denis Pushkarev (zloirock.ru)' }); -},{"./_core":91,"./_global":109,"./_library":128}],166:[function(require,module,exports){ +},{"./_core":85,"./_global":103,"./_library":122}],160:[function(require,module,exports){ // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = require('./_an-object'); var aFunction = require('./_a-function'); @@ -7302,7 +7207,7 @@ module.exports = function (O, D) { return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; -},{"./_a-function":72,"./_an-object":77,"./_wks":191}],167:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_wks":185}],161:[function(require,module,exports){ 'use strict'; var fails = require('./_fails'); @@ -7313,7 +7218,7 @@ module.exports = function (method, arg) { }); }; -},{"./_fails":103}],168:[function(require,module,exports){ +},{"./_fails":97}],162:[function(require,module,exports){ var toInteger = require('./_to-integer'); var defined = require('./_defined'); // true -> String#at @@ -7332,7 +7237,7 @@ module.exports = function (TO_STRING) { }; }; -},{"./_defined":96,"./_to-integer":178}],169:[function(require,module,exports){ +},{"./_defined":90,"./_to-integer":172}],163:[function(require,module,exports){ // helper for String#{startsWith, endsWith, includes} var isRegExp = require('./_is-regexp'); var defined = require('./_defined'); @@ -7342,7 +7247,7 @@ module.exports = function (that, searchString, NAME) { return String(defined(that)); }; -},{"./_defined":96,"./_is-regexp":121}],170:[function(require,module,exports){ +},{"./_defined":90,"./_is-regexp":115}],164:[function(require,module,exports){ var $export = require('./_export'); var fails = require('./_fails'); var defined = require('./_defined'); @@ -7363,7 +7268,7 @@ module.exports = function (NAME, exec) { }), 'String', O); }; -},{"./_defined":96,"./_export":101,"./_fails":103}],171:[function(require,module,exports){ +},{"./_defined":90,"./_export":95,"./_fails":97}],165:[function(require,module,exports){ // https://github.com/tc39/proposal-string-pad-start-end var toLength = require('./_to-length'); var repeat = require('./_string-repeat'); @@ -7381,7 +7286,7 @@ module.exports = function (that, maxLength, fillString, left) { return left ? stringFiller + S : S + stringFiller; }; -},{"./_defined":96,"./_string-repeat":172,"./_to-length":180}],172:[function(require,module,exports){ +},{"./_defined":90,"./_string-repeat":166,"./_to-length":174}],166:[function(require,module,exports){ 'use strict'; var toInteger = require('./_to-integer'); var defined = require('./_defined'); @@ -7395,7 +7300,7 @@ module.exports = function repeat(count) { return res; }; -},{"./_defined":96,"./_to-integer":178}],173:[function(require,module,exports){ +},{"./_defined":90,"./_to-integer":172}],167:[function(require,module,exports){ var $export = require('./_export'); var defined = require('./_defined'); var fails = require('./_fails'); @@ -7427,11 +7332,11 @@ var trim = exporter.trim = function (string, TYPE) { module.exports = exporter; -},{"./_defined":96,"./_export":101,"./_fails":103,"./_string-ws":174}],174:[function(require,module,exports){ +},{"./_defined":90,"./_export":95,"./_fails":97,"./_string-ws":168}],168:[function(require,module,exports){ module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -},{}],175:[function(require,module,exports){ +},{}],169:[function(require,module,exports){ var ctx = require('./_ctx'); var invoke = require('./_invoke'); var html = require('./_html'); @@ -7517,7 +7422,7 @@ module.exports = { clear: clearTask }; -},{"./_cof":87,"./_ctx":93,"./_dom-create":98,"./_global":109,"./_html":112,"./_invoke":115}],176:[function(require,module,exports){ +},{"./_cof":81,"./_ctx":87,"./_dom-create":92,"./_global":103,"./_html":106,"./_invoke":109}],170:[function(require,module,exports){ var toInteger = require('./_to-integer'); var max = Math.max; var min = Math.min; @@ -7526,7 +7431,7 @@ module.exports = function (index, length) { return index < 0 ? max(index + length, 0) : min(index, length); }; -},{"./_to-integer":178}],177:[function(require,module,exports){ +},{"./_to-integer":172}],171:[function(require,module,exports){ // https://tc39.github.io/ecma262/#sec-toindex var toInteger = require('./_to-integer'); var toLength = require('./_to-length'); @@ -7538,7 +7443,7 @@ module.exports = function (it) { return length; }; -},{"./_to-integer":178,"./_to-length":180}],178:[function(require,module,exports){ +},{"./_to-integer":172,"./_to-length":174}],172:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; @@ -7546,7 +7451,7 @@ module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],179:[function(require,module,exports){ +},{}],173:[function(require,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = require('./_iobject'); var defined = require('./_defined'); @@ -7554,7 +7459,7 @@ module.exports = function (it) { return IObject(defined(it)); }; -},{"./_defined":96,"./_iobject":116}],180:[function(require,module,exports){ +},{"./_defined":90,"./_iobject":110}],174:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./_to-integer'); var min = Math.min; @@ -7562,16 +7467,16 @@ module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./_to-integer":178}],181:[function(require,module,exports){ +},{"./_to-integer":172}],175:[function(require,module,exports){ // 7.1.13 ToObject(argument) var defined = require('./_defined'); module.exports = function (it) { return Object(defined(it)); }; -},{"./_defined":96}],182:[function(require,module,exports){ -arguments[4][70][0].apply(exports,arguments) -},{"./_is-object":120,"dup":70}],183:[function(require,module,exports){ +},{"./_defined":90}],176:[function(require,module,exports){ +arguments[4][64][0].apply(exports,arguments) +},{"./_is-object":114,"dup":64}],177:[function(require,module,exports){ 'use strict'; if (require('./_descriptors')) { var LIBRARY = require('./_library'); @@ -8053,7 +7958,7 @@ if (require('./_descriptors')) { }; } else module.exports = function () { /* empty */ }; -},{"./_an-instance":76,"./_array-copy-within":78,"./_array-fill":79,"./_array-includes":80,"./_array-methods":81,"./_classof":86,"./_ctx":93,"./_descriptors":97,"./_export":101,"./_fails":103,"./_global":109,"./_has":110,"./_hide":111,"./_is-array-iter":117,"./_is-object":120,"./_iter-detect":125,"./_iterators":127,"./_library":128,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_object-gpo":144,"./_property-desc":155,"./_redefine-all":156,"./_set-species":162,"./_species-constructor":166,"./_to-absolute-index":176,"./_to-index":177,"./_to-integer":178,"./_to-length":180,"./_to-object":181,"./_to-primitive":182,"./_typed":185,"./_typed-buffer":184,"./_uid":186,"./_wks":191,"./core.get-iterator-method":192,"./es6.array.iterator":203}],184:[function(require,module,exports){ +},{"./_an-instance":70,"./_array-copy-within":72,"./_array-fill":73,"./_array-includes":74,"./_array-methods":75,"./_classof":80,"./_ctx":87,"./_descriptors":91,"./_export":95,"./_fails":97,"./_global":103,"./_has":104,"./_hide":105,"./_is-array-iter":111,"./_is-object":114,"./_iter-detect":119,"./_iterators":121,"./_library":122,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_object-gpo":138,"./_property-desc":149,"./_redefine-all":150,"./_set-species":156,"./_species-constructor":160,"./_to-absolute-index":170,"./_to-index":171,"./_to-integer":172,"./_to-length":174,"./_to-object":175,"./_to-primitive":176,"./_typed":179,"./_typed-buffer":178,"./_uid":180,"./_wks":185,"./core.get-iterator-method":186,"./es6.array.iterator":197}],178:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var DESCRIPTORS = require('./_descriptors'); @@ -8331,7 +8236,7 @@ hide($DataView[PROTOTYPE], $typed.VIEW, true); exports[ARRAY_BUFFER] = $ArrayBuffer; exports[DATA_VIEW] = $DataView; -},{"./_an-instance":76,"./_array-fill":79,"./_descriptors":97,"./_fails":103,"./_global":109,"./_hide":111,"./_library":128,"./_object-dp":138,"./_object-gopn":142,"./_redefine-all":156,"./_set-to-string-tag":163,"./_to-index":177,"./_to-integer":178,"./_to-length":180,"./_typed":185}],185:[function(require,module,exports){ +},{"./_an-instance":70,"./_array-fill":73,"./_descriptors":91,"./_fails":97,"./_global":103,"./_hide":105,"./_library":122,"./_object-dp":132,"./_object-gopn":136,"./_redefine-all":150,"./_set-to-string-tag":157,"./_to-index":171,"./_to-integer":172,"./_to-length":174,"./_typed":179}],179:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var uid = require('./_uid'); @@ -8361,27 +8266,27 @@ module.exports = { VIEW: VIEW }; -},{"./_global":109,"./_hide":111,"./_uid":186}],186:[function(require,module,exports){ +},{"./_global":103,"./_hide":105,"./_uid":180}],180:[function(require,module,exports){ var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],187:[function(require,module,exports){ +},{}],181:[function(require,module,exports){ var global = require('./_global'); var navigator = global.navigator; module.exports = navigator && navigator.userAgent || ''; -},{"./_global":109}],188:[function(require,module,exports){ +},{"./_global":103}],182:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it, TYPE) { if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); return it; }; -},{"./_is-object":120}],189:[function(require,module,exports){ +},{"./_is-object":114}],183:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var LIBRARY = require('./_library'); @@ -8392,10 +8297,10 @@ module.exports = function (name) { if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); }; -},{"./_core":91,"./_global":109,"./_library":128,"./_object-dp":138,"./_wks-ext":190}],190:[function(require,module,exports){ +},{"./_core":85,"./_global":103,"./_library":122,"./_object-dp":132,"./_wks-ext":184}],184:[function(require,module,exports){ exports.f = require('./_wks'); -},{"./_wks":191}],191:[function(require,module,exports){ +},{"./_wks":185}],185:[function(require,module,exports){ var store = require('./_shared')('wks'); var uid = require('./_uid'); var Symbol = require('./_global').Symbol; @@ -8408,7 +8313,7 @@ var $exports = module.exports = function (name) { $exports.store = store; -},{"./_global":109,"./_shared":165,"./_uid":186}],192:[function(require,module,exports){ +},{"./_global":103,"./_shared":159,"./_uid":180}],186:[function(require,module,exports){ var classof = require('./_classof'); var ITERATOR = require('./_wks')('iterator'); var Iterators = require('./_iterators'); @@ -8418,7 +8323,7 @@ module.exports = require('./_core').getIteratorMethod = function (it) { || Iterators[classof(it)]; }; -},{"./_classof":86,"./_core":91,"./_iterators":127,"./_wks":191}],193:[function(require,module,exports){ +},{"./_classof":80,"./_core":85,"./_iterators":121,"./_wks":185}],187:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) var $export = require('./_export'); @@ -8426,7 +8331,7 @@ $export($export.P, 'Array', { copyWithin: require('./_array-copy-within') }); require('./_add-to-unscopables')('copyWithin'); -},{"./_add-to-unscopables":74,"./_array-copy-within":78,"./_export":101}],194:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-copy-within":72,"./_export":95}],188:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $every = require('./_array-methods')(4); @@ -8438,7 +8343,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].every, true), 'A } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],195:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],189:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) var $export = require('./_export'); @@ -8446,7 +8351,7 @@ $export($export.P, 'Array', { fill: require('./_array-fill') }); require('./_add-to-unscopables')('fill'); -},{"./_add-to-unscopables":74,"./_array-fill":79,"./_export":101}],196:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-fill":73,"./_export":95}],190:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $filter = require('./_array-methods')(2); @@ -8458,7 +8363,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].filter, true), ' } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],197:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],191:[function(require,module,exports){ 'use strict'; // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) var $export = require('./_export'); @@ -8474,7 +8379,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":74,"./_array-methods":81,"./_export":101}],198:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-methods":75,"./_export":95}],192:[function(require,module,exports){ 'use strict'; // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) var $export = require('./_export'); @@ -8490,7 +8395,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":74,"./_array-methods":81,"./_export":101}],199:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-methods":75,"./_export":95}],193:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $forEach = require('./_array-methods')(0); @@ -8503,7 +8408,7 @@ $export($export.P + $export.F * !STRICT, 'Array', { } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],200:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],194:[function(require,module,exports){ 'use strict'; var ctx = require('./_ctx'); var $export = require('./_export'); @@ -8542,7 +8447,7 @@ $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Arr } }); -},{"./_create-property":92,"./_ctx":93,"./_export":101,"./_is-array-iter":117,"./_iter-call":122,"./_iter-detect":125,"./_to-length":180,"./_to-object":181,"./core.get-iterator-method":192}],201:[function(require,module,exports){ +},{"./_create-property":86,"./_ctx":87,"./_export":95,"./_is-array-iter":111,"./_iter-call":116,"./_iter-detect":119,"./_to-length":174,"./_to-object":175,"./core.get-iterator-method":186}],195:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $indexOf = require('./_array-includes')(false); @@ -8559,13 +8464,13 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_array-includes":80,"./_export":101,"./_strict-method":167}],202:[function(require,module,exports){ +},{"./_array-includes":74,"./_export":95,"./_strict-method":161}],196:[function(require,module,exports){ // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) var $export = require('./_export'); $export($export.S, 'Array', { isArray: require('./_is-array') }); -},{"./_export":101,"./_is-array":118}],203:[function(require,module,exports){ +},{"./_export":95,"./_is-array":112}],197:[function(require,module,exports){ 'use strict'; var addToUnscopables = require('./_add-to-unscopables'); var step = require('./_iter-step'); @@ -8601,7 +8506,7 @@ addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"./_add-to-unscopables":74,"./_iter-define":124,"./_iter-step":126,"./_iterators":127,"./_to-iobject":179}],204:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_iter-define":118,"./_iter-step":120,"./_iterators":121,"./_to-iobject":173}],198:[function(require,module,exports){ 'use strict'; // 22.1.3.13 Array.prototype.join(separator) var $export = require('./_export'); @@ -8615,7 +8520,7 @@ $export($export.P + $export.F * (require('./_iobject') != Object || !require('./ } }); -},{"./_export":101,"./_iobject":116,"./_strict-method":167,"./_to-iobject":179}],205:[function(require,module,exports){ +},{"./_export":95,"./_iobject":110,"./_strict-method":161,"./_to-iobject":173}],199:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toIObject = require('./_to-iobject'); @@ -8639,7 +8544,7 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_export":101,"./_strict-method":167,"./_to-integer":178,"./_to-iobject":179,"./_to-length":180}],206:[function(require,module,exports){ +},{"./_export":95,"./_strict-method":161,"./_to-integer":172,"./_to-iobject":173,"./_to-length":174}],200:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $map = require('./_array-methods')(1); @@ -8651,7 +8556,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Arr } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],207:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],201:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var createProperty = require('./_create-property'); @@ -8672,7 +8577,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_create-property":92,"./_export":101,"./_fails":103}],208:[function(require,module,exports){ +},{"./_create-property":86,"./_export":95,"./_fails":97}],202:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -8684,7 +8589,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduceRight, tru } }); -},{"./_array-reduce":82,"./_export":101,"./_strict-method":167}],209:[function(require,module,exports){ +},{"./_array-reduce":76,"./_export":95,"./_strict-method":161}],203:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -8696,7 +8601,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduce, true), ' } }); -},{"./_array-reduce":82,"./_export":101,"./_strict-method":167}],210:[function(require,module,exports){ +},{"./_array-reduce":76,"./_export":95,"./_strict-method":161}],204:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var html = require('./_html'); @@ -8726,7 +8631,7 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_cof":87,"./_export":101,"./_fails":103,"./_html":112,"./_to-absolute-index":176,"./_to-length":180}],211:[function(require,module,exports){ +},{"./_cof":81,"./_export":95,"./_fails":97,"./_html":106,"./_to-absolute-index":170,"./_to-length":174}],205:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $some = require('./_array-methods')(3); @@ -8738,7 +8643,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Ar } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],212:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],206:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -8763,16 +8668,16 @@ $export($export.P + $export.F * (fails(function () { } }); -},{"./_a-function":72,"./_export":101,"./_fails":103,"./_strict-method":167,"./_to-object":181}],213:[function(require,module,exports){ +},{"./_a-function":66,"./_export":95,"./_fails":97,"./_strict-method":161,"./_to-object":175}],207:[function(require,module,exports){ require('./_set-species')('Array'); -},{"./_set-species":162}],214:[function(require,module,exports){ +},{"./_set-species":156}],208:[function(require,module,exports){ // 20.3.3.1 / 15.9.4.4 Date.now() var $export = require('./_export'); $export($export.S, 'Date', { now: function () { return new Date().getTime(); } }); -},{"./_export":101}],215:[function(require,module,exports){ +},{"./_export":95}],209:[function(require,module,exports){ // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var $export = require('./_export'); var toISOString = require('./_date-to-iso-string'); @@ -8782,7 +8687,7 @@ $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'D toISOString: toISOString }); -},{"./_date-to-iso-string":94,"./_export":101}],216:[function(require,module,exports){ +},{"./_date-to-iso-string":88,"./_export":95}],210:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toObject = require('./_to-object'); @@ -8800,13 +8705,13 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103,"./_to-object":181,"./_to-primitive":182}],217:[function(require,module,exports){ +},{"./_export":95,"./_fails":97,"./_to-object":175,"./_to-primitive":176}],211:[function(require,module,exports){ var TO_PRIMITIVE = require('./_wks')('toPrimitive'); var proto = Date.prototype; if (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive')); -},{"./_date-to-primitive":95,"./_hide":111,"./_wks":191}],218:[function(require,module,exports){ +},{"./_date-to-primitive":89,"./_hide":105,"./_wks":185}],212:[function(require,module,exports){ var DateProto = Date.prototype; var INVALID_DATE = 'Invalid Date'; var TO_STRING = 'toString'; @@ -8820,13 +8725,13 @@ if (new Date(NaN) + '' != INVALID_DATE) { }); } -},{"./_redefine":157}],219:[function(require,module,exports){ +},{"./_redefine":151}],213:[function(require,module,exports){ // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) var $export = require('./_export'); $export($export.P, 'Function', { bind: require('./_bind') }); -},{"./_bind":85,"./_export":101}],220:[function(require,module,exports){ +},{"./_bind":79,"./_export":95}],214:[function(require,module,exports){ 'use strict'; var isObject = require('./_is-object'); var getPrototypeOf = require('./_object-gpo'); @@ -8841,7 +8746,7 @@ if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, H return false; } }); -},{"./_is-object":120,"./_object-dp":138,"./_object-gpo":144,"./_wks":191}],221:[function(require,module,exports){ +},{"./_is-object":114,"./_object-dp":132,"./_object-gpo":138,"./_wks":185}],215:[function(require,module,exports){ var dP = require('./_object-dp').f; var FProto = Function.prototype; var nameRE = /^\s*function ([^ (]*)/; @@ -8859,7 +8764,7 @@ NAME in FProto || require('./_descriptors') && dP(FProto, NAME, { } }); -},{"./_descriptors":97,"./_object-dp":138}],222:[function(require,module,exports){ +},{"./_descriptors":91,"./_object-dp":132}],216:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -8880,7 +8785,7 @@ module.exports = require('./_collection')(MAP, function (get) { } }, strong, true); -},{"./_collection":90,"./_collection-strong":88,"./_validate-collection":188}],223:[function(require,module,exports){ +},{"./_collection":84,"./_collection-strong":82,"./_validate-collection":182}],217:[function(require,module,exports){ // 20.2.2.3 Math.acosh(x) var $export = require('./_export'); var log1p = require('./_math-log1p'); @@ -8900,7 +8805,7 @@ $export($export.S + $export.F * !($acosh } }); -},{"./_export":101,"./_math-log1p":131}],224:[function(require,module,exports){ +},{"./_export":95,"./_math-log1p":125}],218:[function(require,module,exports){ // 20.2.2.5 Math.asinh(x) var $export = require('./_export'); var $asinh = Math.asinh; @@ -8912,7 +8817,7 @@ function asinh(x) { // Tor Browser bug: Math.asinh(0) -> -0 $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh }); -},{"./_export":101}],225:[function(require,module,exports){ +},{"./_export":95}],219:[function(require,module,exports){ // 20.2.2.7 Math.atanh(x) var $export = require('./_export'); var $atanh = Math.atanh; @@ -8924,7 +8829,7 @@ $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { } }); -},{"./_export":101}],226:[function(require,module,exports){ +},{"./_export":95}],220:[function(require,module,exports){ // 20.2.2.9 Math.cbrt(x) var $export = require('./_export'); var sign = require('./_math-sign'); @@ -8935,7 +8840,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101,"./_math-sign":132}],227:[function(require,module,exports){ +},{"./_export":95,"./_math-sign":126}],221:[function(require,module,exports){ // 20.2.2.11 Math.clz32(x) var $export = require('./_export'); @@ -8945,7 +8850,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],228:[function(require,module,exports){ +},{"./_export":95}],222:[function(require,module,exports){ // 20.2.2.12 Math.cosh(x) var $export = require('./_export'); var exp = Math.exp; @@ -8956,20 +8861,20 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],229:[function(require,module,exports){ +},{"./_export":95}],223:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $export = require('./_export'); var $expm1 = require('./_math-expm1'); $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 }); -},{"./_export":101,"./_math-expm1":129}],230:[function(require,module,exports){ +},{"./_export":95,"./_math-expm1":123}],224:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var $export = require('./_export'); $export($export.S, 'Math', { fround: require('./_math-fround') }); -},{"./_export":101,"./_math-fround":130}],231:[function(require,module,exports){ +},{"./_export":95,"./_math-fround":124}],225:[function(require,module,exports){ // 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) var $export = require('./_export'); var abs = Math.abs; @@ -8996,7 +8901,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],232:[function(require,module,exports){ +},{"./_export":95}],226:[function(require,module,exports){ // 20.2.2.18 Math.imul(x, y) var $export = require('./_export'); var $imul = Math.imul; @@ -9015,7 +8920,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103}],233:[function(require,module,exports){ +},{"./_export":95,"./_fails":97}],227:[function(require,module,exports){ // 20.2.2.21 Math.log10(x) var $export = require('./_export'); @@ -9025,13 +8930,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],234:[function(require,module,exports){ +},{"./_export":95}],228:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) var $export = require('./_export'); $export($export.S, 'Math', { log1p: require('./_math-log1p') }); -},{"./_export":101,"./_math-log1p":131}],235:[function(require,module,exports){ +},{"./_export":95,"./_math-log1p":125}],229:[function(require,module,exports){ // 20.2.2.22 Math.log2(x) var $export = require('./_export'); @@ -9041,13 +8946,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],236:[function(require,module,exports){ +},{"./_export":95}],230:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) var $export = require('./_export'); $export($export.S, 'Math', { sign: require('./_math-sign') }); -},{"./_export":101,"./_math-sign":132}],237:[function(require,module,exports){ +},{"./_export":95,"./_math-sign":126}],231:[function(require,module,exports){ // 20.2.2.30 Math.sinh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9064,7 +8969,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103,"./_math-expm1":129}],238:[function(require,module,exports){ +},{"./_export":95,"./_fails":97,"./_math-expm1":123}],232:[function(require,module,exports){ // 20.2.2.33 Math.tanh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9078,7 +8983,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101,"./_math-expm1":129}],239:[function(require,module,exports){ +},{"./_export":95,"./_math-expm1":123}],233:[function(require,module,exports){ // 20.2.2.34 Math.trunc(x) var $export = require('./_export'); @@ -9088,7 +8993,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],240:[function(require,module,exports){ +},{"./_export":95}],234:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var has = require('./_has'); @@ -9159,13 +9064,13 @@ if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { require('./_redefine')(global, NUMBER, $Number); } -},{"./_cof":87,"./_descriptors":97,"./_fails":103,"./_global":109,"./_has":110,"./_inherit-if-required":114,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_redefine":157,"./_string-trim":173,"./_to-primitive":182}],241:[function(require,module,exports){ +},{"./_cof":81,"./_descriptors":91,"./_fails":97,"./_global":103,"./_has":104,"./_inherit-if-required":108,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_redefine":151,"./_string-trim":167,"./_to-primitive":176}],235:[function(require,module,exports){ // 20.1.2.1 Number.EPSILON var $export = require('./_export'); $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); -},{"./_export":101}],242:[function(require,module,exports){ +},{"./_export":95}],236:[function(require,module,exports){ // 20.1.2.2 Number.isFinite(number) var $export = require('./_export'); var _isFinite = require('./_global').isFinite; @@ -9176,13 +9081,13 @@ $export($export.S, 'Number', { } }); -},{"./_export":101,"./_global":109}],243:[function(require,module,exports){ +},{"./_export":95,"./_global":103}],237:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var $export = require('./_export'); $export($export.S, 'Number', { isInteger: require('./_is-integer') }); -},{"./_export":101,"./_is-integer":119}],244:[function(require,module,exports){ +},{"./_export":95,"./_is-integer":113}],238:[function(require,module,exports){ // 20.1.2.4 Number.isNaN(number) var $export = require('./_export'); @@ -9193,7 +9098,7 @@ $export($export.S, 'Number', { } }); -},{"./_export":101}],245:[function(require,module,exports){ +},{"./_export":95}],239:[function(require,module,exports){ // 20.1.2.5 Number.isSafeInteger(number) var $export = require('./_export'); var isInteger = require('./_is-integer'); @@ -9205,31 +9110,31 @@ $export($export.S, 'Number', { } }); -},{"./_export":101,"./_is-integer":119}],246:[function(require,module,exports){ +},{"./_export":95,"./_is-integer":113}],240:[function(require,module,exports){ // 20.1.2.6 Number.MAX_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); -},{"./_export":101}],247:[function(require,module,exports){ +},{"./_export":95}],241:[function(require,module,exports){ // 20.1.2.10 Number.MIN_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); -},{"./_export":101}],248:[function(require,module,exports){ +},{"./_export":95}],242:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 20.1.2.12 Number.parseFloat(string) $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat }); -},{"./_export":101,"./_parse-float":151}],249:[function(require,module,exports){ +},{"./_export":95,"./_parse-float":145}],243:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 20.1.2.13 Number.parseInt(string, radix) $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt }); -},{"./_export":101,"./_parse-int":152}],250:[function(require,module,exports){ +},{"./_export":95,"./_parse-int":146}],244:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toInteger = require('./_to-integer'); @@ -9345,7 +9250,7 @@ $export($export.P + $export.F * (!!$toFixed && ( } }); -},{"./_a-number-value":73,"./_export":101,"./_fails":103,"./_string-repeat":172,"./_to-integer":178}],251:[function(require,module,exports){ +},{"./_a-number-value":67,"./_export":95,"./_fails":97,"./_string-repeat":166,"./_to-integer":172}],245:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $fails = require('./_fails'); @@ -9365,28 +9270,28 @@ $export($export.P + $export.F * ($fails(function () { } }); -},{"./_a-number-value":73,"./_export":101,"./_fails":103}],252:[function(require,module,exports){ +},{"./_a-number-value":67,"./_export":95,"./_fails":97}],246:[function(require,module,exports){ // 19.1.3.1 Object.assign(target, source) var $export = require('./_export'); $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') }); -},{"./_export":101,"./_object-assign":136}],253:[function(require,module,exports){ +},{"./_export":95,"./_object-assign":130}],247:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) $export($export.S, 'Object', { create: require('./_object-create') }); -},{"./_export":101,"./_object-create":137}],254:[function(require,module,exports){ +},{"./_export":95,"./_object-create":131}],248:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') }); -},{"./_descriptors":97,"./_export":101,"./_object-dps":139}],255:[function(require,module,exports){ +},{"./_descriptors":91,"./_export":95,"./_object-dps":133}],249:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f }); -},{"./_descriptors":97,"./_export":101,"./_object-dp":138}],256:[function(require,module,exports){ +},{"./_descriptors":91,"./_export":95,"./_object-dp":132}],250:[function(require,module,exports){ // 19.1.2.5 Object.freeze(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9397,7 +9302,7 @@ require('./_object-sap')('freeze', function ($freeze) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],257:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],251:[function(require,module,exports){ // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) var toIObject = require('./_to-iobject'); var $getOwnPropertyDescriptor = require('./_object-gopd').f; @@ -9408,13 +9313,13 @@ require('./_object-sap')('getOwnPropertyDescriptor', function () { }; }); -},{"./_object-gopd":140,"./_object-sap":148,"./_to-iobject":179}],258:[function(require,module,exports){ +},{"./_object-gopd":134,"./_object-sap":142,"./_to-iobject":173}],252:[function(require,module,exports){ // 19.1.2.7 Object.getOwnPropertyNames(O) require('./_object-sap')('getOwnPropertyNames', function () { return require('./_object-gopn-ext').f; }); -},{"./_object-gopn-ext":141,"./_object-sap":148}],259:[function(require,module,exports){ +},{"./_object-gopn-ext":135,"./_object-sap":142}],253:[function(require,module,exports){ // 19.1.2.9 Object.getPrototypeOf(O) var toObject = require('./_to-object'); var $getPrototypeOf = require('./_object-gpo'); @@ -9425,7 +9330,7 @@ require('./_object-sap')('getPrototypeOf', function () { }; }); -},{"./_object-gpo":144,"./_object-sap":148,"./_to-object":181}],260:[function(require,module,exports){ +},{"./_object-gpo":138,"./_object-sap":142,"./_to-object":175}],254:[function(require,module,exports){ // 19.1.2.11 Object.isExtensible(O) var isObject = require('./_is-object'); @@ -9435,7 +9340,7 @@ require('./_object-sap')('isExtensible', function ($isExtensible) { }; }); -},{"./_is-object":120,"./_object-sap":148}],261:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],255:[function(require,module,exports){ // 19.1.2.12 Object.isFrozen(O) var isObject = require('./_is-object'); @@ -9445,7 +9350,7 @@ require('./_object-sap')('isFrozen', function ($isFrozen) { }; }); -},{"./_is-object":120,"./_object-sap":148}],262:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],256:[function(require,module,exports){ // 19.1.2.13 Object.isSealed(O) var isObject = require('./_is-object'); @@ -9455,12 +9360,12 @@ require('./_object-sap')('isSealed', function ($isSealed) { }; }); -},{"./_is-object":120,"./_object-sap":148}],263:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],257:[function(require,module,exports){ // 19.1.3.10 Object.is(value1, value2) var $export = require('./_export'); $export($export.S, 'Object', { is: require('./_same-value') }); -},{"./_export":101,"./_same-value":160}],264:[function(require,module,exports){ +},{"./_export":95,"./_same-value":154}],258:[function(require,module,exports){ // 19.1.2.14 Object.keys(O) var toObject = require('./_to-object'); var $keys = require('./_object-keys'); @@ -9471,7 +9376,7 @@ require('./_object-sap')('keys', function () { }; }); -},{"./_object-keys":146,"./_object-sap":148,"./_to-object":181}],265:[function(require,module,exports){ +},{"./_object-keys":140,"./_object-sap":142,"./_to-object":175}],259:[function(require,module,exports){ // 19.1.2.15 Object.preventExtensions(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9482,7 +9387,7 @@ require('./_object-sap')('preventExtensions', function ($preventExtensions) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],266:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],260:[function(require,module,exports){ // 19.1.2.17 Object.seal(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9493,12 +9398,12 @@ require('./_object-sap')('seal', function ($seal) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],267:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],261:[function(require,module,exports){ // 19.1.3.19 Object.setPrototypeOf(O, proto) var $export = require('./_export'); $export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set }); -},{"./_export":101,"./_set-proto":161}],268:[function(require,module,exports){ +},{"./_export":95,"./_set-proto":155}],262:[function(require,module,exports){ 'use strict'; // 19.1.3.6 Object.prototype.toString() var classof = require('./_classof'); @@ -9510,19 +9415,19 @@ if (test + '' != '[object z]') { }, true); } -},{"./_classof":86,"./_redefine":157,"./_wks":191}],269:[function(require,module,exports){ +},{"./_classof":80,"./_redefine":151,"./_wks":185}],263:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 18.2.4 parseFloat(string) $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat }); -},{"./_export":101,"./_parse-float":151}],270:[function(require,module,exports){ +},{"./_export":95,"./_parse-float":145}],264:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 18.2.5 parseInt(string, radix) $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt }); -},{"./_export":101,"./_parse-int":152}],271:[function(require,module,exports){ +},{"./_export":95,"./_parse-int":146}],265:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var global = require('./_global'); @@ -9810,7 +9715,7 @@ $export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(functi } }); -},{"./_a-function":72,"./_an-instance":76,"./_classof":86,"./_core":91,"./_ctx":93,"./_export":101,"./_for-of":107,"./_global":109,"./_is-object":120,"./_iter-detect":125,"./_library":128,"./_microtask":134,"./_new-promise-capability":135,"./_perform":153,"./_promise-resolve":154,"./_redefine-all":156,"./_set-species":162,"./_set-to-string-tag":163,"./_species-constructor":166,"./_task":175,"./_user-agent":187,"./_wks":191}],272:[function(require,module,exports){ +},{"./_a-function":66,"./_an-instance":70,"./_classof":80,"./_core":85,"./_ctx":87,"./_export":95,"./_for-of":101,"./_global":103,"./_is-object":114,"./_iter-detect":119,"./_library":122,"./_microtask":128,"./_new-promise-capability":129,"./_perform":147,"./_promise-resolve":148,"./_redefine-all":150,"./_set-species":156,"./_set-to-string-tag":157,"./_species-constructor":160,"./_task":169,"./_user-agent":181,"./_wks":185}],266:[function(require,module,exports){ // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -9828,7 +9733,7 @@ $export($export.S + $export.F * !require('./_fails')(function () { } }); -},{"./_a-function":72,"./_an-object":77,"./_export":101,"./_fails":103,"./_global":109}],273:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_export":95,"./_fails":97,"./_global":103}],267:[function(require,module,exports){ // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) var $export = require('./_export'); var create = require('./_object-create'); @@ -9877,7 +9782,7 @@ $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { } }); -},{"./_a-function":72,"./_an-object":77,"./_bind":85,"./_export":101,"./_fails":103,"./_global":109,"./_is-object":120,"./_object-create":137}],274:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_bind":79,"./_export":95,"./_fails":97,"./_global":103,"./_is-object":114,"./_object-create":131}],268:[function(require,module,exports){ // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) var dP = require('./_object-dp'); var $export = require('./_export'); @@ -9902,7 +9807,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_an-object":77,"./_export":101,"./_fails":103,"./_object-dp":138,"./_to-primitive":182}],275:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_fails":97,"./_object-dp":132,"./_to-primitive":176}],269:[function(require,module,exports){ // 26.1.4 Reflect.deleteProperty(target, propertyKey) var $export = require('./_export'); var gOPD = require('./_object-gopd').f; @@ -9915,7 +9820,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gopd":140}],276:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gopd":134}],270:[function(require,module,exports){ 'use strict'; // 26.1.5 Reflect.enumerate(target) var $export = require('./_export'); @@ -9943,7 +9848,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_iter-create":123}],277:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_iter-create":117}],271:[function(require,module,exports){ // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) var gOPD = require('./_object-gopd'); var $export = require('./_export'); @@ -9955,7 +9860,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gopd":140}],278:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gopd":134}],272:[function(require,module,exports){ // 26.1.8 Reflect.getPrototypeOf(target) var $export = require('./_export'); var getProto = require('./_object-gpo'); @@ -9967,7 +9872,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gpo":144}],279:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gpo":138}],273:[function(require,module,exports){ // 26.1.6 Reflect.get(target, propertyKey [, receiver]) var gOPD = require('./_object-gopd'); var getPrototypeOf = require('./_object-gpo'); @@ -9990,7 +9895,7 @@ function get(target, propertyKey /* , receiver */) { $export($export.S, 'Reflect', { get: get }); -},{"./_an-object":77,"./_export":101,"./_has":110,"./_is-object":120,"./_object-gopd":140,"./_object-gpo":144}],280:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_has":104,"./_is-object":114,"./_object-gopd":134,"./_object-gpo":138}],274:[function(require,module,exports){ // 26.1.9 Reflect.has(target, propertyKey) var $export = require('./_export'); @@ -10000,7 +9905,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_export":101}],281:[function(require,module,exports){ +},{"./_export":95}],275:[function(require,module,exports){ // 26.1.10 Reflect.isExtensible(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10013,13 +9918,13 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101}],282:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95}],276:[function(require,module,exports){ // 26.1.11 Reflect.ownKeys(target) var $export = require('./_export'); $export($export.S, 'Reflect', { ownKeys: require('./_own-keys') }); -},{"./_export":101,"./_own-keys":150}],283:[function(require,module,exports){ +},{"./_export":95,"./_own-keys":144}],277:[function(require,module,exports){ // 26.1.12 Reflect.preventExtensions(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10037,7 +9942,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101}],284:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95}],278:[function(require,module,exports){ // 26.1.14 Reflect.setPrototypeOf(target, proto) var $export = require('./_export'); var setProto = require('./_set-proto'); @@ -10054,7 +9959,7 @@ if (setProto) $export($export.S, 'Reflect', { } }); -},{"./_export":101,"./_set-proto":161}],285:[function(require,module,exports){ +},{"./_export":95,"./_set-proto":155}],279:[function(require,module,exports){ // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) var dP = require('./_object-dp'); var gOPD = require('./_object-gopd'); @@ -10089,7 +9994,7 @@ function set(target, propertyKey, V /* , receiver */) { $export($export.S, 'Reflect', { set: set }); -},{"./_an-object":77,"./_export":101,"./_has":110,"./_is-object":120,"./_object-dp":138,"./_object-gopd":140,"./_object-gpo":144,"./_property-desc":155}],286:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_has":104,"./_is-object":114,"./_object-dp":132,"./_object-gopd":134,"./_object-gpo":138,"./_property-desc":149}],280:[function(require,module,exports){ var global = require('./_global'); var inheritIfRequired = require('./_inherit-if-required'); var dP = require('./_object-dp').f; @@ -10134,7 +10039,7 @@ if (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function ( require('./_set-species')('RegExp'); -},{"./_descriptors":97,"./_fails":103,"./_flags":105,"./_global":109,"./_inherit-if-required":114,"./_is-regexp":121,"./_object-dp":138,"./_object-gopn":142,"./_redefine":157,"./_set-species":162,"./_wks":191}],287:[function(require,module,exports){ +},{"./_descriptors":91,"./_fails":97,"./_flags":99,"./_global":103,"./_inherit-if-required":108,"./_is-regexp":115,"./_object-dp":132,"./_object-gopn":136,"./_redefine":151,"./_set-species":156,"./_wks":185}],281:[function(require,module,exports){ 'use strict'; var regexpExec = require('./_regexp-exec'); require('./_export')({ @@ -10145,14 +10050,14 @@ require('./_export')({ exec: regexpExec }); -},{"./_export":101,"./_regexp-exec":159}],288:[function(require,module,exports){ +},{"./_export":95,"./_regexp-exec":153}],282:[function(require,module,exports){ // 21.2.5.3 get RegExp.prototype.flags() if (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', { configurable: true, get: require('./_flags') }); -},{"./_descriptors":97,"./_flags":105,"./_object-dp":138}],289:[function(require,module,exports){ +},{"./_descriptors":91,"./_flags":99,"./_object-dp":132}],283:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10194,7 +10099,7 @@ require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCall ]; }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_to-length":180}],290:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_to-length":174}],284:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10314,7 +10219,7 @@ require('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, may } }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_to-integer":178,"./_to-length":180,"./_to-object":181}],291:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_to-integer":172,"./_to-length":174,"./_to-object":175}],285:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10347,7 +10252,7 @@ require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeC ]; }); -},{"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_same-value":160}],292:[function(require,module,exports){ +},{"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_same-value":154}],286:[function(require,module,exports){ 'use strict'; var isRegExp = require('./_is-regexp'); @@ -10483,7 +10388,7 @@ require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCall ]; }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fails":103,"./_fix-re-wks":104,"./_is-regexp":121,"./_regexp-exec":159,"./_regexp-exec-abstract":158,"./_species-constructor":166,"./_to-length":180}],293:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fails":97,"./_fix-re-wks":98,"./_is-regexp":115,"./_regexp-exec":153,"./_regexp-exec-abstract":152,"./_species-constructor":160,"./_to-length":174}],287:[function(require,module,exports){ 'use strict'; require('./es6.regexp.flags'); var anObject = require('./_an-object'); @@ -10510,7 +10415,7 @@ if (require('./_fails')(function () { return $toString.call({ source: 'a', flags }); } -},{"./_an-object":77,"./_descriptors":97,"./_fails":103,"./_flags":105,"./_redefine":157,"./es6.regexp.flags":288}],294:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_fails":97,"./_flags":99,"./_redefine":151,"./es6.regexp.flags":282}],288:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -10526,7 +10431,7 @@ module.exports = require('./_collection')(SET, function (get) { } }, strong); -},{"./_collection":90,"./_collection-strong":88,"./_validate-collection":188}],295:[function(require,module,exports){ +},{"./_collection":84,"./_collection-strong":82,"./_validate-collection":182}],289:[function(require,module,exports){ 'use strict'; // B.2.3.2 String.prototype.anchor(name) require('./_string-html')('anchor', function (createHTML) { @@ -10535,7 +10440,7 @@ require('./_string-html')('anchor', function (createHTML) { }; }); -},{"./_string-html":170}],296:[function(require,module,exports){ +},{"./_string-html":164}],290:[function(require,module,exports){ 'use strict'; // B.2.3.3 String.prototype.big() require('./_string-html')('big', function (createHTML) { @@ -10544,7 +10449,7 @@ require('./_string-html')('big', function (createHTML) { }; }); -},{"./_string-html":170}],297:[function(require,module,exports){ +},{"./_string-html":164}],291:[function(require,module,exports){ 'use strict'; // B.2.3.4 String.prototype.blink() require('./_string-html')('blink', function (createHTML) { @@ -10553,7 +10458,7 @@ require('./_string-html')('blink', function (createHTML) { }; }); -},{"./_string-html":170}],298:[function(require,module,exports){ +},{"./_string-html":164}],292:[function(require,module,exports){ 'use strict'; // B.2.3.5 String.prototype.bold() require('./_string-html')('bold', function (createHTML) { @@ -10562,7 +10467,7 @@ require('./_string-html')('bold', function (createHTML) { }; }); -},{"./_string-html":170}],299:[function(require,module,exports){ +},{"./_string-html":164}],293:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $at = require('./_string-at')(false); @@ -10573,7 +10478,7 @@ $export($export.P, 'String', { } }); -},{"./_export":101,"./_string-at":168}],300:[function(require,module,exports){ +},{"./_export":95,"./_string-at":162}],294:[function(require,module,exports){ // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) 'use strict'; var $export = require('./_export'); @@ -10595,7 +10500,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'Strin } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169,"./_to-length":180}],301:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163,"./_to-length":174}],295:[function(require,module,exports){ 'use strict'; // B.2.3.6 String.prototype.fixed() require('./_string-html')('fixed', function (createHTML) { @@ -10604,7 +10509,7 @@ require('./_string-html')('fixed', function (createHTML) { }; }); -},{"./_string-html":170}],302:[function(require,module,exports){ +},{"./_string-html":164}],296:[function(require,module,exports){ 'use strict'; // B.2.3.7 String.prototype.fontcolor(color) require('./_string-html')('fontcolor', function (createHTML) { @@ -10613,7 +10518,7 @@ require('./_string-html')('fontcolor', function (createHTML) { }; }); -},{"./_string-html":170}],303:[function(require,module,exports){ +},{"./_string-html":164}],297:[function(require,module,exports){ 'use strict'; // B.2.3.8 String.prototype.fontsize(size) require('./_string-html')('fontsize', function (createHTML) { @@ -10622,7 +10527,7 @@ require('./_string-html')('fontsize', function (createHTML) { }; }); -},{"./_string-html":170}],304:[function(require,module,exports){ +},{"./_string-html":164}],298:[function(require,module,exports){ var $export = require('./_export'); var toAbsoluteIndex = require('./_to-absolute-index'); var fromCharCode = String.fromCharCode; @@ -10647,7 +10552,7 @@ $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1) } }); -},{"./_export":101,"./_to-absolute-index":176}],305:[function(require,module,exports){ +},{"./_export":95,"./_to-absolute-index":170}],299:[function(require,module,exports){ // 21.1.3.7 String.prototype.includes(searchString, position = 0) 'use strict'; var $export = require('./_export'); @@ -10661,7 +10566,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169}],306:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163}],300:[function(require,module,exports){ 'use strict'; // B.2.3.9 String.prototype.italics() require('./_string-html')('italics', function (createHTML) { @@ -10670,7 +10575,7 @@ require('./_string-html')('italics', function (createHTML) { }; }); -},{"./_string-html":170}],307:[function(require,module,exports){ +},{"./_string-html":164}],301:[function(require,module,exports){ 'use strict'; var $at = require('./_string-at')(true); @@ -10689,7 +10594,7 @@ require('./_iter-define')(String, 'String', function (iterated) { return { value: point, done: false }; }); -},{"./_iter-define":124,"./_string-at":168}],308:[function(require,module,exports){ +},{"./_iter-define":118,"./_string-at":162}],302:[function(require,module,exports){ 'use strict'; // B.2.3.10 String.prototype.link(url) require('./_string-html')('link', function (createHTML) { @@ -10698,7 +10603,7 @@ require('./_string-html')('link', function (createHTML) { }; }); -},{"./_string-html":170}],309:[function(require,module,exports){ +},{"./_string-html":164}],303:[function(require,module,exports){ var $export = require('./_export'); var toIObject = require('./_to-iobject'); var toLength = require('./_to-length'); @@ -10718,7 +10623,7 @@ $export($export.S, 'String', { } }); -},{"./_export":101,"./_to-iobject":179,"./_to-length":180}],310:[function(require,module,exports){ +},{"./_export":95,"./_to-iobject":173,"./_to-length":174}],304:[function(require,module,exports){ var $export = require('./_export'); $export($export.P, 'String', { @@ -10726,7 +10631,7 @@ $export($export.P, 'String', { repeat: require('./_string-repeat') }); -},{"./_export":101,"./_string-repeat":172}],311:[function(require,module,exports){ +},{"./_export":95,"./_string-repeat":166}],305:[function(require,module,exports){ 'use strict'; // B.2.3.11 String.prototype.small() require('./_string-html')('small', function (createHTML) { @@ -10735,7 +10640,7 @@ require('./_string-html')('small', function (createHTML) { }; }); -},{"./_string-html":170}],312:[function(require,module,exports){ +},{"./_string-html":164}],306:[function(require,module,exports){ // 21.1.3.18 String.prototype.startsWith(searchString [, position ]) 'use strict'; var $export = require('./_export'); @@ -10755,7 +10660,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'Str } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169,"./_to-length":180}],313:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163,"./_to-length":174}],307:[function(require,module,exports){ 'use strict'; // B.2.3.12 String.prototype.strike() require('./_string-html')('strike', function (createHTML) { @@ -10764,7 +10669,7 @@ require('./_string-html')('strike', function (createHTML) { }; }); -},{"./_string-html":170}],314:[function(require,module,exports){ +},{"./_string-html":164}],308:[function(require,module,exports){ 'use strict'; // B.2.3.13 String.prototype.sub() require('./_string-html')('sub', function (createHTML) { @@ -10773,7 +10678,7 @@ require('./_string-html')('sub', function (createHTML) { }; }); -},{"./_string-html":170}],315:[function(require,module,exports){ +},{"./_string-html":164}],309:[function(require,module,exports){ 'use strict'; // B.2.3.14 String.prototype.sup() require('./_string-html')('sup', function (createHTML) { @@ -10782,7 +10687,7 @@ require('./_string-html')('sup', function (createHTML) { }; }); -},{"./_string-html":170}],316:[function(require,module,exports){ +},{"./_string-html":164}],310:[function(require,module,exports){ 'use strict'; // 21.1.3.25 String.prototype.trim() require('./_string-trim')('trim', function ($trim) { @@ -10791,7 +10696,7 @@ require('./_string-trim')('trim', function ($trim) { }; }); -},{"./_string-trim":173}],317:[function(require,module,exports){ +},{"./_string-trim":167}],311:[function(require,module,exports){ 'use strict'; // ECMAScript 6 symbols shim var global = require('./_global'); @@ -11039,7 +10944,7 @@ setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] setToStringTag(global.JSON, 'JSON', true); -},{"./_an-object":77,"./_descriptors":97,"./_enum-keys":100,"./_export":101,"./_fails":103,"./_global":109,"./_has":110,"./_hide":111,"./_is-array":118,"./_is-object":120,"./_library":128,"./_meta":133,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_object-gopn-ext":141,"./_object-gops":143,"./_object-keys":146,"./_object-pie":147,"./_property-desc":155,"./_redefine":157,"./_set-to-string-tag":163,"./_shared":165,"./_to-iobject":179,"./_to-object":181,"./_to-primitive":182,"./_uid":186,"./_wks":191,"./_wks-define":189,"./_wks-ext":190}],318:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_enum-keys":94,"./_export":95,"./_fails":97,"./_global":103,"./_has":104,"./_hide":105,"./_is-array":112,"./_is-object":114,"./_library":122,"./_meta":127,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_object-gopn-ext":135,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_property-desc":149,"./_redefine":151,"./_set-to-string-tag":157,"./_shared":159,"./_to-iobject":173,"./_to-object":175,"./_to-primitive":176,"./_uid":180,"./_wks":185,"./_wks-define":183,"./_wks-ext":184}],312:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $typed = require('./_typed'); @@ -11087,76 +10992,76 @@ $export($export.P + $export.U + $export.F * require('./_fails')(function () { require('./_set-species')(ARRAY_BUFFER); -},{"./_an-object":77,"./_export":101,"./_fails":103,"./_global":109,"./_is-object":120,"./_set-species":162,"./_species-constructor":166,"./_to-absolute-index":176,"./_to-length":180,"./_typed":185,"./_typed-buffer":184}],319:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_fails":97,"./_global":103,"./_is-object":114,"./_set-species":156,"./_species-constructor":160,"./_to-absolute-index":170,"./_to-length":174,"./_typed":179,"./_typed-buffer":178}],313:[function(require,module,exports){ var $export = require('./_export'); $export($export.G + $export.W + $export.F * !require('./_typed').ABV, { DataView: require('./_typed-buffer').DataView }); -},{"./_export":101,"./_typed":185,"./_typed-buffer":184}],320:[function(require,module,exports){ +},{"./_export":95,"./_typed":179,"./_typed-buffer":178}],314:[function(require,module,exports){ require('./_typed-array')('Float32', 4, function (init) { return function Float32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],321:[function(require,module,exports){ +},{"./_typed-array":177}],315:[function(require,module,exports){ require('./_typed-array')('Float64', 8, function (init) { return function Float64Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],322:[function(require,module,exports){ +},{"./_typed-array":177}],316:[function(require,module,exports){ require('./_typed-array')('Int16', 2, function (init) { return function Int16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],323:[function(require,module,exports){ +},{"./_typed-array":177}],317:[function(require,module,exports){ require('./_typed-array')('Int32', 4, function (init) { return function Int32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],324:[function(require,module,exports){ +},{"./_typed-array":177}],318:[function(require,module,exports){ require('./_typed-array')('Int8', 1, function (init) { return function Int8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],325:[function(require,module,exports){ +},{"./_typed-array":177}],319:[function(require,module,exports){ require('./_typed-array')('Uint16', 2, function (init) { return function Uint16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],326:[function(require,module,exports){ +},{"./_typed-array":177}],320:[function(require,module,exports){ require('./_typed-array')('Uint32', 4, function (init) { return function Uint32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],327:[function(require,module,exports){ +},{"./_typed-array":177}],321:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],328:[function(require,module,exports){ +},{"./_typed-array":177}],322:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8ClampedArray(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }, true); -},{"./_typed-array":183}],329:[function(require,module,exports){ +},{"./_typed-array":177}],323:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var each = require('./_array-methods')(0); @@ -11218,7 +11123,7 @@ if (NATIVE_WEAK_MAP && IS_IE11) { }); } -},{"./_array-methods":81,"./_collection":90,"./_collection-weak":89,"./_global":109,"./_is-object":120,"./_meta":133,"./_object-assign":136,"./_redefine":157,"./_validate-collection":188}],330:[function(require,module,exports){ +},{"./_array-methods":75,"./_collection":84,"./_collection-weak":83,"./_global":103,"./_is-object":114,"./_meta":127,"./_object-assign":130,"./_redefine":151,"./_validate-collection":182}],324:[function(require,module,exports){ 'use strict'; var weak = require('./_collection-weak'); var validate = require('./_validate-collection'); @@ -11234,7 +11139,7 @@ require('./_collection')(WEAK_SET, function (get) { } }, weak, false, true); -},{"./_collection":90,"./_collection-weak":89,"./_validate-collection":188}],331:[function(require,module,exports){ +},{"./_collection":84,"./_collection-weak":83,"./_validate-collection":182}],325:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap var $export = require('./_export'); @@ -11258,7 +11163,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('flatMap'); -},{"./_a-function":72,"./_add-to-unscopables":74,"./_array-species-create":84,"./_export":101,"./_flatten-into-array":106,"./_to-length":180,"./_to-object":181}],332:[function(require,module,exports){ +},{"./_a-function":66,"./_add-to-unscopables":68,"./_array-species-create":78,"./_export":95,"./_flatten-into-array":100,"./_to-length":174,"./_to-object":175}],326:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/Array.prototype.includes var $export = require('./_export'); @@ -11272,7 +11177,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('includes'); -},{"./_add-to-unscopables":74,"./_array-includes":80,"./_export":101}],333:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-includes":74,"./_export":95}],327:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $entries = require('./_object-to-array')(true); @@ -11283,7 +11188,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":101,"./_object-to-array":149}],334:[function(require,module,exports){ +},{"./_export":95,"./_object-to-array":143}],328:[function(require,module,exports){ // https://github.com/tc39/proposal-object-getownpropertydescriptors var $export = require('./_export'); var ownKeys = require('./_own-keys'); @@ -11307,7 +11212,7 @@ $export($export.S, 'Object', { } }); -},{"./_create-property":92,"./_export":101,"./_object-gopd":140,"./_own-keys":150,"./_to-iobject":179}],335:[function(require,module,exports){ +},{"./_create-property":86,"./_export":95,"./_object-gopd":134,"./_own-keys":144,"./_to-iobject":173}],329:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $values = require('./_object-to-array')(false); @@ -11318,7 +11223,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":101,"./_object-to-array":149}],336:[function(require,module,exports){ +},{"./_export":95,"./_object-to-array":143}],330:[function(require,module,exports){ // https://github.com/tc39/proposal-promise-finally 'use strict'; var $export = require('./_export'); @@ -11340,7 +11245,7 @@ $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { ); } }); -},{"./_core":91,"./_export":101,"./_global":109,"./_promise-resolve":154,"./_species-constructor":166}],337:[function(require,module,exports){ +},{"./_core":85,"./_export":95,"./_global":103,"./_promise-resolve":148,"./_species-constructor":160}],331:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -11356,7 +11261,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":101,"./_string-pad":171,"./_user-agent":187}],338:[function(require,module,exports){ +},{"./_export":95,"./_string-pad":165,"./_user-agent":181}],332:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -11372,7 +11277,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":101,"./_string-pad":171,"./_user-agent":187}],339:[function(require,module,exports){ +},{"./_export":95,"./_string-pad":165,"./_user-agent":181}],333:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimLeft', function ($trim) { @@ -11381,7 +11286,7 @@ require('./_string-trim')('trimLeft', function ($trim) { }; }, 'trimStart'); -},{"./_string-trim":173}],340:[function(require,module,exports){ +},{"./_string-trim":167}],334:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimRight', function ($trim) { @@ -11390,10 +11295,10 @@ require('./_string-trim')('trimRight', function ($trim) { }; }, 'trimEnd'); -},{"./_string-trim":173}],341:[function(require,module,exports){ +},{"./_string-trim":167}],335:[function(require,module,exports){ require('./_wks-define')('asyncIterator'); -},{"./_wks-define":189}],342:[function(require,module,exports){ +},{"./_wks-define":183}],336:[function(require,module,exports){ var $iterators = require('./es6.array.iterator'); var getKeys = require('./_object-keys'); var redefine = require('./_redefine'); @@ -11453,7 +11358,7 @@ for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++ } } -},{"./_global":109,"./_hide":111,"./_iterators":127,"./_object-keys":146,"./_redefine":157,"./_wks":191,"./es6.array.iterator":203}],343:[function(require,module,exports){ +},{"./_global":103,"./_hide":105,"./_iterators":121,"./_object-keys":140,"./_redefine":151,"./_wks":185,"./es6.array.iterator":197}],337:[function(require,module,exports){ var $export = require('./_export'); var $task = require('./_task'); $export($export.G + $export.B, { @@ -11461,7 +11366,7 @@ $export($export.G + $export.B, { clearImmediate: $task.clear }); -},{"./_export":101,"./_task":175}],344:[function(require,module,exports){ +},{"./_export":95,"./_task":169}],338:[function(require,module,exports){ // ie9- setTimeout & setInterval additional parameters fix var global = require('./_global'); var $export = require('./_export'); @@ -11483,10182 +11388,9948 @@ $export($export.G + $export.B + $export.F * MSIE, { setInterval: wrap(global.setInterval) }); -},{"./_export":101,"./_global":109,"./_user-agent":187}],345:[function(require,module,exports){ +},{"./_export":95,"./_global":103,"./_user-agent":181}],339:[function(require,module,exports){ require('../modules/web.timers'); require('../modules/web.immediate'); require('../modules/web.dom.iterable'); module.exports = require('../modules/_core'); -},{"../modules/_core":91,"../modules/web.dom.iterable":342,"../modules/web.immediate":343,"../modules/web.timers":344}],346:[function(require,module,exports){ -'use strict'; - -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) - && !isSpecial(value) -}; - -function isNonNullObject(value) { - return !!value && typeof value === 'object' -} - -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); - - return stringValue === '[object RegExp]' - || stringValue === '[object Date]' - || isReactElement(value) -} - -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE -} - -function emptyTarget(val) { - return Array.isArray(val) ? [] : {} -} - -function cloneUnlessOtherwiseSpecified(value, options) { - return (options.clone !== false && options.isMergeableObject(value)) - ? deepmerge(emptyTarget(value), value, options) - : value -} - -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options) - }) -} - -function getMergeFunction(key, options) { - if (!options.customMerge) { - return deepmerge - } - var customMerge = options.customMerge(key); - return typeof customMerge === 'function' ? customMerge : deepmerge -} +},{"../modules/_core":85,"../modules/web.dom.iterable":336,"../modules/web.immediate":337,"../modules/web.timers":338}],340:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-env browser */ -function getEnumerableOwnPropertySymbols(target) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return Object.propertyIsEnumerable.call(target, symbol) - }) - : [] -} +/** + * This is the web browser implementation of `debug()`. + */ -function getKeys(target) { - return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) -} +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; -function propertyIsOnObject(object, property) { - try { - return property in object - } catch(_) { - return false - } -} + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { - return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. -} +/** + * Colors. + */ -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) { - getKeys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; } - getKeys(source).forEach(function(key) { - if (propertyIsUnsafe(target, key)) { - return - } - if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { - destination[key] = getMergeFunction(key, options)(target[key], source[key], options); - } else { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } - }); - return destination + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() - // implementations can use it. The caller may not replace it. - options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; +/** + * Colorize log arguments if enabled. + * + * @api public + */ - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); - if (!sourceAndTargetTypesMatch) { - return cloneUnlessOtherwiseSpecified(source, options) - } else if (sourceIsArray) { - return options.arrayMerge(target, source, options) - } else { - return mergeObject(target, source, options) + if (!this.useColors) { + return; } + + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); } -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) { - throw new Error('first argument should be an array') +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? } +} - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options) - }, {}) -}; +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } -var deepmerge_1 = deepmerge; + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } -module.exports = deepmerge_1; + return r; +} -},{}],347:[function(require,module,exports){ -'use strict'; +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ -var $defineProperty = require('es-define-property'); +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } +} -var $SyntaxError = require('es-errors/syntax'); -var $TypeError = require('es-errors/type'); +module.exports = require('./common')(exports); -var gopd = require('gopd'); +const {formatters} = module.exports; -/** @type {import('.')} */ -module.exports = function defineDataProperty( - obj, - property, - value -) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new $TypeError('`obj` must be an object or a function`'); - } - if (typeof property !== 'string' && typeof property !== 'symbol') { - throw new $TypeError('`property` must be a string or a symbol`'); - } - if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { - throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); - } - if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { - throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); - } - if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { - throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); - } - if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { - throw new $TypeError('`loose`, if provided, must be a boolean'); +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; } +}; - var nonEnumerable = arguments.length > 3 ? arguments[3] : null; - var nonWritable = arguments.length > 4 ? arguments[4] : null; - var nonConfigurable = arguments.length > 5 ? arguments[5] : null; - var loose = arguments.length > 6 ? arguments[6] : false; +}).call(this)}).call(this,require('_process')) +},{"./common":341,"_process":429}],341:[function(require,module,exports){ - /* @type {false | TypedPropertyDescriptor} */ - var desc = !!gopd && gopd(obj, property); +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - if ($defineProperty) { - $defineProperty(obj, property, { - configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, - enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, - value: value, - writable: nonWritable === null && desc ? desc.writable : !nonWritable - }); - } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { - // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable - obj[property] = value; // eslint-disable-line no-param-reassign - } else { - throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); - } -}; +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + createDebug.destroy = destroy; -},{"es-define-property":387,"es-errors/syntax":392,"es-errors/type":393,"gopd":405}],348:[function(require,module,exports){ -'use strict'; + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); -var callBind = require('call-bind-apply-helpers'); -var gOPD = require('gopd'); + /** + * The currently active debug mode names, and names to skip. + */ -var hasProtoAccessor; -try { - // eslint-disable-next-line no-extra-parens, no-proto - hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype; -} catch (e) { - if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') { - throw e; - } -} + createDebug.names = []; + createDebug.skips = []; -// eslint-disable-next-line no-extra-parens -var desc = !!hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__')); + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; -var $Object = Object; -var $getPrototypeOf = $Object.getPrototypeOf; - -/** @type {import('./get')} */ -module.exports = desc && typeof desc.get === 'function' - ? callBind([desc.get]) - : typeof $getPrototypeOf === 'function' - ? /** @type {import('./get')} */ function getDunder(value) { - // eslint-disable-next-line eqeqeq - return $getPrototypeOf(value == null ? value : $Object(value)); - } - : false; + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; -},{"call-bind-apply-helpers":38,"gopd":405}],349:[function(require,module,exports){ -'use strict'; + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } -var elliptic = exports; + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; -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'); + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } -},{"../package.json":365,"./elliptic/curve":352,"./elliptic/curves":355,"./elliptic/ec":356,"./elliptic/eddsa":359,"./elliptic/utils":363,"brorand":31}],350:[function(require,module,exports){ -'use strict'; + const self = debug; -var BN = require('bn.js'); -var utils = require('../utils'); -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); + args[0] = createDebug.coerce(args[0]); - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } - // 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); + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); - this._bitLength = this.n ? this.n.bitLength() : 0; + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } - // 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; + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } - var naf = getNAF(k, 1, this._bitLength); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; + return debug; + } - // 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); - } + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } - 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(); -}; + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; + createDebug.names = []; + createDebug.skips = []; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; - // Get NAF form - var naf = getNAF(k, w, this._bitLength); + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - // 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); + namespaces = split[i].replace(/\*/g, '.*?'); - 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; -}; + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } + } -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; + } - // 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; - } + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } - // 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; - } + let i; + let len; - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b], /* 7 */ - ]; + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } - // 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()); - } + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } - 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 */ - ]; + return false; + } - 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; + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); + } - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (i = max; i >= 0; i--) { - var k = 0; + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } - 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; + createDebug.enable(createDebug.load()); - 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(); + return createDebug; +} - 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; +module.exports = setup; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); -}; +},{"ms":423}],342:[function(require,module,exports){ +'use strict'; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) + && !isSpecial(value) }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +function isNonNullObject(value) { + return !!value && typeof value === 'object' +} - var len = this.p.byteLength(); +function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); - // 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); + return stringValue === '[object RegExp]' + || stringValue === '[object Date]' + || isReactElement(value) +} - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); +// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 +var canUseSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - 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'); -}; +function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE +} -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; +function emptyTarget(val) { + return Array.isArray(val) ? [] : {} +} -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +function cloneUnlessOtherwiseSpecified(value, options) { + return (options.clone !== false && options.isMergeableObject(value)) + ? deepmerge(emptyTarget(value), value, options) + : value +} - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); +function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options) + }) +} - return [ 0x04 ].concat(x, this.getY().toArray('be', len)); -}; +function getMergeFunction(key, options) { + if (!options.customMerge) { + return deepmerge + } + var customMerge = options.customMerge(key); + return typeof customMerge === 'function' ? customMerge : deepmerge +} -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; +function getEnumerableOwnPropertySymbols(target) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(target).filter(function(symbol) { + return Object.propertyIsEnumerable.call(target, symbol) + }) + : [] +} -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; +function getKeys(target) { + return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) +} - 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; +function propertyIsOnObject(object, property) { + try { + return property in object + } catch(_) { + return false + } +} - return this; -}; +// Protects from prototype poisoning and unexpected merging up the prototype chain. +function propertyIsUnsafe(target, key) { + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, + && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, + && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. +} -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; +function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) { + getKeys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + } + getKeys(source).forEach(function(key) { + if (propertyIsUnsafe(target, key)) { + return + } - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { + destination[key] = getMergeFunction(key, options)(target[key], source[key], options); + } else { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + } + }); + return destination +} - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; +function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() + // implementations can use it. The caller may not replace it. + options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; - 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, - }; -}; + if (!sourceAndTargetTypesMatch) { + return cloneUnlessOtherwiseSpecified(source, options) + } else if (sourceIsArray) { + return options.arrayMerge(target, source, options) + } else { + return mergeObject(target, source, options) + } +} -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; +deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) { + throw new Error('first argument should be an array') + } - 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, - }; + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options) + }, {}) }; -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; +var deepmerge_1 = deepmerge; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +module.exports = deepmerge_1; -},{"../utils":363,"bn.js":364}],351:[function(require,module,exports){ +},{}],343:[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); +var $defineProperty = require('es-define-property'); - 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); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; +var gopd = require('gopd'); -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); -}; +/** @type {import('.')} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; - 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)); + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } +}; - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); +},{"es-define-property":381,"es-errors/syntax":386,"es-errors/type":387,"gopd":394}],344:[function(require,module,exports){ +'use strict'; - return this.point(x, y); -}; +var elliptic = exports; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); +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'); - // 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()); +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } +},{"../package.json":360,"./elliptic/curve":347,"./elliptic/curves":350,"./elliptic/ec":351,"./elliptic/eddsa":354,"./elliptic/utils":358,"brorand":31}],345:[function(require,module,exports){ +'use strict'; - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - return this.point(x, y); -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; + // 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: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - 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))); + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); - return lhs.cmp(rhs) === 0; -}; + this._bitLength = this.n ? this.n.bitLength() : 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; + // 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.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()); - } + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); } } -inherits(Point, Base.BasePoint); +module.exports = BaseCurve; -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); }; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); -}; +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; -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)); + // 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(); }; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; - // 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); -}; + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; -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 + // Get NAF form + var naf = getNAF(k, w, this._bitLength); - // 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(); + // 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); - 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); + 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 { - // 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); + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); } - } 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); + return p.type === 'affine' ? acc.toP() : acc; }; -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(); -}; +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M + // 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; + } - // 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); -}; + // 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; + } -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; - // 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); -}; + // 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()); + } -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; + 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 */ + ]; - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; + 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; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + 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; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + 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(); - // 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; -}; + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); + if (jacobianResult) + return acc; + else + return acc.toP(); }; -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); }; -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); }; -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); - 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; + var len = this.p.byteLength(); - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; + // 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'); }; -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],352:[function(require,module,exports){ -'use strict'; +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); -var curve = exports; + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; -},{"./base":350,"./edwards":351,"./mont":353,"./short":354}],353:[function(require,module,exports){ -'use strict'; +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); +}; -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; -var utils = require('../utils'); + 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; -function MontCurve(conf) { - Base.call(this, 'mont', conf); + return this; +}; - 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; +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; -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(); + var doubles = this.precomputed.doubles; + if (!doubles) + return false; - return y.redSqr().cmp(rhs) === 0; + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -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); +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); + 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, + }; }; -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); + 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, + }; }; -Point.prototype.precompute = function precompute() { - // No-op +BasePoint.prototype._getBeta = function _getBeta() { + return null; }; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; +},{"../utils":358,"bn.js":359}],346:[function(require,module,exports){ +'use strict'; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; +var assert = utils.assert; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A +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; - // 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); -}; + Base.call(this, 'edwards', conf); -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); -}; + 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); -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; +} +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; - // 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); +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); }; -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; +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); }; -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); }; -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; -}; + 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)); -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; -}; + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); - return this.x.fromRed(); + return this.point(x, y); }; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],354:[function(require,module,exports){ -'use strict'; +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + // 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()); -var assert = utils.assert; + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } -function ShortCurve(conf) { - Base.call(this, 'short', conf); + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - 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(); + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + return this.point(x, y); +}; - // 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; +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); - // 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); + 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 { - // 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); + 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); - // 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); - } +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; - return { - beta: beta, - lambda: lambda, - basis: basis, - }; +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); }; -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(); +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; +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)); }; -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - // 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); + // 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); +}; - // 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; +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 - 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)); + // 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(); - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; + 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); } - 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(); + } 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 [ - { a: a1, b: b1 }, - { a: a2, b: b2 }, - ]; + return this.curve.point(nx, ny, nz); }; -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); +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); }; -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(); +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return this.point(x, y); + // 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); }; -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; - }; +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S -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; + // 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 { - 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; + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); } -} -inherits(Point, Base.BasePoint); - -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); + return this.curve.point(nx, ny, nz); }; -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); +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._getBeta = function _getBeta() { - if (!this.curve.endo) - return; +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; - 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.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; - 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), - }, - } ]; + // 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.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); - } +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; - 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.getX = function getX() { + this.normalize(); + return this.x.fromRed(); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; - // P + O = P - if (p.inf) - return this; + 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; - // P + P = 2P - if (this.eq(p)) - return this.dbl(); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],347:[function(require,module,exports){ +'use strict'; - 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); -}; +var curve = exports; -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); +},{"./base":345,"./edwards":346,"./mont":348,"./short":349}],348:[function(require,module,exports){ +'use strict'; - var a = this.curve.a; +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); +var utils = require('../utils'); - 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); +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; }; -Point.prototype.getX = function getX() { - return this.x.fromRed(); +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); }; -Point.prototype.getY = function getY() { - return this.y.fromRed(); +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); }; -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); +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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.precompute = function precompute() { + // No-op }; -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._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); }; -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.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); }; -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - 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.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; + // 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); }; -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); +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - this.zOne = this.z === this.curve.one; -} -inherits(JPoint, Base.BasePoint); +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); + // 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); }; -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); +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 - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); - return this.curve.point(ax, ay); + 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; }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); }; -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - // P + O = P - if (p.isInfinity()) - return this; +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - // 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); +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; - 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); +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - return this.curve.jpoint(nx, ny, nz); + return this.x.fromRed(); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],349:[function(require,module,exports){ +'use strict'; - // P + O = P - if (p.isInfinity()) - return this; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - // 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 assert = utils.assert; - 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(); - } +function ShortCurve(conf) { + Base.call(this, 'short', conf); - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); + 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(); - 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); + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - return this.curve.jpoint(nx, ny, nz); -}; + // 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; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - var i; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (i = 0; i < pow; i++) - r = r.dbl(); - return r; + // 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); + } } - // 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; + // 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 this.curve.jpoint(jx, jyd.redMul(tinv), jz); + return { + beta: beta, + lambda: lambda, + basis: basis, + }; }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +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(); - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); + 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 ]; }; -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 +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - // 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); + // 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); - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); + // 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; - // 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 + 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)); - // 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); + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - // 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); + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; } + a2 = r.neg(); + b2 = x; - 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 + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } - // 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); + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); } - return this.curve.jpoint(nx, ny, nz); + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; }; -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)); +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - 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 c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); - 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); + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); - return this.curve.jpoint(nx, ny, nz); + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; }; -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); +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - return this.curve.jpoint(nx, ny, nz); -}; + 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'); -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); + // 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.curve._wnafMul(this, k); + return this.point(x, y); }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); - - if (this === p) +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) 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; + var x = point.x; + var y = point.y; - // 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; + 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; }; -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; +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(); - 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; + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return 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); -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); }; -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); }; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],355:[function(require,module,exports){ -'use strict'; +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; -var curves = exports; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; -var hash = require('hash.js'); -var curve = require('./curve'); -var utils = require('./utils'); + 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; +}; -var assert = utils.assert; +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; -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; + 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), + }, + } ]; +}; - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; +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 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; + 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; +}; -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', - ], -}); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; -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', - ], -}); +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; -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', - ], -}); +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; -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', - ], -}); + // P + O = P + if (p.inf) + return this; -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', - ], -}); + // P + P = 2P + if (this.eq(p)) + return this.dbl(); -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', - ], -}); + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); -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', + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658', - ], -}); + 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); +}; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; -} +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; -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, + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3', - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15', - }, - ], + var a = this.curve.a; - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre, - ], -}); + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); -},{"./curve":352,"./precomputed/secp256k1":362,"./utils":363,"hash.js":409}],356:[function(require,module,exports){ -'use strict'; + 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); +}; -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; +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; -var KeyPair = require('./key'); -var Signature = require('./signature'); +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); +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); +}; - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(Object.prototype.hasOwnProperty.call(curves, options), - 'Unknown curve ' + options); +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); +}; - options = curves[options]; +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; +}; - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof curves.PresetCurve) - options = { curve: options }; +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); +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); - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; + this.zOne = this.z === this.curve.one; } -module.exports = EC; +inherits(JPoint, Base.BasePoint); -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); }; -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); +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); }; -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; - // 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, bitLength) { - var byteLength; - if (BN.isBN(msg) || typeof msg === 'number') { - msg = new BN(msg, 16); - byteLength = msg.byteLength(); - } else if (typeof msg === 'object') { - // BN assumes an array-like input and asserts length - byteLength = msg.length; - msg = new BN(msg, 16); - } else { - // BN converts the value to string - var str = msg.toString(); - // HEX encoding - byteLength = (str.length + 1) >>> 1; - msg = new BN(str, 16); - } - // Allow overriding - if (typeof bitLength !== 'number') { - bitLength = byteLength * 8; - } - var delta = bitLength - 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; -}; + // P + O = P + if (p.isInfinity()) + return this; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; + // 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)); - if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) { - assert(typeof msg === 'object' && msg && typeof msg.length === 'number', - 'Expected message to be an array-like, a hex string, or a BN instance'); - assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer - for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]); + 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(); } - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(msg, false, options.msgBitLength); - - // Would fail further checks, but let's make the error message clear - assert(!msg.isNeg(), 'Can not sign a negative message'); - - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + 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); - // Recheck nonce to be bijective to msg - assert((new BN(nonce)).eq(msg), 'Can not sign message'); + return this.curve.jpoint(nx, ny, nz); +}; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - }); +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); + // P + O = P + if (p.isInfinity()) + return this; - 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; + // 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 kp = this.g.mul(k); - if (kp.isInfinity()) - continue; + 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 kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - 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 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); - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); + return this.curve.jpoint(nx, ny, nz); +}; - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; } -}; - -EC.prototype.verify = function verify(msg, signature, key, enc, options) { - if (!options) - options = {}; - msg = this._truncateToN(msg, false, options.msgBitLength); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; - // 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; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - // 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; + // 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)); - if (!this.curve._maxwellTrick) { - p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + 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); - return p.getX().umod(this.n).cmp(r) === 0; + jx = nx; + jz = nz; + jyd = dny; } - // 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); + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; -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'); +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); 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); + return this._dbl(); }; -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; +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 - 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":355,"../utils":363,"./key":357,"./signature":358,"bn.js":364,"brorand":31,"hmac-drbg":422}],357:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; + // 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); -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); - // 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; + // 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 -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; + // 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(); - return new KeyPair(ec, { - pub: pub, - pubEnc: enc, - }); -}; + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; + // 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 new KeyPair(ec, { - priv: priv, - privEnc: enc, - }); + return this.curve.jpoint(nx, ny, nz); }; -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' }; +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 - return { result: true, reason: null }; -}; + // 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 -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; + // 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); } - 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; + return this.curve.jpoint(nx, ny, nz); }; -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; - // 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); -}; + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -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); -}; + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); -// ECDH -KeyPair.prototype.derive = function derive(pub) { - if(!pub.validate()) { - assert(pub.validate(), 'public point not validated'); - } - return pub.mul(this.priv).getX(); -}; + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; + 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); -KeyPair.prototype.verify = function verify(msg, signature, options) { - return this.ec.verify(msg, signature, this, undefined, options); -}; + 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); -KeyPair.prototype.inspect = function inspect() { - return ''; + return this.curve.jpoint(nx, ny, nz); }; -},{"../utils":363,"bn.js":364}],358:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); - -var utils = require('../utils'); -var assert = utils.assert; +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); -function Signature(options, enc) { - if (options instanceof Signature) - return options; + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - 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; + // 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); -function Position() { - this.place = 0; -} + return this.curve.jpoint(nx, ny, nz); +}; -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); - // Indefinite length or overflow - if (octetLen === 0 || octetLen > 4) { - return false; - } + return this.curve._wnafMul(this, k); +}; - if(buf[p.place] === 0x00) { - return false; - } +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - val >>>= 0; - } + if (this === p) + return true; - // Leading zeroes - if (val <= 0x7f) { + // 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; - } - p.place = off; - return val; -} + // 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; +}; -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); -} +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; -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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - if ((data[p.place] & 128) !== 0) { - 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 + 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; - } - } - - 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); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - 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); +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - 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); +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -},{"../utils":363,"bn.js":364}],359:[function(require,module,exports){ +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],350:[function(require,module,exports){ 'use strict'; +var curves = exports; + 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'); +var curve = require('./curve'); +var utils = require('./utils'); -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); +var assert = utils.assert; - if (!(this instanceof EDDSA)) - return new EDDSA(curve); +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; - curve = curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; +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; + }, + }); } -module.exports = EDDSA; +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', + ], +}); -/** -* @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 }); -}; +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', + ], +}); -/** -* @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); - if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) { - return false; - } - 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); -}; +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', + ], +}); -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); -}; +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', + ], +}); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; +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', + ], +}); -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; +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', + ], +}); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; +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', -/** -* * 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; -}; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; +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, - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; - -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; - -},{"../curves":355,"../utils":363,"./key":360,"./signature":361,"hash.js":409}],360:[function(require,module,exports){ -'use strict'; +},{"./curve":347,"./precomputed/secp256k1":357,"./utils":358,"hash.js":399}],351:[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 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); -} +var KeyPair = require('./key'); +var Signature = require('./signature'); -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); -KeyPair.prototype.secret = function secret() { - return this._secret; -}; + options = curves[options]; + } -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; - return a; -}); +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); +}; -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); +}; -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); +}; -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + // 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(), + }); -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + 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; -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); + priv.iaddn(1); + return this.keyFromPrivate(priv); + } }; -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); +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; }; -module.exports = KeyPair; - -},{"../utils":363}],361:[function(require,module,exports){ -'use strict'; +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); -/** -* @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; + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); - if (typeof sig !== 'object') - sig = parseBytes(sig); + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); - if (Array.isArray(sig)) { - assert(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size'); - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength), - }; - } + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); - assert(sig.R && sig.S, 'Signature without R or S'); + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; + 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; - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + } }; -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); -}; +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'); -module.exports = Signature; + // 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; -},{"../utils":363,"bn.js":364}],362:[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', - ], - ], - }, -}; - -},{}],363:[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); - var i; - for (i = 0; i < naf.length; i += 1) { - naf[i] = 0; - } - - var ws = 1 << (w + 1); - var k = num.clone(); - - for (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":364,"minimalistic-assert":439,"minimalistic-crypto-utils":440}],364:[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; - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - } - 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); - }; + // 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; - // 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); - }; + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; + return p.getX().umod(this.n).cmp(r) === 0; + } - BN.prototype.imuln = function imuln (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K - // 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; - } + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } + // 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); +}; - return this; - }; +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); - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; + // 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'); - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; + // 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); - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - res = res.mul(q); - } + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - 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 (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; - if (carry) { - this.words[i] = carry; - this.length++; - } - } +},{"../curves":350,"../utils":358,"./key":352,"./signature":353,"bn.js":359,"brorand":31,"hmac-drbg":412}],352:[function(require,module,exports){ +'use strict'; - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; - for (i = 0; i < s; i++) { - this.words[i] = 0; - } +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; - this.length += s; - } + // 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; - return this.strip(); - }; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); +}; - // 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; - } +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); +}; - h -= s; - h = Math.max(0, h); +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } + 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' }; - 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; - } + return { result: true, reason: null }; +}; - 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; - } +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } + if (!enc) + return this.pub; - return this.strip(); - }; + return this.pub.encode(enc, compact); +}; - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; + // 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); +}; - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; +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); +}; - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - // 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; +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; - // Check bit and return - var w = this.words[s]; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - return !!(w & q); - }; +},{"../utils":358,"bn.js":359}],353:[function(require,module,exports){ +'use strict'; - // 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; +var BN = require('bn.js'); - assert(this.negative === 0, 'imaskn works only with positive numbers'); +var utils = require('../utils'); +var assert = utils.assert; - if (this.length <= s) { - return this; - } +function Signature(options, enc) { + if (options instanceof Signature) + return options; - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); + if (this._importDER(options, enc)) + return; - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } + 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; - return this.strip(); - }; +function Position() { + this.place = 0; +} - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; - // 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); + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } - // 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; - } + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } + // Leading zeroes + if (val <= 0x7f) { + return false; + } - // Add without checks - return this._iaddn(num); - }; + p.place = off; + return val; +} - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; +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); +} - // 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]++; - } +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; } - this.length = Math.max(this.length, i + 1); + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } - return this; - }; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; +}; - // 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); +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); +} - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); - this.words[0] -= num; + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - 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; - } - } + r = rmPadding(r); + s = rmPadding(s); - return this.strip(); - }; + 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); +}; - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; +},{"../utils":358,"bn.js":359}],354:[function(require,module,exports){ +'use strict'; - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; +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'); - BN.prototype.iabs = function iabs () { - this.negative = 0; +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - return this; - }; + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - this._expand(len); +module.exports = EDDSA; - 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; - } +/** +* @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 }); +}; - if (carry === 0) return this.strip(); +/** +* @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); +}; - // 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; +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); +}; - return this.strip(); - }; +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; - var a = this.clone(); - var b = num; +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - // 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; - } +/** +* * 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; +}; - // Initialize quotient - var m = a.length - b.length; - var q; +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - 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 lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - 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(); +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } +},{"../curves":350,"../utils":358,"./key":355,"./signature":356,"hash.js":399}],355:[function(require,module,exports){ +'use strict'; - return { - div: q || null, - mod: a - }; - }; +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; - // 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()); +/** +* @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); +} - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); +}; - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - if (mode !== 'mod') { - div = res.div.neg(); - } +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - return { - div: div, - mod: mod - }; - } +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - if (mode !== 'mod') { - div = res.div.neg(); - } + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - return { - div: div, - mod: res.mod - }; - } + return a; +}); - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - return { - div: res.div, - mod: mod - }; - } +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // Both numbers are positive at this point +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } +module.exports = KeyPair; - return this._wordDiv(num, mode); - }; +},{"../utils":358}],356:[function(require,module,exports){ +'use strict'; - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; +/** +* @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; - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; + if (typeof sig !== 'object') + sig = parseBytes(sig); - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; + assert(sig.R && sig.S, 'Signature without R or S'); - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); - return acc; - }; +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; - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); +},{"../utils":358,"bn.js":359}],357:[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', + ], + ], + }, +}; - 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; - } +},{}],358:[function(require,module,exports){ +'use strict'; - return this.strip(); - }; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + var i; + for (i = 0; i < naf.length; i += 1) { + naf[i] = 0; + } - var x = this; - var y = p.clone(); + var ws = 1 << (w + 1); + var k = num.clone(); - if (x.negative !== 0) { - x = x.umod(p); + for (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 { - x = x.clone(); + z = 0; } - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); + naf[i] = z; + k.iushrn(1); + } - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); + return naf; +} +utils.getNAF = getNAF; - var g = 0; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; + 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 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); - } + 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); - 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(); + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } + return jsf; +} +utils.getJSF = getJSF; - var x1 = new BN(1); - var x2 = new BN(0); +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; - var delta = b.clone(); +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; - 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); - } +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; - 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); - } +},{"bn.js":359,"minimalistic-assert":421,"minimalistic-crypto-utils":422}],359:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; - x2.iushrn(1); - } - } + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } + // 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; + } - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } + // BN - if (res.cmpn(0) < 0) { - res.iadd(p); + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; } - 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; + this.negative = 0; + this.words = null; + this.length = 0; - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } + // Reduction context + this.red = null; - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; } - 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; - } + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } - a.isub(b); - } while (true); + BN.BN = BN; + BN.wordSize = 26; - return b.iushln(shift); - }; + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); }; - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; }; - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; }; - // 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; + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; + if (typeof number === 'object') { + return this._initArray(number, base, endian); } - // 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 (base === 'hex') { + base = 16; } - if (carry !== 0) { - this.words[i] = carry; - this.length++; + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; } - return this; - }; - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; + 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.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; + 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 { - 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; + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; } - 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; + if (endian !== 'le') return; - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; + // Reverse the bytes + this._initArray(this.toArray(), base, endian); }; - // 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; + 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; + } - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; + 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; + } - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; + 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++; + } } - 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; + return this.strip(); }; - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; + 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; + } + } - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; + 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; + } - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; + // 24-bits chunks + var off = 0; + var j = 0; - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 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; + } + } + } - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; + this.strip(); }; - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; + 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; - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; + r *= mul; - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; - 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); - }; + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; + // '0' - '9' + } else { + r += c; + } + } + return r; + } - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; + for (i = 0; i < mod; i++) { + pow *= base; + } - 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); - }; + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } - 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); + this.strip(); }; - 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.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.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; }; - // 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._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; }; - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(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(); }; - // 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._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; }; - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); + BN.prototype.inspect = function inspect () { + return (this.red ? ''; }; - // 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); + var zeros = []; + var groupSizes = []; + var groupBases = []; - this.tmp = this._tmp(); + 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; } - 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; + 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' + ]; - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); + 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 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(); + 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; } - return r; - }; + 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); - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); + 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'); }; - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); + 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; }; - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } + 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'); - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); - 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; - } - }; + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - // 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); - } + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; + res[i] = b; } - } - return num; - }; - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); + for (; i < reqLength; i++) { + res[i] = 0; + } + } - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); + return res; + }; - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + 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; + }; } - 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; + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - num.words[i] = lo; - carry = hi; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; } - if (carry !== 0) { - num.words[num.length++] = carry; + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; } - return num; + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; }; - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; + // 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; + }; - 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; + function toBitArray (num) { + var w = new Array(num.bitLength()); - return prime; - }; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - // - // 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; + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; } + + return w; } - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - 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'); + 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; }; - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(this); + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); }; - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); } - - return this.m.sub(a)._forceRed(this); + return this.clone(); }; - 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); + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); } - return res._forceRed(this); + return this.clone(); }; - 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; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; }; - 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); + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); }; - 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); + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; } - return res; - }; - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); + return this; }; - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; + // 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]; + } - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); + return this.strip(); }; - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); }; - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); + // 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); }; - 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); - } + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - // 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); + // 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; } - 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); + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; } - 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)); + this.length = b.length; - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } + return this.strip(); + }; - return r; + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); }; - 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); - } + // 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); }; - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - 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); + // 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; } - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; } - 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; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; } - start = 26; } - return res; + this.length = a.length; + + return this.strip(); }; - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; - return r === num ? r.clone() : r; + // 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); }; - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); }; - // - // Montgomery method engine - // + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - BN.mont = function mont (num) { - return new Mont(num); - }; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - function Mont (m) { - Red.call(this, m); + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); + if (bitsLeft > 0) { + bytesNeeded--; } - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - 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); + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); + // And remove leading zeroes + return this.strip(); }; - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); }; - 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); - } + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - return res._forceRed(this); - }; + var off = (bit / 26) | 0; + var wbit = bit % 26; - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + this._expand(off + 1); - 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); + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); } - 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); + return this.strip(); }; -})(typeof module === 'undefined' || module, this); -},{"buffer":32}],365:[function(require,module,exports){ -module.exports={ - "name": "elliptic", - "version": "6.6.1", - "description": "EC cryptography", - "main": "lib/elliptic.js", - "files": [ - "lib" - ], - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "test": "npm run lint && npm run unit", - "version": "grunt dist && git add dist/" - }, - "repository": { - "type": "git", - "url": "git@github.com:indutny/elliptic" - }, - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "author": "Fedor Indutny ", - "license": "MIT", - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "homepage": "https://github.com/indutny/elliptic", - "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" - }, - "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" - } -} + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; -},{}],366:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hasCORS = void 0; -// imported from https://github.com/component/has-cors -let value = false; -try { - value = typeof XMLHttpRequest !== 'undefined' && - 'withCredentials' in new XMLHttpRequest(); -} -catch (err) { - // if XMLHttp support is disabled in IE then it will throw - // when trying to create -} -exports.hasCORS = value; + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); -},{}],367:[function(require,module,exports){ -"use strict"; -// imported from https://github.com/galkn/querystring -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encode = encode; -exports.decode = decode; -function encode(obj) { - let str = ''; - for (let i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) - str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - return str; -} -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ -function decode(qs) { - let qry = {}; - let pairs = qs.split('&'); - for (let i = 0, l = pairs.length; i < l; i++) { - let pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); } - return qry; -} -},{}],368:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.parse = parse; -// imported from https://github.com/galkn/parseuri -/** - * Parses a URI - * - * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. - * - * See: - * - https://developer.mozilla.org/en-US/docs/Web/API/URL - * - https://caniuse.com/url - * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B - * - * History of the parse() method: - * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c - * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 - * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 - * - * @author Steven Levithan (MIT license) - * @api private - */ -const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; -const parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; -function parse(str) { - if (str.length > 8000) { - throw "URI too long"; - } - const src = str, b = str.indexOf('['), e = str.indexOf(']'); - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; } - let m = re.exec(str || ''), uri = {}, i = 14; - while (i--) { - uri[parts[i]] = m[i] || ''; + + 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; } - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; } - uri.pathNames = pathNames(uri, uri['path']); - uri.queryKey = queryKey(uri, uri['query']); - return uri; -} -function pathNames(obj, path) { - const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); - if (path.slice(0, 1) == '/' || path.length === 0) { - names.splice(0, 1); + + 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]; + } } - if (path.slice(-1) == '/') { - names.splice(names.length - 1, 1); + + 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; } - return names; -} -function queryKey(uri, query) { - const data = {}; - query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { - if ($1) { - data[$1] = $2; - } - }); - return data; -} -},{}],369:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.defaultBinaryType = exports.globalThisShim = exports.nextTick = void 0; -exports.createCookieJar = createCookieJar; -exports.nextTick = (() => { - const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; - if (isPromiseAvailable) { - return (cb) => Promise.resolve().then(cb); + 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(); } - else { - return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + + // 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; } -})(); -exports.globalThisShim = (() => { - if (typeof self !== "undefined") { - return self; + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; } - else if (typeof window !== "undefined") { - return window; + + 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; } - else { - return Function("return this")(); + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; } -})(); -exports.defaultBinaryType = "arraybuffer"; -function createCookieJar() { } -},{}],370:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0; -const socket_js_1 = require("./socket.js"); -Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); -var socket_js_2 = require("./socket.js"); -Object.defineProperty(exports, "SocketWithoutUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }); -Object.defineProperty(exports, "SocketWithUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }); -exports.protocol = socket_js_1.Socket.protocol; -var transport_js_1 = require("./transport.js"); -Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); -Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); -var index_js_1 = require("./transports/index.js"); -Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); -var util_js_1 = require("./util.js"); -Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); -var parseuri_js_1 = require("./contrib/parseuri.js"); -Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); -var globals_node_js_1 = require("./globals.node.js"); -Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return globals_node_js_1.nextTick; } }); -var polling_fetch_js_1 = require("./transports/polling-fetch.js"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return polling_fetch_js_1.Fetch; } }); -var polling_xhr_node_js_1 = require("./transports/polling-xhr.node.js"); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return polling_xhr_node_js_1.XHR; } }); -var polling_xhr_js_1 = require("./transports/polling-xhr.js"); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return polling_xhr_js_1.XHR; } }); -var websocket_node_js_1 = require("./transports/websocket.node.js"); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return websocket_node_js_1.WS; } }); -var websocket_js_1 = require("./transports/websocket.js"); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return websocket_js_1.WS; } }); -var webtransport_js_1 = require("./transports/webtransport.js"); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return webtransport_js_1.WT; } }); - -},{"./contrib/parseuri.js":368,"./globals.node.js":369,"./socket.js":371,"./transport.js":372,"./transports/index.js":373,"./transports/polling-fetch.js":374,"./transports/polling-xhr.js":375,"./transports/polling-xhr.node.js":375,"./transports/websocket.js":377,"./transports/websocket.node.js":377,"./transports/webtransport.js":378,"./util.js":379}],371:[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.Socket = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = void 0; -const index_js_1 = require("./transports/index.js"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const parseuri_js_1 = require("./contrib/parseuri.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("./globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() -const withEventListeners = typeof addEventListener === "function" && - typeof removeEventListener === "function"; -const OFFLINE_EVENT_LISTENERS = []; -if (withEventListeners) { - // within a ServiceWorker, any event handler for the 'offline' event must be added on the initial evaluation of the - // script, so we create one single event listener here which will forward the event to the socket instances - addEventListener("offline", () => { - debug("closing %d connection(s) because the network was lost", OFFLINE_EVENT_LISTENERS.length); - OFFLINE_EVENT_LISTENERS.forEach((listener) => listener()); - }, false); -} -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that - * successfully establishes the connection. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithoutUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithoutUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithUpgrade - * @see Socket - */ -class SocketWithoutUpgrade extends component_emitter_1.Emitter { - /** - * Socket constructor. - * - * @param {String|Object} uri - uri or options - * @param {Object} opts - options - */ - constructor(uri, opts) { - super(); - this.binaryType = globals_node_js_1.defaultBinaryType; - this.writeBuffer = []; - this._prevBufferLen = 0; - this._pingInterval = -1; - this._pingTimeout = -1; - this._maxPayload = -1; - /** - * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the - * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked. - */ - this._pingTimeoutTime = Infinity; - if (uri && "object" === typeof uri) { - opts = uri; - uri = null; - } - if (uri) { - const parsedUri = (0, parseuri_js_1.parse)(uri); - opts.hostname = parsedUri.host; - opts.secure = - parsedUri.protocol === "https" || parsedUri.protocol === "wss"; - opts.port = parsedUri.port; - if (parsedUri.query) - opts.query = parsedUri.query; - } - else if (opts.host) { - opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; - } - (0, util_js_1.installTimerFunctions)(this, opts); - this.secure = - null != opts.secure - ? opts.secure - : typeof location !== "undefined" && "https:" === location.protocol; - if (opts.hostname && !opts.port) { - // if no port is specified manually, use the protocol default - opts.port = this.secure ? "443" : "80"; - } - this.hostname = - opts.hostname || - (typeof location !== "undefined" ? location.hostname : "localhost"); - this.port = - opts.port || - (typeof location !== "undefined" && location.port - ? location.port - : this.secure - ? "443" - : "80"); - this.transports = []; - this._transportsByName = {}; - opts.transports.forEach((t) => { - const transportName = t.prototype.name; - this.transports.push(transportName); - this._transportsByName[transportName] = t; - }); - this.opts = Object.assign({ - path: "/engine.io", - agent: false, - withCredentials: false, - upgrade: true, - timestampParam: "t", - rememberUpgrade: false, - addTrailingSlash: true, - rejectUnauthorized: true, - perMessageDeflate: { - threshold: 1024, - }, - transportOptions: {}, - closeOnBeforeunload: false, - }, opts); - this.opts.path = - this.opts.path.replace(/\/$/, "") + - (this.opts.addTrailingSlash ? "/" : ""); - if (typeof this.opts.query === "string") { - this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); - } - if (withEventListeners) { - if (this.opts.closeOnBeforeunload) { - // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener - // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is - // closed/reloaded) - this._beforeunloadEventListener = () => { - if (this.transport) { - // silently close the transport - this.transport.removeAllListeners(); - this.transport.close(); - } - }; - addEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this.hostname !== "localhost") { - debug("adding listener for the 'offline' event"); - this._offlineEventListener = () => { - this._onClose("transport close", { - description: "network connection lost", - }); - }; - OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener); - } - } - if (this.opts.withCredentials) { - this._cookieJar = (0, globals_node_js_1.createCookieJar)(); - } - this._open(); + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } } - /** - * Creates transport of the given type. - * - * @param {String} name - transport name - * @return {Transport} - * @private - */ - createTransport(name) { - debug('creating transport "%s"', name); - const query = Object.assign({}, this.opts.query); - // append engine.io protocol identifier - query.EIO = engine_io_parser_1.protocol; - // transport name - query.transport = name; - // session id if we already have one - if (this.id) - query.sid = this.id; - const opts = Object.assign({}, this.opts, { - query, - socket: this, - hostname: this.hostname, - secure: this.secure, - port: this.port, - }, this.opts.transportOptions[name]); - debug("options: %j", opts); - return new this._transportsByName[name](opts); + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; } - /** - * Initializes transport to use and starts probe. - * - * @private - */ - _open() { - if (this.transports.length === 0) { - // Emit error on next tick so it can be listened to - this.setTimeoutFn(() => { - this.emitReserved("error", "No transports available"); - }, 0); - return; - } - const transportName = this.opts.rememberUpgrade && - SocketWithoutUpgrade.priorWebsocketSuccess && - this.transports.indexOf("websocket") !== -1 - ? "websocket" - : this.transports[0]; - this.readyState = "opening"; - const transport = this.createTransport(transportName); - transport.open(); - this.setTransport(transport); + + 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; } - /** - * Sets the current transport. Disables the existing one (if any). - * - * @private - */ - setTransport(transport) { - debug("setting transport %s", transport.name); - if (this.transport) { - debug("clearing existing transport %s", this.transport.name); - this.transport.removeAllListeners(); - } - // set up transport - this.transport = transport; - // set up transport listeners - transport - .on("drain", this._onDrain.bind(this)) - .on("packet", this._onPacket.bind(this)) - .on("error", this._onError.bind(this)) - .on("close", (reason) => this._onClose("transport close", reason)); + 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++; } - /** - * Called when connection is deemed open. - * - * @private - */ - onOpen() { - debug("socket open"); - this.readyState = "open"; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === this.transport.name; - this.emitReserved("open"); - this.flush(); + 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; } - /** - * Handles a packet. - * - * @private - */ - _onPacket(packet) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket receive: type "%s", data "%s"', packet.type, packet.data); - this.emitReserved("packet", packet); - // Socket is live - any packet counts - this.emitReserved("heartbeat"); - switch (packet.type) { - case "open": - this.onHandshake(JSON.parse(packet.data)); - break; - case "ping": - this._sendPacket("pong"); - this.emitReserved("ping"); - this.emitReserved("pong"); - this._resetPingTimeout(); - break; - case "error": - const err = new Error("server error"); - // @ts-ignore - err.code = packet.data; - this._onError(err); - break; - case "message": - this.emitReserved("data", packet.data); - this.emitReserved("message", packet.data); - break; - } - } - else { - debug('packet received with socket readyState "%s"', this.readyState); - } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; } - /** - * Called upon handshake completion. - * - * @param {Object} data - handshake obj - * @private - */ - onHandshake(data) { - this.emitReserved("handshake", data); - this.id = data.sid; - this.transport.query.sid = data.sid; - this._pingInterval = data.pingInterval; - this._pingTimeout = data.pingTimeout; - this._maxPayload = data.maxPayload; - this.onOpen(); - // In case open handler closes socket - if ("closed" === this.readyState) - return; - this._resetPingTimeout(); + + 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); } - /** - * Sets and resets ping timeout timer based on server pings. - * - * @private - */ - _resetPingTimeout() { - this.clearTimeoutFn(this._pingTimeoutTimer); - const delay = this._pingInterval + this._pingTimeout; - this._pingTimeoutTime = Date.now() + delay; - this._pingTimeoutTimer = this.setTimeoutFn(() => { - this._onClose("ping timeout"); - }, delay); - if (this.opts.autoUnref) { - this._pingTimeoutTimer.unref(); - } + + 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); } - /** - * Called on `drain` event - * - * @private - */ - _onDrain() { - this.writeBuffer.splice(0, this._prevBufferLen); - // setting prevBufferLen = 0 is very important - // for example, when upgrading, upgrade packet is sent over, - // and a nonzero prevBufferLen could cause problems on `drain` - this._prevBufferLen = 0; - if (0 === this.writeBuffer.length) { - this.emitReserved("drain"); - } - else { - this.flush(); - } + + 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; } - /** - * Flush write buffers. - * - * @private - */ - flush() { - if ("closed" !== this.readyState && - this.transport.writable && - !this.upgrading && - this.writeBuffer.length) { - const packets = this._getWritablePackets(); - debug("flushing %d packets in socket", packets.length); - this.transport.send(packets); - // keep track of current length of writeBuffer - // splice writeBuffer and callbackBuffer on `drain` - this._prevBufferLen = packets.length; - this.emitReserved("flush"); - } + + 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]]; } - /** - * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP - * long-polling) - * - * @private - */ - _getWritablePackets() { - const shouldCheckPayloadSize = this._maxPayload && - this.transport.name === "polling" && - this.writeBuffer.length > 1; - if (!shouldCheckPayloadSize) { - return this.writeBuffer; - } - let payloadSize = 1; // first packet type - for (let i = 0; i < this.writeBuffer.length; i++) { - const data = this.writeBuffer[i].data; - if (data) { - payloadSize += (0, util_js_1.byteLength)(data); - } - if (i > 0 && payloadSize > this._maxPayload) { - debug("only send %d out of %d packets", i, this.writeBuffer.length); - return this.writeBuffer.slice(0, i); - } - payloadSize += 2; // separator + packet type + }; + + 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; + } } - debug("payload size is %d (max: %d)", payloadSize, this._maxPayload); - return this.writeBuffer; + } } - /** - * Checks whether the heartbeat timer has expired but the socket has not yet been notified. - * - * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the - * `write()` method then the message would not be buffered by the Socket.IO client. - * - * @return {boolean} - * @private - */ - /* private */ _hasPingExpired() { - if (!this._pingTimeoutTime) - return true; - const hasExpired = Date.now() > this._pingTimeoutTime; - if (hasExpired) { - debug("throttled timer detected, scheduling connection close"); - this._pingTimeoutTime = 0; - (0, globals_node_js_1.nextTick)(() => { - this._onClose("ping timeout"); - }, this.setTimeoutFn); - } - return hasExpired; + }; + + 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++; } - /** - * Sends a message. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - write(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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; } - /** - * Sends a message. Alias of {@link Socket#write}. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - send(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + }; + + 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; + } } - /** - * Sends a packet. - * - * @param {String} type: packet type. - * @param {String} data. - * @param {Object} options. - * @param {Function} fn - callback function. - * @private - */ - _sendPacket(type, data, options, fn) { - if ("function" === typeof data) { - fn = data; - data = undefined; - } - if ("function" === typeof options) { - fn = options; - options = null; - } - if ("closing" === this.readyState || "closed" === this.readyState) { - return; - } - options = options || {}; - options.compress = false !== options.compress; - const packet = { - type: type, - data: data, - options: options, - }; - this.emitReserved("packetCreate", packet); - this.writeBuffer.push(packet); - if (fn) - this.once("flush", fn); - this.flush(); + + 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; } - /** - * Closes the connection. - */ - close() { - const close = () => { - this._onClose("forced close"); - debug("socket closing - telling transport to close"); - this.transport.close(); - }; - const cleanupAndClose = () => { - this.off("upgrade", cleanupAndClose); - this.off("upgradeError", cleanupAndClose); - close(); - }; - const waitForUpgrade = () => { - // wait for upgrade to finish since we can't send packets while pausing a transport - this.once("upgrade", cleanupAndClose); - this.once("upgradeError", cleanupAndClose); - }; - if ("opening" === this.readyState || "open" === this.readyState) { - this.readyState = "closing"; - if (this.writeBuffer.length) { - this.once("drain", () => { - if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - }); - } - else if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - } - return this; + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; } - /** - * Called upon transport error - * - * @private - */ - _onError(err) { - debug("socket error %j", err); - SocketWithoutUpgrade.priorWebsocketSuccess = false; - if (this.opts.tryAllTransports && - this.transports.length > 1 && - this.readyState === "opening") { - debug("trying next transport"); - this.transports.shift(); - return this._open(); - } - this.emitReserved("error", err); - this._onClose("transport error", err); + + 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; } - /** - * Called upon transport close. - * - * @private - */ - _onClose(reason, description) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket close with reason: "%s"', reason); - // clear timers - this.clearTimeoutFn(this._pingTimeoutTimer); - // stop event from firing again for transport - this.transport.removeAllListeners("close"); - // ensure transport won't stay open - this.transport.close(); - // ignore further transport communication - this.transport.removeAllListeners(); - if (withEventListeners) { - if (this._beforeunloadEventListener) { - removeEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this._offlineEventListener) { - const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener); - if (i !== -1) { - debug("removing listener for the 'offline' event"); - OFFLINE_EVENT_LISTENERS.splice(i, 1); - } - } - } - // set ready state - this.readyState = "closed"; - // clear session id - this.id = null; - // emit close event - this.emitReserved("close", reason, description); - // clean buffers after, so users can still - // grab the buffers on `close` event - this.writeBuffer = []; - this._prevBufferLen = 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; } -} -exports.SocketWithoutUpgrade = SocketWithoutUpgrade; -SocketWithoutUpgrade.protocol = engine_io_parser_1.protocol; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see Socket - */ -class SocketWithUpgrade extends SocketWithoutUpgrade { - constructor() { - super(...arguments); - this._upgrades = []; + + 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; } - onOpen() { - super.onOpen(); - if ("open" === this.readyState && this.opts.upgrade) { - debug("starting upgrade probes"); - for (let i = 0; i < this._upgrades.length; i++) { - this._probe(this._upgrades[i]); - } - } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Probes a transport. - * - * @param {String} name - transport name - * @private - */ - _probe(name) { - debug('probing transport "%s"', name); - let transport = this.createTransport(name); - let failed = false; - SocketWithoutUpgrade.priorWebsocketSuccess = false; - const onTransportOpen = () => { - if (failed) - return; - debug('probe transport "%s" opened', name); - transport.send([{ type: "ping", data: "probe" }]); - transport.once("packet", (msg) => { - if (failed) - return; - if ("pong" === msg.type && "probe" === msg.data) { - debug('probe transport "%s" pong', name); - this.upgrading = true; - this.emitReserved("upgrading", transport); - if (!transport) - return; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === transport.name; - debug('pausing current transport "%s"', this.transport.name); - this.transport.pause(() => { - if (failed) - return; - if ("closed" === this.readyState) - return; - debug("changing transport and sending upgrade packet"); - cleanup(); - this.setTransport(transport); - transport.send([{ type: "upgrade" }]); - this.emitReserved("upgrade", transport); - transport = null; - this.upgrading = false; - this.flush(); - }); - } - else { - debug('probe transport "%s" failed', name); - const err = new Error("probe error"); - // @ts-ignore - err.transport = transport.name; - this.emitReserved("upgradeError", err); - } - }); - }; - function freezeTransport() { - if (failed) - return; - // Any callback called by transport should be ignored since now - failed = true; - cleanup(); - transport.close(); - transport = null; - } - // Handle any error that happens while probing - const onerror = (err) => { - const error = new Error("probe error: " + err); - // @ts-ignore - error.transport = transport.name; - freezeTransport(); - debug('probe transport "%s" failed because of error: %s', name, err); - this.emitReserved("upgradeError", error); - }; - function onTransportClose() { - onerror("transport closed"); - } - // When the socket is closed while we're probing - function onclose() { - onerror("socket closed"); - } - // When the socket is upgraded while we're probing - function onupgrade(to) { - if (transport && to.name !== transport.name) { - debug('"%s" works - aborting "%s"', to.name, transport.name); - freezeTransport(); - } - } - // Remove all listeners on the transport and on self - const cleanup = () => { - transport.removeListener("open", onTransportOpen); - transport.removeListener("error", onerror); - transport.removeListener("close", onTransportClose); - this.off("close", onclose); - this.off("upgrading", onupgrade); - }; - transport.once("open", onTransportOpen); - transport.once("error", onerror); - transport.once("close", onTransportClose); - this.once("close", onclose); - this.once("upgrading", onupgrade); - if (this._upgrades.indexOf("webtransport") !== -1 && - name !== "webtransport") { - // favor WebTransport - this.setTimeoutFn(() => { - if (!failed) { - transport.open(); - } - }, 200); - } - else { - transport.open(); - } + + 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; } - onHandshake(data) { - this._upgrades = this._filterUpgrades(data.upgrades); - super.onHandshake(data); + + 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); + } } - /** - * Filters upgrades, returning only those matching client transports. - * - * @param {Array} upgrades - server upgrades - * @private - */ - _filterUpgrades(upgrades) { - const filteredUpgrades = []; - for (let i = 0; i < upgrades.length; i++) { - if (~this.transports.indexOf(upgrades[i])) - filteredUpgrades.push(upgrades[i]); - } - return filteredUpgrades; + + 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++; + } } -} -exports.SocketWithUpgrade = SocketWithUpgrade; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * @example - * import { Socket } from "engine.io-client"; - * - * const socket = new Socket(); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see SocketWithUpgrade - */ -class Socket extends SocketWithUpgrade { - constructor(uri, opts = {}) { - const o = typeof uri === "object" ? uri : opts; - if (!o.transports || - (o.transports && typeof o.transports[0] === "string")) { - o.transports = (o.transports || ["polling", "websocket", "webtransport"]) - .map((transportName) => index_js_1.transports[transportName]) - .filter((t) => !!t); - } - super(uri, o); + + 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; } -} -exports.Socket = Socket; -},{"./contrib/parseqs.js":367,"./contrib/parseuri.js":368,"./globals.node.js":369,"./transports/index.js":373,"./util.js":379,"@socket.io/component-emitter":23,"debug":380,"engine.io-parser":386}],372:[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.Transport = exports.TransportError = void 0; -const engine_io_parser_1 = require("engine.io-parser"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() -class TransportError extends Error { - constructor(reason, description, context) { - super(reason); - this.description = description; - this.context = context; - this.type = "TransportError"; + 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; } -} -exports.TransportError = TransportError; -class Transport extends component_emitter_1.Emitter { - /** - * Transport abstract constructor. - * - * @param {Object} opts - options - * @protected - */ - constructor(opts) { - super(); - this.writable = false; - (0, util_js_1.installTimerFunctions)(this, opts); - this.opts = opts; - this.query = opts.query; - this.socket = opts.socket; - this.supportsBinary = !opts.forceBase64; + + 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; } - /** - * Emits an error. - * - * @param {String} reason - * @param description - * @param context - the error context - * @return {Transport} for chaining - * @protected - */ - onError(reason, description, context) { - super.emitReserved("error", new TransportError(reason, description, context)); - return this; + + 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; } - /** - * Opens the transport. - */ - open() { - this.readyState = "opening"; - this.doOpen(); - return this; + + 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; } - /** - * Closes the transport. - */ - close() { - if (this.readyState === "opening" || this.readyState === "open") { - this.doClose(); - this.onClose(); - } - return this; + + // 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; } - /** - * Sends multiple packets. - * - * @param {Array} packets - */ - send(packets) { - if (this.readyState === "open") { - this.write(packets); - } - else { - // this might happen if the transport was silently closed in the beforeunload event handler - debug("transport is not open, discarding packets"); - } + + if (r !== 0) { + s++; } - /** - * Called upon open - * - * @protected - */ - onOpen() { - this.readyState = "open"; - this.writable = true; - super.emitReserved("open"); + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; } - /** - * Called with data. - * - * @param {String} data - * @protected - */ - onData(data) { - const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); - this.onPacket(packet); + + 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; } - /** - * Called with a decoded packet. - * - * @protected - */ - onPacket(packet) { - super.emitReserved("packet", packet); + + // 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]++; + } } - /** - * Called upon close. - * - * @protected - */ - onClose(details) { - this.readyState = "closed"; - super.emitReserved("close", details); + 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; } - /** - * Pauses the transport, in order not to lose packets during an upgrade. - * - * @param onPause - */ - pause(onPause) { } - createUri(schema, query = {}) { - return (schema + - "://" + - this._hostname() + - this._port() + - this.opts.path + - this._query(query)); + + 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; + } } - _hostname() { - const hostname = this.opts.hostname; - return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + + 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; } - _port() { - if (this.opts.port && - ((this.opts.secure && Number(this.opts.port !== 443)) || - (!this.opts.secure && Number(this.opts.port) !== 80))) { - return ":" + this.opts.port; - } - else { - return ""; - } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; } - _query(query) { - const encodedQuery = (0, parseqs_js_1.encode)(query); - return encodedQuery.length ? "?" + encodedQuery : ""; + + 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; } -} -exports.Transport = Transport; + this.negative = 1; -},{"./contrib/parseqs.js":367,"./util.js":379,"@socket.io/component-emitter":23,"debug":380,"engine.io-parser":386}],373:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transports = void 0; -const polling_xhr_node_js_1 = require("./polling-xhr.node.js"); -const websocket_node_js_1 = require("./websocket.node.js"); -const webtransport_js_1 = require("./webtransport.js"); -exports.transports = { - websocket: websocket_node_js_1.WS, - webtransport: webtransport_js_1.WT, - polling: polling_xhr_node_js_1.XHR, -}; + return this.strip(); + }; -},{"./polling-xhr.node.js":375,"./websocket.node.js":377,"./webtransport.js":378}],374:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Fetch = void 0; -const polling_js_1 = require("./polling.js"); -/** - * HTTP long-polling based on the built-in `fetch()` method. - * - * Usage: browser, Node.js (since v18), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch - * @see https://caniuse.com/fetch - * @see https://nodejs.org/api/globals.html#fetch - */ -class Fetch extends polling_js_1.Polling { - doPoll() { - this._fetch() - .then((res) => { - if (!res.ok) { - return this.onError("fetch read error", res.status, res); - } - res.text().then((data) => this.onData(data)); - }) - .catch((err) => { - this.onError("fetch read error", err); - }); + 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; } - doWrite(data, callback) { - this._fetch(data) - .then((res) => { - if (!res.ok) { - return this.onError("fetch write error", res.status, res); - } - callback(); - }) - .catch((err) => { - this.onError("fetch write error", err); - }); + + // 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; + } } - _fetch(data) { - var _a; - const isPost = data !== undefined; - const headers = new Headers(this.opts.extraHeaders); - if (isPost) { - headers.set("content-type", "text/plain;charset=UTF-8"); - } - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.appendCookies(headers); - return fetch(this.uri(), { - method: isPost ? "POST" : "GET", - body: isPost ? data : null, - headers, - credentials: this.opts.withCredentials ? "include" : "omit", - }).then((res) => { - var _a; - // @ts-ignore getSetCookie() was added in Node.js v19.7.0 - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(res.headers.getSetCookie()); - return res; - }); + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } } -} -exports.Fetch = Fetch; -},{"./polling.js":376}],375:[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.XHR = exports.Request = exports.BaseXHR = void 0; -const polling_js_1 = require("./polling.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("../util.js"); -const globals_node_js_1 = require("../globals.node.js"); -const has_cors_js_1 = require("../contrib/has-cors.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -function empty() { } -class BaseXHR extends polling_js_1.Polling { - /** - * XHR Polling constructor. - * - * @param {Object} opts - * @package - */ - constructor(opts) { - super(opts); - if (typeof location !== "undefined") { - const isSSL = "https:" === location.protocol; - let port = location.port; - // some user agents have empty `location.port` - if (!port) { - port = isSSL ? "443" : "80"; - } - this.xd = - (typeof location !== "undefined" && - opts.hostname !== location.hostname) || - port !== opts.port; + 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; + } } - /** - * Sends data. - * - * @param {String} data to send. - * @param {Function} called upon flush. - * @private - */ - doWrite(data, fn) { - const req = this.request({ - method: "POST", - data: data, - }); - req.on("success", fn); - req.on("error", (xhrStatus, context) => { - this.onError("xhr post error", xhrStatus, context); - }); + if (q) { + q.strip(); } - /** - * Starts a poll cycle. - * - * @private - */ - doPoll() { - debug("xhr poll"); - const req = this.request(); - req.on("data", this.onData.bind(this)); - req.on("error", (xhrStatus, context) => { - this.onError("xhr poll error", xhrStatus, context); - }); - this.pollXhr = req; + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); } -} -exports.BaseXHR = BaseXHR; -class Request extends component_emitter_1.Emitter { - /** - * Request constructor - * - * @param {Object} options - * @package - */ - constructor(createRequest, uri, opts) { - super(); - this.createRequest = createRequest; - (0, util_js_1.installTimerFunctions)(this, opts); - this._opts = opts; - this._method = opts.method || "GET"; - this._uri = uri; - this._data = undefined !== opts.data ? opts.data : null; - this._create(); + + 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) + }; } - /** - * Creates the XHR object and sends the request. - * - * @private - */ - _create() { - var _a; - const opts = (0, util_js_1.pick)(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); - opts.xdomain = !!this._opts.xd; - const xhr = (this._xhr = this.createRequest(opts)); - try { - debug("xhr open %s: %s", this._method, this._uri); - xhr.open(this._method, this._uri, true); - try { - if (this._opts.extraHeaders) { - // @ts-ignore - xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); - for (let i in this._opts.extraHeaders) { - if (this._opts.extraHeaders.hasOwnProperty(i)) { - xhr.setRequestHeader(i, this._opts.extraHeaders[i]); - } - } - } - } - catch (e) { } - if ("POST" === this._method) { - try { - xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); - } - catch (e) { } - } - try { - xhr.setRequestHeader("Accept", "*/*"); - } - catch (e) { } - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); - // ie6 check - if ("withCredentials" in xhr) { - xhr.withCredentials = this._opts.withCredentials; - } - if (this._opts.requestTimeout) { - xhr.timeout = this._opts.requestTimeout; - } - xhr.onreadystatechange = () => { - var _a; - if (xhr.readyState === 3) { - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies( - // @ts-ignore - xhr.getResponseHeader("set-cookie")); - } - if (4 !== xhr.readyState) - return; - if (200 === xhr.status || 1223 === xhr.status) { - this._onLoad(); - } - else { - // make sure the `error` event handler that's user-set - // does not throw in the same tick and gets caught here - this.setTimeoutFn(() => { - this._onError(typeof xhr.status === "number" ? xhr.status : 0); - }, 0); - } - }; - debug("xhr data %s", this._data); - xhr.send(this._data); - } - catch (e) { - // Need to defer since .create() is called directly from the constructor - // and thus the 'error' event can only be only bound *after* this exception - // occurs. Therefore, also, we cannot throw here at all. - this.setTimeoutFn(() => { - this._onError(e); - }, 0); - return; - } - if (typeof document !== "undefined") { - this._index = Request.requestsCount++; - Request.requests[this._index] = this; + + 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 + }; } - /** - * Called upon error. - * - * @private - */ - _onError(err) { - this.emitReserved("error", err, this._xhr); - this._cleanup(true); + + 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 + }; } - /** - * Cleans up house. - * - * @private - */ - _cleanup(fromError) { - if ("undefined" === typeof this._xhr || null === this._xhr) { - return; - } - this._xhr.onreadystatechange = empty; - if (fromError) { - try { - this._xhr.abort(); - } - catch (e) { } - } - if (typeof document !== "undefined") { - delete Request.requests[this._index]; + + 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); } - this._xhr = null; + } + + 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])) + }; } - /** - * Called upon load. - * - * @private - */ - _onLoad() { - const data = this._xhr.responseText; - if (data !== null) { - this.emitReserved("data", data); - this.emitReserved("success"); - this._cleanup(); - } + + 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; } - /** - * Aborts the request. - * - * @package - */ - abort() { - this._cleanup(); + + 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; } -} -exports.Request = Request; -Request.requestsCount = 0; -Request.requests = {}; -/** - * Aborts pending requests when unloading the window. This is needed to prevent - * memory leaks (e.g. when using IE) and to ensure that no spurious error is - * emitted. - */ -if (typeof document !== "undefined") { - // @ts-ignore - if (typeof attachEvent === "function") { - // @ts-ignore - attachEvent("onunload", unloadHandler); + + 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(); } - else if (typeof addEventListener === "function") { - const terminationEvent = "onpagehide" in globals_node_js_1.globalThisShim ? "pagehide" : "unload"; - addEventListener(terminationEvent, unloadHandler, false); + + // 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; } -} -function unloadHandler() { - for (let i in Request.requests) { - if (Request.requests.hasOwnProperty(i)) { - Request.requests[i].abort(); + + 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); + } } -} -const hasXHR2 = (function () { - const xhr = newRequest({ - xdomain: false, - }); - return xhr && xhr.responseType !== null; -})(); -/** - * HTTP long-polling based on the built-in `XMLHttpRequest` object. - * - * Usage: browser - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - */ -class XHR extends BaseXHR { - constructor(opts) { - super(opts); - const forceBase64 = opts && opts.forceBase64; - this.supportsBinary = hasXHR2 && !forceBase64; - } - request(opts = {}) { - Object.assign(opts, { xd: this.xd }, this.opts); - return new Request(newRequest, this.uri(), opts); + + 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(); } -} -exports.XHR = XHR; -function newRequest(opts) { - const xdomain = opts.xdomain; - // XMLHttpRequest can be disabled on IE - try { - if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { - return new XMLHttpRequest(); + + 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); } - } - catch (e) { } - if (!xdomain) { - try { - return new globals_node_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + + 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); } - catch (e) { } - } -} + } -},{"../contrib/has-cors.js":366,"../globals.node.js":369,"../util.js":379,"./polling.js":376,"@socket.io/component-emitter":23,"debug":380}],376:[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.Polling = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -class Polling extends transport_js_1.Transport { - constructor() { - super(...arguments); - this._polling = false; + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } } - get name() { - return "polling"; + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; } - /** - * Opens the socket (triggers polling). We write a PING message to determine - * when the transport is open. - * - * @protected - */ - doOpen() { - this._poll(); + + if (res.cmpn(0) < 0) { + res.iadd(p); } - /** - * Pauses polling. - * - * @param {Function} onPause - callback upon buffers are flushed and transport is paused - * @package - */ - pause(onPause) { - this.readyState = "pausing"; - const pause = () => { - debug("paused"); - this.readyState = "paused"; - onPause(); - }; - if (this._polling || !this.writable) { - let total = 0; - if (this._polling) { - debug("we are currently polling - waiting to pause"); - total++; - this.once("pollComplete", function () { - debug("pre-pause polling complete"); - --total || pause(); - }); - } - if (!this.writable) { - debug("we are currently writing - waiting to pause"); - total++; - this.once("drain", function () { - debug("pre-pause writing complete"); - --total || pause(); - }); - } - } - else { - pause(); - } + + 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); } - /** - * Starts polling cycle. - * - * @private - */ - _poll() { - debug("polling"); - this._polling = true; - this.doPoll(); - this.emitReserved("poll"); + + 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; } - /** - * Overloads onData to detect payloads. - * - * @protected - */ - onData(data) { - debug("polling got data %s", data); - const callback = (packet) => { - // if its the first message we consider the transport open - if ("opening" === this.readyState && packet.type === "open") { - this.onOpen(); - } - // if its a close packet, we close the ongoing requests - if ("close" === packet.type) { - this.onClose({ description: "transport closed by the server" }); - return false; - } - // otherwise bypass onData and handle the message - this.onPacket(packet); - }; - // decode payload - (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); - // if an event did not trigger closing - if ("closed" !== this.readyState) { - // if we got data we're not polling - this._polling = false; - this.emitReserved("pollComplete"); - if ("open" === this.readyState) { - this._poll(); - } - else { - debug('ignoring poll - transport state "%s"', this.readyState); - } - } + + // 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; } - /** - * For polling, send a close packet. - * - * @protected - */ - doClose() { - const close = () => { - debug("writing close packet"); - this.write([{ type: "close" }]); - }; - if ("open" === this.readyState) { - debug("transport open - closing"); - close(); - } - else { - // in case we're trying to close while - // handshaking is in progress (GH-164) - debug("transport not open - deferring close"); - this.once("open", close); - } + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Writes a packets payload. - * - * @param {Array} packets - data packets - * @protected - */ - write(packets) { - this.writable = false; - (0, engine_io_parser_1.encodePayload)(packets, (data) => { - this.doWrite(data, () => { - this.writable = true; - this.emitReserved("drain"); - }); - }); + 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; } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "https" : "http"; - const query = this.query || {}; - // cache busting is forced - if (false !== this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - if (!this.supportsBinary && !query.sid) { - query.b64 = 1; - } - return this.createUri(schema, query); + 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(); + } } -} -exports.Polling = Polling; -},{"../transport.js":372,"../util.js":379,"debug":380,"engine.io-parser":386}],377:[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.WS = exports.BaseWS = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("../globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() -// detect ReactNative environment -const isReactNative = typeof navigator !== "undefined" && - typeof navigator.product === "string" && - navigator.product.toLowerCase() === "reactnative"; -class BaseWS extends transport_js_1.Transport { - get name() { - return "websocket"; - } - doOpen() { - const uri = this.uri(); - const protocols = this.opts.protocols; - // React Native only supports the 'headers' option, and will print a warning if anything else is passed - const opts = isReactNative - ? {} - : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); - if (this.opts.extraHeaders) { - opts.headers = this.opts.extraHeaders; - } - try { - this.ws = this.createSocket(uri, protocols, opts); - } - catch (err) { - return this.emitReserved("error", err); - } - this.ws.binaryType = this.socket.binaryType; - this.addEventListeners(); - } - /** - * Adds event listeners to the socket - * - * @private - */ - addEventListeners() { - this.ws.onopen = () => { - if (this.opts.autoUnref) { - this.ws._socket.unref(); - } - this.onOpen(); - }; - this.ws.onclose = (closeEvent) => this.onClose({ - description: "websocket connection closed", - context: closeEvent, - }); - this.ws.onmessage = (ev) => this.onData(ev.data); - this.ws.onerror = (e) => this.onError("websocket error", e); - } - write(packets) { - this.writable = false; - // encodePacket efficient as it uses WS framing - // no need for encodePayload - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { - // Sometimes the websocket has already been closed but the browser didn't - // have a chance of informing us about it yet, in that case send will - // throw an error - try { - this.doWrite(packet, data); - } - catch (e) { - debug("websocket closed before onclose event"); - } - if (lastPacket) { - // fake drain - // defer to next tick to allow Socket to clear writeBuffer - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } - } - doClose() { - if (typeof this.ws !== "undefined") { - this.ws.onerror = () => { }; - this.ws.close(); - this.ws = null; - } - } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "wss" : "ws"; - const query = this.query || {}; - // append timestamp to URI - if (this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - // communicate binary support capabilities - if (!this.supportsBinary) { - query.b64 = 1; - } - return this.createUri(schema, query); - } -} -exports.BaseWS = BaseWS; -const WebSocketCtor = globals_node_js_1.globalThisShim.WebSocket || globals_node_js_1.globalThisShim.MozWebSocket; -/** - * WebSocket transport based on the built-in `WebSocket` object. - * - * Usage: browser, Node.js (since v21), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket - * @see https://caniuse.com/mdn-api_websocket - * @see https://nodejs.org/api/globals.html#websocket - */ -class WS extends BaseWS { - createSocket(uri, protocols, opts) { - return !isReactNative - ? protocols - ? new WebSocketCtor(uri, protocols) - : new WebSocketCtor(uri) - : new WebSocketCtor(uri, protocols, opts); + 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]; } - doWrite(_packet, data) { - this.ws.send(data); + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; } -} -exports.WS = WS; -},{"../globals.node.js":369,"../transport.js":372,"../util.js":379,"debug":380,"engine.io-parser":386}],378:[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.WT = void 0; -const transport_js_1 = require("../transport.js"); -const globals_node_js_1 = require("../globals.node.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() -/** - * WebTransport transport based on the built-in `WebTransport` object. - * - * Usage: browser, Node.js (with the `@fails-components/webtransport` package) - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport - * @see https://caniuse.com/webtransport - */ -class WT extends transport_js_1.Transport { - get name() { - return "webtransport"; + // 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; } - doOpen() { - try { - // @ts-ignore - this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); - } - catch (err) { - return this.emitReserved("error", err); - } - this._transport.closed - .then(() => { - debug("transport closed gracefully"); - this.onClose(); - }) - .catch((err) => { - debug("transport closed due to %s", err); - this.onError("webtransport error", err); - }); - // note: we could have used async/await, but that would require some additional polyfills - this._transport.ready.then(() => { - this._transport.createBidirectionalStream().then((stream) => { - const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); - const reader = stream.readable.pipeThrough(decoderStream).getReader(); - const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); - encoderStream.readable.pipeTo(stream.writable); - this._writer = encoderStream.writable.getWriter(); - const read = () => { - reader - .read() - .then(({ done, value }) => { - if (done) { - debug("session is closed"); - return; - } - debug("received chunk: %o", value); - this.onPacket(value); - read(); - }) - .catch((err) => { - debug("an error occurred while reading: %s", err); - }); - }; - read(); - const packet = { type: "open" }; - if (this.query.sid) { - packet.data = `{"sid":"${this.query.sid}"}`; - } - this._writer.write(packet).then(() => this.onOpen()); - }); - }); + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; } - write(packets) { - this.writable = false; - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - this._writer.write(packet).then(() => { - if (lastPacket) { - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } + }; + + 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); } - doClose() { - var _a; - (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close(); + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } } -} -exports.WT = WT; + return num; + }; -},{"../globals.node.js":369,"../transport.js":372,"debug":380,"engine.io-parser":386}],379:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.pick = pick; -exports.installTimerFunctions = installTimerFunctions; -exports.byteLength = byteLength; -exports.randomString = randomString; -const globals_node_js_1 = require("./globals.node.js"); -function pick(obj, ...attr) { - return attr.reduce((acc, k) => { - if (obj.hasOwnProperty(k)) { - acc[k] = obj[k]; - } - return acc; - }, {}); -} -// Keep a reference to the real timeout functions so they can be used when overridden -const NATIVE_SET_TIMEOUT = globals_node_js_1.globalThisShim.setTimeout; -const NATIVE_CLEAR_TIMEOUT = globals_node_js_1.globalThisShim.clearTimeout; -function installTimerFunctions(obj, opts) { - if (opts.useNativeTimers) { - obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globals_node_js_1.globalThisShim); - } - else { - obj.setTimeoutFn = globals_node_js_1.globalThisShim.setTimeout.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = globals_node_js_1.globalThisShim.clearTimeout.bind(globals_node_js_1.globalThisShim); + 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; } -} -// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) -const BASE64_OVERHEAD = 1.33; -// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 -function byteLength(obj) { - if (typeof obj === "string") { - return utf8Length(obj); + if (carry !== 0) { + num.words[num.length++] = carry; } - // arraybuffer or blob - return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); -} -function utf8Length(str) { - let c = 0, length = 0; - for (let i = 0, l = str.length; i < l; i++) { - c = str.charCodeAt(i); - if (c < 0x80) { - length += 1; - } - else if (c < 0x800) { - length += 2; - } - else if (c < 0xd800 || c >= 0xe000) { - length += 3; - } - else { - i++; - length += 4; - } + 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); } - return length; -} -/** - * Generates a random 8-characters string. - */ -function randomString() { - return (Date.now().toString(36).substring(3) + - Math.random().toString(36).substring(2, 5)); -} + primes[name] = prime; -},{"./globals.node.js":369}],380:[function(require,module,exports){ -(function (process){(function (){ -/* eslint-env browser */ + return prime; + }; -/** - * This is the web browser implementation of `debug()`. - */ + // + // 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; + } + } -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); + 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'); + }; -/** - * Colors. - */ + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ + return this.m.sub(a)._forceRed(this); + }; -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } + Red.prototype.add = function add (a, b) { + this._verify2(a, b); - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; - let m; + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; - if (!this.useColors) { - return; - } + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; - args.splice(lastC, 0, c); -} + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); - return r; -} + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + // 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()); -module.exports = require('./common')(exports); + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); -const {formatters} = module.exports; + // 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); -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; + 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)); -}).call(this)}).call(this,require('_process')) -},{"./common":381,"_process":447}],381:[function(require,module,exports){ + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ + return r; + }; -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - createDebug.destroy = destroy; + 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); + } + }; - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); - /** - * The currently active debug mode names, and names to skip. - */ + 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); + } - createDebug.names = []; - createDebug.skips = []; + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + 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); + } - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; + return res; + }; - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); - const self = debug; + return r === num ? r.clone() : r; + }; - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; - args[0] = createDebug.coerce(args[0]); + // + // Montgomery method engine + // - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } + BN.mont = function mont (num) { + return new Mont(num); + }; - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); + function Mont (m) { + Red.call(this, m); - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } + 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); - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } + 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; - return debug; - } + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } + return res._forceRed(this); + }; - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - createDebug.names = []; - createDebug.skips = []; + 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); + } - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; + return res._forceRed(this); + }; - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } + 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":32}],360:[function(require,module,exports){ +module.exports={ + "name": "elliptic", + "version": "6.5.5", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "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" + }, + "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" + } +} - namespaces = split[i].replace(/\*/g, '.*?'); +},{}],361:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hasCORS = void 0; +// imported from https://github.com/component/has-cors +let value = false; +try { + value = typeof XMLHttpRequest !== 'undefined' && + 'withCredentials' in new XMLHttpRequest(); +} +catch (err) { + // if XMLHttp support is disabled in IE then it will throw + // when trying to create +} +exports.hasCORS = value; - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } +},{}],362:[function(require,module,exports){ +"use strict"; +// imported from https://github.com/galkn/querystring +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decode = exports.encode = void 0; +function encode(obj) { + let str = ''; + for (let i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) + str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + return str; +} +exports.encode = encode; +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ +function decode(qs) { + let qry = {}; + let pairs = qs.split('&'); + for (let i = 0, l = pairs.length; i < l; i++) { + let pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +} +exports.decode = decode; - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } +},{}],363:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parse = void 0; +// imported from https://github.com/galkn/parseuri +/** + * Parses a URI + * + * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. + * + * See: + * - https://developer.mozilla.org/en-US/docs/Web/API/URL + * - https://caniuse.com/url + * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B + * + * History of the parse() method: + * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c + * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 + * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 + * + * @author Steven Levithan (MIT license) + * @api private + */ +const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; +const parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; +function parse(str) { + if (str.length > 2000) { + throw "URI too long"; + } + const src = str, b = str.indexOf('['), e = str.indexOf(']'); + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + let m = re.exec(str || ''), uri = {}, i = 14; + while (i--) { + uri[parts[i]] = m[i] || ''; + } + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + return uri; +} +exports.parse = parse; +function pathNames(obj, path) { + const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); + if (path.slice(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.slice(-1) == '/') { + names.splice(names.length - 1, 1); + } + return names; +} +function queryKey(uri, query) { + const data = {}; + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + return data; +} - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } +},{}],364:[function(require,module,exports){ +// imported from https://github.com/unshiftio/yeast +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.yeast = exports.decode = exports.encode = void 0; +const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''), length = 64, map = {}; +let seed = 0, i = 0, prev; +/** + * Return a string representing the specified number. + * + * @param {Number} num The number to convert. + * @returns {String} The string representation of the number. + * @api public + */ +function encode(num) { + let encoded = ''; + do { + encoded = alphabet[num % length] + encoded; + num = Math.floor(num / length); + } while (num > 0); + return encoded; +} +exports.encode = encode; +/** + * Return the integer value specified by the given string. + * + * @param {String} str The string to convert. + * @returns {Number} The integer value represented by the string. + * @api public + */ +function decode(str) { + let decoded = 0; + for (i = 0; i < str.length; i++) { + decoded = decoded * length + map[str.charAt(i)]; + } + return decoded; +} +exports.decode = decode; +/** + * Yeast: A tiny growing id generator. + * + * @returns {String} A unique id. + * @api public + */ +function yeast() { + const now = encode(+new Date()); + if (now !== prev) + return seed = 0, prev = now; + return now + '.' + encode(seed++); +} +exports.yeast = yeast; +// +// Map each character to its index. +// +for (; i < length; i++) + map[alphabet[i]] = i; - let i; - let len; +},{}],365:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalThisShim = void 0; +exports.globalThisShim = (() => { + if (typeof self !== "undefined") { + return self; + } + else if (typeof window !== "undefined") { + return window; + } + else { + return Function("return this")(); + } +})(); - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } +},{}],366:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0; +const socket_js_1 = require("./socket.js"); +Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); +exports.protocol = socket_js_1.Socket.protocol; +var transport_js_1 = require("./transport.js"); +Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); +Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); +var index_js_1 = require("./transports/index.js"); +Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); +var util_js_1 = require("./util.js"); +Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); +var parseuri_js_1 = require("./contrib/parseuri.js"); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); +var websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return websocket_constructor_js_1.nextTick; } }); + +},{"./contrib/parseuri.js":363,"./socket.js":367,"./transport.js":368,"./transports/index.js":369,"./transports/websocket-constructor.js":371,"./util.js":375}],367:[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.Socket = void 0; +const index_js_1 = require("./transports/index.js"); +const util_js_1 = require("./util.js"); +const parseqs_js_1 = require("./contrib/parseqs.js"); +const parseuri_js_1 = require("./contrib/parseuri.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const component_emitter_1 = require("@socket.io/component-emitter"); +const engine_io_parser_1 = require("engine.io-parser"); +const websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() +class Socket extends component_emitter_1.Emitter { + /** + * Socket constructor. + * + * @param {String|Object} uri - uri or options + * @param {Object} opts - options + */ + constructor(uri, opts = {}) { + super(); + this.binaryType = websocket_constructor_js_1.defaultBinaryType; + this.writeBuffer = []; + if (uri && "object" === typeof uri) { + opts = uri; + uri = null; + } + if (uri) { + uri = (0, parseuri_js_1.parse)(uri); + opts.hostname = uri.host; + opts.secure = uri.protocol === "https" || uri.protocol === "wss"; + opts.port = uri.port; + if (uri.query) + opts.query = uri.query; + } + else if (opts.host) { + opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; + } + (0, util_js_1.installTimerFunctions)(this, opts); + this.secure = + null != opts.secure + ? opts.secure + : typeof location !== "undefined" && "https:" === location.protocol; + if (opts.hostname && !opts.port) { + // if no port is specified manually, use the protocol default + opts.port = this.secure ? "443" : "80"; + } + this.hostname = + opts.hostname || + (typeof location !== "undefined" ? location.hostname : "localhost"); + this.port = + opts.port || + (typeof location !== "undefined" && location.port + ? location.port + : this.secure + ? "443" + : "80"); + this.transports = opts.transports || [ + "polling", + "websocket", + "webtransport", + ]; + this.writeBuffer = []; + this.prevBufferLen = 0; + this.opts = Object.assign({ + path: "/engine.io", + agent: false, + withCredentials: false, + upgrade: true, + timestampParam: "t", + rememberUpgrade: false, + addTrailingSlash: true, + rejectUnauthorized: true, + perMessageDeflate: { + threshold: 1024, + }, + transportOptions: {}, + closeOnBeforeunload: false, + }, opts); + this.opts.path = + this.opts.path.replace(/\/$/, "") + + (this.opts.addTrailingSlash ? "/" : ""); + if (typeof this.opts.query === "string") { + this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); + } + // set on handshake + this.id = null; + this.upgrades = null; + this.pingInterval = null; + this.pingTimeout = null; + // set on heartbeat + this.pingTimeoutTimer = null; + if (typeof addEventListener === "function") { + if (this.opts.closeOnBeforeunload) { + // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener + // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is + // closed/reloaded) + this.beforeunloadEventListener = () => { + if (this.transport) { + // silently close the transport + this.transport.removeAllListeners(); + this.transport.close(); + } + }; + addEventListener("beforeunload", this.beforeunloadEventListener, false); + } + if (this.hostname !== "localhost") { + this.offlineEventListener = () => { + this.onClose("transport close", { + description: "network connection lost", + }); + }; + addEventListener("offline", this.offlineEventListener, false); + } + } + this.open(); + } + /** + * Creates transport of the given type. + * + * @param {String} name - transport name + * @return {Transport} + * @private + */ + createTransport(name) { + debug('creating transport "%s"', name); + const query = Object.assign({}, this.opts.query); + // append engine.io protocol identifier + query.EIO = engine_io_parser_1.protocol; + // transport name + query.transport = name; + // session id if we already have one + if (this.id) + query.sid = this.id; + const opts = Object.assign({}, this.opts, { + query, + socket: this, + hostname: this.hostname, + secure: this.secure, + port: this.port, + }, this.opts.transportOptions[name]); + debug("options: %j", opts); + return new index_js_1.transports[name](opts); + } + /** + * Initializes transport to use and starts probe. + * + * @private + */ + open() { + let transport; + if (this.opts.rememberUpgrade && + Socket.priorWebsocketSuccess && + this.transports.indexOf("websocket") !== -1) { + transport = "websocket"; + } + else if (0 === this.transports.length) { + // Emit error on next tick so it can be listened to + this.setTimeoutFn(() => { + this.emitReserved("error", "No transports available"); + }, 0); + return; + } + else { + transport = this.transports[0]; + } + this.readyState = "opening"; + // Retry with the next transport if the transport is disabled (jsonp: false) + try { + transport = this.createTransport(transport); + } + catch (e) { + debug("error while creating transport: %s", e); + this.transports.shift(); + this.open(); + return; + } + transport.open(); + this.setTransport(transport); + } + /** + * Sets the current transport. Disables the existing one (if any). + * + * @private + */ + setTransport(transport) { + debug("setting transport %s", transport.name); + if (this.transport) { + debug("clearing existing transport %s", this.transport.name); + this.transport.removeAllListeners(); + } + // set up transport + this.transport = transport; + // set up transport listeners + transport + .on("drain", this.onDrain.bind(this)) + .on("packet", this.onPacket.bind(this)) + .on("error", this.onError.bind(this)) + .on("close", (reason) => this.onClose("transport close", reason)); + } + /** + * Probes a transport. + * + * @param {String} name - transport name + * @private + */ + probe(name) { + debug('probing transport "%s"', name); + let transport = this.createTransport(name); + let failed = false; + Socket.priorWebsocketSuccess = false; + const onTransportOpen = () => { + if (failed) + return; + debug('probe transport "%s" opened', name); + transport.send([{ type: "ping", data: "probe" }]); + transport.once("packet", (msg) => { + if (failed) + return; + if ("pong" === msg.type && "probe" === msg.data) { + debug('probe transport "%s" pong', name); + this.upgrading = true; + this.emitReserved("upgrading", transport); + if (!transport) + return; + Socket.priorWebsocketSuccess = "websocket" === transport.name; + debug('pausing current transport "%s"', this.transport.name); + this.transport.pause(() => { + if (failed) + return; + if ("closed" === this.readyState) + return; + debug("changing transport and sending upgrade packet"); + cleanup(); + this.setTransport(transport); + transport.send([{ type: "upgrade" }]); + this.emitReserved("upgrade", transport); + transport = null; + this.upgrading = false; + this.flush(); + }); + } + else { + debug('probe transport "%s" failed', name); + const err = new Error("probe error"); + // @ts-ignore + err.transport = transport.name; + this.emitReserved("upgradeError", err); + } + }); + }; + function freezeTransport() { + if (failed) + return; + // Any callback called by transport should be ignored since now + failed = true; + cleanup(); + transport.close(); + transport = null; + } + // Handle any error that happens while probing + const onerror = (err) => { + const error = new Error("probe error: " + err); + // @ts-ignore + error.transport = transport.name; + freezeTransport(); + debug('probe transport "%s" failed because of error: %s', name, err); + this.emitReserved("upgradeError", error); + }; + function onTransportClose() { + onerror("transport closed"); + } + // When the socket is closed while we're probing + function onclose() { + onerror("socket closed"); + } + // When the socket is upgraded while we're probing + function onupgrade(to) { + if (transport && to.name !== transport.name) { + debug('"%s" works - aborting "%s"', to.name, transport.name); + freezeTransport(); + } + } + // Remove all listeners on the transport and on self + const cleanup = () => { + transport.removeListener("open", onTransportOpen); + transport.removeListener("error", onerror); + transport.removeListener("close", onTransportClose); + this.off("close", onclose); + this.off("upgrading", onupgrade); + }; + transport.once("open", onTransportOpen); + transport.once("error", onerror); + transport.once("close", onTransportClose); + this.once("close", onclose); + this.once("upgrading", onupgrade); + if (this.upgrades.indexOf("webtransport") !== -1 && + name !== "webtransport") { + // favor WebTransport + this.setTimeoutFn(() => { + if (!failed) { + transport.open(); + } + }, 200); + } + else { + transport.open(); + } + } + /** + * Called when connection is deemed open. + * + * @private + */ + onOpen() { + debug("socket open"); + this.readyState = "open"; + Socket.priorWebsocketSuccess = "websocket" === this.transport.name; + this.emitReserved("open"); + this.flush(); + // we check for `readyState` in case an `open` + // listener already closed the socket + if ("open" === this.readyState && this.opts.upgrade) { + debug("starting upgrade probes"); + let i = 0; + const l = this.upgrades.length; + for (; i < l; i++) { + this.probe(this.upgrades[i]); + } + } + } + /** + * Handles a packet. + * + * @private + */ + onPacket(packet) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket receive: type "%s", data "%s"', packet.type, packet.data); + this.emitReserved("packet", packet); + // Socket is live - any packet counts + this.emitReserved("heartbeat"); + this.resetPingTimeout(); + switch (packet.type) { + case "open": + this.onHandshake(JSON.parse(packet.data)); + break; + case "ping": + this.sendPacket("pong"); + this.emitReserved("ping"); + this.emitReserved("pong"); + break; + case "error": + const err = new Error("server error"); + // @ts-ignore + err.code = packet.data; + this.onError(err); + break; + case "message": + this.emitReserved("data", packet.data); + this.emitReserved("message", packet.data); + break; + } + } + else { + debug('packet received with socket readyState "%s"', this.readyState); + } + } + /** + * Called upon handshake completion. + * + * @param {Object} data - handshake obj + * @private + */ + onHandshake(data) { + this.emitReserved("handshake", data); + this.id = data.sid; + this.transport.query.sid = data.sid; + this.upgrades = this.filterUpgrades(data.upgrades); + this.pingInterval = data.pingInterval; + this.pingTimeout = data.pingTimeout; + this.maxPayload = data.maxPayload; + this.onOpen(); + // In case open handler closes socket + if ("closed" === this.readyState) + return; + this.resetPingTimeout(); + } + /** + * Sets and resets ping timeout timer based on server pings. + * + * @private + */ + resetPingTimeout() { + this.clearTimeoutFn(this.pingTimeoutTimer); + this.pingTimeoutTimer = this.setTimeoutFn(() => { + this.onClose("ping timeout"); + }, this.pingInterval + this.pingTimeout); + if (this.opts.autoUnref) { + this.pingTimeoutTimer.unref(); + } + } + /** + * Called on `drain` event + * + * @private + */ + onDrain() { + this.writeBuffer.splice(0, this.prevBufferLen); + // setting prevBufferLen = 0 is very important + // for example, when upgrading, upgrade packet is sent over, + // and a nonzero prevBufferLen could cause problems on `drain` + this.prevBufferLen = 0; + if (0 === this.writeBuffer.length) { + this.emitReserved("drain"); + } + else { + this.flush(); + } + } + /** + * Flush write buffers. + * + * @private + */ + flush() { + if ("closed" !== this.readyState && + this.transport.writable && + !this.upgrading && + this.writeBuffer.length) { + const packets = this.getWritablePackets(); + debug("flushing %d packets in socket", packets.length); + this.transport.send(packets); + // keep track of current length of writeBuffer + // splice writeBuffer and callbackBuffer on `drain` + this.prevBufferLen = packets.length; + this.emitReserved("flush"); + } + } + /** + * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP + * long-polling) + * + * @private + */ + getWritablePackets() { + const shouldCheckPayloadSize = this.maxPayload && + this.transport.name === "polling" && + this.writeBuffer.length > 1; + if (!shouldCheckPayloadSize) { + return this.writeBuffer; + } + let payloadSize = 1; // first packet type + for (let i = 0; i < this.writeBuffer.length; i++) { + const data = this.writeBuffer[i].data; + if (data) { + payloadSize += (0, util_js_1.byteLength)(data); + } + if (i > 0 && payloadSize > this.maxPayload) { + debug("only send %d out of %d packets", i, this.writeBuffer.length); + return this.writeBuffer.slice(0, i); + } + payloadSize += 2; // separator + packet type + } + debug("payload size is %d (max: %d)", payloadSize, this.maxPayload); + return this.writeBuffer; + } + /** + * Sends a message. + * + * @param {String} msg - message. + * @param {Object} options. + * @param {Function} callback function. + * @return {Socket} for chaining. + */ + write(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + send(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + /** + * Sends a packet. + * + * @param {String} type: packet type. + * @param {String} data. + * @param {Object} options. + * @param {Function} fn - callback function. + * @private + */ + sendPacket(type, data, options, fn) { + if ("function" === typeof data) { + fn = data; + data = undefined; + } + if ("function" === typeof options) { + fn = options; + options = null; + } + if ("closing" === this.readyState || "closed" === this.readyState) { + return; + } + options = options || {}; + options.compress = false !== options.compress; + const packet = { + type: type, + data: data, + options: options, + }; + this.emitReserved("packetCreate", packet); + this.writeBuffer.push(packet); + if (fn) + this.once("flush", fn); + this.flush(); + } + /** + * Closes the connection. + */ + close() { + const close = () => { + this.onClose("forced close"); + debug("socket closing - telling transport to close"); + this.transport.close(); + }; + const cleanupAndClose = () => { + this.off("upgrade", cleanupAndClose); + this.off("upgradeError", cleanupAndClose); + close(); + }; + const waitForUpgrade = () => { + // wait for upgrade to finish since we can't send packets while pausing a transport + this.once("upgrade", cleanupAndClose); + this.once("upgradeError", cleanupAndClose); + }; + if ("opening" === this.readyState || "open" === this.readyState) { + this.readyState = "closing"; + if (this.writeBuffer.length) { + this.once("drain", () => { + if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + }); + } + else if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + } + return this; + } + /** + * Called upon transport error + * + * @private + */ + onError(err) { + debug("socket error %j", err); + Socket.priorWebsocketSuccess = false; + this.emitReserved("error", err); + this.onClose("transport error", err); + } + /** + * Called upon transport close. + * + * @private + */ + onClose(reason, description) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket close with reason: "%s"', reason); + // clear timers + this.clearTimeoutFn(this.pingTimeoutTimer); + // stop event from firing again for transport + this.transport.removeAllListeners("close"); + // ensure transport won't stay open + this.transport.close(); + // ignore further transport communication + this.transport.removeAllListeners(); + if (typeof removeEventListener === "function") { + removeEventListener("beforeunload", this.beforeunloadEventListener, false); + removeEventListener("offline", this.offlineEventListener, false); + } + // set ready state + this.readyState = "closed"; + // clear session id + this.id = null; + // emit close event + this.emitReserved("close", reason, description); + // clean buffers after, so users can still + // grab the buffers on `close` event + this.writeBuffer = []; + this.prevBufferLen = 0; + } + } + /** + * Filters upgrades, returning only those matching client transports. + * + * @param {Array} upgrades - server upgrades + * @private + */ + filterUpgrades(upgrades) { + const filteredUpgrades = []; + let i = 0; + const j = upgrades.length; + for (; i < j; i++) { + if (~this.transports.indexOf(upgrades[i])) + filteredUpgrades.push(upgrades[i]); + } + return filteredUpgrades; + } +} +exports.Socket = Socket; +Socket.protocol = engine_io_parser_1.protocol; - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } +},{"./contrib/parseqs.js":362,"./contrib/parseuri.js":363,"./transports/index.js":369,"./transports/websocket-constructor.js":371,"./util.js":375,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],368:[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.Transport = exports.TransportError = void 0; +const engine_io_parser_1 = require("engine.io-parser"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("./util.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const parseqs_js_1 = require("./contrib/parseqs.js"); +const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() +class TransportError extends Error { + constructor(reason, description, context) { + super(reason); + this.description = description; + this.context = context; + this.type = "TransportError"; + } +} +exports.TransportError = TransportError; +class Transport extends component_emitter_1.Emitter { + /** + * Transport abstract constructor. + * + * @param {Object} opts - options + * @protected + */ + constructor(opts) { + super(); + this.writable = false; + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.query = opts.query; + this.socket = opts.socket; + } + /** + * Emits an error. + * + * @param {String} reason + * @param description + * @param context - the error context + * @return {Transport} for chaining + * @protected + */ + onError(reason, description, context) { + super.emitReserved("error", new TransportError(reason, description, context)); + return this; + } + /** + * Opens the transport. + */ + open() { + this.readyState = "opening"; + this.doOpen(); + return this; + } + /** + * Closes the transport. + */ + close() { + if (this.readyState === "opening" || this.readyState === "open") { + this.doClose(); + this.onClose(); + } + return this; + } + /** + * Sends multiple packets. + * + * @param {Array} packets + */ + send(packets) { + if (this.readyState === "open") { + this.write(packets); + } + else { + // this might happen if the transport was silently closed in the beforeunload event handler + debug("transport is not open, discarding packets"); + } + } + /** + * Called upon open + * + * @protected + */ + onOpen() { + this.readyState = "open"; + this.writable = true; + super.emitReserved("open"); + } + /** + * Called with data. + * + * @param {String} data + * @protected + */ + onData(data) { + const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); + this.onPacket(packet); + } + /** + * Called with a decoded packet. + * + * @protected + */ + onPacket(packet) { + super.emitReserved("packet", packet); + } + /** + * Called upon close. + * + * @protected + */ + onClose(details) { + this.readyState = "closed"; + super.emitReserved("close", details); + } + /** + * Pauses the transport, in order not to lose packets during an upgrade. + * + * @param onPause + */ + pause(onPause) { } + createUri(schema, query = {}) { + return (schema + + "://" + + this._hostname() + + this._port() + + this.opts.path + + this._query(query)); + } + _hostname() { + const hostname = this.opts.hostname; + return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + } + _port() { + if (this.opts.port && + ((this.opts.secure && Number(this.opts.port !== 443)) || + (!this.opts.secure && Number(this.opts.port) !== 80))) { + return ":" + this.opts.port; + } + else { + return ""; + } + } + _query(query) { + const encodedQuery = (0, parseqs_js_1.encode)(query); + return encodedQuery.length ? "?" + encodedQuery : ""; + } +} +exports.Transport = Transport; - return false; - } +},{"./contrib/parseqs.js":362,"./util.js":375,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],369:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.transports = void 0; +const polling_js_1 = require("./polling.js"); +const websocket_js_1 = require("./websocket.js"); +const webtransport_js_1 = require("./webtransport.js"); +exports.transports = { + websocket: websocket_js_1.WS, + webtransport: webtransport_js_1.WT, + polling: polling_js_1.Polling, +}; - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } +},{"./polling.js":370,"./websocket.js":372,"./webtransport.js":373}],370:[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.Request = exports.Polling = void 0; +const transport_js_1 = require("../transport.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const yeast_js_1 = require("../contrib/yeast.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const xmlhttprequest_js_1 = require("./xmlhttprequest.js"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("../util.js"); +const globalThis_js_1 = require("../globalThis.js"); +const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() +function empty() { } +const hasXHR2 = (function () { + const xhr = new xmlhttprequest_js_1.XHR({ + xdomain: false, + }); + return null != xhr.responseType; +})(); +class Polling extends transport_js_1.Transport { + /** + * XHR Polling constructor. + * + * @param {Object} opts + * @package + */ + constructor(opts) { + super(opts); + this.polling = false; + if (typeof location !== "undefined") { + const isSSL = "https:" === location.protocol; + let port = location.port; + // some user agents have empty `location.port` + if (!port) { + port = isSSL ? "443" : "80"; + } + this.xd = + (typeof location !== "undefined" && + opts.hostname !== location.hostname) || + port !== opts.port; + } + /** + * XHR supports binary + */ + const forceBase64 = opts && opts.forceBase64; + this.supportsBinary = hasXHR2 && !forceBase64; + if (this.opts.withCredentials) { + this.cookieJar = (0, xmlhttprequest_js_1.createCookieJar)(); + } + } + get name() { + return "polling"; + } + /** + * Opens the socket (triggers polling). We write a PING message to determine + * when the transport is open. + * + * @protected + */ + doOpen() { + this.poll(); + } + /** + * Pauses polling. + * + * @param {Function} onPause - callback upon buffers are flushed and transport is paused + * @package + */ + pause(onPause) { + this.readyState = "pausing"; + const pause = () => { + debug("paused"); + this.readyState = "paused"; + onPause(); + }; + if (this.polling || !this.writable) { + let total = 0; + if (this.polling) { + debug("we are currently polling - waiting to pause"); + total++; + this.once("pollComplete", function () { + debug("pre-pause polling complete"); + --total || pause(); + }); + } + if (!this.writable) { + debug("we are currently writing - waiting to pause"); + total++; + this.once("drain", function () { + debug("pre-pause writing complete"); + --total || pause(); + }); + } + } + else { + pause(); + } + } + /** + * Starts polling cycle. + * + * @private + */ + poll() { + debug("polling"); + this.polling = true; + this.doPoll(); + this.emitReserved("poll"); + } + /** + * Overloads onData to detect payloads. + * + * @protected + */ + onData(data) { + debug("polling got data %s", data); + const callback = (packet) => { + // if its the first message we consider the transport open + if ("opening" === this.readyState && packet.type === "open") { + this.onOpen(); + } + // if its a close packet, we close the ongoing requests + if ("close" === packet.type) { + this.onClose({ description: "transport closed by the server" }); + return false; + } + // otherwise bypass onData and handle the message + this.onPacket(packet); + }; + // decode payload + (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); + // if an event did not trigger closing + if ("closed" !== this.readyState) { + // if we got data we're not polling + this.polling = false; + this.emitReserved("pollComplete"); + if ("open" === this.readyState) { + this.poll(); + } + else { + debug('ignoring poll - transport state "%s"', this.readyState); + } + } + } + /** + * For polling, send a close packet. + * + * @protected + */ + doClose() { + const close = () => { + debug("writing close packet"); + this.write([{ type: "close" }]); + }; + if ("open" === this.readyState) { + debug("transport open - closing"); + close(); + } + else { + // in case we're trying to close while + // handshaking is in progress (GH-164) + debug("transport not open - deferring close"); + this.once("open", close); + } + } + /** + * Writes a packets payload. + * + * @param {Array} packets - data packets + * @protected + */ + write(packets) { + this.writable = false; + (0, engine_io_parser_1.encodePayload)(packets, (data) => { + this.doWrite(data, () => { + this.writable = true; + this.emitReserved("drain"); + }); + }); + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "https" : "http"; + const query = this.query || {}; + // cache busting is forced + if (false !== this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + if (!this.supportsBinary && !query.sid) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Creates a request. + * + * @param {String} method + * @private + */ + request(opts = {}) { + Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts); + return new Request(this.uri(), opts); + } + /** + * Sends data. + * + * @param {String} data to send. + * @param {Function} called upon flush. + * @private + */ + doWrite(data, fn) { + const req = this.request({ + method: "POST", + data: data, + }); + req.on("success", fn); + req.on("error", (xhrStatus, context) => { + this.onError("xhr post error", xhrStatus, context); + }); + } + /** + * Starts a poll cycle. + * + * @private + */ + doPoll() { + debug("xhr poll"); + const req = this.request(); + req.on("data", this.onData.bind(this)); + req.on("error", (xhrStatus, context) => { + this.onError("xhr poll error", xhrStatus, context); + }); + this.pollXhr = req; + } +} +exports.Polling = Polling; +class Request extends component_emitter_1.Emitter { + /** + * Request constructor + * + * @param {Object} options + * @package + */ + constructor(uri, opts) { + super(); + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.method = opts.method || "GET"; + this.uri = uri; + this.data = undefined !== opts.data ? opts.data : null; + this.create(); + } + /** + * Creates the XHR object and sends the request. + * + * @private + */ + create() { + var _a; + const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); + opts.xdomain = !!this.opts.xd; + const xhr = (this.xhr = new xmlhttprequest_js_1.XHR(opts)); + try { + debug("xhr open %s: %s", this.method, this.uri); + xhr.open(this.method, this.uri, true); + try { + if (this.opts.extraHeaders) { + xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); + for (let i in this.opts.extraHeaders) { + if (this.opts.extraHeaders.hasOwnProperty(i)) { + xhr.setRequestHeader(i, this.opts.extraHeaders[i]); + } + } + } + } + catch (e) { } + if ("POST" === this.method) { + try { + xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); + } + catch (e) { } + } + try { + xhr.setRequestHeader("Accept", "*/*"); + } + catch (e) { } + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); + // ie6 check + if ("withCredentials" in xhr) { + xhr.withCredentials = this.opts.withCredentials; + } + if (this.opts.requestTimeout) { + xhr.timeout = this.opts.requestTimeout; + } + xhr.onreadystatechange = () => { + var _a; + if (xhr.readyState === 3) { + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr); + } + if (4 !== xhr.readyState) + return; + if (200 === xhr.status || 1223 === xhr.status) { + this.onLoad(); + } + else { + // make sure the `error` event handler that's user-set + // does not throw in the same tick and gets caught here + this.setTimeoutFn(() => { + this.onError(typeof xhr.status === "number" ? xhr.status : 0); + }, 0); + } + }; + debug("xhr data %s", this.data); + xhr.send(this.data); + } + catch (e) { + // Need to defer since .create() is called directly from the constructor + // and thus the 'error' event can only be only bound *after* this exception + // occurs. Therefore, also, we cannot throw here at all. + this.setTimeoutFn(() => { + this.onError(e); + }, 0); + return; + } + if (typeof document !== "undefined") { + this.index = Request.requestsCount++; + Request.requests[this.index] = this; + } + } + /** + * Called upon error. + * + * @private + */ + onError(err) { + this.emitReserved("error", err, this.xhr); + this.cleanup(true); + } + /** + * Cleans up house. + * + * @private + */ + cleanup(fromError) { + if ("undefined" === typeof this.xhr || null === this.xhr) { + return; + } + this.xhr.onreadystatechange = empty; + if (fromError) { + try { + this.xhr.abort(); + } + catch (e) { } + } + if (typeof document !== "undefined") { + delete Request.requests[this.index]; + } + this.xhr = null; + } + /** + * Called upon load. + * + * @private + */ + onLoad() { + const data = this.xhr.responseText; + if (data !== null) { + this.emitReserved("data", data); + this.emitReserved("success"); + this.cleanup(); + } + } + /** + * Aborts the request. + * + * @package + */ + abort() { + this.cleanup(); + } +} +exports.Request = Request; +Request.requestsCount = 0; +Request.requests = {}; +/** + * Aborts pending requests when unloading the window. This is needed to prevent + * memory leaks (e.g. when using IE) and to ensure that no spurious error is + * emitted. + */ +if (typeof document !== "undefined") { + // @ts-ignore + if (typeof attachEvent === "function") { + // @ts-ignore + attachEvent("onunload", unloadHandler); + } + else if (typeof addEventListener === "function") { + const terminationEvent = "onpagehide" in globalThis_js_1.globalThisShim ? "pagehide" : "unload"; + addEventListener(terminationEvent, unloadHandler, false); + } +} +function unloadHandler() { + for (let i in Request.requests) { + if (Request.requests.hasOwnProperty(i)) { + Request.requests[i].abort(); + } + } +} - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } +},{"../contrib/yeast.js":364,"../globalThis.js":365,"../transport.js":368,"../util.js":375,"./xmlhttprequest.js":374,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],371:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0; +const globalThis_js_1 = require("../globalThis.js"); +exports.nextTick = (() => { + const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; + if (isPromiseAvailable) { + return (cb) => Promise.resolve().then(cb); + } + else { + return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + } +})(); +exports.WebSocket = globalThis_js_1.globalThisShim.WebSocket || globalThis_js_1.globalThisShim.MozWebSocket; +exports.usingBrowserWebSocket = true; +exports.defaultBinaryType = "arraybuffer"; - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } +},{"../globalThis.js":365}],372:[function(require,module,exports){ +(function (Buffer){(function (){ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WS = void 0; +const transport_js_1 = require("../transport.js"); +const yeast_js_1 = require("../contrib/yeast.js"); +const util_js_1 = require("../util.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const engine_io_parser_1 = require("engine.io-parser"); +const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() +// detect ReactNative environment +const isReactNative = typeof navigator !== "undefined" && + typeof navigator.product === "string" && + navigator.product.toLowerCase() === "reactnative"; +class WS extends transport_js_1.Transport { + /** + * WebSocket transport constructor. + * + * @param {Object} opts - connection options + * @protected + */ + constructor(opts) { + super(opts); + this.supportsBinary = !opts.forceBase64; + } + get name() { + return "websocket"; + } + doOpen() { + if (!this.check()) { + // let probe timeout + return; + } + const uri = this.uri(); + const protocols = this.opts.protocols; + // React Native only supports the 'headers' option, and will print a warning if anything else is passed + const opts = isReactNative + ? {} + : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); + if (this.opts.extraHeaders) { + opts.headers = this.opts.extraHeaders; + } + try { + this.ws = + websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative + ? protocols + ? new websocket_constructor_js_1.WebSocket(uri, protocols) + : new websocket_constructor_js_1.WebSocket(uri) + : new websocket_constructor_js_1.WebSocket(uri, protocols, opts); + } + catch (err) { + return this.emitReserved("error", err); + } + this.ws.binaryType = this.socket.binaryType; + this.addEventListeners(); + } + /** + * Adds event listeners to the socket + * + * @private + */ + addEventListeners() { + this.ws.onopen = () => { + if (this.opts.autoUnref) { + this.ws._socket.unref(); + } + this.onOpen(); + }; + this.ws.onclose = (closeEvent) => this.onClose({ + description: "websocket connection closed", + context: closeEvent, + }); + this.ws.onmessage = (ev) => this.onData(ev.data); + this.ws.onerror = (e) => this.onError("websocket error", e); + } + write(packets) { + this.writable = false; + // encodePacket efficient as it uses WS framing + // no need for encodePayload + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { + // always create a new object (GH-437) + const opts = {}; + if (!websocket_constructor_js_1.usingBrowserWebSocket) { + if (packet.options) { + opts.compress = packet.options.compress; + } + if (this.opts.perMessageDeflate) { + const len = + // @ts-ignore + "string" === typeof data ? Buffer.byteLength(data) : data.length; + if (len < this.opts.perMessageDeflate.threshold) { + opts.compress = false; + } + } + } + // Sometimes the websocket has already been closed but the browser didn't + // have a chance of informing us about it yet, in that case send will + // throw an error + try { + if (websocket_constructor_js_1.usingBrowserWebSocket) { + // TypeError is thrown when passing the second argument on Safari + this.ws.send(data); + } + else { + this.ws.send(data, opts); + } + } + catch (e) { + debug("websocket closed before onclose event"); + } + if (lastPacket) { + // fake drain + // defer to next tick to allow Socket to clear writeBuffer + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + if (typeof this.ws !== "undefined") { + this.ws.close(); + this.ws = null; + } + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "wss" : "ws"; + const query = this.query || {}; + // append timestamp to URI + if (this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + // communicate binary support capabilities + if (!this.supportsBinary) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Feature detection for WebSocket. + * + * @return {Boolean} whether this transport is available. + * @private + */ + check() { + return !!websocket_constructor_js_1.WebSocket; + } +} +exports.WS = WS; - createDebug.enable(createDebug.load()); +}).call(this)}).call(this,require("buffer").Buffer) +},{"../contrib/yeast.js":364,"../transport.js":368,"../util.js":375,"./websocket-constructor.js":371,"buffer":33,"debug":340,"engine.io-parser":380}],373:[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.WT = void 0; +const transport_js_1 = require("../transport.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const debug_1 = __importDefault(require("debug")); // debug() +const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() +class WT extends transport_js_1.Transport { + get name() { + return "webtransport"; + } + doOpen() { + // @ts-ignore + if (typeof WebTransport !== "function") { + return; + } + // @ts-ignore + this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); + this.transport.closed + .then(() => { + debug("transport closed gracefully"); + this.onClose(); + }) + .catch((err) => { + debug("transport closed due to %s", err); + this.onError("webtransport error", err); + }); + // note: we could have used async/await, but that would require some additional polyfills + this.transport.ready.then(() => { + this.transport.createBidirectionalStream().then((stream) => { + const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); + const reader = stream.readable.pipeThrough(decoderStream).getReader(); + const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); + encoderStream.readable.pipeTo(stream.writable); + this.writer = encoderStream.writable.getWriter(); + const read = () => { + reader + .read() + .then(({ done, value }) => { + if (done) { + debug("session is closed"); + return; + } + debug("received chunk: %o", value); + this.onPacket(value); + read(); + }) + .catch((err) => { + debug("an error occurred while reading: %s", err); + }); + }; + read(); + const packet = { type: "open" }; + if (this.query.sid) { + packet.data = `{"sid":"${this.query.sid}"}`; + } + this.writer.write(packet).then(() => this.onOpen()); + }); + }); + } + write(packets) { + this.writable = false; + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + this.writer.write(packet).then(() => { + if (lastPacket) { + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + var _a; + (_a = this.transport) === null || _a === void 0 ? void 0 : _a.close(); + } +} +exports.WT = WT; - return createDebug; +},{"../transport.js":368,"./websocket-constructor.js":371,"debug":340,"engine.io-parser":380}],374:[function(require,module,exports){ +"use strict"; +// browser shim for xmlhttprequest module +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createCookieJar = exports.XHR = void 0; +const has_cors_js_1 = require("../contrib/has-cors.js"); +const globalThis_js_1 = require("../globalThis.js"); +function XHR(opts) { + const xdomain = opts.xdomain; + // XMLHttpRequest can be disabled on IE + try { + if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { + return new XMLHttpRequest(); + } + } + catch (e) { } + if (!xdomain) { + try { + return new globalThis_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + catch (e) { } + } } +exports.XHR = XHR; +function createCookieJar() { } +exports.createCookieJar = createCookieJar; -module.exports = setup; +},{"../contrib/has-cors.js":361,"../globalThis.js":365}],375:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.byteLength = exports.installTimerFunctions = exports.pick = void 0; +const globalThis_js_1 = require("./globalThis.js"); +function pick(obj, ...attr) { + return attr.reduce((acc, k) => { + if (obj.hasOwnProperty(k)) { + acc[k] = obj[k]; + } + return acc; + }, {}); +} +exports.pick = pick; +// Keep a reference to the real timeout functions so they can be used when overridden +const NATIVE_SET_TIMEOUT = globalThis_js_1.globalThisShim.setTimeout; +const NATIVE_CLEAR_TIMEOUT = globalThis_js_1.globalThisShim.clearTimeout; +function installTimerFunctions(obj, opts) { + if (opts.useNativeTimers) { + obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.globalThisShim); + } + else { + obj.setTimeoutFn = globalThis_js_1.globalThisShim.setTimeout.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = globalThis_js_1.globalThisShim.clearTimeout.bind(globalThis_js_1.globalThisShim); + } +} +exports.installTimerFunctions = installTimerFunctions; +// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) +const BASE64_OVERHEAD = 1.33; +// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 +function byteLength(obj) { + if (typeof obj === "string") { + return utf8Length(obj); + } + // arraybuffer or blob + return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); +} +exports.byteLength = byteLength; +function utf8Length(str) { + let c = 0, length = 0; + for (let i = 0, l = str.length; i < l; i++) { + c = str.charCodeAt(i); + if (c < 0x80) { + length += 1; + } + else if (c < 0x800) { + length += 2; + } + else if (c < 0xd800 || c >= 0xe000) { + length += 3; + } + else { + i++; + length += 4; + } + } + return length; +} -},{"ms":441}],382:[function(require,module,exports){ +},{"./globalThis.js":365}],376:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0; @@ -21679,7 +21350,7 @@ Object.keys(PACKET_TYPES).forEach((key) => { const ERROR_PACKET = { type: "error", data: "parser error" }; exports.ERROR_PACKET = ERROR_PACKET; -},{}],383:[function(require,module,exports){ +},{}],377:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decode = exports.encode = void 0; @@ -21729,7 +21400,7 @@ const decode = (base64) => { }; exports.decode = decode; -},{}],384:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodePacket = void 0; @@ -21797,11 +21468,10 @@ const mapBinary = (data, binaryType) => { } }; -},{"./commons.js":382,"./contrib/base64-arraybuffer.js":383}],385:[function(require,module,exports){ +},{"./commons.js":376,"./contrib/base64-arraybuffer.js":377}],379:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodePacket = void 0; -exports.encodePacketToBinary = encodePacketToBinary; +exports.encodePacket = exports.encodePacketToBinary = void 0; const commons_js_1 = require("./commons.js"); const withNativeBlob = typeof Blob === "function" || (typeof Blob !== "undefined" && @@ -21870,13 +21540,12 @@ function encodePacketToBinary(packet, callback) { callback(TEXT_ENCODER.encode(encoded)); }); } +exports.encodePacketToBinary = encodePacketToBinary; -},{"./commons.js":382}],386:[function(require,module,exports){ +},{"./commons.js":376}],380:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; -exports.createPacketEncoderStream = createPacketEncoderStream; -exports.createPacketDecoderStream = createPacketDecoderStream; +exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0; const encodePacket_js_1 = require("./encodePacket.js"); Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }); const decodePacket_js_1 = require("./decodePacket.js"); @@ -21913,6 +21582,7 @@ const decodePayload = (encodedPayload, binaryType) => { }; exports.decodePayload = decodePayload; function createPacketEncoderStream() { + // @ts-expect-error return new TransformStream({ transform(packet, controller) { (0, encodePacket_js_1.encodePacketToBinary)(packet, (encodedPacket) => { @@ -21945,6 +21615,7 @@ function createPacketEncoderStream() { }, }); } +exports.createPacketEncoderStream = createPacketEncoderStream; let TEXT_DECODER; function totalLength(chunks) { return chunks.reduce((acc, chunk) => acc + chunk.length, 0); @@ -21972,14 +21643,15 @@ function createPacketDecoderStream(maxPayload, binaryType) { TEXT_DECODER = new TextDecoder(); } const chunks = []; - let state = 0 /* State.READ_HEADER */; + let state = 0 /* READ_HEADER */; let expectedLength = -1; let isBinary = false; + // @ts-expect-error return new TransformStream({ transform(chunk, controller) { chunks.push(chunk); while (true) { - if (state === 0 /* State.READ_HEADER */) { + if (state === 0 /* READ_HEADER */) { if (totalLength(chunks) < 1) { break; } @@ -21987,24 +21659,24 @@ function createPacketDecoderStream(maxPayload, binaryType) { isBinary = (header[0] & 0x80) === 0x80; expectedLength = header[0] & 0x7f; if (expectedLength < 126) { - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else if (expectedLength === 126) { - state = 1 /* State.READ_EXTENDED_LENGTH_16 */; + state = 1 /* READ_EXTENDED_LENGTH_16 */; } else { - state = 2 /* State.READ_EXTENDED_LENGTH_64 */; + state = 2 /* READ_EXTENDED_LENGTH_64 */; } } - else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { + else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { if (totalLength(chunks) < 2) { break; } const headerArray = concatChunks(chunks, 2); expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } - else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { + else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { if (totalLength(chunks) < 8) { break; } @@ -22017,7 +21689,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { break; } expectedLength = n * Math.pow(2, 32) + view.getUint32(4); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else { if (totalLength(chunks) < expectedLength) { @@ -22025,7 +21697,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { } const data = concatChunks(chunks, expectedLength); controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); - state = 0 /* State.READ_HEADER */; + state = 0 /* READ_HEADER */; } if (expectedLength === 0 || expectedLength > maxPayload) { controller.enqueue(commons_js_1.ERROR_PACKET); @@ -22035,13 +21707,16 @@ function createPacketDecoderStream(maxPayload, binaryType) { }, }); } +exports.createPacketDecoderStream = createPacketDecoderStream; exports.protocol = 4; -},{"./commons.js":382,"./decodePacket.js":384,"./encodePacket.js":385}],387:[function(require,module,exports){ +},{"./commons.js":376,"./decodePacket.js":378,"./encodePacket.js":379}],381:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); + /** @type {import('.')} */ -var $defineProperty = Object.defineProperty || false; +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false; if ($defineProperty) { try { $defineProperty({}, 'a', { value: 1 }); @@ -22053,55 +21728,49 @@ if ($defineProperty) { module.exports = $defineProperty; -},{}],388:[function(require,module,exports){ +},{"get-intrinsic":393}],382:[function(require,module,exports){ 'use strict'; /** @type {import('./eval')} */ module.exports = EvalError; -},{}],389:[function(require,module,exports){ +},{}],383:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ module.exports = Error; -},{}],390:[function(require,module,exports){ +},{}],384:[function(require,module,exports){ 'use strict'; /** @type {import('./range')} */ module.exports = RangeError; -},{}],391:[function(require,module,exports){ +},{}],385:[function(require,module,exports){ 'use strict'; /** @type {import('./ref')} */ module.exports = ReferenceError; -},{}],392:[function(require,module,exports){ +},{}],386:[function(require,module,exports){ 'use strict'; /** @type {import('./syntax')} */ module.exports = SyntaxError; -},{}],393:[function(require,module,exports){ +},{}],387:[function(require,module,exports){ 'use strict'; /** @type {import('./type')} */ module.exports = TypeError; -},{}],394:[function(require,module,exports){ +},{}],388:[function(require,module,exports){ 'use strict'; /** @type {import('./uri')} */ module.exports = URIError; -},{}],395:[function(require,module,exports){ -'use strict'; - -/** @type {import('.')} */ -module.exports = Object; - -},{}],396:[function(require,module,exports){ +},{}],389:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keccak512 = exports.keccak384 = exports.keccak256 = exports.keccak224 = void 0; @@ -22116,17 +21785,13 @@ exports.keccak256 = (() => { exports.keccak384 = (0, utils_js_1.wrapHash)(sha3_1.keccak_384); exports.keccak512 = (0, utils_js_1.wrapHash)(sha3_1.keccak_512); -},{"./utils.js":397,"@noble/hashes/sha3":21}],397:[function(require,module,exports){ +},{"./utils.js":390,"@noble/hashes/sha3":21}],390:[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.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; -exports.bytesToUtf8 = bytesToUtf8; -exports.hexToBytes = hexToBytes; -exports.equalsBytes = equalsBytes; -exports.wrapHash = wrapHash; +exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; const _assert_1 = __importDefault(require("@noble/hashes/_assert")); const utils_1 = require("@noble/hashes/utils"); const assertBool = _assert_1.default.bool; @@ -22146,10 +21811,12 @@ function bytesToUtf8(data) { } return new TextDecoder().decode(data); } +exports.bytesToUtf8 = bytesToUtf8; function hexToBytes(data) { const sliced = data.startsWith("0x") ? data.substring(2) : data; return (0, utils_1.hexToBytes)(sliced); } +exports.hexToBytes = hexToBytes; // buf.equals(buf2) -> equalsBytes(buf, buf2) function equalsBytes(a, b) { if (a.length !== b.length) { @@ -22162,6 +21829,7 @@ function equalsBytes(a, b) { } return true; } +exports.equalsBytes = equalsBytes; // Internal utils function wrapHash(hash) { return (msg) => { @@ -22169,8 +21837,20 @@ function wrapHash(hash) { return hash(msg); }; } +exports.wrapHash = wrapHash; +// TODO(v3): switch away from node crypto, remove this unnecessary variable. +exports.crypto = (() => { + const webCrypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined; + const nodeRequire = typeof module !== "undefined" && + typeof module.require === "function" && + module.require.bind(module); + return { + node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined, + web: webCrypto + }; +})(); -},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],398:[function(require,module,exports){ +},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],391:[function(require,module,exports){ 'use strict'; /* eslint no-invalid-this: 1 */ @@ -22256,20 +21936,18 @@ module.exports = function bind(that) { return bound; }; -},{}],399:[function(require,module,exports){ +},{}],392:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":398}],400:[function(require,module,exports){ +},{"./implementation":391}],393:[function(require,module,exports){ 'use strict'; var undefined; -var $Object = require('es-object-atoms'); - var $Error = require('es-errors'); var $EvalError = require('es-errors/eval'); var $RangeError = require('es-errors/range'); @@ -22278,14 +21956,6 @@ var $SyntaxError = require('es-errors/syntax'); var $TypeError = require('es-errors/type'); var $URIError = require('es-errors/uri'); -var abs = require('math-intrinsics/abs'); -var floor = require('math-intrinsics/floor'); -var max = require('math-intrinsics/max'); -var min = require('math-intrinsics/min'); -var pow = require('math-intrinsics/pow'); -var round = require('math-intrinsics/round'); -var sign = require('math-intrinsics/sign'); - var $Function = Function; // eslint-disable-next-line consistent-return @@ -22295,8 +21965,14 @@ var getEvalledConstructor = function (expressionSyntax) { } catch (e) {} }; -var $gOPD = require('gopd'); -var $defineProperty = require('es-define-property'); +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} var throwTypeError = function () { throw new $TypeError(); @@ -22319,13 +21995,13 @@ var ThrowTypeError = $gOPD : throwTypeError; var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); -var getProto = require('get-proto'); -var $ObjectGPO = require('get-proto/Object.getPrototypeOf'); -var $ReflectGPO = require('get-proto/Reflect.getPrototypeOf'); - -var $apply = require('call-bind-apply-helpers/functionApply'); -var $call = require('call-bind-apply-helpers/functionCall'); +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); var needsEval = {}; @@ -22372,8 +22048,7 @@ var INTRINSICS = { '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), '%Math%': Math, '%Number%': Number, - '%Object%': $Object, - '%Object.getOwnPropertyDescriptor%': $gOPD, + '%Object%': Object, '%parseFloat%': parseFloat, '%parseInt%': parseInt, '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, @@ -22399,20 +22074,7 @@ var INTRINSICS = { '%URIError%': $URIError, '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, - '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet, - - '%Function.prototype.call%': $call, - '%Function.prototype.apply%': $apply, - '%Object.defineProperty%': $defineProperty, - '%Object.getPrototypeOf%': $ObjectGPO, - '%Math.abs%': abs, - '%Math.floor%': floor, - '%Math.max%': max, - '%Math.min%': min, - '%Math.pow%': pow, - '%Math.round%': round, - '%Math.sign%': sign, - '%Reflect.getPrototypeOf%': $ReflectGPO + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet }; if (getProto) { @@ -22507,11 +22169,11 @@ var LEGACY_ALIASES = { var bind = require('function-bind'); var hasOwn = require('hasown'); -var $concat = bind.call($call, Array.prototype.concat); -var $spliceApply = bind.call($apply, Array.prototype.splice); -var $replace = bind.call($call, String.prototype.replace); -var $strSlice = bind.call($call, String.prototype.slice); -var $exec = bind.call($call, RegExp.prototype.exec); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; @@ -22642,60 +22304,12 @@ module.exports = function GetIntrinsic(name, allowMissing) { return value; }; -},{"call-bind-apply-helpers/functionApply":36,"call-bind-apply-helpers/functionCall":37,"es-define-property":387,"es-errors":389,"es-errors/eval":388,"es-errors/range":390,"es-errors/ref":391,"es-errors/syntax":392,"es-errors/type":393,"es-errors/uri":394,"es-object-atoms":395,"function-bind":399,"get-proto":403,"get-proto/Object.getPrototypeOf":401,"get-proto/Reflect.getPrototypeOf":402,"gopd":405,"has-symbols":407,"hasown":421,"math-intrinsics/abs":431,"math-intrinsics/floor":432,"math-intrinsics/max":434,"math-intrinsics/min":435,"math-intrinsics/pow":436,"math-intrinsics/round":437,"math-intrinsics/sign":438}],401:[function(require,module,exports){ -'use strict'; - -var $Object = require('es-object-atoms'); - -/** @type {import('./Object.getPrototypeOf')} */ -module.exports = $Object.getPrototypeOf || null; - -},{"es-object-atoms":395}],402:[function(require,module,exports){ +},{"es-errors":383,"es-errors/eval":382,"es-errors/range":384,"es-errors/ref":385,"es-errors/syntax":386,"es-errors/type":387,"es-errors/uri":388,"function-bind":392,"has-proto":396,"has-symbols":397,"hasown":411}],394:[function(require,module,exports){ 'use strict'; -/** @type {import('./Reflect.getPrototypeOf')} */ -module.exports = (typeof Reflect !== 'undefined' && Reflect.getPrototypeOf) || null; - -},{}],403:[function(require,module,exports){ -'use strict'; - -var reflectGetProto = require('./Reflect.getPrototypeOf'); -var originalGetProto = require('./Object.getPrototypeOf'); - -var getDunderProto = require('dunder-proto/get'); - -/** @type {import('.')} */ -module.exports = reflectGetProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return reflectGetProto(O); - } - : originalGetProto - ? function getProto(O) { - if (!O || (typeof O !== 'object' && typeof O !== 'function')) { - throw new TypeError('getProto: not an object'); - } - // @ts-expect-error TS can't narrow inside a closure, for some reason - return originalGetProto(O); - } - : getDunderProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return getDunderProto(O); - } - : null; - -},{"./Object.getPrototypeOf":401,"./Reflect.getPrototypeOf":402,"dunder-proto/get":348}],404:[function(require,module,exports){ -'use strict'; - -/** @type {import('./gOPD')} */ -module.exports = Object.getOwnPropertyDescriptor; - -},{}],405:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -/** @type {import('.')} */ -var $gOPD = require('./gOPD'); +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); if ($gOPD) { try { @@ -22708,7 +22322,7 @@ if ($gOPD) { module.exports = $gOPD; -},{"./gOPD":404}],406:[function(require,module,exports){ +},{"get-intrinsic":393}],395:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -22732,13 +22346,29 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu module.exports = hasPropertyDescriptors; -},{"es-define-property":387}],407:[function(require,module,exports){ +},{"es-define-property":381}],396:[function(require,module,exports){ +'use strict'; + +var test = { + __proto__: null, + foo: {} +}; + +var $Object = Object; + +/** @type {import('.')} */ +module.exports = function hasProto() { + // @ts-expect-error: TS errors on an inherited property for some reason + return { __proto__: test }.foo === test.foo + && !(test instanceof $Object); +}; + +},{}],397:[function(require,module,exports){ 'use strict'; var origSymbol = typeof Symbol !== 'undefined' && Symbol; var hasSymbolSham = require('./shams'); -/** @type {import('.')} */ module.exports = function hasNativeSymbols() { if (typeof origSymbol !== 'function') { return false; } if (typeof Symbol !== 'function') { return false; } @@ -22748,16 +22378,14 @@ module.exports = function hasNativeSymbols() { return hasSymbolSham(); }; -},{"./shams":408}],408:[function(require,module,exports){ +},{"./shams":398}],398:[function(require,module,exports){ 'use strict'; -/** @type {import('./shams')} */ /* eslint complexity: [2, 18], max-statements: [2, 33] */ module.exports = function hasSymbols() { if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } if (typeof Symbol.iterator === 'symbol') { return true; } - /** @type {{ [k in symbol]?: unknown }} */ var obj = {}; var sym = Symbol('test'); var symObj = Object(sym); @@ -22776,7 +22404,7 @@ module.exports = function hasSymbols() { var symVal = 42; obj[sym] = symVal; - for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } @@ -22787,15 +22415,14 @@ module.exports = function hasSymbols() { if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } if (typeof Object.getOwnPropertyDescriptor === 'function') { - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym)); + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } } return true; }; -},{}],409:[function(require,module,exports){ +},{}],399:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -22812,7 +22439,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":410,"./hash/hmac":411,"./hash/ripemd":412,"./hash/sha":413,"./hash/utils":420}],410:[function(require,module,exports){ +},{"./hash/common":400,"./hash/hmac":401,"./hash/ripemd":402,"./hash/sha":403,"./hash/utils":410}],400:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -22906,7 +22533,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":420,"minimalistic-assert":439}],411:[function(require,module,exports){ +},{"./utils":410,"minimalistic-assert":421}],401:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -22955,7 +22582,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":420,"minimalistic-assert":439}],412:[function(require,module,exports){ +},{"./utils":410,"minimalistic-assert":421}],402:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -23103,7 +22730,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":410,"./utils":420}],413:[function(require,module,exports){ +},{"./common":400,"./utils":410}],403:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -23112,7 +22739,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":414,"./sha/224":415,"./sha/256":416,"./sha/384":417,"./sha/512":418}],414:[function(require,module,exports){ +},{"./sha/1":404,"./sha/224":405,"./sha/256":406,"./sha/384":407,"./sha/512":408}],404:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23188,7 +22815,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":410,"../utils":420,"./common":419}],415:[function(require,module,exports){ +},{"../common":400,"../utils":410,"./common":409}],405:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23220,7 +22847,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":420,"./256":416}],416:[function(require,module,exports){ +},{"../utils":410,"./256":406}],406:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23327,7 +22954,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":410,"../utils":420,"./common":419,"minimalistic-assert":439}],417:[function(require,module,exports){ +},{"../common":400,"../utils":410,"./common":409,"minimalistic-assert":421}],407:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23364,7 +22991,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":420,"./512":418}],418:[function(require,module,exports){ +},{"../utils":410,"./512":408}],408:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23696,7 +23323,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":410,"../utils":420,"minimalistic-assert":439}],419:[function(require,module,exports){ +},{"../common":400,"../utils":410,"minimalistic-assert":421}],409:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23747,7 +23374,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":420}],420:[function(require,module,exports){ +},{"../utils":410}],410:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -24027,7 +23654,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":424,"minimalistic-assert":439}],421:[function(require,module,exports){ +},{"inherits":414,"minimalistic-assert":421}],411:[function(require,module,exports){ 'use strict'; var call = Function.prototype.call; @@ -24037,7 +23664,7 @@ var bind = require('function-bind'); /** @type {import('.')} */ module.exports = bind.call(call, $hasOwn); -},{"function-bind":399}],422:[function(require,module,exports){ +},{"function-bind":392}],412:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -24152,7 +23779,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":409,"minimalistic-assert":439,"minimalistic-crypto-utils":440}],423:[function(require,module,exports){ +},{"hash.js":399,"minimalistic-assert":421,"minimalistic-crypto-utils":422}],413:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -24239,7 +23866,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],424:[function(require,module,exports){ +},{}],414:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -24268,30 +23895,26 @@ if (typeof Object.create === 'function') { } } -},{}],425:[function(require,module,exports){ +},{}],415:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],426:[function(require,module,exports){ +},{}],416:[function(require,module,exports){ 'use strict'; -/** @type {typeof JSON.stringify} */ var jsonStringify = (typeof JSON !== 'undefined' ? JSON : require('jsonify')).stringify; var isArray = require('isarray'); var objectKeys = require('object-keys'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $join = callBound('Array.prototype.join'); -var $indexOf = callBound('Array.prototype.indexOf'); -var $splice = callBound('Array.prototype.splice'); -var $sort = callBound('Array.prototype.sort'); +var $push = callBound('Array.prototype.push'); -/** @type {(n: number, char: string) => string} */ var strRepeat = function repeat(n, char) { var str = ''; for (var i = 0; i < n; i += 1) { @@ -24300,103 +23923,85 @@ var strRepeat = function repeat(n, char) { return str; }; -/** @type {(parent: import('.').Node, key: import('.').Key, value: unknown) => unknown} */ -var defaultReplacer = function (_parent, _key, value) { return value; }; +var defaultReplacer = function (parent, key, value) { return value; }; -/** @type {import('.')} */ module.exports = function stableStringify(obj) { - /** @type {Parameters[1]} */ var opts = arguments.length > 1 ? arguments[1] : void undefined; var space = (opts && opts.space) || ''; if (typeof space === 'number') { space = strRepeat(space, ' '); } var cycles = !!opts && typeof opts.cycles === 'boolean' && opts.cycles; - /** @type {undefined | typeof defaultReplacer} */ var replacer = opts && opts.replacer ? callBind(opts.replacer) : defaultReplacer; var cmpOpt = typeof opts === 'function' ? opts : opts && opts.cmp; - /** @type {undefined | ((node: T) => (a: Exclude, b: Exclude) => number)} */ var cmp = cmpOpt && function (node) { - // eslint-disable-next-line no-extra-parens - var get = /** @type {NonNullable} */ (cmpOpt).length > 2 - && /** @type {import('.').Getter['get']} */ function get(k) { return node[k]; }; + var get = cmpOpt.length > 2 && function get(k) { return node[k]; }; return function (a, b) { - // eslint-disable-next-line no-extra-parens - return /** @type {NonNullable} */ (cmpOpt)( + return cmpOpt( { key: a, value: node[a] }, { key: b, value: node[b] }, - // @ts-expect-error TS doesn't understand the optimization used here - get ? /** @type {import('.').Getter} */ { __proto__: null, get: get } : void undefined + get ? { __proto__: null, get: get } : void undefined ); }; }; - /** @type {import('.').Node[]} */ var seen = []; - return (/** @type {(parent: import('.').Node, key: string | number, node: unknown, level: number) => string | undefined} */ - function stringify(parent, key, node, level) { - var indent = space ? '\n' + strRepeat(level, space) : ''; - var colonSeparator = space ? ': ' : ':'; - - // eslint-disable-next-line no-extra-parens - if (node && /** @type {{ toJSON?: unknown }} */ (node).toJSON && typeof /** @type {{ toJSON?: unknown }} */ (node).toJSON === 'function') { - // eslint-disable-next-line no-extra-parens - node = /** @type {{ toJSON: Function }} */ (node).toJSON(); - } + return (function stringify(parent, key, node, level) { + var indent = space ? '\n' + strRepeat(level, space) : ''; + var colonSeparator = space ? ': ' : ':'; - node = replacer(parent, key, node); + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON(); + } - if (node === undefined) { - return; - } - if (typeof node !== 'object' || node === null) { - return jsonStringify(node); - } - if (isArray(node)) { - var out = []; - for (var i = 0; i < node.length; i++) { - var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); - out[out.length] = indent + space + item; - } - return '[' + $join(out, ',') + indent + ']'; - } + node = replacer(parent, key, node); - if ($indexOf(seen, node) !== -1) { - if (cycles) { return jsonStringify('__cycle__'); } - throw new TypeError('Converting circular structure to JSON'); - } else { - seen[seen.length] = /** @type {import('.').NonArrayNode} */ (node); + if (node === undefined) { + return; + } + if (typeof node !== 'object' || node === null) { + return jsonStringify(node); + } + if (isArray(node)) { + var out = []; + for (var i = 0; i < node.length; i++) { + var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); + $push(out, indent + space + item); } + return '[' + $join(out, ',') + indent + ']'; + } - /** @type {import('.').Key[]} */ - // eslint-disable-next-line no-extra-parens - var keys = $sort(objectKeys(node), cmp && cmp(/** @type {import('.').NonArrayNode} */ (node))); - var out = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // eslint-disable-next-line no-extra-parens - var value = stringify(/** @type {import('.').Node} */ (node), key, /** @type {import('.').NonArrayNode} */ (node)[key], level + 1); + if (seen.indexOf(node) !== -1) { + if (cycles) { return jsonStringify('__cycle__'); } + throw new TypeError('Converting circular structure to JSON'); + } else { $push(seen, node); } - if (!value) { continue; } + var keys = objectKeys(node).sort(cmp && cmp(node)); + var out = []; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = stringify(node, key, node[key], level + 1); - var keyValue = jsonStringify(key) - + colonSeparator - + value; + if (!value) { continue; } - out[out.length] = indent + space + keyValue; - } - $splice(seen, $indexOf(seen, node), 1); - return '{' + $join(out, ',') + indent + '}'; - }({ '': obj }, '', obj, 0) - ); + var keyValue = jsonStringify(key) + + colonSeparator + + value; + + $push(out, indent + space + keyValue); + } + seen.splice(seen.indexOf(node), 1); + return '{' + $join(out, ',') + indent + '}'; + + }({ '': obj }, '', obj, 0)); }; -},{"call-bind":40,"call-bound":41,"isarray":425,"jsonify":427,"object-keys":443}],427:[function(require,module,exports){ +},{"call-bind":35,"call-bind/callBound":34,"isarray":415,"jsonify":417,"object-keys":425}],417:[function(require,module,exports){ 'use strict'; exports.parse = require('./lib/parse'); exports.stringify = require('./lib/stringify'); -},{"./lib/parse":428,"./lib/stringify":429}],428:[function(require,module,exports){ +},{"./lib/parse":418,"./lib/stringify":419}],418:[function(require,module,exports){ 'use strict'; var at; // The index of the current character @@ -24659,7 +24264,7 @@ module.exports = function (source, reviver) { }({ '': result }, '')) : result; }; -},{}],429:[function(require,module,exports){ +},{}],419:[function(require,module,exports){ 'use strict'; var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; @@ -24812,7 +24417,7 @@ module.exports = function (value, replacer, space) { return str('', { '': value }); }; -},{}],430:[function(require,module,exports){ +},{}],420:[function(require,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -25171,64 +24776,7 @@ module.exports = function (value, replacer, space) { return defaultLogger; })); -},{}],431:[function(require,module,exports){ -'use strict'; - -/** @type {import('./abs')} */ -module.exports = Math.abs; - -},{}],432:[function(require,module,exports){ -'use strict'; - -/** @type {import('./floor')} */ -module.exports = Math.floor; - -},{}],433:[function(require,module,exports){ -'use strict'; - -/** @type {import('./isNaN')} */ -module.exports = Number.isNaN || function isNaN(a) { - return a !== a; -}; - -},{}],434:[function(require,module,exports){ -'use strict'; - -/** @type {import('./max')} */ -module.exports = Math.max; - -},{}],435:[function(require,module,exports){ -'use strict'; - -/** @type {import('./min')} */ -module.exports = Math.min; - -},{}],436:[function(require,module,exports){ -'use strict'; - -/** @type {import('./pow')} */ -module.exports = Math.pow; - -},{}],437:[function(require,module,exports){ -'use strict'; - -/** @type {import('./round')} */ -module.exports = Math.round; - -},{}],438:[function(require,module,exports){ -'use strict'; - -var $isNaN = require('./isNaN'); - -/** @type {import('./sign')} */ -module.exports = function sign(number) { - if ($isNaN(number) || number === 0) { - return number; - } - return number < 0 ? -1 : +1; -}; - -},{"./isNaN":433}],439:[function(require,module,exports){ +},{}],421:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -25241,7 +24789,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],440:[function(require,module,exports){ +},{}],422:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -25301,7 +24849,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],441:[function(require,module,exports){ +},{}],423:[function(require,module,exports){ /** * Helpers. */ @@ -25327,7 +24875,7 @@ var y = d * 365.25; * @api public */ -module.exports = function (val, options) { +module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { @@ -25465,7 +25013,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],442:[function(require,module,exports){ +},{}],424:[function(require,module,exports){ 'use strict'; var keysShim; @@ -25589,7 +25137,7 @@ if (!Object.keys) { } module.exports = keysShim; -},{"./isArguments":444}],443:[function(require,module,exports){ +},{"./isArguments":426}],425:[function(require,module,exports){ 'use strict'; var slice = Array.prototype.slice; @@ -25623,7 +25171,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./implementation":442,"./isArguments":444}],444:[function(require,module,exports){ +},{"./implementation":424,"./isArguments":426}],426:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -25642,7 +25190,7 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],445:[function(require,module,exports){ +},{}],427:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -25671,7 +25219,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const pkg = __importStar(require("./index.js")); module.exports = pkg; -},{"./index.js":446}],446:[function(require,module,exports){ +},{"./index.js":428}],428:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.now = exports.removeTooOldValues = exports.ObliviousSet = void 0; @@ -25748,7 +25296,7 @@ function now() { } exports.now = now; -},{}],447:[function(require,module,exports){ +},{}],429:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -25934,7 +25482,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],448:[function(require,module,exports){ +},{}],430:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -26697,7 +26245,7 @@ try { } } -},{}],449:[function(require,module,exports){ +},{}],431:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -26741,7 +26289,7 @@ module.exports = function setFunctionLength(fn, length) { return fn; }; -},{"define-data-property":347,"es-errors/type":393,"get-intrinsic":400,"gopd":405,"has-property-descriptors":406}],450:[function(require,module,exports){ +},{"define-data-property":343,"es-errors/type":387,"get-intrinsic":393,"gopd":394,"has-property-descriptors":395}],432:[function(require,module,exports){ "use strict"; /** * Initialize backoff timer with `opts`. @@ -26755,7 +26303,7 @@ module.exports = function setFunctionLength(fn, length) { * @api public */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Backoff = Backoff; +exports.Backoff = void 0; function Backoff(opts) { opts = opts || {}; this.ms = opts.min || 100; @@ -26764,6 +26312,7 @@ function Backoff(opts) { this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; this.attempts = 0; } +exports.Backoff = Backoff; /** * Return the backoff duration. * @@ -26812,23 +26361,20 @@ Backoff.prototype.setJitter = function (jitter) { this.jitter = jitter; }; -},{}],451:[function(require,module,exports){ +},{}],433:[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.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.Socket = exports.Manager = exports.protocol = void 0; -exports.io = lookup; -exports.connect = lookup; -exports.default = lookup; +exports.default = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0; const url_js_1 = require("./url.js"); const manager_js_1 = require("./manager.js"); Object.defineProperty(exports, "Manager", { enumerable: true, get: function () { return manager_js_1.Manager; } }); const socket_js_1 = require("./socket.js"); Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client"); // debug() +const debug = debug_1.default("socket.io-client"); // debug() /** * Managers cache. */ @@ -26839,7 +26385,7 @@ function lookup(uri, opts) { uri = undefined; } opts = opts || {}; - const parsed = (0, url_js_1.url)(uri, opts.path || "/socket.io"); + const parsed = url_js_1.url(uri, opts.path || "/socket.io"); const source = parsed.source; const id = parsed.id; const path = parsed.path; @@ -26865,6 +26411,9 @@ function lookup(uri, opts) { } return io.socket(parsed.path, opts); } +exports.io = lookup; +exports.connect = lookup; +exports.default = lookup; // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a // namespace (e.g. `io.connect(...)`), for backward compatibility Object.assign(lookup, { @@ -26880,25 +26429,14 @@ Object.assign(lookup, { */ var socket_io_parser_1 = require("socket.io-parser"); Object.defineProperty(exports, "protocol", { enumerable: true, get: function () { return socket_io_parser_1.protocol; } }); -var engine_io_client_1 = require("engine.io-client"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return engine_io_client_1.Fetch; } }); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return engine_io_client_1.NodeXHR; } }); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return engine_io_client_1.XHR; } }); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return engine_io_client_1.NodeWebSocket; } }); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return engine_io_client_1.WebSocket; } }); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return engine_io_client_1.WebTransport; } }); module.exports = lookup; -},{"./manager.js":452,"./socket.js":454,"./url.js":455,"debug":456,"engine.io-client":370,"socket.io-parser":459}],452:[function(require,module,exports){ +},{"./manager.js":434,"./socket.js":436,"./url.js":437,"debug":340,"socket.io-parser":439}],434:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); + 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]; @@ -26927,7 +26465,7 @@ const on_js_1 = require("./on.js"); const backo2_js_1 = require("./contrib/backo2.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:manager"); // debug() +const debug = debug_1.default("socket.io-client:manager"); // debug() class Manager extends component_emitter_1.Emitter { constructor(uri, opts) { var _a; @@ -26941,7 +26479,7 @@ class Manager extends component_emitter_1.Emitter { opts = opts || {}; opts.path = opts.path || "/socket.io"; this.opts = opts; - (0, engine_io_client_1.installTimerFunctions)(this, opts); + engine_io_client_1.installTimerFunctions(this, opts); this.reconnection(opts.reconnection !== false); this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); this.reconnectionDelay(opts.reconnectionDelay || 1000); @@ -26966,9 +26504,6 @@ class Manager extends component_emitter_1.Emitter { if (!arguments.length) return this._reconnection; this._reconnection = !!v; - if (!v) { - this.skipReconnect = true; - } return this; } reconnectionAttempts(v) { @@ -27040,7 +26575,7 @@ class Manager extends component_emitter_1.Emitter { this._readyState = "opening"; this.skipReconnect = false; // emit `open` - const openSubDestroy = (0, on_js_1.on)(socket, "open", function () { + const openSubDestroy = on_js_1.on(socket, "open", function () { self.onopen(); fn && fn(); }); @@ -27058,7 +26593,7 @@ class Manager extends component_emitter_1.Emitter { } }; // emit `error` - const errorSub = (0, on_js_1.on)(socket, "error", onError); + const errorSub = on_js_1.on(socket, "error", onError); if (false !== this._timeout) { const timeout = this._timeout; debug("connect attempt will timeout after %d", timeout); @@ -27103,9 +26638,7 @@ class Manager extends component_emitter_1.Emitter { this.emitReserved("open"); // add new subs const socket = this.engine; - this.subs.push((0, on_js_1.on)(socket, "ping", this.onping.bind(this)), (0, on_js_1.on)(socket, "data", this.ondata.bind(this)), (0, on_js_1.on)(socket, "error", this.onerror.bind(this)), (0, on_js_1.on)(socket, "close", this.onclose.bind(this)), - // @ts-ignore - (0, on_js_1.on)(this.decoder, "decoded", this.ondecoded.bind(this))); + this.subs.push(on_js_1.on(socket, "ping", this.onping.bind(this)), on_js_1.on(socket, "data", this.ondata.bind(this)), on_js_1.on(socket, "error", this.onerror.bind(this)), on_js_1.on(socket, "close", this.onclose.bind(this)), on_js_1.on(this.decoder, "decoded", this.ondecoded.bind(this))); } /** * Called upon a ping. @@ -27135,7 +26668,7 @@ class Manager extends component_emitter_1.Emitter { */ ondecoded(packet) { // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error" - (0, engine_io_client_1.nextTick)(() => { + engine_io_client_1.nextTick(() => { this.emitReserved("packet", packet); }, this.setTimeoutFn); } @@ -27216,6 +26749,8 @@ class Manager extends component_emitter_1.Emitter { this.skipReconnect = true; this._reconnecting = false; this.onclose("forced close"); + if (this.engine) + this.engine.close(); } /** * Alias for close() @@ -27226,19 +26761,13 @@ class Manager extends component_emitter_1.Emitter { return this._close(); } /** - * Called when: - * - * - the low-level engine is closed - * - the parser encountered a badly formatted packet - * - all sockets are disconnected + * Called upon engine close. * * @private */ onclose(reason, description) { - var _a; debug("closed due to %s", reason); this.cleanup(); - (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close(); this.backoff.reset(); this._readyState = "closed"; this.emitReserved("close", reason, description); @@ -27308,18 +26837,19 @@ class Manager extends component_emitter_1.Emitter { } exports.Manager = Manager; -},{"./contrib/backo2.js":450,"./on.js":453,"./socket.js":454,"@socket.io/component-emitter":23,"debug":456,"engine.io-client":370,"socket.io-parser":459}],453:[function(require,module,exports){ +},{"./contrib/backo2.js":432,"./on.js":435,"./socket.js":436,"@socket.io/component-emitter":23,"debug":340,"engine.io-client":366,"socket.io-parser":439}],435:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.on = on; +exports.on = void 0; function on(obj, ev, fn) { obj.on(ev, fn); return function subDestroy() { obj.off(ev, fn); }; } +exports.on = on; -},{}],454:[function(require,module,exports){ +},{}],436:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -27330,7 +26860,7 @@ const socket_io_parser_1 = require("socket.io-parser"); const on_js_1 = require("./on.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:socket"); // debug() +const debug = debug_1.default("socket.io-client:socket"); // debug() /** * Internal events. * These events can't be emitted by the user. @@ -27476,10 +27006,10 @@ class Socket extends component_emitter_1.Emitter { return; const io = this.io; this.subs = [ - (0, on_js_1.on)(io, "open", this.onopen.bind(this)), - (0, on_js_1.on)(io, "packet", this.onpacket.bind(this)), - (0, on_js_1.on)(io, "error", this.onerror.bind(this)), - (0, on_js_1.on)(io, "close", this.onclose.bind(this)), + on_js_1.on(io, "open", this.onopen.bind(this)), + on_js_1.on(io, "packet", this.onpacket.bind(this)), + on_js_1.on(io, "error", this.onerror.bind(this)), + on_js_1.on(io, "close", this.onclose.bind(this)), ]; } /** @@ -27566,7 +27096,6 @@ class Socket extends component_emitter_1.Emitter { * @return self */ emit(ev, ...args) { - var _a, _b, _c; if (RESERVED_EVENTS.hasOwnProperty(ev)) { throw new Error('"' + ev.toString() + '" is a reserved event name'); } @@ -27589,13 +27118,14 @@ class Socket extends component_emitter_1.Emitter { this._registerAckCallback(id, ack); packet.id = id; } - const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable; - const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired()); - const discardPacket = this.flags.volatile && !isTransportWritable; + const isTransportWritable = this.io.engine && + this.io.engine.transport && + this.io.engine.transport.writable; + const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected); if (discardPacket) { debug("discard packet as the transport is not currently writable"); } - else if (isConnected) { + else if (this.connected) { this.notifyOutgoingListeners(packet); this.packet(packet); } @@ -28231,16 +27761,16 @@ class Socket extends component_emitter_1.Emitter { } exports.Socket = Socket; -},{"./on.js":453,"@socket.io/component-emitter":23,"debug":456,"socket.io-parser":459}],455:[function(require,module,exports){ +},{"./on.js":435,"@socket.io/component-emitter":23,"debug":340,"socket.io-parser":439}],437:[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.url = url; +exports.url = void 0; const engine_io_client_1 = require("engine.io-client"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:url"); // debug() +const debug = debug_1.default("socket.io-client:url"); // debug() /** * URL parser. * @@ -28277,7 +27807,7 @@ function url(uri, path = "", loc) { } // parse debug("parse %s", uri); - obj = (0, engine_io_client_1.parse)(uri); + obj = engine_io_client_1.parse(uri); } // make sure we treat `localhost:80` and `localhost` equally if (!obj.port) { @@ -28301,12 +27831,9 @@ function url(uri, path = "", loc) { (loc && loc.port === obj.port ? "" : ":" + obj.port); return obj; } +exports.url = url; -},{"debug":456,"engine.io-client":370}],456:[function(require,module,exports){ -arguments[4][380][0].apply(exports,arguments) -},{"./common":457,"_process":447,"dup":380}],457:[function(require,module,exports){ -arguments[4][381][0].apply(exports,arguments) -},{"dup":381,"ms":441}],458:[function(require,module,exports){ +},{"debug":340,"engine.io-client":366}],438:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reconstructPacket = exports.deconstructPacket = void 0; @@ -28396,7 +27923,7 @@ function _reconstructPacket(data, buffers) { return data; } -},{"./is-binary.js":460}],459:[function(require,module,exports){ +},{"./is-binary.js":440}],439:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0; @@ -28719,7 +28246,7 @@ class BinaryReconstructor { } } -},{"./binary.js":458,"./is-binary.js":460,"@socket.io/component-emitter":23,"debug":461}],460:[function(require,module,exports){ +},{"./binary.js":438,"./is-binary.js":440,"@socket.io/component-emitter":23,"debug":340}],440:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasBinary = exports.isBinary = void 0; @@ -28776,11 +28303,7 @@ function hasBinary(obj, toJSON) { } exports.hasBinary = hasBinary; -},{}],461:[function(require,module,exports){ -arguments[4][380][0].apply(exports,arguments) -},{"./common":462,"_process":447,"dup":380}],462:[function(require,module,exports){ -arguments[4][381][0].apply(exports,arguments) -},{"dup":381,"ms":441}],463:[function(require,module,exports){ +},{}],441:[function(require,module,exports){ /* eslint-disable */ /** * used in docs/iframe.html @@ -28822,20 +28345,20 @@ channel.onmessage = function (msg) { }); } }; -},{"../../":2,"./util.js":464,"@babel/polyfill":11}],464:[function(require,module,exports){ +},{"../../":2,"./util.js":442,"@babel/polyfill":11}],442:[function(require,module,exports){ /* eslint no-useless-escape: "off" */ // https://stackoverflow.com/a/901144/3443137 function getParameterByName(name, url) { if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"); + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); var results = regex.exec(url); if (!results) return null; - if (!results[2]) return ""; - return decodeURIComponent(results[2].replace(/\+/g, " ")); + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); } module.exports = { getParameterByName: getParameterByName }; -},{}]},{},[463]); +},{}]},{},[441]); diff --git a/docs/index.js b/docs/index.js index 966b0dd2..02ad0b10 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,11 +1,9 @@ (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 Promise.all(this._befC.map(fn => fn()))) // close the channel - .then(() => this.method.close ? this.method.close(this._state) : Promise.resolve()); + .then(() => this.method.close(this._state)); }, get type() { return this.method.type; @@ -166,7 +164,6 @@ function _post(broadcastChannel, type, msg) { // add/remove to unsend messages list broadcastChannel._uMP.add(sendPromise); - // eslint-disable-next-line promise/valid-params sendPromise.catch().then(() => broadcastChannel._uMP.delete(sendPromise)); return sendPromise; }); @@ -181,7 +178,6 @@ function _prepareChannel(channel) { await new Promise(res => setTimeout(res, this.options.prepareDelay)); }*/ channel._state = s; - return; }); } else { channel._state = maybePromise; @@ -220,7 +216,7 @@ function _startListening(channel) { if (msgObj.time >= listenerObject.time) { listenerObject.fn(msgObj.data); - } else if (channel.method.type === "server") { + } else if (channel.method.type === 'server') { // server msg might lag based on connection. listenerObject.fn(msgObj.data); } @@ -231,7 +227,6 @@ function _startListening(channel) { channel._prepP.then(() => { channel._iL = true; channel.method.onMessage(channel._state, listenerFn, time); - return; }); } else { channel._iL = true; @@ -255,18 +250,18 @@ exports.enforceOptions = enforceOptions; },{"./method-chooser.js":3,"./options.js":9,"./util.js":10}],2:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var broadcastChannel = require('./broadcast-channel.js'); var methodChooser = require('./method-chooser.js'); +exports.NativeMethod = native; exports.IndexedDbMethod = indexedDb; exports.LocalstorageMethod = localstorage; -exports.NativeMethod = native; exports.ServerMethod = server; exports.BroadcastChannel = broadcastChannel.BroadcastChannel; exports.OPEN_BROADCAST_CHANNELS = broadcastChannel.OPEN_BROADCAST_CHANNELS; @@ -276,9 +271,9 @@ exports.chooseMethod = methodChooser.chooseMethod; },{"./broadcast-channel.js":1,"./method-chooser.js":3,"./methods/indexed-db.js":4,"./methods/localstorage.js":5,"./methods/native.js":6,"./methods/server.js":7}],3:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var simulate = require('./methods/simulate.js'); @@ -291,12 +286,12 @@ function chooseMethod(options) { // directly chosen if (options.type) { - if (options.type === "simulate") { + if (options.type === 'simulate') { // only use simulate-method if directly chosen return simulate; } const ret = chooseMethods.find(m => m.type === options.type); - if (!ret) throw new Error("method-type " + options.type + " not found");else return ret; + if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret; } /** @@ -304,7 +299,7 @@ function chooseMethod(options) { * remove idb from the list so that localstorage is been chosen */ if (!options.webWorkerSupport) { - chooseMethods = chooseMethods.filter(m => m.type !== "idb"); + chooseMethods = chooseMethods.filter(m => m.type !== 'idb'); } const useMethod = chooseMethods.find(method => method.canBeUsed(options)); if (!useMethod) throw new Error(`No useable method found in ${JSON.stringify(METHODS.map(m => m.type))}`);else return useMethod; @@ -329,23 +324,23 @@ var options = require('../options.js'); */ const microSeconds = util.microSeconds; -const DB_PREFIX = "pubkey.broadcast-channel-0-"; -const OBJECT_STORE_ID = "messages"; +const DB_PREFIX = 'pubkey.broadcast-channel-0-'; +const OBJECT_STORE_ID = 'messages'; /** * Use relaxed durability for faster performance on all transactions. * @link https://nolanlawson.com/2021/08/22/speeding-up-indexeddb-reads-and-writes/ */ const TRANSACTION_SETTINGS = { - durability: "relaxed" + durability: 'relaxed' }; -const type = "idb"; +const type = 'idb'; function getIdb() { - if (typeof indexedDB !== "undefined") return indexedDB; - if (typeof window !== "undefined") { - if (typeof window.mozIndexedDB !== "undefined") return window.mozIndexedDB; - if (typeof window.webkitIndexedDB !== "undefined") return window.webkitIndexedDB; - if (typeof window.msIndexedDB !== "undefined") return window.msIndexedDB; + if (typeof indexedDB !== 'undefined') return indexedDB; + if (typeof window !== 'undefined') { + if (typeof window.mozIndexedDB !== 'undefined') return window.mozIndexedDB; + if (typeof window.webkitIndexedDB !== 'undefined') return window.webkitIndexedDB; + if (typeof window.msIndexedDB !== 'undefined') return window.msIndexedDB; } return false; } @@ -375,14 +370,14 @@ function createDatabase(channelName) { openRequest.onupgradeneeded = ev => { const db = ev.target.result; db.createObjectStore(OBJECT_STORE_ID, { - keyPath: "id", + keyPath: 'id', autoIncrement: true }); }; - const dbPromise = new Promise((resolve, reject) => { - openRequest.onerror = ev => reject(ev); + const dbPromise = new Promise((res, rej) => { + openRequest.onerror = ev => rej(ev); openRequest.onsuccess = () => { - resolve(openRequest.result); + res(openRequest.result); }; }); return dbPromise; @@ -399,20 +394,20 @@ function writeMessage(db, readerUuid, messageJson) { time, data: messageJson }; - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); - return new Promise((resolve, reject) => { - tx.oncomplete = () => resolve(); - tx.onerror = ev => reject(ev); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); + return new Promise((res, rej) => { + tx.oncomplete = () => res(); + tx.onerror = ev => rej(ev); const objectStore = tx.objectStore(OBJECT_STORE_ID); objectStore.add(writeObject); commitIndexedDBTransaction(tx); }); } function getAllMessages(db) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -421,13 +416,13 @@ function getAllMessages(db) { cursor.continue(); } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function getMessagesHigherThan(db, lastCursorId) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; let keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); @@ -439,10 +434,10 @@ function getMessagesHigherThan(db, lastCursorId) { */ if (objectStore.getAll) { const getAllRequest = objectStore.getAll(keyRangeValue); - return new Promise((resolve, reject) => { - getAllRequest.onerror = err => reject(err); + return new Promise((res, rej) => { + getAllRequest.onerror = err => rej(err); getAllRequest.onsuccess = function (e) { - resolve(e.target.result); + res(e.target.result); }; }); } @@ -453,13 +448,13 @@ function getMessagesHigherThan(db, lastCursorId) { try { keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); return objectStore.openCursor(keyRangeValue); - } catch { + } catch (e) { return objectStore.openCursor(); } } - return new Promise((resolve, reject) => { + return new Promise((res, rej) => { const openCursorRequest = openCursor(); - openCursorRequest.onerror = err => reject(err); + openCursorRequest.onerror = err => rej(err); openCursorRequest.onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -471,27 +466,27 @@ function getMessagesHigherThan(db, lastCursorId) { } } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function removeMessagesById(db, ids) { - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); return Promise.all(ids.map(id => { const deleteRequest = objectStore.delete(id); - return new Promise(resolve => { - deleteRequest.onsuccess = () => resolve(); + return new Promise(res => { + deleteRequest.onsuccess = () => res(); }); })); } function getOldMessages(db, ttl) { const olderThen = Date.now() - ttl; - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -503,11 +498,11 @@ function getOldMessages(db, ttl) { } else { // no more old messages, commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); return; } } else { - resolve(ret); + res(ret); } }; }); @@ -562,8 +557,6 @@ function create(channelName, options$1) { } function _readLoop(state) { if (state.closed) return; - - // eslint-disable-next-line promise/catch-or-return readNewMessages(state).then(() => util.sleep(state.options.idb.fallbackInterval)).then(() => _readLoop(state)); } function _filterMessage(msgObj, state) { @@ -609,7 +602,6 @@ function close(channelState) { } function postMessage(channelState, messageJson) { channelState.writeBlockPromise = channelState.writeBlockPromise.then(() => writeMessage(channelState.db, channelState.uuid, messageJson)).then(() => { - // eslint-disable-next-line promise/always-return if (util.randomInt(0, 10) === 0) { /* await (do not await) */ cleanOldMessages(channelState.db, channelState.options.idb.ttl); @@ -650,7 +642,7 @@ exports.removeMessagesById = removeMessagesById; exports.type = type; exports.writeMessage = writeMessage; -},{"../options.js":9,"../util.js":10,"oblivious-set":445}],5:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":427}],5:[function(require,module,exports){ 'use strict'; var obliviousSet = require('oblivious-set'); @@ -666,8 +658,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "localstorage"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'localstorage'; /** * copied from crosstab @@ -675,11 +667,11 @@ const type = "localstorage"; */ function getLocalStorage() { let localStorage; - if (typeof window === "undefined") return null; + if (typeof window === 'undefined') return null; try { localStorage = window.localStorage; - localStorage = window["ie8-eventlistener/storage"] || window.localStorage; - } catch { + localStorage = window['ie8-eventlistener/storage'] || window.localStorage; + } catch (e) { // New versions of Firefox throw a Security exception // if cookies are disabled. See // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153 @@ -695,8 +687,7 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise(resolve => { - // eslint-disable-next-line promise/catch-or-return, promise/always-return + return new Promise(res => { util.sleep().then(() => { const key = storageKey(channelState.channelName); const writeObj = { @@ -713,12 +704,12 @@ function postMessage(channelState, messageJson) { * in the window that changes the state of the local storage. * So we fire it manually */ - const ev = document.createEvent("Event"); - ev.initEvent("storage", true, true); + const ev = document.createEvent('Event'); + ev.initEvent('storage', true, true); ev.key = key; ev.newValue = value; window.dispatchEvent(ev); - resolve(); + res(); }); }); } @@ -729,16 +720,16 @@ function addStorageEventListener(channelName, fn) { fn(JSON.parse(ev.newValue)); } }; - window.addEventListener("storage", listener); + window.addEventListener('storage', listener); return listener; } function removeStorageEventListener(listener) { - window.removeEventListener("storage", listener); + window.removeEventListener('storage', listener); } function create(channelName, options$1) { options$1 = options.fillOptionsWithDefaults(options$1); if (!canBeUsed()) { - throw new Error("BroadcastChannel: localstorage cannot be used"); + throw new Error('BroadcastChannel: localstorage cannot be used'); } const uuid = util.randomToken(); @@ -776,10 +767,10 @@ function canBeUsed() { const ls = getLocalStorage(); if (!ls) return false; try { - const key = "__broadcastchannel_check"; - ls.setItem(key, "works"); + const key = '__broadcastchannel_check'; + ls.setItem(key, 'works'); ls.removeItem(key); - } catch { + } catch (e) { // Safari 10 in private mode will not allow write access to local // storage and fail with a QuotaExceededError. See // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes @@ -790,7 +781,7 @@ function canBeUsed() { function averageResponseTime() { const defaultTime = 120; const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes("safari") && !userAgent.includes("chrome")) { + if (userAgent.includes('safari') && !userAgent.includes('chrome')) { // safari is much slower so this time is higher return defaultTime * 2; } @@ -810,13 +801,13 @@ exports.removeStorageEventListener = removeStorageEventListener; exports.storageKey = storageKey; exports.type = type; -},{"../options.js":9,"../util.js":10,"oblivious-set":445}],6:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":427}],6:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "native"; +const type = 'native'; function create(channelName) { const state = { time: util.microSeconds(), @@ -851,10 +842,10 @@ function canBeUsed() { * in the electron-renderer, isNode will be true even if we are in browser-context * so we also check if window is undefined */ - if (typeof window === "undefined") return false; - if (typeof BroadcastChannel === "function") { + if (typeof window === 'undefined') return false; + if (typeof BroadcastChannel === 'function') { if (BroadcastChannel._pubkey) { - throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"); + throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill'); } return true; } else return false; @@ -876,12 +867,12 @@ exports.type = type; (function (Buffer){(function (){ 'use strict'; -var eccrypto = require('@toruslabs/eccrypto'); -var metadataHelpers = require('@toruslabs/metadata-helpers'); var obliviousSet = require('oblivious-set'); var socket_ioClient = require('socket.io-client'); -var options = require('../options.js'); +var eccrypto = require('@toruslabs/eccrypto'); +var metadataHelpers = require('@toruslabs/metadata-helpers'); var util = require('../util.js'); +var options = require('../options.js'); /** * A localStorage-only method which uses localstorage and its 'storage'-event @@ -892,8 +883,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "server"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'server'; let SOCKET_CONN_INSTANCE = null; // used to decide to reconnect socket e.g. when socket connection is disconnected unexpectedly const runningChannels = new Set(); @@ -906,12 +897,11 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise((resolve, reject) => { - // eslint-disable-next-line promise/catch-or-return + return new Promise((res, rej) => { util.sleep().then(async () => { const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString("hex"), { + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString('hex'), { token: util.randomToken(), time: Date.now(), data: messageJson, @@ -920,18 +910,18 @@ function postMessage(channelState, messageJson) { const body = { sameOriginCheck: true, sameIpCheck: true, - key: eccrypto.getPublic(channelEncPrivKey).toString("hex"), + key: eccrypto.getPublic(channelEncPrivKey).toString('hex'), data: encData, - signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, "utf8")))).toString("hex") + signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, 'utf8')))).toString('hex') }; if (channelState.timeout) body.timeout = channelState.timeout; - return fetch(channelState.serverUrl + "/channel/set", { - method: "POST", + return fetch(channelState.serverUrl + '/channel/set', { + method: 'POST', body: JSON.stringify(body), headers: { - "Content-Type": "application/json; charset=utf-8" + 'Content-Type': 'application/json; charset=utf-8' } - }).then(resolve).catch(reject); + }).then(res).catch(rej); }); }); } @@ -940,33 +930,33 @@ function getSocketInstance(serverUrl) { return SOCKET_CONN_INSTANCE; } const SOCKET_CONN = socket_ioClient.io(serverUrl, { - transports: ["websocket", "polling"], + transports: ['websocket', 'polling'], // use WebSocket first, if available withCredentials: true, reconnectionDelayMax: 10000, reconnectionAttempts: 10 }); - SOCKET_CONN.on("connect_error", err => { + SOCKET_CONN.on('connect_error', err => { // revert to classic upgrade - SOCKET_CONN.io.opts.transports = ["polling", "websocket"]; - util.log.error("connect error", err); + SOCKET_CONN.io.opts.transports = ['polling', 'websocket']; + util.log.error('connect error', err); }); - SOCKET_CONN.on("connect", async () => { + SOCKET_CONN.on('connect', async () => { const { engine } = SOCKET_CONN.io; - util.log.debug("initially connected to", engine.transport.name); // in most cases, prints "polling" - engine.once("upgrade", () => { + util.log.debug('initially connected to', engine.transport.name); // in most cases, prints "polling" + engine.once('upgrade', () => { // called when the transport is upgraded (i.e. from HTTP long-polling to WebSocket) - util.log.debug("upgraded", engine.transport.name); // in most cases, prints "websocket" + util.log.debug('upgraded', engine.transport.name); // in most cases, prints "websocket" }); - engine.once("close", reason => { + engine.once('close', reason => { // called when the underlying connection is closed - util.log.debug("connection closed", reason); + util.log.debug('connection closed', reason); }); }); - SOCKET_CONN.on("error", err => { - util.log.error("socket errored", err); + SOCKET_CONN.on('error', err => { + util.log.error('socket errored', err); SOCKET_CONN.disconnect(); }); SOCKET_CONN_INSTANCE = SOCKET_CONN; @@ -975,26 +965,26 @@ function getSocketInstance(serverUrl) { function setupSocketConnection(serverUrl, channelState, fn) { const socketConn = getSocketInstance(serverUrl); const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString("hex"); + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString('hex'); if (socketConn.connected) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); } else { - socketConn.once("connect", () => { - util.log.debug("connected with socket"); - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.once('connect', () => { + util.log.debug('connected with socket'); + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); }); } const reconnect = () => { - socketConn.once("connect", async () => { + socketConn.once('connect', async () => { if (runningChannels.has(channelState.channelName)) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); @@ -1004,32 +994,32 @@ function setupSocketConnection(serverUrl, channelState, fn) { const visibilityListener = () => { // if channel is closed, then remove the listener. if (!socketConn || !runningChannels.has(channelState.channelName)) { - document.removeEventListener("visibilitychange", visibilityListener); + document.removeEventListener('visibilitychange', visibilityListener); return; } // if not connected, then wait for connection and ping server for latest msg. - if (!socketConn.connected && document.visibilityState === "visible") { + if (!socketConn.connected && document.visibilityState === 'visible') { reconnect(); } }; const listener = async ev => { try { - const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString("hex"), ev); + const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString('hex'), ev); util.log.info(decData); fn(decData); } catch (error) { util.log.error(error); } }; - socketConn.on("disconnect", () => { - util.log.debug("socket disconnected"); + socketConn.on('disconnect', () => { + util.log.debug('socket disconnected'); if (runningChannels.has(channelState.channelName)) { - util.log.error("socket disconnected unexpectedly, reconnecting socket"); + util.log.error('socket disconnected unexpectedly, reconnecting socket'); reconnect(); } }); socketConn.on(`${channelPubKey}_success`, listener); - if (typeof document !== "undefined") document.addEventListener("visibilitychange", visibilityListener); + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', visibilityListener); return socketConn; } function removeStorageEventListener() { @@ -1104,13 +1094,13 @@ exports.storageKey = storageKey; exports.type = type; }).call(this)}).call(this,require("buffer").Buffer) -},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":33,"oblivious-set":445,"socket.io-client":451}],8:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":33,"oblivious-set":427,"socket.io-client":433}],8:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "simulate"; +const type = 'simulate'; const SIMULATE_CHANNELS = new Set(); const SIMULATE_DELAY_TIME = 5; function create(channelName) { @@ -1126,7 +1116,7 @@ function close(channelState) { SIMULATE_CHANNELS.delete(channelState); } function postMessage(channelState, messageJson) { - return new Promise(resolve => setTimeout(() => { + return new Promise(res => setTimeout(() => { const channelArray = Array.from(SIMULATE_CHANNELS); channelArray.forEach(channel => { if (channel.name === channelState.name && @@ -1140,7 +1130,7 @@ function postMessage(channelState, messageJson) { channel.messagesCallback(messageJson); } }); - resolve(); + res(); }, SIMULATE_DELAY_TIME)); } function onMessage(channelState, fn) { @@ -1170,7 +1160,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { const options = JSON.parse(JSON.stringify(originalOptions)); // main - if (typeof options.webWorkerSupport === "undefined") options.webWorkerSupport = true; + if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db if (!options.idb) options.idb = {}; @@ -1178,7 +1168,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { if (!options.idb.ttl) options.idb.ttl = 1000 * 45; if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events. - if (originalOptions.idb && typeof originalOptions.idb.onclose === "function") options.idb.onclose = originalOptions.idb.onclose; + if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage if (!options.localstorage) options.localstorage = {}; @@ -1186,7 +1176,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { // server if (!options.server) options.server = {}; - if (!options.server.url) options.server.url = "https://session.web3auth.io"; + if (!options.server.url) options.server.url = 'https://session.web3auth.io'; if (!options.server.removeTimeout) options.server.removeTimeout = 1000 * 60 * 5; // 5 minutes // custom methods @@ -1207,7 +1197,7 @@ var loglevel = require('loglevel'); * returns true if the given object is a promise */ function isPromise(obj) { - if (obj && typeof obj.then === "function") { + if (obj && typeof obj.then === 'function') { return true; } else { return false; @@ -1218,7 +1208,7 @@ Promise.resolve(true); const PROMISE_RESOLVED_VOID = Promise.resolve(); function sleep(time, resolveWith) { if (!time) time = 0; - return new Promise(resolve => setTimeout(() => resolve(resolveWith), time)); + return new Promise(res => setTimeout(() => res(resolveWith), time)); } function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); @@ -1272,8 +1262,8 @@ function microSeconds() { // return thirdPartyCookieSupport; // } -const log = loglevel.getLogger("broadcast-channel"); -log.setLevel("error"); +const log = loglevel.getLogger('broadcast-channel'); +log.setLevel('error'); exports.PROMISE_RESOLVED_VOID = PROMISE_RESOLVED_VOID; exports.isPromise = isPromise; @@ -1283,7 +1273,7 @@ exports.randomInt = randomInt; exports.randomToken = randomToken; exports.sleep = sleep; -},{"loglevel":430}],11:[function(require,module,exports){ +},{"loglevel":420}],11:[function(require,module,exports){ "use strict"; require("./noConflict"); @@ -1297,7 +1287,7 @@ if (_global["default"]._babelPolyfill && typeof console !== "undefined" && conso } _global["default"]._babelPolyfill = true; -},{"./noConflict":12,"core-js/library/fn/global":54}],12:[function(require,module,exports){ +},{"./noConflict":12,"core-js/library/fn/global":48}],12:[function(require,module,exports){ "use strict"; require("core-js/es6"); @@ -1327,7 +1317,7 @@ require("core-js/fn/promise/finally"); require("core-js/web"); require("regenerator-runtime/runtime"); -},{"core-js/es6":42,"core-js/fn/array/flat-map":43,"core-js/fn/array/includes":44,"core-js/fn/object/entries":45,"core-js/fn/object/get-own-property-descriptors":46,"core-js/fn/object/values":47,"core-js/fn/promise/finally":48,"core-js/fn/string/pad-end":49,"core-js/fn/string/pad-start":50,"core-js/fn/string/trim-end":51,"core-js/fn/string/trim-start":52,"core-js/fn/symbol/async-iterator":53,"core-js/web":345,"regenerator-runtime/runtime":448}],13:[function(require,module,exports){ +},{"core-js/es6":36,"core-js/fn/array/flat-map":37,"core-js/fn/array/includes":38,"core-js/fn/object/entries":39,"core-js/fn/object/get-own-property-descriptors":40,"core-js/fn/object/values":41,"core-js/fn/promise/finally":42,"core-js/fn/string/pad-end":43,"core-js/fn/string/pad-start":44,"core-js/fn/string/trim-end":45,"core-js/fn/string/trim-start":46,"core-js/fn/symbol/async-iterator":47,"core-js/web":339,"regenerator-runtime/runtime":430}],13:[function(require,module,exports){ var toPropertyKey = require("./toPropertyKey.js"); function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { @@ -1387,54 +1377,54 @@ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports function _typeof(o) { "@babel/helpers - typeof"; - return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; },{}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isBytes = isBytes; -exports.number = number; -exports.bool = bool; -exports.bytes = bytes; -exports.hash = hash; -exports.exists = exists; -exports.output = output; +exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = exports.isBytes = void 0; function number(n) { if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); } +exports.number = number; function bool(b) { if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`); } +exports.bool = bool; // copied from utils function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; function bytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); } +exports.bytes = bytes; function hash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); number(h.outputLen); number(h.blockLen); } +exports.hash = hash; function exists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } +exports.exists = exists; function output(out, instance) { bytes(out); const min = instance.outputLen; @@ -1442,16 +1432,14 @@ function output(out, instance) { throw new Error(`digestInto() expects output buffer of length at least ${min}`); } } +exports.output = output; const assert = { number, bool, bytes, hash, exists, output }; exports.default = assert; },{}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = void 0; -exports.fromBig = fromBig; -exports.split = split; -exports.add = add; +exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.add = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = exports.split = exports.fromBig = void 0; const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); // We are not using BigUint64Array, because they are extremely slow as per 2022 @@ -1460,6 +1448,7 @@ function fromBig(n, le = false) { return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; } +exports.fromBig = fromBig; function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); @@ -1469,6 +1458,7 @@ function split(lst, le = false) { } return [Ah, Al]; } +exports.split = split; const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); exports.toBig = toBig; // for Shift in [0, 32) @@ -1507,6 +1497,7 @@ function add(Ah, Al, Bh, Bl) { const l = (Al >>> 0) + (Bl >>> 0); return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; } +exports.add = add; // Addition with more than 2 elements const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); exports.add3L = add3L; @@ -1540,8 +1531,7 @@ exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? glob },{}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0; -exports.keccakP = keccakP; +exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0; const _assert_js_1 = require("./_assert.js"); const _u64_js_1 = require("./_u64.js"); const utils_js_1 = require("./utils.js"); @@ -1622,6 +1612,7 @@ function keccakP(s, rounds = 24) { } B.fill(0); } +exports.keccakP = keccakP; class Keccak extends utils_js_1.Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { @@ -1761,20 +1752,7 @@ exports.shake256 = genShake(0x1f, 136, 256 / 8); "use strict"; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0; -exports.isBytes = isBytes; -exports.byteSwap32 = byteSwap32; -exports.bytesToHex = bytesToHex; -exports.hexToBytes = hexToBytes; -exports.asyncLoop = asyncLoop; -exports.utf8ToBytes = utf8ToBytes; -exports.toBytes = toBytes; -exports.concatBytes = concatBytes; -exports.checkOpts = checkOpts; -exports.wrapConstructor = wrapConstructor; -exports.wrapConstructorWithOpts = wrapConstructorWithOpts; -exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; -exports.randomBytes = randomBytes; +exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.byteSwap32 = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = exports.isBytes = void 0; // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. // node.js versions earlier than v19 don't declare it in global scope. // For node.js, package.json#exports field mapping rewrites import @@ -1789,6 +1767,7 @@ function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; // Cast array to different type const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); exports.u8 = u8; @@ -1818,6 +1797,7 @@ function byteSwap32(arr) { arr[i] = (0, exports.byteSwap)(arr[i]); } } +exports.byteSwap32 = byteSwap32; // Array where index 0xf0 (240) is mapped to string 'f0' const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); /** @@ -1832,6 +1812,7 @@ function bytesToHex(bytes) { } return hex; } +exports.bytesToHex = bytesToHex; // We use optimized technique to convert hex string to byte array const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; function asciiToBase16(char) { @@ -1865,6 +1846,7 @@ function hexToBytes(hex) { } return array; } +exports.hexToBytes = hexToBytes; // There is no setImmediate in browser and setTimeout is slow. // call of async fn will return Promise, which will be fullfiled only on // next scheduler queue processing step and this is exactly what we need. @@ -1883,6 +1865,7 @@ async function asyncLoop(iters, tick, cb) { ts += diff; } } +exports.asyncLoop = asyncLoop; /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ @@ -1891,6 +1874,7 @@ function utf8ToBytes(str) { throw new Error(`utf8ToBytes expected string, got ${typeof str}`); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } +exports.utf8ToBytes = utf8ToBytes; /** * Normalizes (non-hex) string or Uint8Array to Uint8Array. * Warning: when Uint8Array is passed, it would NOT get copied. @@ -1902,6 +1886,7 @@ function toBytes(data) { (0, _assert_js_1.bytes)(data); return data; } +exports.toBytes = toBytes; /** * Copies several Uint8Arrays into one. */ @@ -1920,6 +1905,7 @@ function concatBytes(...arrays) { } return res; } +exports.concatBytes = concatBytes; // For runtime check if class implements interface class Hash { // Safe version that clones internal state @@ -1935,6 +1921,7 @@ function checkOpts(defaults, opts) { const merged = Object.assign(defaults, opts); return merged; } +exports.checkOpts = checkOpts; function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); @@ -1943,6 +1930,7 @@ function wrapConstructor(hashCons) { hashC.create = () => hashCons(); return hashC; } +exports.wrapConstructor = wrapConstructor; function wrapConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1951,6 +1939,7 @@ function wrapConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapConstructorWithOpts = wrapConstructorWithOpts; function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1959,6 +1948,7 @@ function wrapXOFConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; /** * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. */ @@ -1966,12 +1956,9 @@ function randomBytes(bytesLength = 32) { if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); } - // Legacy Node.js compatibility - if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { - return crypto_1.crypto.randomBytes(bytesLength); - } throw new Error('crypto.getRandomValues must be defined'); } +exports.randomBytes = randomBytes; },{"./_assert.js":18,"@noble/hashes/crypto":20}],23:[function(require,module,exports){ @@ -2197,26 +2184,18 @@ function equalConstTime(b1, b2) { not, since the functions are different and does not convert using browserify */ function randomBytes(size) { - if (typeof browserCrypto.getRandomValues === "undefined") { - return Buffer.from(browserCrypto.randomBytes(size)); - } const arr = new Uint8Array(size); browserCrypto.getRandomValues(arr); return Buffer.from(arr); } async function sha512(msg) { - if (!browserCrypto.createHash) { - const hash = await subtle.digest("SHA-512", msg); - const result = new Uint8Array(hash); - return result; - } - const hash = browserCrypto.createHash("sha512"); - const result = hash.update(msg).digest(); - return new Uint8Array(result); + const hash = await subtle.digest("SHA-512", msg); + const result = new Uint8Array(hash); + return result; } function getAes(op) { return async function (iv, key, data) { - if (subtle && subtle[op] && subtle.importKey) { + if (subtle) { const importAlgorithm = { name: "AES-CBC" }; @@ -2225,20 +2204,8 @@ function getAes(op) { name: "AES-CBC", iv }; - // encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. const result = await subtle[op](encAlgorithm, cryptoKey, data); return Buffer.from(new Uint8Array(result)); - } else if (op === "encrypt" && browserCrypto.createCipheriv) { - // This is available if crypto is polyfilled in react native environment - const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); - const firstChunk = cipher.update(data); - const secondChunk = cipher.final(); - return Buffer.concat([firstChunk, secondChunk]); - } else if (op === "decrypt" && browserCrypto.createDecipheriv) { - const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); - const firstChunk = decipher.update(data); - const secondChunk = decipher.final(); - return Buffer.concat([firstChunk, secondChunk]); } throw new Error(`Unsupported operation: ${op}`); }; @@ -2246,21 +2213,15 @@ function getAes(op) { const aesCbcEncrypt = getAes("encrypt"); const aesCbcDecrypt = getAes("decrypt"); async function hmacSha256Sign(key, msg) { - if (!browserCrypto.createHmac) { - const importAlgorithm = { - name: "HMAC", - hash: { - name: "SHA-256" - } - }; - const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); - const sig = await subtle.sign("HMAC", cryptoKey, msg); - const result = Buffer.from(new Uint8Array(sig)); - return result; - } - const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); - hmac.update(msg); - const result = hmac.digest(); + const importAlgorithm = { + name: "HMAC", + hash: { + name: "SHA-256" + } + }; + const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); + const sig = await subtle.sign("HMAC", cryptoKey, msg); + const result = Buffer.from(new Uint8Array(sig)); return result; } async function hmacSha256Verify(key, msg, sig) { @@ -2418,7 +2379,7 @@ exports.sign = sign; exports.verify = verify; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":33,"elliptic":349}],25:[function(require,module,exports){ +},{"buffer":33,"elliptic":344}],25:[function(require,module,exports){ 'use strict'; var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); @@ -2427,9 +2388,6 @@ var logLevel = require('loglevel'); const log = logLevel.getLogger("http-helpers"); log.setLevel(logLevel.levels.INFO); - -// eslint-disable-next-line @typescript-eslint/no-empty-object-type - let apiKey = "torus-default"; let embedHost = ""; @@ -2472,9 +2430,7 @@ async function fetchAndTrace(url, init) { let _url = null; try { _url = new URL(url); - } catch { - // ignore - } + } catch (error) {} if (sentry && _url && (tracingOrigins.includes(_url.origin) || tracingPaths.includes(_url.pathname))) { const result = await sentry.startSpan({ name: url, @@ -2538,7 +2494,7 @@ const get = async (url, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2577,7 +2533,7 @@ const post = (url, data = {}, options_ = {}, customOptions = {}) => { } if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2616,7 +2572,7 @@ const patch = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2654,7 +2610,7 @@ const put = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2690,7 +2646,7 @@ const remove = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2729,7 +2685,7 @@ exports.setAPIKey = setAPIKey; exports.setEmbedHost = setEmbedHost; exports.setLogLevel = setLogLevel; -},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":346,"loglevel":430}],26:[function(require,module,exports){ +},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":342,"loglevel":420}],26:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -2743,8 +2699,8 @@ class MetadataStorageLayer { // ms constructor(metadataHost = "https://metadata.tor.us", serverTimeOffset = 0) { - _defineProperty(this, "metadataHost", undefined); - _defineProperty(this, "serverTimeOffset", undefined); + _defineProperty(this, "metadataHost", void 0); + _defineProperty(this, "serverTimeOffset", void 0); this.metadataHost = metadataHost; this.serverTimeOffset = serverTimeOffset; } @@ -2766,7 +2722,7 @@ class MetadataStorageLayer { pub_key_X: key.getPublic().getX().toString(16, 64), pub_key_Y: key.getPublic().getY().toString(16, 64), set_data: setData, - signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === undefined ? undefined : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== undefined ? _sig$recoveryParam$to : "00"), "hex").toString("base64") + signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === void 0 ? void 0 : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== void 0 ? _sig$recoveryParam$to : "00"), "hex").toString("base64") }; } generatePubKeyParams(privateKeyHex) { @@ -2799,7 +2755,7 @@ class MetadataStorageLayer { exports.MetadataStorageLayer = MetadataStorageLayer; }).call(this)}).call(this,require("buffer").Buffer) -},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":33,"json-stable-stringify":426}],27:[function(require,module,exports){ +},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":33,"json-stable-stringify":416}],27:[function(require,module,exports){ 'use strict'; var MetadataStorageLayer = require('./MetadataStorageLayer.js'); @@ -2838,7 +2794,7 @@ exports.ec = ec; exports.keccak256 = keccak256; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":33,"elliptic":349,"ethereum-cryptography/keccak":396}],29:[function(require,module,exports){ +},{"buffer":33,"elliptic":344,"ethereum-cryptography/keccak":389}],29:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -4957,112 +4913,61 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":30,"buffer":33,"ieee754":423}],34:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); - -var $apply = require('./functionApply'); -var $call = require('./functionCall'); -var $reflectApply = require('./reflectApply'); - -/** @type {import('./actualApply')} */ -module.exports = $reflectApply || bind.call($call, $apply); - -},{"./functionApply":36,"./functionCall":37,"./reflectApply":39,"function-bind":399}],35:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $apply = require('./functionApply'); -var actualApply = require('./actualApply'); - -/** @type {import('./applyBind')} */ -module.exports = function applyBind() { - return actualApply(bind, $apply, arguments); -}; - -},{"./actualApply":34,"./functionApply":36,"function-bind":399}],36:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionApply')} */ -module.exports = Function.prototype.apply; - -},{}],37:[function(require,module,exports){ +},{"base64-js":30,"buffer":33,"ieee754":413}],34:[function(require,module,exports){ 'use strict'; -/** @type {import('./functionCall')} */ -module.exports = Function.prototype.call; - -},{}],38:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -var bind = require('function-bind'); -var $TypeError = require('es-errors/type'); +var callBind = require('./'); -var $call = require('./functionCall'); -var $actualApply = require('./actualApply'); +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); -/** @type {import('.')} */ -module.exports = function callBindBasic(args) { - if (args.length < 1 || typeof args[0] !== 'function') { - throw new $TypeError('a function is required'); +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { + return callBind(intrinsic); } - return $actualApply(bind, $call, args); + return intrinsic; }; -},{"./actualApply":34,"./functionCall":37,"es-errors/type":393,"function-bind":399}],39:[function(require,module,exports){ -'use strict'; - -/** @type {import('./reflectApply')} */ -module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply; - -},{}],40:[function(require,module,exports){ +},{"./":35,"get-intrinsic":393}],35:[function(require,module,exports){ 'use strict'; +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); var setFunctionLength = require('set-function-length'); -var $defineProperty = require('es-define-property'); +var $TypeError = require('es-errors/type'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); -var callBindBasic = require('call-bind-apply-helpers'); -var applyBind = require('call-bind-apply-helpers/applyBind'); +var $defineProperty = require('es-define-property'); +var $max = GetIntrinsic('%Math.max%'); module.exports = function callBind(originalFunction) { - var func = callBindBasic(arguments); - var adjustedLength = originalFunction.length - (arguments.length - 1); + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); return setFunctionLength( func, - 1 + (adjustedLength > 0 ? adjustedLength : 0), + 1 + $max(0, originalFunction.length - (arguments.length - 1)), true ); }; +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + if ($defineProperty) { $defineProperty(module.exports, 'apply', { value: applyBind }); } else { module.exports.apply = applyBind; } -},{"call-bind-apply-helpers":38,"call-bind-apply-helpers/applyBind":35,"es-define-property":387,"set-function-length":449}],41:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); - -var callBindBasic = require('call-bind-apply-helpers'); - -/** @type {(thisArg: string, searchString: string, position?: number) => number} */ -var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]); - -/** @type {import('.')} */ -module.exports = function callBoundIntrinsic(name, allowMissing) { - // eslint-disable-next-line no-extra-parens - var intrinsic = /** @type {Parameters[0][0]} */ (GetIntrinsic(name, !!allowMissing)); - if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { - return callBindBasic([intrinsic]); - } - return intrinsic; -}; - -},{"call-bind-apply-helpers":38,"get-intrinsic":400}],42:[function(require,module,exports){ +},{"es-define-property":381,"es-errors/type":387,"function-bind":392,"get-intrinsic":393,"set-function-length":431}],36:[function(require,module,exports){ require('../modules/es6.symbol'); require('../modules/es6.object.create'); require('../modules/es6.object.define-property'); @@ -5203,74 +5108,74 @@ require('../modules/es6.reflect.set'); require('../modules/es6.reflect.set-prototype-of'); module.exports = require('../modules/_core'); -},{"../modules/_core":91,"../modules/es6.array.copy-within":193,"../modules/es6.array.every":194,"../modules/es6.array.fill":195,"../modules/es6.array.filter":196,"../modules/es6.array.find":198,"../modules/es6.array.find-index":197,"../modules/es6.array.for-each":199,"../modules/es6.array.from":200,"../modules/es6.array.index-of":201,"../modules/es6.array.is-array":202,"../modules/es6.array.iterator":203,"../modules/es6.array.join":204,"../modules/es6.array.last-index-of":205,"../modules/es6.array.map":206,"../modules/es6.array.of":207,"../modules/es6.array.reduce":209,"../modules/es6.array.reduce-right":208,"../modules/es6.array.slice":210,"../modules/es6.array.some":211,"../modules/es6.array.sort":212,"../modules/es6.array.species":213,"../modules/es6.date.now":214,"../modules/es6.date.to-iso-string":215,"../modules/es6.date.to-json":216,"../modules/es6.date.to-primitive":217,"../modules/es6.date.to-string":218,"../modules/es6.function.bind":219,"../modules/es6.function.has-instance":220,"../modules/es6.function.name":221,"../modules/es6.map":222,"../modules/es6.math.acosh":223,"../modules/es6.math.asinh":224,"../modules/es6.math.atanh":225,"../modules/es6.math.cbrt":226,"../modules/es6.math.clz32":227,"../modules/es6.math.cosh":228,"../modules/es6.math.expm1":229,"../modules/es6.math.fround":230,"../modules/es6.math.hypot":231,"../modules/es6.math.imul":232,"../modules/es6.math.log10":233,"../modules/es6.math.log1p":234,"../modules/es6.math.log2":235,"../modules/es6.math.sign":236,"../modules/es6.math.sinh":237,"../modules/es6.math.tanh":238,"../modules/es6.math.trunc":239,"../modules/es6.number.constructor":240,"../modules/es6.number.epsilon":241,"../modules/es6.number.is-finite":242,"../modules/es6.number.is-integer":243,"../modules/es6.number.is-nan":244,"../modules/es6.number.is-safe-integer":245,"../modules/es6.number.max-safe-integer":246,"../modules/es6.number.min-safe-integer":247,"../modules/es6.number.parse-float":248,"../modules/es6.number.parse-int":249,"../modules/es6.number.to-fixed":250,"../modules/es6.number.to-precision":251,"../modules/es6.object.assign":252,"../modules/es6.object.create":253,"../modules/es6.object.define-properties":254,"../modules/es6.object.define-property":255,"../modules/es6.object.freeze":256,"../modules/es6.object.get-own-property-descriptor":257,"../modules/es6.object.get-own-property-names":258,"../modules/es6.object.get-prototype-of":259,"../modules/es6.object.is":263,"../modules/es6.object.is-extensible":260,"../modules/es6.object.is-frozen":261,"../modules/es6.object.is-sealed":262,"../modules/es6.object.keys":264,"../modules/es6.object.prevent-extensions":265,"../modules/es6.object.seal":266,"../modules/es6.object.set-prototype-of":267,"../modules/es6.object.to-string":268,"../modules/es6.parse-float":269,"../modules/es6.parse-int":270,"../modules/es6.promise":271,"../modules/es6.reflect.apply":272,"../modules/es6.reflect.construct":273,"../modules/es6.reflect.define-property":274,"../modules/es6.reflect.delete-property":275,"../modules/es6.reflect.enumerate":276,"../modules/es6.reflect.get":279,"../modules/es6.reflect.get-own-property-descriptor":277,"../modules/es6.reflect.get-prototype-of":278,"../modules/es6.reflect.has":280,"../modules/es6.reflect.is-extensible":281,"../modules/es6.reflect.own-keys":282,"../modules/es6.reflect.prevent-extensions":283,"../modules/es6.reflect.set":285,"../modules/es6.reflect.set-prototype-of":284,"../modules/es6.regexp.constructor":286,"../modules/es6.regexp.exec":287,"../modules/es6.regexp.flags":288,"../modules/es6.regexp.match":289,"../modules/es6.regexp.replace":290,"../modules/es6.regexp.search":291,"../modules/es6.regexp.split":292,"../modules/es6.regexp.to-string":293,"../modules/es6.set":294,"../modules/es6.string.anchor":295,"../modules/es6.string.big":296,"../modules/es6.string.blink":297,"../modules/es6.string.bold":298,"../modules/es6.string.code-point-at":299,"../modules/es6.string.ends-with":300,"../modules/es6.string.fixed":301,"../modules/es6.string.fontcolor":302,"../modules/es6.string.fontsize":303,"../modules/es6.string.from-code-point":304,"../modules/es6.string.includes":305,"../modules/es6.string.italics":306,"../modules/es6.string.iterator":307,"../modules/es6.string.link":308,"../modules/es6.string.raw":309,"../modules/es6.string.repeat":310,"../modules/es6.string.small":311,"../modules/es6.string.starts-with":312,"../modules/es6.string.strike":313,"../modules/es6.string.sub":314,"../modules/es6.string.sup":315,"../modules/es6.string.trim":316,"../modules/es6.symbol":317,"../modules/es6.typed.array-buffer":318,"../modules/es6.typed.data-view":319,"../modules/es6.typed.float32-array":320,"../modules/es6.typed.float64-array":321,"../modules/es6.typed.int16-array":322,"../modules/es6.typed.int32-array":323,"../modules/es6.typed.int8-array":324,"../modules/es6.typed.uint16-array":325,"../modules/es6.typed.uint32-array":326,"../modules/es6.typed.uint8-array":327,"../modules/es6.typed.uint8-clamped-array":328,"../modules/es6.weak-map":329,"../modules/es6.weak-set":330}],43:[function(require,module,exports){ +},{"../modules/_core":85,"../modules/es6.array.copy-within":187,"../modules/es6.array.every":188,"../modules/es6.array.fill":189,"../modules/es6.array.filter":190,"../modules/es6.array.find":192,"../modules/es6.array.find-index":191,"../modules/es6.array.for-each":193,"../modules/es6.array.from":194,"../modules/es6.array.index-of":195,"../modules/es6.array.is-array":196,"../modules/es6.array.iterator":197,"../modules/es6.array.join":198,"../modules/es6.array.last-index-of":199,"../modules/es6.array.map":200,"../modules/es6.array.of":201,"../modules/es6.array.reduce":203,"../modules/es6.array.reduce-right":202,"../modules/es6.array.slice":204,"../modules/es6.array.some":205,"../modules/es6.array.sort":206,"../modules/es6.array.species":207,"../modules/es6.date.now":208,"../modules/es6.date.to-iso-string":209,"../modules/es6.date.to-json":210,"../modules/es6.date.to-primitive":211,"../modules/es6.date.to-string":212,"../modules/es6.function.bind":213,"../modules/es6.function.has-instance":214,"../modules/es6.function.name":215,"../modules/es6.map":216,"../modules/es6.math.acosh":217,"../modules/es6.math.asinh":218,"../modules/es6.math.atanh":219,"../modules/es6.math.cbrt":220,"../modules/es6.math.clz32":221,"../modules/es6.math.cosh":222,"../modules/es6.math.expm1":223,"../modules/es6.math.fround":224,"../modules/es6.math.hypot":225,"../modules/es6.math.imul":226,"../modules/es6.math.log10":227,"../modules/es6.math.log1p":228,"../modules/es6.math.log2":229,"../modules/es6.math.sign":230,"../modules/es6.math.sinh":231,"../modules/es6.math.tanh":232,"../modules/es6.math.trunc":233,"../modules/es6.number.constructor":234,"../modules/es6.number.epsilon":235,"../modules/es6.number.is-finite":236,"../modules/es6.number.is-integer":237,"../modules/es6.number.is-nan":238,"../modules/es6.number.is-safe-integer":239,"../modules/es6.number.max-safe-integer":240,"../modules/es6.number.min-safe-integer":241,"../modules/es6.number.parse-float":242,"../modules/es6.number.parse-int":243,"../modules/es6.number.to-fixed":244,"../modules/es6.number.to-precision":245,"../modules/es6.object.assign":246,"../modules/es6.object.create":247,"../modules/es6.object.define-properties":248,"../modules/es6.object.define-property":249,"../modules/es6.object.freeze":250,"../modules/es6.object.get-own-property-descriptor":251,"../modules/es6.object.get-own-property-names":252,"../modules/es6.object.get-prototype-of":253,"../modules/es6.object.is":257,"../modules/es6.object.is-extensible":254,"../modules/es6.object.is-frozen":255,"../modules/es6.object.is-sealed":256,"../modules/es6.object.keys":258,"../modules/es6.object.prevent-extensions":259,"../modules/es6.object.seal":260,"../modules/es6.object.set-prototype-of":261,"../modules/es6.object.to-string":262,"../modules/es6.parse-float":263,"../modules/es6.parse-int":264,"../modules/es6.promise":265,"../modules/es6.reflect.apply":266,"../modules/es6.reflect.construct":267,"../modules/es6.reflect.define-property":268,"../modules/es6.reflect.delete-property":269,"../modules/es6.reflect.enumerate":270,"../modules/es6.reflect.get":273,"../modules/es6.reflect.get-own-property-descriptor":271,"../modules/es6.reflect.get-prototype-of":272,"../modules/es6.reflect.has":274,"../modules/es6.reflect.is-extensible":275,"../modules/es6.reflect.own-keys":276,"../modules/es6.reflect.prevent-extensions":277,"../modules/es6.reflect.set":279,"../modules/es6.reflect.set-prototype-of":278,"../modules/es6.regexp.constructor":280,"../modules/es6.regexp.exec":281,"../modules/es6.regexp.flags":282,"../modules/es6.regexp.match":283,"../modules/es6.regexp.replace":284,"../modules/es6.regexp.search":285,"../modules/es6.regexp.split":286,"../modules/es6.regexp.to-string":287,"../modules/es6.set":288,"../modules/es6.string.anchor":289,"../modules/es6.string.big":290,"../modules/es6.string.blink":291,"../modules/es6.string.bold":292,"../modules/es6.string.code-point-at":293,"../modules/es6.string.ends-with":294,"../modules/es6.string.fixed":295,"../modules/es6.string.fontcolor":296,"../modules/es6.string.fontsize":297,"../modules/es6.string.from-code-point":298,"../modules/es6.string.includes":299,"../modules/es6.string.italics":300,"../modules/es6.string.iterator":301,"../modules/es6.string.link":302,"../modules/es6.string.raw":303,"../modules/es6.string.repeat":304,"../modules/es6.string.small":305,"../modules/es6.string.starts-with":306,"../modules/es6.string.strike":307,"../modules/es6.string.sub":308,"../modules/es6.string.sup":309,"../modules/es6.string.trim":310,"../modules/es6.symbol":311,"../modules/es6.typed.array-buffer":312,"../modules/es6.typed.data-view":313,"../modules/es6.typed.float32-array":314,"../modules/es6.typed.float64-array":315,"../modules/es6.typed.int16-array":316,"../modules/es6.typed.int32-array":317,"../modules/es6.typed.int8-array":318,"../modules/es6.typed.uint16-array":319,"../modules/es6.typed.uint32-array":320,"../modules/es6.typed.uint8-array":321,"../modules/es6.typed.uint8-clamped-array":322,"../modules/es6.weak-map":323,"../modules/es6.weak-set":324}],37:[function(require,module,exports){ require('../../modules/es7.array.flat-map'); module.exports = require('../../modules/_core').Array.flatMap; -},{"../../modules/_core":91,"../../modules/es7.array.flat-map":331}],44:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.array.flat-map":325}],38:[function(require,module,exports){ require('../../modules/es7.array.includes'); module.exports = require('../../modules/_core').Array.includes; -},{"../../modules/_core":91,"../../modules/es7.array.includes":332}],45:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.array.includes":326}],39:[function(require,module,exports){ require('../../modules/es7.object.entries'); module.exports = require('../../modules/_core').Object.entries; -},{"../../modules/_core":91,"../../modules/es7.object.entries":333}],46:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.entries":327}],40:[function(require,module,exports){ require('../../modules/es7.object.get-own-property-descriptors'); module.exports = require('../../modules/_core').Object.getOwnPropertyDescriptors; -},{"../../modules/_core":91,"../../modules/es7.object.get-own-property-descriptors":334}],47:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.get-own-property-descriptors":328}],41:[function(require,module,exports){ require('../../modules/es7.object.values'); module.exports = require('../../modules/_core').Object.values; -},{"../../modules/_core":91,"../../modules/es7.object.values":335}],48:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.object.values":329}],42:[function(require,module,exports){ 'use strict'; require('../../modules/es6.promise'); require('../../modules/es7.promise.finally'); module.exports = require('../../modules/_core').Promise['finally']; -},{"../../modules/_core":91,"../../modules/es6.promise":271,"../../modules/es7.promise.finally":336}],49:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es6.promise":265,"../../modules/es7.promise.finally":330}],43:[function(require,module,exports){ require('../../modules/es7.string.pad-end'); module.exports = require('../../modules/_core').String.padEnd; -},{"../../modules/_core":91,"../../modules/es7.string.pad-end":337}],50:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.pad-end":331}],44:[function(require,module,exports){ require('../../modules/es7.string.pad-start'); module.exports = require('../../modules/_core').String.padStart; -},{"../../modules/_core":91,"../../modules/es7.string.pad-start":338}],51:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.pad-start":332}],45:[function(require,module,exports){ require('../../modules/es7.string.trim-right'); module.exports = require('../../modules/_core').String.trimRight; -},{"../../modules/_core":91,"../../modules/es7.string.trim-right":340}],52:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.trim-right":334}],46:[function(require,module,exports){ require('../../modules/es7.string.trim-left'); module.exports = require('../../modules/_core').String.trimLeft; -},{"../../modules/_core":91,"../../modules/es7.string.trim-left":339}],53:[function(require,module,exports){ +},{"../../modules/_core":85,"../../modules/es7.string.trim-left":333}],47:[function(require,module,exports){ require('../../modules/es7.symbol.async-iterator'); module.exports = require('../../modules/_wks-ext').f('asyncIterator'); -},{"../../modules/_wks-ext":190,"../../modules/es7.symbol.async-iterator":341}],54:[function(require,module,exports){ +},{"../../modules/_wks-ext":184,"../../modules/es7.symbol.async-iterator":335}],48:[function(require,module,exports){ require('../modules/es7.global'); module.exports = require('../modules/_core').global; -},{"../modules/_core":57,"../modules/es7.global":71}],55:[function(require,module,exports){ +},{"../modules/_core":51,"../modules/es7.global":65}],49:[function(require,module,exports){ module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; -},{}],56:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; -},{"./_is-object":67}],57:[function(require,module,exports){ +},{"./_is-object":61}],51:[function(require,module,exports){ var core = module.exports = { version: '2.6.12' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -},{}],58:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ // optional / simple context binding var aFunction = require('./_a-function'); module.exports = function (fn, that, length) { @@ -5292,13 +5197,13 @@ module.exports = function (fn, that, length) { }; }; -},{"./_a-function":55}],59:[function(require,module,exports){ +},{"./_a-function":49}],53:[function(require,module,exports){ // Thank's IE8 for his funny defineProperty module.exports = !require('./_fails')(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_fails":62}],60:[function(require,module,exports){ +},{"./_fails":56}],54:[function(require,module,exports){ var isObject = require('./_is-object'); var document = require('./_global').document; // typeof document.createElement is 'object' in old IE @@ -5307,7 +5212,7 @@ module.exports = function (it) { return is ? document.createElement(it) : {}; }; -},{"./_global":63,"./_is-object":67}],61:[function(require,module,exports){ +},{"./_global":57,"./_is-object":61}],55:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var ctx = require('./_ctx'); @@ -5371,7 +5276,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":57,"./_ctx":58,"./_global":63,"./_has":64,"./_hide":65}],62:[function(require,module,exports){ +},{"./_core":51,"./_ctx":52,"./_global":57,"./_has":58,"./_hide":59}],56:[function(require,module,exports){ module.exports = function (exec) { try { return !!exec(); @@ -5380,7 +5285,7 @@ module.exports = function (exec) { } }; -},{}],63:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self @@ -5388,13 +5293,13 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -},{}],64:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; -},{}],65:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ var dP = require('./_object-dp'); var createDesc = require('./_property-desc'); module.exports = require('./_descriptors') ? function (object, key, value) { @@ -5404,17 +5309,17 @@ module.exports = require('./_descriptors') ? function (object, key, value) { return object; }; -},{"./_descriptors":59,"./_object-dp":68,"./_property-desc":69}],66:[function(require,module,exports){ +},{"./_descriptors":53,"./_object-dp":62,"./_property-desc":63}],60:[function(require,module,exports){ module.exports = !require('./_descriptors') && !require('./_fails')(function () { return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_descriptors":59,"./_dom-create":60,"./_fails":62}],67:[function(require,module,exports){ +},{"./_descriptors":53,"./_dom-create":54,"./_fails":56}],61:[function(require,module,exports){ module.exports = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -},{}],68:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ var anObject = require('./_an-object'); var IE8_DOM_DEFINE = require('./_ie8-dom-define'); var toPrimitive = require('./_to-primitive'); @@ -5432,7 +5337,7 @@ exports.f = require('./_descriptors') ? Object.defineProperty : function defineP return O; }; -},{"./_an-object":56,"./_descriptors":59,"./_ie8-dom-define":66,"./_to-primitive":70}],69:[function(require,module,exports){ +},{"./_an-object":50,"./_descriptors":53,"./_ie8-dom-define":60,"./_to-primitive":64}],63:[function(require,module,exports){ module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -5442,7 +5347,7 @@ module.exports = function (bitmap, value) { }; }; -},{}],70:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = require('./_is-object'); // instead of the ES6 spec version, we didn't implement @@toPrimitive case @@ -5456,22 +5361,22 @@ module.exports = function (it, S) { throw TypeError("Can't convert object to primitive value"); }; -},{"./_is-object":67}],71:[function(require,module,exports){ +},{"./_is-object":61}],65:[function(require,module,exports){ // https://github.com/tc39/proposal-global var $export = require('./_export'); $export($export.G, { global: require('./_global') }); -},{"./_export":61,"./_global":63}],72:[function(require,module,exports){ -arguments[4][55][0].apply(exports,arguments) -},{"dup":55}],73:[function(require,module,exports){ +},{"./_export":55,"./_global":57}],66:[function(require,module,exports){ +arguments[4][49][0].apply(exports,arguments) +},{"dup":49}],67:[function(require,module,exports){ var cof = require('./_cof'); module.exports = function (it, msg) { if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg); return +it; }; -},{"./_cof":87}],74:[function(require,module,exports){ +},{"./_cof":81}],68:[function(require,module,exports){ // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = require('./_wks')('unscopables'); var ArrayProto = Array.prototype; @@ -5480,7 +5385,7 @@ module.exports = function (key) { ArrayProto[UNSCOPABLES][key] = true; }; -},{"./_hide":111,"./_wks":191}],75:[function(require,module,exports){ +},{"./_hide":105,"./_wks":185}],69:[function(require,module,exports){ 'use strict'; var at = require('./_string-at')(true); @@ -5490,16 +5395,16 @@ module.exports = function (S, index, unicode) { return index + (unicode ? at(S, index).length : 1); }; -},{"./_string-at":168}],76:[function(require,module,exports){ +},{"./_string-at":162}],70:[function(require,module,exports){ module.exports = function (it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { throw TypeError(name + ': incorrect invocation!'); } return it; }; -},{}],77:[function(require,module,exports){ -arguments[4][56][0].apply(exports,arguments) -},{"./_is-object":120,"dup":56}],78:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ +arguments[4][50][0].apply(exports,arguments) +},{"./_is-object":114,"dup":50}],72:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -5527,7 +5432,7 @@ module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* } return O; }; -},{"./_to-absolute-index":176,"./_to-length":180,"./_to-object":181}],79:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-length":174,"./_to-object":175}],73:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -5544,7 +5449,7 @@ module.exports = function fill(value /* , start = 0, end = @length */) { return O; }; -},{"./_to-absolute-index":176,"./_to-length":180,"./_to-object":181}],80:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-length":174,"./_to-object":175}],74:[function(require,module,exports){ // false -> Array#indexOf // true -> Array#includes var toIObject = require('./_to-iobject'); @@ -5569,7 +5474,7 @@ module.exports = function (IS_INCLUDES) { }; }; -},{"./_to-absolute-index":176,"./_to-iobject":179,"./_to-length":180}],81:[function(require,module,exports){ +},{"./_to-absolute-index":170,"./_to-iobject":173,"./_to-length":174}],75:[function(require,module,exports){ // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter @@ -5615,7 +5520,7 @@ module.exports = function (TYPE, $create) { }; }; -},{"./_array-species-create":84,"./_ctx":93,"./_iobject":116,"./_to-length":180,"./_to-object":181}],82:[function(require,module,exports){ +},{"./_array-species-create":78,"./_ctx":87,"./_iobject":110,"./_to-length":174,"./_to-object":175}],76:[function(require,module,exports){ var aFunction = require('./_a-function'); var toObject = require('./_to-object'); var IObject = require('./_iobject'); @@ -5645,7 +5550,7 @@ module.exports = function (that, callbackfn, aLen, memo, isRight) { return memo; }; -},{"./_a-function":72,"./_iobject":116,"./_to-length":180,"./_to-object":181}],83:[function(require,module,exports){ +},{"./_a-function":66,"./_iobject":110,"./_to-length":174,"./_to-object":175}],77:[function(require,module,exports){ var isObject = require('./_is-object'); var isArray = require('./_is-array'); var SPECIES = require('./_wks')('species'); @@ -5663,7 +5568,7 @@ module.exports = function (original) { } return C === undefined ? Array : C; }; -},{"./_is-array":118,"./_is-object":120,"./_wks":191}],84:[function(require,module,exports){ +},{"./_is-array":112,"./_is-object":114,"./_wks":185}],78:[function(require,module,exports){ // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var speciesConstructor = require('./_array-species-constructor'); @@ -5671,7 +5576,7 @@ module.exports = function (original, length) { return new (speciesConstructor(original))(length); }; -},{"./_array-species-constructor":83}],85:[function(require,module,exports){ +},{"./_array-species-constructor":77}],79:[function(require,module,exports){ 'use strict'; var aFunction = require('./_a-function'); var isObject = require('./_is-object'); @@ -5698,7 +5603,7 @@ module.exports = Function.bind || function bind(that /* , ...args */) { return bound; }; -},{"./_a-function":72,"./_invoke":115,"./_is-object":120}],86:[function(require,module,exports){ +},{"./_a-function":66,"./_invoke":109,"./_is-object":114}],80:[function(require,module,exports){ // getting tag from 19.1.3.6 Object.prototype.toString() var cof = require('./_cof'); var TAG = require('./_wks')('toStringTag'); @@ -5723,14 +5628,14 @@ module.exports = function (it) { : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; -},{"./_cof":87,"./_wks":191}],87:[function(require,module,exports){ +},{"./_cof":81,"./_wks":185}],81:[function(require,module,exports){ var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; -},{}],88:[function(require,module,exports){ +},{}],82:[function(require,module,exports){ 'use strict'; var dP = require('./_object-dp').f; var create = require('./_object-create'); @@ -5876,7 +5781,7 @@ module.exports = { } }; -},{"./_an-instance":76,"./_ctx":93,"./_descriptors":97,"./_for-of":107,"./_iter-define":124,"./_iter-step":126,"./_meta":133,"./_object-create":137,"./_object-dp":138,"./_redefine-all":156,"./_set-species":162,"./_validate-collection":188}],89:[function(require,module,exports){ +},{"./_an-instance":70,"./_ctx":87,"./_descriptors":91,"./_for-of":101,"./_iter-define":118,"./_iter-step":120,"./_meta":127,"./_object-create":131,"./_object-dp":132,"./_redefine-all":150,"./_set-species":156,"./_validate-collection":182}],83:[function(require,module,exports){ 'use strict'; var redefineAll = require('./_redefine-all'); var getWeak = require('./_meta').getWeak; @@ -5963,7 +5868,7 @@ module.exports = { ufstore: uncaughtFrozenStore }; -},{"./_an-instance":76,"./_an-object":77,"./_array-methods":81,"./_for-of":107,"./_has":110,"./_is-object":120,"./_meta":133,"./_redefine-all":156,"./_validate-collection":188}],90:[function(require,module,exports){ +},{"./_an-instance":70,"./_an-object":71,"./_array-methods":75,"./_for-of":101,"./_has":104,"./_is-object":114,"./_meta":127,"./_redefine-all":150,"./_validate-collection":182}],84:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var $export = require('./_export'); @@ -6050,9 +5955,9 @@ module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { return C; }; -},{"./_an-instance":76,"./_export":101,"./_fails":103,"./_for-of":107,"./_global":109,"./_inherit-if-required":114,"./_is-object":120,"./_iter-detect":125,"./_meta":133,"./_redefine":157,"./_redefine-all":156,"./_set-to-string-tag":163}],91:[function(require,module,exports){ -arguments[4][57][0].apply(exports,arguments) -},{"dup":57}],92:[function(require,module,exports){ +},{"./_an-instance":70,"./_export":95,"./_fails":97,"./_for-of":101,"./_global":103,"./_inherit-if-required":108,"./_is-object":114,"./_iter-detect":119,"./_meta":127,"./_redefine":151,"./_redefine-all":150,"./_set-to-string-tag":157}],85:[function(require,module,exports){ +arguments[4][51][0].apply(exports,arguments) +},{"dup":51}],86:[function(require,module,exports){ 'use strict'; var $defineProperty = require('./_object-dp'); var createDesc = require('./_property-desc'); @@ -6062,9 +5967,9 @@ module.exports = function (object, index, value) { else object[index] = value; }; -},{"./_object-dp":138,"./_property-desc":155}],93:[function(require,module,exports){ -arguments[4][58][0].apply(exports,arguments) -},{"./_a-function":72,"dup":58}],94:[function(require,module,exports){ +},{"./_object-dp":132,"./_property-desc":149}],87:[function(require,module,exports){ +arguments[4][52][0].apply(exports,arguments) +},{"./_a-function":66,"dup":52}],88:[function(require,module,exports){ 'use strict'; // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var fails = require('./_fails'); @@ -6092,7 +5997,7 @@ module.exports = (fails(function () { ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; } : $toISOString; -},{"./_fails":103}],95:[function(require,module,exports){ +},{"./_fails":97}],89:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); var toPrimitive = require('./_to-primitive'); @@ -6103,24 +6008,24 @@ module.exports = function (hint) { return toPrimitive(anObject(this), hint != NUMBER); }; -},{"./_an-object":77,"./_to-primitive":182}],96:[function(require,module,exports){ +},{"./_an-object":71,"./_to-primitive":176}],90:[function(require,module,exports){ // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; -},{}],97:[function(require,module,exports){ -arguments[4][59][0].apply(exports,arguments) -},{"./_fails":103,"dup":59}],98:[function(require,module,exports){ -arguments[4][60][0].apply(exports,arguments) -},{"./_global":109,"./_is-object":120,"dup":60}],99:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ +arguments[4][53][0].apply(exports,arguments) +},{"./_fails":97,"dup":53}],92:[function(require,module,exports){ +arguments[4][54][0].apply(exports,arguments) +},{"./_global":103,"./_is-object":114,"dup":54}],93:[function(require,module,exports){ // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); -},{}],100:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ // all enumerable object keys, includes symbols var getKeys = require('./_object-keys'); var gOPS = require('./_object-gops'); @@ -6137,7 +6042,7 @@ module.exports = function (it) { } return result; }; -},{"./_object-gops":143,"./_object-keys":146,"./_object-pie":147}],101:[function(require,module,exports){ +},{"./_object-gops":137,"./_object-keys":140,"./_object-pie":141}],95:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var hide = require('./_hide'); @@ -6182,7 +6087,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":91,"./_ctx":93,"./_global":109,"./_hide":111,"./_redefine":157}],102:[function(require,module,exports){ +},{"./_core":85,"./_ctx":87,"./_global":103,"./_hide":105,"./_redefine":151}],96:[function(require,module,exports){ var MATCH = require('./_wks')('match'); module.exports = function (KEY) { var re = /./; @@ -6196,9 +6101,9 @@ module.exports = function (KEY) { } return true; }; -},{"./_wks":191}],103:[function(require,module,exports){ -arguments[4][62][0].apply(exports,arguments) -},{"dup":62}],104:[function(require,module,exports){ +},{"./_wks":185}],97:[function(require,module,exports){ +arguments[4][56][0].apply(exports,arguments) +},{"dup":56}],98:[function(require,module,exports){ 'use strict'; require('./es6.regexp.exec'); var redefine = require('./_redefine'); @@ -6296,7 +6201,7 @@ module.exports = function (KEY, length, exec) { } }; -},{"./_defined":96,"./_fails":103,"./_hide":111,"./_redefine":157,"./_regexp-exec":159,"./_wks":191,"./es6.regexp.exec":287}],105:[function(require,module,exports){ +},{"./_defined":90,"./_fails":97,"./_hide":105,"./_redefine":151,"./_regexp-exec":153,"./_wks":185,"./es6.regexp.exec":281}],99:[function(require,module,exports){ 'use strict'; // 21.2.5.3 get RegExp.prototype.flags var anObject = require('./_an-object'); @@ -6311,7 +6216,7 @@ module.exports = function () { return result; }; -},{"./_an-object":77}],106:[function(require,module,exports){ +},{"./_an-object":71}],100:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray var isArray = require('./_is-array'); @@ -6352,7 +6257,7 @@ function flattenIntoArray(target, original, source, sourceLen, start, depth, map module.exports = flattenIntoArray; -},{"./_ctx":93,"./_is-array":118,"./_is-object":120,"./_to-length":180,"./_wks":191}],107:[function(require,module,exports){ +},{"./_ctx":87,"./_is-array":112,"./_is-object":114,"./_to-length":174,"./_wks":185}],101:[function(require,module,exports){ var ctx = require('./_ctx'); var call = require('./_iter-call'); var isArrayIter = require('./_is-array-iter'); @@ -6379,22 +6284,22 @@ var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) exports.BREAK = BREAK; exports.RETURN = RETURN; -},{"./_an-object":77,"./_ctx":93,"./_is-array-iter":117,"./_iter-call":122,"./_to-length":180,"./core.get-iterator-method":192}],108:[function(require,module,exports){ +},{"./_an-object":71,"./_ctx":87,"./_is-array-iter":111,"./_iter-call":116,"./_to-length":174,"./core.get-iterator-method":186}],102:[function(require,module,exports){ module.exports = require('./_shared')('native-function-to-string', Function.toString); -},{"./_shared":165}],109:[function(require,module,exports){ -arguments[4][63][0].apply(exports,arguments) -},{"dup":63}],110:[function(require,module,exports){ -arguments[4][64][0].apply(exports,arguments) -},{"dup":64}],111:[function(require,module,exports){ -arguments[4][65][0].apply(exports,arguments) -},{"./_descriptors":97,"./_object-dp":138,"./_property-desc":155,"dup":65}],112:[function(require,module,exports){ +},{"./_shared":159}],103:[function(require,module,exports){ +arguments[4][57][0].apply(exports,arguments) +},{"dup":57}],104:[function(require,module,exports){ +arguments[4][58][0].apply(exports,arguments) +},{"dup":58}],105:[function(require,module,exports){ +arguments[4][59][0].apply(exports,arguments) +},{"./_descriptors":91,"./_object-dp":132,"./_property-desc":149,"dup":59}],106:[function(require,module,exports){ var document = require('./_global').document; module.exports = document && document.documentElement; -},{"./_global":109}],113:[function(require,module,exports){ -arguments[4][66][0].apply(exports,arguments) -},{"./_descriptors":97,"./_dom-create":98,"./_fails":103,"dup":66}],114:[function(require,module,exports){ +},{"./_global":103}],107:[function(require,module,exports){ +arguments[4][60][0].apply(exports,arguments) +},{"./_descriptors":91,"./_dom-create":92,"./_fails":97,"dup":60}],108:[function(require,module,exports){ var isObject = require('./_is-object'); var setPrototypeOf = require('./_set-proto').set; module.exports = function (that, target, C) { @@ -6405,7 +6310,7 @@ module.exports = function (that, target, C) { } return that; }; -},{"./_is-object":120,"./_set-proto":161}],115:[function(require,module,exports){ +},{"./_is-object":114,"./_set-proto":155}],109:[function(require,module,exports){ // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function (fn, args, that) { var un = that === undefined; @@ -6423,7 +6328,7 @@ module.exports = function (fn, args, that) { } return fn.apply(that, args); }; -},{}],116:[function(require,module,exports){ +},{}],110:[function(require,module,exports){ // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = require('./_cof'); // eslint-disable-next-line no-prototype-builtins @@ -6431,7 +6336,7 @@ module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; -},{"./_cof":87}],117:[function(require,module,exports){ +},{"./_cof":81}],111:[function(require,module,exports){ // check on default Array iterator var Iterators = require('./_iterators'); var ITERATOR = require('./_wks')('iterator'); @@ -6441,14 +6346,14 @@ module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; -},{"./_iterators":127,"./_wks":191}],118:[function(require,module,exports){ +},{"./_iterators":121,"./_wks":185}],112:[function(require,module,exports){ // 7.2.2 IsArray(argument) var cof = require('./_cof'); module.exports = Array.isArray || function isArray(arg) { return cof(arg) == 'Array'; }; -},{"./_cof":87}],119:[function(require,module,exports){ +},{"./_cof":81}],113:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var isObject = require('./_is-object'); var floor = Math.floor; @@ -6456,9 +6361,9 @@ module.exports = function isInteger(it) { return !isObject(it) && isFinite(it) && floor(it) === it; }; -},{"./_is-object":120}],120:[function(require,module,exports){ -arguments[4][67][0].apply(exports,arguments) -},{"dup":67}],121:[function(require,module,exports){ +},{"./_is-object":114}],114:[function(require,module,exports){ +arguments[4][61][0].apply(exports,arguments) +},{"dup":61}],115:[function(require,module,exports){ // 7.2.8 IsRegExp(argument) var isObject = require('./_is-object'); var cof = require('./_cof'); @@ -6468,7 +6373,7 @@ module.exports = function (it) { return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); }; -},{"./_cof":87,"./_is-object":120,"./_wks":191}],122:[function(require,module,exports){ +},{"./_cof":81,"./_is-object":114,"./_wks":185}],116:[function(require,module,exports){ // call something on iterator step with safe closing on error var anObject = require('./_an-object'); module.exports = function (iterator, fn, value, entries) { @@ -6482,7 +6387,7 @@ module.exports = function (iterator, fn, value, entries) { } }; -},{"./_an-object":77}],123:[function(require,module,exports){ +},{"./_an-object":71}],117:[function(require,module,exports){ 'use strict'; var create = require('./_object-create'); var descriptor = require('./_property-desc'); @@ -6497,7 +6402,7 @@ module.exports = function (Constructor, NAME, next) { setToStringTag(Constructor, NAME + ' Iterator'); }; -},{"./_hide":111,"./_object-create":137,"./_property-desc":155,"./_set-to-string-tag":163,"./_wks":191}],124:[function(require,module,exports){ +},{"./_hide":105,"./_object-create":131,"./_property-desc":149,"./_set-to-string-tag":157,"./_wks":185}],118:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var $export = require('./_export'); @@ -6568,7 +6473,7 @@ module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE return methods; }; -},{"./_export":101,"./_hide":111,"./_iter-create":123,"./_iterators":127,"./_library":128,"./_object-gpo":144,"./_redefine":157,"./_set-to-string-tag":163,"./_wks":191}],125:[function(require,module,exports){ +},{"./_export":95,"./_hide":105,"./_iter-create":117,"./_iterators":121,"./_library":122,"./_object-gpo":138,"./_redefine":151,"./_set-to-string-tag":157,"./_wks":185}],119:[function(require,module,exports){ var ITERATOR = require('./_wks')('iterator'); var SAFE_CLOSING = false; @@ -6592,18 +6497,18 @@ module.exports = function (exec, skipClosing) { return safe; }; -},{"./_wks":191}],126:[function(require,module,exports){ +},{"./_wks":185}],120:[function(require,module,exports){ module.exports = function (done, value) { return { value: value, done: !!done }; }; -},{}],127:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ module.exports = {}; -},{}],128:[function(require,module,exports){ +},{}],122:[function(require,module,exports){ module.exports = false; -},{}],129:[function(require,module,exports){ +},{}],123:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $expm1 = Math.expm1; module.exports = (!$expm1 @@ -6615,7 +6520,7 @@ module.exports = (!$expm1 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; } : $expm1; -},{}],130:[function(require,module,exports){ +},{}],124:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var sign = require('./_math-sign'); var pow = Math.pow; @@ -6640,20 +6545,20 @@ module.exports = Math.fround || function fround(x) { return $sign * result; }; -},{"./_math-sign":132}],131:[function(require,module,exports){ +},{"./_math-sign":126}],125:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) module.exports = Math.log1p || function log1p(x) { return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); }; -},{}],132:[function(require,module,exports){ +},{}],126:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) module.exports = Math.sign || function sign(x) { // eslint-disable-next-line no-self-compare return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; }; -},{}],133:[function(require,module,exports){ +},{}],127:[function(require,module,exports){ var META = require('./_uid')('meta'); var isObject = require('./_is-object'); var has = require('./_has'); @@ -6708,7 +6613,7 @@ var meta = module.exports = { onFreeze: onFreeze }; -},{"./_fails":103,"./_has":110,"./_is-object":120,"./_object-dp":138,"./_uid":186}],134:[function(require,module,exports){ +},{"./_fails":97,"./_has":104,"./_is-object":114,"./_object-dp":132,"./_uid":180}],128:[function(require,module,exports){ var global = require('./_global'); var macrotask = require('./_task').set; var Observer = global.MutationObserver || global.WebKitMutationObserver; @@ -6779,7 +6684,7 @@ module.exports = function () { }; }; -},{"./_cof":87,"./_global":109,"./_task":175}],135:[function(require,module,exports){ +},{"./_cof":81,"./_global":103,"./_task":169}],129:[function(require,module,exports){ 'use strict'; // 25.4.1.5 NewPromiseCapability(C) var aFunction = require('./_a-function'); @@ -6799,7 +6704,7 @@ module.exports.f = function (C) { return new PromiseCapability(C); }; -},{"./_a-function":72}],136:[function(require,module,exports){ +},{"./_a-function":66}],130:[function(require,module,exports){ 'use strict'; // 19.1.2.1 Object.assign(target, source, ...) var DESCRIPTORS = require('./_descriptors'); @@ -6839,7 +6744,7 @@ module.exports = !$assign || require('./_fails')(function () { } return T; } : $assign; -},{"./_descriptors":97,"./_fails":103,"./_iobject":116,"./_object-gops":143,"./_object-keys":146,"./_object-pie":147,"./_to-object":181}],137:[function(require,module,exports){ +},{"./_descriptors":91,"./_fails":97,"./_iobject":110,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_to-object":175}],131:[function(require,module,exports){ // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = require('./_an-object'); var dPs = require('./_object-dps'); @@ -6882,9 +6787,9 @@ module.exports = Object.create || function create(O, Properties) { return Properties === undefined ? result : dPs(result, Properties); }; -},{"./_an-object":77,"./_dom-create":98,"./_enum-bug-keys":99,"./_html":112,"./_object-dps":139,"./_shared-key":164}],138:[function(require,module,exports){ -arguments[4][68][0].apply(exports,arguments) -},{"./_an-object":77,"./_descriptors":97,"./_ie8-dom-define":113,"./_to-primitive":182,"dup":68}],139:[function(require,module,exports){ +},{"./_an-object":71,"./_dom-create":92,"./_enum-bug-keys":93,"./_html":106,"./_object-dps":133,"./_shared-key":158}],132:[function(require,module,exports){ +arguments[4][62][0].apply(exports,arguments) +},{"./_an-object":71,"./_descriptors":91,"./_ie8-dom-define":107,"./_to-primitive":176,"dup":62}],133:[function(require,module,exports){ var dP = require('./_object-dp'); var anObject = require('./_an-object'); var getKeys = require('./_object-keys'); @@ -6899,7 +6804,7 @@ module.exports = require('./_descriptors') ? Object.defineProperties : function return O; }; -},{"./_an-object":77,"./_descriptors":97,"./_object-dp":138,"./_object-keys":146}],140:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_object-dp":132,"./_object-keys":140}],134:[function(require,module,exports){ var pIE = require('./_object-pie'); var createDesc = require('./_property-desc'); var toIObject = require('./_to-iobject'); @@ -6917,7 +6822,7 @@ exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); }; -},{"./_descriptors":97,"./_has":110,"./_ie8-dom-define":113,"./_object-pie":147,"./_property-desc":155,"./_to-iobject":179,"./_to-primitive":182}],141:[function(require,module,exports){ +},{"./_descriptors":91,"./_has":104,"./_ie8-dom-define":107,"./_object-pie":141,"./_property-desc":149,"./_to-iobject":173,"./_to-primitive":176}],135:[function(require,module,exports){ // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window var toIObject = require('./_to-iobject'); var gOPN = require('./_object-gopn').f; @@ -6938,7 +6843,7 @@ module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); }; -},{"./_object-gopn":142,"./_to-iobject":179}],142:[function(require,module,exports){ +},{"./_object-gopn":136,"./_to-iobject":173}],136:[function(require,module,exports){ // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = require('./_object-keys-internal'); var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype'); @@ -6947,10 +6852,10 @@ exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return $keys(O, hiddenKeys); }; -},{"./_enum-bug-keys":99,"./_object-keys-internal":145}],143:[function(require,module,exports){ +},{"./_enum-bug-keys":93,"./_object-keys-internal":139}],137:[function(require,module,exports){ exports.f = Object.getOwnPropertySymbols; -},{}],144:[function(require,module,exports){ +},{}],138:[function(require,module,exports){ // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = require('./_has'); var toObject = require('./_to-object'); @@ -6965,7 +6870,7 @@ module.exports = Object.getPrototypeOf || function (O) { } return O instanceof Object ? ObjectProto : null; }; -},{"./_has":110,"./_shared-key":164,"./_to-object":181}],145:[function(require,module,exports){ +},{"./_has":104,"./_shared-key":158,"./_to-object":175}],139:[function(require,module,exports){ var has = require('./_has'); var toIObject = require('./_to-iobject'); var arrayIndexOf = require('./_array-includes')(false); @@ -6984,7 +6889,7 @@ module.exports = function (object, names) { return result; }; -},{"./_array-includes":80,"./_has":110,"./_shared-key":164,"./_to-iobject":179}],146:[function(require,module,exports){ +},{"./_array-includes":74,"./_has":104,"./_shared-key":158,"./_to-iobject":173}],140:[function(require,module,exports){ // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = require('./_object-keys-internal'); var enumBugKeys = require('./_enum-bug-keys'); @@ -6993,10 +6898,10 @@ module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; -},{"./_enum-bug-keys":99,"./_object-keys-internal":145}],147:[function(require,module,exports){ +},{"./_enum-bug-keys":93,"./_object-keys-internal":139}],141:[function(require,module,exports){ exports.f = {}.propertyIsEnumerable; -},{}],148:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ // most Object methods by ES6 should accept primitives var $export = require('./_export'); var core = require('./_core'); @@ -7008,7 +6913,7 @@ module.exports = function (KEY, exec) { $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); }; -},{"./_core":91,"./_export":101,"./_fails":103}],149:[function(require,module,exports){ +},{"./_core":85,"./_export":95,"./_fails":97}],143:[function(require,module,exports){ var DESCRIPTORS = require('./_descriptors'); var getKeys = require('./_object-keys'); var toIObject = require('./_to-iobject'); @@ -7031,7 +6936,7 @@ module.exports = function (isEntries) { }; }; -},{"./_descriptors":97,"./_object-keys":146,"./_object-pie":147,"./_to-iobject":179}],150:[function(require,module,exports){ +},{"./_descriptors":91,"./_object-keys":140,"./_object-pie":141,"./_to-iobject":173}],144:[function(require,module,exports){ // all object keys, includes non-enumerable and symbols var gOPN = require('./_object-gopn'); var gOPS = require('./_object-gops'); @@ -7043,7 +6948,7 @@ module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { return getSymbols ? keys.concat(getSymbols(it)) : keys; }; -},{"./_an-object":77,"./_global":109,"./_object-gopn":142,"./_object-gops":143}],151:[function(require,module,exports){ +},{"./_an-object":71,"./_global":103,"./_object-gopn":136,"./_object-gops":137}],145:[function(require,module,exports){ var $parseFloat = require('./_global').parseFloat; var $trim = require('./_string-trim').trim; @@ -7053,7 +6958,7 @@ module.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? return result === 0 && string.charAt(0) == '-' ? -0 : result; } : $parseFloat; -},{"./_global":109,"./_string-trim":173,"./_string-ws":174}],152:[function(require,module,exports){ +},{"./_global":103,"./_string-trim":167,"./_string-ws":168}],146:[function(require,module,exports){ var $parseInt = require('./_global').parseInt; var $trim = require('./_string-trim').trim; var ws = require('./_string-ws'); @@ -7064,7 +6969,7 @@ module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? f return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); } : $parseInt; -},{"./_global":109,"./_string-trim":173,"./_string-ws":174}],153:[function(require,module,exports){ +},{"./_global":103,"./_string-trim":167,"./_string-ws":168}],147:[function(require,module,exports){ module.exports = function (exec) { try { return { e: false, v: exec() }; @@ -7073,7 +6978,7 @@ module.exports = function (exec) { } }; -},{}],154:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ var anObject = require('./_an-object'); var isObject = require('./_is-object'); var newPromiseCapability = require('./_new-promise-capability'); @@ -7087,16 +6992,16 @@ module.exports = function (C, x) { return promiseCapability.promise; }; -},{"./_an-object":77,"./_is-object":120,"./_new-promise-capability":135}],155:[function(require,module,exports){ -arguments[4][69][0].apply(exports,arguments) -},{"dup":69}],156:[function(require,module,exports){ +},{"./_an-object":71,"./_is-object":114,"./_new-promise-capability":129}],149:[function(require,module,exports){ +arguments[4][63][0].apply(exports,arguments) +},{"dup":63}],150:[function(require,module,exports){ var redefine = require('./_redefine'); module.exports = function (target, src, safe) { for (var key in src) redefine(target, key, src[key], safe); return target; }; -},{"./_redefine":157}],157:[function(require,module,exports){ +},{"./_redefine":151}],151:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var has = require('./_has'); @@ -7129,7 +7034,7 @@ require('./_core').inspectSource = function (it) { return typeof this == 'function' && this[SRC] || $toString.call(this); }); -},{"./_core":91,"./_function-to-string":108,"./_global":109,"./_has":110,"./_hide":111,"./_uid":186}],158:[function(require,module,exports){ +},{"./_core":85,"./_function-to-string":102,"./_global":103,"./_has":104,"./_hide":105,"./_uid":180}],152:[function(require,module,exports){ 'use strict'; var classof = require('./_classof'); @@ -7152,7 +7057,7 @@ module.exports = function (R, S) { return builtinExec.call(R, S); }; -},{"./_classof":86}],159:[function(require,module,exports){ +},{"./_classof":80}],153:[function(require,module,exports){ 'use strict'; var regexpFlags = require('./_flags'); @@ -7212,14 +7117,14 @@ if (PATCH) { module.exports = patchedExec; -},{"./_flags":105}],160:[function(require,module,exports){ +},{"./_flags":99}],154:[function(require,module,exports){ // 7.2.9 SameValue(x, y) module.exports = Object.is || function is(x, y) { // eslint-disable-next-line no-self-compare return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; }; -},{}],161:[function(require,module,exports){ +},{}],155:[function(require,module,exports){ // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ var isObject = require('./_is-object'); @@ -7246,7 +7151,7 @@ module.exports = { check: check }; -},{"./_an-object":77,"./_ctx":93,"./_is-object":120,"./_object-gopd":140}],162:[function(require,module,exports){ +},{"./_an-object":71,"./_ctx":87,"./_is-object":114,"./_object-gopd":134}],156:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var dP = require('./_object-dp'); @@ -7261,7 +7166,7 @@ module.exports = function (KEY) { }); }; -},{"./_descriptors":97,"./_global":109,"./_object-dp":138,"./_wks":191}],163:[function(require,module,exports){ +},{"./_descriptors":91,"./_global":103,"./_object-dp":132,"./_wks":185}],157:[function(require,module,exports){ var def = require('./_object-dp').f; var has = require('./_has'); var TAG = require('./_wks')('toStringTag'); @@ -7270,14 +7175,14 @@ module.exports = function (it, tag, stat) { if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); }; -},{"./_has":110,"./_object-dp":138,"./_wks":191}],164:[function(require,module,exports){ +},{"./_has":104,"./_object-dp":132,"./_wks":185}],158:[function(require,module,exports){ var shared = require('./_shared')('keys'); var uid = require('./_uid'); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; -},{"./_shared":165,"./_uid":186}],165:[function(require,module,exports){ +},{"./_shared":159,"./_uid":180}],159:[function(require,module,exports){ var core = require('./_core'); var global = require('./_global'); var SHARED = '__core-js_shared__'; @@ -7291,7 +7196,7 @@ var store = global[SHARED] || (global[SHARED] = {}); copyright: '© 2020 Denis Pushkarev (zloirock.ru)' }); -},{"./_core":91,"./_global":109,"./_library":128}],166:[function(require,module,exports){ +},{"./_core":85,"./_global":103,"./_library":122}],160:[function(require,module,exports){ // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = require('./_an-object'); var aFunction = require('./_a-function'); @@ -7302,7 +7207,7 @@ module.exports = function (O, D) { return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; -},{"./_a-function":72,"./_an-object":77,"./_wks":191}],167:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_wks":185}],161:[function(require,module,exports){ 'use strict'; var fails = require('./_fails'); @@ -7313,7 +7218,7 @@ module.exports = function (method, arg) { }); }; -},{"./_fails":103}],168:[function(require,module,exports){ +},{"./_fails":97}],162:[function(require,module,exports){ var toInteger = require('./_to-integer'); var defined = require('./_defined'); // true -> String#at @@ -7332,7 +7237,7 @@ module.exports = function (TO_STRING) { }; }; -},{"./_defined":96,"./_to-integer":178}],169:[function(require,module,exports){ +},{"./_defined":90,"./_to-integer":172}],163:[function(require,module,exports){ // helper for String#{startsWith, endsWith, includes} var isRegExp = require('./_is-regexp'); var defined = require('./_defined'); @@ -7342,7 +7247,7 @@ module.exports = function (that, searchString, NAME) { return String(defined(that)); }; -},{"./_defined":96,"./_is-regexp":121}],170:[function(require,module,exports){ +},{"./_defined":90,"./_is-regexp":115}],164:[function(require,module,exports){ var $export = require('./_export'); var fails = require('./_fails'); var defined = require('./_defined'); @@ -7363,7 +7268,7 @@ module.exports = function (NAME, exec) { }), 'String', O); }; -},{"./_defined":96,"./_export":101,"./_fails":103}],171:[function(require,module,exports){ +},{"./_defined":90,"./_export":95,"./_fails":97}],165:[function(require,module,exports){ // https://github.com/tc39/proposal-string-pad-start-end var toLength = require('./_to-length'); var repeat = require('./_string-repeat'); @@ -7381,7 +7286,7 @@ module.exports = function (that, maxLength, fillString, left) { return left ? stringFiller + S : S + stringFiller; }; -},{"./_defined":96,"./_string-repeat":172,"./_to-length":180}],172:[function(require,module,exports){ +},{"./_defined":90,"./_string-repeat":166,"./_to-length":174}],166:[function(require,module,exports){ 'use strict'; var toInteger = require('./_to-integer'); var defined = require('./_defined'); @@ -7395,7 +7300,7 @@ module.exports = function repeat(count) { return res; }; -},{"./_defined":96,"./_to-integer":178}],173:[function(require,module,exports){ +},{"./_defined":90,"./_to-integer":172}],167:[function(require,module,exports){ var $export = require('./_export'); var defined = require('./_defined'); var fails = require('./_fails'); @@ -7427,11 +7332,11 @@ var trim = exporter.trim = function (string, TYPE) { module.exports = exporter; -},{"./_defined":96,"./_export":101,"./_fails":103,"./_string-ws":174}],174:[function(require,module,exports){ +},{"./_defined":90,"./_export":95,"./_fails":97,"./_string-ws":168}],168:[function(require,module,exports){ module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -},{}],175:[function(require,module,exports){ +},{}],169:[function(require,module,exports){ var ctx = require('./_ctx'); var invoke = require('./_invoke'); var html = require('./_html'); @@ -7517,7 +7422,7 @@ module.exports = { clear: clearTask }; -},{"./_cof":87,"./_ctx":93,"./_dom-create":98,"./_global":109,"./_html":112,"./_invoke":115}],176:[function(require,module,exports){ +},{"./_cof":81,"./_ctx":87,"./_dom-create":92,"./_global":103,"./_html":106,"./_invoke":109}],170:[function(require,module,exports){ var toInteger = require('./_to-integer'); var max = Math.max; var min = Math.min; @@ -7526,7 +7431,7 @@ module.exports = function (index, length) { return index < 0 ? max(index + length, 0) : min(index, length); }; -},{"./_to-integer":178}],177:[function(require,module,exports){ +},{"./_to-integer":172}],171:[function(require,module,exports){ // https://tc39.github.io/ecma262/#sec-toindex var toInteger = require('./_to-integer'); var toLength = require('./_to-length'); @@ -7538,7 +7443,7 @@ module.exports = function (it) { return length; }; -},{"./_to-integer":178,"./_to-length":180}],178:[function(require,module,exports){ +},{"./_to-integer":172,"./_to-length":174}],172:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; @@ -7546,7 +7451,7 @@ module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],179:[function(require,module,exports){ +},{}],173:[function(require,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = require('./_iobject'); var defined = require('./_defined'); @@ -7554,7 +7459,7 @@ module.exports = function (it) { return IObject(defined(it)); }; -},{"./_defined":96,"./_iobject":116}],180:[function(require,module,exports){ +},{"./_defined":90,"./_iobject":110}],174:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./_to-integer'); var min = Math.min; @@ -7562,16 +7467,16 @@ module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./_to-integer":178}],181:[function(require,module,exports){ +},{"./_to-integer":172}],175:[function(require,module,exports){ // 7.1.13 ToObject(argument) var defined = require('./_defined'); module.exports = function (it) { return Object(defined(it)); }; -},{"./_defined":96}],182:[function(require,module,exports){ -arguments[4][70][0].apply(exports,arguments) -},{"./_is-object":120,"dup":70}],183:[function(require,module,exports){ +},{"./_defined":90}],176:[function(require,module,exports){ +arguments[4][64][0].apply(exports,arguments) +},{"./_is-object":114,"dup":64}],177:[function(require,module,exports){ 'use strict'; if (require('./_descriptors')) { var LIBRARY = require('./_library'); @@ -8053,7 +7958,7 @@ if (require('./_descriptors')) { }; } else module.exports = function () { /* empty */ }; -},{"./_an-instance":76,"./_array-copy-within":78,"./_array-fill":79,"./_array-includes":80,"./_array-methods":81,"./_classof":86,"./_ctx":93,"./_descriptors":97,"./_export":101,"./_fails":103,"./_global":109,"./_has":110,"./_hide":111,"./_is-array-iter":117,"./_is-object":120,"./_iter-detect":125,"./_iterators":127,"./_library":128,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_object-gpo":144,"./_property-desc":155,"./_redefine-all":156,"./_set-species":162,"./_species-constructor":166,"./_to-absolute-index":176,"./_to-index":177,"./_to-integer":178,"./_to-length":180,"./_to-object":181,"./_to-primitive":182,"./_typed":185,"./_typed-buffer":184,"./_uid":186,"./_wks":191,"./core.get-iterator-method":192,"./es6.array.iterator":203}],184:[function(require,module,exports){ +},{"./_an-instance":70,"./_array-copy-within":72,"./_array-fill":73,"./_array-includes":74,"./_array-methods":75,"./_classof":80,"./_ctx":87,"./_descriptors":91,"./_export":95,"./_fails":97,"./_global":103,"./_has":104,"./_hide":105,"./_is-array-iter":111,"./_is-object":114,"./_iter-detect":119,"./_iterators":121,"./_library":122,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_object-gpo":138,"./_property-desc":149,"./_redefine-all":150,"./_set-species":156,"./_species-constructor":160,"./_to-absolute-index":170,"./_to-index":171,"./_to-integer":172,"./_to-length":174,"./_to-object":175,"./_to-primitive":176,"./_typed":179,"./_typed-buffer":178,"./_uid":180,"./_wks":185,"./core.get-iterator-method":186,"./es6.array.iterator":197}],178:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var DESCRIPTORS = require('./_descriptors'); @@ -8331,7 +8236,7 @@ hide($DataView[PROTOTYPE], $typed.VIEW, true); exports[ARRAY_BUFFER] = $ArrayBuffer; exports[DATA_VIEW] = $DataView; -},{"./_an-instance":76,"./_array-fill":79,"./_descriptors":97,"./_fails":103,"./_global":109,"./_hide":111,"./_library":128,"./_object-dp":138,"./_object-gopn":142,"./_redefine-all":156,"./_set-to-string-tag":163,"./_to-index":177,"./_to-integer":178,"./_to-length":180,"./_typed":185}],185:[function(require,module,exports){ +},{"./_an-instance":70,"./_array-fill":73,"./_descriptors":91,"./_fails":97,"./_global":103,"./_hide":105,"./_library":122,"./_object-dp":132,"./_object-gopn":136,"./_redefine-all":150,"./_set-to-string-tag":157,"./_to-index":171,"./_to-integer":172,"./_to-length":174,"./_typed":179}],179:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var uid = require('./_uid'); @@ -8361,27 +8266,27 @@ module.exports = { VIEW: VIEW }; -},{"./_global":109,"./_hide":111,"./_uid":186}],186:[function(require,module,exports){ +},{"./_global":103,"./_hide":105,"./_uid":180}],180:[function(require,module,exports){ var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],187:[function(require,module,exports){ +},{}],181:[function(require,module,exports){ var global = require('./_global'); var navigator = global.navigator; module.exports = navigator && navigator.userAgent || ''; -},{"./_global":109}],188:[function(require,module,exports){ +},{"./_global":103}],182:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it, TYPE) { if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); return it; }; -},{"./_is-object":120}],189:[function(require,module,exports){ +},{"./_is-object":114}],183:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var LIBRARY = require('./_library'); @@ -8392,10 +8297,10 @@ module.exports = function (name) { if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); }; -},{"./_core":91,"./_global":109,"./_library":128,"./_object-dp":138,"./_wks-ext":190}],190:[function(require,module,exports){ +},{"./_core":85,"./_global":103,"./_library":122,"./_object-dp":132,"./_wks-ext":184}],184:[function(require,module,exports){ exports.f = require('./_wks'); -},{"./_wks":191}],191:[function(require,module,exports){ +},{"./_wks":185}],185:[function(require,module,exports){ var store = require('./_shared')('wks'); var uid = require('./_uid'); var Symbol = require('./_global').Symbol; @@ -8408,7 +8313,7 @@ var $exports = module.exports = function (name) { $exports.store = store; -},{"./_global":109,"./_shared":165,"./_uid":186}],192:[function(require,module,exports){ +},{"./_global":103,"./_shared":159,"./_uid":180}],186:[function(require,module,exports){ var classof = require('./_classof'); var ITERATOR = require('./_wks')('iterator'); var Iterators = require('./_iterators'); @@ -8418,7 +8323,7 @@ module.exports = require('./_core').getIteratorMethod = function (it) { || Iterators[classof(it)]; }; -},{"./_classof":86,"./_core":91,"./_iterators":127,"./_wks":191}],193:[function(require,module,exports){ +},{"./_classof":80,"./_core":85,"./_iterators":121,"./_wks":185}],187:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) var $export = require('./_export'); @@ -8426,7 +8331,7 @@ $export($export.P, 'Array', { copyWithin: require('./_array-copy-within') }); require('./_add-to-unscopables')('copyWithin'); -},{"./_add-to-unscopables":74,"./_array-copy-within":78,"./_export":101}],194:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-copy-within":72,"./_export":95}],188:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $every = require('./_array-methods')(4); @@ -8438,7 +8343,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].every, true), 'A } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],195:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],189:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) var $export = require('./_export'); @@ -8446,7 +8351,7 @@ $export($export.P, 'Array', { fill: require('./_array-fill') }); require('./_add-to-unscopables')('fill'); -},{"./_add-to-unscopables":74,"./_array-fill":79,"./_export":101}],196:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-fill":73,"./_export":95}],190:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $filter = require('./_array-methods')(2); @@ -8458,7 +8363,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].filter, true), ' } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],197:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],191:[function(require,module,exports){ 'use strict'; // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) var $export = require('./_export'); @@ -8474,7 +8379,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":74,"./_array-methods":81,"./_export":101}],198:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-methods":75,"./_export":95}],192:[function(require,module,exports){ 'use strict'; // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) var $export = require('./_export'); @@ -8490,7 +8395,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":74,"./_array-methods":81,"./_export":101}],199:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-methods":75,"./_export":95}],193:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $forEach = require('./_array-methods')(0); @@ -8503,7 +8408,7 @@ $export($export.P + $export.F * !STRICT, 'Array', { } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],200:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],194:[function(require,module,exports){ 'use strict'; var ctx = require('./_ctx'); var $export = require('./_export'); @@ -8542,7 +8447,7 @@ $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Arr } }); -},{"./_create-property":92,"./_ctx":93,"./_export":101,"./_is-array-iter":117,"./_iter-call":122,"./_iter-detect":125,"./_to-length":180,"./_to-object":181,"./core.get-iterator-method":192}],201:[function(require,module,exports){ +},{"./_create-property":86,"./_ctx":87,"./_export":95,"./_is-array-iter":111,"./_iter-call":116,"./_iter-detect":119,"./_to-length":174,"./_to-object":175,"./core.get-iterator-method":186}],195:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $indexOf = require('./_array-includes')(false); @@ -8559,13 +8464,13 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_array-includes":80,"./_export":101,"./_strict-method":167}],202:[function(require,module,exports){ +},{"./_array-includes":74,"./_export":95,"./_strict-method":161}],196:[function(require,module,exports){ // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) var $export = require('./_export'); $export($export.S, 'Array', { isArray: require('./_is-array') }); -},{"./_export":101,"./_is-array":118}],203:[function(require,module,exports){ +},{"./_export":95,"./_is-array":112}],197:[function(require,module,exports){ 'use strict'; var addToUnscopables = require('./_add-to-unscopables'); var step = require('./_iter-step'); @@ -8601,7 +8506,7 @@ addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"./_add-to-unscopables":74,"./_iter-define":124,"./_iter-step":126,"./_iterators":127,"./_to-iobject":179}],204:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_iter-define":118,"./_iter-step":120,"./_iterators":121,"./_to-iobject":173}],198:[function(require,module,exports){ 'use strict'; // 22.1.3.13 Array.prototype.join(separator) var $export = require('./_export'); @@ -8615,7 +8520,7 @@ $export($export.P + $export.F * (require('./_iobject') != Object || !require('./ } }); -},{"./_export":101,"./_iobject":116,"./_strict-method":167,"./_to-iobject":179}],205:[function(require,module,exports){ +},{"./_export":95,"./_iobject":110,"./_strict-method":161,"./_to-iobject":173}],199:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toIObject = require('./_to-iobject'); @@ -8639,7 +8544,7 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_export":101,"./_strict-method":167,"./_to-integer":178,"./_to-iobject":179,"./_to-length":180}],206:[function(require,module,exports){ +},{"./_export":95,"./_strict-method":161,"./_to-integer":172,"./_to-iobject":173,"./_to-length":174}],200:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $map = require('./_array-methods')(1); @@ -8651,7 +8556,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Arr } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],207:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],201:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var createProperty = require('./_create-property'); @@ -8672,7 +8577,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_create-property":92,"./_export":101,"./_fails":103}],208:[function(require,module,exports){ +},{"./_create-property":86,"./_export":95,"./_fails":97}],202:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -8684,7 +8589,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduceRight, tru } }); -},{"./_array-reduce":82,"./_export":101,"./_strict-method":167}],209:[function(require,module,exports){ +},{"./_array-reduce":76,"./_export":95,"./_strict-method":161}],203:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -8696,7 +8601,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduce, true), ' } }); -},{"./_array-reduce":82,"./_export":101,"./_strict-method":167}],210:[function(require,module,exports){ +},{"./_array-reduce":76,"./_export":95,"./_strict-method":161}],204:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var html = require('./_html'); @@ -8726,7 +8631,7 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_cof":87,"./_export":101,"./_fails":103,"./_html":112,"./_to-absolute-index":176,"./_to-length":180}],211:[function(require,module,exports){ +},{"./_cof":81,"./_export":95,"./_fails":97,"./_html":106,"./_to-absolute-index":170,"./_to-length":174}],205:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $some = require('./_array-methods')(3); @@ -8738,7 +8643,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Ar } }); -},{"./_array-methods":81,"./_export":101,"./_strict-method":167}],212:[function(require,module,exports){ +},{"./_array-methods":75,"./_export":95,"./_strict-method":161}],206:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -8763,16 +8668,16 @@ $export($export.P + $export.F * (fails(function () { } }); -},{"./_a-function":72,"./_export":101,"./_fails":103,"./_strict-method":167,"./_to-object":181}],213:[function(require,module,exports){ +},{"./_a-function":66,"./_export":95,"./_fails":97,"./_strict-method":161,"./_to-object":175}],207:[function(require,module,exports){ require('./_set-species')('Array'); -},{"./_set-species":162}],214:[function(require,module,exports){ +},{"./_set-species":156}],208:[function(require,module,exports){ // 20.3.3.1 / 15.9.4.4 Date.now() var $export = require('./_export'); $export($export.S, 'Date', { now: function () { return new Date().getTime(); } }); -},{"./_export":101}],215:[function(require,module,exports){ +},{"./_export":95}],209:[function(require,module,exports){ // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var $export = require('./_export'); var toISOString = require('./_date-to-iso-string'); @@ -8782,7 +8687,7 @@ $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'D toISOString: toISOString }); -},{"./_date-to-iso-string":94,"./_export":101}],216:[function(require,module,exports){ +},{"./_date-to-iso-string":88,"./_export":95}],210:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toObject = require('./_to-object'); @@ -8800,13 +8705,13 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103,"./_to-object":181,"./_to-primitive":182}],217:[function(require,module,exports){ +},{"./_export":95,"./_fails":97,"./_to-object":175,"./_to-primitive":176}],211:[function(require,module,exports){ var TO_PRIMITIVE = require('./_wks')('toPrimitive'); var proto = Date.prototype; if (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive')); -},{"./_date-to-primitive":95,"./_hide":111,"./_wks":191}],218:[function(require,module,exports){ +},{"./_date-to-primitive":89,"./_hide":105,"./_wks":185}],212:[function(require,module,exports){ var DateProto = Date.prototype; var INVALID_DATE = 'Invalid Date'; var TO_STRING = 'toString'; @@ -8820,13 +8725,13 @@ if (new Date(NaN) + '' != INVALID_DATE) { }); } -},{"./_redefine":157}],219:[function(require,module,exports){ +},{"./_redefine":151}],213:[function(require,module,exports){ // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) var $export = require('./_export'); $export($export.P, 'Function', { bind: require('./_bind') }); -},{"./_bind":85,"./_export":101}],220:[function(require,module,exports){ +},{"./_bind":79,"./_export":95}],214:[function(require,module,exports){ 'use strict'; var isObject = require('./_is-object'); var getPrototypeOf = require('./_object-gpo'); @@ -8841,7 +8746,7 @@ if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, H return false; } }); -},{"./_is-object":120,"./_object-dp":138,"./_object-gpo":144,"./_wks":191}],221:[function(require,module,exports){ +},{"./_is-object":114,"./_object-dp":132,"./_object-gpo":138,"./_wks":185}],215:[function(require,module,exports){ var dP = require('./_object-dp').f; var FProto = Function.prototype; var nameRE = /^\s*function ([^ (]*)/; @@ -8859,7 +8764,7 @@ NAME in FProto || require('./_descriptors') && dP(FProto, NAME, { } }); -},{"./_descriptors":97,"./_object-dp":138}],222:[function(require,module,exports){ +},{"./_descriptors":91,"./_object-dp":132}],216:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -8880,7 +8785,7 @@ module.exports = require('./_collection')(MAP, function (get) { } }, strong, true); -},{"./_collection":90,"./_collection-strong":88,"./_validate-collection":188}],223:[function(require,module,exports){ +},{"./_collection":84,"./_collection-strong":82,"./_validate-collection":182}],217:[function(require,module,exports){ // 20.2.2.3 Math.acosh(x) var $export = require('./_export'); var log1p = require('./_math-log1p'); @@ -8900,7 +8805,7 @@ $export($export.S + $export.F * !($acosh } }); -},{"./_export":101,"./_math-log1p":131}],224:[function(require,module,exports){ +},{"./_export":95,"./_math-log1p":125}],218:[function(require,module,exports){ // 20.2.2.5 Math.asinh(x) var $export = require('./_export'); var $asinh = Math.asinh; @@ -8912,7 +8817,7 @@ function asinh(x) { // Tor Browser bug: Math.asinh(0) -> -0 $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh }); -},{"./_export":101}],225:[function(require,module,exports){ +},{"./_export":95}],219:[function(require,module,exports){ // 20.2.2.7 Math.atanh(x) var $export = require('./_export'); var $atanh = Math.atanh; @@ -8924,7 +8829,7 @@ $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { } }); -},{"./_export":101}],226:[function(require,module,exports){ +},{"./_export":95}],220:[function(require,module,exports){ // 20.2.2.9 Math.cbrt(x) var $export = require('./_export'); var sign = require('./_math-sign'); @@ -8935,7 +8840,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101,"./_math-sign":132}],227:[function(require,module,exports){ +},{"./_export":95,"./_math-sign":126}],221:[function(require,module,exports){ // 20.2.2.11 Math.clz32(x) var $export = require('./_export'); @@ -8945,7 +8850,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],228:[function(require,module,exports){ +},{"./_export":95}],222:[function(require,module,exports){ // 20.2.2.12 Math.cosh(x) var $export = require('./_export'); var exp = Math.exp; @@ -8956,20 +8861,20 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],229:[function(require,module,exports){ +},{"./_export":95}],223:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $export = require('./_export'); var $expm1 = require('./_math-expm1'); $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 }); -},{"./_export":101,"./_math-expm1":129}],230:[function(require,module,exports){ +},{"./_export":95,"./_math-expm1":123}],224:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var $export = require('./_export'); $export($export.S, 'Math', { fround: require('./_math-fround') }); -},{"./_export":101,"./_math-fround":130}],231:[function(require,module,exports){ +},{"./_export":95,"./_math-fround":124}],225:[function(require,module,exports){ // 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) var $export = require('./_export'); var abs = Math.abs; @@ -8996,7 +8901,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],232:[function(require,module,exports){ +},{"./_export":95}],226:[function(require,module,exports){ // 20.2.2.18 Math.imul(x, y) var $export = require('./_export'); var $imul = Math.imul; @@ -9015,7 +8920,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103}],233:[function(require,module,exports){ +},{"./_export":95,"./_fails":97}],227:[function(require,module,exports){ // 20.2.2.21 Math.log10(x) var $export = require('./_export'); @@ -9025,13 +8930,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],234:[function(require,module,exports){ +},{"./_export":95}],228:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) var $export = require('./_export'); $export($export.S, 'Math', { log1p: require('./_math-log1p') }); -},{"./_export":101,"./_math-log1p":131}],235:[function(require,module,exports){ +},{"./_export":95,"./_math-log1p":125}],229:[function(require,module,exports){ // 20.2.2.22 Math.log2(x) var $export = require('./_export'); @@ -9041,13 +8946,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],236:[function(require,module,exports){ +},{"./_export":95}],230:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) var $export = require('./_export'); $export($export.S, 'Math', { sign: require('./_math-sign') }); -},{"./_export":101,"./_math-sign":132}],237:[function(require,module,exports){ +},{"./_export":95,"./_math-sign":126}],231:[function(require,module,exports){ // 20.2.2.30 Math.sinh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9064,7 +8969,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":101,"./_fails":103,"./_math-expm1":129}],238:[function(require,module,exports){ +},{"./_export":95,"./_fails":97,"./_math-expm1":123}],232:[function(require,module,exports){ // 20.2.2.33 Math.tanh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9078,7 +8983,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101,"./_math-expm1":129}],239:[function(require,module,exports){ +},{"./_export":95,"./_math-expm1":123}],233:[function(require,module,exports){ // 20.2.2.34 Math.trunc(x) var $export = require('./_export'); @@ -9088,7 +8993,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":101}],240:[function(require,module,exports){ +},{"./_export":95}],234:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var has = require('./_has'); @@ -9159,13 +9064,13 @@ if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { require('./_redefine')(global, NUMBER, $Number); } -},{"./_cof":87,"./_descriptors":97,"./_fails":103,"./_global":109,"./_has":110,"./_inherit-if-required":114,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_redefine":157,"./_string-trim":173,"./_to-primitive":182}],241:[function(require,module,exports){ +},{"./_cof":81,"./_descriptors":91,"./_fails":97,"./_global":103,"./_has":104,"./_inherit-if-required":108,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_redefine":151,"./_string-trim":167,"./_to-primitive":176}],235:[function(require,module,exports){ // 20.1.2.1 Number.EPSILON var $export = require('./_export'); $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); -},{"./_export":101}],242:[function(require,module,exports){ +},{"./_export":95}],236:[function(require,module,exports){ // 20.1.2.2 Number.isFinite(number) var $export = require('./_export'); var _isFinite = require('./_global').isFinite; @@ -9176,13 +9081,13 @@ $export($export.S, 'Number', { } }); -},{"./_export":101,"./_global":109}],243:[function(require,module,exports){ +},{"./_export":95,"./_global":103}],237:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var $export = require('./_export'); $export($export.S, 'Number', { isInteger: require('./_is-integer') }); -},{"./_export":101,"./_is-integer":119}],244:[function(require,module,exports){ +},{"./_export":95,"./_is-integer":113}],238:[function(require,module,exports){ // 20.1.2.4 Number.isNaN(number) var $export = require('./_export'); @@ -9193,7 +9098,7 @@ $export($export.S, 'Number', { } }); -},{"./_export":101}],245:[function(require,module,exports){ +},{"./_export":95}],239:[function(require,module,exports){ // 20.1.2.5 Number.isSafeInteger(number) var $export = require('./_export'); var isInteger = require('./_is-integer'); @@ -9205,31 +9110,31 @@ $export($export.S, 'Number', { } }); -},{"./_export":101,"./_is-integer":119}],246:[function(require,module,exports){ +},{"./_export":95,"./_is-integer":113}],240:[function(require,module,exports){ // 20.1.2.6 Number.MAX_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); -},{"./_export":101}],247:[function(require,module,exports){ +},{"./_export":95}],241:[function(require,module,exports){ // 20.1.2.10 Number.MIN_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); -},{"./_export":101}],248:[function(require,module,exports){ +},{"./_export":95}],242:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 20.1.2.12 Number.parseFloat(string) $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat }); -},{"./_export":101,"./_parse-float":151}],249:[function(require,module,exports){ +},{"./_export":95,"./_parse-float":145}],243:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 20.1.2.13 Number.parseInt(string, radix) $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt }); -},{"./_export":101,"./_parse-int":152}],250:[function(require,module,exports){ +},{"./_export":95,"./_parse-int":146}],244:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toInteger = require('./_to-integer'); @@ -9345,7 +9250,7 @@ $export($export.P + $export.F * (!!$toFixed && ( } }); -},{"./_a-number-value":73,"./_export":101,"./_fails":103,"./_string-repeat":172,"./_to-integer":178}],251:[function(require,module,exports){ +},{"./_a-number-value":67,"./_export":95,"./_fails":97,"./_string-repeat":166,"./_to-integer":172}],245:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $fails = require('./_fails'); @@ -9365,28 +9270,28 @@ $export($export.P + $export.F * ($fails(function () { } }); -},{"./_a-number-value":73,"./_export":101,"./_fails":103}],252:[function(require,module,exports){ +},{"./_a-number-value":67,"./_export":95,"./_fails":97}],246:[function(require,module,exports){ // 19.1.3.1 Object.assign(target, source) var $export = require('./_export'); $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') }); -},{"./_export":101,"./_object-assign":136}],253:[function(require,module,exports){ +},{"./_export":95,"./_object-assign":130}],247:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) $export($export.S, 'Object', { create: require('./_object-create') }); -},{"./_export":101,"./_object-create":137}],254:[function(require,module,exports){ +},{"./_export":95,"./_object-create":131}],248:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') }); -},{"./_descriptors":97,"./_export":101,"./_object-dps":139}],255:[function(require,module,exports){ +},{"./_descriptors":91,"./_export":95,"./_object-dps":133}],249:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f }); -},{"./_descriptors":97,"./_export":101,"./_object-dp":138}],256:[function(require,module,exports){ +},{"./_descriptors":91,"./_export":95,"./_object-dp":132}],250:[function(require,module,exports){ // 19.1.2.5 Object.freeze(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9397,7 +9302,7 @@ require('./_object-sap')('freeze', function ($freeze) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],257:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],251:[function(require,module,exports){ // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) var toIObject = require('./_to-iobject'); var $getOwnPropertyDescriptor = require('./_object-gopd').f; @@ -9408,13 +9313,13 @@ require('./_object-sap')('getOwnPropertyDescriptor', function () { }; }); -},{"./_object-gopd":140,"./_object-sap":148,"./_to-iobject":179}],258:[function(require,module,exports){ +},{"./_object-gopd":134,"./_object-sap":142,"./_to-iobject":173}],252:[function(require,module,exports){ // 19.1.2.7 Object.getOwnPropertyNames(O) require('./_object-sap')('getOwnPropertyNames', function () { return require('./_object-gopn-ext').f; }); -},{"./_object-gopn-ext":141,"./_object-sap":148}],259:[function(require,module,exports){ +},{"./_object-gopn-ext":135,"./_object-sap":142}],253:[function(require,module,exports){ // 19.1.2.9 Object.getPrototypeOf(O) var toObject = require('./_to-object'); var $getPrototypeOf = require('./_object-gpo'); @@ -9425,7 +9330,7 @@ require('./_object-sap')('getPrototypeOf', function () { }; }); -},{"./_object-gpo":144,"./_object-sap":148,"./_to-object":181}],260:[function(require,module,exports){ +},{"./_object-gpo":138,"./_object-sap":142,"./_to-object":175}],254:[function(require,module,exports){ // 19.1.2.11 Object.isExtensible(O) var isObject = require('./_is-object'); @@ -9435,7 +9340,7 @@ require('./_object-sap')('isExtensible', function ($isExtensible) { }; }); -},{"./_is-object":120,"./_object-sap":148}],261:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],255:[function(require,module,exports){ // 19.1.2.12 Object.isFrozen(O) var isObject = require('./_is-object'); @@ -9445,7 +9350,7 @@ require('./_object-sap')('isFrozen', function ($isFrozen) { }; }); -},{"./_is-object":120,"./_object-sap":148}],262:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],256:[function(require,module,exports){ // 19.1.2.13 Object.isSealed(O) var isObject = require('./_is-object'); @@ -9455,12 +9360,12 @@ require('./_object-sap')('isSealed', function ($isSealed) { }; }); -},{"./_is-object":120,"./_object-sap":148}],263:[function(require,module,exports){ +},{"./_is-object":114,"./_object-sap":142}],257:[function(require,module,exports){ // 19.1.3.10 Object.is(value1, value2) var $export = require('./_export'); $export($export.S, 'Object', { is: require('./_same-value') }); -},{"./_export":101,"./_same-value":160}],264:[function(require,module,exports){ +},{"./_export":95,"./_same-value":154}],258:[function(require,module,exports){ // 19.1.2.14 Object.keys(O) var toObject = require('./_to-object'); var $keys = require('./_object-keys'); @@ -9471,7 +9376,7 @@ require('./_object-sap')('keys', function () { }; }); -},{"./_object-keys":146,"./_object-sap":148,"./_to-object":181}],265:[function(require,module,exports){ +},{"./_object-keys":140,"./_object-sap":142,"./_to-object":175}],259:[function(require,module,exports){ // 19.1.2.15 Object.preventExtensions(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9482,7 +9387,7 @@ require('./_object-sap')('preventExtensions', function ($preventExtensions) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],266:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],260:[function(require,module,exports){ // 19.1.2.17 Object.seal(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -9493,12 +9398,12 @@ require('./_object-sap')('seal', function ($seal) { }; }); -},{"./_is-object":120,"./_meta":133,"./_object-sap":148}],267:[function(require,module,exports){ +},{"./_is-object":114,"./_meta":127,"./_object-sap":142}],261:[function(require,module,exports){ // 19.1.3.19 Object.setPrototypeOf(O, proto) var $export = require('./_export'); $export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set }); -},{"./_export":101,"./_set-proto":161}],268:[function(require,module,exports){ +},{"./_export":95,"./_set-proto":155}],262:[function(require,module,exports){ 'use strict'; // 19.1.3.6 Object.prototype.toString() var classof = require('./_classof'); @@ -9510,19 +9415,19 @@ if (test + '' != '[object z]') { }, true); } -},{"./_classof":86,"./_redefine":157,"./_wks":191}],269:[function(require,module,exports){ +},{"./_classof":80,"./_redefine":151,"./_wks":185}],263:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 18.2.4 parseFloat(string) $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat }); -},{"./_export":101,"./_parse-float":151}],270:[function(require,module,exports){ +},{"./_export":95,"./_parse-float":145}],264:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 18.2.5 parseInt(string, radix) $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt }); -},{"./_export":101,"./_parse-int":152}],271:[function(require,module,exports){ +},{"./_export":95,"./_parse-int":146}],265:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var global = require('./_global'); @@ -9810,7 +9715,7 @@ $export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(functi } }); -},{"./_a-function":72,"./_an-instance":76,"./_classof":86,"./_core":91,"./_ctx":93,"./_export":101,"./_for-of":107,"./_global":109,"./_is-object":120,"./_iter-detect":125,"./_library":128,"./_microtask":134,"./_new-promise-capability":135,"./_perform":153,"./_promise-resolve":154,"./_redefine-all":156,"./_set-species":162,"./_set-to-string-tag":163,"./_species-constructor":166,"./_task":175,"./_user-agent":187,"./_wks":191}],272:[function(require,module,exports){ +},{"./_a-function":66,"./_an-instance":70,"./_classof":80,"./_core":85,"./_ctx":87,"./_export":95,"./_for-of":101,"./_global":103,"./_is-object":114,"./_iter-detect":119,"./_library":122,"./_microtask":128,"./_new-promise-capability":129,"./_perform":147,"./_promise-resolve":148,"./_redefine-all":150,"./_set-species":156,"./_set-to-string-tag":157,"./_species-constructor":160,"./_task":169,"./_user-agent":181,"./_wks":185}],266:[function(require,module,exports){ // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -9828,7 +9733,7 @@ $export($export.S + $export.F * !require('./_fails')(function () { } }); -},{"./_a-function":72,"./_an-object":77,"./_export":101,"./_fails":103,"./_global":109}],273:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_export":95,"./_fails":97,"./_global":103}],267:[function(require,module,exports){ // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) var $export = require('./_export'); var create = require('./_object-create'); @@ -9877,7 +9782,7 @@ $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { } }); -},{"./_a-function":72,"./_an-object":77,"./_bind":85,"./_export":101,"./_fails":103,"./_global":109,"./_is-object":120,"./_object-create":137}],274:[function(require,module,exports){ +},{"./_a-function":66,"./_an-object":71,"./_bind":79,"./_export":95,"./_fails":97,"./_global":103,"./_is-object":114,"./_object-create":131}],268:[function(require,module,exports){ // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) var dP = require('./_object-dp'); var $export = require('./_export'); @@ -9902,7 +9807,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_an-object":77,"./_export":101,"./_fails":103,"./_object-dp":138,"./_to-primitive":182}],275:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_fails":97,"./_object-dp":132,"./_to-primitive":176}],269:[function(require,module,exports){ // 26.1.4 Reflect.deleteProperty(target, propertyKey) var $export = require('./_export'); var gOPD = require('./_object-gopd').f; @@ -9915,7 +9820,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gopd":140}],276:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gopd":134}],270:[function(require,module,exports){ 'use strict'; // 26.1.5 Reflect.enumerate(target) var $export = require('./_export'); @@ -9943,7 +9848,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_iter-create":123}],277:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_iter-create":117}],271:[function(require,module,exports){ // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) var gOPD = require('./_object-gopd'); var $export = require('./_export'); @@ -9955,7 +9860,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gopd":140}],278:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gopd":134}],272:[function(require,module,exports){ // 26.1.8 Reflect.getPrototypeOf(target) var $export = require('./_export'); var getProto = require('./_object-gpo'); @@ -9967,7 +9872,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101,"./_object-gpo":144}],279:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_object-gpo":138}],273:[function(require,module,exports){ // 26.1.6 Reflect.get(target, propertyKey [, receiver]) var gOPD = require('./_object-gopd'); var getPrototypeOf = require('./_object-gpo'); @@ -9990,7 +9895,7 @@ function get(target, propertyKey /* , receiver */) { $export($export.S, 'Reflect', { get: get }); -},{"./_an-object":77,"./_export":101,"./_has":110,"./_is-object":120,"./_object-gopd":140,"./_object-gpo":144}],280:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_has":104,"./_is-object":114,"./_object-gopd":134,"./_object-gpo":138}],274:[function(require,module,exports){ // 26.1.9 Reflect.has(target, propertyKey) var $export = require('./_export'); @@ -10000,7 +9905,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_export":101}],281:[function(require,module,exports){ +},{"./_export":95}],275:[function(require,module,exports){ // 26.1.10 Reflect.isExtensible(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10013,13 +9918,13 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101}],282:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95}],276:[function(require,module,exports){ // 26.1.11 Reflect.ownKeys(target) var $export = require('./_export'); $export($export.S, 'Reflect', { ownKeys: require('./_own-keys') }); -},{"./_export":101,"./_own-keys":150}],283:[function(require,module,exports){ +},{"./_export":95,"./_own-keys":144}],277:[function(require,module,exports){ // 26.1.12 Reflect.preventExtensions(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10037,7 +9942,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":77,"./_export":101}],284:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95}],278:[function(require,module,exports){ // 26.1.14 Reflect.setPrototypeOf(target, proto) var $export = require('./_export'); var setProto = require('./_set-proto'); @@ -10054,7 +9959,7 @@ if (setProto) $export($export.S, 'Reflect', { } }); -},{"./_export":101,"./_set-proto":161}],285:[function(require,module,exports){ +},{"./_export":95,"./_set-proto":155}],279:[function(require,module,exports){ // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) var dP = require('./_object-dp'); var gOPD = require('./_object-gopd'); @@ -10089,7 +9994,7 @@ function set(target, propertyKey, V /* , receiver */) { $export($export.S, 'Reflect', { set: set }); -},{"./_an-object":77,"./_export":101,"./_has":110,"./_is-object":120,"./_object-dp":138,"./_object-gopd":140,"./_object-gpo":144,"./_property-desc":155}],286:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_has":104,"./_is-object":114,"./_object-dp":132,"./_object-gopd":134,"./_object-gpo":138,"./_property-desc":149}],280:[function(require,module,exports){ var global = require('./_global'); var inheritIfRequired = require('./_inherit-if-required'); var dP = require('./_object-dp').f; @@ -10134,7 +10039,7 @@ if (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function ( require('./_set-species')('RegExp'); -},{"./_descriptors":97,"./_fails":103,"./_flags":105,"./_global":109,"./_inherit-if-required":114,"./_is-regexp":121,"./_object-dp":138,"./_object-gopn":142,"./_redefine":157,"./_set-species":162,"./_wks":191}],287:[function(require,module,exports){ +},{"./_descriptors":91,"./_fails":97,"./_flags":99,"./_global":103,"./_inherit-if-required":108,"./_is-regexp":115,"./_object-dp":132,"./_object-gopn":136,"./_redefine":151,"./_set-species":156,"./_wks":185}],281:[function(require,module,exports){ 'use strict'; var regexpExec = require('./_regexp-exec'); require('./_export')({ @@ -10145,14 +10050,14 @@ require('./_export')({ exec: regexpExec }); -},{"./_export":101,"./_regexp-exec":159}],288:[function(require,module,exports){ +},{"./_export":95,"./_regexp-exec":153}],282:[function(require,module,exports){ // 21.2.5.3 get RegExp.prototype.flags() if (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', { configurable: true, get: require('./_flags') }); -},{"./_descriptors":97,"./_flags":105,"./_object-dp":138}],289:[function(require,module,exports){ +},{"./_descriptors":91,"./_flags":99,"./_object-dp":132}],283:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10194,7 +10099,7 @@ require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCall ]; }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_to-length":180}],290:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_to-length":174}],284:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10314,7 +10219,7 @@ require('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, may } }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_to-integer":178,"./_to-length":180,"./_to-object":181}],291:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_to-integer":172,"./_to-length":174,"./_to-object":175}],285:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -10347,7 +10252,7 @@ require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeC ]; }); -},{"./_an-object":77,"./_fix-re-wks":104,"./_regexp-exec-abstract":158,"./_same-value":160}],292:[function(require,module,exports){ +},{"./_an-object":71,"./_fix-re-wks":98,"./_regexp-exec-abstract":152,"./_same-value":154}],286:[function(require,module,exports){ 'use strict'; var isRegExp = require('./_is-regexp'); @@ -10483,7 +10388,7 @@ require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCall ]; }); -},{"./_advance-string-index":75,"./_an-object":77,"./_fails":103,"./_fix-re-wks":104,"./_is-regexp":121,"./_regexp-exec":159,"./_regexp-exec-abstract":158,"./_species-constructor":166,"./_to-length":180}],293:[function(require,module,exports){ +},{"./_advance-string-index":69,"./_an-object":71,"./_fails":97,"./_fix-re-wks":98,"./_is-regexp":115,"./_regexp-exec":153,"./_regexp-exec-abstract":152,"./_species-constructor":160,"./_to-length":174}],287:[function(require,module,exports){ 'use strict'; require('./es6.regexp.flags'); var anObject = require('./_an-object'); @@ -10510,7 +10415,7 @@ if (require('./_fails')(function () { return $toString.call({ source: 'a', flags }); } -},{"./_an-object":77,"./_descriptors":97,"./_fails":103,"./_flags":105,"./_redefine":157,"./es6.regexp.flags":288}],294:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_fails":97,"./_flags":99,"./_redefine":151,"./es6.regexp.flags":282}],288:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -10526,7 +10431,7 @@ module.exports = require('./_collection')(SET, function (get) { } }, strong); -},{"./_collection":90,"./_collection-strong":88,"./_validate-collection":188}],295:[function(require,module,exports){ +},{"./_collection":84,"./_collection-strong":82,"./_validate-collection":182}],289:[function(require,module,exports){ 'use strict'; // B.2.3.2 String.prototype.anchor(name) require('./_string-html')('anchor', function (createHTML) { @@ -10535,7 +10440,7 @@ require('./_string-html')('anchor', function (createHTML) { }; }); -},{"./_string-html":170}],296:[function(require,module,exports){ +},{"./_string-html":164}],290:[function(require,module,exports){ 'use strict'; // B.2.3.3 String.prototype.big() require('./_string-html')('big', function (createHTML) { @@ -10544,7 +10449,7 @@ require('./_string-html')('big', function (createHTML) { }; }); -},{"./_string-html":170}],297:[function(require,module,exports){ +},{"./_string-html":164}],291:[function(require,module,exports){ 'use strict'; // B.2.3.4 String.prototype.blink() require('./_string-html')('blink', function (createHTML) { @@ -10553,7 +10458,7 @@ require('./_string-html')('blink', function (createHTML) { }; }); -},{"./_string-html":170}],298:[function(require,module,exports){ +},{"./_string-html":164}],292:[function(require,module,exports){ 'use strict'; // B.2.3.5 String.prototype.bold() require('./_string-html')('bold', function (createHTML) { @@ -10562,7 +10467,7 @@ require('./_string-html')('bold', function (createHTML) { }; }); -},{"./_string-html":170}],299:[function(require,module,exports){ +},{"./_string-html":164}],293:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $at = require('./_string-at')(false); @@ -10573,7 +10478,7 @@ $export($export.P, 'String', { } }); -},{"./_export":101,"./_string-at":168}],300:[function(require,module,exports){ +},{"./_export":95,"./_string-at":162}],294:[function(require,module,exports){ // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) 'use strict'; var $export = require('./_export'); @@ -10595,7 +10500,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'Strin } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169,"./_to-length":180}],301:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163,"./_to-length":174}],295:[function(require,module,exports){ 'use strict'; // B.2.3.6 String.prototype.fixed() require('./_string-html')('fixed', function (createHTML) { @@ -10604,7 +10509,7 @@ require('./_string-html')('fixed', function (createHTML) { }; }); -},{"./_string-html":170}],302:[function(require,module,exports){ +},{"./_string-html":164}],296:[function(require,module,exports){ 'use strict'; // B.2.3.7 String.prototype.fontcolor(color) require('./_string-html')('fontcolor', function (createHTML) { @@ -10613,7 +10518,7 @@ require('./_string-html')('fontcolor', function (createHTML) { }; }); -},{"./_string-html":170}],303:[function(require,module,exports){ +},{"./_string-html":164}],297:[function(require,module,exports){ 'use strict'; // B.2.3.8 String.prototype.fontsize(size) require('./_string-html')('fontsize', function (createHTML) { @@ -10622,7 +10527,7 @@ require('./_string-html')('fontsize', function (createHTML) { }; }); -},{"./_string-html":170}],304:[function(require,module,exports){ +},{"./_string-html":164}],298:[function(require,module,exports){ var $export = require('./_export'); var toAbsoluteIndex = require('./_to-absolute-index'); var fromCharCode = String.fromCharCode; @@ -10647,7 +10552,7 @@ $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1) } }); -},{"./_export":101,"./_to-absolute-index":176}],305:[function(require,module,exports){ +},{"./_export":95,"./_to-absolute-index":170}],299:[function(require,module,exports){ // 21.1.3.7 String.prototype.includes(searchString, position = 0) 'use strict'; var $export = require('./_export'); @@ -10661,7 +10566,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169}],306:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163}],300:[function(require,module,exports){ 'use strict'; // B.2.3.9 String.prototype.italics() require('./_string-html')('italics', function (createHTML) { @@ -10670,7 +10575,7 @@ require('./_string-html')('italics', function (createHTML) { }; }); -},{"./_string-html":170}],307:[function(require,module,exports){ +},{"./_string-html":164}],301:[function(require,module,exports){ 'use strict'; var $at = require('./_string-at')(true); @@ -10689,7 +10594,7 @@ require('./_iter-define')(String, 'String', function (iterated) { return { value: point, done: false }; }); -},{"./_iter-define":124,"./_string-at":168}],308:[function(require,module,exports){ +},{"./_iter-define":118,"./_string-at":162}],302:[function(require,module,exports){ 'use strict'; // B.2.3.10 String.prototype.link(url) require('./_string-html')('link', function (createHTML) { @@ -10698,7 +10603,7 @@ require('./_string-html')('link', function (createHTML) { }; }); -},{"./_string-html":170}],309:[function(require,module,exports){ +},{"./_string-html":164}],303:[function(require,module,exports){ var $export = require('./_export'); var toIObject = require('./_to-iobject'); var toLength = require('./_to-length'); @@ -10718,7 +10623,7 @@ $export($export.S, 'String', { } }); -},{"./_export":101,"./_to-iobject":179,"./_to-length":180}],310:[function(require,module,exports){ +},{"./_export":95,"./_to-iobject":173,"./_to-length":174}],304:[function(require,module,exports){ var $export = require('./_export'); $export($export.P, 'String', { @@ -10726,7 +10631,7 @@ $export($export.P, 'String', { repeat: require('./_string-repeat') }); -},{"./_export":101,"./_string-repeat":172}],311:[function(require,module,exports){ +},{"./_export":95,"./_string-repeat":166}],305:[function(require,module,exports){ 'use strict'; // B.2.3.11 String.prototype.small() require('./_string-html')('small', function (createHTML) { @@ -10735,7 +10640,7 @@ require('./_string-html')('small', function (createHTML) { }; }); -},{"./_string-html":170}],312:[function(require,module,exports){ +},{"./_string-html":164}],306:[function(require,module,exports){ // 21.1.3.18 String.prototype.startsWith(searchString [, position ]) 'use strict'; var $export = require('./_export'); @@ -10755,7 +10660,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'Str } }); -},{"./_export":101,"./_fails-is-regexp":102,"./_string-context":169,"./_to-length":180}],313:[function(require,module,exports){ +},{"./_export":95,"./_fails-is-regexp":96,"./_string-context":163,"./_to-length":174}],307:[function(require,module,exports){ 'use strict'; // B.2.3.12 String.prototype.strike() require('./_string-html')('strike', function (createHTML) { @@ -10764,7 +10669,7 @@ require('./_string-html')('strike', function (createHTML) { }; }); -},{"./_string-html":170}],314:[function(require,module,exports){ +},{"./_string-html":164}],308:[function(require,module,exports){ 'use strict'; // B.2.3.13 String.prototype.sub() require('./_string-html')('sub', function (createHTML) { @@ -10773,7 +10678,7 @@ require('./_string-html')('sub', function (createHTML) { }; }); -},{"./_string-html":170}],315:[function(require,module,exports){ +},{"./_string-html":164}],309:[function(require,module,exports){ 'use strict'; // B.2.3.14 String.prototype.sup() require('./_string-html')('sup', function (createHTML) { @@ -10782,7 +10687,7 @@ require('./_string-html')('sup', function (createHTML) { }; }); -},{"./_string-html":170}],316:[function(require,module,exports){ +},{"./_string-html":164}],310:[function(require,module,exports){ 'use strict'; // 21.1.3.25 String.prototype.trim() require('./_string-trim')('trim', function ($trim) { @@ -10791,7 +10696,7 @@ require('./_string-trim')('trim', function ($trim) { }; }); -},{"./_string-trim":173}],317:[function(require,module,exports){ +},{"./_string-trim":167}],311:[function(require,module,exports){ 'use strict'; // ECMAScript 6 symbols shim var global = require('./_global'); @@ -11039,7 +10944,7 @@ setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] setToStringTag(global.JSON, 'JSON', true); -},{"./_an-object":77,"./_descriptors":97,"./_enum-keys":100,"./_export":101,"./_fails":103,"./_global":109,"./_has":110,"./_hide":111,"./_is-array":118,"./_is-object":120,"./_library":128,"./_meta":133,"./_object-create":137,"./_object-dp":138,"./_object-gopd":140,"./_object-gopn":142,"./_object-gopn-ext":141,"./_object-gops":143,"./_object-keys":146,"./_object-pie":147,"./_property-desc":155,"./_redefine":157,"./_set-to-string-tag":163,"./_shared":165,"./_to-iobject":179,"./_to-object":181,"./_to-primitive":182,"./_uid":186,"./_wks":191,"./_wks-define":189,"./_wks-ext":190}],318:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":91,"./_enum-keys":94,"./_export":95,"./_fails":97,"./_global":103,"./_has":104,"./_hide":105,"./_is-array":112,"./_is-object":114,"./_library":122,"./_meta":127,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_object-gopn-ext":135,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_property-desc":149,"./_redefine":151,"./_set-to-string-tag":157,"./_shared":159,"./_to-iobject":173,"./_to-object":175,"./_to-primitive":176,"./_uid":180,"./_wks":185,"./_wks-define":183,"./_wks-ext":184}],312:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $typed = require('./_typed'); @@ -11087,76 +10992,76 @@ $export($export.P + $export.U + $export.F * require('./_fails')(function () { require('./_set-species')(ARRAY_BUFFER); -},{"./_an-object":77,"./_export":101,"./_fails":103,"./_global":109,"./_is-object":120,"./_set-species":162,"./_species-constructor":166,"./_to-absolute-index":176,"./_to-length":180,"./_typed":185,"./_typed-buffer":184}],319:[function(require,module,exports){ +},{"./_an-object":71,"./_export":95,"./_fails":97,"./_global":103,"./_is-object":114,"./_set-species":156,"./_species-constructor":160,"./_to-absolute-index":170,"./_to-length":174,"./_typed":179,"./_typed-buffer":178}],313:[function(require,module,exports){ var $export = require('./_export'); $export($export.G + $export.W + $export.F * !require('./_typed').ABV, { DataView: require('./_typed-buffer').DataView }); -},{"./_export":101,"./_typed":185,"./_typed-buffer":184}],320:[function(require,module,exports){ +},{"./_export":95,"./_typed":179,"./_typed-buffer":178}],314:[function(require,module,exports){ require('./_typed-array')('Float32', 4, function (init) { return function Float32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],321:[function(require,module,exports){ +},{"./_typed-array":177}],315:[function(require,module,exports){ require('./_typed-array')('Float64', 8, function (init) { return function Float64Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],322:[function(require,module,exports){ +},{"./_typed-array":177}],316:[function(require,module,exports){ require('./_typed-array')('Int16', 2, function (init) { return function Int16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],323:[function(require,module,exports){ +},{"./_typed-array":177}],317:[function(require,module,exports){ require('./_typed-array')('Int32', 4, function (init) { return function Int32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],324:[function(require,module,exports){ +},{"./_typed-array":177}],318:[function(require,module,exports){ require('./_typed-array')('Int8', 1, function (init) { return function Int8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],325:[function(require,module,exports){ +},{"./_typed-array":177}],319:[function(require,module,exports){ require('./_typed-array')('Uint16', 2, function (init) { return function Uint16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],326:[function(require,module,exports){ +},{"./_typed-array":177}],320:[function(require,module,exports){ require('./_typed-array')('Uint32', 4, function (init) { return function Uint32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],327:[function(require,module,exports){ +},{"./_typed-array":177}],321:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":183}],328:[function(require,module,exports){ +},{"./_typed-array":177}],322:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8ClampedArray(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }, true); -},{"./_typed-array":183}],329:[function(require,module,exports){ +},{"./_typed-array":177}],323:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var each = require('./_array-methods')(0); @@ -11218,7 +11123,7 @@ if (NATIVE_WEAK_MAP && IS_IE11) { }); } -},{"./_array-methods":81,"./_collection":90,"./_collection-weak":89,"./_global":109,"./_is-object":120,"./_meta":133,"./_object-assign":136,"./_redefine":157,"./_validate-collection":188}],330:[function(require,module,exports){ +},{"./_array-methods":75,"./_collection":84,"./_collection-weak":83,"./_global":103,"./_is-object":114,"./_meta":127,"./_object-assign":130,"./_redefine":151,"./_validate-collection":182}],324:[function(require,module,exports){ 'use strict'; var weak = require('./_collection-weak'); var validate = require('./_validate-collection'); @@ -11234,7 +11139,7 @@ require('./_collection')(WEAK_SET, function (get) { } }, weak, false, true); -},{"./_collection":90,"./_collection-weak":89,"./_validate-collection":188}],331:[function(require,module,exports){ +},{"./_collection":84,"./_collection-weak":83,"./_validate-collection":182}],325:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap var $export = require('./_export'); @@ -11258,7 +11163,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('flatMap'); -},{"./_a-function":72,"./_add-to-unscopables":74,"./_array-species-create":84,"./_export":101,"./_flatten-into-array":106,"./_to-length":180,"./_to-object":181}],332:[function(require,module,exports){ +},{"./_a-function":66,"./_add-to-unscopables":68,"./_array-species-create":78,"./_export":95,"./_flatten-into-array":100,"./_to-length":174,"./_to-object":175}],326:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/Array.prototype.includes var $export = require('./_export'); @@ -11272,7 +11177,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('includes'); -},{"./_add-to-unscopables":74,"./_array-includes":80,"./_export":101}],333:[function(require,module,exports){ +},{"./_add-to-unscopables":68,"./_array-includes":74,"./_export":95}],327:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $entries = require('./_object-to-array')(true); @@ -11283,7 +11188,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":101,"./_object-to-array":149}],334:[function(require,module,exports){ +},{"./_export":95,"./_object-to-array":143}],328:[function(require,module,exports){ // https://github.com/tc39/proposal-object-getownpropertydescriptors var $export = require('./_export'); var ownKeys = require('./_own-keys'); @@ -11307,7 +11212,7 @@ $export($export.S, 'Object', { } }); -},{"./_create-property":92,"./_export":101,"./_object-gopd":140,"./_own-keys":150,"./_to-iobject":179}],335:[function(require,module,exports){ +},{"./_create-property":86,"./_export":95,"./_object-gopd":134,"./_own-keys":144,"./_to-iobject":173}],329:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $values = require('./_object-to-array')(false); @@ -11318,7 +11223,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":101,"./_object-to-array":149}],336:[function(require,module,exports){ +},{"./_export":95,"./_object-to-array":143}],330:[function(require,module,exports){ // https://github.com/tc39/proposal-promise-finally 'use strict'; var $export = require('./_export'); @@ -11340,7 +11245,7 @@ $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { ); } }); -},{"./_core":91,"./_export":101,"./_global":109,"./_promise-resolve":154,"./_species-constructor":166}],337:[function(require,module,exports){ +},{"./_core":85,"./_export":95,"./_global":103,"./_promise-resolve":148,"./_species-constructor":160}],331:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -11356,7 +11261,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":101,"./_string-pad":171,"./_user-agent":187}],338:[function(require,module,exports){ +},{"./_export":95,"./_string-pad":165,"./_user-agent":181}],332:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -11372,7 +11277,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":101,"./_string-pad":171,"./_user-agent":187}],339:[function(require,module,exports){ +},{"./_export":95,"./_string-pad":165,"./_user-agent":181}],333:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimLeft', function ($trim) { @@ -11381,7 +11286,7 @@ require('./_string-trim')('trimLeft', function ($trim) { }; }, 'trimStart'); -},{"./_string-trim":173}],340:[function(require,module,exports){ +},{"./_string-trim":167}],334:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimRight', function ($trim) { @@ -11390,10 +11295,10 @@ require('./_string-trim')('trimRight', function ($trim) { }; }, 'trimEnd'); -},{"./_string-trim":173}],341:[function(require,module,exports){ +},{"./_string-trim":167}],335:[function(require,module,exports){ require('./_wks-define')('asyncIterator'); -},{"./_wks-define":189}],342:[function(require,module,exports){ +},{"./_wks-define":183}],336:[function(require,module,exports){ var $iterators = require('./es6.array.iterator'); var getKeys = require('./_object-keys'); var redefine = require('./_redefine'); @@ -11453,7 +11358,7 @@ for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++ } } -},{"./_global":109,"./_hide":111,"./_iterators":127,"./_object-keys":146,"./_redefine":157,"./_wks":191,"./es6.array.iterator":203}],343:[function(require,module,exports){ +},{"./_global":103,"./_hide":105,"./_iterators":121,"./_object-keys":140,"./_redefine":151,"./_wks":185,"./es6.array.iterator":197}],337:[function(require,module,exports){ var $export = require('./_export'); var $task = require('./_task'); $export($export.G + $export.B, { @@ -11461,7 +11366,7 @@ $export($export.G + $export.B, { clearImmediate: $task.clear }); -},{"./_export":101,"./_task":175}],344:[function(require,module,exports){ +},{"./_export":95,"./_task":169}],338:[function(require,module,exports){ // ie9- setTimeout & setInterval additional parameters fix var global = require('./_global'); var $export = require('./_export'); @@ -11483,10182 +11388,9948 @@ $export($export.G + $export.B + $export.F * MSIE, { setInterval: wrap(global.setInterval) }); -},{"./_export":101,"./_global":109,"./_user-agent":187}],345:[function(require,module,exports){ +},{"./_export":95,"./_global":103,"./_user-agent":181}],339:[function(require,module,exports){ require('../modules/web.timers'); require('../modules/web.immediate'); require('../modules/web.dom.iterable'); module.exports = require('../modules/_core'); -},{"../modules/_core":91,"../modules/web.dom.iterable":342,"../modules/web.immediate":343,"../modules/web.timers":344}],346:[function(require,module,exports){ -'use strict'; - -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) - && !isSpecial(value) -}; - -function isNonNullObject(value) { - return !!value && typeof value === 'object' -} - -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); - - return stringValue === '[object RegExp]' - || stringValue === '[object Date]' - || isReactElement(value) -} - -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE -} - -function emptyTarget(val) { - return Array.isArray(val) ? [] : {} -} - -function cloneUnlessOtherwiseSpecified(value, options) { - return (options.clone !== false && options.isMergeableObject(value)) - ? deepmerge(emptyTarget(value), value, options) - : value -} - -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options) - }) -} - -function getMergeFunction(key, options) { - if (!options.customMerge) { - return deepmerge - } - var customMerge = options.customMerge(key); - return typeof customMerge === 'function' ? customMerge : deepmerge -} +},{"../modules/_core":85,"../modules/web.dom.iterable":336,"../modules/web.immediate":337,"../modules/web.timers":338}],340:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-env browser */ -function getEnumerableOwnPropertySymbols(target) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return Object.propertyIsEnumerable.call(target, symbol) - }) - : [] -} +/** + * This is the web browser implementation of `debug()`. + */ -function getKeys(target) { - return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) -} +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; -function propertyIsOnObject(object, property) { - try { - return property in object - } catch(_) { - return false - } -} + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { - return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. -} +/** + * Colors. + */ -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) { - getKeys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; } - getKeys(source).forEach(function(key) { - if (propertyIsUnsafe(target, key)) { - return - } - if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { - destination[key] = getMergeFunction(key, options)(target[key], source[key], options); - } else { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } - }); - return destination + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() - // implementations can use it. The caller may not replace it. - options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; +/** + * Colorize log arguments if enabled. + * + * @api public + */ - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); - if (!sourceAndTargetTypesMatch) { - return cloneUnlessOtherwiseSpecified(source, options) - } else if (sourceIsArray) { - return options.arrayMerge(target, source, options) - } else { - return mergeObject(target, source, options) + if (!this.useColors) { + return; } + + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); } -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) { - throw new Error('first argument should be an array') +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? } +} - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options) - }, {}) -}; +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } -var deepmerge_1 = deepmerge; + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } -module.exports = deepmerge_1; + return r; +} -},{}],347:[function(require,module,exports){ -'use strict'; +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ -var $defineProperty = require('es-define-property'); +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } +} -var $SyntaxError = require('es-errors/syntax'); -var $TypeError = require('es-errors/type'); +module.exports = require('./common')(exports); -var gopd = require('gopd'); +const {formatters} = module.exports; -/** @type {import('.')} */ -module.exports = function defineDataProperty( - obj, - property, - value -) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new $TypeError('`obj` must be an object or a function`'); - } - if (typeof property !== 'string' && typeof property !== 'symbol') { - throw new $TypeError('`property` must be a string or a symbol`'); - } - if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { - throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); - } - if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { - throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); - } - if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { - throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); - } - if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { - throw new $TypeError('`loose`, if provided, must be a boolean'); +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; } +}; - var nonEnumerable = arguments.length > 3 ? arguments[3] : null; - var nonWritable = arguments.length > 4 ? arguments[4] : null; - var nonConfigurable = arguments.length > 5 ? arguments[5] : null; - var loose = arguments.length > 6 ? arguments[6] : false; +}).call(this)}).call(this,require('_process')) +},{"./common":341,"_process":429}],341:[function(require,module,exports){ - /* @type {false | TypedPropertyDescriptor} */ - var desc = !!gopd && gopd(obj, property); +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - if ($defineProperty) { - $defineProperty(obj, property, { - configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, - enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, - value: value, - writable: nonWritable === null && desc ? desc.writable : !nonWritable - }); - } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { - // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable - obj[property] = value; // eslint-disable-line no-param-reassign - } else { - throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); - } -}; +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + createDebug.destroy = destroy; -},{"es-define-property":387,"es-errors/syntax":392,"es-errors/type":393,"gopd":405}],348:[function(require,module,exports){ -'use strict'; + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); -var callBind = require('call-bind-apply-helpers'); -var gOPD = require('gopd'); + /** + * The currently active debug mode names, and names to skip. + */ -var hasProtoAccessor; -try { - // eslint-disable-next-line no-extra-parens, no-proto - hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype; -} catch (e) { - if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') { - throw e; - } -} + createDebug.names = []; + createDebug.skips = []; -// eslint-disable-next-line no-extra-parens -var desc = !!hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__')); + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; -var $Object = Object; -var $getPrototypeOf = $Object.getPrototypeOf; - -/** @type {import('./get')} */ -module.exports = desc && typeof desc.get === 'function' - ? callBind([desc.get]) - : typeof $getPrototypeOf === 'function' - ? /** @type {import('./get')} */ function getDunder(value) { - // eslint-disable-next-line eqeqeq - return $getPrototypeOf(value == null ? value : $Object(value)); - } - : false; + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; -},{"call-bind-apply-helpers":38,"gopd":405}],349:[function(require,module,exports){ -'use strict'; + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } -var elliptic = exports; + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; -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'); + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } -},{"../package.json":365,"./elliptic/curve":352,"./elliptic/curves":355,"./elliptic/ec":356,"./elliptic/eddsa":359,"./elliptic/utils":363,"brorand":31}],350:[function(require,module,exports){ -'use strict'; + const self = debug; -var BN = require('bn.js'); -var utils = require('../utils'); -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); + args[0] = createDebug.coerce(args[0]); - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } - // 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); + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); - this._bitLength = this.n ? this.n.bitLength() : 0; + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } - // 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; + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } - var naf = getNAF(k, 1, this._bitLength); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; + return debug; + } - // 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); - } + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } - 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(); -}; + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; + createDebug.names = []; + createDebug.skips = []; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; - // Get NAF form - var naf = getNAF(k, w, this._bitLength); + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - // 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); + namespaces = split[i].replace(/\*/g, '.*?'); - 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; -}; + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } + } -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; + } - // 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; - } + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } - // 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; - } + let i; + let len; - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b], /* 7 */ - ]; + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } - // 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()); - } + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } - 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 */ - ]; + return false; + } - 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; + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); + } - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (i = max; i >= 0; i--) { - var k = 0; + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } - 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; + createDebug.enable(createDebug.load()); - 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(); + return createDebug; +} - 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; +module.exports = setup; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); -}; +},{"ms":423}],342:[function(require,module,exports){ +'use strict'; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) + && !isSpecial(value) }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +function isNonNullObject(value) { + return !!value && typeof value === 'object' +} - var len = this.p.byteLength(); +function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); - // 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); + return stringValue === '[object RegExp]' + || stringValue === '[object Date]' + || isReactElement(value) +} - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); +// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 +var canUseSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - 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'); -}; +function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE +} -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; +function emptyTarget(val) { + return Array.isArray(val) ? [] : {} +} -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +function cloneUnlessOtherwiseSpecified(value, options) { + return (options.clone !== false && options.isMergeableObject(value)) + ? deepmerge(emptyTarget(value), value, options) + : value +} - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); +function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options) + }) +} - return [ 0x04 ].concat(x, this.getY().toArray('be', len)); -}; +function getMergeFunction(key, options) { + if (!options.customMerge) { + return deepmerge + } + var customMerge = options.customMerge(key); + return typeof customMerge === 'function' ? customMerge : deepmerge +} -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; +function getEnumerableOwnPropertySymbols(target) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(target).filter(function(symbol) { + return Object.propertyIsEnumerable.call(target, symbol) + }) + : [] +} -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; +function getKeys(target) { + return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) +} - 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; +function propertyIsOnObject(object, property) { + try { + return property in object + } catch(_) { + return false + } +} - return this; -}; +// Protects from prototype poisoning and unexpected merging up the prototype chain. +function propertyIsUnsafe(target, key) { + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, + && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, + && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. +} -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; +function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) { + getKeys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + } + getKeys(source).forEach(function(key) { + if (propertyIsUnsafe(target, key)) { + return + } - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { + destination[key] = getMergeFunction(key, options)(target[key], source[key], options); + } else { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + } + }); + return destination +} - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; +function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() + // implementations can use it. The caller may not replace it. + options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; - 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, - }; -}; + if (!sourceAndTargetTypesMatch) { + return cloneUnlessOtherwiseSpecified(source, options) + } else if (sourceIsArray) { + return options.arrayMerge(target, source, options) + } else { + return mergeObject(target, source, options) + } +} -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; +deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) { + throw new Error('first argument should be an array') + } - 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, - }; + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options) + }, {}) }; -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; +var deepmerge_1 = deepmerge; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +module.exports = deepmerge_1; -},{"../utils":363,"bn.js":364}],351:[function(require,module,exports){ +},{}],343:[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); +var $defineProperty = require('es-define-property'); - 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); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; +var gopd = require('gopd'); -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); -}; +/** @type {import('.')} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; - 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)); + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } +}; - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); +},{"es-define-property":381,"es-errors/syntax":386,"es-errors/type":387,"gopd":394}],344:[function(require,module,exports){ +'use strict'; - return this.point(x, y); -}; +var elliptic = exports; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); +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'); - // 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()); +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } +},{"../package.json":360,"./elliptic/curve":347,"./elliptic/curves":350,"./elliptic/ec":351,"./elliptic/eddsa":354,"./elliptic/utils":358,"brorand":31}],345:[function(require,module,exports){ +'use strict'; - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - return this.point(x, y); -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; + // 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: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - 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))); + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); - return lhs.cmp(rhs) === 0; -}; + this._bitLength = this.n ? this.n.bitLength() : 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; + // 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.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()); - } + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); } } -inherits(Point, Base.BasePoint); +module.exports = BaseCurve; -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); }; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); -}; +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; -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)); + // 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(); }; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; - // 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); -}; + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; -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 + // Get NAF form + var naf = getNAF(k, w, this._bitLength); - // 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(); + // 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); - 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); + 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 { - // 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); + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); } - } 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); + return p.type === 'affine' ? acc.toP() : acc; }; -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(); -}; +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M + // 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; + } - // 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); -}; + // 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; + } -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; - // 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); -}; + // 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()); + } -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; + 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 */ + ]; - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; + 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; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + 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; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + 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(); - // 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; -}; + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); + if (jacobianResult) + return acc; + else + return acc.toP(); }; -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); }; -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); }; -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); - 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; + var len = this.p.byteLength(); - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; + // 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'); }; -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],352:[function(require,module,exports){ -'use strict'; +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); -var curve = exports; + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; -},{"./base":350,"./edwards":351,"./mont":353,"./short":354}],353:[function(require,module,exports){ -'use strict'; +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); +}; -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; -var utils = require('../utils'); + 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; -function MontCurve(conf) { - Base.call(this, 'mont', conf); + return this; +}; - 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; +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; -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(); + var doubles = this.precomputed.doubles; + if (!doubles) + return false; - return y.redSqr().cmp(rhs) === 0; + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -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); +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); + 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, + }; }; -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); + 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, + }; }; -Point.prototype.precompute = function precompute() { - // No-op +BasePoint.prototype._getBeta = function _getBeta() { + return null; }; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; +},{"../utils":358,"bn.js":359}],346:[function(require,module,exports){ +'use strict'; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; +var assert = utils.assert; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A +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; - // 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); -}; + Base.call(this, 'edwards', conf); -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); -}; + 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); -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; +} +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; - // 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); +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); }; -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; +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); }; -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); }; -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; -}; + 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)); -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; -}; + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); - return this.x.fromRed(); + return this.point(x, y); }; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],354:[function(require,module,exports){ -'use strict'; +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + // 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()); -var assert = utils.assert; + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } -function ShortCurve(conf) { - Base.call(this, 'short', conf); + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - 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(); + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + return this.point(x, y); +}; - // 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; +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); - // 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); + 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 { - // 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); + 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); - // 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); - } +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; - return { - beta: beta, - lambda: lambda, - basis: basis, - }; +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); }; -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(); +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; +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)); }; -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - // 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); + // 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); +}; - // 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; +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 - 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)); + // 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(); - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; + 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); } - 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(); + } 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 [ - { a: a1, b: b1 }, - { a: a2, b: b2 }, - ]; + return this.curve.point(nx, ny, nz); }; -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); +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); }; -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(); +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return this.point(x, y); + // 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); }; -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; - }; +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S -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; + // 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 { - 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; + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); } -} -inherits(Point, Base.BasePoint); - -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); + return this.curve.point(nx, ny, nz); }; -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); +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._getBeta = function _getBeta() { - if (!this.curve.endo) - return; +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; - 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.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; - 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), - }, - } ]; + // 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.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); - } +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; - 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.getX = function getX() { + this.normalize(); + return this.x.fromRed(); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; - // P + O = P - if (p.inf) - return this; + 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; - // P + P = 2P - if (this.eq(p)) - return this.dbl(); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],347:[function(require,module,exports){ +'use strict'; - 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); -}; +var curve = exports; -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); +},{"./base":345,"./edwards":346,"./mont":348,"./short":349}],348:[function(require,module,exports){ +'use strict'; - var a = this.curve.a; +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); +var utils = require('../utils'); - 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); +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; }; -Point.prototype.getX = function getX() { - return this.x.fromRed(); +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); }; -Point.prototype.getY = function getY() { - return this.y.fromRed(); +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); }; -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); +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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.precompute = function precompute() { + // No-op }; -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._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); }; -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.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); }; -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - 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.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; + // 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); }; -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); +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - this.zOne = this.z === this.curve.one; -} -inherits(JPoint, Base.BasePoint); +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); + // 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); }; -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); +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 - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); - return this.curve.point(ax, ay); + 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; }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); }; -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - // P + O = P - if (p.isInfinity()) - return this; +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - // 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); +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; - 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); +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - return this.curve.jpoint(nx, ny, nz); + return this.x.fromRed(); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],349:[function(require,module,exports){ +'use strict'; - // P + O = P - if (p.isInfinity()) - return this; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - // 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 assert = utils.assert; - 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(); - } +function ShortCurve(conf) { + Base.call(this, 'short', conf); - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); + 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(); - 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); + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - return this.curve.jpoint(nx, ny, nz); -}; + // 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; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - var i; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (i = 0; i < pow; i++) - r = r.dbl(); - return r; + // 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); + } } - // 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; + // 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 this.curve.jpoint(jx, jyd.redMul(tinv), jz); + return { + beta: beta, + lambda: lambda, + basis: basis, + }; }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +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(); - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); + 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 ]; }; -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 +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - // 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); + // 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); - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); + // 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; - // 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 + 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)); - // 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); + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - // 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); + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; } + a2 = r.neg(); + b2 = x; - 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 + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } - // 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); + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); } - return this.curve.jpoint(nx, ny, nz); + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; }; -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)); +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - 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 c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); - 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); + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); - return this.curve.jpoint(nx, ny, nz); + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; }; -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); +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - return this.curve.jpoint(nx, ny, nz); -}; + 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'); -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); + // 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.curve._wnafMul(this, k); + return this.point(x, y); }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); - - if (this === p) +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) 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; + var x = point.x; + var y = point.y; - // 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; + 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; }; -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; +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(); - 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; + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return 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); -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); }; -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); }; -},{"../utils":363,"./base":350,"bn.js":364,"inherits":424}],355:[function(require,module,exports){ -'use strict'; +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; -var curves = exports; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; -var hash = require('hash.js'); -var curve = require('./curve'); -var utils = require('./utils'); + 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; +}; -var assert = utils.assert; +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; -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; + 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), + }, + } ]; +}; - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; +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 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; + 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; +}; -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', - ], -}); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; -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', - ], -}); +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; -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', - ], -}); +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; -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', - ], -}); + // P + O = P + if (p.inf) + return this; -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', - ], -}); + // P + P = 2P + if (this.eq(p)) + return this.dbl(); -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', - ], -}); + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); -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', + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658', - ], -}); + 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); +}; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; -} +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; -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, + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3', - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15', - }, - ], + var a = this.curve.a; - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre, - ], -}); + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); -},{"./curve":352,"./precomputed/secp256k1":362,"./utils":363,"hash.js":409}],356:[function(require,module,exports){ -'use strict'; + 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); +}; -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; +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; -var KeyPair = require('./key'); -var Signature = require('./signature'); +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); +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); +}; - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(Object.prototype.hasOwnProperty.call(curves, options), - 'Unknown curve ' + options); +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); +}; - options = curves[options]; +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; +}; - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof curves.PresetCurve) - options = { curve: options }; +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); +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); - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; + this.zOne = this.z === this.curve.one; } -module.exports = EC; +inherits(JPoint, Base.BasePoint); -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); }; -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); +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); }; -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; - // 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, bitLength) { - var byteLength; - if (BN.isBN(msg) || typeof msg === 'number') { - msg = new BN(msg, 16); - byteLength = msg.byteLength(); - } else if (typeof msg === 'object') { - // BN assumes an array-like input and asserts length - byteLength = msg.length; - msg = new BN(msg, 16); - } else { - // BN converts the value to string - var str = msg.toString(); - // HEX encoding - byteLength = (str.length + 1) >>> 1; - msg = new BN(str, 16); - } - // Allow overriding - if (typeof bitLength !== 'number') { - bitLength = byteLength * 8; - } - var delta = bitLength - 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; -}; + // P + O = P + if (p.isInfinity()) + return this; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; + // 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)); - if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) { - assert(typeof msg === 'object' && msg && typeof msg.length === 'number', - 'Expected message to be an array-like, a hex string, or a BN instance'); - assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer - for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]); + 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(); } - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(msg, false, options.msgBitLength); - - // Would fail further checks, but let's make the error message clear - assert(!msg.isNeg(), 'Can not sign a negative message'); - - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + 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); - // Recheck nonce to be bijective to msg - assert((new BN(nonce)).eq(msg), 'Can not sign message'); + return this.curve.jpoint(nx, ny, nz); +}; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - }); +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); + // P + O = P + if (p.isInfinity()) + return this; - 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; + // 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 kp = this.g.mul(k); - if (kp.isInfinity()) - continue; + 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 kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - 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 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); - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); + return this.curve.jpoint(nx, ny, nz); +}; - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; } -}; - -EC.prototype.verify = function verify(msg, signature, key, enc, options) { - if (!options) - options = {}; - msg = this._truncateToN(msg, false, options.msgBitLength); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; - // 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; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - // 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; + // 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)); - if (!this.curve._maxwellTrick) { - p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + 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); - return p.getX().umod(this.n).cmp(r) === 0; + jx = nx; + jz = nz; + jyd = dny; } - // 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); + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; -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'); +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); 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); + return this._dbl(); }; -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; +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 - 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":355,"../utils":363,"./key":357,"./signature":358,"bn.js":364,"brorand":31,"hmac-drbg":422}],357:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; + // 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); -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); - // 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; + // 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 -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; + // 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(); - return new KeyPair(ec, { - pub: pub, - pubEnc: enc, - }); -}; + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; + // 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 new KeyPair(ec, { - priv: priv, - privEnc: enc, - }); + return this.curve.jpoint(nx, ny, nz); }; -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' }; +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 - return { result: true, reason: null }; -}; + // 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 -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; + // 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); } - 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; + return this.curve.jpoint(nx, ny, nz); }; -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; - // 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); -}; + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -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); -}; + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); -// ECDH -KeyPair.prototype.derive = function derive(pub) { - if(!pub.validate()) { - assert(pub.validate(), 'public point not validated'); - } - return pub.mul(this.priv).getX(); -}; + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; + 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); -KeyPair.prototype.verify = function verify(msg, signature, options) { - return this.ec.verify(msg, signature, this, undefined, options); -}; + 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); -KeyPair.prototype.inspect = function inspect() { - return ''; + return this.curve.jpoint(nx, ny, nz); }; -},{"../utils":363,"bn.js":364}],358:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); - -var utils = require('../utils'); -var assert = utils.assert; +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); -function Signature(options, enc) { - if (options instanceof Signature) - return options; + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - 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; + // 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); -function Position() { - this.place = 0; -} + return this.curve.jpoint(nx, ny, nz); +}; -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); - // Indefinite length or overflow - if (octetLen === 0 || octetLen > 4) { - return false; - } + return this.curve._wnafMul(this, k); +}; - if(buf[p.place] === 0x00) { - return false; - } +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - val >>>= 0; - } + if (this === p) + return true; - // Leading zeroes - if (val <= 0x7f) { + // 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; - } - p.place = off; - return val; -} + // 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; +}; -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); -} +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; -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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - if ((data[p.place] & 128) !== 0) { - 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 + 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; - } - } - - 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); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - 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); +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - 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); +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -},{"../utils":363,"bn.js":364}],359:[function(require,module,exports){ +},{"../utils":358,"./base":345,"bn.js":359,"inherits":414}],350:[function(require,module,exports){ 'use strict'; +var curves = exports; + 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'); +var curve = require('./curve'); +var utils = require('./utils'); -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); +var assert = utils.assert; - if (!(this instanceof EDDSA)) - return new EDDSA(curve); +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; - curve = curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; +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; + }, + }); } -module.exports = EDDSA; +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', + ], +}); -/** -* @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 }); -}; +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', + ], +}); -/** -* @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); - if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) { - return false; - } - 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); -}; +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', + ], +}); -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); -}; +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', + ], +}); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; +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', + ], +}); -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; +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', + ], +}); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; +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', -/** -* * 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; -}; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; +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, - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; - -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; - -},{"../curves":355,"../utils":363,"./key":360,"./signature":361,"hash.js":409}],360:[function(require,module,exports){ -'use strict'; +},{"./curve":347,"./precomputed/secp256k1":357,"./utils":358,"hash.js":399}],351:[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 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); -} +var KeyPair = require('./key'); +var Signature = require('./signature'); -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); -KeyPair.prototype.secret = function secret() { - return this._secret; -}; + options = curves[options]; + } -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; - return a; -}); +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); +}; -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); +}; -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); +}; -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + // 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(), + }); -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + 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; -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); + priv.iaddn(1); + return this.keyFromPrivate(priv); + } }; -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); +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; }; -module.exports = KeyPair; - -},{"../utils":363}],361:[function(require,module,exports){ -'use strict'; +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); -/** -* @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; + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); - if (typeof sig !== 'object') - sig = parseBytes(sig); + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); - if (Array.isArray(sig)) { - assert(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size'); - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength), - }; - } + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); - assert(sig.R && sig.S, 'Signature without R or S'); + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; + 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; - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + } }; -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); -}; +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'); -module.exports = Signature; + // 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; -},{"../utils":363,"bn.js":364}],362:[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', - ], - ], - }, -}; - -},{}],363:[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); - var i; - for (i = 0; i < naf.length; i += 1) { - naf[i] = 0; - } - - var ws = 1 << (w + 1); - var k = num.clone(); - - for (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":364,"minimalistic-assert":439,"minimalistic-crypto-utils":440}],364:[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; - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - } - 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); - }; + // 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; - // 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); - }; + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; + return p.getX().umod(this.n).cmp(r) === 0; + } - BN.prototype.imuln = function imuln (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K - // 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; - } + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } + // 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); +}; - return this; - }; +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); - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; + // 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'); - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; + // 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); - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - res = res.mul(q); - } + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - 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 (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; - if (carry) { - this.words[i] = carry; - this.length++; - } - } +},{"../curves":350,"../utils":358,"./key":352,"./signature":353,"bn.js":359,"brorand":31,"hmac-drbg":412}],352:[function(require,module,exports){ +'use strict'; - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; - for (i = 0; i < s; i++) { - this.words[i] = 0; - } +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; - this.length += s; - } + // 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; - return this.strip(); - }; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); +}; - // 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; - } +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); +}; - h -= s; - h = Math.max(0, h); +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } + 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' }; - 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; - } + return { result: true, reason: null }; +}; - 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; - } +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } + if (!enc) + return this.pub; - return this.strip(); - }; + return this.pub.encode(enc, compact); +}; - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; + // 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); +}; - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; +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); +}; - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - // 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; +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; - // Check bit and return - var w = this.words[s]; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - return !!(w & q); - }; +},{"../utils":358,"bn.js":359}],353:[function(require,module,exports){ +'use strict'; - // 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; +var BN = require('bn.js'); - assert(this.negative === 0, 'imaskn works only with positive numbers'); +var utils = require('../utils'); +var assert = utils.assert; - if (this.length <= s) { - return this; - } +function Signature(options, enc) { + if (options instanceof Signature) + return options; - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); + if (this._importDER(options, enc)) + return; - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } + 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; - return this.strip(); - }; +function Position() { + this.place = 0; +} - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; - // 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); + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } - // 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; - } + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } + // Leading zeroes + if (val <= 0x7f) { + return false; + } - // Add without checks - return this._iaddn(num); - }; + p.place = off; + return val; +} - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; +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); +} - // 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]++; - } +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; } - this.length = Math.max(this.length, i + 1); + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } - return this; - }; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; +}; - // 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); +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); +} - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); - this.words[0] -= num; + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - 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; - } - } + r = rmPadding(r); + s = rmPadding(s); - return this.strip(); - }; + 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); +}; - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; +},{"../utils":358,"bn.js":359}],354:[function(require,module,exports){ +'use strict'; - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; +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'); - BN.prototype.iabs = function iabs () { - this.negative = 0; +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - return this; - }; + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - this._expand(len); +module.exports = EDDSA; - 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; - } +/** +* @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 }); +}; - if (carry === 0) return this.strip(); +/** +* @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); +}; - // 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; +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); +}; - return this.strip(); - }; +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; - var a = this.clone(); - var b = num; +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - // 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; - } +/** +* * 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; +}; - // Initialize quotient - var m = a.length - b.length; - var q; +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - 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 lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - 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(); +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } +},{"../curves":350,"../utils":358,"./key":355,"./signature":356,"hash.js":399}],355:[function(require,module,exports){ +'use strict'; - return { - div: q || null, - mod: a - }; - }; +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; - // 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()); +/** +* @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); +} - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); +}; - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - if (mode !== 'mod') { - div = res.div.neg(); - } +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - return { - div: div, - mod: mod - }; - } +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - if (mode !== 'mod') { - div = res.div.neg(); - } + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - return { - div: div, - mod: res.mod - }; - } + return a; +}); - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - return { - div: res.div, - mod: mod - }; - } +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // Both numbers are positive at this point +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } +module.exports = KeyPair; - return this._wordDiv(num, mode); - }; +},{"../utils":358}],356:[function(require,module,exports){ +'use strict'; - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; +/** +* @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; - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; + if (typeof sig !== 'object') + sig = parseBytes(sig); - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; + assert(sig.R && sig.S, 'Signature without R or S'); - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); - return acc; - }; +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; - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); +},{"../utils":358,"bn.js":359}],357:[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', + ], + ], + }, +}; - 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; - } +},{}],358:[function(require,module,exports){ +'use strict'; - return this.strip(); - }; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + var i; + for (i = 0; i < naf.length; i += 1) { + naf[i] = 0; + } - var x = this; - var y = p.clone(); + var ws = 1 << (w + 1); + var k = num.clone(); - if (x.negative !== 0) { - x = x.umod(p); + for (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 { - x = x.clone(); + z = 0; } - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); + naf[i] = z; + k.iushrn(1); + } - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); + return naf; +} +utils.getNAF = getNAF; - var g = 0; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; + 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 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); - } + 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); - 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(); + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } + return jsf; +} +utils.getJSF = getJSF; - var x1 = new BN(1); - var x2 = new BN(0); +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; - var delta = b.clone(); +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; - 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); - } +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; - 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); - } +},{"bn.js":359,"minimalistic-assert":421,"minimalistic-crypto-utils":422}],359:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; - x2.iushrn(1); - } - } + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } + // 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; + } - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } + // BN - if (res.cmpn(0) < 0) { - res.iadd(p); + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; } - 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; + this.negative = 0; + this.words = null; + this.length = 0; - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } + // Reduction context + this.red = null; - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; } - 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; - } + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } - a.isub(b); - } while (true); + BN.BN = BN; + BN.wordSize = 26; - return b.iushln(shift); - }; + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); }; - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; }; - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; }; - // 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; + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; + if (typeof number === 'object') { + return this._initArray(number, base, endian); } - // 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 (base === 'hex') { + base = 16; } - if (carry !== 0) { - this.words[i] = carry; - this.length++; + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; } - return this; - }; - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; + 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.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; + 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 { - 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; + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; } - 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; + if (endian !== 'le') return; - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; + // Reverse the bytes + this._initArray(this.toArray(), base, endian); }; - // 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; + 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; + } - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; + 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; + } - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; + 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++; + } } - 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; + return this.strip(); }; - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; + 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; + } + } - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; + 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; + } - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; + // 24-bits chunks + var off = 0; + var j = 0; - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 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; + } + } + } - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; + this.strip(); }; - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; + 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; - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; + r *= mul; - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; - 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); - }; + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; + // '0' - '9' + } else { + r += c; + } + } + return r; + } - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; + for (i = 0; i < mod; i++) { + pow *= base; + } - 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); - }; + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } - 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); + this.strip(); }; - 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.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.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; }; - // 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._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; }; - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(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(); }; - // 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._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; }; - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); + BN.prototype.inspect = function inspect () { + return (this.red ? ''; }; - // 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); + var zeros = []; + var groupSizes = []; + var groupBases = []; - this.tmp = this._tmp(); + 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; } - 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; + 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' + ]; - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); + 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 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(); + 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; } - return r; - }; + 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); - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); + 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'); }; - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); + 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; }; - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } + 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'); - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); - 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; - } - }; + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - // 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); - } + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; + res[i] = b; } - } - return num; - }; - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); + for (; i < reqLength; i++) { + res[i] = 0; + } + } - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); + return res; + }; - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + 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; + }; } - 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; + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - num.words[i] = lo; - carry = hi; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; } - if (carry !== 0) { - num.words[num.length++] = carry; + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; } - return num; + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; }; - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; + // 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; + }; - 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; + function toBitArray (num) { + var w = new Array(num.bitLength()); - return prime; - }; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - // - // 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; + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; } + + return w; } - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - 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'); + 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; }; - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(this); + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); }; - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); } - - return this.m.sub(a)._forceRed(this); + return this.clone(); }; - 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); + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); } - return res._forceRed(this); + return this.clone(); }; - 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; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; }; - 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); + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); }; - 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); + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; } - return res; - }; - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); + return this; }; - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; + // 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]; + } - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); + return this.strip(); }; - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); }; - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); + // 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); }; - 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); - } + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - // 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); + // 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; } - 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); + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; } - 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)); + this.length = b.length; - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } + return this.strip(); + }; - return r; + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); }; - 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); - } + // 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); }; - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - 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); + // 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; } - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; } - 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; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; } - start = 26; } - return res; + this.length = a.length; + + return this.strip(); }; - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; - return r === num ? r.clone() : r; + // 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); }; - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); }; - // - // Montgomery method engine - // + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - BN.mont = function mont (num) { - return new Mont(num); - }; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - function Mont (m) { - Red.call(this, m); + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); + if (bitsLeft > 0) { + bytesNeeded--; } - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - 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); + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); + // And remove leading zeroes + return this.strip(); }; - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); }; - 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); - } + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - return res._forceRed(this); - }; + var off = (bit / 26) | 0; + var wbit = bit % 26; - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + this._expand(off + 1); - 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); + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); } - 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); + return this.strip(); }; -})(typeof module === 'undefined' || module, this); -},{"buffer":32}],365:[function(require,module,exports){ -module.exports={ - "name": "elliptic", - "version": "6.6.1", - "description": "EC cryptography", - "main": "lib/elliptic.js", - "files": [ - "lib" - ], - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "test": "npm run lint && npm run unit", - "version": "grunt dist && git add dist/" - }, - "repository": { - "type": "git", - "url": "git@github.com:indutny/elliptic" - }, - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "author": "Fedor Indutny ", - "license": "MIT", - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "homepage": "https://github.com/indutny/elliptic", - "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" - }, - "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" - } -} + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; -},{}],366:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hasCORS = void 0; -// imported from https://github.com/component/has-cors -let value = false; -try { - value = typeof XMLHttpRequest !== 'undefined' && - 'withCredentials' in new XMLHttpRequest(); -} -catch (err) { - // if XMLHttp support is disabled in IE then it will throw - // when trying to create -} -exports.hasCORS = value; + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); -},{}],367:[function(require,module,exports){ -"use strict"; -// imported from https://github.com/galkn/querystring -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encode = encode; -exports.decode = decode; -function encode(obj) { - let str = ''; - for (let i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) - str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - return str; -} -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ -function decode(qs) { - let qry = {}; - let pairs = qs.split('&'); - for (let i = 0, l = pairs.length; i < l; i++) { - let pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); } - return qry; -} -},{}],368:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.parse = parse; -// imported from https://github.com/galkn/parseuri -/** - * Parses a URI - * - * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. - * - * See: - * - https://developer.mozilla.org/en-US/docs/Web/API/URL - * - https://caniuse.com/url - * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B - * - * History of the parse() method: - * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c - * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 - * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 - * - * @author Steven Levithan (MIT license) - * @api private - */ -const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; -const parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; -function parse(str) { - if (str.length > 8000) { - throw "URI too long"; - } - const src = str, b = str.indexOf('['), e = str.indexOf(']'); - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; } - let m = re.exec(str || ''), uri = {}, i = 14; - while (i--) { - uri[parts[i]] = m[i] || ''; + + 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; } - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; } - uri.pathNames = pathNames(uri, uri['path']); - uri.queryKey = queryKey(uri, uri['query']); - return uri; -} -function pathNames(obj, path) { - const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); - if (path.slice(0, 1) == '/' || path.length === 0) { - names.splice(0, 1); + + 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]; + } } - if (path.slice(-1) == '/') { - names.splice(names.length - 1, 1); + + 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; } - return names; -} -function queryKey(uri, query) { - const data = {}; - query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { - if ($1) { - data[$1] = $2; - } - }); - return data; -} -},{}],369:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.defaultBinaryType = exports.globalThisShim = exports.nextTick = void 0; -exports.createCookieJar = createCookieJar; -exports.nextTick = (() => { - const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; - if (isPromiseAvailable) { - return (cb) => Promise.resolve().then(cb); + 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(); } - else { - return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + + // 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; } -})(); -exports.globalThisShim = (() => { - if (typeof self !== "undefined") { - return self; + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; } - else if (typeof window !== "undefined") { - return window; + + 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; } - else { - return Function("return this")(); + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; } -})(); -exports.defaultBinaryType = "arraybuffer"; -function createCookieJar() { } -},{}],370:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0; -const socket_js_1 = require("./socket.js"); -Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); -var socket_js_2 = require("./socket.js"); -Object.defineProperty(exports, "SocketWithoutUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }); -Object.defineProperty(exports, "SocketWithUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }); -exports.protocol = socket_js_1.Socket.protocol; -var transport_js_1 = require("./transport.js"); -Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); -Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); -var index_js_1 = require("./transports/index.js"); -Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); -var util_js_1 = require("./util.js"); -Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); -var parseuri_js_1 = require("./contrib/parseuri.js"); -Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); -var globals_node_js_1 = require("./globals.node.js"); -Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return globals_node_js_1.nextTick; } }); -var polling_fetch_js_1 = require("./transports/polling-fetch.js"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return polling_fetch_js_1.Fetch; } }); -var polling_xhr_node_js_1 = require("./transports/polling-xhr.node.js"); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return polling_xhr_node_js_1.XHR; } }); -var polling_xhr_js_1 = require("./transports/polling-xhr.js"); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return polling_xhr_js_1.XHR; } }); -var websocket_node_js_1 = require("./transports/websocket.node.js"); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return websocket_node_js_1.WS; } }); -var websocket_js_1 = require("./transports/websocket.js"); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return websocket_js_1.WS; } }); -var webtransport_js_1 = require("./transports/webtransport.js"); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return webtransport_js_1.WT; } }); - -},{"./contrib/parseuri.js":368,"./globals.node.js":369,"./socket.js":371,"./transport.js":372,"./transports/index.js":373,"./transports/polling-fetch.js":374,"./transports/polling-xhr.js":375,"./transports/polling-xhr.node.js":375,"./transports/websocket.js":377,"./transports/websocket.node.js":377,"./transports/webtransport.js":378,"./util.js":379}],371:[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.Socket = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = void 0; -const index_js_1 = require("./transports/index.js"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const parseuri_js_1 = require("./contrib/parseuri.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("./globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() -const withEventListeners = typeof addEventListener === "function" && - typeof removeEventListener === "function"; -const OFFLINE_EVENT_LISTENERS = []; -if (withEventListeners) { - // within a ServiceWorker, any event handler for the 'offline' event must be added on the initial evaluation of the - // script, so we create one single event listener here which will forward the event to the socket instances - addEventListener("offline", () => { - debug("closing %d connection(s) because the network was lost", OFFLINE_EVENT_LISTENERS.length); - OFFLINE_EVENT_LISTENERS.forEach((listener) => listener()); - }, false); -} -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that - * successfully establishes the connection. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithoutUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithoutUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithUpgrade - * @see Socket - */ -class SocketWithoutUpgrade extends component_emitter_1.Emitter { - /** - * Socket constructor. - * - * @param {String|Object} uri - uri or options - * @param {Object} opts - options - */ - constructor(uri, opts) { - super(); - this.binaryType = globals_node_js_1.defaultBinaryType; - this.writeBuffer = []; - this._prevBufferLen = 0; - this._pingInterval = -1; - this._pingTimeout = -1; - this._maxPayload = -1; - /** - * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the - * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked. - */ - this._pingTimeoutTime = Infinity; - if (uri && "object" === typeof uri) { - opts = uri; - uri = null; - } - if (uri) { - const parsedUri = (0, parseuri_js_1.parse)(uri); - opts.hostname = parsedUri.host; - opts.secure = - parsedUri.protocol === "https" || parsedUri.protocol === "wss"; - opts.port = parsedUri.port; - if (parsedUri.query) - opts.query = parsedUri.query; - } - else if (opts.host) { - opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; - } - (0, util_js_1.installTimerFunctions)(this, opts); - this.secure = - null != opts.secure - ? opts.secure - : typeof location !== "undefined" && "https:" === location.protocol; - if (opts.hostname && !opts.port) { - // if no port is specified manually, use the protocol default - opts.port = this.secure ? "443" : "80"; - } - this.hostname = - opts.hostname || - (typeof location !== "undefined" ? location.hostname : "localhost"); - this.port = - opts.port || - (typeof location !== "undefined" && location.port - ? location.port - : this.secure - ? "443" - : "80"); - this.transports = []; - this._transportsByName = {}; - opts.transports.forEach((t) => { - const transportName = t.prototype.name; - this.transports.push(transportName); - this._transportsByName[transportName] = t; - }); - this.opts = Object.assign({ - path: "/engine.io", - agent: false, - withCredentials: false, - upgrade: true, - timestampParam: "t", - rememberUpgrade: false, - addTrailingSlash: true, - rejectUnauthorized: true, - perMessageDeflate: { - threshold: 1024, - }, - transportOptions: {}, - closeOnBeforeunload: false, - }, opts); - this.opts.path = - this.opts.path.replace(/\/$/, "") + - (this.opts.addTrailingSlash ? "/" : ""); - if (typeof this.opts.query === "string") { - this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); - } - if (withEventListeners) { - if (this.opts.closeOnBeforeunload) { - // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener - // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is - // closed/reloaded) - this._beforeunloadEventListener = () => { - if (this.transport) { - // silently close the transport - this.transport.removeAllListeners(); - this.transport.close(); - } - }; - addEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this.hostname !== "localhost") { - debug("adding listener for the 'offline' event"); - this._offlineEventListener = () => { - this._onClose("transport close", { - description: "network connection lost", - }); - }; - OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener); - } - } - if (this.opts.withCredentials) { - this._cookieJar = (0, globals_node_js_1.createCookieJar)(); - } - this._open(); + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } } - /** - * Creates transport of the given type. - * - * @param {String} name - transport name - * @return {Transport} - * @private - */ - createTransport(name) { - debug('creating transport "%s"', name); - const query = Object.assign({}, this.opts.query); - // append engine.io protocol identifier - query.EIO = engine_io_parser_1.protocol; - // transport name - query.transport = name; - // session id if we already have one - if (this.id) - query.sid = this.id; - const opts = Object.assign({}, this.opts, { - query, - socket: this, - hostname: this.hostname, - secure: this.secure, - port: this.port, - }, this.opts.transportOptions[name]); - debug("options: %j", opts); - return new this._transportsByName[name](opts); + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; } - /** - * Initializes transport to use and starts probe. - * - * @private - */ - _open() { - if (this.transports.length === 0) { - // Emit error on next tick so it can be listened to - this.setTimeoutFn(() => { - this.emitReserved("error", "No transports available"); - }, 0); - return; - } - const transportName = this.opts.rememberUpgrade && - SocketWithoutUpgrade.priorWebsocketSuccess && - this.transports.indexOf("websocket") !== -1 - ? "websocket" - : this.transports[0]; - this.readyState = "opening"; - const transport = this.createTransport(transportName); - transport.open(); - this.setTransport(transport); + + 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; } - /** - * Sets the current transport. Disables the existing one (if any). - * - * @private - */ - setTransport(transport) { - debug("setting transport %s", transport.name); - if (this.transport) { - debug("clearing existing transport %s", this.transport.name); - this.transport.removeAllListeners(); - } - // set up transport - this.transport = transport; - // set up transport listeners - transport - .on("drain", this._onDrain.bind(this)) - .on("packet", this._onPacket.bind(this)) - .on("error", this._onError.bind(this)) - .on("close", (reason) => this._onClose("transport close", reason)); + 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++; } - /** - * Called when connection is deemed open. - * - * @private - */ - onOpen() { - debug("socket open"); - this.readyState = "open"; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === this.transport.name; - this.emitReserved("open"); - this.flush(); + 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; } - /** - * Handles a packet. - * - * @private - */ - _onPacket(packet) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket receive: type "%s", data "%s"', packet.type, packet.data); - this.emitReserved("packet", packet); - // Socket is live - any packet counts - this.emitReserved("heartbeat"); - switch (packet.type) { - case "open": - this.onHandshake(JSON.parse(packet.data)); - break; - case "ping": - this._sendPacket("pong"); - this.emitReserved("ping"); - this.emitReserved("pong"); - this._resetPingTimeout(); - break; - case "error": - const err = new Error("server error"); - // @ts-ignore - err.code = packet.data; - this._onError(err); - break; - case "message": - this.emitReserved("data", packet.data); - this.emitReserved("message", packet.data); - break; - } - } - else { - debug('packet received with socket readyState "%s"', this.readyState); - } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; } - /** - * Called upon handshake completion. - * - * @param {Object} data - handshake obj - * @private - */ - onHandshake(data) { - this.emitReserved("handshake", data); - this.id = data.sid; - this.transport.query.sid = data.sid; - this._pingInterval = data.pingInterval; - this._pingTimeout = data.pingTimeout; - this._maxPayload = data.maxPayload; - this.onOpen(); - // In case open handler closes socket - if ("closed" === this.readyState) - return; - this._resetPingTimeout(); + + 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); } - /** - * Sets and resets ping timeout timer based on server pings. - * - * @private - */ - _resetPingTimeout() { - this.clearTimeoutFn(this._pingTimeoutTimer); - const delay = this._pingInterval + this._pingTimeout; - this._pingTimeoutTime = Date.now() + delay; - this._pingTimeoutTimer = this.setTimeoutFn(() => { - this._onClose("ping timeout"); - }, delay); - if (this.opts.autoUnref) { - this._pingTimeoutTimer.unref(); - } + + 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); } - /** - * Called on `drain` event - * - * @private - */ - _onDrain() { - this.writeBuffer.splice(0, this._prevBufferLen); - // setting prevBufferLen = 0 is very important - // for example, when upgrading, upgrade packet is sent over, - // and a nonzero prevBufferLen could cause problems on `drain` - this._prevBufferLen = 0; - if (0 === this.writeBuffer.length) { - this.emitReserved("drain"); - } - else { - this.flush(); - } + + 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; } - /** - * Flush write buffers. - * - * @private - */ - flush() { - if ("closed" !== this.readyState && - this.transport.writable && - !this.upgrading && - this.writeBuffer.length) { - const packets = this._getWritablePackets(); - debug("flushing %d packets in socket", packets.length); - this.transport.send(packets); - // keep track of current length of writeBuffer - // splice writeBuffer and callbackBuffer on `drain` - this._prevBufferLen = packets.length; - this.emitReserved("flush"); - } + + 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]]; } - /** - * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP - * long-polling) - * - * @private - */ - _getWritablePackets() { - const shouldCheckPayloadSize = this._maxPayload && - this.transport.name === "polling" && - this.writeBuffer.length > 1; - if (!shouldCheckPayloadSize) { - return this.writeBuffer; - } - let payloadSize = 1; // first packet type - for (let i = 0; i < this.writeBuffer.length; i++) { - const data = this.writeBuffer[i].data; - if (data) { - payloadSize += (0, util_js_1.byteLength)(data); - } - if (i > 0 && payloadSize > this._maxPayload) { - debug("only send %d out of %d packets", i, this.writeBuffer.length); - return this.writeBuffer.slice(0, i); - } - payloadSize += 2; // separator + packet type + }; + + 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; + } } - debug("payload size is %d (max: %d)", payloadSize, this._maxPayload); - return this.writeBuffer; + } } - /** - * Checks whether the heartbeat timer has expired but the socket has not yet been notified. - * - * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the - * `write()` method then the message would not be buffered by the Socket.IO client. - * - * @return {boolean} - * @private - */ - /* private */ _hasPingExpired() { - if (!this._pingTimeoutTime) - return true; - const hasExpired = Date.now() > this._pingTimeoutTime; - if (hasExpired) { - debug("throttled timer detected, scheduling connection close"); - this._pingTimeoutTime = 0; - (0, globals_node_js_1.nextTick)(() => { - this._onClose("ping timeout"); - }, this.setTimeoutFn); - } - return hasExpired; + }; + + 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++; } - /** - * Sends a message. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - write(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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; } - /** - * Sends a message. Alias of {@link Socket#write}. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - send(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + }; + + 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; + } } - /** - * Sends a packet. - * - * @param {String} type: packet type. - * @param {String} data. - * @param {Object} options. - * @param {Function} fn - callback function. - * @private - */ - _sendPacket(type, data, options, fn) { - if ("function" === typeof data) { - fn = data; - data = undefined; - } - if ("function" === typeof options) { - fn = options; - options = null; - } - if ("closing" === this.readyState || "closed" === this.readyState) { - return; - } - options = options || {}; - options.compress = false !== options.compress; - const packet = { - type: type, - data: data, - options: options, - }; - this.emitReserved("packetCreate", packet); - this.writeBuffer.push(packet); - if (fn) - this.once("flush", fn); - this.flush(); + + 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; } - /** - * Closes the connection. - */ - close() { - const close = () => { - this._onClose("forced close"); - debug("socket closing - telling transport to close"); - this.transport.close(); - }; - const cleanupAndClose = () => { - this.off("upgrade", cleanupAndClose); - this.off("upgradeError", cleanupAndClose); - close(); - }; - const waitForUpgrade = () => { - // wait for upgrade to finish since we can't send packets while pausing a transport - this.once("upgrade", cleanupAndClose); - this.once("upgradeError", cleanupAndClose); - }; - if ("opening" === this.readyState || "open" === this.readyState) { - this.readyState = "closing"; - if (this.writeBuffer.length) { - this.once("drain", () => { - if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - }); - } - else if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - } - return this; + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; } - /** - * Called upon transport error - * - * @private - */ - _onError(err) { - debug("socket error %j", err); - SocketWithoutUpgrade.priorWebsocketSuccess = false; - if (this.opts.tryAllTransports && - this.transports.length > 1 && - this.readyState === "opening") { - debug("trying next transport"); - this.transports.shift(); - return this._open(); - } - this.emitReserved("error", err); - this._onClose("transport error", err); + + 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; } - /** - * Called upon transport close. - * - * @private - */ - _onClose(reason, description) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket close with reason: "%s"', reason); - // clear timers - this.clearTimeoutFn(this._pingTimeoutTimer); - // stop event from firing again for transport - this.transport.removeAllListeners("close"); - // ensure transport won't stay open - this.transport.close(); - // ignore further transport communication - this.transport.removeAllListeners(); - if (withEventListeners) { - if (this._beforeunloadEventListener) { - removeEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this._offlineEventListener) { - const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener); - if (i !== -1) { - debug("removing listener for the 'offline' event"); - OFFLINE_EVENT_LISTENERS.splice(i, 1); - } - } - } - // set ready state - this.readyState = "closed"; - // clear session id - this.id = null; - // emit close event - this.emitReserved("close", reason, description); - // clean buffers after, so users can still - // grab the buffers on `close` event - this.writeBuffer = []; - this._prevBufferLen = 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; } -} -exports.SocketWithoutUpgrade = SocketWithoutUpgrade; -SocketWithoutUpgrade.protocol = engine_io_parser_1.protocol; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see Socket - */ -class SocketWithUpgrade extends SocketWithoutUpgrade { - constructor() { - super(...arguments); - this._upgrades = []; + + 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; } - onOpen() { - super.onOpen(); - if ("open" === this.readyState && this.opts.upgrade) { - debug("starting upgrade probes"); - for (let i = 0; i < this._upgrades.length; i++) { - this._probe(this._upgrades[i]); - } - } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Probes a transport. - * - * @param {String} name - transport name - * @private - */ - _probe(name) { - debug('probing transport "%s"', name); - let transport = this.createTransport(name); - let failed = false; - SocketWithoutUpgrade.priorWebsocketSuccess = false; - const onTransportOpen = () => { - if (failed) - return; - debug('probe transport "%s" opened', name); - transport.send([{ type: "ping", data: "probe" }]); - transport.once("packet", (msg) => { - if (failed) - return; - if ("pong" === msg.type && "probe" === msg.data) { - debug('probe transport "%s" pong', name); - this.upgrading = true; - this.emitReserved("upgrading", transport); - if (!transport) - return; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === transport.name; - debug('pausing current transport "%s"', this.transport.name); - this.transport.pause(() => { - if (failed) - return; - if ("closed" === this.readyState) - return; - debug("changing transport and sending upgrade packet"); - cleanup(); - this.setTransport(transport); - transport.send([{ type: "upgrade" }]); - this.emitReserved("upgrade", transport); - transport = null; - this.upgrading = false; - this.flush(); - }); - } - else { - debug('probe transport "%s" failed', name); - const err = new Error("probe error"); - // @ts-ignore - err.transport = transport.name; - this.emitReserved("upgradeError", err); - } - }); - }; - function freezeTransport() { - if (failed) - return; - // Any callback called by transport should be ignored since now - failed = true; - cleanup(); - transport.close(); - transport = null; - } - // Handle any error that happens while probing - const onerror = (err) => { - const error = new Error("probe error: " + err); - // @ts-ignore - error.transport = transport.name; - freezeTransport(); - debug('probe transport "%s" failed because of error: %s', name, err); - this.emitReserved("upgradeError", error); - }; - function onTransportClose() { - onerror("transport closed"); - } - // When the socket is closed while we're probing - function onclose() { - onerror("socket closed"); - } - // When the socket is upgraded while we're probing - function onupgrade(to) { - if (transport && to.name !== transport.name) { - debug('"%s" works - aborting "%s"', to.name, transport.name); - freezeTransport(); - } - } - // Remove all listeners on the transport and on self - const cleanup = () => { - transport.removeListener("open", onTransportOpen); - transport.removeListener("error", onerror); - transport.removeListener("close", onTransportClose); - this.off("close", onclose); - this.off("upgrading", onupgrade); - }; - transport.once("open", onTransportOpen); - transport.once("error", onerror); - transport.once("close", onTransportClose); - this.once("close", onclose); - this.once("upgrading", onupgrade); - if (this._upgrades.indexOf("webtransport") !== -1 && - name !== "webtransport") { - // favor WebTransport - this.setTimeoutFn(() => { - if (!failed) { - transport.open(); - } - }, 200); - } - else { - transport.open(); - } + + 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; } - onHandshake(data) { - this._upgrades = this._filterUpgrades(data.upgrades); - super.onHandshake(data); + + 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); + } } - /** - * Filters upgrades, returning only those matching client transports. - * - * @param {Array} upgrades - server upgrades - * @private - */ - _filterUpgrades(upgrades) { - const filteredUpgrades = []; - for (let i = 0; i < upgrades.length; i++) { - if (~this.transports.indexOf(upgrades[i])) - filteredUpgrades.push(upgrades[i]); - } - return filteredUpgrades; + + 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++; + } } -} -exports.SocketWithUpgrade = SocketWithUpgrade; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * @example - * import { Socket } from "engine.io-client"; - * - * const socket = new Socket(); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see SocketWithUpgrade - */ -class Socket extends SocketWithUpgrade { - constructor(uri, opts = {}) { - const o = typeof uri === "object" ? uri : opts; - if (!o.transports || - (o.transports && typeof o.transports[0] === "string")) { - o.transports = (o.transports || ["polling", "websocket", "webtransport"]) - .map((transportName) => index_js_1.transports[transportName]) - .filter((t) => !!t); - } - super(uri, o); + + 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; } -} -exports.Socket = Socket; -},{"./contrib/parseqs.js":367,"./contrib/parseuri.js":368,"./globals.node.js":369,"./transports/index.js":373,"./util.js":379,"@socket.io/component-emitter":23,"debug":380,"engine.io-parser":386}],372:[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.Transport = exports.TransportError = void 0; -const engine_io_parser_1 = require("engine.io-parser"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() -class TransportError extends Error { - constructor(reason, description, context) { - super(reason); - this.description = description; - this.context = context; - this.type = "TransportError"; + 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; } -} -exports.TransportError = TransportError; -class Transport extends component_emitter_1.Emitter { - /** - * Transport abstract constructor. - * - * @param {Object} opts - options - * @protected - */ - constructor(opts) { - super(); - this.writable = false; - (0, util_js_1.installTimerFunctions)(this, opts); - this.opts = opts; - this.query = opts.query; - this.socket = opts.socket; - this.supportsBinary = !opts.forceBase64; + + 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; } - /** - * Emits an error. - * - * @param {String} reason - * @param description - * @param context - the error context - * @return {Transport} for chaining - * @protected - */ - onError(reason, description, context) { - super.emitReserved("error", new TransportError(reason, description, context)); - return this; + + 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; } - /** - * Opens the transport. - */ - open() { - this.readyState = "opening"; - this.doOpen(); - return this; + + 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; } - /** - * Closes the transport. - */ - close() { - if (this.readyState === "opening" || this.readyState === "open") { - this.doClose(); - this.onClose(); - } - return this; + + // 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; } - /** - * Sends multiple packets. - * - * @param {Array} packets - */ - send(packets) { - if (this.readyState === "open") { - this.write(packets); - } - else { - // this might happen if the transport was silently closed in the beforeunload event handler - debug("transport is not open, discarding packets"); - } + + if (r !== 0) { + s++; } - /** - * Called upon open - * - * @protected - */ - onOpen() { - this.readyState = "open"; - this.writable = true; - super.emitReserved("open"); + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; } - /** - * Called with data. - * - * @param {String} data - * @protected - */ - onData(data) { - const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); - this.onPacket(packet); + + 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; } - /** - * Called with a decoded packet. - * - * @protected - */ - onPacket(packet) { - super.emitReserved("packet", packet); + + // 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]++; + } } - /** - * Called upon close. - * - * @protected - */ - onClose(details) { - this.readyState = "closed"; - super.emitReserved("close", details); + 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; } - /** - * Pauses the transport, in order not to lose packets during an upgrade. - * - * @param onPause - */ - pause(onPause) { } - createUri(schema, query = {}) { - return (schema + - "://" + - this._hostname() + - this._port() + - this.opts.path + - this._query(query)); + + 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; + } } - _hostname() { - const hostname = this.opts.hostname; - return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + + 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; } - _port() { - if (this.opts.port && - ((this.opts.secure && Number(this.opts.port !== 443)) || - (!this.opts.secure && Number(this.opts.port) !== 80))) { - return ":" + this.opts.port; - } - else { - return ""; - } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; } - _query(query) { - const encodedQuery = (0, parseqs_js_1.encode)(query); - return encodedQuery.length ? "?" + encodedQuery : ""; + + 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; } -} -exports.Transport = Transport; + this.negative = 1; -},{"./contrib/parseqs.js":367,"./util.js":379,"@socket.io/component-emitter":23,"debug":380,"engine.io-parser":386}],373:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transports = void 0; -const polling_xhr_node_js_1 = require("./polling-xhr.node.js"); -const websocket_node_js_1 = require("./websocket.node.js"); -const webtransport_js_1 = require("./webtransport.js"); -exports.transports = { - websocket: websocket_node_js_1.WS, - webtransport: webtransport_js_1.WT, - polling: polling_xhr_node_js_1.XHR, -}; + return this.strip(); + }; -},{"./polling-xhr.node.js":375,"./websocket.node.js":377,"./webtransport.js":378}],374:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Fetch = void 0; -const polling_js_1 = require("./polling.js"); -/** - * HTTP long-polling based on the built-in `fetch()` method. - * - * Usage: browser, Node.js (since v18), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch - * @see https://caniuse.com/fetch - * @see https://nodejs.org/api/globals.html#fetch - */ -class Fetch extends polling_js_1.Polling { - doPoll() { - this._fetch() - .then((res) => { - if (!res.ok) { - return this.onError("fetch read error", res.status, res); - } - res.text().then((data) => this.onData(data)); - }) - .catch((err) => { - this.onError("fetch read error", err); - }); + 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; } - doWrite(data, callback) { - this._fetch(data) - .then((res) => { - if (!res.ok) { - return this.onError("fetch write error", res.status, res); - } - callback(); - }) - .catch((err) => { - this.onError("fetch write error", err); - }); + + // 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; + } } - _fetch(data) { - var _a; - const isPost = data !== undefined; - const headers = new Headers(this.opts.extraHeaders); - if (isPost) { - headers.set("content-type", "text/plain;charset=UTF-8"); - } - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.appendCookies(headers); - return fetch(this.uri(), { - method: isPost ? "POST" : "GET", - body: isPost ? data : null, - headers, - credentials: this.opts.withCredentials ? "include" : "omit", - }).then((res) => { - var _a; - // @ts-ignore getSetCookie() was added in Node.js v19.7.0 - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(res.headers.getSetCookie()); - return res; - }); + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } } -} -exports.Fetch = Fetch; -},{"./polling.js":376}],375:[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.XHR = exports.Request = exports.BaseXHR = void 0; -const polling_js_1 = require("./polling.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("../util.js"); -const globals_node_js_1 = require("../globals.node.js"); -const has_cors_js_1 = require("../contrib/has-cors.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -function empty() { } -class BaseXHR extends polling_js_1.Polling { - /** - * XHR Polling constructor. - * - * @param {Object} opts - * @package - */ - constructor(opts) { - super(opts); - if (typeof location !== "undefined") { - const isSSL = "https:" === location.protocol; - let port = location.port; - // some user agents have empty `location.port` - if (!port) { - port = isSSL ? "443" : "80"; - } - this.xd = - (typeof location !== "undefined" && - opts.hostname !== location.hostname) || - port !== opts.port; + 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; + } } - /** - * Sends data. - * - * @param {String} data to send. - * @param {Function} called upon flush. - * @private - */ - doWrite(data, fn) { - const req = this.request({ - method: "POST", - data: data, - }); - req.on("success", fn); - req.on("error", (xhrStatus, context) => { - this.onError("xhr post error", xhrStatus, context); - }); + if (q) { + q.strip(); } - /** - * Starts a poll cycle. - * - * @private - */ - doPoll() { - debug("xhr poll"); - const req = this.request(); - req.on("data", this.onData.bind(this)); - req.on("error", (xhrStatus, context) => { - this.onError("xhr poll error", xhrStatus, context); - }); - this.pollXhr = req; + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); } -} -exports.BaseXHR = BaseXHR; -class Request extends component_emitter_1.Emitter { - /** - * Request constructor - * - * @param {Object} options - * @package - */ - constructor(createRequest, uri, opts) { - super(); - this.createRequest = createRequest; - (0, util_js_1.installTimerFunctions)(this, opts); - this._opts = opts; - this._method = opts.method || "GET"; - this._uri = uri; - this._data = undefined !== opts.data ? opts.data : null; - this._create(); + + 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) + }; } - /** - * Creates the XHR object and sends the request. - * - * @private - */ - _create() { - var _a; - const opts = (0, util_js_1.pick)(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); - opts.xdomain = !!this._opts.xd; - const xhr = (this._xhr = this.createRequest(opts)); - try { - debug("xhr open %s: %s", this._method, this._uri); - xhr.open(this._method, this._uri, true); - try { - if (this._opts.extraHeaders) { - // @ts-ignore - xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); - for (let i in this._opts.extraHeaders) { - if (this._opts.extraHeaders.hasOwnProperty(i)) { - xhr.setRequestHeader(i, this._opts.extraHeaders[i]); - } - } - } - } - catch (e) { } - if ("POST" === this._method) { - try { - xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); - } - catch (e) { } - } - try { - xhr.setRequestHeader("Accept", "*/*"); - } - catch (e) { } - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); - // ie6 check - if ("withCredentials" in xhr) { - xhr.withCredentials = this._opts.withCredentials; - } - if (this._opts.requestTimeout) { - xhr.timeout = this._opts.requestTimeout; - } - xhr.onreadystatechange = () => { - var _a; - if (xhr.readyState === 3) { - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies( - // @ts-ignore - xhr.getResponseHeader("set-cookie")); - } - if (4 !== xhr.readyState) - return; - if (200 === xhr.status || 1223 === xhr.status) { - this._onLoad(); - } - else { - // make sure the `error` event handler that's user-set - // does not throw in the same tick and gets caught here - this.setTimeoutFn(() => { - this._onError(typeof xhr.status === "number" ? xhr.status : 0); - }, 0); - } - }; - debug("xhr data %s", this._data); - xhr.send(this._data); - } - catch (e) { - // Need to defer since .create() is called directly from the constructor - // and thus the 'error' event can only be only bound *after* this exception - // occurs. Therefore, also, we cannot throw here at all. - this.setTimeoutFn(() => { - this._onError(e); - }, 0); - return; - } - if (typeof document !== "undefined") { - this._index = Request.requestsCount++; - Request.requests[this._index] = this; + + 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 + }; } - /** - * Called upon error. - * - * @private - */ - _onError(err) { - this.emitReserved("error", err, this._xhr); - this._cleanup(true); + + 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 + }; } - /** - * Cleans up house. - * - * @private - */ - _cleanup(fromError) { - if ("undefined" === typeof this._xhr || null === this._xhr) { - return; - } - this._xhr.onreadystatechange = empty; - if (fromError) { - try { - this._xhr.abort(); - } - catch (e) { } - } - if (typeof document !== "undefined") { - delete Request.requests[this._index]; + + 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); } - this._xhr = null; + } + + 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])) + }; } - /** - * Called upon load. - * - * @private - */ - _onLoad() { - const data = this._xhr.responseText; - if (data !== null) { - this.emitReserved("data", data); - this.emitReserved("success"); - this._cleanup(); - } + + 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; } - /** - * Aborts the request. - * - * @package - */ - abort() { - this._cleanup(); + + 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; } -} -exports.Request = Request; -Request.requestsCount = 0; -Request.requests = {}; -/** - * Aborts pending requests when unloading the window. This is needed to prevent - * memory leaks (e.g. when using IE) and to ensure that no spurious error is - * emitted. - */ -if (typeof document !== "undefined") { - // @ts-ignore - if (typeof attachEvent === "function") { - // @ts-ignore - attachEvent("onunload", unloadHandler); + + 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(); } - else if (typeof addEventListener === "function") { - const terminationEvent = "onpagehide" in globals_node_js_1.globalThisShim ? "pagehide" : "unload"; - addEventListener(terminationEvent, unloadHandler, false); + + // 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; } -} -function unloadHandler() { - for (let i in Request.requests) { - if (Request.requests.hasOwnProperty(i)) { - Request.requests[i].abort(); + + 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); + } } -} -const hasXHR2 = (function () { - const xhr = newRequest({ - xdomain: false, - }); - return xhr && xhr.responseType !== null; -})(); -/** - * HTTP long-polling based on the built-in `XMLHttpRequest` object. - * - * Usage: browser - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - */ -class XHR extends BaseXHR { - constructor(opts) { - super(opts); - const forceBase64 = opts && opts.forceBase64; - this.supportsBinary = hasXHR2 && !forceBase64; - } - request(opts = {}) { - Object.assign(opts, { xd: this.xd }, this.opts); - return new Request(newRequest, this.uri(), opts); + + 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(); } -} -exports.XHR = XHR; -function newRequest(opts) { - const xdomain = opts.xdomain; - // XMLHttpRequest can be disabled on IE - try { - if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { - return new XMLHttpRequest(); + + 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); } - } - catch (e) { } - if (!xdomain) { - try { - return new globals_node_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + + 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); } - catch (e) { } - } -} + } -},{"../contrib/has-cors.js":366,"../globals.node.js":369,"../util.js":379,"./polling.js":376,"@socket.io/component-emitter":23,"debug":380}],376:[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.Polling = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -class Polling extends transport_js_1.Transport { - constructor() { - super(...arguments); - this._polling = false; + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } } - get name() { - return "polling"; + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; } - /** - * Opens the socket (triggers polling). We write a PING message to determine - * when the transport is open. - * - * @protected - */ - doOpen() { - this._poll(); + + if (res.cmpn(0) < 0) { + res.iadd(p); } - /** - * Pauses polling. - * - * @param {Function} onPause - callback upon buffers are flushed and transport is paused - * @package - */ - pause(onPause) { - this.readyState = "pausing"; - const pause = () => { - debug("paused"); - this.readyState = "paused"; - onPause(); - }; - if (this._polling || !this.writable) { - let total = 0; - if (this._polling) { - debug("we are currently polling - waiting to pause"); - total++; - this.once("pollComplete", function () { - debug("pre-pause polling complete"); - --total || pause(); - }); - } - if (!this.writable) { - debug("we are currently writing - waiting to pause"); - total++; - this.once("drain", function () { - debug("pre-pause writing complete"); - --total || pause(); - }); - } - } - else { - pause(); - } + + 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); } - /** - * Starts polling cycle. - * - * @private - */ - _poll() { - debug("polling"); - this._polling = true; - this.doPoll(); - this.emitReserved("poll"); + + 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; } - /** - * Overloads onData to detect payloads. - * - * @protected - */ - onData(data) { - debug("polling got data %s", data); - const callback = (packet) => { - // if its the first message we consider the transport open - if ("opening" === this.readyState && packet.type === "open") { - this.onOpen(); - } - // if its a close packet, we close the ongoing requests - if ("close" === packet.type) { - this.onClose({ description: "transport closed by the server" }); - return false; - } - // otherwise bypass onData and handle the message - this.onPacket(packet); - }; - // decode payload - (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); - // if an event did not trigger closing - if ("closed" !== this.readyState) { - // if we got data we're not polling - this._polling = false; - this.emitReserved("pollComplete"); - if ("open" === this.readyState) { - this._poll(); - } - else { - debug('ignoring poll - transport state "%s"', this.readyState); - } - } + + // 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; } - /** - * For polling, send a close packet. - * - * @protected - */ - doClose() { - const close = () => { - debug("writing close packet"); - this.write([{ type: "close" }]); - }; - if ("open" === this.readyState) { - debug("transport open - closing"); - close(); - } - else { - // in case we're trying to close while - // handshaking is in progress (GH-164) - debug("transport not open - deferring close"); - this.once("open", close); - } + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Writes a packets payload. - * - * @param {Array} packets - data packets - * @protected - */ - write(packets) { - this.writable = false; - (0, engine_io_parser_1.encodePayload)(packets, (data) => { - this.doWrite(data, () => { - this.writable = true; - this.emitReserved("drain"); - }); - }); + 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; } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "https" : "http"; - const query = this.query || {}; - // cache busting is forced - if (false !== this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - if (!this.supportsBinary && !query.sid) { - query.b64 = 1; - } - return this.createUri(schema, query); + 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(); + } } -} -exports.Polling = Polling; -},{"../transport.js":372,"../util.js":379,"debug":380,"engine.io-parser":386}],377:[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.WS = exports.BaseWS = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("../globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() -// detect ReactNative environment -const isReactNative = typeof navigator !== "undefined" && - typeof navigator.product === "string" && - navigator.product.toLowerCase() === "reactnative"; -class BaseWS extends transport_js_1.Transport { - get name() { - return "websocket"; - } - doOpen() { - const uri = this.uri(); - const protocols = this.opts.protocols; - // React Native only supports the 'headers' option, and will print a warning if anything else is passed - const opts = isReactNative - ? {} - : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); - if (this.opts.extraHeaders) { - opts.headers = this.opts.extraHeaders; - } - try { - this.ws = this.createSocket(uri, protocols, opts); - } - catch (err) { - return this.emitReserved("error", err); - } - this.ws.binaryType = this.socket.binaryType; - this.addEventListeners(); - } - /** - * Adds event listeners to the socket - * - * @private - */ - addEventListeners() { - this.ws.onopen = () => { - if (this.opts.autoUnref) { - this.ws._socket.unref(); - } - this.onOpen(); - }; - this.ws.onclose = (closeEvent) => this.onClose({ - description: "websocket connection closed", - context: closeEvent, - }); - this.ws.onmessage = (ev) => this.onData(ev.data); - this.ws.onerror = (e) => this.onError("websocket error", e); - } - write(packets) { - this.writable = false; - // encodePacket efficient as it uses WS framing - // no need for encodePayload - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { - // Sometimes the websocket has already been closed but the browser didn't - // have a chance of informing us about it yet, in that case send will - // throw an error - try { - this.doWrite(packet, data); - } - catch (e) { - debug("websocket closed before onclose event"); - } - if (lastPacket) { - // fake drain - // defer to next tick to allow Socket to clear writeBuffer - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } - } - doClose() { - if (typeof this.ws !== "undefined") { - this.ws.onerror = () => { }; - this.ws.close(); - this.ws = null; - } - } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "wss" : "ws"; - const query = this.query || {}; - // append timestamp to URI - if (this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - // communicate binary support capabilities - if (!this.supportsBinary) { - query.b64 = 1; - } - return this.createUri(schema, query); - } -} -exports.BaseWS = BaseWS; -const WebSocketCtor = globals_node_js_1.globalThisShim.WebSocket || globals_node_js_1.globalThisShim.MozWebSocket; -/** - * WebSocket transport based on the built-in `WebSocket` object. - * - * Usage: browser, Node.js (since v21), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket - * @see https://caniuse.com/mdn-api_websocket - * @see https://nodejs.org/api/globals.html#websocket - */ -class WS extends BaseWS { - createSocket(uri, protocols, opts) { - return !isReactNative - ? protocols - ? new WebSocketCtor(uri, protocols) - : new WebSocketCtor(uri) - : new WebSocketCtor(uri, protocols, opts); + 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]; } - doWrite(_packet, data) { - this.ws.send(data); + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; } -} -exports.WS = WS; -},{"../globals.node.js":369,"../transport.js":372,"../util.js":379,"debug":380,"engine.io-parser":386}],378:[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.WT = void 0; -const transport_js_1 = require("../transport.js"); -const globals_node_js_1 = require("../globals.node.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() -/** - * WebTransport transport based on the built-in `WebTransport` object. - * - * Usage: browser, Node.js (with the `@fails-components/webtransport` package) - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport - * @see https://caniuse.com/webtransport - */ -class WT extends transport_js_1.Transport { - get name() { - return "webtransport"; + // 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; } - doOpen() { - try { - // @ts-ignore - this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); - } - catch (err) { - return this.emitReserved("error", err); - } - this._transport.closed - .then(() => { - debug("transport closed gracefully"); - this.onClose(); - }) - .catch((err) => { - debug("transport closed due to %s", err); - this.onError("webtransport error", err); - }); - // note: we could have used async/await, but that would require some additional polyfills - this._transport.ready.then(() => { - this._transport.createBidirectionalStream().then((stream) => { - const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); - const reader = stream.readable.pipeThrough(decoderStream).getReader(); - const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); - encoderStream.readable.pipeTo(stream.writable); - this._writer = encoderStream.writable.getWriter(); - const read = () => { - reader - .read() - .then(({ done, value }) => { - if (done) { - debug("session is closed"); - return; - } - debug("received chunk: %o", value); - this.onPacket(value); - read(); - }) - .catch((err) => { - debug("an error occurred while reading: %s", err); - }); - }; - read(); - const packet = { type: "open" }; - if (this.query.sid) { - packet.data = `{"sid":"${this.query.sid}"}`; - } - this._writer.write(packet).then(() => this.onOpen()); - }); - }); + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; } - write(packets) { - this.writable = false; - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - this._writer.write(packet).then(() => { - if (lastPacket) { - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } + }; + + 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); } - doClose() { - var _a; - (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close(); + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } } -} -exports.WT = WT; + return num; + }; -},{"../globals.node.js":369,"../transport.js":372,"debug":380,"engine.io-parser":386}],379:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.pick = pick; -exports.installTimerFunctions = installTimerFunctions; -exports.byteLength = byteLength; -exports.randomString = randomString; -const globals_node_js_1 = require("./globals.node.js"); -function pick(obj, ...attr) { - return attr.reduce((acc, k) => { - if (obj.hasOwnProperty(k)) { - acc[k] = obj[k]; - } - return acc; - }, {}); -} -// Keep a reference to the real timeout functions so they can be used when overridden -const NATIVE_SET_TIMEOUT = globals_node_js_1.globalThisShim.setTimeout; -const NATIVE_CLEAR_TIMEOUT = globals_node_js_1.globalThisShim.clearTimeout; -function installTimerFunctions(obj, opts) { - if (opts.useNativeTimers) { - obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globals_node_js_1.globalThisShim); - } - else { - obj.setTimeoutFn = globals_node_js_1.globalThisShim.setTimeout.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = globals_node_js_1.globalThisShim.clearTimeout.bind(globals_node_js_1.globalThisShim); + 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; } -} -// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) -const BASE64_OVERHEAD = 1.33; -// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 -function byteLength(obj) { - if (typeof obj === "string") { - return utf8Length(obj); + if (carry !== 0) { + num.words[num.length++] = carry; } - // arraybuffer or blob - return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); -} -function utf8Length(str) { - let c = 0, length = 0; - for (let i = 0, l = str.length; i < l; i++) { - c = str.charCodeAt(i); - if (c < 0x80) { - length += 1; - } - else if (c < 0x800) { - length += 2; - } - else if (c < 0xd800 || c >= 0xe000) { - length += 3; - } - else { - i++; - length += 4; - } + 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); } - return length; -} -/** - * Generates a random 8-characters string. - */ -function randomString() { - return (Date.now().toString(36).substring(3) + - Math.random().toString(36).substring(2, 5)); -} + primes[name] = prime; -},{"./globals.node.js":369}],380:[function(require,module,exports){ -(function (process){(function (){ -/* eslint-env browser */ + return prime; + }; -/** - * This is the web browser implementation of `debug()`. - */ + // + // 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; + } + } -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); + 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'); + }; -/** - * Colors. - */ + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ + return this.m.sub(a)._forceRed(this); + }; -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } + Red.prototype.add = function add (a, b) { + this._verify2(a, b); - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; - let m; + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; - if (!this.useColors) { - return; - } + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; - args.splice(lastC, 0, c); -} + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); - return r; -} + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + // 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()); -module.exports = require('./common')(exports); + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); -const {formatters} = module.exports; + // 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); -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; + 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)); -}).call(this)}).call(this,require('_process')) -},{"./common":381,"_process":447}],381:[function(require,module,exports){ + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ + return r; + }; -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - createDebug.destroy = destroy; + 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); + } + }; - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); - /** - * The currently active debug mode names, and names to skip. - */ + 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); + } - createDebug.names = []; - createDebug.skips = []; + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + 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); + } - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; + return res; + }; - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); - const self = debug; + return r === num ? r.clone() : r; + }; - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; - args[0] = createDebug.coerce(args[0]); + // + // Montgomery method engine + // - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } + BN.mont = function mont (num) { + return new Mont(num); + }; - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); + function Mont (m) { + Red.call(this, m); - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } + 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); - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } + 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; - return debug; - } + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } + return res._forceRed(this); + }; - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - createDebug.names = []; - createDebug.skips = []; + 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); + } - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; + return res._forceRed(this); + }; - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } + 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":32}],360:[function(require,module,exports){ +module.exports={ + "name": "elliptic", + "version": "6.5.5", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "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" + }, + "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" + } +} - namespaces = split[i].replace(/\*/g, '.*?'); +},{}],361:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hasCORS = void 0; +// imported from https://github.com/component/has-cors +let value = false; +try { + value = typeof XMLHttpRequest !== 'undefined' && + 'withCredentials' in new XMLHttpRequest(); +} +catch (err) { + // if XMLHttp support is disabled in IE then it will throw + // when trying to create +} +exports.hasCORS = value; - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } +},{}],362:[function(require,module,exports){ +"use strict"; +// imported from https://github.com/galkn/querystring +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decode = exports.encode = void 0; +function encode(obj) { + let str = ''; + for (let i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) + str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + return str; +} +exports.encode = encode; +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ +function decode(qs) { + let qry = {}; + let pairs = qs.split('&'); + for (let i = 0, l = pairs.length; i < l; i++) { + let pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +} +exports.decode = decode; - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } +},{}],363:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parse = void 0; +// imported from https://github.com/galkn/parseuri +/** + * Parses a URI + * + * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. + * + * See: + * - https://developer.mozilla.org/en-US/docs/Web/API/URL + * - https://caniuse.com/url + * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B + * + * History of the parse() method: + * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c + * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 + * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 + * + * @author Steven Levithan (MIT license) + * @api private + */ +const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; +const parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; +function parse(str) { + if (str.length > 2000) { + throw "URI too long"; + } + const src = str, b = str.indexOf('['), e = str.indexOf(']'); + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + let m = re.exec(str || ''), uri = {}, i = 14; + while (i--) { + uri[parts[i]] = m[i] || ''; + } + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + return uri; +} +exports.parse = parse; +function pathNames(obj, path) { + const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); + if (path.slice(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.slice(-1) == '/') { + names.splice(names.length - 1, 1); + } + return names; +} +function queryKey(uri, query) { + const data = {}; + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + return data; +} - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } +},{}],364:[function(require,module,exports){ +// imported from https://github.com/unshiftio/yeast +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.yeast = exports.decode = exports.encode = void 0; +const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''), length = 64, map = {}; +let seed = 0, i = 0, prev; +/** + * Return a string representing the specified number. + * + * @param {Number} num The number to convert. + * @returns {String} The string representation of the number. + * @api public + */ +function encode(num) { + let encoded = ''; + do { + encoded = alphabet[num % length] + encoded; + num = Math.floor(num / length); + } while (num > 0); + return encoded; +} +exports.encode = encode; +/** + * Return the integer value specified by the given string. + * + * @param {String} str The string to convert. + * @returns {Number} The integer value represented by the string. + * @api public + */ +function decode(str) { + let decoded = 0; + for (i = 0; i < str.length; i++) { + decoded = decoded * length + map[str.charAt(i)]; + } + return decoded; +} +exports.decode = decode; +/** + * Yeast: A tiny growing id generator. + * + * @returns {String} A unique id. + * @api public + */ +function yeast() { + const now = encode(+new Date()); + if (now !== prev) + return seed = 0, prev = now; + return now + '.' + encode(seed++); +} +exports.yeast = yeast; +// +// Map each character to its index. +// +for (; i < length; i++) + map[alphabet[i]] = i; - let i; - let len; +},{}],365:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalThisShim = void 0; +exports.globalThisShim = (() => { + if (typeof self !== "undefined") { + return self; + } + else if (typeof window !== "undefined") { + return window; + } + else { + return Function("return this")(); + } +})(); - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } +},{}],366:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0; +const socket_js_1 = require("./socket.js"); +Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); +exports.protocol = socket_js_1.Socket.protocol; +var transport_js_1 = require("./transport.js"); +Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); +Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); +var index_js_1 = require("./transports/index.js"); +Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); +var util_js_1 = require("./util.js"); +Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); +var parseuri_js_1 = require("./contrib/parseuri.js"); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); +var websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return websocket_constructor_js_1.nextTick; } }); + +},{"./contrib/parseuri.js":363,"./socket.js":367,"./transport.js":368,"./transports/index.js":369,"./transports/websocket-constructor.js":371,"./util.js":375}],367:[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.Socket = void 0; +const index_js_1 = require("./transports/index.js"); +const util_js_1 = require("./util.js"); +const parseqs_js_1 = require("./contrib/parseqs.js"); +const parseuri_js_1 = require("./contrib/parseuri.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const component_emitter_1 = require("@socket.io/component-emitter"); +const engine_io_parser_1 = require("engine.io-parser"); +const websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() +class Socket extends component_emitter_1.Emitter { + /** + * Socket constructor. + * + * @param {String|Object} uri - uri or options + * @param {Object} opts - options + */ + constructor(uri, opts = {}) { + super(); + this.binaryType = websocket_constructor_js_1.defaultBinaryType; + this.writeBuffer = []; + if (uri && "object" === typeof uri) { + opts = uri; + uri = null; + } + if (uri) { + uri = (0, parseuri_js_1.parse)(uri); + opts.hostname = uri.host; + opts.secure = uri.protocol === "https" || uri.protocol === "wss"; + opts.port = uri.port; + if (uri.query) + opts.query = uri.query; + } + else if (opts.host) { + opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; + } + (0, util_js_1.installTimerFunctions)(this, opts); + this.secure = + null != opts.secure + ? opts.secure + : typeof location !== "undefined" && "https:" === location.protocol; + if (opts.hostname && !opts.port) { + // if no port is specified manually, use the protocol default + opts.port = this.secure ? "443" : "80"; + } + this.hostname = + opts.hostname || + (typeof location !== "undefined" ? location.hostname : "localhost"); + this.port = + opts.port || + (typeof location !== "undefined" && location.port + ? location.port + : this.secure + ? "443" + : "80"); + this.transports = opts.transports || [ + "polling", + "websocket", + "webtransport", + ]; + this.writeBuffer = []; + this.prevBufferLen = 0; + this.opts = Object.assign({ + path: "/engine.io", + agent: false, + withCredentials: false, + upgrade: true, + timestampParam: "t", + rememberUpgrade: false, + addTrailingSlash: true, + rejectUnauthorized: true, + perMessageDeflate: { + threshold: 1024, + }, + transportOptions: {}, + closeOnBeforeunload: false, + }, opts); + this.opts.path = + this.opts.path.replace(/\/$/, "") + + (this.opts.addTrailingSlash ? "/" : ""); + if (typeof this.opts.query === "string") { + this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); + } + // set on handshake + this.id = null; + this.upgrades = null; + this.pingInterval = null; + this.pingTimeout = null; + // set on heartbeat + this.pingTimeoutTimer = null; + if (typeof addEventListener === "function") { + if (this.opts.closeOnBeforeunload) { + // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener + // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is + // closed/reloaded) + this.beforeunloadEventListener = () => { + if (this.transport) { + // silently close the transport + this.transport.removeAllListeners(); + this.transport.close(); + } + }; + addEventListener("beforeunload", this.beforeunloadEventListener, false); + } + if (this.hostname !== "localhost") { + this.offlineEventListener = () => { + this.onClose("transport close", { + description: "network connection lost", + }); + }; + addEventListener("offline", this.offlineEventListener, false); + } + } + this.open(); + } + /** + * Creates transport of the given type. + * + * @param {String} name - transport name + * @return {Transport} + * @private + */ + createTransport(name) { + debug('creating transport "%s"', name); + const query = Object.assign({}, this.opts.query); + // append engine.io protocol identifier + query.EIO = engine_io_parser_1.protocol; + // transport name + query.transport = name; + // session id if we already have one + if (this.id) + query.sid = this.id; + const opts = Object.assign({}, this.opts, { + query, + socket: this, + hostname: this.hostname, + secure: this.secure, + port: this.port, + }, this.opts.transportOptions[name]); + debug("options: %j", opts); + return new index_js_1.transports[name](opts); + } + /** + * Initializes transport to use and starts probe. + * + * @private + */ + open() { + let transport; + if (this.opts.rememberUpgrade && + Socket.priorWebsocketSuccess && + this.transports.indexOf("websocket") !== -1) { + transport = "websocket"; + } + else if (0 === this.transports.length) { + // Emit error on next tick so it can be listened to + this.setTimeoutFn(() => { + this.emitReserved("error", "No transports available"); + }, 0); + return; + } + else { + transport = this.transports[0]; + } + this.readyState = "opening"; + // Retry with the next transport if the transport is disabled (jsonp: false) + try { + transport = this.createTransport(transport); + } + catch (e) { + debug("error while creating transport: %s", e); + this.transports.shift(); + this.open(); + return; + } + transport.open(); + this.setTransport(transport); + } + /** + * Sets the current transport. Disables the existing one (if any). + * + * @private + */ + setTransport(transport) { + debug("setting transport %s", transport.name); + if (this.transport) { + debug("clearing existing transport %s", this.transport.name); + this.transport.removeAllListeners(); + } + // set up transport + this.transport = transport; + // set up transport listeners + transport + .on("drain", this.onDrain.bind(this)) + .on("packet", this.onPacket.bind(this)) + .on("error", this.onError.bind(this)) + .on("close", (reason) => this.onClose("transport close", reason)); + } + /** + * Probes a transport. + * + * @param {String} name - transport name + * @private + */ + probe(name) { + debug('probing transport "%s"', name); + let transport = this.createTransport(name); + let failed = false; + Socket.priorWebsocketSuccess = false; + const onTransportOpen = () => { + if (failed) + return; + debug('probe transport "%s" opened', name); + transport.send([{ type: "ping", data: "probe" }]); + transport.once("packet", (msg) => { + if (failed) + return; + if ("pong" === msg.type && "probe" === msg.data) { + debug('probe transport "%s" pong', name); + this.upgrading = true; + this.emitReserved("upgrading", transport); + if (!transport) + return; + Socket.priorWebsocketSuccess = "websocket" === transport.name; + debug('pausing current transport "%s"', this.transport.name); + this.transport.pause(() => { + if (failed) + return; + if ("closed" === this.readyState) + return; + debug("changing transport and sending upgrade packet"); + cleanup(); + this.setTransport(transport); + transport.send([{ type: "upgrade" }]); + this.emitReserved("upgrade", transport); + transport = null; + this.upgrading = false; + this.flush(); + }); + } + else { + debug('probe transport "%s" failed', name); + const err = new Error("probe error"); + // @ts-ignore + err.transport = transport.name; + this.emitReserved("upgradeError", err); + } + }); + }; + function freezeTransport() { + if (failed) + return; + // Any callback called by transport should be ignored since now + failed = true; + cleanup(); + transport.close(); + transport = null; + } + // Handle any error that happens while probing + const onerror = (err) => { + const error = new Error("probe error: " + err); + // @ts-ignore + error.transport = transport.name; + freezeTransport(); + debug('probe transport "%s" failed because of error: %s', name, err); + this.emitReserved("upgradeError", error); + }; + function onTransportClose() { + onerror("transport closed"); + } + // When the socket is closed while we're probing + function onclose() { + onerror("socket closed"); + } + // When the socket is upgraded while we're probing + function onupgrade(to) { + if (transport && to.name !== transport.name) { + debug('"%s" works - aborting "%s"', to.name, transport.name); + freezeTransport(); + } + } + // Remove all listeners on the transport and on self + const cleanup = () => { + transport.removeListener("open", onTransportOpen); + transport.removeListener("error", onerror); + transport.removeListener("close", onTransportClose); + this.off("close", onclose); + this.off("upgrading", onupgrade); + }; + transport.once("open", onTransportOpen); + transport.once("error", onerror); + transport.once("close", onTransportClose); + this.once("close", onclose); + this.once("upgrading", onupgrade); + if (this.upgrades.indexOf("webtransport") !== -1 && + name !== "webtransport") { + // favor WebTransport + this.setTimeoutFn(() => { + if (!failed) { + transport.open(); + } + }, 200); + } + else { + transport.open(); + } + } + /** + * Called when connection is deemed open. + * + * @private + */ + onOpen() { + debug("socket open"); + this.readyState = "open"; + Socket.priorWebsocketSuccess = "websocket" === this.transport.name; + this.emitReserved("open"); + this.flush(); + // we check for `readyState` in case an `open` + // listener already closed the socket + if ("open" === this.readyState && this.opts.upgrade) { + debug("starting upgrade probes"); + let i = 0; + const l = this.upgrades.length; + for (; i < l; i++) { + this.probe(this.upgrades[i]); + } + } + } + /** + * Handles a packet. + * + * @private + */ + onPacket(packet) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket receive: type "%s", data "%s"', packet.type, packet.data); + this.emitReserved("packet", packet); + // Socket is live - any packet counts + this.emitReserved("heartbeat"); + this.resetPingTimeout(); + switch (packet.type) { + case "open": + this.onHandshake(JSON.parse(packet.data)); + break; + case "ping": + this.sendPacket("pong"); + this.emitReserved("ping"); + this.emitReserved("pong"); + break; + case "error": + const err = new Error("server error"); + // @ts-ignore + err.code = packet.data; + this.onError(err); + break; + case "message": + this.emitReserved("data", packet.data); + this.emitReserved("message", packet.data); + break; + } + } + else { + debug('packet received with socket readyState "%s"', this.readyState); + } + } + /** + * Called upon handshake completion. + * + * @param {Object} data - handshake obj + * @private + */ + onHandshake(data) { + this.emitReserved("handshake", data); + this.id = data.sid; + this.transport.query.sid = data.sid; + this.upgrades = this.filterUpgrades(data.upgrades); + this.pingInterval = data.pingInterval; + this.pingTimeout = data.pingTimeout; + this.maxPayload = data.maxPayload; + this.onOpen(); + // In case open handler closes socket + if ("closed" === this.readyState) + return; + this.resetPingTimeout(); + } + /** + * Sets and resets ping timeout timer based on server pings. + * + * @private + */ + resetPingTimeout() { + this.clearTimeoutFn(this.pingTimeoutTimer); + this.pingTimeoutTimer = this.setTimeoutFn(() => { + this.onClose("ping timeout"); + }, this.pingInterval + this.pingTimeout); + if (this.opts.autoUnref) { + this.pingTimeoutTimer.unref(); + } + } + /** + * Called on `drain` event + * + * @private + */ + onDrain() { + this.writeBuffer.splice(0, this.prevBufferLen); + // setting prevBufferLen = 0 is very important + // for example, when upgrading, upgrade packet is sent over, + // and a nonzero prevBufferLen could cause problems on `drain` + this.prevBufferLen = 0; + if (0 === this.writeBuffer.length) { + this.emitReserved("drain"); + } + else { + this.flush(); + } + } + /** + * Flush write buffers. + * + * @private + */ + flush() { + if ("closed" !== this.readyState && + this.transport.writable && + !this.upgrading && + this.writeBuffer.length) { + const packets = this.getWritablePackets(); + debug("flushing %d packets in socket", packets.length); + this.transport.send(packets); + // keep track of current length of writeBuffer + // splice writeBuffer and callbackBuffer on `drain` + this.prevBufferLen = packets.length; + this.emitReserved("flush"); + } + } + /** + * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP + * long-polling) + * + * @private + */ + getWritablePackets() { + const shouldCheckPayloadSize = this.maxPayload && + this.transport.name === "polling" && + this.writeBuffer.length > 1; + if (!shouldCheckPayloadSize) { + return this.writeBuffer; + } + let payloadSize = 1; // first packet type + for (let i = 0; i < this.writeBuffer.length; i++) { + const data = this.writeBuffer[i].data; + if (data) { + payloadSize += (0, util_js_1.byteLength)(data); + } + if (i > 0 && payloadSize > this.maxPayload) { + debug("only send %d out of %d packets", i, this.writeBuffer.length); + return this.writeBuffer.slice(0, i); + } + payloadSize += 2; // separator + packet type + } + debug("payload size is %d (max: %d)", payloadSize, this.maxPayload); + return this.writeBuffer; + } + /** + * Sends a message. + * + * @param {String} msg - message. + * @param {Object} options. + * @param {Function} callback function. + * @return {Socket} for chaining. + */ + write(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + send(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + /** + * Sends a packet. + * + * @param {String} type: packet type. + * @param {String} data. + * @param {Object} options. + * @param {Function} fn - callback function. + * @private + */ + sendPacket(type, data, options, fn) { + if ("function" === typeof data) { + fn = data; + data = undefined; + } + if ("function" === typeof options) { + fn = options; + options = null; + } + if ("closing" === this.readyState || "closed" === this.readyState) { + return; + } + options = options || {}; + options.compress = false !== options.compress; + const packet = { + type: type, + data: data, + options: options, + }; + this.emitReserved("packetCreate", packet); + this.writeBuffer.push(packet); + if (fn) + this.once("flush", fn); + this.flush(); + } + /** + * Closes the connection. + */ + close() { + const close = () => { + this.onClose("forced close"); + debug("socket closing - telling transport to close"); + this.transport.close(); + }; + const cleanupAndClose = () => { + this.off("upgrade", cleanupAndClose); + this.off("upgradeError", cleanupAndClose); + close(); + }; + const waitForUpgrade = () => { + // wait for upgrade to finish since we can't send packets while pausing a transport + this.once("upgrade", cleanupAndClose); + this.once("upgradeError", cleanupAndClose); + }; + if ("opening" === this.readyState || "open" === this.readyState) { + this.readyState = "closing"; + if (this.writeBuffer.length) { + this.once("drain", () => { + if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + }); + } + else if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + } + return this; + } + /** + * Called upon transport error + * + * @private + */ + onError(err) { + debug("socket error %j", err); + Socket.priorWebsocketSuccess = false; + this.emitReserved("error", err); + this.onClose("transport error", err); + } + /** + * Called upon transport close. + * + * @private + */ + onClose(reason, description) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket close with reason: "%s"', reason); + // clear timers + this.clearTimeoutFn(this.pingTimeoutTimer); + // stop event from firing again for transport + this.transport.removeAllListeners("close"); + // ensure transport won't stay open + this.transport.close(); + // ignore further transport communication + this.transport.removeAllListeners(); + if (typeof removeEventListener === "function") { + removeEventListener("beforeunload", this.beforeunloadEventListener, false); + removeEventListener("offline", this.offlineEventListener, false); + } + // set ready state + this.readyState = "closed"; + // clear session id + this.id = null; + // emit close event + this.emitReserved("close", reason, description); + // clean buffers after, so users can still + // grab the buffers on `close` event + this.writeBuffer = []; + this.prevBufferLen = 0; + } + } + /** + * Filters upgrades, returning only those matching client transports. + * + * @param {Array} upgrades - server upgrades + * @private + */ + filterUpgrades(upgrades) { + const filteredUpgrades = []; + let i = 0; + const j = upgrades.length; + for (; i < j; i++) { + if (~this.transports.indexOf(upgrades[i])) + filteredUpgrades.push(upgrades[i]); + } + return filteredUpgrades; + } +} +exports.Socket = Socket; +Socket.protocol = engine_io_parser_1.protocol; - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } +},{"./contrib/parseqs.js":362,"./contrib/parseuri.js":363,"./transports/index.js":369,"./transports/websocket-constructor.js":371,"./util.js":375,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],368:[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.Transport = exports.TransportError = void 0; +const engine_io_parser_1 = require("engine.io-parser"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("./util.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const parseqs_js_1 = require("./contrib/parseqs.js"); +const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() +class TransportError extends Error { + constructor(reason, description, context) { + super(reason); + this.description = description; + this.context = context; + this.type = "TransportError"; + } +} +exports.TransportError = TransportError; +class Transport extends component_emitter_1.Emitter { + /** + * Transport abstract constructor. + * + * @param {Object} opts - options + * @protected + */ + constructor(opts) { + super(); + this.writable = false; + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.query = opts.query; + this.socket = opts.socket; + } + /** + * Emits an error. + * + * @param {String} reason + * @param description + * @param context - the error context + * @return {Transport} for chaining + * @protected + */ + onError(reason, description, context) { + super.emitReserved("error", new TransportError(reason, description, context)); + return this; + } + /** + * Opens the transport. + */ + open() { + this.readyState = "opening"; + this.doOpen(); + return this; + } + /** + * Closes the transport. + */ + close() { + if (this.readyState === "opening" || this.readyState === "open") { + this.doClose(); + this.onClose(); + } + return this; + } + /** + * Sends multiple packets. + * + * @param {Array} packets + */ + send(packets) { + if (this.readyState === "open") { + this.write(packets); + } + else { + // this might happen if the transport was silently closed in the beforeunload event handler + debug("transport is not open, discarding packets"); + } + } + /** + * Called upon open + * + * @protected + */ + onOpen() { + this.readyState = "open"; + this.writable = true; + super.emitReserved("open"); + } + /** + * Called with data. + * + * @param {String} data + * @protected + */ + onData(data) { + const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); + this.onPacket(packet); + } + /** + * Called with a decoded packet. + * + * @protected + */ + onPacket(packet) { + super.emitReserved("packet", packet); + } + /** + * Called upon close. + * + * @protected + */ + onClose(details) { + this.readyState = "closed"; + super.emitReserved("close", details); + } + /** + * Pauses the transport, in order not to lose packets during an upgrade. + * + * @param onPause + */ + pause(onPause) { } + createUri(schema, query = {}) { + return (schema + + "://" + + this._hostname() + + this._port() + + this.opts.path + + this._query(query)); + } + _hostname() { + const hostname = this.opts.hostname; + return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + } + _port() { + if (this.opts.port && + ((this.opts.secure && Number(this.opts.port !== 443)) || + (!this.opts.secure && Number(this.opts.port) !== 80))) { + return ":" + this.opts.port; + } + else { + return ""; + } + } + _query(query) { + const encodedQuery = (0, parseqs_js_1.encode)(query); + return encodedQuery.length ? "?" + encodedQuery : ""; + } +} +exports.Transport = Transport; - return false; - } +},{"./contrib/parseqs.js":362,"./util.js":375,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],369:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.transports = void 0; +const polling_js_1 = require("./polling.js"); +const websocket_js_1 = require("./websocket.js"); +const webtransport_js_1 = require("./webtransport.js"); +exports.transports = { + websocket: websocket_js_1.WS, + webtransport: webtransport_js_1.WT, + polling: polling_js_1.Polling, +}; - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } +},{"./polling.js":370,"./websocket.js":372,"./webtransport.js":373}],370:[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.Request = exports.Polling = void 0; +const transport_js_1 = require("../transport.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const yeast_js_1 = require("../contrib/yeast.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const xmlhttprequest_js_1 = require("./xmlhttprequest.js"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("../util.js"); +const globalThis_js_1 = require("../globalThis.js"); +const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() +function empty() { } +const hasXHR2 = (function () { + const xhr = new xmlhttprequest_js_1.XHR({ + xdomain: false, + }); + return null != xhr.responseType; +})(); +class Polling extends transport_js_1.Transport { + /** + * XHR Polling constructor. + * + * @param {Object} opts + * @package + */ + constructor(opts) { + super(opts); + this.polling = false; + if (typeof location !== "undefined") { + const isSSL = "https:" === location.protocol; + let port = location.port; + // some user agents have empty `location.port` + if (!port) { + port = isSSL ? "443" : "80"; + } + this.xd = + (typeof location !== "undefined" && + opts.hostname !== location.hostname) || + port !== opts.port; + } + /** + * XHR supports binary + */ + const forceBase64 = opts && opts.forceBase64; + this.supportsBinary = hasXHR2 && !forceBase64; + if (this.opts.withCredentials) { + this.cookieJar = (0, xmlhttprequest_js_1.createCookieJar)(); + } + } + get name() { + return "polling"; + } + /** + * Opens the socket (triggers polling). We write a PING message to determine + * when the transport is open. + * + * @protected + */ + doOpen() { + this.poll(); + } + /** + * Pauses polling. + * + * @param {Function} onPause - callback upon buffers are flushed and transport is paused + * @package + */ + pause(onPause) { + this.readyState = "pausing"; + const pause = () => { + debug("paused"); + this.readyState = "paused"; + onPause(); + }; + if (this.polling || !this.writable) { + let total = 0; + if (this.polling) { + debug("we are currently polling - waiting to pause"); + total++; + this.once("pollComplete", function () { + debug("pre-pause polling complete"); + --total || pause(); + }); + } + if (!this.writable) { + debug("we are currently writing - waiting to pause"); + total++; + this.once("drain", function () { + debug("pre-pause writing complete"); + --total || pause(); + }); + } + } + else { + pause(); + } + } + /** + * Starts polling cycle. + * + * @private + */ + poll() { + debug("polling"); + this.polling = true; + this.doPoll(); + this.emitReserved("poll"); + } + /** + * Overloads onData to detect payloads. + * + * @protected + */ + onData(data) { + debug("polling got data %s", data); + const callback = (packet) => { + // if its the first message we consider the transport open + if ("opening" === this.readyState && packet.type === "open") { + this.onOpen(); + } + // if its a close packet, we close the ongoing requests + if ("close" === packet.type) { + this.onClose({ description: "transport closed by the server" }); + return false; + } + // otherwise bypass onData and handle the message + this.onPacket(packet); + }; + // decode payload + (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); + // if an event did not trigger closing + if ("closed" !== this.readyState) { + // if we got data we're not polling + this.polling = false; + this.emitReserved("pollComplete"); + if ("open" === this.readyState) { + this.poll(); + } + else { + debug('ignoring poll - transport state "%s"', this.readyState); + } + } + } + /** + * For polling, send a close packet. + * + * @protected + */ + doClose() { + const close = () => { + debug("writing close packet"); + this.write([{ type: "close" }]); + }; + if ("open" === this.readyState) { + debug("transport open - closing"); + close(); + } + else { + // in case we're trying to close while + // handshaking is in progress (GH-164) + debug("transport not open - deferring close"); + this.once("open", close); + } + } + /** + * Writes a packets payload. + * + * @param {Array} packets - data packets + * @protected + */ + write(packets) { + this.writable = false; + (0, engine_io_parser_1.encodePayload)(packets, (data) => { + this.doWrite(data, () => { + this.writable = true; + this.emitReserved("drain"); + }); + }); + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "https" : "http"; + const query = this.query || {}; + // cache busting is forced + if (false !== this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + if (!this.supportsBinary && !query.sid) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Creates a request. + * + * @param {String} method + * @private + */ + request(opts = {}) { + Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts); + return new Request(this.uri(), opts); + } + /** + * Sends data. + * + * @param {String} data to send. + * @param {Function} called upon flush. + * @private + */ + doWrite(data, fn) { + const req = this.request({ + method: "POST", + data: data, + }); + req.on("success", fn); + req.on("error", (xhrStatus, context) => { + this.onError("xhr post error", xhrStatus, context); + }); + } + /** + * Starts a poll cycle. + * + * @private + */ + doPoll() { + debug("xhr poll"); + const req = this.request(); + req.on("data", this.onData.bind(this)); + req.on("error", (xhrStatus, context) => { + this.onError("xhr poll error", xhrStatus, context); + }); + this.pollXhr = req; + } +} +exports.Polling = Polling; +class Request extends component_emitter_1.Emitter { + /** + * Request constructor + * + * @param {Object} options + * @package + */ + constructor(uri, opts) { + super(); + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.method = opts.method || "GET"; + this.uri = uri; + this.data = undefined !== opts.data ? opts.data : null; + this.create(); + } + /** + * Creates the XHR object and sends the request. + * + * @private + */ + create() { + var _a; + const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); + opts.xdomain = !!this.opts.xd; + const xhr = (this.xhr = new xmlhttprequest_js_1.XHR(opts)); + try { + debug("xhr open %s: %s", this.method, this.uri); + xhr.open(this.method, this.uri, true); + try { + if (this.opts.extraHeaders) { + xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); + for (let i in this.opts.extraHeaders) { + if (this.opts.extraHeaders.hasOwnProperty(i)) { + xhr.setRequestHeader(i, this.opts.extraHeaders[i]); + } + } + } + } + catch (e) { } + if ("POST" === this.method) { + try { + xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); + } + catch (e) { } + } + try { + xhr.setRequestHeader("Accept", "*/*"); + } + catch (e) { } + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); + // ie6 check + if ("withCredentials" in xhr) { + xhr.withCredentials = this.opts.withCredentials; + } + if (this.opts.requestTimeout) { + xhr.timeout = this.opts.requestTimeout; + } + xhr.onreadystatechange = () => { + var _a; + if (xhr.readyState === 3) { + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr); + } + if (4 !== xhr.readyState) + return; + if (200 === xhr.status || 1223 === xhr.status) { + this.onLoad(); + } + else { + // make sure the `error` event handler that's user-set + // does not throw in the same tick and gets caught here + this.setTimeoutFn(() => { + this.onError(typeof xhr.status === "number" ? xhr.status : 0); + }, 0); + } + }; + debug("xhr data %s", this.data); + xhr.send(this.data); + } + catch (e) { + // Need to defer since .create() is called directly from the constructor + // and thus the 'error' event can only be only bound *after* this exception + // occurs. Therefore, also, we cannot throw here at all. + this.setTimeoutFn(() => { + this.onError(e); + }, 0); + return; + } + if (typeof document !== "undefined") { + this.index = Request.requestsCount++; + Request.requests[this.index] = this; + } + } + /** + * Called upon error. + * + * @private + */ + onError(err) { + this.emitReserved("error", err, this.xhr); + this.cleanup(true); + } + /** + * Cleans up house. + * + * @private + */ + cleanup(fromError) { + if ("undefined" === typeof this.xhr || null === this.xhr) { + return; + } + this.xhr.onreadystatechange = empty; + if (fromError) { + try { + this.xhr.abort(); + } + catch (e) { } + } + if (typeof document !== "undefined") { + delete Request.requests[this.index]; + } + this.xhr = null; + } + /** + * Called upon load. + * + * @private + */ + onLoad() { + const data = this.xhr.responseText; + if (data !== null) { + this.emitReserved("data", data); + this.emitReserved("success"); + this.cleanup(); + } + } + /** + * Aborts the request. + * + * @package + */ + abort() { + this.cleanup(); + } +} +exports.Request = Request; +Request.requestsCount = 0; +Request.requests = {}; +/** + * Aborts pending requests when unloading the window. This is needed to prevent + * memory leaks (e.g. when using IE) and to ensure that no spurious error is + * emitted. + */ +if (typeof document !== "undefined") { + // @ts-ignore + if (typeof attachEvent === "function") { + // @ts-ignore + attachEvent("onunload", unloadHandler); + } + else if (typeof addEventListener === "function") { + const terminationEvent = "onpagehide" in globalThis_js_1.globalThisShim ? "pagehide" : "unload"; + addEventListener(terminationEvent, unloadHandler, false); + } +} +function unloadHandler() { + for (let i in Request.requests) { + if (Request.requests.hasOwnProperty(i)) { + Request.requests[i].abort(); + } + } +} - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } +},{"../contrib/yeast.js":364,"../globalThis.js":365,"../transport.js":368,"../util.js":375,"./xmlhttprequest.js":374,"@socket.io/component-emitter":23,"debug":340,"engine.io-parser":380}],371:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0; +const globalThis_js_1 = require("../globalThis.js"); +exports.nextTick = (() => { + const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; + if (isPromiseAvailable) { + return (cb) => Promise.resolve().then(cb); + } + else { + return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + } +})(); +exports.WebSocket = globalThis_js_1.globalThisShim.WebSocket || globalThis_js_1.globalThisShim.MozWebSocket; +exports.usingBrowserWebSocket = true; +exports.defaultBinaryType = "arraybuffer"; - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } +},{"../globalThis.js":365}],372:[function(require,module,exports){ +(function (Buffer){(function (){ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WS = void 0; +const transport_js_1 = require("../transport.js"); +const yeast_js_1 = require("../contrib/yeast.js"); +const util_js_1 = require("../util.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const engine_io_parser_1 = require("engine.io-parser"); +const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() +// detect ReactNative environment +const isReactNative = typeof navigator !== "undefined" && + typeof navigator.product === "string" && + navigator.product.toLowerCase() === "reactnative"; +class WS extends transport_js_1.Transport { + /** + * WebSocket transport constructor. + * + * @param {Object} opts - connection options + * @protected + */ + constructor(opts) { + super(opts); + this.supportsBinary = !opts.forceBase64; + } + get name() { + return "websocket"; + } + doOpen() { + if (!this.check()) { + // let probe timeout + return; + } + const uri = this.uri(); + const protocols = this.opts.protocols; + // React Native only supports the 'headers' option, and will print a warning if anything else is passed + const opts = isReactNative + ? {} + : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); + if (this.opts.extraHeaders) { + opts.headers = this.opts.extraHeaders; + } + try { + this.ws = + websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative + ? protocols + ? new websocket_constructor_js_1.WebSocket(uri, protocols) + : new websocket_constructor_js_1.WebSocket(uri) + : new websocket_constructor_js_1.WebSocket(uri, protocols, opts); + } + catch (err) { + return this.emitReserved("error", err); + } + this.ws.binaryType = this.socket.binaryType; + this.addEventListeners(); + } + /** + * Adds event listeners to the socket + * + * @private + */ + addEventListeners() { + this.ws.onopen = () => { + if (this.opts.autoUnref) { + this.ws._socket.unref(); + } + this.onOpen(); + }; + this.ws.onclose = (closeEvent) => this.onClose({ + description: "websocket connection closed", + context: closeEvent, + }); + this.ws.onmessage = (ev) => this.onData(ev.data); + this.ws.onerror = (e) => this.onError("websocket error", e); + } + write(packets) { + this.writable = false; + // encodePacket efficient as it uses WS framing + // no need for encodePayload + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { + // always create a new object (GH-437) + const opts = {}; + if (!websocket_constructor_js_1.usingBrowserWebSocket) { + if (packet.options) { + opts.compress = packet.options.compress; + } + if (this.opts.perMessageDeflate) { + const len = + // @ts-ignore + "string" === typeof data ? Buffer.byteLength(data) : data.length; + if (len < this.opts.perMessageDeflate.threshold) { + opts.compress = false; + } + } + } + // Sometimes the websocket has already been closed but the browser didn't + // have a chance of informing us about it yet, in that case send will + // throw an error + try { + if (websocket_constructor_js_1.usingBrowserWebSocket) { + // TypeError is thrown when passing the second argument on Safari + this.ws.send(data); + } + else { + this.ws.send(data, opts); + } + } + catch (e) { + debug("websocket closed before onclose event"); + } + if (lastPacket) { + // fake drain + // defer to next tick to allow Socket to clear writeBuffer + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + if (typeof this.ws !== "undefined") { + this.ws.close(); + this.ws = null; + } + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "wss" : "ws"; + const query = this.query || {}; + // append timestamp to URI + if (this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + // communicate binary support capabilities + if (!this.supportsBinary) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Feature detection for WebSocket. + * + * @return {Boolean} whether this transport is available. + * @private + */ + check() { + return !!websocket_constructor_js_1.WebSocket; + } +} +exports.WS = WS; - createDebug.enable(createDebug.load()); +}).call(this)}).call(this,require("buffer").Buffer) +},{"../contrib/yeast.js":364,"../transport.js":368,"../util.js":375,"./websocket-constructor.js":371,"buffer":33,"debug":340,"engine.io-parser":380}],373:[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.WT = void 0; +const transport_js_1 = require("../transport.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const debug_1 = __importDefault(require("debug")); // debug() +const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() +class WT extends transport_js_1.Transport { + get name() { + return "webtransport"; + } + doOpen() { + // @ts-ignore + if (typeof WebTransport !== "function") { + return; + } + // @ts-ignore + this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); + this.transport.closed + .then(() => { + debug("transport closed gracefully"); + this.onClose(); + }) + .catch((err) => { + debug("transport closed due to %s", err); + this.onError("webtransport error", err); + }); + // note: we could have used async/await, but that would require some additional polyfills + this.transport.ready.then(() => { + this.transport.createBidirectionalStream().then((stream) => { + const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); + const reader = stream.readable.pipeThrough(decoderStream).getReader(); + const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); + encoderStream.readable.pipeTo(stream.writable); + this.writer = encoderStream.writable.getWriter(); + const read = () => { + reader + .read() + .then(({ done, value }) => { + if (done) { + debug("session is closed"); + return; + } + debug("received chunk: %o", value); + this.onPacket(value); + read(); + }) + .catch((err) => { + debug("an error occurred while reading: %s", err); + }); + }; + read(); + const packet = { type: "open" }; + if (this.query.sid) { + packet.data = `{"sid":"${this.query.sid}"}`; + } + this.writer.write(packet).then(() => this.onOpen()); + }); + }); + } + write(packets) { + this.writable = false; + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + this.writer.write(packet).then(() => { + if (lastPacket) { + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + var _a; + (_a = this.transport) === null || _a === void 0 ? void 0 : _a.close(); + } +} +exports.WT = WT; - return createDebug; +},{"../transport.js":368,"./websocket-constructor.js":371,"debug":340,"engine.io-parser":380}],374:[function(require,module,exports){ +"use strict"; +// browser shim for xmlhttprequest module +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createCookieJar = exports.XHR = void 0; +const has_cors_js_1 = require("../contrib/has-cors.js"); +const globalThis_js_1 = require("../globalThis.js"); +function XHR(opts) { + const xdomain = opts.xdomain; + // XMLHttpRequest can be disabled on IE + try { + if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { + return new XMLHttpRequest(); + } + } + catch (e) { } + if (!xdomain) { + try { + return new globalThis_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + catch (e) { } + } } +exports.XHR = XHR; +function createCookieJar() { } +exports.createCookieJar = createCookieJar; -module.exports = setup; +},{"../contrib/has-cors.js":361,"../globalThis.js":365}],375:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.byteLength = exports.installTimerFunctions = exports.pick = void 0; +const globalThis_js_1 = require("./globalThis.js"); +function pick(obj, ...attr) { + return attr.reduce((acc, k) => { + if (obj.hasOwnProperty(k)) { + acc[k] = obj[k]; + } + return acc; + }, {}); +} +exports.pick = pick; +// Keep a reference to the real timeout functions so they can be used when overridden +const NATIVE_SET_TIMEOUT = globalThis_js_1.globalThisShim.setTimeout; +const NATIVE_CLEAR_TIMEOUT = globalThis_js_1.globalThisShim.clearTimeout; +function installTimerFunctions(obj, opts) { + if (opts.useNativeTimers) { + obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.globalThisShim); + } + else { + obj.setTimeoutFn = globalThis_js_1.globalThisShim.setTimeout.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = globalThis_js_1.globalThisShim.clearTimeout.bind(globalThis_js_1.globalThisShim); + } +} +exports.installTimerFunctions = installTimerFunctions; +// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) +const BASE64_OVERHEAD = 1.33; +// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 +function byteLength(obj) { + if (typeof obj === "string") { + return utf8Length(obj); + } + // arraybuffer or blob + return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); +} +exports.byteLength = byteLength; +function utf8Length(str) { + let c = 0, length = 0; + for (let i = 0, l = str.length; i < l; i++) { + c = str.charCodeAt(i); + if (c < 0x80) { + length += 1; + } + else if (c < 0x800) { + length += 2; + } + else if (c < 0xd800 || c >= 0xe000) { + length += 3; + } + else { + i++; + length += 4; + } + } + return length; +} -},{"ms":441}],382:[function(require,module,exports){ +},{"./globalThis.js":365}],376:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0; @@ -21679,7 +21350,7 @@ Object.keys(PACKET_TYPES).forEach((key) => { const ERROR_PACKET = { type: "error", data: "parser error" }; exports.ERROR_PACKET = ERROR_PACKET; -},{}],383:[function(require,module,exports){ +},{}],377:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decode = exports.encode = void 0; @@ -21729,7 +21400,7 @@ const decode = (base64) => { }; exports.decode = decode; -},{}],384:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodePacket = void 0; @@ -21797,11 +21468,10 @@ const mapBinary = (data, binaryType) => { } }; -},{"./commons.js":382,"./contrib/base64-arraybuffer.js":383}],385:[function(require,module,exports){ +},{"./commons.js":376,"./contrib/base64-arraybuffer.js":377}],379:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodePacket = void 0; -exports.encodePacketToBinary = encodePacketToBinary; +exports.encodePacket = exports.encodePacketToBinary = void 0; const commons_js_1 = require("./commons.js"); const withNativeBlob = typeof Blob === "function" || (typeof Blob !== "undefined" && @@ -21870,13 +21540,12 @@ function encodePacketToBinary(packet, callback) { callback(TEXT_ENCODER.encode(encoded)); }); } +exports.encodePacketToBinary = encodePacketToBinary; -},{"./commons.js":382}],386:[function(require,module,exports){ +},{"./commons.js":376}],380:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; -exports.createPacketEncoderStream = createPacketEncoderStream; -exports.createPacketDecoderStream = createPacketDecoderStream; +exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0; const encodePacket_js_1 = require("./encodePacket.js"); Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }); const decodePacket_js_1 = require("./decodePacket.js"); @@ -21913,6 +21582,7 @@ const decodePayload = (encodedPayload, binaryType) => { }; exports.decodePayload = decodePayload; function createPacketEncoderStream() { + // @ts-expect-error return new TransformStream({ transform(packet, controller) { (0, encodePacket_js_1.encodePacketToBinary)(packet, (encodedPacket) => { @@ -21945,6 +21615,7 @@ function createPacketEncoderStream() { }, }); } +exports.createPacketEncoderStream = createPacketEncoderStream; let TEXT_DECODER; function totalLength(chunks) { return chunks.reduce((acc, chunk) => acc + chunk.length, 0); @@ -21972,14 +21643,15 @@ function createPacketDecoderStream(maxPayload, binaryType) { TEXT_DECODER = new TextDecoder(); } const chunks = []; - let state = 0 /* State.READ_HEADER */; + let state = 0 /* READ_HEADER */; let expectedLength = -1; let isBinary = false; + // @ts-expect-error return new TransformStream({ transform(chunk, controller) { chunks.push(chunk); while (true) { - if (state === 0 /* State.READ_HEADER */) { + if (state === 0 /* READ_HEADER */) { if (totalLength(chunks) < 1) { break; } @@ -21987,24 +21659,24 @@ function createPacketDecoderStream(maxPayload, binaryType) { isBinary = (header[0] & 0x80) === 0x80; expectedLength = header[0] & 0x7f; if (expectedLength < 126) { - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else if (expectedLength === 126) { - state = 1 /* State.READ_EXTENDED_LENGTH_16 */; + state = 1 /* READ_EXTENDED_LENGTH_16 */; } else { - state = 2 /* State.READ_EXTENDED_LENGTH_64 */; + state = 2 /* READ_EXTENDED_LENGTH_64 */; } } - else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { + else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { if (totalLength(chunks) < 2) { break; } const headerArray = concatChunks(chunks, 2); expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } - else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { + else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { if (totalLength(chunks) < 8) { break; } @@ -22017,7 +21689,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { break; } expectedLength = n * Math.pow(2, 32) + view.getUint32(4); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else { if (totalLength(chunks) < expectedLength) { @@ -22025,7 +21697,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { } const data = concatChunks(chunks, expectedLength); controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); - state = 0 /* State.READ_HEADER */; + state = 0 /* READ_HEADER */; } if (expectedLength === 0 || expectedLength > maxPayload) { controller.enqueue(commons_js_1.ERROR_PACKET); @@ -22035,13 +21707,16 @@ function createPacketDecoderStream(maxPayload, binaryType) { }, }); } +exports.createPacketDecoderStream = createPacketDecoderStream; exports.protocol = 4; -},{"./commons.js":382,"./decodePacket.js":384,"./encodePacket.js":385}],387:[function(require,module,exports){ +},{"./commons.js":376,"./decodePacket.js":378,"./encodePacket.js":379}],381:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); + /** @type {import('.')} */ -var $defineProperty = Object.defineProperty || false; +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false; if ($defineProperty) { try { $defineProperty({}, 'a', { value: 1 }); @@ -22053,55 +21728,49 @@ if ($defineProperty) { module.exports = $defineProperty; -},{}],388:[function(require,module,exports){ +},{"get-intrinsic":393}],382:[function(require,module,exports){ 'use strict'; /** @type {import('./eval')} */ module.exports = EvalError; -},{}],389:[function(require,module,exports){ +},{}],383:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ module.exports = Error; -},{}],390:[function(require,module,exports){ +},{}],384:[function(require,module,exports){ 'use strict'; /** @type {import('./range')} */ module.exports = RangeError; -},{}],391:[function(require,module,exports){ +},{}],385:[function(require,module,exports){ 'use strict'; /** @type {import('./ref')} */ module.exports = ReferenceError; -},{}],392:[function(require,module,exports){ +},{}],386:[function(require,module,exports){ 'use strict'; /** @type {import('./syntax')} */ module.exports = SyntaxError; -},{}],393:[function(require,module,exports){ +},{}],387:[function(require,module,exports){ 'use strict'; /** @type {import('./type')} */ module.exports = TypeError; -},{}],394:[function(require,module,exports){ +},{}],388:[function(require,module,exports){ 'use strict'; /** @type {import('./uri')} */ module.exports = URIError; -},{}],395:[function(require,module,exports){ -'use strict'; - -/** @type {import('.')} */ -module.exports = Object; - -},{}],396:[function(require,module,exports){ +},{}],389:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keccak512 = exports.keccak384 = exports.keccak256 = exports.keccak224 = void 0; @@ -22116,17 +21785,13 @@ exports.keccak256 = (() => { exports.keccak384 = (0, utils_js_1.wrapHash)(sha3_1.keccak_384); exports.keccak512 = (0, utils_js_1.wrapHash)(sha3_1.keccak_512); -},{"./utils.js":397,"@noble/hashes/sha3":21}],397:[function(require,module,exports){ +},{"./utils.js":390,"@noble/hashes/sha3":21}],390:[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.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; -exports.bytesToUtf8 = bytesToUtf8; -exports.hexToBytes = hexToBytes; -exports.equalsBytes = equalsBytes; -exports.wrapHash = wrapHash; +exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; const _assert_1 = __importDefault(require("@noble/hashes/_assert")); const utils_1 = require("@noble/hashes/utils"); const assertBool = _assert_1.default.bool; @@ -22146,10 +21811,12 @@ function bytesToUtf8(data) { } return new TextDecoder().decode(data); } +exports.bytesToUtf8 = bytesToUtf8; function hexToBytes(data) { const sliced = data.startsWith("0x") ? data.substring(2) : data; return (0, utils_1.hexToBytes)(sliced); } +exports.hexToBytes = hexToBytes; // buf.equals(buf2) -> equalsBytes(buf, buf2) function equalsBytes(a, b) { if (a.length !== b.length) { @@ -22162,6 +21829,7 @@ function equalsBytes(a, b) { } return true; } +exports.equalsBytes = equalsBytes; // Internal utils function wrapHash(hash) { return (msg) => { @@ -22169,8 +21837,20 @@ function wrapHash(hash) { return hash(msg); }; } +exports.wrapHash = wrapHash; +// TODO(v3): switch away from node crypto, remove this unnecessary variable. +exports.crypto = (() => { + const webCrypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined; + const nodeRequire = typeof module !== "undefined" && + typeof module.require === "function" && + module.require.bind(module); + return { + node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined, + web: webCrypto + }; +})(); -},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],398:[function(require,module,exports){ +},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],391:[function(require,module,exports){ 'use strict'; /* eslint no-invalid-this: 1 */ @@ -22256,20 +21936,18 @@ module.exports = function bind(that) { return bound; }; -},{}],399:[function(require,module,exports){ +},{}],392:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":398}],400:[function(require,module,exports){ +},{"./implementation":391}],393:[function(require,module,exports){ 'use strict'; var undefined; -var $Object = require('es-object-atoms'); - var $Error = require('es-errors'); var $EvalError = require('es-errors/eval'); var $RangeError = require('es-errors/range'); @@ -22278,14 +21956,6 @@ var $SyntaxError = require('es-errors/syntax'); var $TypeError = require('es-errors/type'); var $URIError = require('es-errors/uri'); -var abs = require('math-intrinsics/abs'); -var floor = require('math-intrinsics/floor'); -var max = require('math-intrinsics/max'); -var min = require('math-intrinsics/min'); -var pow = require('math-intrinsics/pow'); -var round = require('math-intrinsics/round'); -var sign = require('math-intrinsics/sign'); - var $Function = Function; // eslint-disable-next-line consistent-return @@ -22295,8 +21965,14 @@ var getEvalledConstructor = function (expressionSyntax) { } catch (e) {} }; -var $gOPD = require('gopd'); -var $defineProperty = require('es-define-property'); +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} var throwTypeError = function () { throw new $TypeError(); @@ -22319,13 +21995,13 @@ var ThrowTypeError = $gOPD : throwTypeError; var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); -var getProto = require('get-proto'); -var $ObjectGPO = require('get-proto/Object.getPrototypeOf'); -var $ReflectGPO = require('get-proto/Reflect.getPrototypeOf'); - -var $apply = require('call-bind-apply-helpers/functionApply'); -var $call = require('call-bind-apply-helpers/functionCall'); +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); var needsEval = {}; @@ -22372,8 +22048,7 @@ var INTRINSICS = { '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), '%Math%': Math, '%Number%': Number, - '%Object%': $Object, - '%Object.getOwnPropertyDescriptor%': $gOPD, + '%Object%': Object, '%parseFloat%': parseFloat, '%parseInt%': parseInt, '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, @@ -22399,20 +22074,7 @@ var INTRINSICS = { '%URIError%': $URIError, '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, - '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet, - - '%Function.prototype.call%': $call, - '%Function.prototype.apply%': $apply, - '%Object.defineProperty%': $defineProperty, - '%Object.getPrototypeOf%': $ObjectGPO, - '%Math.abs%': abs, - '%Math.floor%': floor, - '%Math.max%': max, - '%Math.min%': min, - '%Math.pow%': pow, - '%Math.round%': round, - '%Math.sign%': sign, - '%Reflect.getPrototypeOf%': $ReflectGPO + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet }; if (getProto) { @@ -22507,11 +22169,11 @@ var LEGACY_ALIASES = { var bind = require('function-bind'); var hasOwn = require('hasown'); -var $concat = bind.call($call, Array.prototype.concat); -var $spliceApply = bind.call($apply, Array.prototype.splice); -var $replace = bind.call($call, String.prototype.replace); -var $strSlice = bind.call($call, String.prototype.slice); -var $exec = bind.call($call, RegExp.prototype.exec); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; @@ -22642,60 +22304,12 @@ module.exports = function GetIntrinsic(name, allowMissing) { return value; }; -},{"call-bind-apply-helpers/functionApply":36,"call-bind-apply-helpers/functionCall":37,"es-define-property":387,"es-errors":389,"es-errors/eval":388,"es-errors/range":390,"es-errors/ref":391,"es-errors/syntax":392,"es-errors/type":393,"es-errors/uri":394,"es-object-atoms":395,"function-bind":399,"get-proto":403,"get-proto/Object.getPrototypeOf":401,"get-proto/Reflect.getPrototypeOf":402,"gopd":405,"has-symbols":407,"hasown":421,"math-intrinsics/abs":431,"math-intrinsics/floor":432,"math-intrinsics/max":434,"math-intrinsics/min":435,"math-intrinsics/pow":436,"math-intrinsics/round":437,"math-intrinsics/sign":438}],401:[function(require,module,exports){ -'use strict'; - -var $Object = require('es-object-atoms'); - -/** @type {import('./Object.getPrototypeOf')} */ -module.exports = $Object.getPrototypeOf || null; - -},{"es-object-atoms":395}],402:[function(require,module,exports){ +},{"es-errors":383,"es-errors/eval":382,"es-errors/range":384,"es-errors/ref":385,"es-errors/syntax":386,"es-errors/type":387,"es-errors/uri":388,"function-bind":392,"has-proto":396,"has-symbols":397,"hasown":411}],394:[function(require,module,exports){ 'use strict'; -/** @type {import('./Reflect.getPrototypeOf')} */ -module.exports = (typeof Reflect !== 'undefined' && Reflect.getPrototypeOf) || null; - -},{}],403:[function(require,module,exports){ -'use strict'; - -var reflectGetProto = require('./Reflect.getPrototypeOf'); -var originalGetProto = require('./Object.getPrototypeOf'); - -var getDunderProto = require('dunder-proto/get'); - -/** @type {import('.')} */ -module.exports = reflectGetProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return reflectGetProto(O); - } - : originalGetProto - ? function getProto(O) { - if (!O || (typeof O !== 'object' && typeof O !== 'function')) { - throw new TypeError('getProto: not an object'); - } - // @ts-expect-error TS can't narrow inside a closure, for some reason - return originalGetProto(O); - } - : getDunderProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return getDunderProto(O); - } - : null; - -},{"./Object.getPrototypeOf":401,"./Reflect.getPrototypeOf":402,"dunder-proto/get":348}],404:[function(require,module,exports){ -'use strict'; - -/** @type {import('./gOPD')} */ -module.exports = Object.getOwnPropertyDescriptor; - -},{}],405:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -/** @type {import('.')} */ -var $gOPD = require('./gOPD'); +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); if ($gOPD) { try { @@ -22708,7 +22322,7 @@ if ($gOPD) { module.exports = $gOPD; -},{"./gOPD":404}],406:[function(require,module,exports){ +},{"get-intrinsic":393}],395:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -22732,13 +22346,29 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu module.exports = hasPropertyDescriptors; -},{"es-define-property":387}],407:[function(require,module,exports){ +},{"es-define-property":381}],396:[function(require,module,exports){ +'use strict'; + +var test = { + __proto__: null, + foo: {} +}; + +var $Object = Object; + +/** @type {import('.')} */ +module.exports = function hasProto() { + // @ts-expect-error: TS errors on an inherited property for some reason + return { __proto__: test }.foo === test.foo + && !(test instanceof $Object); +}; + +},{}],397:[function(require,module,exports){ 'use strict'; var origSymbol = typeof Symbol !== 'undefined' && Symbol; var hasSymbolSham = require('./shams'); -/** @type {import('.')} */ module.exports = function hasNativeSymbols() { if (typeof origSymbol !== 'function') { return false; } if (typeof Symbol !== 'function') { return false; } @@ -22748,16 +22378,14 @@ module.exports = function hasNativeSymbols() { return hasSymbolSham(); }; -},{"./shams":408}],408:[function(require,module,exports){ +},{"./shams":398}],398:[function(require,module,exports){ 'use strict'; -/** @type {import('./shams')} */ /* eslint complexity: [2, 18], max-statements: [2, 33] */ module.exports = function hasSymbols() { if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } if (typeof Symbol.iterator === 'symbol') { return true; } - /** @type {{ [k in symbol]?: unknown }} */ var obj = {}; var sym = Symbol('test'); var symObj = Object(sym); @@ -22776,7 +22404,7 @@ module.exports = function hasSymbols() { var symVal = 42; obj[sym] = symVal; - for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } @@ -22787,15 +22415,14 @@ module.exports = function hasSymbols() { if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } if (typeof Object.getOwnPropertyDescriptor === 'function') { - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym)); + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } } return true; }; -},{}],409:[function(require,module,exports){ +},{}],399:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -22812,7 +22439,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":410,"./hash/hmac":411,"./hash/ripemd":412,"./hash/sha":413,"./hash/utils":420}],410:[function(require,module,exports){ +},{"./hash/common":400,"./hash/hmac":401,"./hash/ripemd":402,"./hash/sha":403,"./hash/utils":410}],400:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -22906,7 +22533,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":420,"minimalistic-assert":439}],411:[function(require,module,exports){ +},{"./utils":410,"minimalistic-assert":421}],401:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -22955,7 +22582,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":420,"minimalistic-assert":439}],412:[function(require,module,exports){ +},{"./utils":410,"minimalistic-assert":421}],402:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -23103,7 +22730,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":410,"./utils":420}],413:[function(require,module,exports){ +},{"./common":400,"./utils":410}],403:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -23112,7 +22739,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":414,"./sha/224":415,"./sha/256":416,"./sha/384":417,"./sha/512":418}],414:[function(require,module,exports){ +},{"./sha/1":404,"./sha/224":405,"./sha/256":406,"./sha/384":407,"./sha/512":408}],404:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23188,7 +22815,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":410,"../utils":420,"./common":419}],415:[function(require,module,exports){ +},{"../common":400,"../utils":410,"./common":409}],405:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23220,7 +22847,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":420,"./256":416}],416:[function(require,module,exports){ +},{"../utils":410,"./256":406}],406:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23327,7 +22954,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":410,"../utils":420,"./common":419,"minimalistic-assert":439}],417:[function(require,module,exports){ +},{"../common":400,"../utils":410,"./common":409,"minimalistic-assert":421}],407:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23364,7 +22991,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":420,"./512":418}],418:[function(require,module,exports){ +},{"../utils":410,"./512":408}],408:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23696,7 +23323,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":410,"../utils":420,"minimalistic-assert":439}],419:[function(require,module,exports){ +},{"../common":400,"../utils":410,"minimalistic-assert":421}],409:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -23747,7 +23374,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":420}],420:[function(require,module,exports){ +},{"../utils":410}],410:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -24027,7 +23654,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":424,"minimalistic-assert":439}],421:[function(require,module,exports){ +},{"inherits":414,"minimalistic-assert":421}],411:[function(require,module,exports){ 'use strict'; var call = Function.prototype.call; @@ -24037,7 +23664,7 @@ var bind = require('function-bind'); /** @type {import('.')} */ module.exports = bind.call(call, $hasOwn); -},{"function-bind":399}],422:[function(require,module,exports){ +},{"function-bind":392}],412:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -24152,7 +23779,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":409,"minimalistic-assert":439,"minimalistic-crypto-utils":440}],423:[function(require,module,exports){ +},{"hash.js":399,"minimalistic-assert":421,"minimalistic-crypto-utils":422}],413:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -24239,7 +23866,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],424:[function(require,module,exports){ +},{}],414:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -24268,30 +23895,26 @@ if (typeof Object.create === 'function') { } } -},{}],425:[function(require,module,exports){ +},{}],415:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],426:[function(require,module,exports){ +},{}],416:[function(require,module,exports){ 'use strict'; -/** @type {typeof JSON.stringify} */ var jsonStringify = (typeof JSON !== 'undefined' ? JSON : require('jsonify')).stringify; var isArray = require('isarray'); var objectKeys = require('object-keys'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $join = callBound('Array.prototype.join'); -var $indexOf = callBound('Array.prototype.indexOf'); -var $splice = callBound('Array.prototype.splice'); -var $sort = callBound('Array.prototype.sort'); +var $push = callBound('Array.prototype.push'); -/** @type {(n: number, char: string) => string} */ var strRepeat = function repeat(n, char) { var str = ''; for (var i = 0; i < n; i += 1) { @@ -24300,103 +23923,85 @@ var strRepeat = function repeat(n, char) { return str; }; -/** @type {(parent: import('.').Node, key: import('.').Key, value: unknown) => unknown} */ -var defaultReplacer = function (_parent, _key, value) { return value; }; +var defaultReplacer = function (parent, key, value) { return value; }; -/** @type {import('.')} */ module.exports = function stableStringify(obj) { - /** @type {Parameters[1]} */ var opts = arguments.length > 1 ? arguments[1] : void undefined; var space = (opts && opts.space) || ''; if (typeof space === 'number') { space = strRepeat(space, ' '); } var cycles = !!opts && typeof opts.cycles === 'boolean' && opts.cycles; - /** @type {undefined | typeof defaultReplacer} */ var replacer = opts && opts.replacer ? callBind(opts.replacer) : defaultReplacer; var cmpOpt = typeof opts === 'function' ? opts : opts && opts.cmp; - /** @type {undefined | ((node: T) => (a: Exclude, b: Exclude) => number)} */ var cmp = cmpOpt && function (node) { - // eslint-disable-next-line no-extra-parens - var get = /** @type {NonNullable} */ (cmpOpt).length > 2 - && /** @type {import('.').Getter['get']} */ function get(k) { return node[k]; }; + var get = cmpOpt.length > 2 && function get(k) { return node[k]; }; return function (a, b) { - // eslint-disable-next-line no-extra-parens - return /** @type {NonNullable} */ (cmpOpt)( + return cmpOpt( { key: a, value: node[a] }, { key: b, value: node[b] }, - // @ts-expect-error TS doesn't understand the optimization used here - get ? /** @type {import('.').Getter} */ { __proto__: null, get: get } : void undefined + get ? { __proto__: null, get: get } : void undefined ); }; }; - /** @type {import('.').Node[]} */ var seen = []; - return (/** @type {(parent: import('.').Node, key: string | number, node: unknown, level: number) => string | undefined} */ - function stringify(parent, key, node, level) { - var indent = space ? '\n' + strRepeat(level, space) : ''; - var colonSeparator = space ? ': ' : ':'; - - // eslint-disable-next-line no-extra-parens - if (node && /** @type {{ toJSON?: unknown }} */ (node).toJSON && typeof /** @type {{ toJSON?: unknown }} */ (node).toJSON === 'function') { - // eslint-disable-next-line no-extra-parens - node = /** @type {{ toJSON: Function }} */ (node).toJSON(); - } + return (function stringify(parent, key, node, level) { + var indent = space ? '\n' + strRepeat(level, space) : ''; + var colonSeparator = space ? ': ' : ':'; - node = replacer(parent, key, node); + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON(); + } - if (node === undefined) { - return; - } - if (typeof node !== 'object' || node === null) { - return jsonStringify(node); - } - if (isArray(node)) { - var out = []; - for (var i = 0; i < node.length; i++) { - var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); - out[out.length] = indent + space + item; - } - return '[' + $join(out, ',') + indent + ']'; - } + node = replacer(parent, key, node); - if ($indexOf(seen, node) !== -1) { - if (cycles) { return jsonStringify('__cycle__'); } - throw new TypeError('Converting circular structure to JSON'); - } else { - seen[seen.length] = /** @type {import('.').NonArrayNode} */ (node); + if (node === undefined) { + return; + } + if (typeof node !== 'object' || node === null) { + return jsonStringify(node); + } + if (isArray(node)) { + var out = []; + for (var i = 0; i < node.length; i++) { + var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); + $push(out, indent + space + item); } + return '[' + $join(out, ',') + indent + ']'; + } - /** @type {import('.').Key[]} */ - // eslint-disable-next-line no-extra-parens - var keys = $sort(objectKeys(node), cmp && cmp(/** @type {import('.').NonArrayNode} */ (node))); - var out = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // eslint-disable-next-line no-extra-parens - var value = stringify(/** @type {import('.').Node} */ (node), key, /** @type {import('.').NonArrayNode} */ (node)[key], level + 1); + if (seen.indexOf(node) !== -1) { + if (cycles) { return jsonStringify('__cycle__'); } + throw new TypeError('Converting circular structure to JSON'); + } else { $push(seen, node); } - if (!value) { continue; } + var keys = objectKeys(node).sort(cmp && cmp(node)); + var out = []; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = stringify(node, key, node[key], level + 1); - var keyValue = jsonStringify(key) - + colonSeparator - + value; + if (!value) { continue; } - out[out.length] = indent + space + keyValue; - } - $splice(seen, $indexOf(seen, node), 1); - return '{' + $join(out, ',') + indent + '}'; - }({ '': obj }, '', obj, 0) - ); + var keyValue = jsonStringify(key) + + colonSeparator + + value; + + $push(out, indent + space + keyValue); + } + seen.splice(seen.indexOf(node), 1); + return '{' + $join(out, ',') + indent + '}'; + + }({ '': obj }, '', obj, 0)); }; -},{"call-bind":40,"call-bound":41,"isarray":425,"jsonify":427,"object-keys":443}],427:[function(require,module,exports){ +},{"call-bind":35,"call-bind/callBound":34,"isarray":415,"jsonify":417,"object-keys":425}],417:[function(require,module,exports){ 'use strict'; exports.parse = require('./lib/parse'); exports.stringify = require('./lib/stringify'); -},{"./lib/parse":428,"./lib/stringify":429}],428:[function(require,module,exports){ +},{"./lib/parse":418,"./lib/stringify":419}],418:[function(require,module,exports){ 'use strict'; var at; // The index of the current character @@ -24659,7 +24264,7 @@ module.exports = function (source, reviver) { }({ '': result }, '')) : result; }; -},{}],429:[function(require,module,exports){ +},{}],419:[function(require,module,exports){ 'use strict'; var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; @@ -24812,7 +24417,7 @@ module.exports = function (value, replacer, space) { return str('', { '': value }); }; -},{}],430:[function(require,module,exports){ +},{}],420:[function(require,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -25171,64 +24776,7 @@ module.exports = function (value, replacer, space) { return defaultLogger; })); -},{}],431:[function(require,module,exports){ -'use strict'; - -/** @type {import('./abs')} */ -module.exports = Math.abs; - -},{}],432:[function(require,module,exports){ -'use strict'; - -/** @type {import('./floor')} */ -module.exports = Math.floor; - -},{}],433:[function(require,module,exports){ -'use strict'; - -/** @type {import('./isNaN')} */ -module.exports = Number.isNaN || function isNaN(a) { - return a !== a; -}; - -},{}],434:[function(require,module,exports){ -'use strict'; - -/** @type {import('./max')} */ -module.exports = Math.max; - -},{}],435:[function(require,module,exports){ -'use strict'; - -/** @type {import('./min')} */ -module.exports = Math.min; - -},{}],436:[function(require,module,exports){ -'use strict'; - -/** @type {import('./pow')} */ -module.exports = Math.pow; - -},{}],437:[function(require,module,exports){ -'use strict'; - -/** @type {import('./round')} */ -module.exports = Math.round; - -},{}],438:[function(require,module,exports){ -'use strict'; - -var $isNaN = require('./isNaN'); - -/** @type {import('./sign')} */ -module.exports = function sign(number) { - if ($isNaN(number) || number === 0) { - return number; - } - return number < 0 ? -1 : +1; -}; - -},{"./isNaN":433}],439:[function(require,module,exports){ +},{}],421:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -25241,7 +24789,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],440:[function(require,module,exports){ +},{}],422:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -25301,7 +24849,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],441:[function(require,module,exports){ +},{}],423:[function(require,module,exports){ /** * Helpers. */ @@ -25327,7 +24875,7 @@ var y = d * 365.25; * @api public */ -module.exports = function (val, options) { +module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { @@ -25465,7 +25013,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],442:[function(require,module,exports){ +},{}],424:[function(require,module,exports){ 'use strict'; var keysShim; @@ -25589,7 +25137,7 @@ if (!Object.keys) { } module.exports = keysShim; -},{"./isArguments":444}],443:[function(require,module,exports){ +},{"./isArguments":426}],425:[function(require,module,exports){ 'use strict'; var slice = Array.prototype.slice; @@ -25623,7 +25171,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./implementation":442,"./isArguments":444}],444:[function(require,module,exports){ +},{"./implementation":424,"./isArguments":426}],426:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -25642,7 +25190,7 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],445:[function(require,module,exports){ +},{}],427:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -25671,7 +25219,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const pkg = __importStar(require("./index.js")); module.exports = pkg; -},{"./index.js":446}],446:[function(require,module,exports){ +},{"./index.js":428}],428:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.now = exports.removeTooOldValues = exports.ObliviousSet = void 0; @@ -25748,7 +25296,7 @@ function now() { } exports.now = now; -},{}],447:[function(require,module,exports){ +},{}],429:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -25934,7 +25482,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],448:[function(require,module,exports){ +},{}],430:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -26697,7 +26245,7 @@ try { } } -},{}],449:[function(require,module,exports){ +},{}],431:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -26741,7 +26289,7 @@ module.exports = function setFunctionLength(fn, length) { return fn; }; -},{"define-data-property":347,"es-errors/type":393,"get-intrinsic":400,"gopd":405,"has-property-descriptors":406}],450:[function(require,module,exports){ +},{"define-data-property":343,"es-errors/type":387,"get-intrinsic":393,"gopd":394,"has-property-descriptors":395}],432:[function(require,module,exports){ "use strict"; /** * Initialize backoff timer with `opts`. @@ -26755,7 +26303,7 @@ module.exports = function setFunctionLength(fn, length) { * @api public */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Backoff = Backoff; +exports.Backoff = void 0; function Backoff(opts) { opts = opts || {}; this.ms = opts.min || 100; @@ -26764,6 +26312,7 @@ function Backoff(opts) { this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; this.attempts = 0; } +exports.Backoff = Backoff; /** * Return the backoff duration. * @@ -26812,23 +26361,20 @@ Backoff.prototype.setJitter = function (jitter) { this.jitter = jitter; }; -},{}],451:[function(require,module,exports){ +},{}],433:[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.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.Socket = exports.Manager = exports.protocol = void 0; -exports.io = lookup; -exports.connect = lookup; -exports.default = lookup; +exports.default = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0; const url_js_1 = require("./url.js"); const manager_js_1 = require("./manager.js"); Object.defineProperty(exports, "Manager", { enumerable: true, get: function () { return manager_js_1.Manager; } }); const socket_js_1 = require("./socket.js"); Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client"); // debug() +const debug = debug_1.default("socket.io-client"); // debug() /** * Managers cache. */ @@ -26839,7 +26385,7 @@ function lookup(uri, opts) { uri = undefined; } opts = opts || {}; - const parsed = (0, url_js_1.url)(uri, opts.path || "/socket.io"); + const parsed = url_js_1.url(uri, opts.path || "/socket.io"); const source = parsed.source; const id = parsed.id; const path = parsed.path; @@ -26865,6 +26411,9 @@ function lookup(uri, opts) { } return io.socket(parsed.path, opts); } +exports.io = lookup; +exports.connect = lookup; +exports.default = lookup; // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a // namespace (e.g. `io.connect(...)`), for backward compatibility Object.assign(lookup, { @@ -26880,25 +26429,14 @@ Object.assign(lookup, { */ var socket_io_parser_1 = require("socket.io-parser"); Object.defineProperty(exports, "protocol", { enumerable: true, get: function () { return socket_io_parser_1.protocol; } }); -var engine_io_client_1 = require("engine.io-client"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return engine_io_client_1.Fetch; } }); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return engine_io_client_1.NodeXHR; } }); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return engine_io_client_1.XHR; } }); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return engine_io_client_1.NodeWebSocket; } }); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return engine_io_client_1.WebSocket; } }); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return engine_io_client_1.WebTransport; } }); module.exports = lookup; -},{"./manager.js":452,"./socket.js":454,"./url.js":455,"debug":456,"engine.io-client":370,"socket.io-parser":459}],452:[function(require,module,exports){ +},{"./manager.js":434,"./socket.js":436,"./url.js":437,"debug":340,"socket.io-parser":439}],434:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); + 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]; @@ -26927,7 +26465,7 @@ const on_js_1 = require("./on.js"); const backo2_js_1 = require("./contrib/backo2.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:manager"); // debug() +const debug = debug_1.default("socket.io-client:manager"); // debug() class Manager extends component_emitter_1.Emitter { constructor(uri, opts) { var _a; @@ -26941,7 +26479,7 @@ class Manager extends component_emitter_1.Emitter { opts = opts || {}; opts.path = opts.path || "/socket.io"; this.opts = opts; - (0, engine_io_client_1.installTimerFunctions)(this, opts); + engine_io_client_1.installTimerFunctions(this, opts); this.reconnection(opts.reconnection !== false); this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); this.reconnectionDelay(opts.reconnectionDelay || 1000); @@ -26966,9 +26504,6 @@ class Manager extends component_emitter_1.Emitter { if (!arguments.length) return this._reconnection; this._reconnection = !!v; - if (!v) { - this.skipReconnect = true; - } return this; } reconnectionAttempts(v) { @@ -27040,7 +26575,7 @@ class Manager extends component_emitter_1.Emitter { this._readyState = "opening"; this.skipReconnect = false; // emit `open` - const openSubDestroy = (0, on_js_1.on)(socket, "open", function () { + const openSubDestroy = on_js_1.on(socket, "open", function () { self.onopen(); fn && fn(); }); @@ -27058,7 +26593,7 @@ class Manager extends component_emitter_1.Emitter { } }; // emit `error` - const errorSub = (0, on_js_1.on)(socket, "error", onError); + const errorSub = on_js_1.on(socket, "error", onError); if (false !== this._timeout) { const timeout = this._timeout; debug("connect attempt will timeout after %d", timeout); @@ -27103,9 +26638,7 @@ class Manager extends component_emitter_1.Emitter { this.emitReserved("open"); // add new subs const socket = this.engine; - this.subs.push((0, on_js_1.on)(socket, "ping", this.onping.bind(this)), (0, on_js_1.on)(socket, "data", this.ondata.bind(this)), (0, on_js_1.on)(socket, "error", this.onerror.bind(this)), (0, on_js_1.on)(socket, "close", this.onclose.bind(this)), - // @ts-ignore - (0, on_js_1.on)(this.decoder, "decoded", this.ondecoded.bind(this))); + this.subs.push(on_js_1.on(socket, "ping", this.onping.bind(this)), on_js_1.on(socket, "data", this.ondata.bind(this)), on_js_1.on(socket, "error", this.onerror.bind(this)), on_js_1.on(socket, "close", this.onclose.bind(this)), on_js_1.on(this.decoder, "decoded", this.ondecoded.bind(this))); } /** * Called upon a ping. @@ -27135,7 +26668,7 @@ class Manager extends component_emitter_1.Emitter { */ ondecoded(packet) { // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error" - (0, engine_io_client_1.nextTick)(() => { + engine_io_client_1.nextTick(() => { this.emitReserved("packet", packet); }, this.setTimeoutFn); } @@ -27216,6 +26749,8 @@ class Manager extends component_emitter_1.Emitter { this.skipReconnect = true; this._reconnecting = false; this.onclose("forced close"); + if (this.engine) + this.engine.close(); } /** * Alias for close() @@ -27226,19 +26761,13 @@ class Manager extends component_emitter_1.Emitter { return this._close(); } /** - * Called when: - * - * - the low-level engine is closed - * - the parser encountered a badly formatted packet - * - all sockets are disconnected + * Called upon engine close. * * @private */ onclose(reason, description) { - var _a; debug("closed due to %s", reason); this.cleanup(); - (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close(); this.backoff.reset(); this._readyState = "closed"; this.emitReserved("close", reason, description); @@ -27308,18 +26837,19 @@ class Manager extends component_emitter_1.Emitter { } exports.Manager = Manager; -},{"./contrib/backo2.js":450,"./on.js":453,"./socket.js":454,"@socket.io/component-emitter":23,"debug":456,"engine.io-client":370,"socket.io-parser":459}],453:[function(require,module,exports){ +},{"./contrib/backo2.js":432,"./on.js":435,"./socket.js":436,"@socket.io/component-emitter":23,"debug":340,"engine.io-client":366,"socket.io-parser":439}],435:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.on = on; +exports.on = void 0; function on(obj, ev, fn) { obj.on(ev, fn); return function subDestroy() { obj.off(ev, fn); }; } +exports.on = on; -},{}],454:[function(require,module,exports){ +},{}],436:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -27330,7 +26860,7 @@ const socket_io_parser_1 = require("socket.io-parser"); const on_js_1 = require("./on.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:socket"); // debug() +const debug = debug_1.default("socket.io-client:socket"); // debug() /** * Internal events. * These events can't be emitted by the user. @@ -27476,10 +27006,10 @@ class Socket extends component_emitter_1.Emitter { return; const io = this.io; this.subs = [ - (0, on_js_1.on)(io, "open", this.onopen.bind(this)), - (0, on_js_1.on)(io, "packet", this.onpacket.bind(this)), - (0, on_js_1.on)(io, "error", this.onerror.bind(this)), - (0, on_js_1.on)(io, "close", this.onclose.bind(this)), + on_js_1.on(io, "open", this.onopen.bind(this)), + on_js_1.on(io, "packet", this.onpacket.bind(this)), + on_js_1.on(io, "error", this.onerror.bind(this)), + on_js_1.on(io, "close", this.onclose.bind(this)), ]; } /** @@ -27566,7 +27096,6 @@ class Socket extends component_emitter_1.Emitter { * @return self */ emit(ev, ...args) { - var _a, _b, _c; if (RESERVED_EVENTS.hasOwnProperty(ev)) { throw new Error('"' + ev.toString() + '" is a reserved event name'); } @@ -27589,13 +27118,14 @@ class Socket extends component_emitter_1.Emitter { this._registerAckCallback(id, ack); packet.id = id; } - const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable; - const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired()); - const discardPacket = this.flags.volatile && !isTransportWritable; + const isTransportWritable = this.io.engine && + this.io.engine.transport && + this.io.engine.transport.writable; + const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected); if (discardPacket) { debug("discard packet as the transport is not currently writable"); } - else if (isConnected) { + else if (this.connected) { this.notifyOutgoingListeners(packet); this.packet(packet); } @@ -28231,16 +27761,16 @@ class Socket extends component_emitter_1.Emitter { } exports.Socket = Socket; -},{"./on.js":453,"@socket.io/component-emitter":23,"debug":456,"socket.io-parser":459}],455:[function(require,module,exports){ +},{"./on.js":435,"@socket.io/component-emitter":23,"debug":340,"socket.io-parser":439}],437:[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.url = url; +exports.url = void 0; const engine_io_client_1 = require("engine.io-client"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:url"); // debug() +const debug = debug_1.default("socket.io-client:url"); // debug() /** * URL parser. * @@ -28277,7 +27807,7 @@ function url(uri, path = "", loc) { } // parse debug("parse %s", uri); - obj = (0, engine_io_client_1.parse)(uri); + obj = engine_io_client_1.parse(uri); } // make sure we treat `localhost:80` and `localhost` equally if (!obj.port) { @@ -28301,12 +27831,9 @@ function url(uri, path = "", loc) { (loc && loc.port === obj.port ? "" : ":" + obj.port); return obj; } +exports.url = url; -},{"debug":456,"engine.io-client":370}],456:[function(require,module,exports){ -arguments[4][380][0].apply(exports,arguments) -},{"./common":457,"_process":447,"dup":380}],457:[function(require,module,exports){ -arguments[4][381][0].apply(exports,arguments) -},{"dup":381,"ms":441}],458:[function(require,module,exports){ +},{"debug":340,"engine.io-client":366}],438:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reconstructPacket = exports.deconstructPacket = void 0; @@ -28396,7 +27923,7 @@ function _reconstructPacket(data, buffers) { return data; } -},{"./is-binary.js":460}],459:[function(require,module,exports){ +},{"./is-binary.js":440}],439:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0; @@ -28719,7 +28246,7 @@ class BinaryReconstructor { } } -},{"./binary.js":458,"./is-binary.js":460,"@socket.io/component-emitter":23,"debug":461}],460:[function(require,module,exports){ +},{"./binary.js":438,"./is-binary.js":440,"@socket.io/component-emitter":23,"debug":340}],440:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasBinary = exports.isBinary = void 0; @@ -28776,11 +28303,7 @@ function hasBinary(obj, toJSON) { } exports.hasBinary = hasBinary; -},{}],461:[function(require,module,exports){ -arguments[4][380][0].apply(exports,arguments) -},{"./common":462,"_process":447,"dup":380}],462:[function(require,module,exports){ -arguments[4][381][0].apply(exports,arguments) -},{"dup":381,"ms":441}],463:[function(require,module,exports){ +},{}],441:[function(require,module,exports){ /* eslint-disable */ /** * used in docs/index.html @@ -28814,4 +28337,4 @@ channel.onmessage = function (message) { console.dir('recieved message: ' + message); addTextToMessageBox('recieved: ' + message); }; -},{"../../":2,"@babel/polyfill":11}]},{},[463]); +},{"../../":2,"@babel/polyfill":11}]},{},[441]); diff --git a/docs/worker.js b/docs/worker.js index 72cf77fd..d91b45e0 100644 --- a/docs/worker.js +++ b/docs/worker.js @@ -1,11 +1,9 @@ (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 Promise.all(this._befC.map(fn => fn()))) // close the channel - .then(() => this.method.close ? this.method.close(this._state) : Promise.resolve()); + .then(() => this.method.close(this._state)); }, get type() { return this.method.type; @@ -166,7 +164,6 @@ function _post(broadcastChannel, type, msg) { // add/remove to unsend messages list broadcastChannel._uMP.add(sendPromise); - // eslint-disable-next-line promise/valid-params sendPromise.catch().then(() => broadcastChannel._uMP.delete(sendPromise)); return sendPromise; }); @@ -181,7 +178,6 @@ function _prepareChannel(channel) { await new Promise(res => setTimeout(res, this.options.prepareDelay)); }*/ channel._state = s; - return; }); } else { channel._state = maybePromise; @@ -220,7 +216,7 @@ function _startListening(channel) { if (msgObj.time >= listenerObject.time) { listenerObject.fn(msgObj.data); - } else if (channel.method.type === "server") { + } else if (channel.method.type === 'server') { // server msg might lag based on connection. listenerObject.fn(msgObj.data); } @@ -231,7 +227,6 @@ function _startListening(channel) { channel._prepP.then(() => { channel._iL = true; channel.method.onMessage(channel._state, listenerFn, time); - return; }); } else { channel._iL = true; @@ -255,18 +250,18 @@ exports.enforceOptions = enforceOptions; },{"./method-chooser.js":3,"./options.js":9,"./util.js":10}],2:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var broadcastChannel = require('./broadcast-channel.js'); var methodChooser = require('./method-chooser.js'); +exports.NativeMethod = native; exports.IndexedDbMethod = indexedDb; exports.LocalstorageMethod = localstorage; -exports.NativeMethod = native; exports.ServerMethod = server; exports.BroadcastChannel = broadcastChannel.BroadcastChannel; exports.OPEN_BROADCAST_CHANNELS = broadcastChannel.OPEN_BROADCAST_CHANNELS; @@ -276,9 +271,9 @@ exports.chooseMethod = methodChooser.chooseMethod; },{"./broadcast-channel.js":1,"./method-chooser.js":3,"./methods/indexed-db.js":4,"./methods/localstorage.js":5,"./methods/native.js":6,"./methods/server.js":7}],3:[function(require,module,exports){ 'use strict'; +var native = require('./methods/native.js'); var indexedDb = require('./methods/indexed-db.js'); var localstorage = require('./methods/localstorage.js'); -var native = require('./methods/native.js'); var server = require('./methods/server.js'); var simulate = require('./methods/simulate.js'); @@ -291,12 +286,12 @@ function chooseMethod(options) { // directly chosen if (options.type) { - if (options.type === "simulate") { + if (options.type === 'simulate') { // only use simulate-method if directly chosen return simulate; } const ret = chooseMethods.find(m => m.type === options.type); - if (!ret) throw new Error("method-type " + options.type + " not found");else return ret; + if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret; } /** @@ -304,7 +299,7 @@ function chooseMethod(options) { * remove idb from the list so that localstorage is been chosen */ if (!options.webWorkerSupport) { - chooseMethods = chooseMethods.filter(m => m.type !== "idb"); + chooseMethods = chooseMethods.filter(m => m.type !== 'idb'); } const useMethod = chooseMethods.find(method => method.canBeUsed(options)); if (!useMethod) throw new Error(`No useable method found in ${JSON.stringify(METHODS.map(m => m.type))}`);else return useMethod; @@ -329,23 +324,23 @@ var options = require('../options.js'); */ const microSeconds = util.microSeconds; -const DB_PREFIX = "pubkey.broadcast-channel-0-"; -const OBJECT_STORE_ID = "messages"; +const DB_PREFIX = 'pubkey.broadcast-channel-0-'; +const OBJECT_STORE_ID = 'messages'; /** * Use relaxed durability for faster performance on all transactions. * @link https://nolanlawson.com/2021/08/22/speeding-up-indexeddb-reads-and-writes/ */ const TRANSACTION_SETTINGS = { - durability: "relaxed" + durability: 'relaxed' }; -const type = "idb"; +const type = 'idb'; function getIdb() { - if (typeof indexedDB !== "undefined") return indexedDB; - if (typeof window !== "undefined") { - if (typeof window.mozIndexedDB !== "undefined") return window.mozIndexedDB; - if (typeof window.webkitIndexedDB !== "undefined") return window.webkitIndexedDB; - if (typeof window.msIndexedDB !== "undefined") return window.msIndexedDB; + if (typeof indexedDB !== 'undefined') return indexedDB; + if (typeof window !== 'undefined') { + if (typeof window.mozIndexedDB !== 'undefined') return window.mozIndexedDB; + if (typeof window.webkitIndexedDB !== 'undefined') return window.webkitIndexedDB; + if (typeof window.msIndexedDB !== 'undefined') return window.msIndexedDB; } return false; } @@ -375,14 +370,14 @@ function createDatabase(channelName) { openRequest.onupgradeneeded = ev => { const db = ev.target.result; db.createObjectStore(OBJECT_STORE_ID, { - keyPath: "id", + keyPath: 'id', autoIncrement: true }); }; - const dbPromise = new Promise((resolve, reject) => { - openRequest.onerror = ev => reject(ev); + const dbPromise = new Promise((res, rej) => { + openRequest.onerror = ev => rej(ev); openRequest.onsuccess = () => { - resolve(openRequest.result); + res(openRequest.result); }; }); return dbPromise; @@ -399,20 +394,20 @@ function writeMessage(db, readerUuid, messageJson) { time, data: messageJson }; - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); - return new Promise((resolve, reject) => { - tx.oncomplete = () => resolve(); - tx.onerror = ev => reject(ev); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); + return new Promise((res, rej) => { + tx.oncomplete = () => res(); + tx.onerror = ev => rej(ev); const objectStore = tx.objectStore(OBJECT_STORE_ID); objectStore.add(writeObject); commitIndexedDBTransaction(tx); }); } function getAllMessages(db) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -421,13 +416,13 @@ function getAllMessages(db) { cursor.continue(); } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function getMessagesHigherThan(db, lastCursorId) { - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; let keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); @@ -439,10 +434,10 @@ function getMessagesHigherThan(db, lastCursorId) { */ if (objectStore.getAll) { const getAllRequest = objectStore.getAll(keyRangeValue); - return new Promise((resolve, reject) => { - getAllRequest.onerror = err => reject(err); + return new Promise((res, rej) => { + getAllRequest.onerror = err => rej(err); getAllRequest.onsuccess = function (e) { - resolve(e.target.result); + res(e.target.result); }; }); } @@ -453,13 +448,13 @@ function getMessagesHigherThan(db, lastCursorId) { try { keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, Infinity); return objectStore.openCursor(keyRangeValue); - } catch { + } catch (e) { return objectStore.openCursor(); } } - return new Promise((resolve, reject) => { + return new Promise((res, rej) => { const openCursorRequest = openCursor(); - openCursorRequest.onerror = err => reject(err); + openCursorRequest.onerror = err => rej(err); openCursorRequest.onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -471,27 +466,27 @@ function getMessagesHigherThan(db, lastCursorId) { } } else { commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); } }; }); } function removeMessagesById(db, ids) { - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); + const tx = db.transaction([OBJECT_STORE_ID], 'readwrite', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); return Promise.all(ids.map(id => { const deleteRequest = objectStore.delete(id); - return new Promise(resolve => { - deleteRequest.onsuccess = () => resolve(); + return new Promise(res => { + deleteRequest.onsuccess = () => res(); }); })); } function getOldMessages(db, ttl) { const olderThen = Date.now() - ttl; - const tx = db.transaction(OBJECT_STORE_ID, "readonly", TRANSACTION_SETTINGS); + const tx = db.transaction(OBJECT_STORE_ID, 'readonly', TRANSACTION_SETTINGS); const objectStore = tx.objectStore(OBJECT_STORE_ID); const ret = []; - return new Promise(resolve => { + return new Promise(res => { objectStore.openCursor().onsuccess = ev => { const cursor = ev.target.result; if (cursor) { @@ -503,11 +498,11 @@ function getOldMessages(db, ttl) { } else { // no more old messages, commitIndexedDBTransaction(tx); - resolve(ret); + res(ret); return; } } else { - resolve(ret); + res(ret); } }; }); @@ -562,8 +557,6 @@ function create(channelName, options$1) { } function _readLoop(state) { if (state.closed) return; - - // eslint-disable-next-line promise/catch-or-return readNewMessages(state).then(() => util.sleep(state.options.idb.fallbackInterval)).then(() => _readLoop(state)); } function _filterMessage(msgObj, state) { @@ -609,7 +602,6 @@ function close(channelState) { } function postMessage(channelState, messageJson) { channelState.writeBlockPromise = channelState.writeBlockPromise.then(() => writeMessage(channelState.db, channelState.uuid, messageJson)).then(() => { - // eslint-disable-next-line promise/always-return if (util.randomInt(0, 10) === 0) { /* await (do not await) */ cleanOldMessages(channelState.db, channelState.options.idb.ttl); @@ -650,7 +642,7 @@ exports.removeMessagesById = removeMessagesById; exports.type = type; exports.writeMessage = writeMessage; -},{"../options.js":9,"../util.js":10,"oblivious-set":500}],5:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":481}],5:[function(require,module,exports){ 'use strict'; var obliviousSet = require('oblivious-set'); @@ -666,8 +658,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "localstorage"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'localstorage'; /** * copied from crosstab @@ -675,11 +667,11 @@ const type = "localstorage"; */ function getLocalStorage() { let localStorage; - if (typeof window === "undefined") return null; + if (typeof window === 'undefined') return null; try { localStorage = window.localStorage; - localStorage = window["ie8-eventlistener/storage"] || window.localStorage; - } catch { + localStorage = window['ie8-eventlistener/storage'] || window.localStorage; + } catch (e) { // New versions of Firefox throw a Security exception // if cookies are disabled. See // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153 @@ -695,8 +687,7 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise(resolve => { - // eslint-disable-next-line promise/catch-or-return, promise/always-return + return new Promise(res => { util.sleep().then(() => { const key = storageKey(channelState.channelName); const writeObj = { @@ -713,12 +704,12 @@ function postMessage(channelState, messageJson) { * in the window that changes the state of the local storage. * So we fire it manually */ - const ev = document.createEvent("Event"); - ev.initEvent("storage", true, true); + const ev = document.createEvent('Event'); + ev.initEvent('storage', true, true); ev.key = key; ev.newValue = value; window.dispatchEvent(ev); - resolve(); + res(); }); }); } @@ -729,16 +720,16 @@ function addStorageEventListener(channelName, fn) { fn(JSON.parse(ev.newValue)); } }; - window.addEventListener("storage", listener); + window.addEventListener('storage', listener); return listener; } function removeStorageEventListener(listener) { - window.removeEventListener("storage", listener); + window.removeEventListener('storage', listener); } function create(channelName, options$1) { options$1 = options.fillOptionsWithDefaults(options$1); if (!canBeUsed()) { - throw new Error("BroadcastChannel: localstorage cannot be used"); + throw new Error('BroadcastChannel: localstorage cannot be used'); } const uuid = util.randomToken(); @@ -776,10 +767,10 @@ function canBeUsed() { const ls = getLocalStorage(); if (!ls) return false; try { - const key = "__broadcastchannel_check"; - ls.setItem(key, "works"); + const key = '__broadcastchannel_check'; + ls.setItem(key, 'works'); ls.removeItem(key); - } catch { + } catch (e) { // Safari 10 in private mode will not allow write access to local // storage and fail with a QuotaExceededError. See // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes @@ -790,7 +781,7 @@ function canBeUsed() { function averageResponseTime() { const defaultTime = 120; const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes("safari") && !userAgent.includes("chrome")) { + if (userAgent.includes('safari') && !userAgent.includes('chrome')) { // safari is much slower so this time is higher return defaultTime * 2; } @@ -810,13 +801,13 @@ exports.removeStorageEventListener = removeStorageEventListener; exports.storageKey = storageKey; exports.type = type; -},{"../options.js":9,"../util.js":10,"oblivious-set":500}],6:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"oblivious-set":481}],6:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "native"; +const type = 'native'; function create(channelName) { const state = { time: util.microSeconds(), @@ -851,10 +842,10 @@ function canBeUsed() { * in the electron-renderer, isNode will be true even if we are in browser-context * so we also check if window is undefined */ - if (typeof window === "undefined") return false; - if (typeof BroadcastChannel === "function") { + if (typeof window === 'undefined') return false; + if (typeof BroadcastChannel === 'function') { if (BroadcastChannel._pubkey) { - throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"); + throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill'); } return true; } else return false; @@ -876,12 +867,12 @@ exports.type = type; (function (Buffer){(function (){ 'use strict'; -var eccrypto = require('@toruslabs/eccrypto'); -var metadataHelpers = require('@toruslabs/metadata-helpers'); var obliviousSet = require('oblivious-set'); var socket_ioClient = require('socket.io-client'); -var options = require('../options.js'); +var eccrypto = require('@toruslabs/eccrypto'); +var metadataHelpers = require('@toruslabs/metadata-helpers'); var util = require('../util.js'); +var options = require('../options.js'); /** * A localStorage-only method which uses localstorage and its 'storage'-event @@ -892,8 +883,8 @@ var util = require('../util.js'); */ const microSeconds = util.microSeconds; -const KEY_PREFIX = "pubkey.broadcastChannel-"; -const type = "server"; +const KEY_PREFIX = 'pubkey.broadcastChannel-'; +const type = 'server'; let SOCKET_CONN_INSTANCE = null; // used to decide to reconnect socket e.g. when socket connection is disconnected unexpectedly const runningChannels = new Set(); @@ -906,12 +897,11 @@ function storageKey(channelName) { * and fires the storage-event so other readers can find it */ function postMessage(channelState, messageJson) { - return new Promise((resolve, reject) => { - // eslint-disable-next-line promise/catch-or-return + return new Promise((res, rej) => { util.sleep().then(async () => { const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString("hex"), { + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const encData = await metadataHelpers.encryptData(channelEncPrivKey.toString('hex'), { token: util.randomToken(), time: Date.now(), data: messageJson, @@ -920,18 +910,18 @@ function postMessage(channelState, messageJson) { const body = { sameOriginCheck: true, sameIpCheck: true, - key: eccrypto.getPublic(channelEncPrivKey).toString("hex"), + key: eccrypto.getPublic(channelEncPrivKey).toString('hex'), data: encData, - signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, "utf8")))).toString("hex") + signature: (await eccrypto.sign(channelEncPrivKey, metadataHelpers.keccak256(Buffer.from(encData, 'utf8')))).toString('hex') }; if (channelState.timeout) body.timeout = channelState.timeout; - return fetch(channelState.serverUrl + "/channel/set", { - method: "POST", + return fetch(channelState.serverUrl + '/channel/set', { + method: 'POST', body: JSON.stringify(body), headers: { - "Content-Type": "application/json; charset=utf-8" + 'Content-Type': 'application/json; charset=utf-8' } - }).then(resolve).catch(reject); + }).then(res).catch(rej); }); }); } @@ -940,33 +930,33 @@ function getSocketInstance(serverUrl) { return SOCKET_CONN_INSTANCE; } const SOCKET_CONN = socket_ioClient.io(serverUrl, { - transports: ["websocket", "polling"], + transports: ['websocket', 'polling'], // use WebSocket first, if available withCredentials: true, reconnectionDelayMax: 10000, reconnectionAttempts: 10 }); - SOCKET_CONN.on("connect_error", err => { + SOCKET_CONN.on('connect_error', err => { // revert to classic upgrade - SOCKET_CONN.io.opts.transports = ["polling", "websocket"]; - util.log.error("connect error", err); + SOCKET_CONN.io.opts.transports = ['polling', 'websocket']; + util.log.error('connect error', err); }); - SOCKET_CONN.on("connect", async () => { + SOCKET_CONN.on('connect', async () => { const { engine } = SOCKET_CONN.io; - util.log.debug("initially connected to", engine.transport.name); // in most cases, prints "polling" - engine.once("upgrade", () => { + util.log.debug('initially connected to', engine.transport.name); // in most cases, prints "polling" + engine.once('upgrade', () => { // called when the transport is upgraded (i.e. from HTTP long-polling to WebSocket) - util.log.debug("upgraded", engine.transport.name); // in most cases, prints "websocket" + util.log.debug('upgraded', engine.transport.name); // in most cases, prints "websocket" }); - engine.once("close", reason => { + engine.once('close', reason => { // called when the underlying connection is closed - util.log.debug("connection closed", reason); + util.log.debug('connection closed', reason); }); }); - SOCKET_CONN.on("error", err => { - util.log.error("socket errored", err); + SOCKET_CONN.on('error', err => { + util.log.error('socket errored', err); SOCKET_CONN.disconnect(); }); SOCKET_CONN_INSTANCE = SOCKET_CONN; @@ -975,26 +965,26 @@ function getSocketInstance(serverUrl) { function setupSocketConnection(serverUrl, channelState, fn) { const socketConn = getSocketInstance(serverUrl); const key = storageKey(channelState.channelName); - const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, "utf8")); - const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString("hex"); + const channelEncPrivKey = metadataHelpers.keccak256(Buffer.from(key, 'utf8')); + const channelPubKey = eccrypto.getPublic(channelEncPrivKey).toString('hex'); if (socketConn.connected) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); } else { - socketConn.once("connect", () => { - util.log.debug("connected with socket"); - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.once('connect', () => { + util.log.debug('connected with socket'); + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); }); } const reconnect = () => { - socketConn.once("connect", async () => { + socketConn.once('connect', async () => { if (runningChannels.has(channelState.channelName)) { - socketConn.emit("check_auth_status", channelPubKey, { + socketConn.emit('check_auth_status', channelPubKey, { sameOriginCheck: true, sameIpCheck: true }); @@ -1004,32 +994,32 @@ function setupSocketConnection(serverUrl, channelState, fn) { const visibilityListener = () => { // if channel is closed, then remove the listener. if (!socketConn || !runningChannels.has(channelState.channelName)) { - document.removeEventListener("visibilitychange", visibilityListener); + document.removeEventListener('visibilitychange', visibilityListener); return; } // if not connected, then wait for connection and ping server for latest msg. - if (!socketConn.connected && document.visibilityState === "visible") { + if (!socketConn.connected && document.visibilityState === 'visible') { reconnect(); } }; const listener = async ev => { try { - const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString("hex"), ev); + const decData = await metadataHelpers.decryptData(channelEncPrivKey.toString('hex'), ev); util.log.info(decData); fn(decData); } catch (error) { util.log.error(error); } }; - socketConn.on("disconnect", () => { - util.log.debug("socket disconnected"); + socketConn.on('disconnect', () => { + util.log.debug('socket disconnected'); if (runningChannels.has(channelState.channelName)) { - util.log.error("socket disconnected unexpectedly, reconnecting socket"); + util.log.error('socket disconnected unexpectedly, reconnecting socket'); reconnect(); } }); socketConn.on(`${channelPubKey}_success`, listener); - if (typeof document !== "undefined") document.addEventListener("visibilitychange", visibilityListener); + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', visibilityListener); return socketConn; } function removeStorageEventListener() { @@ -1104,13 +1094,13 @@ exports.storageKey = storageKey; exports.type = type; }).call(this)}).call(this,require("buffer").Buffer) -},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":53,"oblivious-set":500,"socket.io-client":517}],8:[function(require,module,exports){ +},{"../options.js":9,"../util.js":10,"@toruslabs/eccrypto":24,"@toruslabs/metadata-helpers":27,"buffer":53,"oblivious-set":481,"socket.io-client":494}],8:[function(require,module,exports){ 'use strict'; var util = require('../util.js'); const microSeconds = util.microSeconds; -const type = "simulate"; +const type = 'simulate'; const SIMULATE_CHANNELS = new Set(); const SIMULATE_DELAY_TIME = 5; function create(channelName) { @@ -1126,7 +1116,7 @@ function close(channelState) { SIMULATE_CHANNELS.delete(channelState); } function postMessage(channelState, messageJson) { - return new Promise(resolve => setTimeout(() => { + return new Promise(res => setTimeout(() => { const channelArray = Array.from(SIMULATE_CHANNELS); channelArray.forEach(channel => { if (channel.name === channelState.name && @@ -1140,7 +1130,7 @@ function postMessage(channelState, messageJson) { channel.messagesCallback(messageJson); } }); - resolve(); + res(); }, SIMULATE_DELAY_TIME)); } function onMessage(channelState, fn) { @@ -1170,7 +1160,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { const options = JSON.parse(JSON.stringify(originalOptions)); // main - if (typeof options.webWorkerSupport === "undefined") options.webWorkerSupport = true; + if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db if (!options.idb) options.idb = {}; @@ -1178,7 +1168,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { if (!options.idb.ttl) options.idb.ttl = 1000 * 45; if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events. - if (originalOptions.idb && typeof originalOptions.idb.onclose === "function") options.idb.onclose = originalOptions.idb.onclose; + if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage if (!options.localstorage) options.localstorage = {}; @@ -1186,7 +1176,7 @@ function fillOptionsWithDefaults(originalOptions = {}) { // server if (!options.server) options.server = {}; - if (!options.server.url) options.server.url = "https://session.web3auth.io"; + if (!options.server.url) options.server.url = 'https://session.web3auth.io'; if (!options.server.removeTimeout) options.server.removeTimeout = 1000 * 60 * 5; // 5 minutes // custom methods @@ -1207,7 +1197,7 @@ var loglevel = require('loglevel'); * returns true if the given object is a promise */ function isPromise(obj) { - if (obj && typeof obj.then === "function") { + if (obj && typeof obj.then === 'function') { return true; } else { return false; @@ -1218,7 +1208,7 @@ Promise.resolve(true); const PROMISE_RESOLVED_VOID = Promise.resolve(); function sleep(time, resolveWith) { if (!time) time = 0; - return new Promise(resolve => setTimeout(() => resolve(resolveWith), time)); + return new Promise(res => setTimeout(() => res(resolveWith), time)); } function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); @@ -1272,8 +1262,8 @@ function microSeconds() { // return thirdPartyCookieSupport; // } -const log = loglevel.getLogger("broadcast-channel"); -log.setLevel("error"); +const log = loglevel.getLogger('broadcast-channel'); +log.setLevel('error'); exports.PROMISE_RESOLVED_VOID = PROMISE_RESOLVED_VOID; exports.isPromise = isPromise; @@ -1283,7 +1273,7 @@ exports.randomInt = randomInt; exports.randomToken = randomToken; exports.sleep = sleep; -},{"loglevel":476}],11:[function(require,module,exports){ +},{"loglevel":465}],11:[function(require,module,exports){ "use strict"; require("./noConflict"); @@ -1297,7 +1287,7 @@ if (_global["default"]._babelPolyfill && typeof console !== "undefined" && conso } _global["default"]._babelPolyfill = true; -},{"./noConflict":12,"core-js/library/fn/global":76}],12:[function(require,module,exports){ +},{"./noConflict":12,"core-js/library/fn/global":69}],12:[function(require,module,exports){ "use strict"; require("core-js/es6"); @@ -1327,7 +1317,7 @@ require("core-js/fn/promise/finally"); require("core-js/web"); require("regenerator-runtime/runtime"); -},{"core-js/es6":64,"core-js/fn/array/flat-map":65,"core-js/fn/array/includes":66,"core-js/fn/object/entries":67,"core-js/fn/object/get-own-property-descriptors":68,"core-js/fn/object/values":69,"core-js/fn/promise/finally":70,"core-js/fn/string/pad-end":71,"core-js/fn/string/pad-start":72,"core-js/fn/string/trim-end":73,"core-js/fn/string/trim-start":74,"core-js/fn/symbol/async-iterator":75,"core-js/web":367,"regenerator-runtime/runtime":504}],13:[function(require,module,exports){ +},{"core-js/es6":57,"core-js/fn/array/flat-map":58,"core-js/fn/array/includes":59,"core-js/fn/object/entries":60,"core-js/fn/object/get-own-property-descriptors":61,"core-js/fn/object/values":62,"core-js/fn/promise/finally":63,"core-js/fn/string/pad-end":64,"core-js/fn/string/pad-start":65,"core-js/fn/string/trim-end":66,"core-js/fn/string/trim-start":67,"core-js/fn/symbol/async-iterator":68,"core-js/web":360,"regenerator-runtime/runtime":485}],13:[function(require,module,exports){ var toPropertyKey = require("./toPropertyKey.js"); function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { @@ -1387,54 +1377,54 @@ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports function _typeof(o) { "@babel/helpers - typeof"; - return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; },{}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isBytes = isBytes; -exports.number = number; -exports.bool = bool; -exports.bytes = bytes; -exports.hash = hash; -exports.exists = exists; -exports.output = output; +exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = exports.isBytes = void 0; function number(n) { if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); } +exports.number = number; function bool(b) { if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`); } +exports.bool = bool; // copied from utils function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; function bytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); } +exports.bytes = bytes; function hash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); number(h.outputLen); number(h.blockLen); } +exports.hash = hash; function exists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } +exports.exists = exists; function output(out, instance) { bytes(out); const min = instance.outputLen; @@ -1442,16 +1432,14 @@ function output(out, instance) { throw new Error(`digestInto() expects output buffer of length at least ${min}`); } } +exports.output = output; const assert = { number, bool, bytes, hash, exists, output }; exports.default = assert; },{}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = void 0; -exports.fromBig = fromBig; -exports.split = split; -exports.add = add; +exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.add = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = exports.split = exports.fromBig = void 0; const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); // We are not using BigUint64Array, because they are extremely slow as per 2022 @@ -1460,6 +1448,7 @@ function fromBig(n, le = false) { return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; } +exports.fromBig = fromBig; function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); @@ -1469,6 +1458,7 @@ function split(lst, le = false) { } return [Ah, Al]; } +exports.split = split; const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0); exports.toBig = toBig; // for Shift in [0, 32) @@ -1507,6 +1497,7 @@ function add(Ah, Al, Bh, Bl) { const l = (Al >>> 0) + (Bl >>> 0); return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }; } +exports.add = add; // Addition with more than 2 elements const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); exports.add3L = add3L; @@ -1540,8 +1531,7 @@ exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? glob },{}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0; -exports.keccakP = keccakP; +exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0; const _assert_js_1 = require("./_assert.js"); const _u64_js_1 = require("./_u64.js"); const utils_js_1 = require("./utils.js"); @@ -1622,6 +1612,7 @@ function keccakP(s, rounds = 24) { } B.fill(0); } +exports.keccakP = keccakP; class Keccak extends utils_js_1.Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { @@ -1761,20 +1752,7 @@ exports.shake256 = genShake(0x1f, 136, 256 / 8); "use strict"; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0; -exports.isBytes = isBytes; -exports.byteSwap32 = byteSwap32; -exports.bytesToHex = bytesToHex; -exports.hexToBytes = hexToBytes; -exports.asyncLoop = asyncLoop; -exports.utf8ToBytes = utf8ToBytes; -exports.toBytes = toBytes; -exports.concatBytes = concatBytes; -exports.checkOpts = checkOpts; -exports.wrapConstructor = wrapConstructor; -exports.wrapConstructorWithOpts = wrapConstructorWithOpts; -exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; -exports.randomBytes = randomBytes; +exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.byteSwap32 = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = exports.isBytes = void 0; // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. // node.js versions earlier than v19 don't declare it in global scope. // For node.js, package.json#exports field mapping rewrites import @@ -1789,6 +1767,7 @@ function isBytes(a) { return (a instanceof Uint8Array || (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')); } +exports.isBytes = isBytes; // Cast array to different type const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); exports.u8 = u8; @@ -1818,6 +1797,7 @@ function byteSwap32(arr) { arr[i] = (0, exports.byteSwap)(arr[i]); } } +exports.byteSwap32 = byteSwap32; // Array where index 0xf0 (240) is mapped to string 'f0' const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); /** @@ -1832,6 +1812,7 @@ function bytesToHex(bytes) { } return hex; } +exports.bytesToHex = bytesToHex; // We use optimized technique to convert hex string to byte array const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; function asciiToBase16(char) { @@ -1865,6 +1846,7 @@ function hexToBytes(hex) { } return array; } +exports.hexToBytes = hexToBytes; // There is no setImmediate in browser and setTimeout is slow. // call of async fn will return Promise, which will be fullfiled only on // next scheduler queue processing step and this is exactly what we need. @@ -1883,6 +1865,7 @@ async function asyncLoop(iters, tick, cb) { ts += diff; } } +exports.asyncLoop = asyncLoop; /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ @@ -1891,6 +1874,7 @@ function utf8ToBytes(str) { throw new Error(`utf8ToBytes expected string, got ${typeof str}`); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } +exports.utf8ToBytes = utf8ToBytes; /** * Normalizes (non-hex) string or Uint8Array to Uint8Array. * Warning: when Uint8Array is passed, it would NOT get copied. @@ -1902,6 +1886,7 @@ function toBytes(data) { (0, _assert_js_1.bytes)(data); return data; } +exports.toBytes = toBytes; /** * Copies several Uint8Arrays into one. */ @@ -1920,6 +1905,7 @@ function concatBytes(...arrays) { } return res; } +exports.concatBytes = concatBytes; // For runtime check if class implements interface class Hash { // Safe version that clones internal state @@ -1935,6 +1921,7 @@ function checkOpts(defaults, opts) { const merged = Object.assign(defaults, opts); return merged; } +exports.checkOpts = checkOpts; function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); @@ -1943,6 +1930,7 @@ function wrapConstructor(hashCons) { hashC.create = () => hashCons(); return hashC; } +exports.wrapConstructor = wrapConstructor; function wrapConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1951,6 +1939,7 @@ function wrapConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapConstructorWithOpts = wrapConstructorWithOpts; function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); @@ -1959,6 +1948,7 @@ function wrapXOFConstructorWithOpts(hashCons) { hashC.create = (opts) => hashCons(opts); return hashC; } +exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; /** * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. */ @@ -1966,12 +1956,9 @@ function randomBytes(bytesLength = 32) { if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') { return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); } - // Legacy Node.js compatibility - if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') { - return crypto_1.crypto.randomBytes(bytesLength); - } throw new Error('crypto.getRandomValues must be defined'); } +exports.randomBytes = randomBytes; },{"./_assert.js":18,"@noble/hashes/crypto":20}],23:[function(require,module,exports){ @@ -2197,26 +2184,18 @@ function equalConstTime(b1, b2) { not, since the functions are different and does not convert using browserify */ function randomBytes(size) { - if (typeof browserCrypto.getRandomValues === "undefined") { - return Buffer.from(browserCrypto.randomBytes(size)); - } const arr = new Uint8Array(size); browserCrypto.getRandomValues(arr); return Buffer.from(arr); } async function sha512(msg) { - if (!browserCrypto.createHash) { - const hash = await subtle.digest("SHA-512", msg); - const result = new Uint8Array(hash); - return result; - } - const hash = browserCrypto.createHash("sha512"); - const result = hash.update(msg).digest(); - return new Uint8Array(result); + const hash = await subtle.digest("SHA-512", msg); + const result = new Uint8Array(hash); + return result; } function getAes(op) { return async function (iv, key, data) { - if (subtle && subtle[op] && subtle.importKey) { + if (subtle) { const importAlgorithm = { name: "AES-CBC" }; @@ -2225,20 +2204,8 @@ function getAes(op) { name: "AES-CBC", iv }; - // encrypt and decrypt ops are not implemented in react-native-quick-crypto yet. const result = await subtle[op](encAlgorithm, cryptoKey, data); return Buffer.from(new Uint8Array(result)); - } else if (op === "encrypt" && browserCrypto.createCipheriv) { - // This is available if crypto is polyfilled in react native environment - const cipher = browserCrypto.createCipheriv("aes-256-cbc", key, iv); - const firstChunk = cipher.update(data); - const secondChunk = cipher.final(); - return Buffer.concat([firstChunk, secondChunk]); - } else if (op === "decrypt" && browserCrypto.createDecipheriv) { - const decipher = browserCrypto.createDecipheriv("aes-256-cbc", key, iv); - const firstChunk = decipher.update(data); - const secondChunk = decipher.final(); - return Buffer.concat([firstChunk, secondChunk]); } throw new Error(`Unsupported operation: ${op}`); }; @@ -2246,21 +2213,15 @@ function getAes(op) { const aesCbcEncrypt = getAes("encrypt"); const aesCbcDecrypt = getAes("decrypt"); async function hmacSha256Sign(key, msg) { - if (!browserCrypto.createHmac) { - const importAlgorithm = { - name: "HMAC", - hash: { - name: "SHA-256" - } - }; - const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); - const sig = await subtle.sign("HMAC", cryptoKey, msg); - const result = Buffer.from(new Uint8Array(sig)); - return result; - } - const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); - hmac.update(msg); - const result = hmac.digest(); + const importAlgorithm = { + name: "HMAC", + hash: { + name: "SHA-256" + } + }; + const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); + const sig = await subtle.sign("HMAC", cryptoKey, msg); + const result = Buffer.from(new Uint8Array(sig)); return result; } async function hmacSha256Verify(key, msg, sig) { @@ -2418,7 +2379,7 @@ exports.sign = sign; exports.verify = verify; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":53,"elliptic":373}],25:[function(require,module,exports){ +},{"buffer":53,"elliptic":367}],25:[function(require,module,exports){ 'use strict'; var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); @@ -2427,9 +2388,6 @@ var logLevel = require('loglevel'); const log = logLevel.getLogger("http-helpers"); log.setLevel(logLevel.levels.INFO); - -// eslint-disable-next-line @typescript-eslint/no-empty-object-type - let apiKey = "torus-default"; let embedHost = ""; @@ -2472,9 +2430,7 @@ async function fetchAndTrace(url, init) { let _url = null; try { _url = new URL(url); - } catch { - // ignore - } + } catch (error) {} if (sentry && _url && (tracingOrigins.includes(_url.origin) || tracingPaths.includes(_url.pathname))) { const result = await sentry.startSpan({ name: url, @@ -2538,7 +2494,7 @@ const get = async (url, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2577,7 +2533,7 @@ const post = (url, data = {}, options_ = {}, customOptions = {}) => { } if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2616,7 +2572,7 @@ const patch = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2654,7 +2610,7 @@ const put = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2690,7 +2646,7 @@ const remove = async (url, data = {}, options_ = {}, customOptions = {}) => { const response = await fetchAndTrace(url, options); if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType !== null && responseContentType !== undefined && responseContentType.includes("application/json")) { + if (responseContentType !== null && responseContentType !== void 0 && responseContentType.includes("application/json")) { return response.json(); } return response.text(); @@ -2729,7 +2685,7 @@ exports.setAPIKey = setAPIKey; exports.setEmbedHost = setEmbedHost; exports.setLogLevel = setLogLevel; -},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":369,"loglevel":476}],26:[function(require,module,exports){ +},{"@babel/runtime/helpers/objectSpread2":14,"deepmerge":364,"loglevel":465}],26:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -2743,8 +2699,8 @@ class MetadataStorageLayer { // ms constructor(metadataHost = "https://metadata.tor.us", serverTimeOffset = 0) { - _defineProperty(this, "metadataHost", undefined); - _defineProperty(this, "serverTimeOffset", undefined); + _defineProperty(this, "metadataHost", void 0); + _defineProperty(this, "serverTimeOffset", void 0); this.metadataHost = metadataHost; this.serverTimeOffset = serverTimeOffset; } @@ -2766,7 +2722,7 @@ class MetadataStorageLayer { pub_key_X: key.getPublic().getX().toString(16, 64), pub_key_Y: key.getPublic().getY().toString(16, 64), set_data: setData, - signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === undefined ? undefined : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== undefined ? _sig$recoveryParam$to : "00"), "hex").toString("base64") + signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + ((_sig$recoveryParam$to = (_sig$recoveryParam = sig.recoveryParam) === null || _sig$recoveryParam === void 0 ? void 0 : _sig$recoveryParam.toString(16).padStart(2, "0").slice(-2)) !== null && _sig$recoveryParam$to !== void 0 ? _sig$recoveryParam$to : "00"), "hex").toString("base64") }; } generatePubKeyParams(privateKeyHex) { @@ -2799,7 +2755,7 @@ class MetadataStorageLayer { exports.MetadataStorageLayer = MetadataStorageLayer; }).call(this)}).call(this,require("buffer").Buffer) -},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":53,"json-stable-stringify":472}],27:[function(require,module,exports){ +},{"./utils.js":28,"@babel/runtime/helpers/defineProperty":13,"@babel/runtime/helpers/objectSpread2":14,"@toruslabs/http-helpers":25,"buffer":53,"json-stable-stringify":461}],27:[function(require,module,exports){ 'use strict'; var MetadataStorageLayer = require('./MetadataStorageLayer.js'); @@ -2838,7 +2794,7 @@ exports.ec = ec; exports.keccak256 = keccak256; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":53,"elliptic":373,"ethereum-cryptography/keccak":421}],29:[function(require,module,exports){ +},{"buffer":53,"elliptic":367,"ethereum-cryptography/keccak":413}],29:[function(require,module,exports){ (function (Buffer){(function (){ 'use strict'; @@ -2958,7 +2914,7 @@ exports.setTorusShare = setTorusShare; },{"./utils.js":28,"@toruslabs/eccrypto":24,"buffer":53}],30:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true); var isArrayBuffer = require('is-array-buffer'); @@ -2971,7 +2927,7 @@ module.exports = function byteLength(ab) { return $byteLength ? $byteLength(ab) : ab.byteLength; }; // in node < 0.11, byteLength is an own nonconfigurable property -},{"call-bound":62,"is-array-buffer":456}],31:[function(require,module,exports){ +},{"call-bind/callBound":54,"is-array-buffer":445}],31:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3036,7 +2992,7 @@ Object.defineProperty(exports, "__esModule", { exports["default"] = void 0; var _clone = _interopRequireDefault(require("clone")); var _default = exports["default"] = _clone["default"]; -},{"@babel/runtime/helpers/interopRequireDefault":48,"clone":63}],33:[function(require,module,exports){ +},{"@babel/runtime/helpers/interopRequireDefault":48,"clone":56}],33:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3046,7 +3002,7 @@ Object.defineProperty(exports, "__esModule", { exports["default"] = void 0; var _deepEqual = _interopRequireDefault(require("deep-equal")); var _default = exports["default"] = _deepEqual["default"]; -},{"@babel/runtime/helpers/interopRequireDefault":48,"deep-equal":368}],34:[function(require,module,exports){ +},{"@babel/runtime/helpers/interopRequireDefault":48,"deep-equal":363}],34:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3216,7 +3172,7 @@ function performanceNow() { } else perf = window.performance; return perf.now(); } -},{"./require-on-node-only":52,"@babel/runtime/helpers/interopRequireDefault":48,"is-node":462}],37:[function(require,module,exports){ +},{"./require-on-node-only":52,"@babel/runtime/helpers/interopRequireDefault":48,"is-node":451}],37:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); @@ -3508,7 +3464,7 @@ module.exports = function availableTypedArrays() { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"possible-typed-array-names":502}],50:[function(require,module,exports){ +},{"possible-typed-array-names":483}],50:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -5510,66 +5466,7 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":50,"buffer":53,"ieee754":452}],54:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); - -var $apply = require('./functionApply'); -var $call = require('./functionCall'); -var $reflectApply = require('./reflectApply'); - -/** @type {import('./actualApply')} */ -module.exports = $reflectApply || bind.call($call, $apply); - -},{"./functionApply":56,"./functionCall":57,"./reflectApply":59,"function-bind":425}],55:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $apply = require('./functionApply'); -var actualApply = require('./actualApply'); - -/** @type {import('./applyBind')} */ -module.exports = function applyBind() { - return actualApply(bind, $apply, arguments); -}; - -},{"./actualApply":54,"./functionApply":56,"function-bind":425}],56:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionApply')} */ -module.exports = Function.prototype.apply; - -},{}],57:[function(require,module,exports){ -'use strict'; - -/** @type {import('./functionCall')} */ -module.exports = Function.prototype.call; - -},{}],58:[function(require,module,exports){ -'use strict'; - -var bind = require('function-bind'); -var $TypeError = require('es-errors/type'); - -var $call = require('./functionCall'); -var $actualApply = require('./actualApply'); - -/** @type {import('.')} */ -module.exports = function callBindBasic(args) { - if (args.length < 1 || typeof args[0] !== 'function') { - throw new $TypeError('a function is required'); - } - return $actualApply(bind, $call, args); -}; - -},{"./actualApply":54,"./functionCall":57,"es-errors/type":417,"function-bind":425}],59:[function(require,module,exports){ -'use strict'; - -/** @type {import('./reflectApply')} */ -module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply; - -},{}],60:[function(require,module,exports){ +},{"base64-js":50,"buffer":53,"ieee754":441}],54:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -5586,53 +5483,44 @@ module.exports = function callBoundIntrinsic(name, allowMissing) { return intrinsic; }; -},{"./":61,"get-intrinsic":427}],61:[function(require,module,exports){ +},{"./":55,"get-intrinsic":419}],55:[function(require,module,exports){ 'use strict'; +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); var setFunctionLength = require('set-function-length'); -var $defineProperty = require('es-define-property'); +var $TypeError = require('es-errors/type'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); -var callBindBasic = require('call-bind-apply-helpers'); -var applyBind = require('call-bind-apply-helpers/applyBind'); +var $defineProperty = require('es-define-property'); +var $max = GetIntrinsic('%Math.max%'); module.exports = function callBind(originalFunction) { - var func = callBindBasic(arguments); - var adjustedLength = originalFunction.length - (arguments.length - 1); + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); return setFunctionLength( func, - 1 + (adjustedLength > 0 ? adjustedLength : 0), + 1 + $max(0, originalFunction.length - (arguments.length - 1)), true ); }; +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + if ($defineProperty) { $defineProperty(module.exports, 'apply', { value: applyBind }); } else { module.exports.apply = applyBind; } -},{"call-bind-apply-helpers":58,"call-bind-apply-helpers/applyBind":55,"es-define-property":411,"set-function-length":510}],62:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); - -var callBindBasic = require('call-bind-apply-helpers'); - -/** @type {(thisArg: string, searchString: string, position?: number) => number} */ -var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]); - -/** @type {import('.')} */ -module.exports = function callBoundIntrinsic(name, allowMissing) { - // eslint-disable-next-line no-extra-parens - var intrinsic = /** @type {Parameters[0][0]} */ (GetIntrinsic(name, !!allowMissing)); - if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { - return callBindBasic([intrinsic]); - } - return intrinsic; -}; - -},{"call-bind-apply-helpers":58,"get-intrinsic":427}],63:[function(require,module,exports){ +},{"es-define-property":404,"es-errors/type":410,"function-bind":417,"get-intrinsic":419,"set-function-length":490}],56:[function(require,module,exports){ (function (Buffer){(function (){ var clone = (function() { 'use strict'; @@ -5893,7 +5781,7 @@ if (typeof module === 'object' && module.exports) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":53}],64:[function(require,module,exports){ +},{"buffer":53}],57:[function(require,module,exports){ require('../modules/es6.symbol'); require('../modules/es6.object.create'); require('../modules/es6.object.define-property'); @@ -6034,74 +5922,74 @@ require('../modules/es6.reflect.set'); require('../modules/es6.reflect.set-prototype-of'); module.exports = require('../modules/_core'); -},{"../modules/_core":113,"../modules/es6.array.copy-within":215,"../modules/es6.array.every":216,"../modules/es6.array.fill":217,"../modules/es6.array.filter":218,"../modules/es6.array.find":220,"../modules/es6.array.find-index":219,"../modules/es6.array.for-each":221,"../modules/es6.array.from":222,"../modules/es6.array.index-of":223,"../modules/es6.array.is-array":224,"../modules/es6.array.iterator":225,"../modules/es6.array.join":226,"../modules/es6.array.last-index-of":227,"../modules/es6.array.map":228,"../modules/es6.array.of":229,"../modules/es6.array.reduce":231,"../modules/es6.array.reduce-right":230,"../modules/es6.array.slice":232,"../modules/es6.array.some":233,"../modules/es6.array.sort":234,"../modules/es6.array.species":235,"../modules/es6.date.now":236,"../modules/es6.date.to-iso-string":237,"../modules/es6.date.to-json":238,"../modules/es6.date.to-primitive":239,"../modules/es6.date.to-string":240,"../modules/es6.function.bind":241,"../modules/es6.function.has-instance":242,"../modules/es6.function.name":243,"../modules/es6.map":244,"../modules/es6.math.acosh":245,"../modules/es6.math.asinh":246,"../modules/es6.math.atanh":247,"../modules/es6.math.cbrt":248,"../modules/es6.math.clz32":249,"../modules/es6.math.cosh":250,"../modules/es6.math.expm1":251,"../modules/es6.math.fround":252,"../modules/es6.math.hypot":253,"../modules/es6.math.imul":254,"../modules/es6.math.log10":255,"../modules/es6.math.log1p":256,"../modules/es6.math.log2":257,"../modules/es6.math.sign":258,"../modules/es6.math.sinh":259,"../modules/es6.math.tanh":260,"../modules/es6.math.trunc":261,"../modules/es6.number.constructor":262,"../modules/es6.number.epsilon":263,"../modules/es6.number.is-finite":264,"../modules/es6.number.is-integer":265,"../modules/es6.number.is-nan":266,"../modules/es6.number.is-safe-integer":267,"../modules/es6.number.max-safe-integer":268,"../modules/es6.number.min-safe-integer":269,"../modules/es6.number.parse-float":270,"../modules/es6.number.parse-int":271,"../modules/es6.number.to-fixed":272,"../modules/es6.number.to-precision":273,"../modules/es6.object.assign":274,"../modules/es6.object.create":275,"../modules/es6.object.define-properties":276,"../modules/es6.object.define-property":277,"../modules/es6.object.freeze":278,"../modules/es6.object.get-own-property-descriptor":279,"../modules/es6.object.get-own-property-names":280,"../modules/es6.object.get-prototype-of":281,"../modules/es6.object.is":285,"../modules/es6.object.is-extensible":282,"../modules/es6.object.is-frozen":283,"../modules/es6.object.is-sealed":284,"../modules/es6.object.keys":286,"../modules/es6.object.prevent-extensions":287,"../modules/es6.object.seal":288,"../modules/es6.object.set-prototype-of":289,"../modules/es6.object.to-string":290,"../modules/es6.parse-float":291,"../modules/es6.parse-int":292,"../modules/es6.promise":293,"../modules/es6.reflect.apply":294,"../modules/es6.reflect.construct":295,"../modules/es6.reflect.define-property":296,"../modules/es6.reflect.delete-property":297,"../modules/es6.reflect.enumerate":298,"../modules/es6.reflect.get":301,"../modules/es6.reflect.get-own-property-descriptor":299,"../modules/es6.reflect.get-prototype-of":300,"../modules/es6.reflect.has":302,"../modules/es6.reflect.is-extensible":303,"../modules/es6.reflect.own-keys":304,"../modules/es6.reflect.prevent-extensions":305,"../modules/es6.reflect.set":307,"../modules/es6.reflect.set-prototype-of":306,"../modules/es6.regexp.constructor":308,"../modules/es6.regexp.exec":309,"../modules/es6.regexp.flags":310,"../modules/es6.regexp.match":311,"../modules/es6.regexp.replace":312,"../modules/es6.regexp.search":313,"../modules/es6.regexp.split":314,"../modules/es6.regexp.to-string":315,"../modules/es6.set":316,"../modules/es6.string.anchor":317,"../modules/es6.string.big":318,"../modules/es6.string.blink":319,"../modules/es6.string.bold":320,"../modules/es6.string.code-point-at":321,"../modules/es6.string.ends-with":322,"../modules/es6.string.fixed":323,"../modules/es6.string.fontcolor":324,"../modules/es6.string.fontsize":325,"../modules/es6.string.from-code-point":326,"../modules/es6.string.includes":327,"../modules/es6.string.italics":328,"../modules/es6.string.iterator":329,"../modules/es6.string.link":330,"../modules/es6.string.raw":331,"../modules/es6.string.repeat":332,"../modules/es6.string.small":333,"../modules/es6.string.starts-with":334,"../modules/es6.string.strike":335,"../modules/es6.string.sub":336,"../modules/es6.string.sup":337,"../modules/es6.string.trim":338,"../modules/es6.symbol":339,"../modules/es6.typed.array-buffer":340,"../modules/es6.typed.data-view":341,"../modules/es6.typed.float32-array":342,"../modules/es6.typed.float64-array":343,"../modules/es6.typed.int16-array":344,"../modules/es6.typed.int32-array":345,"../modules/es6.typed.int8-array":346,"../modules/es6.typed.uint16-array":347,"../modules/es6.typed.uint32-array":348,"../modules/es6.typed.uint8-array":349,"../modules/es6.typed.uint8-clamped-array":350,"../modules/es6.weak-map":351,"../modules/es6.weak-set":352}],65:[function(require,module,exports){ +},{"../modules/_core":106,"../modules/es6.array.copy-within":208,"../modules/es6.array.every":209,"../modules/es6.array.fill":210,"../modules/es6.array.filter":211,"../modules/es6.array.find":213,"../modules/es6.array.find-index":212,"../modules/es6.array.for-each":214,"../modules/es6.array.from":215,"../modules/es6.array.index-of":216,"../modules/es6.array.is-array":217,"../modules/es6.array.iterator":218,"../modules/es6.array.join":219,"../modules/es6.array.last-index-of":220,"../modules/es6.array.map":221,"../modules/es6.array.of":222,"../modules/es6.array.reduce":224,"../modules/es6.array.reduce-right":223,"../modules/es6.array.slice":225,"../modules/es6.array.some":226,"../modules/es6.array.sort":227,"../modules/es6.array.species":228,"../modules/es6.date.now":229,"../modules/es6.date.to-iso-string":230,"../modules/es6.date.to-json":231,"../modules/es6.date.to-primitive":232,"../modules/es6.date.to-string":233,"../modules/es6.function.bind":234,"../modules/es6.function.has-instance":235,"../modules/es6.function.name":236,"../modules/es6.map":237,"../modules/es6.math.acosh":238,"../modules/es6.math.asinh":239,"../modules/es6.math.atanh":240,"../modules/es6.math.cbrt":241,"../modules/es6.math.clz32":242,"../modules/es6.math.cosh":243,"../modules/es6.math.expm1":244,"../modules/es6.math.fround":245,"../modules/es6.math.hypot":246,"../modules/es6.math.imul":247,"../modules/es6.math.log10":248,"../modules/es6.math.log1p":249,"../modules/es6.math.log2":250,"../modules/es6.math.sign":251,"../modules/es6.math.sinh":252,"../modules/es6.math.tanh":253,"../modules/es6.math.trunc":254,"../modules/es6.number.constructor":255,"../modules/es6.number.epsilon":256,"../modules/es6.number.is-finite":257,"../modules/es6.number.is-integer":258,"../modules/es6.number.is-nan":259,"../modules/es6.number.is-safe-integer":260,"../modules/es6.number.max-safe-integer":261,"../modules/es6.number.min-safe-integer":262,"../modules/es6.number.parse-float":263,"../modules/es6.number.parse-int":264,"../modules/es6.number.to-fixed":265,"../modules/es6.number.to-precision":266,"../modules/es6.object.assign":267,"../modules/es6.object.create":268,"../modules/es6.object.define-properties":269,"../modules/es6.object.define-property":270,"../modules/es6.object.freeze":271,"../modules/es6.object.get-own-property-descriptor":272,"../modules/es6.object.get-own-property-names":273,"../modules/es6.object.get-prototype-of":274,"../modules/es6.object.is":278,"../modules/es6.object.is-extensible":275,"../modules/es6.object.is-frozen":276,"../modules/es6.object.is-sealed":277,"../modules/es6.object.keys":279,"../modules/es6.object.prevent-extensions":280,"../modules/es6.object.seal":281,"../modules/es6.object.set-prototype-of":282,"../modules/es6.object.to-string":283,"../modules/es6.parse-float":284,"../modules/es6.parse-int":285,"../modules/es6.promise":286,"../modules/es6.reflect.apply":287,"../modules/es6.reflect.construct":288,"../modules/es6.reflect.define-property":289,"../modules/es6.reflect.delete-property":290,"../modules/es6.reflect.enumerate":291,"../modules/es6.reflect.get":294,"../modules/es6.reflect.get-own-property-descriptor":292,"../modules/es6.reflect.get-prototype-of":293,"../modules/es6.reflect.has":295,"../modules/es6.reflect.is-extensible":296,"../modules/es6.reflect.own-keys":297,"../modules/es6.reflect.prevent-extensions":298,"../modules/es6.reflect.set":300,"../modules/es6.reflect.set-prototype-of":299,"../modules/es6.regexp.constructor":301,"../modules/es6.regexp.exec":302,"../modules/es6.regexp.flags":303,"../modules/es6.regexp.match":304,"../modules/es6.regexp.replace":305,"../modules/es6.regexp.search":306,"../modules/es6.regexp.split":307,"../modules/es6.regexp.to-string":308,"../modules/es6.set":309,"../modules/es6.string.anchor":310,"../modules/es6.string.big":311,"../modules/es6.string.blink":312,"../modules/es6.string.bold":313,"../modules/es6.string.code-point-at":314,"../modules/es6.string.ends-with":315,"../modules/es6.string.fixed":316,"../modules/es6.string.fontcolor":317,"../modules/es6.string.fontsize":318,"../modules/es6.string.from-code-point":319,"../modules/es6.string.includes":320,"../modules/es6.string.italics":321,"../modules/es6.string.iterator":322,"../modules/es6.string.link":323,"../modules/es6.string.raw":324,"../modules/es6.string.repeat":325,"../modules/es6.string.small":326,"../modules/es6.string.starts-with":327,"../modules/es6.string.strike":328,"../modules/es6.string.sub":329,"../modules/es6.string.sup":330,"../modules/es6.string.trim":331,"../modules/es6.symbol":332,"../modules/es6.typed.array-buffer":333,"../modules/es6.typed.data-view":334,"../modules/es6.typed.float32-array":335,"../modules/es6.typed.float64-array":336,"../modules/es6.typed.int16-array":337,"../modules/es6.typed.int32-array":338,"../modules/es6.typed.int8-array":339,"../modules/es6.typed.uint16-array":340,"../modules/es6.typed.uint32-array":341,"../modules/es6.typed.uint8-array":342,"../modules/es6.typed.uint8-clamped-array":343,"../modules/es6.weak-map":344,"../modules/es6.weak-set":345}],58:[function(require,module,exports){ require('../../modules/es7.array.flat-map'); module.exports = require('../../modules/_core').Array.flatMap; -},{"../../modules/_core":113,"../../modules/es7.array.flat-map":353}],66:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.array.flat-map":346}],59:[function(require,module,exports){ require('../../modules/es7.array.includes'); module.exports = require('../../modules/_core').Array.includes; -},{"../../modules/_core":113,"../../modules/es7.array.includes":354}],67:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.array.includes":347}],60:[function(require,module,exports){ require('../../modules/es7.object.entries'); module.exports = require('../../modules/_core').Object.entries; -},{"../../modules/_core":113,"../../modules/es7.object.entries":355}],68:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.object.entries":348}],61:[function(require,module,exports){ require('../../modules/es7.object.get-own-property-descriptors'); module.exports = require('../../modules/_core').Object.getOwnPropertyDescriptors; -},{"../../modules/_core":113,"../../modules/es7.object.get-own-property-descriptors":356}],69:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.object.get-own-property-descriptors":349}],62:[function(require,module,exports){ require('../../modules/es7.object.values'); module.exports = require('../../modules/_core').Object.values; -},{"../../modules/_core":113,"../../modules/es7.object.values":357}],70:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.object.values":350}],63:[function(require,module,exports){ 'use strict'; require('../../modules/es6.promise'); require('../../modules/es7.promise.finally'); module.exports = require('../../modules/_core').Promise['finally']; -},{"../../modules/_core":113,"../../modules/es6.promise":293,"../../modules/es7.promise.finally":358}],71:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es6.promise":286,"../../modules/es7.promise.finally":351}],64:[function(require,module,exports){ require('../../modules/es7.string.pad-end'); module.exports = require('../../modules/_core').String.padEnd; -},{"../../modules/_core":113,"../../modules/es7.string.pad-end":359}],72:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.string.pad-end":352}],65:[function(require,module,exports){ require('../../modules/es7.string.pad-start'); module.exports = require('../../modules/_core').String.padStart; -},{"../../modules/_core":113,"../../modules/es7.string.pad-start":360}],73:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.string.pad-start":353}],66:[function(require,module,exports){ require('../../modules/es7.string.trim-right'); module.exports = require('../../modules/_core').String.trimRight; -},{"../../modules/_core":113,"../../modules/es7.string.trim-right":362}],74:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.string.trim-right":355}],67:[function(require,module,exports){ require('../../modules/es7.string.trim-left'); module.exports = require('../../modules/_core').String.trimLeft; -},{"../../modules/_core":113,"../../modules/es7.string.trim-left":361}],75:[function(require,module,exports){ +},{"../../modules/_core":106,"../../modules/es7.string.trim-left":354}],68:[function(require,module,exports){ require('../../modules/es7.symbol.async-iterator'); module.exports = require('../../modules/_wks-ext').f('asyncIterator'); -},{"../../modules/_wks-ext":212,"../../modules/es7.symbol.async-iterator":363}],76:[function(require,module,exports){ +},{"../../modules/_wks-ext":205,"../../modules/es7.symbol.async-iterator":356}],69:[function(require,module,exports){ require('../modules/es7.global'); module.exports = require('../modules/_core').global; -},{"../modules/_core":79,"../modules/es7.global":93}],77:[function(require,module,exports){ +},{"../modules/_core":72,"../modules/es7.global":86}],70:[function(require,module,exports){ module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; -},{}],78:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; -},{"./_is-object":89}],79:[function(require,module,exports){ +},{"./_is-object":82}],72:[function(require,module,exports){ var core = module.exports = { version: '2.6.12' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -},{}],80:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ // optional / simple context binding var aFunction = require('./_a-function'); module.exports = function (fn, that, length) { @@ -6123,13 +6011,13 @@ module.exports = function (fn, that, length) { }; }; -},{"./_a-function":77}],81:[function(require,module,exports){ +},{"./_a-function":70}],74:[function(require,module,exports){ // Thank's IE8 for his funny defineProperty module.exports = !require('./_fails')(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_fails":84}],82:[function(require,module,exports){ +},{"./_fails":77}],75:[function(require,module,exports){ var isObject = require('./_is-object'); var document = require('./_global').document; // typeof document.createElement is 'object' in old IE @@ -6138,7 +6026,7 @@ module.exports = function (it) { return is ? document.createElement(it) : {}; }; -},{"./_global":85,"./_is-object":89}],83:[function(require,module,exports){ +},{"./_global":78,"./_is-object":82}],76:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var ctx = require('./_ctx'); @@ -6202,7 +6090,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":79,"./_ctx":80,"./_global":85,"./_has":86,"./_hide":87}],84:[function(require,module,exports){ +},{"./_core":72,"./_ctx":73,"./_global":78,"./_has":79,"./_hide":80}],77:[function(require,module,exports){ module.exports = function (exec) { try { return !!exec(); @@ -6211,7 +6099,7 @@ module.exports = function (exec) { } }; -},{}],85:[function(require,module,exports){ +},{}],78:[function(require,module,exports){ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self @@ -6219,13 +6107,13 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -},{}],86:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; -},{}],87:[function(require,module,exports){ +},{}],80:[function(require,module,exports){ var dP = require('./_object-dp'); var createDesc = require('./_property-desc'); module.exports = require('./_descriptors') ? function (object, key, value) { @@ -6235,17 +6123,17 @@ module.exports = require('./_descriptors') ? function (object, key, value) { return object; }; -},{"./_descriptors":81,"./_object-dp":90,"./_property-desc":91}],88:[function(require,module,exports){ +},{"./_descriptors":74,"./_object-dp":83,"./_property-desc":84}],81:[function(require,module,exports){ module.exports = !require('./_descriptors') && !require('./_fails')(function () { return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; }); -},{"./_descriptors":81,"./_dom-create":82,"./_fails":84}],89:[function(require,module,exports){ +},{"./_descriptors":74,"./_dom-create":75,"./_fails":77}],82:[function(require,module,exports){ module.exports = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -},{}],90:[function(require,module,exports){ +},{}],83:[function(require,module,exports){ var anObject = require('./_an-object'); var IE8_DOM_DEFINE = require('./_ie8-dom-define'); var toPrimitive = require('./_to-primitive'); @@ -6263,7 +6151,7 @@ exports.f = require('./_descriptors') ? Object.defineProperty : function defineP return O; }; -},{"./_an-object":78,"./_descriptors":81,"./_ie8-dom-define":88,"./_to-primitive":92}],91:[function(require,module,exports){ +},{"./_an-object":71,"./_descriptors":74,"./_ie8-dom-define":81,"./_to-primitive":85}],84:[function(require,module,exports){ module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -6273,7 +6161,7 @@ module.exports = function (bitmap, value) { }; }; -},{}],92:[function(require,module,exports){ +},{}],85:[function(require,module,exports){ // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = require('./_is-object'); // instead of the ES6 spec version, we didn't implement @@toPrimitive case @@ -6287,22 +6175,22 @@ module.exports = function (it, S) { throw TypeError("Can't convert object to primitive value"); }; -},{"./_is-object":89}],93:[function(require,module,exports){ +},{"./_is-object":82}],86:[function(require,module,exports){ // https://github.com/tc39/proposal-global var $export = require('./_export'); $export($export.G, { global: require('./_global') }); -},{"./_export":83,"./_global":85}],94:[function(require,module,exports){ -arguments[4][77][0].apply(exports,arguments) -},{"dup":77}],95:[function(require,module,exports){ +},{"./_export":76,"./_global":78}],87:[function(require,module,exports){ +arguments[4][70][0].apply(exports,arguments) +},{"dup":70}],88:[function(require,module,exports){ var cof = require('./_cof'); module.exports = function (it, msg) { if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg); return +it; }; -},{"./_cof":109}],96:[function(require,module,exports){ +},{"./_cof":102}],89:[function(require,module,exports){ // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = require('./_wks')('unscopables'); var ArrayProto = Array.prototype; @@ -6311,7 +6199,7 @@ module.exports = function (key) { ArrayProto[UNSCOPABLES][key] = true; }; -},{"./_hide":133,"./_wks":213}],97:[function(require,module,exports){ +},{"./_hide":126,"./_wks":206}],90:[function(require,module,exports){ 'use strict'; var at = require('./_string-at')(true); @@ -6321,16 +6209,16 @@ module.exports = function (S, index, unicode) { return index + (unicode ? at(S, index).length : 1); }; -},{"./_string-at":190}],98:[function(require,module,exports){ +},{"./_string-at":183}],91:[function(require,module,exports){ module.exports = function (it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { throw TypeError(name + ': incorrect invocation!'); } return it; }; -},{}],99:[function(require,module,exports){ -arguments[4][78][0].apply(exports,arguments) -},{"./_is-object":142,"dup":78}],100:[function(require,module,exports){ +},{}],92:[function(require,module,exports){ +arguments[4][71][0].apply(exports,arguments) +},{"./_is-object":135,"dup":71}],93:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -6358,7 +6246,7 @@ module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* } return O; }; -},{"./_to-absolute-index":198,"./_to-length":202,"./_to-object":203}],101:[function(require,module,exports){ +},{"./_to-absolute-index":191,"./_to-length":195,"./_to-object":196}],94:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 'use strict'; var toObject = require('./_to-object'); @@ -6375,7 +6263,7 @@ module.exports = function fill(value /* , start = 0, end = @length */) { return O; }; -},{"./_to-absolute-index":198,"./_to-length":202,"./_to-object":203}],102:[function(require,module,exports){ +},{"./_to-absolute-index":191,"./_to-length":195,"./_to-object":196}],95:[function(require,module,exports){ // false -> Array#indexOf // true -> Array#includes var toIObject = require('./_to-iobject'); @@ -6400,7 +6288,7 @@ module.exports = function (IS_INCLUDES) { }; }; -},{"./_to-absolute-index":198,"./_to-iobject":201,"./_to-length":202}],103:[function(require,module,exports){ +},{"./_to-absolute-index":191,"./_to-iobject":194,"./_to-length":195}],96:[function(require,module,exports){ // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter @@ -6446,7 +6334,7 @@ module.exports = function (TYPE, $create) { }; }; -},{"./_array-species-create":106,"./_ctx":115,"./_iobject":138,"./_to-length":202,"./_to-object":203}],104:[function(require,module,exports){ +},{"./_array-species-create":99,"./_ctx":108,"./_iobject":131,"./_to-length":195,"./_to-object":196}],97:[function(require,module,exports){ var aFunction = require('./_a-function'); var toObject = require('./_to-object'); var IObject = require('./_iobject'); @@ -6476,7 +6364,7 @@ module.exports = function (that, callbackfn, aLen, memo, isRight) { return memo; }; -},{"./_a-function":94,"./_iobject":138,"./_to-length":202,"./_to-object":203}],105:[function(require,module,exports){ +},{"./_a-function":87,"./_iobject":131,"./_to-length":195,"./_to-object":196}],98:[function(require,module,exports){ var isObject = require('./_is-object'); var isArray = require('./_is-array'); var SPECIES = require('./_wks')('species'); @@ -6494,7 +6382,7 @@ module.exports = function (original) { } return C === undefined ? Array : C; }; -},{"./_is-array":140,"./_is-object":142,"./_wks":213}],106:[function(require,module,exports){ +},{"./_is-array":133,"./_is-object":135,"./_wks":206}],99:[function(require,module,exports){ // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var speciesConstructor = require('./_array-species-constructor'); @@ -6502,7 +6390,7 @@ module.exports = function (original, length) { return new (speciesConstructor(original))(length); }; -},{"./_array-species-constructor":105}],107:[function(require,module,exports){ +},{"./_array-species-constructor":98}],100:[function(require,module,exports){ 'use strict'; var aFunction = require('./_a-function'); var isObject = require('./_is-object'); @@ -6529,7 +6417,7 @@ module.exports = Function.bind || function bind(that /* , ...args */) { return bound; }; -},{"./_a-function":94,"./_invoke":137,"./_is-object":142}],108:[function(require,module,exports){ +},{"./_a-function":87,"./_invoke":130,"./_is-object":135}],101:[function(require,module,exports){ // getting tag from 19.1.3.6 Object.prototype.toString() var cof = require('./_cof'); var TAG = require('./_wks')('toStringTag'); @@ -6554,14 +6442,14 @@ module.exports = function (it) { : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; -},{"./_cof":109,"./_wks":213}],109:[function(require,module,exports){ +},{"./_cof":102,"./_wks":206}],102:[function(require,module,exports){ var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; -},{}],110:[function(require,module,exports){ +},{}],103:[function(require,module,exports){ 'use strict'; var dP = require('./_object-dp').f; var create = require('./_object-create'); @@ -6707,7 +6595,7 @@ module.exports = { } }; -},{"./_an-instance":98,"./_ctx":115,"./_descriptors":119,"./_for-of":129,"./_iter-define":146,"./_iter-step":148,"./_meta":155,"./_object-create":159,"./_object-dp":160,"./_redefine-all":178,"./_set-species":184,"./_validate-collection":210}],111:[function(require,module,exports){ +},{"./_an-instance":91,"./_ctx":108,"./_descriptors":112,"./_for-of":122,"./_iter-define":139,"./_iter-step":141,"./_meta":148,"./_object-create":152,"./_object-dp":153,"./_redefine-all":171,"./_set-species":177,"./_validate-collection":203}],104:[function(require,module,exports){ 'use strict'; var redefineAll = require('./_redefine-all'); var getWeak = require('./_meta').getWeak; @@ -6794,7 +6682,7 @@ module.exports = { ufstore: uncaughtFrozenStore }; -},{"./_an-instance":98,"./_an-object":99,"./_array-methods":103,"./_for-of":129,"./_has":132,"./_is-object":142,"./_meta":155,"./_redefine-all":178,"./_validate-collection":210}],112:[function(require,module,exports){ +},{"./_an-instance":91,"./_an-object":92,"./_array-methods":96,"./_for-of":122,"./_has":125,"./_is-object":135,"./_meta":148,"./_redefine-all":171,"./_validate-collection":203}],105:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var $export = require('./_export'); @@ -6881,9 +6769,9 @@ module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { return C; }; -},{"./_an-instance":98,"./_export":123,"./_fails":125,"./_for-of":129,"./_global":131,"./_inherit-if-required":136,"./_is-object":142,"./_iter-detect":147,"./_meta":155,"./_redefine":179,"./_redefine-all":178,"./_set-to-string-tag":185}],113:[function(require,module,exports){ -arguments[4][79][0].apply(exports,arguments) -},{"dup":79}],114:[function(require,module,exports){ +},{"./_an-instance":91,"./_export":116,"./_fails":118,"./_for-of":122,"./_global":124,"./_inherit-if-required":129,"./_is-object":135,"./_iter-detect":140,"./_meta":148,"./_redefine":172,"./_redefine-all":171,"./_set-to-string-tag":178}],106:[function(require,module,exports){ +arguments[4][72][0].apply(exports,arguments) +},{"dup":72}],107:[function(require,module,exports){ 'use strict'; var $defineProperty = require('./_object-dp'); var createDesc = require('./_property-desc'); @@ -6893,9 +6781,9 @@ module.exports = function (object, index, value) { else object[index] = value; }; -},{"./_object-dp":160,"./_property-desc":177}],115:[function(require,module,exports){ -arguments[4][80][0].apply(exports,arguments) -},{"./_a-function":94,"dup":80}],116:[function(require,module,exports){ +},{"./_object-dp":153,"./_property-desc":170}],108:[function(require,module,exports){ +arguments[4][73][0].apply(exports,arguments) +},{"./_a-function":87,"dup":73}],109:[function(require,module,exports){ 'use strict'; // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var fails = require('./_fails'); @@ -6923,7 +6811,7 @@ module.exports = (fails(function () { ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; } : $toISOString; -},{"./_fails":125}],117:[function(require,module,exports){ +},{"./_fails":118}],110:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); var toPrimitive = require('./_to-primitive'); @@ -6934,24 +6822,24 @@ module.exports = function (hint) { return toPrimitive(anObject(this), hint != NUMBER); }; -},{"./_an-object":99,"./_to-primitive":204}],118:[function(require,module,exports){ +},{"./_an-object":92,"./_to-primitive":197}],111:[function(require,module,exports){ // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; -},{}],119:[function(require,module,exports){ -arguments[4][81][0].apply(exports,arguments) -},{"./_fails":125,"dup":81}],120:[function(require,module,exports){ -arguments[4][82][0].apply(exports,arguments) -},{"./_global":131,"./_is-object":142,"dup":82}],121:[function(require,module,exports){ +},{}],112:[function(require,module,exports){ +arguments[4][74][0].apply(exports,arguments) +},{"./_fails":118,"dup":74}],113:[function(require,module,exports){ +arguments[4][75][0].apply(exports,arguments) +},{"./_global":124,"./_is-object":135,"dup":75}],114:[function(require,module,exports){ // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); -},{}],122:[function(require,module,exports){ +},{}],115:[function(require,module,exports){ // all enumerable object keys, includes symbols var getKeys = require('./_object-keys'); var gOPS = require('./_object-gops'); @@ -6968,7 +6856,7 @@ module.exports = function (it) { } return result; }; -},{"./_object-gops":165,"./_object-keys":168,"./_object-pie":169}],123:[function(require,module,exports){ +},{"./_object-gops":158,"./_object-keys":161,"./_object-pie":162}],116:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var hide = require('./_hide'); @@ -7013,7 +6901,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":113,"./_ctx":115,"./_global":131,"./_hide":133,"./_redefine":179}],124:[function(require,module,exports){ +},{"./_core":106,"./_ctx":108,"./_global":124,"./_hide":126,"./_redefine":172}],117:[function(require,module,exports){ var MATCH = require('./_wks')('match'); module.exports = function (KEY) { var re = /./; @@ -7027,9 +6915,9 @@ module.exports = function (KEY) { } return true; }; -},{"./_wks":213}],125:[function(require,module,exports){ -arguments[4][84][0].apply(exports,arguments) -},{"dup":84}],126:[function(require,module,exports){ +},{"./_wks":206}],118:[function(require,module,exports){ +arguments[4][77][0].apply(exports,arguments) +},{"dup":77}],119:[function(require,module,exports){ 'use strict'; require('./es6.regexp.exec'); var redefine = require('./_redefine'); @@ -7127,7 +7015,7 @@ module.exports = function (KEY, length, exec) { } }; -},{"./_defined":118,"./_fails":125,"./_hide":133,"./_redefine":179,"./_regexp-exec":181,"./_wks":213,"./es6.regexp.exec":309}],127:[function(require,module,exports){ +},{"./_defined":111,"./_fails":118,"./_hide":126,"./_redefine":172,"./_regexp-exec":174,"./_wks":206,"./es6.regexp.exec":302}],120:[function(require,module,exports){ 'use strict'; // 21.2.5.3 get RegExp.prototype.flags var anObject = require('./_an-object'); @@ -7142,7 +7030,7 @@ module.exports = function () { return result; }; -},{"./_an-object":99}],128:[function(require,module,exports){ +},{"./_an-object":92}],121:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray var isArray = require('./_is-array'); @@ -7183,7 +7071,7 @@ function flattenIntoArray(target, original, source, sourceLen, start, depth, map module.exports = flattenIntoArray; -},{"./_ctx":115,"./_is-array":140,"./_is-object":142,"./_to-length":202,"./_wks":213}],129:[function(require,module,exports){ +},{"./_ctx":108,"./_is-array":133,"./_is-object":135,"./_to-length":195,"./_wks":206}],122:[function(require,module,exports){ var ctx = require('./_ctx'); var call = require('./_iter-call'); var isArrayIter = require('./_is-array-iter'); @@ -7210,22 +7098,22 @@ var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) exports.BREAK = BREAK; exports.RETURN = RETURN; -},{"./_an-object":99,"./_ctx":115,"./_is-array-iter":139,"./_iter-call":144,"./_to-length":202,"./core.get-iterator-method":214}],130:[function(require,module,exports){ +},{"./_an-object":92,"./_ctx":108,"./_is-array-iter":132,"./_iter-call":137,"./_to-length":195,"./core.get-iterator-method":207}],123:[function(require,module,exports){ module.exports = require('./_shared')('native-function-to-string', Function.toString); -},{"./_shared":187}],131:[function(require,module,exports){ -arguments[4][85][0].apply(exports,arguments) -},{"dup":85}],132:[function(require,module,exports){ -arguments[4][86][0].apply(exports,arguments) -},{"dup":86}],133:[function(require,module,exports){ -arguments[4][87][0].apply(exports,arguments) -},{"./_descriptors":119,"./_object-dp":160,"./_property-desc":177,"dup":87}],134:[function(require,module,exports){ +},{"./_shared":180}],124:[function(require,module,exports){ +arguments[4][78][0].apply(exports,arguments) +},{"dup":78}],125:[function(require,module,exports){ +arguments[4][79][0].apply(exports,arguments) +},{"dup":79}],126:[function(require,module,exports){ +arguments[4][80][0].apply(exports,arguments) +},{"./_descriptors":112,"./_object-dp":153,"./_property-desc":170,"dup":80}],127:[function(require,module,exports){ var document = require('./_global').document; module.exports = document && document.documentElement; -},{"./_global":131}],135:[function(require,module,exports){ -arguments[4][88][0].apply(exports,arguments) -},{"./_descriptors":119,"./_dom-create":120,"./_fails":125,"dup":88}],136:[function(require,module,exports){ +},{"./_global":124}],128:[function(require,module,exports){ +arguments[4][81][0].apply(exports,arguments) +},{"./_descriptors":112,"./_dom-create":113,"./_fails":118,"dup":81}],129:[function(require,module,exports){ var isObject = require('./_is-object'); var setPrototypeOf = require('./_set-proto').set; module.exports = function (that, target, C) { @@ -7236,7 +7124,7 @@ module.exports = function (that, target, C) { } return that; }; -},{"./_is-object":142,"./_set-proto":183}],137:[function(require,module,exports){ +},{"./_is-object":135,"./_set-proto":176}],130:[function(require,module,exports){ // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function (fn, args, that) { var un = that === undefined; @@ -7254,7 +7142,7 @@ module.exports = function (fn, args, that) { } return fn.apply(that, args); }; -},{}],138:[function(require,module,exports){ +},{}],131:[function(require,module,exports){ // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = require('./_cof'); // eslint-disable-next-line no-prototype-builtins @@ -7262,7 +7150,7 @@ module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; -},{"./_cof":109}],139:[function(require,module,exports){ +},{"./_cof":102}],132:[function(require,module,exports){ // check on default Array iterator var Iterators = require('./_iterators'); var ITERATOR = require('./_wks')('iterator'); @@ -7272,14 +7160,14 @@ module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; -},{"./_iterators":149,"./_wks":213}],140:[function(require,module,exports){ +},{"./_iterators":142,"./_wks":206}],133:[function(require,module,exports){ // 7.2.2 IsArray(argument) var cof = require('./_cof'); module.exports = Array.isArray || function isArray(arg) { return cof(arg) == 'Array'; }; -},{"./_cof":109}],141:[function(require,module,exports){ +},{"./_cof":102}],134:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var isObject = require('./_is-object'); var floor = Math.floor; @@ -7287,9 +7175,9 @@ module.exports = function isInteger(it) { return !isObject(it) && isFinite(it) && floor(it) === it; }; -},{"./_is-object":142}],142:[function(require,module,exports){ -arguments[4][89][0].apply(exports,arguments) -},{"dup":89}],143:[function(require,module,exports){ +},{"./_is-object":135}],135:[function(require,module,exports){ +arguments[4][82][0].apply(exports,arguments) +},{"dup":82}],136:[function(require,module,exports){ // 7.2.8 IsRegExp(argument) var isObject = require('./_is-object'); var cof = require('./_cof'); @@ -7299,7 +7187,7 @@ module.exports = function (it) { return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); }; -},{"./_cof":109,"./_is-object":142,"./_wks":213}],144:[function(require,module,exports){ +},{"./_cof":102,"./_is-object":135,"./_wks":206}],137:[function(require,module,exports){ // call something on iterator step with safe closing on error var anObject = require('./_an-object'); module.exports = function (iterator, fn, value, entries) { @@ -7313,7 +7201,7 @@ module.exports = function (iterator, fn, value, entries) { } }; -},{"./_an-object":99}],145:[function(require,module,exports){ +},{"./_an-object":92}],138:[function(require,module,exports){ 'use strict'; var create = require('./_object-create'); var descriptor = require('./_property-desc'); @@ -7328,7 +7216,7 @@ module.exports = function (Constructor, NAME, next) { setToStringTag(Constructor, NAME + ' Iterator'); }; -},{"./_hide":133,"./_object-create":159,"./_property-desc":177,"./_set-to-string-tag":185,"./_wks":213}],146:[function(require,module,exports){ +},{"./_hide":126,"./_object-create":152,"./_property-desc":170,"./_set-to-string-tag":178,"./_wks":206}],139:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var $export = require('./_export'); @@ -7399,7 +7287,7 @@ module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE return methods; }; -},{"./_export":123,"./_hide":133,"./_iter-create":145,"./_iterators":149,"./_library":150,"./_object-gpo":166,"./_redefine":179,"./_set-to-string-tag":185,"./_wks":213}],147:[function(require,module,exports){ +},{"./_export":116,"./_hide":126,"./_iter-create":138,"./_iterators":142,"./_library":143,"./_object-gpo":159,"./_redefine":172,"./_set-to-string-tag":178,"./_wks":206}],140:[function(require,module,exports){ var ITERATOR = require('./_wks')('iterator'); var SAFE_CLOSING = false; @@ -7423,18 +7311,18 @@ module.exports = function (exec, skipClosing) { return safe; }; -},{"./_wks":213}],148:[function(require,module,exports){ +},{"./_wks":206}],141:[function(require,module,exports){ module.exports = function (done, value) { return { value: value, done: !!done }; }; -},{}],149:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ module.exports = {}; -},{}],150:[function(require,module,exports){ +},{}],143:[function(require,module,exports){ module.exports = false; -},{}],151:[function(require,module,exports){ +},{}],144:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $expm1 = Math.expm1; module.exports = (!$expm1 @@ -7446,7 +7334,7 @@ module.exports = (!$expm1 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; } : $expm1; -},{}],152:[function(require,module,exports){ +},{}],145:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var sign = require('./_math-sign'); var pow = Math.pow; @@ -7471,20 +7359,20 @@ module.exports = Math.fround || function fround(x) { return $sign * result; }; -},{"./_math-sign":154}],153:[function(require,module,exports){ +},{"./_math-sign":147}],146:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) module.exports = Math.log1p || function log1p(x) { return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); }; -},{}],154:[function(require,module,exports){ +},{}],147:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) module.exports = Math.sign || function sign(x) { // eslint-disable-next-line no-self-compare return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; }; -},{}],155:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ var META = require('./_uid')('meta'); var isObject = require('./_is-object'); var has = require('./_has'); @@ -7539,7 +7427,7 @@ var meta = module.exports = { onFreeze: onFreeze }; -},{"./_fails":125,"./_has":132,"./_is-object":142,"./_object-dp":160,"./_uid":208}],156:[function(require,module,exports){ +},{"./_fails":118,"./_has":125,"./_is-object":135,"./_object-dp":153,"./_uid":201}],149:[function(require,module,exports){ var global = require('./_global'); var macrotask = require('./_task').set; var Observer = global.MutationObserver || global.WebKitMutationObserver; @@ -7610,7 +7498,7 @@ module.exports = function () { }; }; -},{"./_cof":109,"./_global":131,"./_task":197}],157:[function(require,module,exports){ +},{"./_cof":102,"./_global":124,"./_task":190}],150:[function(require,module,exports){ 'use strict'; // 25.4.1.5 NewPromiseCapability(C) var aFunction = require('./_a-function'); @@ -7630,7 +7518,7 @@ module.exports.f = function (C) { return new PromiseCapability(C); }; -},{"./_a-function":94}],158:[function(require,module,exports){ +},{"./_a-function":87}],151:[function(require,module,exports){ 'use strict'; // 19.1.2.1 Object.assign(target, source, ...) var DESCRIPTORS = require('./_descriptors'); @@ -7670,7 +7558,7 @@ module.exports = !$assign || require('./_fails')(function () { } return T; } : $assign; -},{"./_descriptors":119,"./_fails":125,"./_iobject":138,"./_object-gops":165,"./_object-keys":168,"./_object-pie":169,"./_to-object":203}],159:[function(require,module,exports){ +},{"./_descriptors":112,"./_fails":118,"./_iobject":131,"./_object-gops":158,"./_object-keys":161,"./_object-pie":162,"./_to-object":196}],152:[function(require,module,exports){ // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = require('./_an-object'); var dPs = require('./_object-dps'); @@ -7713,9 +7601,9 @@ module.exports = Object.create || function create(O, Properties) { return Properties === undefined ? result : dPs(result, Properties); }; -},{"./_an-object":99,"./_dom-create":120,"./_enum-bug-keys":121,"./_html":134,"./_object-dps":161,"./_shared-key":186}],160:[function(require,module,exports){ -arguments[4][90][0].apply(exports,arguments) -},{"./_an-object":99,"./_descriptors":119,"./_ie8-dom-define":135,"./_to-primitive":204,"dup":90}],161:[function(require,module,exports){ +},{"./_an-object":92,"./_dom-create":113,"./_enum-bug-keys":114,"./_html":127,"./_object-dps":154,"./_shared-key":179}],153:[function(require,module,exports){ +arguments[4][83][0].apply(exports,arguments) +},{"./_an-object":92,"./_descriptors":112,"./_ie8-dom-define":128,"./_to-primitive":197,"dup":83}],154:[function(require,module,exports){ var dP = require('./_object-dp'); var anObject = require('./_an-object'); var getKeys = require('./_object-keys'); @@ -7730,7 +7618,7 @@ module.exports = require('./_descriptors') ? Object.defineProperties : function return O; }; -},{"./_an-object":99,"./_descriptors":119,"./_object-dp":160,"./_object-keys":168}],162:[function(require,module,exports){ +},{"./_an-object":92,"./_descriptors":112,"./_object-dp":153,"./_object-keys":161}],155:[function(require,module,exports){ var pIE = require('./_object-pie'); var createDesc = require('./_property-desc'); var toIObject = require('./_to-iobject'); @@ -7748,7 +7636,7 @@ exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); }; -},{"./_descriptors":119,"./_has":132,"./_ie8-dom-define":135,"./_object-pie":169,"./_property-desc":177,"./_to-iobject":201,"./_to-primitive":204}],163:[function(require,module,exports){ +},{"./_descriptors":112,"./_has":125,"./_ie8-dom-define":128,"./_object-pie":162,"./_property-desc":170,"./_to-iobject":194,"./_to-primitive":197}],156:[function(require,module,exports){ // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window var toIObject = require('./_to-iobject'); var gOPN = require('./_object-gopn').f; @@ -7769,7 +7657,7 @@ module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); }; -},{"./_object-gopn":164,"./_to-iobject":201}],164:[function(require,module,exports){ +},{"./_object-gopn":157,"./_to-iobject":194}],157:[function(require,module,exports){ // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = require('./_object-keys-internal'); var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype'); @@ -7778,10 +7666,10 @@ exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return $keys(O, hiddenKeys); }; -},{"./_enum-bug-keys":121,"./_object-keys-internal":167}],165:[function(require,module,exports){ +},{"./_enum-bug-keys":114,"./_object-keys-internal":160}],158:[function(require,module,exports){ exports.f = Object.getOwnPropertySymbols; -},{}],166:[function(require,module,exports){ +},{}],159:[function(require,module,exports){ // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = require('./_has'); var toObject = require('./_to-object'); @@ -7796,7 +7684,7 @@ module.exports = Object.getPrototypeOf || function (O) { } return O instanceof Object ? ObjectProto : null; }; -},{"./_has":132,"./_shared-key":186,"./_to-object":203}],167:[function(require,module,exports){ +},{"./_has":125,"./_shared-key":179,"./_to-object":196}],160:[function(require,module,exports){ var has = require('./_has'); var toIObject = require('./_to-iobject'); var arrayIndexOf = require('./_array-includes')(false); @@ -7815,7 +7703,7 @@ module.exports = function (object, names) { return result; }; -},{"./_array-includes":102,"./_has":132,"./_shared-key":186,"./_to-iobject":201}],168:[function(require,module,exports){ +},{"./_array-includes":95,"./_has":125,"./_shared-key":179,"./_to-iobject":194}],161:[function(require,module,exports){ // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = require('./_object-keys-internal'); var enumBugKeys = require('./_enum-bug-keys'); @@ -7824,10 +7712,10 @@ module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; -},{"./_enum-bug-keys":121,"./_object-keys-internal":167}],169:[function(require,module,exports){ +},{"./_enum-bug-keys":114,"./_object-keys-internal":160}],162:[function(require,module,exports){ exports.f = {}.propertyIsEnumerable; -},{}],170:[function(require,module,exports){ +},{}],163:[function(require,module,exports){ // most Object methods by ES6 should accept primitives var $export = require('./_export'); var core = require('./_core'); @@ -7839,7 +7727,7 @@ module.exports = function (KEY, exec) { $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); }; -},{"./_core":113,"./_export":123,"./_fails":125}],171:[function(require,module,exports){ +},{"./_core":106,"./_export":116,"./_fails":118}],164:[function(require,module,exports){ var DESCRIPTORS = require('./_descriptors'); var getKeys = require('./_object-keys'); var toIObject = require('./_to-iobject'); @@ -7862,7 +7750,7 @@ module.exports = function (isEntries) { }; }; -},{"./_descriptors":119,"./_object-keys":168,"./_object-pie":169,"./_to-iobject":201}],172:[function(require,module,exports){ +},{"./_descriptors":112,"./_object-keys":161,"./_object-pie":162,"./_to-iobject":194}],165:[function(require,module,exports){ // all object keys, includes non-enumerable and symbols var gOPN = require('./_object-gopn'); var gOPS = require('./_object-gops'); @@ -7874,7 +7762,7 @@ module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { return getSymbols ? keys.concat(getSymbols(it)) : keys; }; -},{"./_an-object":99,"./_global":131,"./_object-gopn":164,"./_object-gops":165}],173:[function(require,module,exports){ +},{"./_an-object":92,"./_global":124,"./_object-gopn":157,"./_object-gops":158}],166:[function(require,module,exports){ var $parseFloat = require('./_global').parseFloat; var $trim = require('./_string-trim').trim; @@ -7884,7 +7772,7 @@ module.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? return result === 0 && string.charAt(0) == '-' ? -0 : result; } : $parseFloat; -},{"./_global":131,"./_string-trim":195,"./_string-ws":196}],174:[function(require,module,exports){ +},{"./_global":124,"./_string-trim":188,"./_string-ws":189}],167:[function(require,module,exports){ var $parseInt = require('./_global').parseInt; var $trim = require('./_string-trim').trim; var ws = require('./_string-ws'); @@ -7895,7 +7783,7 @@ module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? f return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); } : $parseInt; -},{"./_global":131,"./_string-trim":195,"./_string-ws":196}],175:[function(require,module,exports){ +},{"./_global":124,"./_string-trim":188,"./_string-ws":189}],168:[function(require,module,exports){ module.exports = function (exec) { try { return { e: false, v: exec() }; @@ -7904,7 +7792,7 @@ module.exports = function (exec) { } }; -},{}],176:[function(require,module,exports){ +},{}],169:[function(require,module,exports){ var anObject = require('./_an-object'); var isObject = require('./_is-object'); var newPromiseCapability = require('./_new-promise-capability'); @@ -7918,16 +7806,16 @@ module.exports = function (C, x) { return promiseCapability.promise; }; -},{"./_an-object":99,"./_is-object":142,"./_new-promise-capability":157}],177:[function(require,module,exports){ -arguments[4][91][0].apply(exports,arguments) -},{"dup":91}],178:[function(require,module,exports){ +},{"./_an-object":92,"./_is-object":135,"./_new-promise-capability":150}],170:[function(require,module,exports){ +arguments[4][84][0].apply(exports,arguments) +},{"dup":84}],171:[function(require,module,exports){ var redefine = require('./_redefine'); module.exports = function (target, src, safe) { for (var key in src) redefine(target, key, src[key], safe); return target; }; -},{"./_redefine":179}],179:[function(require,module,exports){ +},{"./_redefine":172}],172:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var has = require('./_has'); @@ -7960,7 +7848,7 @@ require('./_core').inspectSource = function (it) { return typeof this == 'function' && this[SRC] || $toString.call(this); }); -},{"./_core":113,"./_function-to-string":130,"./_global":131,"./_has":132,"./_hide":133,"./_uid":208}],180:[function(require,module,exports){ +},{"./_core":106,"./_function-to-string":123,"./_global":124,"./_has":125,"./_hide":126,"./_uid":201}],173:[function(require,module,exports){ 'use strict'; var classof = require('./_classof'); @@ -7983,7 +7871,7 @@ module.exports = function (R, S) { return builtinExec.call(R, S); }; -},{"./_classof":108}],181:[function(require,module,exports){ +},{"./_classof":101}],174:[function(require,module,exports){ 'use strict'; var regexpFlags = require('./_flags'); @@ -8043,14 +7931,14 @@ if (PATCH) { module.exports = patchedExec; -},{"./_flags":127}],182:[function(require,module,exports){ +},{"./_flags":120}],175:[function(require,module,exports){ // 7.2.9 SameValue(x, y) module.exports = Object.is || function is(x, y) { // eslint-disable-next-line no-self-compare return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; }; -},{}],183:[function(require,module,exports){ +},{}],176:[function(require,module,exports){ // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ var isObject = require('./_is-object'); @@ -8077,7 +7965,7 @@ module.exports = { check: check }; -},{"./_an-object":99,"./_ctx":115,"./_is-object":142,"./_object-gopd":162}],184:[function(require,module,exports){ +},{"./_an-object":92,"./_ctx":108,"./_is-object":135,"./_object-gopd":155}],177:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var dP = require('./_object-dp'); @@ -8092,7 +7980,7 @@ module.exports = function (KEY) { }); }; -},{"./_descriptors":119,"./_global":131,"./_object-dp":160,"./_wks":213}],185:[function(require,module,exports){ +},{"./_descriptors":112,"./_global":124,"./_object-dp":153,"./_wks":206}],178:[function(require,module,exports){ var def = require('./_object-dp').f; var has = require('./_has'); var TAG = require('./_wks')('toStringTag'); @@ -8101,14 +7989,14 @@ module.exports = function (it, tag, stat) { if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); }; -},{"./_has":132,"./_object-dp":160,"./_wks":213}],186:[function(require,module,exports){ +},{"./_has":125,"./_object-dp":153,"./_wks":206}],179:[function(require,module,exports){ var shared = require('./_shared')('keys'); var uid = require('./_uid'); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; -},{"./_shared":187,"./_uid":208}],187:[function(require,module,exports){ +},{"./_shared":180,"./_uid":201}],180:[function(require,module,exports){ var core = require('./_core'); var global = require('./_global'); var SHARED = '__core-js_shared__'; @@ -8122,7 +8010,7 @@ var store = global[SHARED] || (global[SHARED] = {}); copyright: '© 2020 Denis Pushkarev (zloirock.ru)' }); -},{"./_core":113,"./_global":131,"./_library":150}],188:[function(require,module,exports){ +},{"./_core":106,"./_global":124,"./_library":143}],181:[function(require,module,exports){ // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = require('./_an-object'); var aFunction = require('./_a-function'); @@ -8133,7 +8021,7 @@ module.exports = function (O, D) { return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; -},{"./_a-function":94,"./_an-object":99,"./_wks":213}],189:[function(require,module,exports){ +},{"./_a-function":87,"./_an-object":92,"./_wks":206}],182:[function(require,module,exports){ 'use strict'; var fails = require('./_fails'); @@ -8144,7 +8032,7 @@ module.exports = function (method, arg) { }); }; -},{"./_fails":125}],190:[function(require,module,exports){ +},{"./_fails":118}],183:[function(require,module,exports){ var toInteger = require('./_to-integer'); var defined = require('./_defined'); // true -> String#at @@ -8163,7 +8051,7 @@ module.exports = function (TO_STRING) { }; }; -},{"./_defined":118,"./_to-integer":200}],191:[function(require,module,exports){ +},{"./_defined":111,"./_to-integer":193}],184:[function(require,module,exports){ // helper for String#{startsWith, endsWith, includes} var isRegExp = require('./_is-regexp'); var defined = require('./_defined'); @@ -8173,7 +8061,7 @@ module.exports = function (that, searchString, NAME) { return String(defined(that)); }; -},{"./_defined":118,"./_is-regexp":143}],192:[function(require,module,exports){ +},{"./_defined":111,"./_is-regexp":136}],185:[function(require,module,exports){ var $export = require('./_export'); var fails = require('./_fails'); var defined = require('./_defined'); @@ -8194,7 +8082,7 @@ module.exports = function (NAME, exec) { }), 'String', O); }; -},{"./_defined":118,"./_export":123,"./_fails":125}],193:[function(require,module,exports){ +},{"./_defined":111,"./_export":116,"./_fails":118}],186:[function(require,module,exports){ // https://github.com/tc39/proposal-string-pad-start-end var toLength = require('./_to-length'); var repeat = require('./_string-repeat'); @@ -8212,7 +8100,7 @@ module.exports = function (that, maxLength, fillString, left) { return left ? stringFiller + S : S + stringFiller; }; -},{"./_defined":118,"./_string-repeat":194,"./_to-length":202}],194:[function(require,module,exports){ +},{"./_defined":111,"./_string-repeat":187,"./_to-length":195}],187:[function(require,module,exports){ 'use strict'; var toInteger = require('./_to-integer'); var defined = require('./_defined'); @@ -8226,7 +8114,7 @@ module.exports = function repeat(count) { return res; }; -},{"./_defined":118,"./_to-integer":200}],195:[function(require,module,exports){ +},{"./_defined":111,"./_to-integer":193}],188:[function(require,module,exports){ var $export = require('./_export'); var defined = require('./_defined'); var fails = require('./_fails'); @@ -8258,11 +8146,11 @@ var trim = exporter.trim = function (string, TYPE) { module.exports = exporter; -},{"./_defined":118,"./_export":123,"./_fails":125,"./_string-ws":196}],196:[function(require,module,exports){ +},{"./_defined":111,"./_export":116,"./_fails":118,"./_string-ws":189}],189:[function(require,module,exports){ module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -},{}],197:[function(require,module,exports){ +},{}],190:[function(require,module,exports){ var ctx = require('./_ctx'); var invoke = require('./_invoke'); var html = require('./_html'); @@ -8348,7 +8236,7 @@ module.exports = { clear: clearTask }; -},{"./_cof":109,"./_ctx":115,"./_dom-create":120,"./_global":131,"./_html":134,"./_invoke":137}],198:[function(require,module,exports){ +},{"./_cof":102,"./_ctx":108,"./_dom-create":113,"./_global":124,"./_html":127,"./_invoke":130}],191:[function(require,module,exports){ var toInteger = require('./_to-integer'); var max = Math.max; var min = Math.min; @@ -8357,7 +8245,7 @@ module.exports = function (index, length) { return index < 0 ? max(index + length, 0) : min(index, length); }; -},{"./_to-integer":200}],199:[function(require,module,exports){ +},{"./_to-integer":193}],192:[function(require,module,exports){ // https://tc39.github.io/ecma262/#sec-toindex var toInteger = require('./_to-integer'); var toLength = require('./_to-length'); @@ -8369,7 +8257,7 @@ module.exports = function (it) { return length; }; -},{"./_to-integer":200,"./_to-length":202}],200:[function(require,module,exports){ +},{"./_to-integer":193,"./_to-length":195}],193:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; @@ -8377,7 +8265,7 @@ module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],201:[function(require,module,exports){ +},{}],194:[function(require,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = require('./_iobject'); var defined = require('./_defined'); @@ -8385,7 +8273,7 @@ module.exports = function (it) { return IObject(defined(it)); }; -},{"./_defined":118,"./_iobject":138}],202:[function(require,module,exports){ +},{"./_defined":111,"./_iobject":131}],195:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./_to-integer'); var min = Math.min; @@ -8393,16 +8281,16 @@ module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./_to-integer":200}],203:[function(require,module,exports){ +},{"./_to-integer":193}],196:[function(require,module,exports){ // 7.1.13 ToObject(argument) var defined = require('./_defined'); module.exports = function (it) { return Object(defined(it)); }; -},{"./_defined":118}],204:[function(require,module,exports){ -arguments[4][92][0].apply(exports,arguments) -},{"./_is-object":142,"dup":92}],205:[function(require,module,exports){ +},{"./_defined":111}],197:[function(require,module,exports){ +arguments[4][85][0].apply(exports,arguments) +},{"./_is-object":135,"dup":85}],198:[function(require,module,exports){ 'use strict'; if (require('./_descriptors')) { var LIBRARY = require('./_library'); @@ -8884,7 +8772,7 @@ if (require('./_descriptors')) { }; } else module.exports = function () { /* empty */ }; -},{"./_an-instance":98,"./_array-copy-within":100,"./_array-fill":101,"./_array-includes":102,"./_array-methods":103,"./_classof":108,"./_ctx":115,"./_descriptors":119,"./_export":123,"./_fails":125,"./_global":131,"./_has":132,"./_hide":133,"./_is-array-iter":139,"./_is-object":142,"./_iter-detect":147,"./_iterators":149,"./_library":150,"./_object-create":159,"./_object-dp":160,"./_object-gopd":162,"./_object-gopn":164,"./_object-gpo":166,"./_property-desc":177,"./_redefine-all":178,"./_set-species":184,"./_species-constructor":188,"./_to-absolute-index":198,"./_to-index":199,"./_to-integer":200,"./_to-length":202,"./_to-object":203,"./_to-primitive":204,"./_typed":207,"./_typed-buffer":206,"./_uid":208,"./_wks":213,"./core.get-iterator-method":214,"./es6.array.iterator":225}],206:[function(require,module,exports){ +},{"./_an-instance":91,"./_array-copy-within":93,"./_array-fill":94,"./_array-includes":95,"./_array-methods":96,"./_classof":101,"./_ctx":108,"./_descriptors":112,"./_export":116,"./_fails":118,"./_global":124,"./_has":125,"./_hide":126,"./_is-array-iter":132,"./_is-object":135,"./_iter-detect":140,"./_iterators":142,"./_library":143,"./_object-create":152,"./_object-dp":153,"./_object-gopd":155,"./_object-gopn":157,"./_object-gpo":159,"./_property-desc":170,"./_redefine-all":171,"./_set-species":177,"./_species-constructor":181,"./_to-absolute-index":191,"./_to-index":192,"./_to-integer":193,"./_to-length":195,"./_to-object":196,"./_to-primitive":197,"./_typed":200,"./_typed-buffer":199,"./_uid":201,"./_wks":206,"./core.get-iterator-method":207,"./es6.array.iterator":218}],199:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var DESCRIPTORS = require('./_descriptors'); @@ -9162,7 +9050,7 @@ hide($DataView[PROTOTYPE], $typed.VIEW, true); exports[ARRAY_BUFFER] = $ArrayBuffer; exports[DATA_VIEW] = $DataView; -},{"./_an-instance":98,"./_array-fill":101,"./_descriptors":119,"./_fails":125,"./_global":131,"./_hide":133,"./_library":150,"./_object-dp":160,"./_object-gopn":164,"./_redefine-all":178,"./_set-to-string-tag":185,"./_to-index":199,"./_to-integer":200,"./_to-length":202,"./_typed":207}],207:[function(require,module,exports){ +},{"./_an-instance":91,"./_array-fill":94,"./_descriptors":112,"./_fails":118,"./_global":124,"./_hide":126,"./_library":143,"./_object-dp":153,"./_object-gopn":157,"./_redefine-all":171,"./_set-to-string-tag":178,"./_to-index":192,"./_to-integer":193,"./_to-length":195,"./_typed":200}],200:[function(require,module,exports){ var global = require('./_global'); var hide = require('./_hide'); var uid = require('./_uid'); @@ -9192,27 +9080,27 @@ module.exports = { VIEW: VIEW }; -},{"./_global":131,"./_hide":133,"./_uid":208}],208:[function(require,module,exports){ +},{"./_global":124,"./_hide":126,"./_uid":201}],201:[function(require,module,exports){ var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],209:[function(require,module,exports){ +},{}],202:[function(require,module,exports){ var global = require('./_global'); var navigator = global.navigator; module.exports = navigator && navigator.userAgent || ''; -},{"./_global":131}],210:[function(require,module,exports){ +},{"./_global":124}],203:[function(require,module,exports){ var isObject = require('./_is-object'); module.exports = function (it, TYPE) { if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); return it; }; -},{"./_is-object":142}],211:[function(require,module,exports){ +},{"./_is-object":135}],204:[function(require,module,exports){ var global = require('./_global'); var core = require('./_core'); var LIBRARY = require('./_library'); @@ -9223,10 +9111,10 @@ module.exports = function (name) { if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); }; -},{"./_core":113,"./_global":131,"./_library":150,"./_object-dp":160,"./_wks-ext":212}],212:[function(require,module,exports){ +},{"./_core":106,"./_global":124,"./_library":143,"./_object-dp":153,"./_wks-ext":205}],205:[function(require,module,exports){ exports.f = require('./_wks'); -},{"./_wks":213}],213:[function(require,module,exports){ +},{"./_wks":206}],206:[function(require,module,exports){ var store = require('./_shared')('wks'); var uid = require('./_uid'); var Symbol = require('./_global').Symbol; @@ -9239,7 +9127,7 @@ var $exports = module.exports = function (name) { $exports.store = store; -},{"./_global":131,"./_shared":187,"./_uid":208}],214:[function(require,module,exports){ +},{"./_global":124,"./_shared":180,"./_uid":201}],207:[function(require,module,exports){ var classof = require('./_classof'); var ITERATOR = require('./_wks')('iterator'); var Iterators = require('./_iterators'); @@ -9249,7 +9137,7 @@ module.exports = require('./_core').getIteratorMethod = function (it) { || Iterators[classof(it)]; }; -},{"./_classof":108,"./_core":113,"./_iterators":149,"./_wks":213}],215:[function(require,module,exports){ +},{"./_classof":101,"./_core":106,"./_iterators":142,"./_wks":206}],208:[function(require,module,exports){ // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) var $export = require('./_export'); @@ -9257,7 +9145,7 @@ $export($export.P, 'Array', { copyWithin: require('./_array-copy-within') }); require('./_add-to-unscopables')('copyWithin'); -},{"./_add-to-unscopables":96,"./_array-copy-within":100,"./_export":123}],216:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_array-copy-within":93,"./_export":116}],209:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $every = require('./_array-methods')(4); @@ -9269,7 +9157,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].every, true), 'A } }); -},{"./_array-methods":103,"./_export":123,"./_strict-method":189}],217:[function(require,module,exports){ +},{"./_array-methods":96,"./_export":116,"./_strict-method":182}],210:[function(require,module,exports){ // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) var $export = require('./_export'); @@ -9277,7 +9165,7 @@ $export($export.P, 'Array', { fill: require('./_array-fill') }); require('./_add-to-unscopables')('fill'); -},{"./_add-to-unscopables":96,"./_array-fill":101,"./_export":123}],218:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_array-fill":94,"./_export":116}],211:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $filter = require('./_array-methods')(2); @@ -9289,7 +9177,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].filter, true), ' } }); -},{"./_array-methods":103,"./_export":123,"./_strict-method":189}],219:[function(require,module,exports){ +},{"./_array-methods":96,"./_export":116,"./_strict-method":182}],212:[function(require,module,exports){ 'use strict'; // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) var $export = require('./_export'); @@ -9305,7 +9193,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":96,"./_array-methods":103,"./_export":123}],220:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_array-methods":96,"./_export":116}],213:[function(require,module,exports){ 'use strict'; // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) var $export = require('./_export'); @@ -9321,7 +9209,7 @@ $export($export.P + $export.F * forced, 'Array', { }); require('./_add-to-unscopables')(KEY); -},{"./_add-to-unscopables":96,"./_array-methods":103,"./_export":123}],221:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_array-methods":96,"./_export":116}],214:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $forEach = require('./_array-methods')(0); @@ -9334,7 +9222,7 @@ $export($export.P + $export.F * !STRICT, 'Array', { } }); -},{"./_array-methods":103,"./_export":123,"./_strict-method":189}],222:[function(require,module,exports){ +},{"./_array-methods":96,"./_export":116,"./_strict-method":182}],215:[function(require,module,exports){ 'use strict'; var ctx = require('./_ctx'); var $export = require('./_export'); @@ -9373,7 +9261,7 @@ $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Arr } }); -},{"./_create-property":114,"./_ctx":115,"./_export":123,"./_is-array-iter":139,"./_iter-call":144,"./_iter-detect":147,"./_to-length":202,"./_to-object":203,"./core.get-iterator-method":214}],223:[function(require,module,exports){ +},{"./_create-property":107,"./_ctx":108,"./_export":116,"./_is-array-iter":132,"./_iter-call":137,"./_iter-detect":140,"./_to-length":195,"./_to-object":196,"./core.get-iterator-method":207}],216:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $indexOf = require('./_array-includes')(false); @@ -9390,13 +9278,13 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_array-includes":102,"./_export":123,"./_strict-method":189}],224:[function(require,module,exports){ +},{"./_array-includes":95,"./_export":116,"./_strict-method":182}],217:[function(require,module,exports){ // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) var $export = require('./_export'); $export($export.S, 'Array', { isArray: require('./_is-array') }); -},{"./_export":123,"./_is-array":140}],225:[function(require,module,exports){ +},{"./_export":116,"./_is-array":133}],218:[function(require,module,exports){ 'use strict'; var addToUnscopables = require('./_add-to-unscopables'); var step = require('./_iter-step'); @@ -9432,7 +9320,7 @@ addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"./_add-to-unscopables":96,"./_iter-define":146,"./_iter-step":148,"./_iterators":149,"./_to-iobject":201}],226:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_iter-define":139,"./_iter-step":141,"./_iterators":142,"./_to-iobject":194}],219:[function(require,module,exports){ 'use strict'; // 22.1.3.13 Array.prototype.join(separator) var $export = require('./_export'); @@ -9446,7 +9334,7 @@ $export($export.P + $export.F * (require('./_iobject') != Object || !require('./ } }); -},{"./_export":123,"./_iobject":138,"./_strict-method":189,"./_to-iobject":201}],227:[function(require,module,exports){ +},{"./_export":116,"./_iobject":131,"./_strict-method":182,"./_to-iobject":194}],220:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toIObject = require('./_to-iobject'); @@ -9470,7 +9358,7 @@ $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($ } }); -},{"./_export":123,"./_strict-method":189,"./_to-integer":200,"./_to-iobject":201,"./_to-length":202}],228:[function(require,module,exports){ +},{"./_export":116,"./_strict-method":182,"./_to-integer":193,"./_to-iobject":194,"./_to-length":195}],221:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $map = require('./_array-methods')(1); @@ -9482,7 +9370,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Arr } }); -},{"./_array-methods":103,"./_export":123,"./_strict-method":189}],229:[function(require,module,exports){ +},{"./_array-methods":96,"./_export":116,"./_strict-method":182}],222:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var createProperty = require('./_create-property'); @@ -9503,7 +9391,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_create-property":114,"./_export":123,"./_fails":125}],230:[function(require,module,exports){ +},{"./_create-property":107,"./_export":116,"./_fails":118}],223:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -9515,7 +9403,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduceRight, tru } }); -},{"./_array-reduce":104,"./_export":123,"./_strict-method":189}],231:[function(require,module,exports){ +},{"./_array-reduce":97,"./_export":116,"./_strict-method":182}],224:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $reduce = require('./_array-reduce'); @@ -9527,7 +9415,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].reduce, true), ' } }); -},{"./_array-reduce":104,"./_export":123,"./_strict-method":189}],232:[function(require,module,exports){ +},{"./_array-reduce":97,"./_export":116,"./_strict-method":182}],225:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var html = require('./_html'); @@ -9557,7 +9445,7 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_cof":109,"./_export":123,"./_fails":125,"./_html":134,"./_to-absolute-index":198,"./_to-length":202}],233:[function(require,module,exports){ +},{"./_cof":102,"./_export":116,"./_fails":118,"./_html":127,"./_to-absolute-index":191,"./_to-length":195}],226:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $some = require('./_array-methods')(3); @@ -9569,7 +9457,7 @@ $export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Ar } }); -},{"./_array-methods":103,"./_export":123,"./_strict-method":189}],234:[function(require,module,exports){ +},{"./_array-methods":96,"./_export":116,"./_strict-method":182}],227:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -9594,16 +9482,16 @@ $export($export.P + $export.F * (fails(function () { } }); -},{"./_a-function":94,"./_export":123,"./_fails":125,"./_strict-method":189,"./_to-object":203}],235:[function(require,module,exports){ +},{"./_a-function":87,"./_export":116,"./_fails":118,"./_strict-method":182,"./_to-object":196}],228:[function(require,module,exports){ require('./_set-species')('Array'); -},{"./_set-species":184}],236:[function(require,module,exports){ +},{"./_set-species":177}],229:[function(require,module,exports){ // 20.3.3.1 / 15.9.4.4 Date.now() var $export = require('./_export'); $export($export.S, 'Date', { now: function () { return new Date().getTime(); } }); -},{"./_export":123}],237:[function(require,module,exports){ +},{"./_export":116}],230:[function(require,module,exports){ // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() var $export = require('./_export'); var toISOString = require('./_date-to-iso-string'); @@ -9613,7 +9501,7 @@ $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'D toISOString: toISOString }); -},{"./_date-to-iso-string":116,"./_export":123}],238:[function(require,module,exports){ +},{"./_date-to-iso-string":109,"./_export":116}],231:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toObject = require('./_to-object'); @@ -9631,13 +9519,13 @@ $export($export.P + $export.F * require('./_fails')(function () { } }); -},{"./_export":123,"./_fails":125,"./_to-object":203,"./_to-primitive":204}],239:[function(require,module,exports){ +},{"./_export":116,"./_fails":118,"./_to-object":196,"./_to-primitive":197}],232:[function(require,module,exports){ var TO_PRIMITIVE = require('./_wks')('toPrimitive'); var proto = Date.prototype; if (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive')); -},{"./_date-to-primitive":117,"./_hide":133,"./_wks":213}],240:[function(require,module,exports){ +},{"./_date-to-primitive":110,"./_hide":126,"./_wks":206}],233:[function(require,module,exports){ var DateProto = Date.prototype; var INVALID_DATE = 'Invalid Date'; var TO_STRING = 'toString'; @@ -9651,13 +9539,13 @@ if (new Date(NaN) + '' != INVALID_DATE) { }); } -},{"./_redefine":179}],241:[function(require,module,exports){ +},{"./_redefine":172}],234:[function(require,module,exports){ // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) var $export = require('./_export'); $export($export.P, 'Function', { bind: require('./_bind') }); -},{"./_bind":107,"./_export":123}],242:[function(require,module,exports){ +},{"./_bind":100,"./_export":116}],235:[function(require,module,exports){ 'use strict'; var isObject = require('./_is-object'); var getPrototypeOf = require('./_object-gpo'); @@ -9672,7 +9560,7 @@ if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, H return false; } }); -},{"./_is-object":142,"./_object-dp":160,"./_object-gpo":166,"./_wks":213}],243:[function(require,module,exports){ +},{"./_is-object":135,"./_object-dp":153,"./_object-gpo":159,"./_wks":206}],236:[function(require,module,exports){ var dP = require('./_object-dp').f; var FProto = Function.prototype; var nameRE = /^\s*function ([^ (]*)/; @@ -9690,7 +9578,7 @@ NAME in FProto || require('./_descriptors') && dP(FProto, NAME, { } }); -},{"./_descriptors":119,"./_object-dp":160}],244:[function(require,module,exports){ +},{"./_descriptors":112,"./_object-dp":153}],237:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -9711,7 +9599,7 @@ module.exports = require('./_collection')(MAP, function (get) { } }, strong, true); -},{"./_collection":112,"./_collection-strong":110,"./_validate-collection":210}],245:[function(require,module,exports){ +},{"./_collection":105,"./_collection-strong":103,"./_validate-collection":203}],238:[function(require,module,exports){ // 20.2.2.3 Math.acosh(x) var $export = require('./_export'); var log1p = require('./_math-log1p'); @@ -9731,7 +9619,7 @@ $export($export.S + $export.F * !($acosh } }); -},{"./_export":123,"./_math-log1p":153}],246:[function(require,module,exports){ +},{"./_export":116,"./_math-log1p":146}],239:[function(require,module,exports){ // 20.2.2.5 Math.asinh(x) var $export = require('./_export'); var $asinh = Math.asinh; @@ -9743,7 +9631,7 @@ function asinh(x) { // Tor Browser bug: Math.asinh(0) -> -0 $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh }); -},{"./_export":123}],247:[function(require,module,exports){ +},{"./_export":116}],240:[function(require,module,exports){ // 20.2.2.7 Math.atanh(x) var $export = require('./_export'); var $atanh = Math.atanh; @@ -9755,7 +9643,7 @@ $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { } }); -},{"./_export":123}],248:[function(require,module,exports){ +},{"./_export":116}],241:[function(require,module,exports){ // 20.2.2.9 Math.cbrt(x) var $export = require('./_export'); var sign = require('./_math-sign'); @@ -9766,7 +9654,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":123,"./_math-sign":154}],249:[function(require,module,exports){ +},{"./_export":116,"./_math-sign":147}],242:[function(require,module,exports){ // 20.2.2.11 Math.clz32(x) var $export = require('./_export'); @@ -9776,7 +9664,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],250:[function(require,module,exports){ +},{"./_export":116}],243:[function(require,module,exports){ // 20.2.2.12 Math.cosh(x) var $export = require('./_export'); var exp = Math.exp; @@ -9787,20 +9675,20 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],251:[function(require,module,exports){ +},{"./_export":116}],244:[function(require,module,exports){ // 20.2.2.14 Math.expm1(x) var $export = require('./_export'); var $expm1 = require('./_math-expm1'); $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 }); -},{"./_export":123,"./_math-expm1":151}],252:[function(require,module,exports){ +},{"./_export":116,"./_math-expm1":144}],245:[function(require,module,exports){ // 20.2.2.16 Math.fround(x) var $export = require('./_export'); $export($export.S, 'Math', { fround: require('./_math-fround') }); -},{"./_export":123,"./_math-fround":152}],253:[function(require,module,exports){ +},{"./_export":116,"./_math-fround":145}],246:[function(require,module,exports){ // 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) var $export = require('./_export'); var abs = Math.abs; @@ -9827,7 +9715,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],254:[function(require,module,exports){ +},{"./_export":116}],247:[function(require,module,exports){ // 20.2.2.18 Math.imul(x, y) var $export = require('./_export'); var $imul = Math.imul; @@ -9846,7 +9734,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":123,"./_fails":125}],255:[function(require,module,exports){ +},{"./_export":116,"./_fails":118}],248:[function(require,module,exports){ // 20.2.2.21 Math.log10(x) var $export = require('./_export'); @@ -9856,13 +9744,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],256:[function(require,module,exports){ +},{"./_export":116}],249:[function(require,module,exports){ // 20.2.2.20 Math.log1p(x) var $export = require('./_export'); $export($export.S, 'Math', { log1p: require('./_math-log1p') }); -},{"./_export":123,"./_math-log1p":153}],257:[function(require,module,exports){ +},{"./_export":116,"./_math-log1p":146}],250:[function(require,module,exports){ // 20.2.2.22 Math.log2(x) var $export = require('./_export'); @@ -9872,13 +9760,13 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],258:[function(require,module,exports){ +},{"./_export":116}],251:[function(require,module,exports){ // 20.2.2.28 Math.sign(x) var $export = require('./_export'); $export($export.S, 'Math', { sign: require('./_math-sign') }); -},{"./_export":123,"./_math-sign":154}],259:[function(require,module,exports){ +},{"./_export":116,"./_math-sign":147}],252:[function(require,module,exports){ // 20.2.2.30 Math.sinh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9895,7 +9783,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_export":123,"./_fails":125,"./_math-expm1":151}],260:[function(require,module,exports){ +},{"./_export":116,"./_fails":118,"./_math-expm1":144}],253:[function(require,module,exports){ // 20.2.2.33 Math.tanh(x) var $export = require('./_export'); var expm1 = require('./_math-expm1'); @@ -9909,7 +9797,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":123,"./_math-expm1":151}],261:[function(require,module,exports){ +},{"./_export":116,"./_math-expm1":144}],254:[function(require,module,exports){ // 20.2.2.34 Math.trunc(x) var $export = require('./_export'); @@ -9919,7 +9807,7 @@ $export($export.S, 'Math', { } }); -},{"./_export":123}],262:[function(require,module,exports){ +},{"./_export":116}],255:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var has = require('./_has'); @@ -9990,13 +9878,13 @@ if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { require('./_redefine')(global, NUMBER, $Number); } -},{"./_cof":109,"./_descriptors":119,"./_fails":125,"./_global":131,"./_has":132,"./_inherit-if-required":136,"./_object-create":159,"./_object-dp":160,"./_object-gopd":162,"./_object-gopn":164,"./_redefine":179,"./_string-trim":195,"./_to-primitive":204}],263:[function(require,module,exports){ +},{"./_cof":102,"./_descriptors":112,"./_fails":118,"./_global":124,"./_has":125,"./_inherit-if-required":129,"./_object-create":152,"./_object-dp":153,"./_object-gopd":155,"./_object-gopn":157,"./_redefine":172,"./_string-trim":188,"./_to-primitive":197}],256:[function(require,module,exports){ // 20.1.2.1 Number.EPSILON var $export = require('./_export'); $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); -},{"./_export":123}],264:[function(require,module,exports){ +},{"./_export":116}],257:[function(require,module,exports){ // 20.1.2.2 Number.isFinite(number) var $export = require('./_export'); var _isFinite = require('./_global').isFinite; @@ -10007,13 +9895,13 @@ $export($export.S, 'Number', { } }); -},{"./_export":123,"./_global":131}],265:[function(require,module,exports){ +},{"./_export":116,"./_global":124}],258:[function(require,module,exports){ // 20.1.2.3 Number.isInteger(number) var $export = require('./_export'); $export($export.S, 'Number', { isInteger: require('./_is-integer') }); -},{"./_export":123,"./_is-integer":141}],266:[function(require,module,exports){ +},{"./_export":116,"./_is-integer":134}],259:[function(require,module,exports){ // 20.1.2.4 Number.isNaN(number) var $export = require('./_export'); @@ -10024,7 +9912,7 @@ $export($export.S, 'Number', { } }); -},{"./_export":123}],267:[function(require,module,exports){ +},{"./_export":116}],260:[function(require,module,exports){ // 20.1.2.5 Number.isSafeInteger(number) var $export = require('./_export'); var isInteger = require('./_is-integer'); @@ -10036,31 +9924,31 @@ $export($export.S, 'Number', { } }); -},{"./_export":123,"./_is-integer":141}],268:[function(require,module,exports){ +},{"./_export":116,"./_is-integer":134}],261:[function(require,module,exports){ // 20.1.2.6 Number.MAX_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); -},{"./_export":123}],269:[function(require,module,exports){ +},{"./_export":116}],262:[function(require,module,exports){ // 20.1.2.10 Number.MIN_SAFE_INTEGER var $export = require('./_export'); $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); -},{"./_export":123}],270:[function(require,module,exports){ +},{"./_export":116}],263:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 20.1.2.12 Number.parseFloat(string) $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat }); -},{"./_export":123,"./_parse-float":173}],271:[function(require,module,exports){ +},{"./_export":116,"./_parse-float":166}],264:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 20.1.2.13 Number.parseInt(string, radix) $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt }); -},{"./_export":123,"./_parse-int":174}],272:[function(require,module,exports){ +},{"./_export":116,"./_parse-int":167}],265:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var toInteger = require('./_to-integer'); @@ -10176,7 +10064,7 @@ $export($export.P + $export.F * (!!$toFixed && ( } }); -},{"./_a-number-value":95,"./_export":123,"./_fails":125,"./_string-repeat":194,"./_to-integer":200}],273:[function(require,module,exports){ +},{"./_a-number-value":88,"./_export":116,"./_fails":118,"./_string-repeat":187,"./_to-integer":193}],266:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $fails = require('./_fails'); @@ -10196,28 +10084,28 @@ $export($export.P + $export.F * ($fails(function () { } }); -},{"./_a-number-value":95,"./_export":123,"./_fails":125}],274:[function(require,module,exports){ +},{"./_a-number-value":88,"./_export":116,"./_fails":118}],267:[function(require,module,exports){ // 19.1.3.1 Object.assign(target, source) var $export = require('./_export'); $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') }); -},{"./_export":123,"./_object-assign":158}],275:[function(require,module,exports){ +},{"./_export":116,"./_object-assign":151}],268:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) $export($export.S, 'Object', { create: require('./_object-create') }); -},{"./_export":123,"./_object-create":159}],276:[function(require,module,exports){ +},{"./_export":116,"./_object-create":152}],269:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') }); -},{"./_descriptors":119,"./_export":123,"./_object-dps":161}],277:[function(require,module,exports){ +},{"./_descriptors":112,"./_export":116,"./_object-dps":154}],270:[function(require,module,exports){ var $export = require('./_export'); // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f }); -},{"./_descriptors":119,"./_export":123,"./_object-dp":160}],278:[function(require,module,exports){ +},{"./_descriptors":112,"./_export":116,"./_object-dp":153}],271:[function(require,module,exports){ // 19.1.2.5 Object.freeze(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10228,7 +10116,7 @@ require('./_object-sap')('freeze', function ($freeze) { }; }); -},{"./_is-object":142,"./_meta":155,"./_object-sap":170}],279:[function(require,module,exports){ +},{"./_is-object":135,"./_meta":148,"./_object-sap":163}],272:[function(require,module,exports){ // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) var toIObject = require('./_to-iobject'); var $getOwnPropertyDescriptor = require('./_object-gopd').f; @@ -10239,13 +10127,13 @@ require('./_object-sap')('getOwnPropertyDescriptor', function () { }; }); -},{"./_object-gopd":162,"./_object-sap":170,"./_to-iobject":201}],280:[function(require,module,exports){ +},{"./_object-gopd":155,"./_object-sap":163,"./_to-iobject":194}],273:[function(require,module,exports){ // 19.1.2.7 Object.getOwnPropertyNames(O) require('./_object-sap')('getOwnPropertyNames', function () { return require('./_object-gopn-ext').f; }); -},{"./_object-gopn-ext":163,"./_object-sap":170}],281:[function(require,module,exports){ +},{"./_object-gopn-ext":156,"./_object-sap":163}],274:[function(require,module,exports){ // 19.1.2.9 Object.getPrototypeOf(O) var toObject = require('./_to-object'); var $getPrototypeOf = require('./_object-gpo'); @@ -10256,7 +10144,7 @@ require('./_object-sap')('getPrototypeOf', function () { }; }); -},{"./_object-gpo":166,"./_object-sap":170,"./_to-object":203}],282:[function(require,module,exports){ +},{"./_object-gpo":159,"./_object-sap":163,"./_to-object":196}],275:[function(require,module,exports){ // 19.1.2.11 Object.isExtensible(O) var isObject = require('./_is-object'); @@ -10266,7 +10154,7 @@ require('./_object-sap')('isExtensible', function ($isExtensible) { }; }); -},{"./_is-object":142,"./_object-sap":170}],283:[function(require,module,exports){ +},{"./_is-object":135,"./_object-sap":163}],276:[function(require,module,exports){ // 19.1.2.12 Object.isFrozen(O) var isObject = require('./_is-object'); @@ -10276,7 +10164,7 @@ require('./_object-sap')('isFrozen', function ($isFrozen) { }; }); -},{"./_is-object":142,"./_object-sap":170}],284:[function(require,module,exports){ +},{"./_is-object":135,"./_object-sap":163}],277:[function(require,module,exports){ // 19.1.2.13 Object.isSealed(O) var isObject = require('./_is-object'); @@ -10286,12 +10174,12 @@ require('./_object-sap')('isSealed', function ($isSealed) { }; }); -},{"./_is-object":142,"./_object-sap":170}],285:[function(require,module,exports){ +},{"./_is-object":135,"./_object-sap":163}],278:[function(require,module,exports){ // 19.1.3.10 Object.is(value1, value2) var $export = require('./_export'); $export($export.S, 'Object', { is: require('./_same-value') }); -},{"./_export":123,"./_same-value":182}],286:[function(require,module,exports){ +},{"./_export":116,"./_same-value":175}],279:[function(require,module,exports){ // 19.1.2.14 Object.keys(O) var toObject = require('./_to-object'); var $keys = require('./_object-keys'); @@ -10302,7 +10190,7 @@ require('./_object-sap')('keys', function () { }; }); -},{"./_object-keys":168,"./_object-sap":170,"./_to-object":203}],287:[function(require,module,exports){ +},{"./_object-keys":161,"./_object-sap":163,"./_to-object":196}],280:[function(require,module,exports){ // 19.1.2.15 Object.preventExtensions(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10313,7 +10201,7 @@ require('./_object-sap')('preventExtensions', function ($preventExtensions) { }; }); -},{"./_is-object":142,"./_meta":155,"./_object-sap":170}],288:[function(require,module,exports){ +},{"./_is-object":135,"./_meta":148,"./_object-sap":163}],281:[function(require,module,exports){ // 19.1.2.17 Object.seal(O) var isObject = require('./_is-object'); var meta = require('./_meta').onFreeze; @@ -10324,12 +10212,12 @@ require('./_object-sap')('seal', function ($seal) { }; }); -},{"./_is-object":142,"./_meta":155,"./_object-sap":170}],289:[function(require,module,exports){ +},{"./_is-object":135,"./_meta":148,"./_object-sap":163}],282:[function(require,module,exports){ // 19.1.3.19 Object.setPrototypeOf(O, proto) var $export = require('./_export'); $export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set }); -},{"./_export":123,"./_set-proto":183}],290:[function(require,module,exports){ +},{"./_export":116,"./_set-proto":176}],283:[function(require,module,exports){ 'use strict'; // 19.1.3.6 Object.prototype.toString() var classof = require('./_classof'); @@ -10341,19 +10229,19 @@ if (test + '' != '[object z]') { }, true); } -},{"./_classof":108,"./_redefine":179,"./_wks":213}],291:[function(require,module,exports){ +},{"./_classof":101,"./_redefine":172,"./_wks":206}],284:[function(require,module,exports){ var $export = require('./_export'); var $parseFloat = require('./_parse-float'); // 18.2.4 parseFloat(string) $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat }); -},{"./_export":123,"./_parse-float":173}],292:[function(require,module,exports){ +},{"./_export":116,"./_parse-float":166}],285:[function(require,module,exports){ var $export = require('./_export'); var $parseInt = require('./_parse-int'); // 18.2.5 parseInt(string, radix) $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt }); -},{"./_export":123,"./_parse-int":174}],293:[function(require,module,exports){ +},{"./_export":116,"./_parse-int":167}],286:[function(require,module,exports){ 'use strict'; var LIBRARY = require('./_library'); var global = require('./_global'); @@ -10641,7 +10529,7 @@ $export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(functi } }); -},{"./_a-function":94,"./_an-instance":98,"./_classof":108,"./_core":113,"./_ctx":115,"./_export":123,"./_for-of":129,"./_global":131,"./_is-object":142,"./_iter-detect":147,"./_library":150,"./_microtask":156,"./_new-promise-capability":157,"./_perform":175,"./_promise-resolve":176,"./_redefine-all":178,"./_set-species":184,"./_set-to-string-tag":185,"./_species-constructor":188,"./_task":197,"./_user-agent":209,"./_wks":213}],294:[function(require,module,exports){ +},{"./_a-function":87,"./_an-instance":91,"./_classof":101,"./_core":106,"./_ctx":108,"./_export":116,"./_for-of":122,"./_global":124,"./_is-object":135,"./_iter-detect":140,"./_library":143,"./_microtask":149,"./_new-promise-capability":150,"./_perform":168,"./_promise-resolve":169,"./_redefine-all":171,"./_set-species":177,"./_set-to-string-tag":178,"./_species-constructor":181,"./_task":190,"./_user-agent":202,"./_wks":206}],287:[function(require,module,exports){ // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) var $export = require('./_export'); var aFunction = require('./_a-function'); @@ -10659,7 +10547,7 @@ $export($export.S + $export.F * !require('./_fails')(function () { } }); -},{"./_a-function":94,"./_an-object":99,"./_export":123,"./_fails":125,"./_global":131}],295:[function(require,module,exports){ +},{"./_a-function":87,"./_an-object":92,"./_export":116,"./_fails":118,"./_global":124}],288:[function(require,module,exports){ // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) var $export = require('./_export'); var create = require('./_object-create'); @@ -10708,7 +10596,7 @@ $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { } }); -},{"./_a-function":94,"./_an-object":99,"./_bind":107,"./_export":123,"./_fails":125,"./_global":131,"./_is-object":142,"./_object-create":159}],296:[function(require,module,exports){ +},{"./_a-function":87,"./_an-object":92,"./_bind":100,"./_export":116,"./_fails":118,"./_global":124,"./_is-object":135,"./_object-create":152}],289:[function(require,module,exports){ // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) var dP = require('./_object-dp'); var $export = require('./_export'); @@ -10733,7 +10621,7 @@ $export($export.S + $export.F * require('./_fails')(function () { } }); -},{"./_an-object":99,"./_export":123,"./_fails":125,"./_object-dp":160,"./_to-primitive":204}],297:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_fails":118,"./_object-dp":153,"./_to-primitive":197}],290:[function(require,module,exports){ // 26.1.4 Reflect.deleteProperty(target, propertyKey) var $export = require('./_export'); var gOPD = require('./_object-gopd').f; @@ -10746,7 +10634,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123,"./_object-gopd":162}],298:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_object-gopd":155}],291:[function(require,module,exports){ 'use strict'; // 26.1.5 Reflect.enumerate(target) var $export = require('./_export'); @@ -10774,7 +10662,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123,"./_iter-create":145}],299:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_iter-create":138}],292:[function(require,module,exports){ // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) var gOPD = require('./_object-gopd'); var $export = require('./_export'); @@ -10786,7 +10674,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123,"./_object-gopd":162}],300:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_object-gopd":155}],293:[function(require,module,exports){ // 26.1.8 Reflect.getPrototypeOf(target) var $export = require('./_export'); var getProto = require('./_object-gpo'); @@ -10798,7 +10686,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123,"./_object-gpo":166}],301:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_object-gpo":159}],294:[function(require,module,exports){ // 26.1.6 Reflect.get(target, propertyKey [, receiver]) var gOPD = require('./_object-gopd'); var getPrototypeOf = require('./_object-gpo'); @@ -10821,7 +10709,7 @@ function get(target, propertyKey /* , receiver */) { $export($export.S, 'Reflect', { get: get }); -},{"./_an-object":99,"./_export":123,"./_has":132,"./_is-object":142,"./_object-gopd":162,"./_object-gpo":166}],302:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_has":125,"./_is-object":135,"./_object-gopd":155,"./_object-gpo":159}],295:[function(require,module,exports){ // 26.1.9 Reflect.has(target, propertyKey) var $export = require('./_export'); @@ -10831,7 +10719,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_export":123}],303:[function(require,module,exports){ +},{"./_export":116}],296:[function(require,module,exports){ // 26.1.10 Reflect.isExtensible(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10844,13 +10732,13 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123}],304:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116}],297:[function(require,module,exports){ // 26.1.11 Reflect.ownKeys(target) var $export = require('./_export'); $export($export.S, 'Reflect', { ownKeys: require('./_own-keys') }); -},{"./_export":123,"./_own-keys":172}],305:[function(require,module,exports){ +},{"./_export":116,"./_own-keys":165}],298:[function(require,module,exports){ // 26.1.12 Reflect.preventExtensions(target) var $export = require('./_export'); var anObject = require('./_an-object'); @@ -10868,7 +10756,7 @@ $export($export.S, 'Reflect', { } }); -},{"./_an-object":99,"./_export":123}],306:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116}],299:[function(require,module,exports){ // 26.1.14 Reflect.setPrototypeOf(target, proto) var $export = require('./_export'); var setProto = require('./_set-proto'); @@ -10885,7 +10773,7 @@ if (setProto) $export($export.S, 'Reflect', { } }); -},{"./_export":123,"./_set-proto":183}],307:[function(require,module,exports){ +},{"./_export":116,"./_set-proto":176}],300:[function(require,module,exports){ // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) var dP = require('./_object-dp'); var gOPD = require('./_object-gopd'); @@ -10920,7 +10808,7 @@ function set(target, propertyKey, V /* , receiver */) { $export($export.S, 'Reflect', { set: set }); -},{"./_an-object":99,"./_export":123,"./_has":132,"./_is-object":142,"./_object-dp":160,"./_object-gopd":162,"./_object-gpo":166,"./_property-desc":177}],308:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_has":125,"./_is-object":135,"./_object-dp":153,"./_object-gopd":155,"./_object-gpo":159,"./_property-desc":170}],301:[function(require,module,exports){ var global = require('./_global'); var inheritIfRequired = require('./_inherit-if-required'); var dP = require('./_object-dp').f; @@ -10965,7 +10853,7 @@ if (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function ( require('./_set-species')('RegExp'); -},{"./_descriptors":119,"./_fails":125,"./_flags":127,"./_global":131,"./_inherit-if-required":136,"./_is-regexp":143,"./_object-dp":160,"./_object-gopn":164,"./_redefine":179,"./_set-species":184,"./_wks":213}],309:[function(require,module,exports){ +},{"./_descriptors":112,"./_fails":118,"./_flags":120,"./_global":124,"./_inherit-if-required":129,"./_is-regexp":136,"./_object-dp":153,"./_object-gopn":157,"./_redefine":172,"./_set-species":177,"./_wks":206}],302:[function(require,module,exports){ 'use strict'; var regexpExec = require('./_regexp-exec'); require('./_export')({ @@ -10976,14 +10864,14 @@ require('./_export')({ exec: regexpExec }); -},{"./_export":123,"./_regexp-exec":181}],310:[function(require,module,exports){ +},{"./_export":116,"./_regexp-exec":174}],303:[function(require,module,exports){ // 21.2.5.3 get RegExp.prototype.flags() if (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', { configurable: true, get: require('./_flags') }); -},{"./_descriptors":119,"./_flags":127,"./_object-dp":160}],311:[function(require,module,exports){ +},{"./_descriptors":112,"./_flags":120,"./_object-dp":153}],304:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11025,7 +10913,7 @@ require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCall ]; }); -},{"./_advance-string-index":97,"./_an-object":99,"./_fix-re-wks":126,"./_regexp-exec-abstract":180,"./_to-length":202}],312:[function(require,module,exports){ +},{"./_advance-string-index":90,"./_an-object":92,"./_fix-re-wks":119,"./_regexp-exec-abstract":173,"./_to-length":195}],305:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11145,7 +11033,7 @@ require('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, may } }); -},{"./_advance-string-index":97,"./_an-object":99,"./_fix-re-wks":126,"./_regexp-exec-abstract":180,"./_to-integer":200,"./_to-length":202,"./_to-object":203}],313:[function(require,module,exports){ +},{"./_advance-string-index":90,"./_an-object":92,"./_fix-re-wks":119,"./_regexp-exec-abstract":173,"./_to-integer":193,"./_to-length":195,"./_to-object":196}],306:[function(require,module,exports){ 'use strict'; var anObject = require('./_an-object'); @@ -11178,7 +11066,7 @@ require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeC ]; }); -},{"./_an-object":99,"./_fix-re-wks":126,"./_regexp-exec-abstract":180,"./_same-value":182}],314:[function(require,module,exports){ +},{"./_an-object":92,"./_fix-re-wks":119,"./_regexp-exec-abstract":173,"./_same-value":175}],307:[function(require,module,exports){ 'use strict'; var isRegExp = require('./_is-regexp'); @@ -11314,7 +11202,7 @@ require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCall ]; }); -},{"./_advance-string-index":97,"./_an-object":99,"./_fails":125,"./_fix-re-wks":126,"./_is-regexp":143,"./_regexp-exec":181,"./_regexp-exec-abstract":180,"./_species-constructor":188,"./_to-length":202}],315:[function(require,module,exports){ +},{"./_advance-string-index":90,"./_an-object":92,"./_fails":118,"./_fix-re-wks":119,"./_is-regexp":136,"./_regexp-exec":174,"./_regexp-exec-abstract":173,"./_species-constructor":181,"./_to-length":195}],308:[function(require,module,exports){ 'use strict'; require('./es6.regexp.flags'); var anObject = require('./_an-object'); @@ -11341,7 +11229,7 @@ if (require('./_fails')(function () { return $toString.call({ source: 'a', flags }); } -},{"./_an-object":99,"./_descriptors":119,"./_fails":125,"./_flags":127,"./_redefine":179,"./es6.regexp.flags":310}],316:[function(require,module,exports){ +},{"./_an-object":92,"./_descriptors":112,"./_fails":118,"./_flags":120,"./_redefine":172,"./es6.regexp.flags":303}],309:[function(require,module,exports){ 'use strict'; var strong = require('./_collection-strong'); var validate = require('./_validate-collection'); @@ -11357,7 +11245,7 @@ module.exports = require('./_collection')(SET, function (get) { } }, strong); -},{"./_collection":112,"./_collection-strong":110,"./_validate-collection":210}],317:[function(require,module,exports){ +},{"./_collection":105,"./_collection-strong":103,"./_validate-collection":203}],310:[function(require,module,exports){ 'use strict'; // B.2.3.2 String.prototype.anchor(name) require('./_string-html')('anchor', function (createHTML) { @@ -11366,7 +11254,7 @@ require('./_string-html')('anchor', function (createHTML) { }; }); -},{"./_string-html":192}],318:[function(require,module,exports){ +},{"./_string-html":185}],311:[function(require,module,exports){ 'use strict'; // B.2.3.3 String.prototype.big() require('./_string-html')('big', function (createHTML) { @@ -11375,7 +11263,7 @@ require('./_string-html')('big', function (createHTML) { }; }); -},{"./_string-html":192}],319:[function(require,module,exports){ +},{"./_string-html":185}],312:[function(require,module,exports){ 'use strict'; // B.2.3.4 String.prototype.blink() require('./_string-html')('blink', function (createHTML) { @@ -11384,7 +11272,7 @@ require('./_string-html')('blink', function (createHTML) { }; }); -},{"./_string-html":192}],320:[function(require,module,exports){ +},{"./_string-html":185}],313:[function(require,module,exports){ 'use strict'; // B.2.3.5 String.prototype.bold() require('./_string-html')('bold', function (createHTML) { @@ -11393,7 +11281,7 @@ require('./_string-html')('bold', function (createHTML) { }; }); -},{"./_string-html":192}],321:[function(require,module,exports){ +},{"./_string-html":185}],314:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $at = require('./_string-at')(false); @@ -11404,7 +11292,7 @@ $export($export.P, 'String', { } }); -},{"./_export":123,"./_string-at":190}],322:[function(require,module,exports){ +},{"./_export":116,"./_string-at":183}],315:[function(require,module,exports){ // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) 'use strict'; var $export = require('./_export'); @@ -11426,7 +11314,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'Strin } }); -},{"./_export":123,"./_fails-is-regexp":124,"./_string-context":191,"./_to-length":202}],323:[function(require,module,exports){ +},{"./_export":116,"./_fails-is-regexp":117,"./_string-context":184,"./_to-length":195}],316:[function(require,module,exports){ 'use strict'; // B.2.3.6 String.prototype.fixed() require('./_string-html')('fixed', function (createHTML) { @@ -11435,7 +11323,7 @@ require('./_string-html')('fixed', function (createHTML) { }; }); -},{"./_string-html":192}],324:[function(require,module,exports){ +},{"./_string-html":185}],317:[function(require,module,exports){ 'use strict'; // B.2.3.7 String.prototype.fontcolor(color) require('./_string-html')('fontcolor', function (createHTML) { @@ -11444,7 +11332,7 @@ require('./_string-html')('fontcolor', function (createHTML) { }; }); -},{"./_string-html":192}],325:[function(require,module,exports){ +},{"./_string-html":185}],318:[function(require,module,exports){ 'use strict'; // B.2.3.8 String.prototype.fontsize(size) require('./_string-html')('fontsize', function (createHTML) { @@ -11453,7 +11341,7 @@ require('./_string-html')('fontsize', function (createHTML) { }; }); -},{"./_string-html":192}],326:[function(require,module,exports){ +},{"./_string-html":185}],319:[function(require,module,exports){ var $export = require('./_export'); var toAbsoluteIndex = require('./_to-absolute-index'); var fromCharCode = String.fromCharCode; @@ -11478,7 +11366,7 @@ $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1) } }); -},{"./_export":123,"./_to-absolute-index":198}],327:[function(require,module,exports){ +},{"./_export":116,"./_to-absolute-index":191}],320:[function(require,module,exports){ // 21.1.3.7 String.prototype.includes(searchString, position = 0) 'use strict'; var $export = require('./_export'); @@ -11492,7 +11380,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String } }); -},{"./_export":123,"./_fails-is-regexp":124,"./_string-context":191}],328:[function(require,module,exports){ +},{"./_export":116,"./_fails-is-regexp":117,"./_string-context":184}],321:[function(require,module,exports){ 'use strict'; // B.2.3.9 String.prototype.italics() require('./_string-html')('italics', function (createHTML) { @@ -11501,7 +11389,7 @@ require('./_string-html')('italics', function (createHTML) { }; }); -},{"./_string-html":192}],329:[function(require,module,exports){ +},{"./_string-html":185}],322:[function(require,module,exports){ 'use strict'; var $at = require('./_string-at')(true); @@ -11520,7 +11408,7 @@ require('./_iter-define')(String, 'String', function (iterated) { return { value: point, done: false }; }); -},{"./_iter-define":146,"./_string-at":190}],330:[function(require,module,exports){ +},{"./_iter-define":139,"./_string-at":183}],323:[function(require,module,exports){ 'use strict'; // B.2.3.10 String.prototype.link(url) require('./_string-html')('link', function (createHTML) { @@ -11529,7 +11417,7 @@ require('./_string-html')('link', function (createHTML) { }; }); -},{"./_string-html":192}],331:[function(require,module,exports){ +},{"./_string-html":185}],324:[function(require,module,exports){ var $export = require('./_export'); var toIObject = require('./_to-iobject'); var toLength = require('./_to-length'); @@ -11549,7 +11437,7 @@ $export($export.S, 'String', { } }); -},{"./_export":123,"./_to-iobject":201,"./_to-length":202}],332:[function(require,module,exports){ +},{"./_export":116,"./_to-iobject":194,"./_to-length":195}],325:[function(require,module,exports){ var $export = require('./_export'); $export($export.P, 'String', { @@ -11557,7 +11445,7 @@ $export($export.P, 'String', { repeat: require('./_string-repeat') }); -},{"./_export":123,"./_string-repeat":194}],333:[function(require,module,exports){ +},{"./_export":116,"./_string-repeat":187}],326:[function(require,module,exports){ 'use strict'; // B.2.3.11 String.prototype.small() require('./_string-html')('small', function (createHTML) { @@ -11566,7 +11454,7 @@ require('./_string-html')('small', function (createHTML) { }; }); -},{"./_string-html":192}],334:[function(require,module,exports){ +},{"./_string-html":185}],327:[function(require,module,exports){ // 21.1.3.18 String.prototype.startsWith(searchString [, position ]) 'use strict'; var $export = require('./_export'); @@ -11586,7 +11474,7 @@ $export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'Str } }); -},{"./_export":123,"./_fails-is-regexp":124,"./_string-context":191,"./_to-length":202}],335:[function(require,module,exports){ +},{"./_export":116,"./_fails-is-regexp":117,"./_string-context":184,"./_to-length":195}],328:[function(require,module,exports){ 'use strict'; // B.2.3.12 String.prototype.strike() require('./_string-html')('strike', function (createHTML) { @@ -11595,7 +11483,7 @@ require('./_string-html')('strike', function (createHTML) { }; }); -},{"./_string-html":192}],336:[function(require,module,exports){ +},{"./_string-html":185}],329:[function(require,module,exports){ 'use strict'; // B.2.3.13 String.prototype.sub() require('./_string-html')('sub', function (createHTML) { @@ -11604,7 +11492,7 @@ require('./_string-html')('sub', function (createHTML) { }; }); -},{"./_string-html":192}],337:[function(require,module,exports){ +},{"./_string-html":185}],330:[function(require,module,exports){ 'use strict'; // B.2.3.14 String.prototype.sup() require('./_string-html')('sup', function (createHTML) { @@ -11613,7 +11501,7 @@ require('./_string-html')('sup', function (createHTML) { }; }); -},{"./_string-html":192}],338:[function(require,module,exports){ +},{"./_string-html":185}],331:[function(require,module,exports){ 'use strict'; // 21.1.3.25 String.prototype.trim() require('./_string-trim')('trim', function ($trim) { @@ -11622,7 +11510,7 @@ require('./_string-trim')('trim', function ($trim) { }; }); -},{"./_string-trim":195}],339:[function(require,module,exports){ +},{"./_string-trim":188}],332:[function(require,module,exports){ 'use strict'; // ECMAScript 6 symbols shim var global = require('./_global'); @@ -11870,7 +11758,7 @@ setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] setToStringTag(global.JSON, 'JSON', true); -},{"./_an-object":99,"./_descriptors":119,"./_enum-keys":122,"./_export":123,"./_fails":125,"./_global":131,"./_has":132,"./_hide":133,"./_is-array":140,"./_is-object":142,"./_library":150,"./_meta":155,"./_object-create":159,"./_object-dp":160,"./_object-gopd":162,"./_object-gopn":164,"./_object-gopn-ext":163,"./_object-gops":165,"./_object-keys":168,"./_object-pie":169,"./_property-desc":177,"./_redefine":179,"./_set-to-string-tag":185,"./_shared":187,"./_to-iobject":201,"./_to-object":203,"./_to-primitive":204,"./_uid":208,"./_wks":213,"./_wks-define":211,"./_wks-ext":212}],340:[function(require,module,exports){ +},{"./_an-object":92,"./_descriptors":112,"./_enum-keys":115,"./_export":116,"./_fails":118,"./_global":124,"./_has":125,"./_hide":126,"./_is-array":133,"./_is-object":135,"./_library":143,"./_meta":148,"./_object-create":152,"./_object-dp":153,"./_object-gopd":155,"./_object-gopn":157,"./_object-gopn-ext":156,"./_object-gops":158,"./_object-keys":161,"./_object-pie":162,"./_property-desc":170,"./_redefine":172,"./_set-to-string-tag":178,"./_shared":180,"./_to-iobject":194,"./_to-object":196,"./_to-primitive":197,"./_uid":201,"./_wks":206,"./_wks-define":204,"./_wks-ext":205}],333:[function(require,module,exports){ 'use strict'; var $export = require('./_export'); var $typed = require('./_typed'); @@ -11918,76 +11806,76 @@ $export($export.P + $export.U + $export.F * require('./_fails')(function () { require('./_set-species')(ARRAY_BUFFER); -},{"./_an-object":99,"./_export":123,"./_fails":125,"./_global":131,"./_is-object":142,"./_set-species":184,"./_species-constructor":188,"./_to-absolute-index":198,"./_to-length":202,"./_typed":207,"./_typed-buffer":206}],341:[function(require,module,exports){ +},{"./_an-object":92,"./_export":116,"./_fails":118,"./_global":124,"./_is-object":135,"./_set-species":177,"./_species-constructor":181,"./_to-absolute-index":191,"./_to-length":195,"./_typed":200,"./_typed-buffer":199}],334:[function(require,module,exports){ var $export = require('./_export'); $export($export.G + $export.W + $export.F * !require('./_typed').ABV, { DataView: require('./_typed-buffer').DataView }); -},{"./_export":123,"./_typed":207,"./_typed-buffer":206}],342:[function(require,module,exports){ +},{"./_export":116,"./_typed":200,"./_typed-buffer":199}],335:[function(require,module,exports){ require('./_typed-array')('Float32', 4, function (init) { return function Float32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],343:[function(require,module,exports){ +},{"./_typed-array":198}],336:[function(require,module,exports){ require('./_typed-array')('Float64', 8, function (init) { return function Float64Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],344:[function(require,module,exports){ +},{"./_typed-array":198}],337:[function(require,module,exports){ require('./_typed-array')('Int16', 2, function (init) { return function Int16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],345:[function(require,module,exports){ +},{"./_typed-array":198}],338:[function(require,module,exports){ require('./_typed-array')('Int32', 4, function (init) { return function Int32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],346:[function(require,module,exports){ +},{"./_typed-array":198}],339:[function(require,module,exports){ require('./_typed-array')('Int8', 1, function (init) { return function Int8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],347:[function(require,module,exports){ +},{"./_typed-array":198}],340:[function(require,module,exports){ require('./_typed-array')('Uint16', 2, function (init) { return function Uint16Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],348:[function(require,module,exports){ +},{"./_typed-array":198}],341:[function(require,module,exports){ require('./_typed-array')('Uint32', 4, function (init) { return function Uint32Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],349:[function(require,module,exports){ +},{"./_typed-array":198}],342:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8Array(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }); -},{"./_typed-array":205}],350:[function(require,module,exports){ +},{"./_typed-array":198}],343:[function(require,module,exports){ require('./_typed-array')('Uint8', 1, function (init) { return function Uint8ClampedArray(data, byteOffset, length) { return init(this, data, byteOffset, length); }; }, true); -},{"./_typed-array":205}],351:[function(require,module,exports){ +},{"./_typed-array":198}],344:[function(require,module,exports){ 'use strict'; var global = require('./_global'); var each = require('./_array-methods')(0); @@ -12049,7 +11937,7 @@ if (NATIVE_WEAK_MAP && IS_IE11) { }); } -},{"./_array-methods":103,"./_collection":112,"./_collection-weak":111,"./_global":131,"./_is-object":142,"./_meta":155,"./_object-assign":158,"./_redefine":179,"./_validate-collection":210}],352:[function(require,module,exports){ +},{"./_array-methods":96,"./_collection":105,"./_collection-weak":104,"./_global":124,"./_is-object":135,"./_meta":148,"./_object-assign":151,"./_redefine":172,"./_validate-collection":203}],345:[function(require,module,exports){ 'use strict'; var weak = require('./_collection-weak'); var validate = require('./_validate-collection'); @@ -12065,7 +11953,7 @@ require('./_collection')(WEAK_SET, function (get) { } }, weak, false, true); -},{"./_collection":112,"./_collection-weak":111,"./_validate-collection":210}],353:[function(require,module,exports){ +},{"./_collection":105,"./_collection-weak":104,"./_validate-collection":203}],346:[function(require,module,exports){ 'use strict'; // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap var $export = require('./_export'); @@ -12089,7 +11977,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('flatMap'); -},{"./_a-function":94,"./_add-to-unscopables":96,"./_array-species-create":106,"./_export":123,"./_flatten-into-array":128,"./_to-length":202,"./_to-object":203}],354:[function(require,module,exports){ +},{"./_a-function":87,"./_add-to-unscopables":89,"./_array-species-create":99,"./_export":116,"./_flatten-into-array":121,"./_to-length":195,"./_to-object":196}],347:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/Array.prototype.includes var $export = require('./_export'); @@ -12103,7 +11991,7 @@ $export($export.P, 'Array', { require('./_add-to-unscopables')('includes'); -},{"./_add-to-unscopables":96,"./_array-includes":102,"./_export":123}],355:[function(require,module,exports){ +},{"./_add-to-unscopables":89,"./_array-includes":95,"./_export":116}],348:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $entries = require('./_object-to-array')(true); @@ -12114,7 +12002,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":123,"./_object-to-array":171}],356:[function(require,module,exports){ +},{"./_export":116,"./_object-to-array":164}],349:[function(require,module,exports){ // https://github.com/tc39/proposal-object-getownpropertydescriptors var $export = require('./_export'); var ownKeys = require('./_own-keys'); @@ -12138,7 +12026,7 @@ $export($export.S, 'Object', { } }); -},{"./_create-property":114,"./_export":123,"./_object-gopd":162,"./_own-keys":172,"./_to-iobject":201}],357:[function(require,module,exports){ +},{"./_create-property":107,"./_export":116,"./_object-gopd":155,"./_own-keys":165,"./_to-iobject":194}],350:[function(require,module,exports){ // https://github.com/tc39/proposal-object-values-entries var $export = require('./_export'); var $values = require('./_object-to-array')(false); @@ -12149,7 +12037,7 @@ $export($export.S, 'Object', { } }); -},{"./_export":123,"./_object-to-array":171}],358:[function(require,module,exports){ +},{"./_export":116,"./_object-to-array":164}],351:[function(require,module,exports){ // https://github.com/tc39/proposal-promise-finally 'use strict'; var $export = require('./_export'); @@ -12171,7 +12059,7 @@ $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { ); } }); -},{"./_core":113,"./_export":123,"./_global":131,"./_promise-resolve":176,"./_species-constructor":188}],359:[function(require,module,exports){ +},{"./_core":106,"./_export":116,"./_global":124,"./_promise-resolve":169,"./_species-constructor":181}],352:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -12187,7 +12075,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":123,"./_string-pad":193,"./_user-agent":209}],360:[function(require,module,exports){ +},{"./_export":116,"./_string-pad":186,"./_user-agent":202}],353:[function(require,module,exports){ 'use strict'; // https://github.com/tc39/proposal-string-pad-start-end var $export = require('./_export'); @@ -12203,7 +12091,7 @@ $export($export.P + $export.F * WEBKIT_BUG, 'String', { } }); -},{"./_export":123,"./_string-pad":193,"./_user-agent":209}],361:[function(require,module,exports){ +},{"./_export":116,"./_string-pad":186,"./_user-agent":202}],354:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimLeft', function ($trim) { @@ -12212,7 +12100,7 @@ require('./_string-trim')('trimLeft', function ($trim) { }; }, 'trimStart'); -},{"./_string-trim":195}],362:[function(require,module,exports){ +},{"./_string-trim":188}],355:[function(require,module,exports){ 'use strict'; // https://github.com/sebmarkbage/ecmascript-string-left-right-trim require('./_string-trim')('trimRight', function ($trim) { @@ -12221,10 +12109,10 @@ require('./_string-trim')('trimRight', function ($trim) { }; }, 'trimEnd'); -},{"./_string-trim":195}],363:[function(require,module,exports){ +},{"./_string-trim":188}],356:[function(require,module,exports){ require('./_wks-define')('asyncIterator'); -},{"./_wks-define":211}],364:[function(require,module,exports){ +},{"./_wks-define":204}],357:[function(require,module,exports){ var $iterators = require('./es6.array.iterator'); var getKeys = require('./_object-keys'); var redefine = require('./_redefine'); @@ -12284,7 +12172,7 @@ for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++ } } -},{"./_global":131,"./_hide":133,"./_iterators":149,"./_object-keys":168,"./_redefine":179,"./_wks":213,"./es6.array.iterator":225}],365:[function(require,module,exports){ +},{"./_global":124,"./_hide":126,"./_iterators":142,"./_object-keys":161,"./_redefine":172,"./_wks":206,"./es6.array.iterator":218}],358:[function(require,module,exports){ var $export = require('./_export'); var $task = require('./_task'); $export($export.G + $export.B, { @@ -12292,7 +12180,7 @@ $export($export.G + $export.B, { clearImmediate: $task.clear }); -},{"./_export":123,"./_task":197}],366:[function(require,module,exports){ +},{"./_export":116,"./_task":190}],359:[function(require,module,exports){ // ie9- setTimeout & setInterval additional parameters fix var global = require('./_global'); var $export = require('./_export'); @@ -12314,10625 +12202,10391 @@ $export($export.G + $export.B + $export.F * MSIE, { setInterval: wrap(global.setInterval) }); -},{"./_export":123,"./_global":131,"./_user-agent":209}],367:[function(require,module,exports){ +},{"./_export":116,"./_global":124,"./_user-agent":202}],360:[function(require,module,exports){ require('../modules/web.timers'); require('../modules/web.immediate'); require('../modules/web.dom.iterable'); module.exports = require('../modules/_core'); -},{"../modules/_core":113,"../modules/web.dom.iterable":364,"../modules/web.immediate":365,"../modules/web.timers":366}],368:[function(require,module,exports){ -'use strict'; - -var assign = require('object.assign'); -var callBound = require('call-bind/callBound'); -var flags = require('regexp.prototype.flags'); -var GetIntrinsic = require('get-intrinsic'); -var getIterator = require('es-get-iterator'); -var getSideChannel = require('side-channel'); -var is = require('object-is'); -var isArguments = require('is-arguments'); -var isArray = require('isarray'); -var isArrayBuffer = require('is-array-buffer'); -var isDate = require('is-date-object'); -var isRegex = require('is-regex'); -var isSharedArrayBuffer = require('is-shared-array-buffer'); -var objectKeys = require('object-keys'); -var whichBoxedPrimitive = require('which-boxed-primitive'); -var whichCollection = require('which-collection'); -var whichTypedArray = require('which-typed-array'); -var byteLength = require('array-buffer-byte-length'); - -var sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); - -var $getTime = callBound('Date.prototype.getTime'); -var gPO = Object.getPrototypeOf; -var $objToString = callBound('Object.prototype.toString'); +},{"../modules/_core":106,"../modules/web.dom.iterable":357,"../modules/web.immediate":358,"../modules/web.timers":359}],361:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-env browser */ -var $Set = GetIntrinsic('%Set%', true); -var $mapHas = callBound('Map.prototype.has', true); -var $mapGet = callBound('Map.prototype.get', true); -var $mapSize = callBound('Map.prototype.size', true); -var $setAdd = callBound('Set.prototype.add', true); -var $setDelete = callBound('Set.prototype.delete', true); -var $setHas = callBound('Set.prototype.has', true); -var $setSize = callBound('Set.prototype.size', true); +/** + * This is the web browser implementation of `debug()`. + */ -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414 -function setHasEqualElement(set, val1, opts, channel) { - var i = getIterator(set); - var result; - while ((result = i.next()) && !result.done) { - if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define - // Remove the matching element to make sure we do not check that again. - $setDelete(set, result.value); - return true; - } - } +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; - return false; -} + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439 -function findLooseMatchingPrimitives(prim) { - if (typeof prim === 'undefined') { - return null; - } - if (typeof prim === 'object') { // Only pass in null as object! - return void 0; - } - if (typeof prim === 'symbol') { - return false; - } - if (typeof prim === 'string' || typeof prim === 'number') { - // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN. - return +prim === +prim; // eslint-disable-line no-implicit-coercion - } - return true; -} +/** + * Colors. + */ -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460 -function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) { - var altValue = findLooseMatchingPrimitives(prim); - if (altValue != null) { - return altValue; - } - var curB = $mapGet(b, altValue); - var looseOpts = assign({}, opts, { strict: false }); - if ( - (typeof curB === 'undefined' && !$mapHas(b, altValue)) - // eslint-disable-next-line no-use-before-define - || !internalDeepEqual(item, curB, looseOpts, channel) - ) { - return false; - } - // eslint-disable-next-line no-use-before-define - return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel); -} +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447 -function setMightHaveLoosePrim(a, b, prim) { - var altValue = findLooseMatchingPrimitives(prim); - if (altValue != null) { - return altValue; - } +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ - return $setHas(b, altValue) && !$setHas(a, altValue); -} +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } -// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533 -function mapHasEqualEntry(set, map, key1, item1, opts, channel) { - var i = getIterator(set); - var result; - var key2; - while ((result = i.next()) && !result.done) { - key2 = result.value; - if ( - // eslint-disable-next-line no-use-before-define - internalDeepEqual(key1, key2, opts, channel) - // eslint-disable-next-line no-use-before-define - && internalDeepEqual(item1, $mapGet(map, key2), opts, channel) - ) { - $setDelete(set, key2); - return true; - } - } + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } - return false; + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } -function internalDeepEqual(actual, expected, options, channel) { - var opts = options || {}; - - // 7.1. All identical values are equivalent, as determined by ===. - if (opts.strict ? is(actual, expected) : actual === expected) { - return true; - } +/** + * Colorize log arguments if enabled. + * + * @api public + */ - var actualBoxed = whichBoxedPrimitive(actual); - var expectedBoxed = whichBoxedPrimitive(expected); - if (actualBoxed !== expectedBoxed) { - return false; - } +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); - // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==. - if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) { - return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq - } + if (!this.useColors) { + return; + } - /* - * 7.4. 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. - */ - // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); - var hasActual = channel.has(actual); - var hasExpected = channel.has(expected); - var sentinel; - if (hasActual && hasExpected) { - if (channel.get(actual) === channel.get(expected)) { - return true; - } - } else { - sentinel = {}; - } - if (!hasActual) { channel.set(actual, sentinel); } - if (!hasExpected) { channel.set(expected, sentinel); } + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); - // eslint-disable-next-line no-use-before-define - return objEquiv(actual, expected, opts, channel); + args.splice(lastC, 0, c); } -function isBuffer(x) { - if (!x || typeof x !== 'object' || typeof x.length !== 'number') { - return false; - } - if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { - return false; - } - if (x.length > 0 && typeof x[0] !== 'number') { - return false; - } +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); - return !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x)); +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } -function setEquiv(a, b, opts, channel) { - if ($setSize(a) !== $setSize(b)) { - return false; - } - var iA = getIterator(a); - var iB = getIterator(b); - var resultA; - var resultB; - var set; - while ((resultA = iA.next()) && !resultA.done) { - if (resultA.value && typeof resultA.value === 'object') { - if (!set) { set = new $Set(); } - $setAdd(set, resultA.value); - } else if (!$setHas(b, resultA.value)) { - if (opts.strict) { return false; } - if (!setMightHaveLoosePrim(a, b, resultA.value)) { - return false; - } - if (!set) { set = new $Set(); } - $setAdd(set, resultA.value); - } - } - if (set) { - while ((resultB = iB.next()) && !resultB.done) { - // We have to check if a primitive value is already matching and only if it's not, go hunting for it. - if (resultB.value && typeof resultB.value === 'object') { - if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) { - return false; - } - } else if ( - !opts.strict - && !$setHas(a, resultB.value) - && !setHasEqualElement(set, resultB.value, opts.strict, channel) - ) { - return false; - } - } - return $setSize(set) === 0; - } - return true; +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; } -function mapEquiv(a, b, opts, channel) { - if ($mapSize(a) !== $mapSize(b)) { - return false; - } - var iA = getIterator(a); - var iB = getIterator(b); - var resultA; - var resultB; - var set; - var key; - var item1; - var item2; - while ((resultA = iA.next()) && !resultA.done) { - key = resultA.value[0]; - item1 = resultA.value[1]; - if (key && typeof key === 'object') { - if (!set) { set = new $Set(); } - $setAdd(set, key); - } else { - item2 = $mapGet(b, key); - if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) { - if (opts.strict) { - return false; - } - if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) { - return false; - } - if (!set) { set = new $Set(); } - $setAdd(set, key); - } - } - } +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ - if (set) { - while ((resultB = iB.next()) && !resultB.done) { - key = resultB.value[0]; - item2 = resultB.value[1]; - if (key && typeof key === 'object') { - if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) { - return false; - } - } else if ( - !opts.strict - && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel)) - && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel) - ) { - return false; - } - } - return $setSize(set) === 0; - } - return true; +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } -function objEquiv(a, b, opts, channel) { - /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5], max-lines: [2, 400] */ - var i, key; +module.exports = require('./common')(exports); - if (typeof a !== typeof b) { return false; } - if (a == null || b == null) { return false; } +const {formatters} = module.exports; - if ($objToString(a) !== $objToString(b)) { return false; } +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ - if (isArguments(a) !== isArguments(b)) { return false; } +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } +}; - var aIsArray = isArray(a); - var bIsArray = isArray(b); - if (aIsArray !== bIsArray) { return false; } +}).call(this)}).call(this,require('_process')) +},{"./common":362,"_process":484}],362:[function(require,module,exports){ - // TODO: replace when a cross-realm brand check is available - var aIsError = a instanceof Error; - var bIsError = b instanceof Error; - if (aIsError !== bIsError) { return false; } - if (aIsError || bIsError) { - if (a.name !== b.name || a.message !== b.message) { return false; } - } +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - var aIsRegex = isRegex(a); - var bIsRegex = isRegex(b); - if (aIsRegex !== bIsRegex) { return false; } - if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) { - return false; - } +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + createDebug.destroy = destroy; - var aIsDate = isDate(a); - var bIsDate = isDate(b); - if (aIsDate !== bIsDate) { return false; } - if (aIsDate || bIsDate) { // && would work too, because both are true or both false here - if ($getTime(a) !== $getTime(b)) { return false; } - } - if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; } + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); - var aWhich = whichTypedArray(a); - var bWhich = whichTypedArray(b); - if (aWhich !== bWhich) { - return false; - } - if (aWhich || bWhich) { // && would work too, because both are true or both false here - if (a.length !== b.length) { return false; } - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { return false; } - } - return true; - } + /** + * The currently active debug mode names, and names to skip. + */ - var aIsBuffer = isBuffer(a); - var bIsBuffer = isBuffer(b); - if (aIsBuffer !== bIsBuffer) { return false; } - if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here - if (a.length !== b.length) { return false; } - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { return false; } - } - return true; - } + createDebug.names = []; + createDebug.skips = []; - var aIsArrayBuffer = isArrayBuffer(a); - var bIsArrayBuffer = isArrayBuffer(b); - if (aIsArrayBuffer !== bIsArrayBuffer) { return false; } - if (aIsArrayBuffer || bIsArrayBuffer) { // && would work too, because both are true or both false here - if (byteLength(a) !== byteLength(b)) { return false; } - return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); - } + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; - var aIsSAB = isSharedArrayBuffer(a); - var bIsSAB = isSharedArrayBuffer(b); - if (aIsSAB !== bIsSAB) { return false; } - if (aIsSAB || bIsSAB) { // && would work too, because both are true or both false here - if (sabByteLength(a) !== sabByteLength(b)) { return false; } - return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); - } + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; - if (typeof a !== typeof b) { return false; } + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } - var ka = objectKeys(a); - var kb = objectKeys(b); - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (ka.length !== kb.length) { return false; } + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; - // 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; } // eslint-disable-line eqeqeq - } - - // equivalent values for every corresponding key, and ~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; } - } + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; - var aCollection = whichCollection(a); - var bCollection = whichCollection(b); - if (aCollection !== bCollection) { - return false; - } - if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection - return setEquiv(a, b, opts, channel); - } - if (aCollection === 'Map') { // aCollection === bCollection - return mapEquiv(a, b, opts, channel); - } + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } - return true; -} + const self = debug; -module.exports = function deepEqual(a, b, opts) { - return internalDeepEqual(a, b, opts, getSideChannel()); -}; + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; -},{"array-buffer-byte-length":30,"call-bind/callBound":60,"es-get-iterator":419,"get-intrinsic":427,"is-arguments":455,"is-array-buffer":456,"is-date-object":460,"is-regex":464,"is-shared-array-buffer":466,"isarray":471,"object-is":490,"object-keys":494,"object.assign":497,"regexp.prototype.flags":506,"side-channel":515,"which-boxed-primitive":530,"which-collection":531,"which-typed-array":532}],369:[function(require,module,exports){ -'use strict'; + args[0] = createDebug.coerce(args[0]); -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) - && !isSpecial(value) -}; + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } -function isNonNullObject(value) { - return !!value && typeof value === 'object' -} + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); - return stringValue === '[object RegExp]' - || stringValue === '[object Date]' - || isReactElement(value) -} + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE -} + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. -function emptyTarget(val) { - return Array.isArray(val) ? [] : {} -} + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } -function cloneUnlessOtherwiseSpecified(value, options) { - return (options.clone !== false && options.isMergeableObject(value)) - ? deepmerge(emptyTarget(value), value, options) - : value -} + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options) - }) -} + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } -function getMergeFunction(key, options) { - if (!options.customMerge) { - return deepmerge + return debug; } - var customMerge = options.customMerge(key); - return typeof customMerge === 'function' ? customMerge : deepmerge -} - -function getEnumerableOwnPropertySymbols(target) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return Object.propertyIsEnumerable.call(target, symbol) - }) - : [] -} - -function getKeys(target) { - return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) -} -function propertyIsOnObject(object, property) { - try { - return property in object - } catch(_) { - return false + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; } -} -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { - return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. -} + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) { - getKeys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); - } - getKeys(source).forEach(function(key) { - if (propertyIsUnsafe(target, key)) { - return - } + createDebug.names = []; + createDebug.skips = []; - if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { - destination[key] = getMergeFunction(key, options)(target[key], source[key], options); - } else { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } - }); - return destination -} + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() - // implementations can use it. The caller may not replace it. - options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; + namespaces = split[i].replace(/\*/g, '.*?'); - if (!sourceAndTargetTypesMatch) { - return cloneUnlessOtherwiseSpecified(source, options) - } else if (sourceIsArray) { - return options.arrayMerge(target, source, options) - } else { - return mergeObject(target, source, options) + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } } -} -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) { - throw new Error('first argument should be an array') + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; } - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options) - }, {}) -}; - -var deepmerge_1 = deepmerge; - -module.exports = deepmerge_1; - -},{}],370:[function(require,module,exports){ -'use strict'; + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } -var $defineProperty = require('es-define-property'); + let i; + let len; -var $SyntaxError = require('es-errors/syntax'); -var $TypeError = require('es-errors/type'); + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } -var gopd = require('gopd'); + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } -/** @type {import('.')} */ -module.exports = function defineDataProperty( - obj, - property, - value -) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new $TypeError('`obj` must be an object or a function`'); - } - if (typeof property !== 'string' && typeof property !== 'symbol') { - throw new $TypeError('`property` must be a string or a symbol`'); - } - if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { - throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); - } - if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { - throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); - } - if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { - throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); - } - if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { - throw new $TypeError('`loose`, if provided, must be a boolean'); + return false; } - var nonEnumerable = arguments.length > 3 ? arguments[3] : null; - var nonWritable = arguments.length > 4 ? arguments[4] : null; - var nonConfigurable = arguments.length > 5 ? arguments[5] : null; - var loose = arguments.length > 6 ? arguments[6] : false; - - /* @type {false | TypedPropertyDescriptor} */ - var desc = !!gopd && gopd(obj, property); - - if ($defineProperty) { - $defineProperty(obj, property, { - configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, - enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, - value: value, - writable: nonWritable === null && desc ? desc.writable : !nonWritable - }); - } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { - // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable - obj[property] = value; // eslint-disable-line no-param-reassign - } else { - throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); } -}; - -},{"es-define-property":411,"es-errors/syntax":416,"es-errors/type":417,"gopd":432}],371:[function(require,module,exports){ -'use strict'; - -var keys = require('object-keys'); -var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; -var toStr = Object.prototype.toString; -var concat = Array.prototype.concat; -var defineDataProperty = require('define-data-property'); - -var isFunction = function (fn) { - return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; -}; - -var supportsDescriptors = require('has-property-descriptors')(); - -var defineProperty = function (object, name, value, predicate) { - if (name in object) { - if (predicate === true) { - if (object[name] === value) { - return; - } - } else if (!isFunction(predicate) || !predicate()) { - return; + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; } + return val; } - if (supportsDescriptors) { - defineDataProperty(object, name, value, true); - } else { - defineDataProperty(object, name, value); + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } -}; -var defineProperties = function (object, map) { - var predicates = arguments.length > 2 ? arguments[2] : {}; - var props = keys(map); - if (hasSymbols) { - props = concat.call(props, Object.getOwnPropertySymbols(map)); - } - for (var i = 0; i < props.length; i += 1) { - defineProperty(object, props[i], map[props[i]], predicates[props[i]]); - } -}; + createDebug.enable(createDebug.load()); -defineProperties.supportsDescriptors = !!supportsDescriptors; + return createDebug; +} -module.exports = defineProperties; +module.exports = setup; -},{"define-data-property":370,"has-property-descriptors":434,"object-keys":494}],372:[function(require,module,exports){ +},{"ms":468}],363:[function(require,module,exports){ 'use strict'; -var callBind = require('call-bind-apply-helpers'); -var gOPD = require('gopd'); +var assign = require('object.assign'); +var callBound = require('call-bind/callBound'); +var flags = require('regexp.prototype.flags'); +var GetIntrinsic = require('get-intrinsic'); +var getIterator = require('es-get-iterator'); +var getSideChannel = require('side-channel'); +var is = require('object-is'); +var isArguments = require('is-arguments'); +var isArray = require('isarray'); +var isArrayBuffer = require('is-array-buffer'); +var isDate = require('is-date-object'); +var isRegex = require('is-regex'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var objectKeys = require('object-keys'); +var whichBoxedPrimitive = require('which-boxed-primitive'); +var whichCollection = require('which-collection'); +var whichTypedArray = require('which-typed-array'); +var byteLength = require('array-buffer-byte-length'); -var hasProtoAccessor; -try { - // eslint-disable-next-line no-extra-parens, no-proto - hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype; -} catch (e) { - if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') { - throw e; - } -} +var sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); -// eslint-disable-next-line no-extra-parens -var desc = !!hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__')); +var $getTime = callBound('Date.prototype.getTime'); +var gPO = Object.getPrototypeOf; +var $objToString = callBound('Object.prototype.toString'); -var $Object = Object; -var $getPrototypeOf = $Object.getPrototypeOf; - -/** @type {import('./get')} */ -module.exports = desc && typeof desc.get === 'function' - ? callBind([desc.get]) - : typeof $getPrototypeOf === 'function' - ? /** @type {import('./get')} */ function getDunder(value) { - // eslint-disable-next-line eqeqeq - return $getPrototypeOf(value == null ? value : $Object(value)); - } - : false; +var $Set = GetIntrinsic('%Set%', true); +var $mapHas = callBound('Map.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSize = callBound('Map.prototype.size', true); +var $setAdd = callBound('Set.prototype.add', true); +var $setDelete = callBound('Set.prototype.delete', true); +var $setHas = callBound('Set.prototype.has', true); +var $setSize = callBound('Set.prototype.size', true); -},{"call-bind-apply-helpers":58,"gopd":432}],373:[function(require,module,exports){ -'use strict'; +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414 +function setHasEqualElement(set, val1, opts, channel) { + var i = getIterator(set); + var result; + while ((result = i.next()) && !result.done) { + if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define + // Remove the matching element to make sure we do not check that again. + $setDelete(set, result.value); + return true; + } + } -var elliptic = exports; + return false; +} -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'); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439 +function findLooseMatchingPrimitives(prim) { + if (typeof prim === 'undefined') { + return null; + } + if (typeof prim === 'object') { // Only pass in null as object! + return void 0; + } + if (typeof prim === 'symbol') { + return false; + } + if (typeof prim === 'string' || typeof prim === 'number') { + // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN. + return +prim === +prim; // eslint-disable-line no-implicit-coercion + } + return true; +} -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460 +function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } + var curB = $mapGet(b, altValue); + var looseOpts = assign({}, opts, { strict: false }); + if ( + (typeof curB === 'undefined' && !$mapHas(b, altValue)) + // eslint-disable-next-line no-use-before-define + || !internalDeepEqual(item, curB, looseOpts, channel) + ) { + return false; + } + // eslint-disable-next-line no-use-before-define + return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel); +} -},{"../package.json":389,"./elliptic/curve":376,"./elliptic/curves":379,"./elliptic/ec":380,"./elliptic/eddsa":383,"./elliptic/utils":387,"brorand":51}],374:[function(require,module,exports){ -'use strict'; +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447 +function setMightHaveLoosePrim(a, b, prim) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } -var BN = require('bn.js'); -var utils = require('../utils'); -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; + return $setHas(b, altValue) && !$setHas(a, altValue); +} -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533 +function mapHasEqualEntry(set, map, key1, item1, opts, channel) { + var i = getIterator(set); + var result; + var key2; + while ((result = i.next()) && !result.done) { + key2 = result.value; + if ( + // eslint-disable-next-line no-use-before-define + internalDeepEqual(key1, key2, opts, channel) + // eslint-disable-next-line no-use-before-define + && internalDeepEqual(item1, $mapGet(map, key2), opts, channel) + ) { + $setDelete(set, key2); + return true; + } + } - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + return false; +} - // 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); +function internalDeepEqual(actual, expected, options, channel) { + var opts = options || {}; - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + // 7.1. All identical values are equivalent, as determined by ===. + if (opts.strict ? is(actual, expected) : actual === expected) { + return true; + } - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + var actualBoxed = whichBoxedPrimitive(actual); + var expectedBoxed = whichBoxedPrimitive(expected); + if (actualBoxed !== expectedBoxed) { + return false; + } - this._bitLength = this.n ? this.n.bitLength() : 0; + // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==. + if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) { + return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq + } - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; + /* + * 7.4. 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. + */ + // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration + + var hasActual = channel.has(actual); + var hasExpected = channel.has(expected); + var sentinel; + if (hasActual && hasExpected) { + if (channel.get(actual) === channel.get(expected)) { + return true; + } } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); + sentinel = {}; } -} -module.exports = BaseCurve; + if (!hasActual) { channel.set(actual, sentinel); } + if (!hasExpected) { channel.set(expected, sentinel); } -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; + // eslint-disable-next-line no-use-before-define + return objEquiv(actual, expected, opts, channel); +} -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; +function isBuffer(x) { + if (!x || typeof x !== 'object' || typeof x.length !== 'number') { + return false; + } + if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { + return false; + } + if (x.length > 0 && typeof x[0] !== 'number') { + return false; + } -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); + return !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x)); +} - var naf = getNAF(k, 1, this._bitLength); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; +function setEquiv(a, b, opts, channel) { + if ($setSize(a) !== $setSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + while ((resultA = iA.next()) && !resultA.done) { + if (resultA.value && typeof resultA.value === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } else if (!$setHas(b, resultA.value)) { + if (opts.strict) { return false; } + if (!setMightHaveLoosePrim(a, b, resultA.value)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } + } + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + // We have to check if a primitive value is already matching and only if it's not, go hunting for it. + if (resultB.value && typeof resultB.value === 'object') { + if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) { + return false; + } + } else if ( + !opts.strict + && !$setHas(a, resultB.value) + && !setHasEqualElement(set, resultB.value, opts.strict, channel) + ) { + return false; + } + } + return $setSize(set) === 0; + } + return true; +} - // 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); +function mapEquiv(a, b, opts, channel) { + if ($mapSize(a) !== $mapSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + var key; + var item1; + var item2; + while ((resultA = iA.next()) && !resultA.done) { + key = resultA.value[0]; + item1 = resultA.value[1]; + if (key && typeof key === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, key); + } else { + item2 = $mapGet(b, key); + if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) { + if (opts.strict) { + return false; + } + if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, key); + } + } } - 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()); + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + key = resultB.value[0]; + item2 = resultB.value[1]; + if (key && typeof key === 'object') { + if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) { + return false; + } + } else if ( + !opts.strict + && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel)) + && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel) + ) { + return false; + } } - a = a.add(b); + return $setSize(set) === 0; } - return a.toP(); -}; + return true; +} -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; +function objEquiv(a, b, opts, channel) { + /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5], max-lines: [2, 400] */ + var i, key; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + if (typeof a !== typeof b) { return false; } + if (a == null || b == null) { return false; } - // Get NAF form - var naf = getNAF(k, w, this._bitLength); + if ($objToString(a) !== $objToString(b)) { return false; } - // 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 (isArguments(a) !== isArguments(b)) { return false; } - 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()); - } + var aIsArray = isArray(a); + var bIsArray = isArray(b); + if (aIsArray !== bIsArray) { return false; } + + // TODO: replace when a cross-realm brand check is available + var aIsError = a instanceof Error; + var bIsError = b instanceof Error; + if (aIsError !== bIsError) { return false; } + if (aIsError || bIsError) { + if (a.name !== b.name || a.message !== b.message) { return false; } } - 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; + var aIsRegex = isRegex(a); + var bIsRegex = isRegex(b); + if (aIsRegex !== bIsRegex) { return false; } + if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) { + return false; + } - // 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; + var aIsDate = isDate(a); + var bIsDate = isDate(b); + if (aIsDate !== bIsDate) { return false; } + if (aIsDate || bIsDate) { // && would work too, because both are true or both false here + if ($getTime(a) !== $getTime(b)) { return false; } } + if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; } - // 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 aWhich = whichTypedArray(a); + var bWhich = whichTypedArray(b); + if (aWhich !== bWhich) { + return false; + } + if (aWhich || bWhich) { // && would work too, because both are true or both false here + if (a.length !== b.length) { return false; } + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } } + return true; + } - 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 aIsBuffer = isBuffer(a); + var bIsBuffer = isBuffer(b); + if (aIsBuffer !== bIsBuffer) { return false; } + if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here + if (a.length !== b.length) { return false; } + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } } + return true; + } - 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; + var aIsArrayBuffer = isArrayBuffer(a); + var bIsArrayBuffer = isArrayBuffer(b); + if (aIsArrayBuffer !== bIsArrayBuffer) { return false; } + if (aIsArrayBuffer || bIsArrayBuffer) { // && would work too, because both are true or both false here + if (byteLength(a) !== byteLength(b)) { return false; } + return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); + } - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } + var aIsSAB = isSharedArrayBuffer(a); + var bIsSAB = isSharedArrayBuffer(b); + if (aIsSAB !== bIsSAB) { return false; } + if (aIsSAB || bIsSAB) { // && would work too, because both are true or both false here + if (sabByteLength(a) !== sabByteLength(b)) { return false; } + return typeof Uint8Array === 'function' && internalDeepEqual(new Uint8Array(a), new Uint8Array(b), opts, channel); } - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (i = max; i >= 0; i--) { - var k = 0; + if (typeof a !== typeof b) { return false; } - 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; + var ka = objectKeys(a); + var kb = objectKeys(b); + // having the same number of owned properties (keys incorporates hasOwnProperty) + if (ka.length !== kb.length) { return false; } - 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(); + // 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; } // eslint-disable-line eqeqeq + } - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } + // equivalent values for every corresponding key, and ~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; } } - // Zeroify references - for (i = 0; i < len; i++) - wnd[i] = null; - if (jacobianResult) - return acc; - else - return acc.toP(); -}; + var aCollection = whichCollection(a); + var bCollection = whichCollection(b); + if (aCollection !== bCollection) { + return false; + } + if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection + return setEquiv(a, b, opts, channel); + } + if (aCollection === 'Map') { // aCollection === bCollection + return mapEquiv(a, b, opts, channel); + } -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; + return true; } -BaseCurve.BasePoint = BasePoint; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); +module.exports = function deepEqual(a, b, opts) { + return internalDeepEqual(a, b, opts, getSideChannel()); }; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +},{"array-buffer-byte-length":30,"call-bind/callBound":54,"es-get-iterator":412,"get-intrinsic":419,"is-arguments":444,"is-array-buffer":445,"is-date-object":449,"is-regex":453,"is-shared-array-buffer":455,"isarray":460,"object-is":471,"object-keys":475,"object.assign":478,"regexp.prototype.flags":487,"side-channel":492,"which-boxed-primitive":503,"which-collection":504,"which-typed-array":505}],364:[function(require,module,exports){ +'use strict'; + +var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) + && !isSpecial(value) }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +function isNonNullObject(value) { + return !!value && typeof value === 'object' +} - var len = this.p.byteLength(); +function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); - // 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); + return stringValue === '[object RegExp]' + || stringValue === '[object Date]' + || isReactElement(value) +} - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); +// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 +var canUseSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; - 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'); -}; +function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE +} -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; +function emptyTarget(val) { + return Array.isArray(val) ? [] : {} +} -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +function cloneUnlessOtherwiseSpecified(value, options) { + return (options.clone !== false && options.isMergeableObject(value)) + ? deepmerge(emptyTarget(value), value, options) + : value +} - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); +function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options) + }) +} - return [ 0x04 ].concat(x, this.getY().toArray('be', len)); -}; +function getMergeFunction(key, options) { + if (!options.customMerge) { + return deepmerge + } + var customMerge = options.customMerge(key); + return typeof customMerge === 'function' ? customMerge : deepmerge +} -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; +function getEnumerableOwnPropertySymbols(target) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(target).filter(function(symbol) { + return Object.propertyIsEnumerable.call(target, symbol) + }) + : [] +} -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; +function getKeys(target) { + return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) +} - 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; +function propertyIsOnObject(object, property) { + try { + return property in object + } catch(_) { + return false + } +} - return this; -}; +// Protects from prototype poisoning and unexpected merging up the prototype chain. +function propertyIsUnsafe(target, key) { + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, + && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, + && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. +} -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; +function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) { + getKeys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + } + getKeys(source).forEach(function(key) { + if (propertyIsUnsafe(target, key)) { + return + } - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { + destination[key] = getMergeFunction(key, options)(target[key], source[key], options); + } else { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + } + }); + return destination +} - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; +function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() + // implementations can use it. The caller may not replace it. + options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; - 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, - }; -}; + if (!sourceAndTargetTypesMatch) { + return cloneUnlessOtherwiseSpecified(source, options) + } else if (sourceIsArray) { + return options.arrayMerge(target, source, options) + } else { + return mergeObject(target, source, options) + } +} -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; +deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) { + throw new Error('first argument should be an array') + } - 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, - }; + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options) + }, {}) }; -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; +var deepmerge_1 = deepmerge; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +module.exports = deepmerge_1; -},{"../utils":387,"bn.js":388}],375:[function(require,module,exports){ +},{}],365:[function(require,module,exports){ 'use strict'; -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); +var $defineProperty = require('es-define-property'); -var assert = utils.assert; +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); -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; +var gopd = require('gopd'); - Base.call(this, 'edwards', conf); +/** @type {import('.')} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } - 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); + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); - else - return this.a.redMul(num); + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } }; -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); -}; +},{"es-define-property":404,"es-errors/syntax":409,"es-errors/type":410,"gopd":420}],366:[function(require,module,exports){ +'use strict'; -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); +var keys = require('object-keys'); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; + +var toStr = Object.prototype.toString; +var concat = Array.prototype.concat; +var defineDataProperty = require('define-data-property'); + +var isFunction = function (fn) { + return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; }; -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); +var supportsDescriptors = require('has-property-descriptors')(); - 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 defineProperty = function (object, name, value, predicate) { + if (name in object) { + if (predicate === true) { + if (object[name] === value) { + return; + } + } else if (!isFunction(predicate) || !predicate()) { + return; + } + } - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + if (supportsDescriptors) { + defineDataProperty(object, name, value, true); + } else { + defineDataProperty(object, name, value); + } +}; - return this.point(x, y); +var defineProperties = function (object, map) { + var predicates = arguments.length > 2 ? arguments[2] : {}; + var props = keys(map); + if (hasSymbols) { + props = concat.call(props, Object.getOwnPropertySymbols(map)); + } + for (var i = 0; i < props.length; i += 1) { + defineProperty(object, props[i], map[props[i]], predicates[props[i]]); + } }; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); +defineProperties.supportsDescriptors = !!supportsDescriptors; - // 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()); +module.exports = defineProperties; - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } +},{"define-data-property":365,"has-property-descriptors":422,"object-keys":475}],367:[function(require,module,exports){ +'use strict'; - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +var elliptic = exports; - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); +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'); - return this.point(x, y); -}; +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; +},{"../package.json":383,"./elliptic/curve":370,"./elliptic/curves":373,"./elliptic/ec":374,"./elliptic/eddsa":377,"./elliptic/utils":381,"brorand":51}],368:[function(require,module,exports){ +'use strict'; - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; - 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))); +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - return lhs.cmp(rhs) === 0; -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -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; + // 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); - // 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()); - } + // 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); } } -inherits(Point, Base.BasePoint); - -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; +module.exports = BaseCurve; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); -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)); -}; + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S + // 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); + } - // 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); + 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(); }; -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 +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; - // 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(); + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; - 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); + // 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 { - // 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); + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); } - } 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); + return p.type === 'affine' ? acc.toP() : acc; }; -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; - // 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); + // 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; } - return this.curve.point(nx, ny, nz); -}; -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; + // 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; + } - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; + // 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()); + } -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; + 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 */ + ]; -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + 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; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } - // 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; -}; + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; + 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; -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; + 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(); -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; + if (jacobianResult) + return acc; + else + return acc.toP(); }; -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; +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); }; -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; -},{"../utils":387,"./base":374,"bn.js":388,"inherits":453}],376:[function(require,module,exports){ -'use strict'; +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); -var curve = exports; + var len = this.p.byteLength(); -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + // 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); -},{"./base":374,"./edwards":375,"./mont":377,"./short":378}],377:[function(require,module,exports){ -'use strict'; + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + 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'); +}; -var utils = require('../utils'); +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; -function MontCurve(conf) { - Base.call(this, 'mont', conf); +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); - 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; + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); -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 [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; - return y.redSqr().cmp(rhs) === 0; +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); }; -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); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; + 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; -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); + return this; }; -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; -Point.prototype.precompute = function precompute() { - // No-op -}; + var doubles = this.precomputed.doubles; + if (!doubles) + return false; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; + 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, + }; }; -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A + 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, + }; +}; - // 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); +BasePoint.prototype._getBeta = function _getBeta() { + return null; }; -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; }; -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A +},{"../utils":381,"bn.js":382}],369:[function(require,module,exports){ +'use strict'; - // 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); -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -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 +var assert = utils.assert; - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); +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; - 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; -}; + Base.call(this, 'edwards', conf); -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); -}; + 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); -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); + 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); }; -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); }; -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); }; -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - return this.x.fromRed(); + 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); }; -},{"../utils":387,"./base":374,"bn.js":388,"inherits":453}],378:[function(require,module,exports){ -'use strict'; +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); -var utils = require('../utils'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = require('./base'); + // 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()); -var assert = utils.assert; + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } -function ShortCurve(conf) { - Base.call(this, 'short', conf); + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - 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(); + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + return this.point(x, y); +}; - // 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; +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); - // 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); - } - } + 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))); - // 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), - }; - }); + 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 { - basis = this._getEndoBasis(lambda); + 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); - return { - beta: beta, - lambda: lambda, - basis: basis, - }; +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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); +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); }; -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); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // 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; +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)); +}; - 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)); +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; + // 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); +}; - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; +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 - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } + // 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(); - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); + 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 [ - { a: a1, b: b1 }, - { a: a2, b: b2 }, - ]; + return this.curve.point(nx, ny, nz); }; -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); +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); }; -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(); +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return this.point(x, y); + // 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); }; -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; -}; +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S -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; + // 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 { - 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), - }, - }; + // 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 beta; + return this.curve.point(nx, ny, nz); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; - 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), - }, - } ]; + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); }; -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.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; - - // P + O = P - if (p.inf) +Point.prototype.normalize = function normalize() { + if (this.zOne) 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); + // 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.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.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.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.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; }; -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.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; -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); -}; + 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; -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); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } }; -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - 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; -}; +},{"../utils":381,"./base":368,"bn.js":382,"inherits":442}],370:[function(require,module,exports){ +'use strict'; -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +var curve = exports; - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); + +},{"./base":368,"./edwards":369,"./mont":371,"./short":372}],371:[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 JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); + this.z = this.curve.zero; } 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.z.red) + this.z = this.z.toRed(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); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; } -inherits(JPoint, Base.BasePoint); +inherits(Point, Base.BasePoint); -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); }; -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); +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); }; -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); +Point.prototype.precompute = function precompute() { + // No-op +}; - 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); +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; - return this.curve.jpoint(nx, ny, nz); +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P +Point.prototype.inspect = function inspect() { if (this.isInfinity()) - return p.toJ(); + return ''; + return ''; +}; - // P + O = P - if (p.isInfinity()) - return this; +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; - // 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); +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - 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(); - } + // 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); +}; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - 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); +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A - return this.curve.jpoint(nx, ny, nz); + // 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); }; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +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 - var i; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (i = 0; i < pow; i++) - r = r.dbl(); - return r; + 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; +}; - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - // 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)); +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - 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); +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; - jx = nx; - jz = nz; - jyd = dny; - } +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + return this.x.fromRed(); }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +},{"../utils":381,"./base":368,"bn.js":382,"inherits":442}],372:[function(require,module,exports){ +'use strict'; - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); -}; +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -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 +var assert = utils.assert; - // 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); +function ShortCurve(conf) { + Base.call(this, 'short', conf); - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); + 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(); - // 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 + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - // 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(); + // 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; - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - // 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); + // 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); + } } - return this.curve.jpoint(nx, ny, nz); + // 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, + }; }; -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 +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(); - // 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); - } + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - return this.curve.jpoint(nx, ny, nz); + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; }; -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); + // 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); - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); + // 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 c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + 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)); - 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); + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - 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); + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; - return this.curve.jpoint(nx, ny, nz); -}; + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; - // 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); +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - return this.curve.jpoint(nx, ny, nz); -}; + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); - return this.curve._wnafMul(this, k); + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); - if (this === p) - return true; + 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'); - // 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; + // 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(); - // 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; + return this.point(x, y); }; -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) +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) 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 ''; -}; + var x = point.x; + var y = point.y; -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; + 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; }; -},{"../utils":387,"./base":374,"bn.js":388,"inherits":453}],379:[function(require,module,exports){ -'use strict'; - -var curves = exports; +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(); -var hash = require('hash.js'); -var curve = require('./curve'); -var utils = require('./utils'); - -var assert = utils.assert; + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } -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; + 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); - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; -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; - }, - }); +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); -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', - ], -}); +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; -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', - ], -}); +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; -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', - ], -}); +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; -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', - ], -}); + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; -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', - ], -}); + 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; +}; -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', - ], -}); +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; -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', + 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), + }, + } ]; +}; - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658', - ], -}); +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; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; -} + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } -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', + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15', + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), }, - ], + }; + return res; +}; - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre, - ], -}); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; -},{"./curve":376,"./precomputed/secp256k1":386,"./utils":387,"hash.js":438}],380:[function(require,module,exports){ -'use strict'; +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; -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; +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; -var KeyPair = require('./key'); -var Signature = require('./signature'); + // P + O = P + if (p.inf) + return this; -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); + // P + P = 2P + if (this.eq(p)) + return this.dbl(); - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(Object.prototype.hasOwnProperty.call(curves, options), - 'Unknown curve ' + options); + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); - options = curves[options]; - } + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof curves.PresetCurve) - options = { curve: options }; + 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); +}; - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; -} -module.exports = EC; + var a = this.curve.a; -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); + 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); }; -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); +Point.prototype.getX = function getX() { + return this.x.fromRed(); }; -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(), - }); +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; - 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; +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); +}; - priv.iaddn(1); - return this.keyFromPrivate(priv); - } +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); }; -EC.prototype._truncateToN = function _truncateToN(msg, truncOnly, bitLength) { - var byteLength; - if (BN.isBN(msg) || typeof msg === 'number') { - msg = new BN(msg, 16); - byteLength = msg.byteLength(); - } else if (typeof msg === 'object') { - // BN assumes an array-like input and asserts length - byteLength = msg.length; - msg = new BN(msg, 16); - } else { - // BN converts the value to string - var str = msg.toString(); - // HEX encoding - byteLength = (str.length + 1) >>> 1; - msg = new BN(str, 16); - } - // Allow overriding - if (typeof bitLength !== 'number') { - bitLength = byteLength * 8; - } - var delta = bitLength - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); +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 msg; + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; +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; - if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) { - assert(typeof msg === 'object' && msg && typeof msg.length === 'number', - 'Expected message to be an array-like, a hex string, or a BN instance'); - assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer - for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]); + 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; +}; - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(msg, false, options.msgBitLength); +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - // Would fail further checks, but let's make the error message clear - assert(!msg.isNeg(), 'Can not sign a negative message'); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); +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); - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); - // Recheck nonce to be bijective to msg - assert((new BN(nonce)).eq(msg), 'Can not sign message'); +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; - // 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); +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); - } + return this.curve.point(ax, ay); }; -EC.prototype.verify = function verify(msg, signature, key, enc, options) { - if (!options) - options = {}; - - msg = this._truncateToN(msg, false, options.msgBitLength); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; - // 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; +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; - // 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; + // P + O = P + if (p.isInfinity()) + return this; - if (!this.curve._maxwellTrick) { - p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + // 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)); - return p.getX().umod(this.n).cmp(r) === 0; + 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(); } - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + 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); - // 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); + return this.curve.jpoint(nx, ny, nz); }; -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); +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; + // P + O = P + if (p.isInfinity()) + return this; - // 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'); + // 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); - // 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 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 rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; + 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); -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; + return this.curve.jpoint(nx, ny, nz); +}; - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; - } +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); - if (Qprime.eq(Q)) - return i; + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; } - throw new Error('Unable to find valid recovery factor'); -}; -},{"../curves":379,"../utils":387,"./key":381,"./signature":382,"bn.js":388,"brorand":51,"hmac-drbg":451}],381:[function(require,module,exports){ -'use strict'; + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; + // 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)); - // 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; + 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); -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; + jx = nx; + jz = nz; + jyd = dny; + } - return new KeyPair(ec, { - pub: pub, - pubEnc: enc, - }); + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; - return new KeyPair(ec, { - priv: priv, - privEnc: enc, - }); + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); }; -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); +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 - 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' }; + // 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); - return { result: true, reason: null }; -}; + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; - } + // 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 - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); + // 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(); - if (!enc) - return this.pub; + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); - return this.pub.encode(enc, compact); -}; + // 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); + } -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); - else - return this.priv; + return this.curve.jpoint(nx, ny, nz); }; -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); -}; +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 -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); -}; + // 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 -// ECDH -KeyPair.prototype.derive = function derive(pub) { - if(!pub.validate()) { - assert(pub.validate(), 'public point not validated'); + // 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 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, options) { - return this.ec.verify(msg, signature, this, undefined, options); -}; -KeyPair.prototype.inspect = function inspect() { - return ''; + return this.curve.jpoint(nx, ny, nz); }; -},{"../utils":387,"bn.js":388}],382:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); - -var utils = require('../utils'); -var assert = utils.assert; +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; -function Signature(options, enc) { - if (options instanceof Signature) - return options; + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - if (this._importDER(options, enc)) - return; + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); - 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; + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); -function Position() { - this.place = 0; -} + 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); -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; + 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); - // Indefinite length or overflow - if (octetLen === 0 || octetLen > 4) { - return false; - } + return this.curve.jpoint(nx, ny, nz); +}; - if(buf[p.place] === 0x00) { - return false; - } +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - val >>>= 0; - } + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - // Leading zeroes - if (val <= 0x7f) { - return false; - } + // 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); - p.place = off; - return val; -} + return this.curve.jpoint(nx, ny, nz); +}; -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); -} +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); -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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - if ((data[p.place] & 128) !== 0) { - 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; - } - } + return this.curve._wnafMul(this, k); +}; - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); - return true; -}; + if (this === p) + 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); -} + // 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; -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); + // 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; +}; - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); +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; - r = rmPadding(r); - s = rmPadding(s); + 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; - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - 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":387,"bn.js":388}],383:[function(require,module,exports){ +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":381,"./base":368,"bn.js":382,"inherits":442}],373:[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'); +var curves = exports; -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); - if (!(this instanceof EDDSA)) - return new EDDSA(curve); +var assert = utils.assert; - curve = curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); +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; - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); } +curves.PresetCurve = PresetCurve; -module.exports = EDDSA; +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; + }, + }); +} -/** -* @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); - if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) { - return false; - } - 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); -}; +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', + ], +}); -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); -}; +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', + ], +}); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; +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', + ], +}); -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; +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', + ], +}); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; +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', + ], +}); -/** -* * 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; -}; +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', + ], +}); -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); +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', - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; +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, -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -},{"../curves":379,"../utils":387,"./key":384,"./signature":385,"hash.js":438}],384:[function(require,module,exports){ +},{"./curve":370,"./precomputed/secp256k1":380,"./utils":381,"hash.js":427}],374:[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 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); -} +var KeyPair = require('./key'); +var Signature = require('./signature'); -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); +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); }; -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); }; -KeyPair.prototype.secret = function secret() { - return this._secret; +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); }; -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + // 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(), + }); -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + 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; - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + priv.iaddn(1); + return this.keyFromPrivate(priv); + } +}; - return a; -}); +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; +}; -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; + 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; -module.exports = KeyPair; + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; -},{"../utils":387}],385:[function(require,module,exports){ -'use strict'; + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; -var BN = require('bn.js'); -var utils = require('../utils'); -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -/** -* @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; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); - if (typeof sig !== 'object') - sig = parseBytes(sig); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } - if (Array.isArray(sig)) { - assert(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size'); - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength), - }; + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } +}; - assert(sig.R && sig.S, 'Signature without R or S'); +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'); - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; + // 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; - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} + // 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; -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); + return p.getX().umod(this.n).cmp(r) === 0; + } -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); + // 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); }; -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); -}; +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); -module.exports = Signature; + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; -},{"../utils":387,"bn.js":388}],386:[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', - ], - ], - }, -}; - -},{}],387:[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); - var i; - for (i = 0; i < naf.length; i += 1) { - naf[i] = 0; - } - - var ws = 1 << (w + 1); - var k = num.clone(); - - for (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":388,"minimalistic-assert":485,"minimalistic-crypto-utils":486}],388:[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; - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - } - 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(); - }; + // 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'); - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; + // 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 a = this.clone(); - var b = num; + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - // 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; - } + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; - // Initialize quotient - var m = a.length - b.length; - var q; +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - 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; - } + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); +},{"../curves":373,"../utils":381,"./key":375,"./signature":376,"bn.js":382,"brorand":51,"hmac-drbg":440}],375:[function(require,module,exports){ +'use strict'; - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; - 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(); +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } + // 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; - return { - div: q || null, - mod: a - }; - }; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - // 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()); + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); +}; - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); +}; - if (mode !== 'mod') { - div = res.div.neg(); - } +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } + 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 { - div: div, - mod: mod - }; - } + return { result: true, reason: null }; +}; - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } - if (mode !== 'mod') { - div = res.div.neg(); - } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); - return { - div: div, - mod: res.mod - }; - } + if (!enc) + return this.pub; - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); + return this.pub.encode(enc, compact); +}; - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; - return { - div: res.div, - mod: mod - }; - } +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - // Both numbers are positive at this point + // 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); +}; - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; +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); +}; - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; - return this._wordDiv(num, mode); - }; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; +},{"../utils":381,"bn.js":382}],376:[function(require,module,exports){ +'use strict'; - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; +var BN = require('bn.js'); - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; +var utils = require('../utils'); +var assert = utils.assert; - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); +function Signature(options, enc) { + if (options instanceof Signature) + return options; - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; + if (this._importDER(options, enc)) + return; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + 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; - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); +function Position() { + this.place = 0; +} - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } + // Leading zeroes + if (val <= 0x7f) { + return false; + } - return acc; - }; + p.place = off; + return val; +} - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); +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); +} - 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; +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; } + } - return this.strip(); - }; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; + return true; +}; - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); +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); +} - var x = this; - var y = p.clone(); +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); + r = rmPadding(r); + s = rmPadding(s); - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); + 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); +}; - var g = 0; +},{"../utils":381,"bn.js":382}],377:[function(require,module,exports){ +'use strict'; - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } +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'); - var yp = y.clone(); - var xp = x.clone(); +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - 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); - } + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - A.iushrn(1); - B.iushrn(1); - } - } + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 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); - } + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - C.iushrn(1); - D.iushrn(1); - } - } +module.exports = EDDSA; - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } +/** +* @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 }); +}; - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; +/** +* @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); +}; - // 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()); +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); +}; - var a = this; - var b = p.clone(); +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; - var x1 = new BN(1); - var x2 = new BN(0); +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - var delta = b.clone(); +/** +* * 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; +}; - 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); - } +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - x1.iushrn(1); - } - } + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - 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); - } + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - x2.iushrn(1); - } - } +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; - if (res.cmpn(0) < 0) { - res.iadd(p); - } +},{"../curves":373,"../utils":381,"./key":378,"./signature":379,"hash.js":427}],378:[function(require,module,exports){ +'use strict'; - return res; - }; +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); +/** +* @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); +} - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); +}; - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - 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; - } +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - a.isub(b); - } while (true); +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - return b.iushln(shift); - }; +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; + return a; +}); - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - // 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; +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, 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; - }; +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; +module.exports = KeyPair; - this.strip(); +},{"../utils":381}],379:[function(require,module,exports){ +'use strict'; - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - assert(num <= 0x3ffffff, 'Number is too big'); +/** +* @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; - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; + if (typeof sig !== 'object') + sig = parseBytes(sig); - // 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; + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; + assert(sig.R && sig.S, 'Signature without R or S'); - // 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; + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); +}; - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; + +module.exports = Signature; + +},{"../utils":381,"bn.js":382}],380:[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', + ], + ], + }, +}; - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; +},{}],381:[function(require,module,exports){ +'use strict'; - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + var i; + for (i = 0; i < naf.length; i += 1) { + naf[i] = 0; + } - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; + var ws = 1 << (w + 1); + var k = num.clone(); - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; + for (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; + } - 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); - }; + naf[i] = z; + k.iushrn(1); + } - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; + return naf; +} +utils.getNAF = getNAF; - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; + 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); - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; + 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); - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; + return jsf; +} +utils.getJSF = getJSF; - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); +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; - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; - 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); - }; +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; - 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.js":382,"minimalistic-assert":466,"minimalistic-crypto-utils":467}],382:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } - // 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); - }; + // 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.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; + // BN - // 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); - }; + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; + this.negative = 0; + this.words = null; + this.length = 0; - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; + // Reduction context + this.red = 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); + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - this.tmp = this._tmp(); + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; } - 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); + BN.BN = BN; + BN.wordSize = 26; - 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); + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; } else { - if (r.strip !== undefined) { - // r is BN v4 instance - r.strip(); - } else { - // r is BN v5 instance - r._strip(); - } + Buffer = require('buffer').Buffer; } + } catch (e) { + } - return r; + 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); }; - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; }; - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; }; - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; + if (base === 'hex') { + base = 16; } - output.length = outLen; + assert(base === (base | 0) && base >= 2 && base <= 36); - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; } - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; + 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); + } + } + } + }; - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; + 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 { - input.length -= 9; + 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); }; - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; + 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; + } - // 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); + 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; } - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; + 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 num; + return this.strip(); }; - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + 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; + } } - inherits(P224, MPrime); - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; } - inherits(P192, MPrime); - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + 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; } - 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; + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; - num.words[i] = lo; - carry = hi; + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; } - if (carry !== 0) { - num.words[num.length++] = carry; + 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); + } } - 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]; + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - 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); + 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); + } } - primes[name] = prime; - return prime; + this.strip(); }; - // - // 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; + 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; + }; - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; }; - 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'); + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; }; - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(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(); }; - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; } + return this; + }; - return this.m.sub(a)._forceRed(this); + BN.prototype.inspect = function inspect () { + return (this.red ? ''; }; - 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); + 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; } - return res._forceRed(this); - }; + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } - 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; - }; + 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' + ]; - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); + 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 res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); + 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; } - return res._forceRed(this); - }; - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); + 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); - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); + 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; } - return res; - }; - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); + assert(false, 'Base should be between 2 and 36'); }; - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); + 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; }; - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); + BN.prototype.toJSON = function toJSON () { + return this.toString(16); }; - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); }; - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); }; - 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); + 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'); - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); - 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(); + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; } - 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; - }; + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); + res[reqLength - i - 1] = b; + } } 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; - } + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + res[i] = b; + } - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; + for (; i < reqLength; i++) { + res[i] = 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); + 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; + }; } - inherits(Mont, Red); - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; + 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; }; - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } + // 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; + }; - 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; + function toBitArray (num) { + var w = new Array(num.bitLength()); - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); + 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 res._forceRed(this); - }; + return w; + } - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - 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); + 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 res._forceRed(this); + return r; }; - 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); + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); }; -})(typeof module === 'undefined' || module, this); - -},{"buffer":52}],389:[function(require,module,exports){ -module.exports={ - "name": "elliptic", - "version": "6.6.1", - "description": "EC cryptography", - "main": "lib/elliptic.js", - "files": [ - "lib" - ], - "scripts": { - "lint": "eslint lib test", - "lint:fix": "npm run lint -- --fix", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "test": "npm run lint && npm run unit", - "version": "grunt dist && git add dist/" - }, - "repository": { - "type": "git", - "url": "git@github.com:indutny/elliptic" - }, - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "author": "Fedor Indutny ", - "license": "MIT", - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "homepage": "https://github.com/indutny/elliptic", - "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" - }, - "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" - } -} - -},{}],390:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hasCORS = void 0; -// imported from https://github.com/component/has-cors -let value = false; -try { - value = typeof XMLHttpRequest !== 'undefined' && - 'withCredentials' in new XMLHttpRequest(); -} -catch (err) { - // if XMLHttp support is disabled in IE then it will throw - // when trying to create -} -exports.hasCORS = value; -},{}],391:[function(require,module,exports){ -"use strict"; -// imported from https://github.com/galkn/querystring -/** - * Compiles a querystring - * Returns string representation of the object - * - * @param {Object} - * @api private - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.encode = encode; -exports.decode = decode; -function encode(obj) { - let str = ''; - for (let i in obj) { - if (obj.hasOwnProperty(i)) { - if (str.length) - str += '&'; - str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); - } - } - return str; -} -/** - * Parses a simple querystring into an object - * - * @param {String} qs - * @api private - */ -function decode(qs) { - let qry = {}; - let pairs = qs.split('&'); - for (let i = 0, l = pairs.length; i < l; i++) { - let pair = pairs[i].split('='); - qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); } - return qry; -} + return this.clone(); + }; -},{}],392:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.parse = parse; -// imported from https://github.com/galkn/parseuri -/** - * Parses a URI - * - * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. - * - * See: - * - https://developer.mozilla.org/en-US/docs/Web/API/URL - * - https://caniuse.com/url - * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B - * - * History of the parse() method: - * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c - * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 - * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 - * - * @author Steven Levithan (MIT license) - * @api private - */ -const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; -const parts = [ - 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' -]; -function parse(str) { - if (str.length > 8000) { - throw "URI too long"; - } - const src = str, b = str.indexOf('['), e = str.indexOf(']'); - if (b != -1 && e != -1) { - str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); - } - let m = re.exec(str || ''), uri = {}, i = 14; - while (i--) { - uri[parts[i]] = m[i] || ''; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); } - if (b != -1 && e != -1) { - uri.source = src; - uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); - uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); - uri.ipv6uri = true; + 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; } - uri.pathNames = pathNames(uri, uri['path']); - uri.queryKey = queryKey(uri, uri['query']); - return uri; -} -function pathNames(obj, path) { - const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); - if (path.slice(0, 1) == '/' || path.length === 0) { - names.splice(0, 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; } - if (path.slice(-1) == '/') { - names.splice(names.length - 1, 1); + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; } - return names; -} -function queryKey(uri, query) { - const data = {}; - query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { - if ($1) { - data[$1] = $2; - } - }); - return data; -} -},{}],393:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.defaultBinaryType = exports.globalThisShim = exports.nextTick = void 0; -exports.createCookieJar = createCookieJar; -exports.nextTick = (() => { - const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; - if (isPromiseAvailable) { - return (cb) => Promise.resolve().then(cb); + 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; } - else { - return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; } -})(); -exports.globalThisShim = (() => { - if (typeof self !== "undefined") { - return self; + + 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; } - else if (typeof window !== "undefined") { - return window; + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; } - else { - return Function("return this")(); + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } } -})(); -exports.defaultBinaryType = "arraybuffer"; -function createCookieJar() { } -},{}],394:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0; -const socket_js_1 = require("./socket.js"); -Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); -var socket_js_2 = require("./socket.js"); -Object.defineProperty(exports, "SocketWithoutUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }); -Object.defineProperty(exports, "SocketWithUpgrade", { enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }); -exports.protocol = socket_js_1.Socket.protocol; -var transport_js_1 = require("./transport.js"); -Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); -Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); -var index_js_1 = require("./transports/index.js"); -Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); -var util_js_1 = require("./util.js"); -Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); -var parseuri_js_1 = require("./contrib/parseuri.js"); -Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); -var globals_node_js_1 = require("./globals.node.js"); -Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return globals_node_js_1.nextTick; } }); -var polling_fetch_js_1 = require("./transports/polling-fetch.js"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return polling_fetch_js_1.Fetch; } }); -var polling_xhr_node_js_1 = require("./transports/polling-xhr.node.js"); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return polling_xhr_node_js_1.XHR; } }); -var polling_xhr_js_1 = require("./transports/polling-xhr.js"); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return polling_xhr_js_1.XHR; } }); -var websocket_node_js_1 = require("./transports/websocket.node.js"); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return websocket_node_js_1.WS; } }); -var websocket_js_1 = require("./transports/websocket.js"); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return websocket_js_1.WS; } }); -var webtransport_js_1 = require("./transports/webtransport.js"); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return webtransport_js_1.WT; } }); - -},{"./contrib/parseuri.js":392,"./globals.node.js":393,"./socket.js":395,"./transport.js":396,"./transports/index.js":397,"./transports/polling-fetch.js":398,"./transports/polling-xhr.js":399,"./transports/polling-xhr.node.js":399,"./transports/websocket.js":401,"./transports/websocket.node.js":401,"./transports/webtransport.js":402,"./util.js":403}],395:[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.Socket = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = void 0; -const index_js_1 = require("./transports/index.js"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const parseuri_js_1 = require("./contrib/parseuri.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("./globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() -const withEventListeners = typeof addEventListener === "function" && - typeof removeEventListener === "function"; -const OFFLINE_EVENT_LISTENERS = []; -if (withEventListeners) { - // within a ServiceWorker, any event handler for the 'offline' event must be added on the initial evaluation of the - // script, so we create one single event listener here which will forward the event to the socket instances - addEventListener("offline", () => { - debug("closing %d connection(s) because the network was lost", OFFLINE_EVENT_LISTENERS.length); - OFFLINE_EVENT_LISTENERS.forEach((listener) => listener()); - }, false); -} -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that - * successfully establishes the connection. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithoutUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithoutUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithUpgrade - * @see Socket - */ -class SocketWithoutUpgrade extends component_emitter_1.Emitter { - /** - * Socket constructor. - * - * @param {String|Object} uri - uri or options - * @param {Object} opts - options - */ - constructor(uri, opts) { - super(); - this.binaryType = globals_node_js_1.defaultBinaryType; - this.writeBuffer = []; - this._prevBufferLen = 0; - this._pingInterval = -1; - this._pingTimeout = -1; - this._maxPayload = -1; - /** - * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the - * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked. - */ - this._pingTimeoutTime = Infinity; - if (uri && "object" === typeof uri) { - opts = uri; - uri = null; - } - if (uri) { - const parsedUri = (0, parseuri_js_1.parse)(uri); - opts.hostname = parsedUri.host; - opts.secure = - parsedUri.protocol === "https" || parsedUri.protocol === "wss"; - opts.port = parsedUri.port; - if (parsedUri.query) - opts.query = parsedUri.query; - } - else if (opts.host) { - opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; - } - (0, util_js_1.installTimerFunctions)(this, opts); - this.secure = - null != opts.secure - ? opts.secure - : typeof location !== "undefined" && "https:" === location.protocol; - if (opts.hostname && !opts.port) { - // if no port is specified manually, use the protocol default - opts.port = this.secure ? "443" : "80"; - } - this.hostname = - opts.hostname || - (typeof location !== "undefined" ? location.hostname : "localhost"); - this.port = - opts.port || - (typeof location !== "undefined" && location.port - ? location.port - : this.secure - ? "443" - : "80"); - this.transports = []; - this._transportsByName = {}; - opts.transports.forEach((t) => { - const transportName = t.prototype.name; - this.transports.push(transportName); - this._transportsByName[transportName] = t; - }); - this.opts = Object.assign({ - path: "/engine.io", - agent: false, - withCredentials: false, - upgrade: true, - timestampParam: "t", - rememberUpgrade: false, - addTrailingSlash: true, - rejectUnauthorized: true, - perMessageDeflate: { - threshold: 1024, - }, - transportOptions: {}, - closeOnBeforeunload: false, - }, opts); - this.opts.path = - this.opts.path.replace(/\/$/, "") + - (this.opts.addTrailingSlash ? "/" : ""); - if (typeof this.opts.query === "string") { - this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); - } - if (withEventListeners) { - if (this.opts.closeOnBeforeunload) { - // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener - // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is - // closed/reloaded) - this._beforeunloadEventListener = () => { - if (this.transport) { - // silently close the transport - this.transport.removeAllListeners(); - this.transport.close(); - } - }; - addEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this.hostname !== "localhost") { - debug("adding listener for the 'offline' event"); - this._offlineEventListener = () => { - this._onClose("transport close", { - description: "network connection lost", - }); - }; - OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener); - } - } - if (this.opts.withCredentials) { - this._cookieJar = (0, globals_node_js_1.createCookieJar)(); - } - this._open(); + 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--; } - /** - * Creates transport of the given type. - * - * @param {String} name - transport name - * @return {Transport} - * @private - */ - createTransport(name) { - debug('creating transport "%s"', name); - const query = Object.assign({}, this.opts.query); - // append engine.io protocol identifier - query.EIO = engine_io_parser_1.protocol; - // transport name - query.transport = name; - // session id if we already have one - if (this.id) - query.sid = this.id; - const opts = Object.assign({}, this.opts, { - query, - socket: this, - hostname: this.hostname, - secure: this.secure, - port: this.port, - }, this.opts.transportOptions[name]); - debug("options: %j", opts); - return new this._transportsByName[name](opts); + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; } - /** - * Initializes transport to use and starts probe. - * - * @private - */ - _open() { - if (this.transports.length === 0) { - // Emit error on next tick so it can be listened to - this.setTimeoutFn(() => { - this.emitReserved("error", "No transports available"); - }, 0); - return; - } - const transportName = this.opts.rememberUpgrade && - SocketWithoutUpgrade.priorWebsocketSuccess && - this.transports.indexOf("websocket") !== -1 - ? "websocket" - : this.transports[0]; - this.readyState = "opening"; - const transport = this.createTransport(transportName); - transport.open(); - this.setTransport(transport); + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); } - /** - * Sets the current transport. Disables the existing one (if any). - * - * @private - */ - setTransport(transport) { - debug("setting transport %s", transport.name); - if (this.transport) { - debug("clearing existing transport %s", this.transport.name); - this.transport.removeAllListeners(); - } - // set up transport - this.transport = transport; - // set up transport listeners - transport - .on("drain", this._onDrain.bind(this)) - .on("packet", this._onPacket.bind(this)) - .on("error", this._onError.bind(this)) - .on("close", (reason) => this._onClose("transport close", reason)); + + // 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); } - /** - * Called when connection is deemed open. - * - * @private - */ - onOpen() { - debug("socket open"); - this.readyState = "open"; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === this.transport.name; - this.emitReserved("open"); - this.flush(); + + 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(); } - /** - * Handles a packet. - * - * @private - */ - _onPacket(packet) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket receive: type "%s", data "%s"', packet.type, packet.data); - this.emitReserved("packet", packet); - // Socket is live - any packet counts - this.emitReserved("heartbeat"); - switch (packet.type) { - case "open": - this.onHandshake(JSON.parse(packet.data)); - break; - case "ping": - this._sendPacket("pong"); - this.emitReserved("ping"); - this.emitReserved("pong"); - this._resetPingTimeout(); - break; - case "error": - const err = new Error("server error"); - // @ts-ignore - err.code = packet.data; - this._onError(err); - break; - case "message": - this.emitReserved("data", packet.data); - this.emitReserved("message", packet.data); - break; - } - } - else { - debug('packet received with socket readyState "%s"', this.readyState); - } + + // 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; } - /** - * Called upon handshake completion. - * - * @param {Object} data - handshake obj - * @private - */ - onHandshake(data) { - this.emitReserved("handshake", data); - this.id = data.sid; - this.transport.query.sid = data.sid; - this._pingInterval = data.pingInterval; - this._pingTimeout = data.pingTimeout; - this._maxPayload = data.maxPayload; - this.onOpen(); - // In case open handler closes socket - if ("closed" === this.readyState) - return; - this._resetPingTimeout(); + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; } - /** - * Sets and resets ping timeout timer based on server pings. - * - * @private - */ - _resetPingTimeout() { - this.clearTimeoutFn(this._pingTimeoutTimer); - const delay = this._pingInterval + this._pingTimeout; - this._pingTimeoutTime = Date.now() + delay; - this._pingTimeoutTimer = this.setTimeoutFn(() => { - this._onClose("ping timeout"); - }, delay); - if (this.opts.autoUnref) { - this._pingTimeoutTimer.unref(); - } + + 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; } - /** - * Called on `drain` event - * - * @private - */ - _onDrain() { - this.writeBuffer.splice(0, this._prevBufferLen); - // setting prevBufferLen = 0 is very important - // for example, when upgrading, upgrade packet is sent over, - // and a nonzero prevBufferLen could cause problems on `drain` - this._prevBufferLen = 0; - if (0 === this.writeBuffer.length) { - this.emitReserved("drain"); - } - else { - this.flush(); - } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; } - /** - * Flush write buffers. - * - * @private - */ - flush() { - if ("closed" !== this.readyState && - this.transport.writable && - !this.upgrading && - this.writeBuffer.length) { - const packets = this._getWritablePackets(); - debug("flushing %d packets in socket", packets.length); - this.transport.send(packets); - // keep track of current length of writeBuffer - // splice writeBuffer and callbackBuffer on `drain` - this._prevBufferLen = packets.length; - this.emitReserved("flush"); - } + + // 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++; } - /** - * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP - * long-polling) - * - * @private - */ - _getWritablePackets() { - const shouldCheckPayloadSize = this._maxPayload && - this.transport.name === "polling" && - this.writeBuffer.length > 1; - if (!shouldCheckPayloadSize) { - return this.writeBuffer; - } - let payloadSize = 1; // first packet type - for (let i = 0; i < this.writeBuffer.length; i++) { - const data = this.writeBuffer[i].data; - if (data) { - payloadSize += (0, util_js_1.byteLength)(data); - } - if (i > 0 && payloadSize > this._maxPayload) { - debug("only send %d out of %d packets", i, this.writeBuffer.length); - return this.writeBuffer.slice(0, i); - } - payloadSize += 2; // separator + packet type - } - debug("payload size is %d (max: %d)", payloadSize, this._maxPayload); - return this.writeBuffer; + 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; } - /** - * Checks whether the heartbeat timer has expired but the socket has not yet been notified. - * - * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the - * `write()` method then the message would not be buffered by the Socket.IO client. - * - * @return {boolean} - * @private - */ - /* private */ _hasPingExpired() { - if (!this._pingTimeoutTime) - return true; - const hasExpired = Date.now() > this._pingTimeoutTime; - if (hasExpired) { - debug("throttled timer detected, scheduling connection close"); - this._pingTimeoutTime = 0; - (0, globals_node_js_1.nextTick)(() => { - this._onClose("ping timeout"); - }, this.setTimeoutFn); - } - return hasExpired; + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; } - /** - * Sends a message. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - write(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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); } - /** - * Sends a message. Alias of {@link Socket#write}. - * - * @param {String} msg - message. - * @param {Object} options. - * @param {Function} fn - callback function. - * @return {Socket} for chaining. - */ - send(msg, options, fn) { - this._sendPacket("message", msg, options, fn); - return this; + + 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); } - /** - * Sends a packet. - * - * @param {String} type: packet type. - * @param {String} data. - * @param {Object} options. - * @param {Function} fn - callback function. - * @private - */ - _sendPacket(type, data, options, fn) { - if ("function" === typeof data) { - fn = data; - data = undefined; - } - if ("function" === typeof options) { - fn = options; - options = null; - } - if ("closing" === this.readyState || "closed" === this.readyState) { - return; - } - options = options || {}; - options.compress = false !== options.compress; - const packet = { - type: type, - data: data, - options: options, - }; - this.emitReserved("packetCreate", packet); - this.writeBuffer.push(packet); - if (fn) - this.once("flush", fn); - this.flush(); + + 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; } - /** - * Closes the connection. - */ - close() { - const close = () => { - this._onClose("forced close"); - debug("socket closing - telling transport to close"); - this.transport.close(); - }; - const cleanupAndClose = () => { - this.off("upgrade", cleanupAndClose); - this.off("upgradeError", cleanupAndClose); - close(); - }; - const waitForUpgrade = () => { - // wait for upgrade to finish since we can't send packets while pausing a transport - this.once("upgrade", cleanupAndClose); - this.once("upgradeError", cleanupAndClose); - }; - if ("opening" === this.readyState || "open" === this.readyState) { - this.readyState = "closing"; - if (this.writeBuffer.length) { - this.once("drain", () => { - if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - }); - } - else if (this.upgrading) { - waitForUpgrade(); - } - else { - close(); - } - } - return this; + + 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]]; } - /** - * Called upon transport error - * - * @private - */ - _onError(err) { - debug("socket error %j", err); - SocketWithoutUpgrade.priorWebsocketSuccess = false; - if (this.opts.tryAllTransports && - this.transports.length > 1 && - this.readyState === "opening") { - debug("trying next transport"); - this.transports.shift(); - return this._open(); + }; + + 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; + } } - this.emitReserved("error", err); - this._onClose("transport error", err); + } + } + }; + + 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; + } } - /** - * Called upon transport close. - * - * @private - */ - _onClose(reason, description) { - if ("opening" === this.readyState || - "open" === this.readyState || - "closing" === this.readyState) { - debug('socket close with reason: "%s"', reason); - // clear timers - this.clearTimeoutFn(this._pingTimeoutTimer); - // stop event from firing again for transport - this.transport.removeAllListeners("close"); - // ensure transport won't stay open - this.transport.close(); - // ignore further transport communication - this.transport.removeAllListeners(); - if (withEventListeners) { - if (this._beforeunloadEventListener) { - removeEventListener("beforeunload", this._beforeunloadEventListener, false); - } - if (this._offlineEventListener) { - const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener); - if (i !== -1) { - debug("removing listener for the 'offline' event"); - OFFLINE_EVENT_LISTENERS.splice(i, 1); - } - } - } - // set ready state - this.readyState = "closed"; - // clear session id - this.id = null; - // emit close event - this.emitReserved("close", reason, description); - // clean buffers after, so users can still - // grab the buffers on `close` event - this.writeBuffer = []; - this._prevBufferLen = 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; } -} -exports.SocketWithoutUpgrade = SocketWithoutUpgrade; -SocketWithoutUpgrade.protocol = engine_io_parser_1.protocol; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory. - * - * @example - * import { SocketWithUpgrade, WebSocket } from "engine.io-client"; - * - * const socket = new SocketWithUpgrade({ - * transports: [WebSocket] - * }); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see Socket - */ -class SocketWithUpgrade extends SocketWithoutUpgrade { - constructor() { - super(...arguments); - this._upgrades = []; + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; } - onOpen() { - super.onOpen(); - if ("open" === this.readyState && this.opts.upgrade) { - debug("starting upgrade probes"); - for (let i = 0; i < this._upgrades.length; i++) { - this._probe(this._upgrades[i]); - } - } + + 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; } - /** - * Probes a transport. - * - * @param {String} name - transport name - * @private - */ - _probe(name) { - debug('probing transport "%s"', name); - let transport = this.createTransport(name); - let failed = false; - SocketWithoutUpgrade.priorWebsocketSuccess = false; - const onTransportOpen = () => { - if (failed) - return; - debug('probe transport "%s" opened', name); - transport.send([{ type: "ping", data: "probe" }]); - transport.once("packet", (msg) => { - if (failed) - return; - if ("pong" === msg.type && "probe" === msg.data) { - debug('probe transport "%s" pong', name); - this.upgrading = true; - this.emitReserved("upgrading", transport); - if (!transport) - return; - SocketWithoutUpgrade.priorWebsocketSuccess = - "websocket" === transport.name; - debug('pausing current transport "%s"', this.transport.name); - this.transport.pause(() => { - if (failed) - return; - if ("closed" === this.readyState) - return; - debug("changing transport and sending upgrade packet"); - cleanup(); - this.setTransport(transport); - transport.send([{ type: "upgrade" }]); - this.emitReserved("upgrade", transport); - transport = null; - this.upgrading = false; - this.flush(); - }); - } - else { - debug('probe transport "%s" failed', name); - const err = new Error("probe error"); - // @ts-ignore - err.transport = transport.name; - this.emitReserved("upgradeError", err); - } - }); - }; - function freezeTransport() { - if (failed) - return; - // Any callback called by transport should be ignored since now - failed = true; - cleanup(); - transport.close(); - transport = null; - } - // Handle any error that happens while probing - const onerror = (err) => { - const error = new Error("probe error: " + err); - // @ts-ignore - error.transport = transport.name; - freezeTransport(); - debug('probe transport "%s" failed because of error: %s', name, err); - this.emitReserved("upgradeError", error); - }; - function onTransportClose() { - onerror("transport closed"); - } - // When the socket is closed while we're probing - function onclose() { - onerror("socket closed"); - } - // When the socket is upgraded while we're probing - function onupgrade(to) { - if (transport && to.name !== transport.name) { - debug('"%s" works - aborting "%s"', to.name, transport.name); - freezeTransport(); - } - } - // Remove all listeners on the transport and on self - const cleanup = () => { - transport.removeListener("open", onTransportOpen); - transport.removeListener("error", onerror); - transport.removeListener("close", onTransportClose); - this.off("close", onclose); - this.off("upgrading", onupgrade); - }; - transport.once("open", onTransportOpen); - transport.once("error", onerror); - transport.once("close", onTransportClose); - this.once("close", onclose); - this.once("upgrading", onupgrade); - if (this._upgrades.indexOf("webtransport") !== -1 && - name !== "webtransport") { - // favor WebTransport - this.setTimeoutFn(() => { - if (!failed) { - transport.open(); - } - }, 200); - } - else { - transport.open(); - } + + 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; } - onHandshake(data) { - this._upgrades = this._filterUpgrades(data.upgrades); - super.onHandshake(data); + + if (carry !== 0) { + this.words[i] = carry; + this.length++; } - /** - * Filters upgrades, returning only those matching client transports. - * - * @param {Array} upgrades - server upgrades - * @private - */ - _filterUpgrades(upgrades) { - const filteredUpgrades = []; - for (let i = 0; i < upgrades.length; i++) { - if (~this.transports.indexOf(upgrades[i])) - filteredUpgrades.push(upgrades[i]); - } - return filteredUpgrades; + + 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; } -} -exports.SocketWithUpgrade = SocketWithUpgrade; -/** - * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established - * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport. - * - * This class comes with an upgrade mechanism, which means that once the connection is established with the first - * low-level transport, it will try to upgrade to a better transport. - * - * @example - * import { Socket } from "engine.io-client"; - * - * const socket = new Socket(); - * - * socket.on("open", () => { - * socket.send("hello"); - * }); - * - * @see SocketWithoutUpgrade - * @see SocketWithUpgrade - */ -class Socket extends SocketWithUpgrade { - constructor(uri, opts = {}) { - const o = typeof uri === "object" ? uri : opts; - if (!o.transports || - (o.transports && typeof o.transports[0] === "string")) { - o.transports = (o.transports || ["polling", "websocket", "webtransport"]) - .map((transportName) => index_js_1.transports[transportName]) - .filter((t) => !!t); - } - super(uri, o); + + 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); + } } -} -exports.Socket = Socket; -},{"./contrib/parseqs.js":391,"./contrib/parseuri.js":392,"./globals.node.js":393,"./transports/index.js":397,"./util.js":403,"@socket.io/component-emitter":23,"debug":404,"engine.io-parser":410}],396:[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.Transport = exports.TransportError = void 0; -const engine_io_parser_1 = require("engine.io-parser"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("./util.js"); -const parseqs_js_1 = require("./contrib/parseqs.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() -class TransportError extends Error { - constructor(reason, description, context) { - super(reason); - this.description = description; - this.context = context; - this.type = "TransportError"; + 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++; + } } -} -exports.TransportError = TransportError; -class Transport extends component_emitter_1.Emitter { - /** - * Transport abstract constructor. - * - * @param {Object} opts - options - * @protected - */ - constructor(opts) { - super(); - this.writable = false; - (0, util_js_1.installTimerFunctions)(this, opts); - this.opts = opts; - this.query = opts.query; - this.socket = opts.socket; - this.supportsBinary = !opts.forceBase64; + + 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; } - /** - * Emits an error. - * - * @param {String} reason - * @param description - * @param context - the error context - * @return {Transport} for chaining - * @protected - */ - onError(reason, description, context) { - super.emitReserved("error", new TransportError(reason, description, context)); - return this; + + if (r !== 0) { + s++; } - /** - * Opens the transport. - */ - open() { - this.readyState = "opening"; - this.doOpen(); - return this; + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; } - /** - * Closes the transport. - */ - close() { - if (this.readyState === "opening" || this.readyState === "open") { - this.doClose(); - this.onClose(); - } + + 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; } - /** - * Sends multiple packets. - * - * @param {Array} packets - */ - send(packets) { - if (this.readyState === "open") { - this.write(packets); - } - else { - // this might happen if the transport was silently closed in the beforeunload event handler - debug("transport is not open, discarding packets"); - } + + // 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]++; + } } - /** - * Called upon open - * - * @protected - */ - onOpen() { - this.readyState = "open"; - this.writable = true; - super.emitReserved("open"); + 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; } - /** - * Called with data. - * - * @param {String} data - * @protected - */ - onData(data) { - const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); - this.onPacket(packet); + + 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; + } } - /** - * Called with a decoded packet. - * - * @protected - */ - onPacket(packet) { - super.emitReserved("packet", packet); + + 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; } - /** - * Called upon close. - * - * @protected - */ - onClose(details) { - this.readyState = "closed"; - super.emitReserved("close", details); + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; } - /** - * Pauses the transport, in order not to lose packets during an upgrade. - * - * @param onPause - */ - pause(onPause) { } - createUri(schema, query = {}) { - return (schema + - "://" + - this._hostname() + - this._port() + - this.opts.path + - this._query(query)); + + 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; } - _hostname() { - const hostname = this.opts.hostname; - return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + 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; } - _port() { - if (this.opts.port && - ((this.opts.secure && Number(this.opts.port !== 443)) || - (!this.opts.secure && Number(this.opts.port) !== 80))) { - return ":" + this.opts.port; - } - else { - return ""; - } + + // 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; + } } - _query(query) { - const encodedQuery = (0, parseqs_js_1.encode)(query); - return encodedQuery.length ? "?" + encodedQuery : ""; + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } } -} -exports.Transport = Transport; -},{"./contrib/parseqs.js":391,"./util.js":403,"@socket.io/component-emitter":23,"debug":404,"engine.io-parser":410}],397:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transports = void 0; -const polling_xhr_node_js_1 = require("./polling-xhr.node.js"); -const websocket_node_js_1 = require("./websocket.node.js"); -const webtransport_js_1 = require("./webtransport.js"); -exports.transports = { - websocket: websocket_node_js_1.WS, - webtransport: webtransport_js_1.WT, - polling: polling_xhr_node_js_1.XHR, -}; + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); -},{"./polling-xhr.node.js":399,"./websocket.node.js":401,"./webtransport.js":402}],398:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Fetch = void 0; -const polling_js_1 = require("./polling.js"); -/** - * HTTP long-polling based on the built-in `fetch()` method. - * - * Usage: browser, Node.js (since v18), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch - * @see https://caniuse.com/fetch - * @see https://nodejs.org/api/globals.html#fetch - */ -class Fetch extends polling_js_1.Polling { - doPoll() { - this._fetch() - .then((res) => { - if (!res.ok) { - return this.onError("fetch read error", res.status, res); - } - res.text().then((data) => this.onData(data)); - }) - .catch((err) => { - this.onError("fetch read error", err); - }); - } - doWrite(data, callback) { - this._fetch(data) - .then((res) => { - if (!res.ok) { - return this.onError("fetch write error", res.status, res); - } - callback(); - }) - .catch((err) => { - this.onError("fetch write error", err); - }); - } - _fetch(data) { - var _a; - const isPost = data !== undefined; - const headers = new Headers(this.opts.extraHeaders); - if (isPost) { - headers.set("content-type", "text/plain;charset=UTF-8"); - } - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.appendCookies(headers); - return fetch(this.uri(), { - method: isPost ? "POST" : "GET", - body: isPost ? data : null, - headers, - credentials: this.opts.withCredentials ? "include" : "omit", - }).then((res) => { - var _a; - // @ts-ignore getSetCookie() was added in Node.js v19.7.0 - (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(res.headers.getSetCookie()); - return res; - }); - } -} -exports.Fetch = Fetch; + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); -},{"./polling.js":400}],399:[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.XHR = exports.Request = exports.BaseXHR = void 0; -const polling_js_1 = require("./polling.js"); -const component_emitter_1 = require("@socket.io/component-emitter"); -const util_js_1 = require("../util.js"); -const globals_node_js_1 = require("../globals.node.js"); -const has_cors_js_1 = require("../contrib/has-cors.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -function empty() { } -class BaseXHR extends polling_js_1.Polling { - /** - * XHR Polling constructor. - * - * @param {Object} opts - * @package - */ - constructor(opts) { - super(opts); - if (typeof location !== "undefined") { - const isSSL = "https:" === location.protocol; - let port = location.port; - // some user agents have empty `location.port` - if (!port) { - port = isSSL ? "443" : "80"; - } - this.xd = - (typeof location !== "undefined" && - opts.hostname !== location.hostname) || - port !== opts.port; + 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; + } } - /** - * Sends data. - * - * @param {String} data to send. - * @param {Function} called upon flush. - * @private - */ - doWrite(data, fn) { - const req = this.request({ - method: "POST", - data: data, - }); - req.on("success", fn); - req.on("error", (xhrStatus, context) => { - this.onError("xhr post error", xhrStatus, context); - }); + if (q) { + q.strip(); } - /** - * Starts a poll cycle. - * - * @private - */ - doPoll() { - debug("xhr poll"); - const req = this.request(); - req.on("data", this.onData.bind(this)); - req.on("error", (xhrStatus, context) => { - this.onError("xhr poll error", xhrStatus, context); - }); - this.pollXhr = req; + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); } -} -exports.BaseXHR = BaseXHR; -class Request extends component_emitter_1.Emitter { - /** - * Request constructor - * - * @param {Object} options - * @package - */ - constructor(createRequest, uri, opts) { - super(); - this.createRequest = createRequest; - (0, util_js_1.installTimerFunctions)(this, opts); - this._opts = opts; - this._method = opts.method || "GET"; - this._uri = uri; - this._data = undefined !== opts.data ? opts.data : null; - this._create(); + + 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) + }; } - /** - * Creates the XHR object and sends the request. - * - * @private - */ - _create() { - var _a; - const opts = (0, util_js_1.pick)(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); - opts.xdomain = !!this._opts.xd; - const xhr = (this._xhr = this.createRequest(opts)); - try { - debug("xhr open %s: %s", this._method, this._uri); - xhr.open(this._method, this._uri, true); - try { - if (this._opts.extraHeaders) { - // @ts-ignore - xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); - for (let i in this._opts.extraHeaders) { - if (this._opts.extraHeaders.hasOwnProperty(i)) { - xhr.setRequestHeader(i, this._opts.extraHeaders[i]); - } - } - } - } - catch (e) { } - if ("POST" === this._method) { - try { - xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); - } - catch (e) { } - } - try { - xhr.setRequestHeader("Accept", "*/*"); - } - catch (e) { } - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); - // ie6 check - if ("withCredentials" in xhr) { - xhr.withCredentials = this._opts.withCredentials; - } - if (this._opts.requestTimeout) { - xhr.timeout = this._opts.requestTimeout; - } - xhr.onreadystatechange = () => { - var _a; - if (xhr.readyState === 3) { - (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies( - // @ts-ignore - xhr.getResponseHeader("set-cookie")); - } - if (4 !== xhr.readyState) - return; - if (200 === xhr.status || 1223 === xhr.status) { - this._onLoad(); - } - else { - // make sure the `error` event handler that's user-set - // does not throw in the same tick and gets caught here - this.setTimeoutFn(() => { - this._onError(typeof xhr.status === "number" ? xhr.status : 0); - }, 0); - } - }; - debug("xhr data %s", this._data); - xhr.send(this._data); - } - catch (e) { - // Need to defer since .create() is called directly from the constructor - // and thus the 'error' event can only be only bound *after* this exception - // occurs. Therefore, also, we cannot throw here at all. - this.setTimeoutFn(() => { - this._onError(e); - }, 0); - return; - } - if (typeof document !== "undefined") { - this._index = Request.requestsCount++; - Request.requests[this._index] = this; + + 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 + }; } - /** - * Called upon error. - * - * @private - */ - _onError(err) { - this.emitReserved("error", err, this._xhr); - this._cleanup(true); - } - /** - * Cleans up house. - * - * @private - */ - _cleanup(fromError) { - if ("undefined" === typeof this._xhr || null === this._xhr) { - return; - } - this._xhr.onreadystatechange = empty; - if (fromError) { - try { - this._xhr.abort(); - } - catch (e) { } - } - if (typeof document !== "undefined") { - delete Request.requests[this._index]; - } - this._xhr = null; + + 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 + }; } - /** - * Called upon load. - * - * @private - */ - _onLoad() { - const data = this._xhr.responseText; - if (data !== null) { - this.emitReserved("data", data); - this.emitReserved("success"); - this._cleanup(); + + 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 + }; } - /** - * Aborts the request. - * - * @package - */ - abort() { - this._cleanup(); + + // 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 + }; } -} -exports.Request = Request; -Request.requestsCount = 0; -Request.requests = {}; -/** - * Aborts pending requests when unloading the window. This is needed to prevent - * memory leaks (e.g. when using IE) and to ensure that no spurious error is - * emitted. - */ -if (typeof document !== "undefined") { - // @ts-ignore - if (typeof attachEvent === "function") { - // @ts-ignore - attachEvent("onunload", unloadHandler); + + // 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])) + }; } - else if (typeof addEventListener === "function") { - const terminationEvent = "onpagehide" in globals_node_js_1.globalThisShim ? "pagehide" : "unload"; - addEventListener(terminationEvent, unloadHandler, false); + + 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; } -} -function unloadHandler() { - for (let i in Request.requests) { - if (Request.requests.hasOwnProperty(i)) { - Request.requests[i].abort(); - } + + 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; } -} -const hasXHR2 = (function () { - const xhr = newRequest({ - xdomain: false, - }); - return xhr && xhr.responseType !== null; -})(); -/** - * HTTP long-polling based on the built-in `XMLHttpRequest` object. - * - * Usage: browser - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest - */ -class XHR extends BaseXHR { - constructor(opts) { - super(opts); - const forceBase64 = opts && opts.forceBase64; - this.supportsBinary = hasXHR2 && !forceBase64; + + 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(); } - request(opts = {}) { - Object.assign(opts, { xd: this.xd }, this.opts); - return new Request(newRequest, this.uri(), opts); + + // 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; } -} -exports.XHR = XHR; -function newRequest(opts) { - const xdomain = opts.xdomain; - // XMLHttpRequest can be disabled on IE - try { - if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { - return new XMLHttpRequest(); + + 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); } - } - catch (e) { } - if (!xdomain) { - try { - return new globals_node_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + + 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); } - catch (e) { } - } -} + } -},{"../contrib/has-cors.js":390,"../globals.node.js":393,"../util.js":403,"./polling.js":400,"@socket.io/component-emitter":23,"debug":404}],400:[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.Polling = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() -class Polling extends transport_js_1.Transport { - constructor() { - super(...arguments); - this._polling = false; - } - get name() { - return "polling"; + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } } - /** - * Opens the socket (triggers polling). We write a PING message to determine - * when the transport is open. - * - * @protected - */ - doOpen() { - this._poll(); + + 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(); } - /** - * Pauses polling. - * - * @param {Function} onPause - callback upon buffers are flushed and transport is paused - * @package - */ - pause(onPause) { - this.readyState = "pausing"; - const pause = () => { - debug("paused"); - this.readyState = "paused"; - onPause(); - }; - if (this._polling || !this.writable) { - let total = 0; - if (this._polling) { - debug("we are currently polling - waiting to pause"); - total++; - this.once("pollComplete", function () { - debug("pre-pause polling complete"); - --total || pause(); - }); - } - if (!this.writable) { - debug("we are currently writing - waiting to pause"); - total++; - this.once("drain", function () { - debug("pre-pause writing complete"); - --total || pause(); - }); - } + + 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); } - else { - pause(); + } + + 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); + } } - /** - * Starts polling cycle. - * - * @private - */ - _poll() { - debug("polling"); - this._polling = true; - this.doPoll(); - this.emitReserved("poll"); + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; } - /** - * Overloads onData to detect payloads. - * - * @protected - */ - onData(data) { - debug("polling got data %s", data); - const callback = (packet) => { - // if its the first message we consider the transport open - if ("opening" === this.readyState && packet.type === "open") { - this.onOpen(); - } - // if its a close packet, we close the ongoing requests - if ("close" === packet.type) { - this.onClose({ description: "transport closed by the server" }); - return false; - } - // otherwise bypass onData and handle the message - this.onPacket(packet); - }; - // decode payload - (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); - // if an event did not trigger closing - if ("closed" !== this.readyState) { - // if we got data we're not polling - this._polling = false; - this.emitReserved("pollComplete"); - if ("open" === this.readyState) { - this._poll(); - } - else { - debug('ignoring poll - transport state "%s"', this.readyState); - } - } + + if (res.cmpn(0) < 0) { + res.iadd(p); } - /** - * For polling, send a close packet. - * - * @protected - */ - doClose() { - const close = () => { - debug("writing close packet"); - this.write([{ type: "close" }]); - }; - if ("open" === this.readyState) { - debug("transport open - closing"); - close(); - } - else { - // in case we're trying to close while - // handshaking is in progress (GH-164) - debug("transport not open - deferring close"); - this.once("open", close); - } + + 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); } - /** - * Writes a packets payload. - * - * @param {Array} packets - data packets - * @protected - */ - write(packets) { - this.writable = false; - (0, engine_io_parser_1.encodePayload)(packets, (data) => { - this.doWrite(data, () => { - this.writable = true; - this.emitReserved("drain"); - }); - }); + + 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; } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "https" : "http"; - const query = this.query || {}; - // cache busting is forced - if (false !== this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - if (!this.supportsBinary && !query.sid) { - query.b64 = 1; - } - return this.createUri(schema, query); + if (carry !== 0) { + this.words[i] = carry; + this.length++; } -} -exports.Polling = Polling; + 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; + }; -},{"../transport.js":396,"../util.js":403,"debug":404,"engine.io-parser":410}],401:[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.WS = exports.BaseWS = void 0; -const transport_js_1 = require("../transport.js"); -const util_js_1 = require("../util.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const globals_node_js_1 = require("../globals.node.js"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() -// detect ReactNative environment -const isReactNative = typeof navigator !== "undefined" && - typeof navigator.product === "string" && - navigator.product.toLowerCase() === "reactnative"; -class BaseWS extends transport_js_1.Transport { - get name() { - return "websocket"; - } - doOpen() { - const uri = this.uri(); - const protocols = this.opts.protocols; - // React Native only supports the 'headers' option, and will print a warning if anything else is passed - const opts = isReactNative - ? {} - : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); - if (this.opts.extraHeaders) { - opts.headers = this.opts.extraHeaders; - } - try { - this.ws = this.createSocket(uri, protocols, opts); - } - catch (err) { - return this.emitReserved("error", err); - } - this.ws.binaryType = this.socket.binaryType; - this.addEventListeners(); - } - /** - * Adds event listeners to the socket - * - * @private - */ - addEventListeners() { - this.ws.onopen = () => { - if (this.opts.autoUnref) { - this.ws._socket.unref(); - } - this.onOpen(); - }; - this.ws.onclose = (closeEvent) => this.onClose({ - description: "websocket connection closed", - context: closeEvent, - }); - this.ws.onmessage = (ev) => this.onData(ev.data); - this.ws.onerror = (e) => this.onError("websocket error", e); - } - write(packets) { - this.writable = false; - // encodePacket efficient as it uses WS framing - // no need for encodePayload - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { - // Sometimes the websocket has already been closed but the browser didn't - // have a chance of informing us about it yet, in that case send will - // throw an error - try { - this.doWrite(packet, data); - } - catch (e) { - debug("websocket closed before onclose event"); - } - if (lastPacket) { - // fake drain - // defer to next tick to allow Socket to clear writeBuffer - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } - } - doClose() { - if (typeof this.ws !== "undefined") { - this.ws.onerror = () => { }; - this.ws.close(); - this.ws = null; - } - } - /** - * Generates uri for connection. - * - * @private - */ - uri() { - const schema = this.opts.secure ? "wss" : "ws"; - const query = this.query || {}; - // append timestamp to URI - if (this.opts.timestampRequests) { - query[this.opts.timestampParam] = (0, util_js_1.randomString)(); - } - // communicate binary support capabilities - if (!this.supportsBinary) { - query.b64 = 1; - } - return this.createUri(schema, query); - } -} -exports.BaseWS = BaseWS; -const WebSocketCtor = globals_node_js_1.globalThisShim.WebSocket || globals_node_js_1.globalThisShim.MozWebSocket; -/** - * WebSocket transport based on the built-in `WebSocket` object. - * - * Usage: browser, Node.js (since v21), Deno, Bun - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket - * @see https://caniuse.com/mdn-api_websocket - * @see https://nodejs.org/api/globals.html#websocket - */ -class WS extends BaseWS { - createSocket(uri, protocols, opts) { - return !isReactNative - ? protocols - ? new WebSocketCtor(uri, protocols) - : new WebSocketCtor(uri) - : new WebSocketCtor(uri, protocols, opts); - } - doWrite(_packet, data) { - this.ws.send(data); - } -} -exports.WS = WS; + 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; -},{"../globals.node.js":393,"../transport.js":396,"../util.js":403,"debug":404,"engine.io-parser":410}],402:[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.WT = void 0; -const transport_js_1 = require("../transport.js"); -const globals_node_js_1 = require("../globals.node.js"); -const engine_io_parser_1 = require("engine.io-parser"); -const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() -/** - * WebTransport transport based on the built-in `WebTransport` object. - * - * Usage: browser, Node.js (with the `@fails-components/webtransport` package) - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport - * @see https://caniuse.com/webtransport - */ -class WT extends transport_js_1.Transport { - get name() { - return "webtransport"; - } - doOpen() { - try { - // @ts-ignore - this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); - } - catch (err) { - return this.emitReserved("error", err); - } - this._transport.closed - .then(() => { - debug("transport closed gracefully"); - this.onClose(); - }) - .catch((err) => { - debug("transport closed due to %s", err); - this.onError("webtransport error", err); - }); - // note: we could have used async/await, but that would require some additional polyfills - this._transport.ready.then(() => { - this._transport.createBidirectionalStream().then((stream) => { - const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); - const reader = stream.readable.pipeThrough(decoderStream).getReader(); - const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); - encoderStream.readable.pipeTo(stream.writable); - this._writer = encoderStream.writable.getWriter(); - const read = () => { - reader - .read() - .then(({ done, value }) => { - if (done) { - debug("session is closed"); - return; - } - debug("received chunk: %o", value); - this.onPacket(value); - read(); - }) - .catch((err) => { - debug("an error occurred while reading: %s", err); - }); - }; - read(); - const packet = { type: "open" }; - if (this.query.sid) { - packet.data = `{"sid":"${this.query.sid}"}`; - } - this._writer.write(packet).then(() => this.onOpen()); - }); - }); + 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(); + } } - write(packets) { - this.writable = false; - for (let i = 0; i < packets.length; i++) { - const packet = packets[i]; - const lastPacket = i === packets.length - 1; - this._writer.write(packet).then(() => { - if (lastPacket) { - (0, globals_node_js_1.nextTick)(() => { - this.writable = true; - this.emitReserved("drain"); - }, this.setTimeoutFn); - } - }); - } + + 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]; } - doClose() { - var _a; - (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close(); + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; } -} -exports.WT = WT; -},{"../globals.node.js":393,"../transport.js":396,"debug":404,"engine.io-parser":410}],403:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.pick = pick; -exports.installTimerFunctions = installTimerFunctions; -exports.byteLength = byteLength; -exports.randomString = randomString; -const globals_node_js_1 = require("./globals.node.js"); -function pick(obj, ...attr) { - return attr.reduce((acc, k) => { - if (obj.hasOwnProperty(k)) { - acc[k] = obj[k]; - } - return acc; - }, {}); -} -// Keep a reference to the real timeout functions so they can be used when overridden -const NATIVE_SET_TIMEOUT = globals_node_js_1.globalThisShim.setTimeout; -const NATIVE_CLEAR_TIMEOUT = globals_node_js_1.globalThisShim.clearTimeout; -function installTimerFunctions(obj, opts) { - if (opts.useNativeTimers) { - obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globals_node_js_1.globalThisShim); + // 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; } - else { - obj.setTimeoutFn = globals_node_js_1.globalThisShim.setTimeout.bind(globals_node_js_1.globalThisShim); - obj.clearTimeoutFn = globals_node_js_1.globalThisShim.clearTimeout.bind(globals_node_js_1.globalThisShim); + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; } -} -// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) -const BASE64_OVERHEAD = 1.33; -// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 -function byteLength(obj) { - if (typeof obj === "string") { - return utf8Length(obj); + }; + + 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); } - // arraybuffer or blob - return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); -} -function utf8Length(str) { - let c = 0, length = 0; - for (let i = 0, l = str.length; i < l; i++) { - c = str.charCodeAt(i); - if (c < 0x80) { - length += 1; - } - else if (c < 0x800) { - length += 2; - } - else if (c < 0xd800 || c >= 0xe000) { - length += 3; - } - else { - i++; - length += 4; - } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } } - return length; -} -/** - * Generates a random 8-characters string. - */ -function randomString() { - return (Date.now().toString(36).substring(3) + - Math.random().toString(36).substring(2, 5)); -} + return num; + }; -},{"./globals.node.js":393}],404:[function(require,module,exports){ -(function (process){(function (){ -/* eslint-env browser */ + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); -/** - * This is the web browser implementation of `debug()`. - */ + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); + 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; -/** - * Colors. - */ + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; + // 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; + } + } -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } + 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'); + }; - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; - let m; + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + return this.m.sub(a)._forceRed(this); + }; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + Red.prototype.add = function add (a, b) { + this._verify2(a, b); -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; - if (!this.useColors) { - return; - } + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); - args.splice(lastC, 0, c); -} + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; - return r; -} + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; -module.exports = require('./common')(exports); + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); -const {formatters} = module.exports; + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; + // 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)); -}).call(this)}).call(this,require('_process')) -},{"./common":405,"_process":503}],405:[function(require,module,exports){ + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ + return r; + }; -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - createDebug.destroy = destroy; + 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); + } + }; - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); - /** - * The currently active debug mode names, and names to skip. - */ + 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); + } - createDebug.names = []; - createDebug.skips = []; + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + 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); + } - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; + return res; + }; - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); - const self = debug; + return r === num ? r.clone() : r; + }; - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; - args[0] = createDebug.coerce(args[0]); + // + // Montgomery method engine + // - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } + BN.mont = function mont (num) { + return new Mont(num); + }; - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); + function Mont (m) { + Red.call(this, m); - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } + 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); - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } + 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; - return debug; - } + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } + return res._forceRed(this); + }; - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; + 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); + } - createDebug.names = []; - createDebug.skips = []; + return res._forceRed(this); + }; - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; + 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); - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } +},{"buffer":52}],383:[function(require,module,exports){ +module.exports={ + "name": "elliptic", + "version": "6.5.5", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "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" + }, + "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" + } +} - namespaces = split[i].replace(/\*/g, '.*?'); +},{}],384:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hasCORS = void 0; +// imported from https://github.com/component/has-cors +let value = false; +try { + value = typeof XMLHttpRequest !== 'undefined' && + 'withCredentials' in new XMLHttpRequest(); +} +catch (err) { + // if XMLHttp support is disabled in IE then it will throw + // when trying to create +} +exports.hasCORS = value; - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } +},{}],385:[function(require,module,exports){ +"use strict"; +// imported from https://github.com/galkn/querystring +/** + * Compiles a querystring + * Returns string representation of the object + * + * @param {Object} + * @api private + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decode = exports.encode = void 0; +function encode(obj) { + let str = ''; + for (let i in obj) { + if (obj.hasOwnProperty(i)) { + if (str.length) + str += '&'; + str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); + } + } + return str; +} +exports.encode = encode; +/** + * Parses a simple querystring into an object + * + * @param {String} qs + * @api private + */ +function decode(qs) { + let qry = {}; + let pairs = qs.split('&'); + for (let i = 0, l = pairs.length; i < l; i++) { + let pair = pairs[i].split('='); + qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + return qry; +} +exports.decode = decode; - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } +},{}],386:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parse = void 0; +// imported from https://github.com/galkn/parseuri +/** + * Parses a URI + * + * Note: we could also have used the built-in URL object, but it isn't supported on all platforms. + * + * See: + * - https://developer.mozilla.org/en-US/docs/Web/API/URL + * - https://caniuse.com/url + * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B + * + * History of the parse() method: + * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c + * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3 + * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242 + * + * @author Steven Levithan (MIT license) + * @api private + */ +const re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; +const parts = [ + 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor' +]; +function parse(str) { + if (str.length > 2000) { + throw "URI too long"; + } + const src = str, b = str.indexOf('['), e = str.indexOf(']'); + if (b != -1 && e != -1) { + str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); + } + let m = re.exec(str || ''), uri = {}, i = 14; + while (i--) { + uri[parts[i]] = m[i] || ''; + } + if (b != -1 && e != -1) { + uri.source = src; + uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); + uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); + uri.ipv6uri = true; + } + uri.pathNames = pathNames(uri, uri['path']); + uri.queryKey = queryKey(uri, uri['query']); + return uri; +} +exports.parse = parse; +function pathNames(obj, path) { + const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/"); + if (path.slice(0, 1) == '/' || path.length === 0) { + names.splice(0, 1); + } + if (path.slice(-1) == '/') { + names.splice(names.length - 1, 1); + } + return names; +} +function queryKey(uri, query) { + const data = {}; + query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) { + if ($1) { + data[$1] = $2; + } + }); + return data; +} - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } +},{}],387:[function(require,module,exports){ +// imported from https://github.com/unshiftio/yeast +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.yeast = exports.decode = exports.encode = void 0; +const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''), length = 64, map = {}; +let seed = 0, i = 0, prev; +/** + * Return a string representing the specified number. + * + * @param {Number} num The number to convert. + * @returns {String} The string representation of the number. + * @api public + */ +function encode(num) { + let encoded = ''; + do { + encoded = alphabet[num % length] + encoded; + num = Math.floor(num / length); + } while (num > 0); + return encoded; +} +exports.encode = encode; +/** + * Return the integer value specified by the given string. + * + * @param {String} str The string to convert. + * @returns {Number} The integer value represented by the string. + * @api public + */ +function decode(str) { + let decoded = 0; + for (i = 0; i < str.length; i++) { + decoded = decoded * length + map[str.charAt(i)]; + } + return decoded; +} +exports.decode = decode; +/** + * Yeast: A tiny growing id generator. + * + * @returns {String} A unique id. + * @api public + */ +function yeast() { + const now = encode(+new Date()); + if (now !== prev) + return seed = 0, prev = now; + return now + '.' + encode(seed++); +} +exports.yeast = yeast; +// +// Map each character to its index. +// +for (; i < length; i++) + map[alphabet[i]] = i; - let i; - let len; +},{}],388:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalThisShim = void 0; +exports.globalThisShim = (() => { + if (typeof self !== "undefined") { + return self; + } + else if (typeof window !== "undefined") { + return window; + } + else { + return Function("return this")(); + } +})(); - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } +},{}],389:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0; +const socket_js_1 = require("./socket.js"); +Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); +exports.protocol = socket_js_1.Socket.protocol; +var transport_js_1 = require("./transport.js"); +Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_js_1.Transport; } }); +Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return transport_js_1.TransportError; } }); +var index_js_1 = require("./transports/index.js"); +Object.defineProperty(exports, "transports", { enumerable: true, get: function () { return index_js_1.transports; } }); +var util_js_1 = require("./util.js"); +Object.defineProperty(exports, "installTimerFunctions", { enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }); +var parseuri_js_1 = require("./contrib/parseuri.js"); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseuri_js_1.parse; } }); +var websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +Object.defineProperty(exports, "nextTick", { enumerable: true, get: function () { return websocket_constructor_js_1.nextTick; } }); + +},{"./contrib/parseuri.js":386,"./socket.js":390,"./transport.js":391,"./transports/index.js":392,"./transports/websocket-constructor.js":394,"./util.js":398}],390:[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.Socket = void 0; +const index_js_1 = require("./transports/index.js"); +const util_js_1 = require("./util.js"); +const parseqs_js_1 = require("./contrib/parseqs.js"); +const parseuri_js_1 = require("./contrib/parseuri.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const component_emitter_1 = require("@socket.io/component-emitter"); +const engine_io_parser_1 = require("engine.io-parser"); +const websocket_constructor_js_1 = require("./transports/websocket-constructor.js"); +const debug = (0, debug_1.default)("engine.io-client:socket"); // debug() +class Socket extends component_emitter_1.Emitter { + /** + * Socket constructor. + * + * @param {String|Object} uri - uri or options + * @param {Object} opts - options + */ + constructor(uri, opts = {}) { + super(); + this.binaryType = websocket_constructor_js_1.defaultBinaryType; + this.writeBuffer = []; + if (uri && "object" === typeof uri) { + opts = uri; + uri = null; + } + if (uri) { + uri = (0, parseuri_js_1.parse)(uri); + opts.hostname = uri.host; + opts.secure = uri.protocol === "https" || uri.protocol === "wss"; + opts.port = uri.port; + if (uri.query) + opts.query = uri.query; + } + else if (opts.host) { + opts.hostname = (0, parseuri_js_1.parse)(opts.host).host; + } + (0, util_js_1.installTimerFunctions)(this, opts); + this.secure = + null != opts.secure + ? opts.secure + : typeof location !== "undefined" && "https:" === location.protocol; + if (opts.hostname && !opts.port) { + // if no port is specified manually, use the protocol default + opts.port = this.secure ? "443" : "80"; + } + this.hostname = + opts.hostname || + (typeof location !== "undefined" ? location.hostname : "localhost"); + this.port = + opts.port || + (typeof location !== "undefined" && location.port + ? location.port + : this.secure + ? "443" + : "80"); + this.transports = opts.transports || [ + "polling", + "websocket", + "webtransport", + ]; + this.writeBuffer = []; + this.prevBufferLen = 0; + this.opts = Object.assign({ + path: "/engine.io", + agent: false, + withCredentials: false, + upgrade: true, + timestampParam: "t", + rememberUpgrade: false, + addTrailingSlash: true, + rejectUnauthorized: true, + perMessageDeflate: { + threshold: 1024, + }, + transportOptions: {}, + closeOnBeforeunload: false, + }, opts); + this.opts.path = + this.opts.path.replace(/\/$/, "") + + (this.opts.addTrailingSlash ? "/" : ""); + if (typeof this.opts.query === "string") { + this.opts.query = (0, parseqs_js_1.decode)(this.opts.query); + } + // set on handshake + this.id = null; + this.upgrades = null; + this.pingInterval = null; + this.pingTimeout = null; + // set on heartbeat + this.pingTimeoutTimer = null; + if (typeof addEventListener === "function") { + if (this.opts.closeOnBeforeunload) { + // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener + // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is + // closed/reloaded) + this.beforeunloadEventListener = () => { + if (this.transport) { + // silently close the transport + this.transport.removeAllListeners(); + this.transport.close(); + } + }; + addEventListener("beforeunload", this.beforeunloadEventListener, false); + } + if (this.hostname !== "localhost") { + this.offlineEventListener = () => { + this.onClose("transport close", { + description: "network connection lost", + }); + }; + addEventListener("offline", this.offlineEventListener, false); + } + } + this.open(); + } + /** + * Creates transport of the given type. + * + * @param {String} name - transport name + * @return {Transport} + * @private + */ + createTransport(name) { + debug('creating transport "%s"', name); + const query = Object.assign({}, this.opts.query); + // append engine.io protocol identifier + query.EIO = engine_io_parser_1.protocol; + // transport name + query.transport = name; + // session id if we already have one + if (this.id) + query.sid = this.id; + const opts = Object.assign({}, this.opts, { + query, + socket: this, + hostname: this.hostname, + secure: this.secure, + port: this.port, + }, this.opts.transportOptions[name]); + debug("options: %j", opts); + return new index_js_1.transports[name](opts); + } + /** + * Initializes transport to use and starts probe. + * + * @private + */ + open() { + let transport; + if (this.opts.rememberUpgrade && + Socket.priorWebsocketSuccess && + this.transports.indexOf("websocket") !== -1) { + transport = "websocket"; + } + else if (0 === this.transports.length) { + // Emit error on next tick so it can be listened to + this.setTimeoutFn(() => { + this.emitReserved("error", "No transports available"); + }, 0); + return; + } + else { + transport = this.transports[0]; + } + this.readyState = "opening"; + // Retry with the next transport if the transport is disabled (jsonp: false) + try { + transport = this.createTransport(transport); + } + catch (e) { + debug("error while creating transport: %s", e); + this.transports.shift(); + this.open(); + return; + } + transport.open(); + this.setTransport(transport); + } + /** + * Sets the current transport. Disables the existing one (if any). + * + * @private + */ + setTransport(transport) { + debug("setting transport %s", transport.name); + if (this.transport) { + debug("clearing existing transport %s", this.transport.name); + this.transport.removeAllListeners(); + } + // set up transport + this.transport = transport; + // set up transport listeners + transport + .on("drain", this.onDrain.bind(this)) + .on("packet", this.onPacket.bind(this)) + .on("error", this.onError.bind(this)) + .on("close", (reason) => this.onClose("transport close", reason)); + } + /** + * Probes a transport. + * + * @param {String} name - transport name + * @private + */ + probe(name) { + debug('probing transport "%s"', name); + let transport = this.createTransport(name); + let failed = false; + Socket.priorWebsocketSuccess = false; + const onTransportOpen = () => { + if (failed) + return; + debug('probe transport "%s" opened', name); + transport.send([{ type: "ping", data: "probe" }]); + transport.once("packet", (msg) => { + if (failed) + return; + if ("pong" === msg.type && "probe" === msg.data) { + debug('probe transport "%s" pong', name); + this.upgrading = true; + this.emitReserved("upgrading", transport); + if (!transport) + return; + Socket.priorWebsocketSuccess = "websocket" === transport.name; + debug('pausing current transport "%s"', this.transport.name); + this.transport.pause(() => { + if (failed) + return; + if ("closed" === this.readyState) + return; + debug("changing transport and sending upgrade packet"); + cleanup(); + this.setTransport(transport); + transport.send([{ type: "upgrade" }]); + this.emitReserved("upgrade", transport); + transport = null; + this.upgrading = false; + this.flush(); + }); + } + else { + debug('probe transport "%s" failed', name); + const err = new Error("probe error"); + // @ts-ignore + err.transport = transport.name; + this.emitReserved("upgradeError", err); + } + }); + }; + function freezeTransport() { + if (failed) + return; + // Any callback called by transport should be ignored since now + failed = true; + cleanup(); + transport.close(); + transport = null; + } + // Handle any error that happens while probing + const onerror = (err) => { + const error = new Error("probe error: " + err); + // @ts-ignore + error.transport = transport.name; + freezeTransport(); + debug('probe transport "%s" failed because of error: %s', name, err); + this.emitReserved("upgradeError", error); + }; + function onTransportClose() { + onerror("transport closed"); + } + // When the socket is closed while we're probing + function onclose() { + onerror("socket closed"); + } + // When the socket is upgraded while we're probing + function onupgrade(to) { + if (transport && to.name !== transport.name) { + debug('"%s" works - aborting "%s"', to.name, transport.name); + freezeTransport(); + } + } + // Remove all listeners on the transport and on self + const cleanup = () => { + transport.removeListener("open", onTransportOpen); + transport.removeListener("error", onerror); + transport.removeListener("close", onTransportClose); + this.off("close", onclose); + this.off("upgrading", onupgrade); + }; + transport.once("open", onTransportOpen); + transport.once("error", onerror); + transport.once("close", onTransportClose); + this.once("close", onclose); + this.once("upgrading", onupgrade); + if (this.upgrades.indexOf("webtransport") !== -1 && + name !== "webtransport") { + // favor WebTransport + this.setTimeoutFn(() => { + if (!failed) { + transport.open(); + } + }, 200); + } + else { + transport.open(); + } + } + /** + * Called when connection is deemed open. + * + * @private + */ + onOpen() { + debug("socket open"); + this.readyState = "open"; + Socket.priorWebsocketSuccess = "websocket" === this.transport.name; + this.emitReserved("open"); + this.flush(); + // we check for `readyState` in case an `open` + // listener already closed the socket + if ("open" === this.readyState && this.opts.upgrade) { + debug("starting upgrade probes"); + let i = 0; + const l = this.upgrades.length; + for (; i < l; i++) { + this.probe(this.upgrades[i]); + } + } + } + /** + * Handles a packet. + * + * @private + */ + onPacket(packet) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket receive: type "%s", data "%s"', packet.type, packet.data); + this.emitReserved("packet", packet); + // Socket is live - any packet counts + this.emitReserved("heartbeat"); + this.resetPingTimeout(); + switch (packet.type) { + case "open": + this.onHandshake(JSON.parse(packet.data)); + break; + case "ping": + this.sendPacket("pong"); + this.emitReserved("ping"); + this.emitReserved("pong"); + break; + case "error": + const err = new Error("server error"); + // @ts-ignore + err.code = packet.data; + this.onError(err); + break; + case "message": + this.emitReserved("data", packet.data); + this.emitReserved("message", packet.data); + break; + } + } + else { + debug('packet received with socket readyState "%s"', this.readyState); + } + } + /** + * Called upon handshake completion. + * + * @param {Object} data - handshake obj + * @private + */ + onHandshake(data) { + this.emitReserved("handshake", data); + this.id = data.sid; + this.transport.query.sid = data.sid; + this.upgrades = this.filterUpgrades(data.upgrades); + this.pingInterval = data.pingInterval; + this.pingTimeout = data.pingTimeout; + this.maxPayload = data.maxPayload; + this.onOpen(); + // In case open handler closes socket + if ("closed" === this.readyState) + return; + this.resetPingTimeout(); + } + /** + * Sets and resets ping timeout timer based on server pings. + * + * @private + */ + resetPingTimeout() { + this.clearTimeoutFn(this.pingTimeoutTimer); + this.pingTimeoutTimer = this.setTimeoutFn(() => { + this.onClose("ping timeout"); + }, this.pingInterval + this.pingTimeout); + if (this.opts.autoUnref) { + this.pingTimeoutTimer.unref(); + } + } + /** + * Called on `drain` event + * + * @private + */ + onDrain() { + this.writeBuffer.splice(0, this.prevBufferLen); + // setting prevBufferLen = 0 is very important + // for example, when upgrading, upgrade packet is sent over, + // and a nonzero prevBufferLen could cause problems on `drain` + this.prevBufferLen = 0; + if (0 === this.writeBuffer.length) { + this.emitReserved("drain"); + } + else { + this.flush(); + } + } + /** + * Flush write buffers. + * + * @private + */ + flush() { + if ("closed" !== this.readyState && + this.transport.writable && + !this.upgrading && + this.writeBuffer.length) { + const packets = this.getWritablePackets(); + debug("flushing %d packets in socket", packets.length); + this.transport.send(packets); + // keep track of current length of writeBuffer + // splice writeBuffer and callbackBuffer on `drain` + this.prevBufferLen = packets.length; + this.emitReserved("flush"); + } + } + /** + * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP + * long-polling) + * + * @private + */ + getWritablePackets() { + const shouldCheckPayloadSize = this.maxPayload && + this.transport.name === "polling" && + this.writeBuffer.length > 1; + if (!shouldCheckPayloadSize) { + return this.writeBuffer; + } + let payloadSize = 1; // first packet type + for (let i = 0; i < this.writeBuffer.length; i++) { + const data = this.writeBuffer[i].data; + if (data) { + payloadSize += (0, util_js_1.byteLength)(data); + } + if (i > 0 && payloadSize > this.maxPayload) { + debug("only send %d out of %d packets", i, this.writeBuffer.length); + return this.writeBuffer.slice(0, i); + } + payloadSize += 2; // separator + packet type + } + debug("payload size is %d (max: %d)", payloadSize, this.maxPayload); + return this.writeBuffer; + } + /** + * Sends a message. + * + * @param {String} msg - message. + * @param {Object} options. + * @param {Function} callback function. + * @return {Socket} for chaining. + */ + write(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + send(msg, options, fn) { + this.sendPacket("message", msg, options, fn); + return this; + } + /** + * Sends a packet. + * + * @param {String} type: packet type. + * @param {String} data. + * @param {Object} options. + * @param {Function} fn - callback function. + * @private + */ + sendPacket(type, data, options, fn) { + if ("function" === typeof data) { + fn = data; + data = undefined; + } + if ("function" === typeof options) { + fn = options; + options = null; + } + if ("closing" === this.readyState || "closed" === this.readyState) { + return; + } + options = options || {}; + options.compress = false !== options.compress; + const packet = { + type: type, + data: data, + options: options, + }; + this.emitReserved("packetCreate", packet); + this.writeBuffer.push(packet); + if (fn) + this.once("flush", fn); + this.flush(); + } + /** + * Closes the connection. + */ + close() { + const close = () => { + this.onClose("forced close"); + debug("socket closing - telling transport to close"); + this.transport.close(); + }; + const cleanupAndClose = () => { + this.off("upgrade", cleanupAndClose); + this.off("upgradeError", cleanupAndClose); + close(); + }; + const waitForUpgrade = () => { + // wait for upgrade to finish since we can't send packets while pausing a transport + this.once("upgrade", cleanupAndClose); + this.once("upgradeError", cleanupAndClose); + }; + if ("opening" === this.readyState || "open" === this.readyState) { + this.readyState = "closing"; + if (this.writeBuffer.length) { + this.once("drain", () => { + if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + }); + } + else if (this.upgrading) { + waitForUpgrade(); + } + else { + close(); + } + } + return this; + } + /** + * Called upon transport error + * + * @private + */ + onError(err) { + debug("socket error %j", err); + Socket.priorWebsocketSuccess = false; + this.emitReserved("error", err); + this.onClose("transport error", err); + } + /** + * Called upon transport close. + * + * @private + */ + onClose(reason, description) { + if ("opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState) { + debug('socket close with reason: "%s"', reason); + // clear timers + this.clearTimeoutFn(this.pingTimeoutTimer); + // stop event from firing again for transport + this.transport.removeAllListeners("close"); + // ensure transport won't stay open + this.transport.close(); + // ignore further transport communication + this.transport.removeAllListeners(); + if (typeof removeEventListener === "function") { + removeEventListener("beforeunload", this.beforeunloadEventListener, false); + removeEventListener("offline", this.offlineEventListener, false); + } + // set ready state + this.readyState = "closed"; + // clear session id + this.id = null; + // emit close event + this.emitReserved("close", reason, description); + // clean buffers after, so users can still + // grab the buffers on `close` event + this.writeBuffer = []; + this.prevBufferLen = 0; + } + } + /** + * Filters upgrades, returning only those matching client transports. + * + * @param {Array} upgrades - server upgrades + * @private + */ + filterUpgrades(upgrades) { + const filteredUpgrades = []; + let i = 0; + const j = upgrades.length; + for (; i < j; i++) { + if (~this.transports.indexOf(upgrades[i])) + filteredUpgrades.push(upgrades[i]); + } + return filteredUpgrades; + } +} +exports.Socket = Socket; +Socket.protocol = engine_io_parser_1.protocol; - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } +},{"./contrib/parseqs.js":385,"./contrib/parseuri.js":386,"./transports/index.js":392,"./transports/websocket-constructor.js":394,"./util.js":398,"@socket.io/component-emitter":23,"debug":361,"engine.io-parser":403}],391:[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.Transport = exports.TransportError = void 0; +const engine_io_parser_1 = require("engine.io-parser"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("./util.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const parseqs_js_1 = require("./contrib/parseqs.js"); +const debug = (0, debug_1.default)("engine.io-client:transport"); // debug() +class TransportError extends Error { + constructor(reason, description, context) { + super(reason); + this.description = description; + this.context = context; + this.type = "TransportError"; + } +} +exports.TransportError = TransportError; +class Transport extends component_emitter_1.Emitter { + /** + * Transport abstract constructor. + * + * @param {Object} opts - options + * @protected + */ + constructor(opts) { + super(); + this.writable = false; + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.query = opts.query; + this.socket = opts.socket; + } + /** + * Emits an error. + * + * @param {String} reason + * @param description + * @param context - the error context + * @return {Transport} for chaining + * @protected + */ + onError(reason, description, context) { + super.emitReserved("error", new TransportError(reason, description, context)); + return this; + } + /** + * Opens the transport. + */ + open() { + this.readyState = "opening"; + this.doOpen(); + return this; + } + /** + * Closes the transport. + */ + close() { + if (this.readyState === "opening" || this.readyState === "open") { + this.doClose(); + this.onClose(); + } + return this; + } + /** + * Sends multiple packets. + * + * @param {Array} packets + */ + send(packets) { + if (this.readyState === "open") { + this.write(packets); + } + else { + // this might happen if the transport was silently closed in the beforeunload event handler + debug("transport is not open, discarding packets"); + } + } + /** + * Called upon open + * + * @protected + */ + onOpen() { + this.readyState = "open"; + this.writable = true; + super.emitReserved("open"); + } + /** + * Called with data. + * + * @param {String} data + * @protected + */ + onData(data) { + const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType); + this.onPacket(packet); + } + /** + * Called with a decoded packet. + * + * @protected + */ + onPacket(packet) { + super.emitReserved("packet", packet); + } + /** + * Called upon close. + * + * @protected + */ + onClose(details) { + this.readyState = "closed"; + super.emitReserved("close", details); + } + /** + * Pauses the transport, in order not to lose packets during an upgrade. + * + * @param onPause + */ + pause(onPause) { } + createUri(schema, query = {}) { + return (schema + + "://" + + this._hostname() + + this._port() + + this.opts.path + + this._query(query)); + } + _hostname() { + const hostname = this.opts.hostname; + return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; + } + _port() { + if (this.opts.port && + ((this.opts.secure && Number(this.opts.port !== 443)) || + (!this.opts.secure && Number(this.opts.port) !== 80))) { + return ":" + this.opts.port; + } + else { + return ""; + } + } + _query(query) { + const encodedQuery = (0, parseqs_js_1.encode)(query); + return encodedQuery.length ? "?" + encodedQuery : ""; + } +} +exports.Transport = Transport; - return false; - } +},{"./contrib/parseqs.js":385,"./util.js":398,"@socket.io/component-emitter":23,"debug":361,"engine.io-parser":403}],392:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.transports = void 0; +const polling_js_1 = require("./polling.js"); +const websocket_js_1 = require("./websocket.js"); +const webtransport_js_1 = require("./webtransport.js"); +exports.transports = { + websocket: websocket_js_1.WS, + webtransport: webtransport_js_1.WT, + polling: polling_js_1.Polling, +}; - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } +},{"./polling.js":393,"./websocket.js":395,"./webtransport.js":396}],393:[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.Request = exports.Polling = void 0; +const transport_js_1 = require("../transport.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const yeast_js_1 = require("../contrib/yeast.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const xmlhttprequest_js_1 = require("./xmlhttprequest.js"); +const component_emitter_1 = require("@socket.io/component-emitter"); +const util_js_1 = require("../util.js"); +const globalThis_js_1 = require("../globalThis.js"); +const debug = (0, debug_1.default)("engine.io-client:polling"); // debug() +function empty() { } +const hasXHR2 = (function () { + const xhr = new xmlhttprequest_js_1.XHR({ + xdomain: false, + }); + return null != xhr.responseType; +})(); +class Polling extends transport_js_1.Transport { + /** + * XHR Polling constructor. + * + * @param {Object} opts + * @package + */ + constructor(opts) { + super(opts); + this.polling = false; + if (typeof location !== "undefined") { + const isSSL = "https:" === location.protocol; + let port = location.port; + // some user agents have empty `location.port` + if (!port) { + port = isSSL ? "443" : "80"; + } + this.xd = + (typeof location !== "undefined" && + opts.hostname !== location.hostname) || + port !== opts.port; + } + /** + * XHR supports binary + */ + const forceBase64 = opts && opts.forceBase64; + this.supportsBinary = hasXHR2 && !forceBase64; + if (this.opts.withCredentials) { + this.cookieJar = (0, xmlhttprequest_js_1.createCookieJar)(); + } + } + get name() { + return "polling"; + } + /** + * Opens the socket (triggers polling). We write a PING message to determine + * when the transport is open. + * + * @protected + */ + doOpen() { + this.poll(); + } + /** + * Pauses polling. + * + * @param {Function} onPause - callback upon buffers are flushed and transport is paused + * @package + */ + pause(onPause) { + this.readyState = "pausing"; + const pause = () => { + debug("paused"); + this.readyState = "paused"; + onPause(); + }; + if (this.polling || !this.writable) { + let total = 0; + if (this.polling) { + debug("we are currently polling - waiting to pause"); + total++; + this.once("pollComplete", function () { + debug("pre-pause polling complete"); + --total || pause(); + }); + } + if (!this.writable) { + debug("we are currently writing - waiting to pause"); + total++; + this.once("drain", function () { + debug("pre-pause writing complete"); + --total || pause(); + }); + } + } + else { + pause(); + } + } + /** + * Starts polling cycle. + * + * @private + */ + poll() { + debug("polling"); + this.polling = true; + this.doPoll(); + this.emitReserved("poll"); + } + /** + * Overloads onData to detect payloads. + * + * @protected + */ + onData(data) { + debug("polling got data %s", data); + const callback = (packet) => { + // if its the first message we consider the transport open + if ("opening" === this.readyState && packet.type === "open") { + this.onOpen(); + } + // if its a close packet, we close the ongoing requests + if ("close" === packet.type) { + this.onClose({ description: "transport closed by the server" }); + return false; + } + // otherwise bypass onData and handle the message + this.onPacket(packet); + }; + // decode payload + (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback); + // if an event did not trigger closing + if ("closed" !== this.readyState) { + // if we got data we're not polling + this.polling = false; + this.emitReserved("pollComplete"); + if ("open" === this.readyState) { + this.poll(); + } + else { + debug('ignoring poll - transport state "%s"', this.readyState); + } + } + } + /** + * For polling, send a close packet. + * + * @protected + */ + doClose() { + const close = () => { + debug("writing close packet"); + this.write([{ type: "close" }]); + }; + if ("open" === this.readyState) { + debug("transport open - closing"); + close(); + } + else { + // in case we're trying to close while + // handshaking is in progress (GH-164) + debug("transport not open - deferring close"); + this.once("open", close); + } + } + /** + * Writes a packets payload. + * + * @param {Array} packets - data packets + * @protected + */ + write(packets) { + this.writable = false; + (0, engine_io_parser_1.encodePayload)(packets, (data) => { + this.doWrite(data, () => { + this.writable = true; + this.emitReserved("drain"); + }); + }); + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "https" : "http"; + const query = this.query || {}; + // cache busting is forced + if (false !== this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + if (!this.supportsBinary && !query.sid) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Creates a request. + * + * @param {String} method + * @private + */ + request(opts = {}) { + Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts); + return new Request(this.uri(), opts); + } + /** + * Sends data. + * + * @param {String} data to send. + * @param {Function} called upon flush. + * @private + */ + doWrite(data, fn) { + const req = this.request({ + method: "POST", + data: data, + }); + req.on("success", fn); + req.on("error", (xhrStatus, context) => { + this.onError("xhr post error", xhrStatus, context); + }); + } + /** + * Starts a poll cycle. + * + * @private + */ + doPoll() { + debug("xhr poll"); + const req = this.request(); + req.on("data", this.onData.bind(this)); + req.on("error", (xhrStatus, context) => { + this.onError("xhr poll error", xhrStatus, context); + }); + this.pollXhr = req; + } +} +exports.Polling = Polling; +class Request extends component_emitter_1.Emitter { + /** + * Request constructor + * + * @param {Object} options + * @package + */ + constructor(uri, opts) { + super(); + (0, util_js_1.installTimerFunctions)(this, opts); + this.opts = opts; + this.method = opts.method || "GET"; + this.uri = uri; + this.data = undefined !== opts.data ? opts.data : null; + this.create(); + } + /** + * Creates the XHR object and sends the request. + * + * @private + */ + create() { + var _a; + const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); + opts.xdomain = !!this.opts.xd; + const xhr = (this.xhr = new xmlhttprequest_js_1.XHR(opts)); + try { + debug("xhr open %s: %s", this.method, this.uri); + xhr.open(this.method, this.uri, true); + try { + if (this.opts.extraHeaders) { + xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); + for (let i in this.opts.extraHeaders) { + if (this.opts.extraHeaders.hasOwnProperty(i)) { + xhr.setRequestHeader(i, this.opts.extraHeaders[i]); + } + } + } + } + catch (e) { } + if ("POST" === this.method) { + try { + xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); + } + catch (e) { } + } + try { + xhr.setRequestHeader("Accept", "*/*"); + } + catch (e) { } + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); + // ie6 check + if ("withCredentials" in xhr) { + xhr.withCredentials = this.opts.withCredentials; + } + if (this.opts.requestTimeout) { + xhr.timeout = this.opts.requestTimeout; + } + xhr.onreadystatechange = () => { + var _a; + if (xhr.readyState === 3) { + (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr); + } + if (4 !== xhr.readyState) + return; + if (200 === xhr.status || 1223 === xhr.status) { + this.onLoad(); + } + else { + // make sure the `error` event handler that's user-set + // does not throw in the same tick and gets caught here + this.setTimeoutFn(() => { + this.onError(typeof xhr.status === "number" ? xhr.status : 0); + }, 0); + } + }; + debug("xhr data %s", this.data); + xhr.send(this.data); + } + catch (e) { + // Need to defer since .create() is called directly from the constructor + // and thus the 'error' event can only be only bound *after* this exception + // occurs. Therefore, also, we cannot throw here at all. + this.setTimeoutFn(() => { + this.onError(e); + }, 0); + return; + } + if (typeof document !== "undefined") { + this.index = Request.requestsCount++; + Request.requests[this.index] = this; + } + } + /** + * Called upon error. + * + * @private + */ + onError(err) { + this.emitReserved("error", err, this.xhr); + this.cleanup(true); + } + /** + * Cleans up house. + * + * @private + */ + cleanup(fromError) { + if ("undefined" === typeof this.xhr || null === this.xhr) { + return; + } + this.xhr.onreadystatechange = empty; + if (fromError) { + try { + this.xhr.abort(); + } + catch (e) { } + } + if (typeof document !== "undefined") { + delete Request.requests[this.index]; + } + this.xhr = null; + } + /** + * Called upon load. + * + * @private + */ + onLoad() { + const data = this.xhr.responseText; + if (data !== null) { + this.emitReserved("data", data); + this.emitReserved("success"); + this.cleanup(); + } + } + /** + * Aborts the request. + * + * @package + */ + abort() { + this.cleanup(); + } +} +exports.Request = Request; +Request.requestsCount = 0; +Request.requests = {}; +/** + * Aborts pending requests when unloading the window. This is needed to prevent + * memory leaks (e.g. when using IE) and to ensure that no spurious error is + * emitted. + */ +if (typeof document !== "undefined") { + // @ts-ignore + if (typeof attachEvent === "function") { + // @ts-ignore + attachEvent("onunload", unloadHandler); + } + else if (typeof addEventListener === "function") { + const terminationEvent = "onpagehide" in globalThis_js_1.globalThisShim ? "pagehide" : "unload"; + addEventListener(terminationEvent, unloadHandler, false); + } +} +function unloadHandler() { + for (let i in Request.requests) { + if (Request.requests.hasOwnProperty(i)) { + Request.requests[i].abort(); + } + } +} - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } +},{"../contrib/yeast.js":387,"../globalThis.js":388,"../transport.js":391,"../util.js":398,"./xmlhttprequest.js":397,"@socket.io/component-emitter":23,"debug":361,"engine.io-parser":403}],394:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0; +const globalThis_js_1 = require("../globalThis.js"); +exports.nextTick = (() => { + const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function"; + if (isPromiseAvailable) { + return (cb) => Promise.resolve().then(cb); + } + else { + return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); + } +})(); +exports.WebSocket = globalThis_js_1.globalThisShim.WebSocket || globalThis_js_1.globalThisShim.MozWebSocket; +exports.usingBrowserWebSocket = true; +exports.defaultBinaryType = "arraybuffer"; - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } +},{"../globalThis.js":388}],395:[function(require,module,exports){ +(function (Buffer){(function (){ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WS = void 0; +const transport_js_1 = require("../transport.js"); +const yeast_js_1 = require("../contrib/yeast.js"); +const util_js_1 = require("../util.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const debug_1 = __importDefault(require("debug")); // debug() +const engine_io_parser_1 = require("engine.io-parser"); +const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug() +// detect ReactNative environment +const isReactNative = typeof navigator !== "undefined" && + typeof navigator.product === "string" && + navigator.product.toLowerCase() === "reactnative"; +class WS extends transport_js_1.Transport { + /** + * WebSocket transport constructor. + * + * @param {Object} opts - connection options + * @protected + */ + constructor(opts) { + super(opts); + this.supportsBinary = !opts.forceBase64; + } + get name() { + return "websocket"; + } + doOpen() { + if (!this.check()) { + // let probe timeout + return; + } + const uri = this.uri(); + const protocols = this.opts.protocols; + // React Native only supports the 'headers' option, and will print a warning if anything else is passed + const opts = isReactNative + ? {} + : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); + if (this.opts.extraHeaders) { + opts.headers = this.opts.extraHeaders; + } + try { + this.ws = + websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative + ? protocols + ? new websocket_constructor_js_1.WebSocket(uri, protocols) + : new websocket_constructor_js_1.WebSocket(uri) + : new websocket_constructor_js_1.WebSocket(uri, protocols, opts); + } + catch (err) { + return this.emitReserved("error", err); + } + this.ws.binaryType = this.socket.binaryType; + this.addEventListeners(); + } + /** + * Adds event listeners to the socket + * + * @private + */ + addEventListeners() { + this.ws.onopen = () => { + if (this.opts.autoUnref) { + this.ws._socket.unref(); + } + this.onOpen(); + }; + this.ws.onclose = (closeEvent) => this.onClose({ + description: "websocket connection closed", + context: closeEvent, + }); + this.ws.onmessage = (ev) => this.onData(ev.data); + this.ws.onerror = (e) => this.onError("websocket error", e); + } + write(packets) { + this.writable = false; + // encodePacket efficient as it uses WS framing + // no need for encodePayload + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => { + // always create a new object (GH-437) + const opts = {}; + if (!websocket_constructor_js_1.usingBrowserWebSocket) { + if (packet.options) { + opts.compress = packet.options.compress; + } + if (this.opts.perMessageDeflate) { + const len = + // @ts-ignore + "string" === typeof data ? Buffer.byteLength(data) : data.length; + if (len < this.opts.perMessageDeflate.threshold) { + opts.compress = false; + } + } + } + // Sometimes the websocket has already been closed but the browser didn't + // have a chance of informing us about it yet, in that case send will + // throw an error + try { + if (websocket_constructor_js_1.usingBrowserWebSocket) { + // TypeError is thrown when passing the second argument on Safari + this.ws.send(data); + } + else { + this.ws.send(data, opts); + } + } + catch (e) { + debug("websocket closed before onclose event"); + } + if (lastPacket) { + // fake drain + // defer to next tick to allow Socket to clear writeBuffer + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + if (typeof this.ws !== "undefined") { + this.ws.close(); + this.ws = null; + } + } + /** + * Generates uri for connection. + * + * @private + */ + uri() { + const schema = this.opts.secure ? "wss" : "ws"; + const query = this.query || {}; + // append timestamp to URI + if (this.opts.timestampRequests) { + query[this.opts.timestampParam] = (0, yeast_js_1.yeast)(); + } + // communicate binary support capabilities + if (!this.supportsBinary) { + query.b64 = 1; + } + return this.createUri(schema, query); + } + /** + * Feature detection for WebSocket. + * + * @return {Boolean} whether this transport is available. + * @private + */ + check() { + return !!websocket_constructor_js_1.WebSocket; + } +} +exports.WS = WS; - createDebug.enable(createDebug.load()); +}).call(this)}).call(this,require("buffer").Buffer) +},{"../contrib/yeast.js":387,"../transport.js":391,"../util.js":398,"./websocket-constructor.js":394,"buffer":53,"debug":361,"engine.io-parser":403}],396:[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.WT = void 0; +const transport_js_1 = require("../transport.js"); +const websocket_constructor_js_1 = require("./websocket-constructor.js"); +const engine_io_parser_1 = require("engine.io-parser"); +const debug_1 = __importDefault(require("debug")); // debug() +const debug = (0, debug_1.default)("engine.io-client:webtransport"); // debug() +class WT extends transport_js_1.Transport { + get name() { + return "webtransport"; + } + doOpen() { + // @ts-ignore + if (typeof WebTransport !== "function") { + return; + } + // @ts-ignore + this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); + this.transport.closed + .then(() => { + debug("transport closed gracefully"); + this.onClose(); + }) + .catch((err) => { + debug("transport closed due to %s", err); + this.onError("webtransport error", err); + }); + // note: we could have used async/await, but that would require some additional polyfills + this.transport.ready.then(() => { + this.transport.createBidirectionalStream().then((stream) => { + const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType); + const reader = stream.readable.pipeThrough(decoderStream).getReader(); + const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)(); + encoderStream.readable.pipeTo(stream.writable); + this.writer = encoderStream.writable.getWriter(); + const read = () => { + reader + .read() + .then(({ done, value }) => { + if (done) { + debug("session is closed"); + return; + } + debug("received chunk: %o", value); + this.onPacket(value); + read(); + }) + .catch((err) => { + debug("an error occurred while reading: %s", err); + }); + }; + read(); + const packet = { type: "open" }; + if (this.query.sid) { + packet.data = `{"sid":"${this.query.sid}"}`; + } + this.writer.write(packet).then(() => this.onOpen()); + }); + }); + } + write(packets) { + this.writable = false; + for (let i = 0; i < packets.length; i++) { + const packet = packets[i]; + const lastPacket = i === packets.length - 1; + this.writer.write(packet).then(() => { + if (lastPacket) { + (0, websocket_constructor_js_1.nextTick)(() => { + this.writable = true; + this.emitReserved("drain"); + }, this.setTimeoutFn); + } + }); + } + } + doClose() { + var _a; + (_a = this.transport) === null || _a === void 0 ? void 0 : _a.close(); + } +} +exports.WT = WT; - return createDebug; +},{"../transport.js":391,"./websocket-constructor.js":394,"debug":361,"engine.io-parser":403}],397:[function(require,module,exports){ +"use strict"; +// browser shim for xmlhttprequest module +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createCookieJar = exports.XHR = void 0; +const has_cors_js_1 = require("../contrib/has-cors.js"); +const globalThis_js_1 = require("../globalThis.js"); +function XHR(opts) { + const xdomain = opts.xdomain; + // XMLHttpRequest can be disabled on IE + try { + if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) { + return new XMLHttpRequest(); + } + } + catch (e) { } + if (!xdomain) { + try { + return new globalThis_js_1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); + } + catch (e) { } + } } +exports.XHR = XHR; +function createCookieJar() { } +exports.createCookieJar = createCookieJar; -module.exports = setup; +},{"../contrib/has-cors.js":384,"../globalThis.js":388}],398:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.byteLength = exports.installTimerFunctions = exports.pick = void 0; +const globalThis_js_1 = require("./globalThis.js"); +function pick(obj, ...attr) { + return attr.reduce((acc, k) => { + if (obj.hasOwnProperty(k)) { + acc[k] = obj[k]; + } + return acc; + }, {}); +} +exports.pick = pick; +// Keep a reference to the real timeout functions so they can be used when overridden +const NATIVE_SET_TIMEOUT = globalThis_js_1.globalThisShim.setTimeout; +const NATIVE_CLEAR_TIMEOUT = globalThis_js_1.globalThisShim.clearTimeout; +function installTimerFunctions(obj, opts) { + if (opts.useNativeTimers) { + obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.globalThisShim); + } + else { + obj.setTimeoutFn = globalThis_js_1.globalThisShim.setTimeout.bind(globalThis_js_1.globalThisShim); + obj.clearTimeoutFn = globalThis_js_1.globalThisShim.clearTimeout.bind(globalThis_js_1.globalThisShim); + } +} +exports.installTimerFunctions = installTimerFunctions; +// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64) +const BASE64_OVERHEAD = 1.33; +// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9 +function byteLength(obj) { + if (typeof obj === "string") { + return utf8Length(obj); + } + // arraybuffer or blob + return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); +} +exports.byteLength = byteLength; +function utf8Length(str) { + let c = 0, length = 0; + for (let i = 0, l = str.length; i < l; i++) { + c = str.charCodeAt(i); + if (c < 0x80) { + length += 1; + } + else if (c < 0x800) { + length += 2; + } + else if (c < 0xd800 || c >= 0xe000) { + length += 3; + } + else { + i++; + length += 4; + } + } + return length; +} -},{"ms":487}],406:[function(require,module,exports){ +},{"./globalThis.js":388}],399:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0; @@ -22953,7 +22607,7 @@ Object.keys(PACKET_TYPES).forEach((key) => { const ERROR_PACKET = { type: "error", data: "parser error" }; exports.ERROR_PACKET = ERROR_PACKET; -},{}],407:[function(require,module,exports){ +},{}],400:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decode = exports.encode = void 0; @@ -23003,7 +22657,7 @@ const decode = (base64) => { }; exports.decode = decode; -},{}],408:[function(require,module,exports){ +},{}],401:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodePacket = void 0; @@ -23071,11 +22725,10 @@ const mapBinary = (data, binaryType) => { } }; -},{"./commons.js":406,"./contrib/base64-arraybuffer.js":407}],409:[function(require,module,exports){ +},{"./commons.js":399,"./contrib/base64-arraybuffer.js":400}],402:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.encodePacket = void 0; -exports.encodePacketToBinary = encodePacketToBinary; +exports.encodePacket = exports.encodePacketToBinary = void 0; const commons_js_1 = require("./commons.js"); const withNativeBlob = typeof Blob === "function" || (typeof Blob !== "undefined" && @@ -23144,13 +22797,12 @@ function encodePacketToBinary(packet, callback) { callback(TEXT_ENCODER.encode(encoded)); }); } +exports.encodePacketToBinary = encodePacketToBinary; -},{"./commons.js":406}],410:[function(require,module,exports){ +},{"./commons.js":399}],403:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; -exports.createPacketEncoderStream = createPacketEncoderStream; -exports.createPacketDecoderStream = createPacketDecoderStream; +exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0; const encodePacket_js_1 = require("./encodePacket.js"); Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }); const decodePacket_js_1 = require("./decodePacket.js"); @@ -23187,6 +22839,7 @@ const decodePayload = (encodedPayload, binaryType) => { }; exports.decodePayload = decodePayload; function createPacketEncoderStream() { + // @ts-expect-error return new TransformStream({ transform(packet, controller) { (0, encodePacket_js_1.encodePacketToBinary)(packet, (encodedPacket) => { @@ -23219,6 +22872,7 @@ function createPacketEncoderStream() { }, }); } +exports.createPacketEncoderStream = createPacketEncoderStream; let TEXT_DECODER; function totalLength(chunks) { return chunks.reduce((acc, chunk) => acc + chunk.length, 0); @@ -23246,14 +22900,15 @@ function createPacketDecoderStream(maxPayload, binaryType) { TEXT_DECODER = new TextDecoder(); } const chunks = []; - let state = 0 /* State.READ_HEADER */; + let state = 0 /* READ_HEADER */; let expectedLength = -1; let isBinary = false; + // @ts-expect-error return new TransformStream({ transform(chunk, controller) { chunks.push(chunk); while (true) { - if (state === 0 /* State.READ_HEADER */) { + if (state === 0 /* READ_HEADER */) { if (totalLength(chunks) < 1) { break; } @@ -23261,24 +22916,24 @@ function createPacketDecoderStream(maxPayload, binaryType) { isBinary = (header[0] & 0x80) === 0x80; expectedLength = header[0] & 0x7f; if (expectedLength < 126) { - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else if (expectedLength === 126) { - state = 1 /* State.READ_EXTENDED_LENGTH_16 */; + state = 1 /* READ_EXTENDED_LENGTH_16 */; } else { - state = 2 /* State.READ_EXTENDED_LENGTH_64 */; + state = 2 /* READ_EXTENDED_LENGTH_64 */; } } - else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) { + else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) { if (totalLength(chunks) < 2) { break; } const headerArray = concatChunks(chunks, 2); expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } - else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) { + else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) { if (totalLength(chunks) < 8) { break; } @@ -23291,7 +22946,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { break; } expectedLength = n * Math.pow(2, 32) + view.getUint32(4); - state = 3 /* State.READ_PAYLOAD */; + state = 3 /* READ_PAYLOAD */; } else { if (totalLength(chunks) < expectedLength) { @@ -23299,7 +22954,7 @@ function createPacketDecoderStream(maxPayload, binaryType) { } const data = concatChunks(chunks, expectedLength); controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType)); - state = 0 /* State.READ_HEADER */; + state = 0 /* READ_HEADER */; } if (expectedLength === 0 || expectedLength > maxPayload) { controller.enqueue(commons_js_1.ERROR_PACKET); @@ -23309,13 +22964,16 @@ function createPacketDecoderStream(maxPayload, binaryType) { }, }); } +exports.createPacketDecoderStream = createPacketDecoderStream; exports.protocol = 4; -},{"./commons.js":406,"./decodePacket.js":408,"./encodePacket.js":409}],411:[function(require,module,exports){ +},{"./commons.js":399,"./decodePacket.js":401,"./encodePacket.js":402}],404:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); + /** @type {import('.')} */ -var $defineProperty = Object.defineProperty || false; +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false; if ($defineProperty) { try { $defineProperty({}, 'a', { value: 1 }); @@ -23327,49 +22985,49 @@ if ($defineProperty) { module.exports = $defineProperty; -},{}],412:[function(require,module,exports){ +},{"get-intrinsic":419}],405:[function(require,module,exports){ 'use strict'; /** @type {import('./eval')} */ module.exports = EvalError; -},{}],413:[function(require,module,exports){ +},{}],406:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ module.exports = Error; -},{}],414:[function(require,module,exports){ +},{}],407:[function(require,module,exports){ 'use strict'; /** @type {import('./range')} */ module.exports = RangeError; -},{}],415:[function(require,module,exports){ +},{}],408:[function(require,module,exports){ 'use strict'; /** @type {import('./ref')} */ module.exports = ReferenceError; -},{}],416:[function(require,module,exports){ +},{}],409:[function(require,module,exports){ 'use strict'; /** @type {import('./syntax')} */ module.exports = SyntaxError; -},{}],417:[function(require,module,exports){ +},{}],410:[function(require,module,exports){ 'use strict'; /** @type {import('./type')} */ module.exports = TypeError; -},{}],418:[function(require,module,exports){ +},{}],411:[function(require,module,exports){ 'use strict'; /** @type {import('./uri')} */ module.exports = URIError; -},{}],419:[function(require,module,exports){ +},{}],412:[function(require,module,exports){ (function (process){(function (){ 'use strict'; @@ -23562,13 +23220,7 @@ if (require('has-symbols')() || require('has-symbols/shams')()) { } }).call(this)}).call(this,require('_process')) -},{"_process":503,"call-bind/callBound":60,"get-intrinsic":427,"has-symbols":435,"has-symbols/shams":436,"is-arguments":455,"is-map":461,"is-set":465,"is-string":467,"isarray":471,"stop-iteration-iterator":529}],420:[function(require,module,exports){ -'use strict'; - -/** @type {import('.')} */ -module.exports = Object; - -},{}],421:[function(require,module,exports){ +},{"_process":484,"call-bind/callBound":54,"get-intrinsic":419,"has-symbols":424,"has-symbols/shams":425,"is-arguments":444,"is-map":450,"is-set":454,"is-string":456,"isarray":460,"stop-iteration-iterator":502}],413:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keccak512 = exports.keccak384 = exports.keccak256 = exports.keccak224 = void 0; @@ -23583,17 +23235,13 @@ exports.keccak256 = (() => { exports.keccak384 = (0, utils_js_1.wrapHash)(sha3_1.keccak_384); exports.keccak512 = (0, utils_js_1.wrapHash)(sha3_1.keccak_512); -},{"./utils.js":422,"@noble/hashes/sha3":21}],422:[function(require,module,exports){ +},{"./utils.js":414,"@noble/hashes/sha3":21}],414:[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.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; -exports.bytesToUtf8 = bytesToUtf8; -exports.hexToBytes = hexToBytes; -exports.equalsBytes = equalsBytes; -exports.wrapHash = wrapHash; +exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0; const _assert_1 = __importDefault(require("@noble/hashes/_assert")); const utils_1 = require("@noble/hashes/utils"); const assertBool = _assert_1.default.bool; @@ -23613,10 +23261,12 @@ function bytesToUtf8(data) { } return new TextDecoder().decode(data); } +exports.bytesToUtf8 = bytesToUtf8; function hexToBytes(data) { const sliced = data.startsWith("0x") ? data.substring(2) : data; return (0, utils_1.hexToBytes)(sliced); } +exports.hexToBytes = hexToBytes; // buf.equals(buf2) -> equalsBytes(buf, buf2) function equalsBytes(a, b) { if (a.length !== b.length) { @@ -23629,6 +23279,7 @@ function equalsBytes(a, b) { } return true; } +exports.equalsBytes = equalsBytes; // Internal utils function wrapHash(hash) { return (msg) => { @@ -23636,8 +23287,20 @@ function wrapHash(hash) { return hash(msg); }; } +exports.wrapHash = wrapHash; +// TODO(v3): switch away from node crypto, remove this unnecessary variable. +exports.crypto = (() => { + const webCrypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined; + const nodeRequire = typeof module !== "undefined" && + typeof module.require === "function" && + module.require.bind(module); + return { + node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined, + web: webCrypto + }; +})(); -},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],423:[function(require,module,exports){ +},{"@noble/hashes/_assert":18,"@noble/hashes/utils":22}],415:[function(require,module,exports){ 'use strict'; var isCallable = require('is-callable'); @@ -23701,7 +23364,7 @@ var forEach = function forEach(list, iterator, thisArg) { module.exports = forEach; -},{"is-callable":459}],424:[function(require,module,exports){ +},{"is-callable":448}],416:[function(require,module,exports){ 'use strict'; /* eslint no-invalid-this: 1 */ @@ -23787,14 +23450,14 @@ module.exports = function bind(that) { return bound; }; -},{}],425:[function(require,module,exports){ +},{}],417:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); module.exports = Function.prototype.bind || implementation; -},{"./implementation":424}],426:[function(require,module,exports){ +},{"./implementation":416}],418:[function(require,module,exports){ 'use strict'; var functionsHaveNames = function functionsHaveNames() { @@ -23827,13 +23490,11 @@ functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() module.exports = functionsHaveNames; -},{}],427:[function(require,module,exports){ +},{}],419:[function(require,module,exports){ 'use strict'; var undefined; -var $Object = require('es-object-atoms'); - var $Error = require('es-errors'); var $EvalError = require('es-errors/eval'); var $RangeError = require('es-errors/range'); @@ -23842,14 +23503,6 @@ var $SyntaxError = require('es-errors/syntax'); var $TypeError = require('es-errors/type'); var $URIError = require('es-errors/uri'); -var abs = require('math-intrinsics/abs'); -var floor = require('math-intrinsics/floor'); -var max = require('math-intrinsics/max'); -var min = require('math-intrinsics/min'); -var pow = require('math-intrinsics/pow'); -var round = require('math-intrinsics/round'); -var sign = require('math-intrinsics/sign'); - var $Function = Function; // eslint-disable-next-line consistent-return @@ -23859,8 +23512,14 @@ var getEvalledConstructor = function (expressionSyntax) { } catch (e) {} }; -var $gOPD = require('gopd'); -var $defineProperty = require('es-define-property'); +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} var throwTypeError = function () { throw new $TypeError(); @@ -23883,13 +23542,13 @@ var ThrowTypeError = $gOPD : throwTypeError; var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); -var getProto = require('get-proto'); -var $ObjectGPO = require('get-proto/Object.getPrototypeOf'); -var $ReflectGPO = require('get-proto/Reflect.getPrototypeOf'); - -var $apply = require('call-bind-apply-helpers/functionApply'); -var $call = require('call-bind-apply-helpers/functionCall'); +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); var needsEval = {}; @@ -23936,8 +23595,7 @@ var INTRINSICS = { '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), '%Math%': Math, '%Number%': Number, - '%Object%': $Object, - '%Object.getOwnPropertyDescriptor%': $gOPD, + '%Object%': Object, '%parseFloat%': parseFloat, '%parseInt%': parseInt, '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, @@ -23963,20 +23621,7 @@ var INTRINSICS = { '%URIError%': $URIError, '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, - '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet, - - '%Function.prototype.call%': $call, - '%Function.prototype.apply%': $apply, - '%Object.defineProperty%': $defineProperty, - '%Object.getPrototypeOf%': $ObjectGPO, - '%Math.abs%': abs, - '%Math.floor%': floor, - '%Math.max%': max, - '%Math.min%': min, - '%Math.pow%': pow, - '%Math.round%': round, - '%Math.sign%': sign, - '%Reflect.getPrototypeOf%': $ReflectGPO + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet }; if (getProto) { @@ -24071,11 +23716,11 @@ var LEGACY_ALIASES = { var bind = require('function-bind'); var hasOwn = require('hasown'); -var $concat = bind.call($call, Array.prototype.concat); -var $spliceApply = bind.call($apply, Array.prototype.splice); -var $replace = bind.call($call, String.prototype.replace); -var $strSlice = bind.call($call, String.prototype.slice); -var $exec = bind.call($call, RegExp.prototype.exec); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; @@ -24206,60 +23851,12 @@ module.exports = function GetIntrinsic(name, allowMissing) { return value; }; -},{"call-bind-apply-helpers/functionApply":56,"call-bind-apply-helpers/functionCall":57,"es-define-property":411,"es-errors":413,"es-errors/eval":412,"es-errors/range":414,"es-errors/ref":415,"es-errors/syntax":416,"es-errors/type":417,"es-errors/uri":418,"es-object-atoms":420,"function-bind":425,"get-proto":430,"get-proto/Object.getPrototypeOf":428,"get-proto/Reflect.getPrototypeOf":429,"gopd":432,"has-symbols":435,"hasown":450,"math-intrinsics/abs":477,"math-intrinsics/floor":478,"math-intrinsics/max":480,"math-intrinsics/min":481,"math-intrinsics/pow":482,"math-intrinsics/round":483,"math-intrinsics/sign":484}],428:[function(require,module,exports){ -'use strict'; - -var $Object = require('es-object-atoms'); - -/** @type {import('./Object.getPrototypeOf')} */ -module.exports = $Object.getPrototypeOf || null; - -},{"es-object-atoms":420}],429:[function(require,module,exports){ +},{"es-errors":406,"es-errors/eval":405,"es-errors/range":407,"es-errors/ref":408,"es-errors/syntax":409,"es-errors/type":410,"es-errors/uri":411,"function-bind":417,"has-proto":423,"has-symbols":424,"hasown":439}],420:[function(require,module,exports){ 'use strict'; -/** @type {import('./Reflect.getPrototypeOf')} */ -module.exports = (typeof Reflect !== 'undefined' && Reflect.getPrototypeOf) || null; - -},{}],430:[function(require,module,exports){ -'use strict'; - -var reflectGetProto = require('./Reflect.getPrototypeOf'); -var originalGetProto = require('./Object.getPrototypeOf'); - -var getDunderProto = require('dunder-proto/get'); - -/** @type {import('.')} */ -module.exports = reflectGetProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return reflectGetProto(O); - } - : originalGetProto - ? function getProto(O) { - if (!O || (typeof O !== 'object' && typeof O !== 'function')) { - throw new TypeError('getProto: not an object'); - } - // @ts-expect-error TS can't narrow inside a closure, for some reason - return originalGetProto(O); - } - : getDunderProto - ? function getProto(O) { - // @ts-expect-error TS can't narrow inside a closure, for some reason - return getDunderProto(O); - } - : null; - -},{"./Object.getPrototypeOf":428,"./Reflect.getPrototypeOf":429,"dunder-proto/get":372}],431:[function(require,module,exports){ -'use strict'; - -/** @type {import('./gOPD')} */ -module.exports = Object.getOwnPropertyDescriptor; - -},{}],432:[function(require,module,exports){ -'use strict'; +var GetIntrinsic = require('get-intrinsic'); -/** @type {import('.')} */ -var $gOPD = require('./gOPD'); +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); if ($gOPD) { try { @@ -24272,12 +23869,11 @@ if ($gOPD) { module.exports = $gOPD; -},{"./gOPD":431}],433:[function(require,module,exports){ +},{"get-intrinsic":419}],421:[function(require,module,exports){ 'use strict'; var $BigInt = typeof BigInt !== 'undefined' && BigInt; -/** @type {import('.')} */ module.exports = function hasNativeBigInts() { return typeof $BigInt === 'function' && typeof BigInt === 'function' @@ -24285,7 +23881,7 @@ module.exports = function hasNativeBigInts() { && typeof BigInt(42) === 'bigint'; // eslint-disable-line no-magic-numbers }; -},{}],434:[function(require,module,exports){ +},{}],422:[function(require,module,exports){ 'use strict'; var $defineProperty = require('es-define-property'); @@ -24309,13 +23905,29 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu module.exports = hasPropertyDescriptors; -},{"es-define-property":411}],435:[function(require,module,exports){ +},{"es-define-property":404}],423:[function(require,module,exports){ +'use strict'; + +var test = { + __proto__: null, + foo: {} +}; + +var $Object = Object; + +/** @type {import('.')} */ +module.exports = function hasProto() { + // @ts-expect-error: TS errors on an inherited property for some reason + return { __proto__: test }.foo === test.foo + && !(test instanceof $Object); +}; + +},{}],424:[function(require,module,exports){ 'use strict'; var origSymbol = typeof Symbol !== 'undefined' && Symbol; var hasSymbolSham = require('./shams'); -/** @type {import('.')} */ module.exports = function hasNativeSymbols() { if (typeof origSymbol !== 'function') { return false; } if (typeof Symbol !== 'function') { return false; } @@ -24325,16 +23937,14 @@ module.exports = function hasNativeSymbols() { return hasSymbolSham(); }; -},{"./shams":436}],436:[function(require,module,exports){ +},{"./shams":425}],425:[function(require,module,exports){ 'use strict'; -/** @type {import('./shams')} */ /* eslint complexity: [2, 18], max-statements: [2, 33] */ module.exports = function hasSymbols() { if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } if (typeof Symbol.iterator === 'symbol') { return true; } - /** @type {{ [k in symbol]?: unknown }} */ var obj = {}; var sym = Symbol('test'); var symObj = Object(sym); @@ -24353,7 +23963,7 @@ module.exports = function hasSymbols() { var symVal = 42; obj[sym] = symVal; - for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } @@ -24364,15 +23974,14 @@ module.exports = function hasSymbols() { if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } if (typeof Object.getOwnPropertyDescriptor === 'function') { - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym)); + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } } return true; }; -},{}],437:[function(require,module,exports){ +},{}],426:[function(require,module,exports){ 'use strict'; var hasSymbols = require('has-symbols/shams'); @@ -24382,7 +23991,7 @@ module.exports = function hasToStringTagShams() { return hasSymbols() && !!Symbol.toStringTag; }; -},{"has-symbols/shams":436}],438:[function(require,module,exports){ +},{"has-symbols/shams":425}],427:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -24399,7 +24008,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":439,"./hash/hmac":440,"./hash/ripemd":441,"./hash/sha":442,"./hash/utils":449}],439:[function(require,module,exports){ +},{"./hash/common":428,"./hash/hmac":429,"./hash/ripemd":430,"./hash/sha":431,"./hash/utils":438}],428:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -24493,7 +24102,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":449,"minimalistic-assert":485}],440:[function(require,module,exports){ +},{"./utils":438,"minimalistic-assert":466}],429:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -24542,7 +24151,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":449,"minimalistic-assert":485}],441:[function(require,module,exports){ +},{"./utils":438,"minimalistic-assert":466}],430:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -24690,7 +24299,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":439,"./utils":449}],442:[function(require,module,exports){ +},{"./common":428,"./utils":438}],431:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -24699,7 +24308,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":443,"./sha/224":444,"./sha/256":445,"./sha/384":446,"./sha/512":447}],443:[function(require,module,exports){ +},{"./sha/1":432,"./sha/224":433,"./sha/256":434,"./sha/384":435,"./sha/512":436}],432:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -24775,7 +24384,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":439,"../utils":449,"./common":448}],444:[function(require,module,exports){ +},{"../common":428,"../utils":438,"./common":437}],433:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -24807,7 +24416,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":449,"./256":445}],445:[function(require,module,exports){ +},{"../utils":438,"./256":434}],434:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -24914,7 +24523,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":439,"../utils":449,"./common":448,"minimalistic-assert":485}],446:[function(require,module,exports){ +},{"../common":428,"../utils":438,"./common":437,"minimalistic-assert":466}],435:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -24951,7 +24560,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":449,"./512":447}],447:[function(require,module,exports){ +},{"../utils":438,"./512":436}],436:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25283,7 +24892,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":439,"../utils":449,"minimalistic-assert":485}],448:[function(require,module,exports){ +},{"../common":428,"../utils":438,"minimalistic-assert":466}],437:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -25334,7 +24943,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":449}],449:[function(require,module,exports){ +},{"../utils":438}],438:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -25614,7 +25223,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":453,"minimalistic-assert":485}],450:[function(require,module,exports){ +},{"inherits":442,"minimalistic-assert":466}],439:[function(require,module,exports){ 'use strict'; var call = Function.prototype.call; @@ -25624,7 +25233,7 @@ var bind = require('function-bind'); /** @type {import('.')} */ module.exports = bind.call(call, $hasOwn); -},{"function-bind":425}],451:[function(require,module,exports){ +},{"function-bind":417}],440:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -25739,7 +25348,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":438,"minimalistic-assert":485,"minimalistic-crypto-utils":486}],452:[function(require,module,exports){ +},{"hash.js":427,"minimalistic-assert":466,"minimalistic-crypto-utils":467}],441:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -25826,7 +25435,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],453:[function(require,module,exports){ +},{}],442:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -25855,19 +25464,14 @@ if (typeof Object.create === 'function') { } } -},{}],454:[function(require,module,exports){ +},{}],443:[function(require,module,exports){ 'use strict'; -/** @typedef {`$${import('.').InternalSlot}`} SaltedInternalSlot */ -/** @typedef {{ [k in SaltedInternalSlot]?: unknown }} SlotsObject */ - var hasOwn = require('hasown'); -/** @type {import('side-channel').Channel} */ var channel = require('side-channel')(); var $TypeError = require('es-errors/type'); -/** @type {import('.')} */ var SLOT = { assert: function (O, slot) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -25889,8 +25493,7 @@ var SLOT = { throw new $TypeError('`slot` must be a string'); } var slots = channel.get(O); - // eslint-disable-next-line no-extra-parens - return slots && slots[/** @type {SaltedInternalSlot} */ ('$' + slot)]; + return slots && slots['$' + slot]; }, has: function (O, slot) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -25900,8 +25503,7 @@ var SLOT = { throw new $TypeError('`slot` must be a string'); } var slots = channel.get(O); - // eslint-disable-next-line no-extra-parens - return !!slots && hasOwn(slots, /** @type {SaltedInternalSlot} */ ('$' + slot)); + return !!slots && hasOwn(slots, '$' + slot); }, set: function (O, slot, V) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) { @@ -25915,8 +25517,7 @@ var SLOT = { slots = {}; channel.set(O, slots); } - // eslint-disable-next-line no-extra-parens - slots[/** @type {SaltedInternalSlot} */ ('$' + slot)] = V; + slots['$' + slot] = V; } }; @@ -25926,57 +25527,46 @@ if (Object.freeze) { module.exports = SLOT; -},{"es-errors/type":417,"hasown":450,"side-channel":515}],455:[function(require,module,exports){ +},{"es-errors/type":410,"hasown":439,"side-channel":492}],444:[function(require,module,exports){ 'use strict'; var hasToStringTag = require('has-tostringtag/shams')(); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $toString = callBound('Object.prototype.toString'); -/** @type {import('.')} */ var isStandardArguments = function isArguments(value) { - if ( - hasToStringTag - && value - && typeof value === 'object' - && Symbol.toStringTag in value - ) { + if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) { return false; } return $toString(value) === '[object Arguments]'; }; -/** @type {import('.')} */ var isLegacyArguments = function isArguments(value) { if (isStandardArguments(value)) { return true; } - return value !== null - && typeof value === 'object' - && 'length' in value - && typeof value.length === 'number' - && value.length >= 0 - && $toString(value) !== '[object Array]' - && 'callee' in value - && $toString(value.callee) === '[object Function]'; + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + $toString(value) !== '[object Array]' && + $toString(value.callee) === '[object Function]'; }; var supportsStandardArguments = (function () { return isStandardArguments(arguments); }()); -// @ts-expect-error TODO make this not error isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests -/** @type {import('.')} */ module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments; -},{"call-bound":62,"has-tostringtag/shams":437}],456:[function(require,module,exports){ +},{"call-bind/callBound":54,"has-tostringtag/shams":426}],445:[function(require,module,exports){ 'use strict'; var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var GetIntrinsic = require('get-intrinsic'); var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true); @@ -26012,19 +25602,17 @@ module.exports = $byteLength || $abSlice ? function isArrayBuffer(obj) { return $toString(obj) === '[object ArrayBuffer]'; } - // @ts-expect-error : function isArrayBuffer(obj) { // eslint-disable-line no-unused-vars return false; }; -},{"call-bind":61,"call-bound":62,"get-intrinsic":427}],457:[function(require,module,exports){ +},{"call-bind":55,"call-bind/callBound":54,"get-intrinsic":419}],446:[function(require,module,exports){ 'use strict'; var hasBigInts = require('has-bigints')(); if (hasBigInts) { var bigIntValueOf = BigInt.prototype.valueOf; - /** @type {(value: object) => value is BigInt} */ var tryBigInt = function tryBigIntObject(value) { try { bigIntValueOf.call(value); @@ -26034,7 +25622,6 @@ if (hasBigInts) { return false; }; - /** @type {import('.')} */ module.exports = function isBigInt(value) { if ( value === null @@ -26054,20 +25641,18 @@ if (hasBigInts) { return tryBigInt(value); }; } else { - /** @type {import('.')} */ module.exports = function isBigInt(value) { return false && value; }; } -},{"has-bigints":433}],458:[function(require,module,exports){ +},{"has-bigints":421}],447:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $boolToStr = callBound('Boolean.prototype.toString'); var $toString = callBound('Object.prototype.toString'); -/** @type {import('.')} */ var tryBooleanObject = function booleanBrandCheck(value) { try { $boolToStr(value); @@ -26079,7 +25664,6 @@ var tryBooleanObject = function booleanBrandCheck(value) { var boolClass = '[object Boolean]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isBoolean(value) { if (typeof value === 'boolean') { return true; @@ -26090,7 +25674,7 @@ module.exports = function isBoolean(value) { return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass; }; -},{"call-bound":62,"has-tostringtag/shams":437}],459:[function(require,module,exports){ +},{"call-bind/callBound":54,"has-tostringtag/shams":426}],448:[function(require,module,exports){ 'use strict'; var fnToStr = Function.prototype.toString; @@ -26193,36 +25777,31 @@ module.exports = reflectApply return tryFunctionObject(value); }; -},{}],460:[function(require,module,exports){ +},{}],449:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -var getDay = callBound('Date.prototype.getDay'); -/** @type {import('.')} */ +var getDay = Date.prototype.getDay; var tryDateObject = function tryDateGetDayCall(value) { try { - getDay(value); + getDay.call(value); return true; } catch (e) { return false; } }; -/** @type {(value: unknown) => string} */ -var toStr = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var dateClass = '[object Date]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isDateObject(value) { if (typeof value !== 'object' || value === null) { return false; } - return hasToStringTag ? tryDateObject(value) : toStr(value) === dateClass; + return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; }; -},{"call-bound":62,"has-tostringtag/shams":437}],461:[function(require,module,exports){ +},{"has-tostringtag/shams":426}],450:[function(require,module,exports){ 'use strict'; /** @const */ @@ -26271,7 +25850,7 @@ module.exports = exported || function isMap(x) { return false; }; -},{}],462:[function(require,module,exports){ +},{}],451:[function(require,module,exports){ (function (process){(function (){ // Coding standard for this project defined @ https://github.com/MatthewSH/standards/blob/master/JavaScript.md 'use strict'; @@ -26279,59 +25858,51 @@ module.exports = exported || function isMap(x) { exports = module.exports = !!(typeof process !== 'undefined' && process.versions && process.versions.node); }).call(this)}).call(this,require('_process')) -},{"_process":503}],463:[function(require,module,exports){ +},{"_process":484}],452:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -var $numToStr = callBound('Number.prototype.toString'); - -/** @type {import('.')} */ +var numToStr = Number.prototype.toString; var tryNumberObject = function tryNumberObject(value) { try { - $numToStr(value); + numToStr.call(value); return true; } catch (e) { return false; } }; -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var numClass = '[object Number]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isNumberObject(value) { if (typeof value === 'number') { return true; } - if (!value || typeof value !== 'object') { + if (typeof value !== 'object') { return false; } - return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass; + return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass; }; -},{"call-bound":62,"has-tostringtag/shams":437}],464:[function(require,module,exports){ +},{"has-tostringtag/shams":426}],453:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var hasToStringTag = require('has-tostringtag/shams')(); -var hasOwn = require('hasown'); -var gOPD = require('gopd'); - -/** @type {import('.')} */ -var fn; +var has; +var $exec; +var isRegexMarker; +var badStringifier; if (hasToStringTag) { - /** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ - var $exec = callBound('RegExp.prototype.exec'); - /** @type {object} */ - var isRegexMarker = {}; + has = callBound('Object.prototype.hasOwnProperty'); + $exec = callBound('RegExp.prototype.exec'); + isRegexMarker = {}; var throwRegexMarker = function () { throw isRegexMarker; }; - /** @type {{ toString(): never, valueOf(): never, [Symbol.toPrimitive]?(): never }} */ - var badStringifier = { + badStringifier = { toString: throwRegexMarker, valueOf: throwRegexMarker }; @@ -26339,37 +25910,32 @@ if (hasToStringTag) { if (typeof Symbol.toPrimitive === 'symbol') { badStringifier[Symbol.toPrimitive] = throwRegexMarker; } +} - /** @type {import('.')} */ - // @ts-expect-error TS can't figure out that the $exec call always throws +var $toString = callBound('Object.prototype.toString'); +var gOPD = Object.getOwnPropertyDescriptor; +var regexClass = '[object RegExp]'; + +module.exports = hasToStringTag // eslint-disable-next-line consistent-return - fn = function isRegex(value) { + ? function isRegex(value) { if (!value || typeof value !== 'object') { return false; } - // eslint-disable-next-line no-extra-parens - var descriptor = /** @type {NonNullable} */ (gOPD)(/** @type {{ lastIndex?: unknown }} */ (value), 'lastIndex'); - var hasLastIndexDataProperty = descriptor && hasOwn(descriptor, 'value'); + var descriptor = gOPD(value, 'lastIndex'); + var hasLastIndexDataProperty = descriptor && has(descriptor, 'value'); if (!hasLastIndexDataProperty) { return false; } try { - // eslint-disable-next-line no-extra-parens - $exec(value, /** @type {string} */ (/** @type {unknown} */ (badStringifier))); + $exec(value, badStringifier); } catch (e) { return e === isRegexMarker; } - }; -} else { - /** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ - var $toString = callBound('Object.prototype.toString'); - /** @const @type {'[object RegExp]'} */ - var regexClass = '[object RegExp]'; - - /** @type {import('.')} */ - fn = function isRegex(value) { + } + : function isRegex(value) { // In older browsers, typeof regex incorrectly returns 'function' if (!value || (typeof value !== 'object' && typeof value !== 'function')) { return false; @@ -26377,11 +25943,8 @@ if (hasToStringTag) { return $toString(value) === regexClass; }; -} - -module.exports = fn; -},{"call-bound":62,"gopd":432,"has-tostringtag/shams":437,"hasown":450}],465:[function(require,module,exports){ +},{"call-bind/callBound":54,"has-tostringtag/shams":426}],454:[function(require,module,exports){ 'use strict'; var $Map = typeof Map === 'function' && Map.prototype ? Map : null; @@ -26429,12 +25992,11 @@ module.exports = exported || function isSet(x) { return false; }; -},{}],466:[function(require,module,exports){ +},{}],455:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); -/** @type {undefined | ((thisArg: SharedArrayBuffer) => number)} */ var $byteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); /** @type {import('.')} */ @@ -26444,76 +26006,63 @@ module.exports = $byteLength return false; } try { - // @ts-expect-error TS can't figure out this closed-over variable is non-nullable, and it's fine that `obj` might not be a SAB $byteLength(obj); return true; } catch (e) { return false; } } - : function isSharedArrayBuffer(_obj) { // eslint-disable-line no-unused-vars + : function isSharedArrayBuffer(obj) { // eslint-disable-line no-unused-vars return false; }; -},{"call-bound":62}],467:[function(require,module,exports){ +},{"call-bind/callBound":54}],456:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); - -/** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ -var $strValueOf = callBound('String.prototype.valueOf'); - -/** @type {import('.')} */ +var strValue = String.prototype.valueOf; var tryStringObject = function tryStringObject(value) { try { - $strValueOf(value); + strValue.call(value); return true; } catch (e) { return false; } }; -/** @type {(receiver: ThisParameterType, ...args: Parameters) => ReturnType} */ -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var strClass = '[object String]'; var hasToStringTag = require('has-tostringtag/shams')(); -/** @type {import('.')} */ module.exports = function isString(value) { if (typeof value === 'string') { return true; } - if (!value || typeof value !== 'object') { + if (typeof value !== 'object') { return false; } - return hasToStringTag ? tryStringObject(value) : $toString(value) === strClass; + return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; }; -},{"call-bound":62,"has-tostringtag/shams":437}],468:[function(require,module,exports){ +},{"has-tostringtag/shams":426}],457:[function(require,module,exports){ 'use strict'; -var callBound = require('call-bound'); -var $toString = callBound('Object.prototype.toString'); +var toStr = Object.prototype.toString; var hasSymbols = require('has-symbols')(); -var safeRegexTest = require('safe-regex-test'); if (hasSymbols) { - var $symToStr = callBound('Symbol.prototype.toString'); - var isSymString = safeRegexTest(/^Symbol\(.*\)$/); - - /** @type {(value: object) => value is Symbol} */ + var symToStr = Symbol.prototype.toString; + var symStringRegex = /^Symbol\(.*\)$/; var isSymbolObject = function isRealSymbolObject(value) { if (typeof value.valueOf() !== 'symbol') { return false; } - return isSymString($symToStr(value)); + return symStringRegex.test(symToStr.call(value)); }; - /** @type {import('.')} */ module.exports = function isSymbol(value) { if (typeof value === 'symbol') { return true; } - if (!value || typeof value !== 'object' || $toString(value) !== '[object Symbol]') { + if (toStr.call(value) !== '[object Symbol]') { return false; } try { @@ -26523,14 +26072,14 @@ if (hasSymbols) { } }; } else { - /** @type {import('.')} */ + module.exports = function isSymbol(value) { // this environment does not support Symbols. return false && value; }; } -},{"call-bound":62,"has-symbols":435,"safe-regex-test":509}],469:[function(require,module,exports){ +},{"has-symbols":424}],458:[function(require,module,exports){ 'use strict'; var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null; @@ -26578,19 +26127,17 @@ module.exports = exported || function isWeakMap(x) { return false; }; -},{}],470:[function(require,module,exports){ +},{}],459:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $WeakSet = GetIntrinsic('%WeakSet%', true); -/** @type {undefined | ((thisArg: Set, value: V) => boolean)} */ var $setHas = callBound('WeakSet.prototype.has', true); if ($setHas) { - /** @type {undefined | ((thisArg: WeakMap, key: K) => boolean)} */ var $mapHas = callBound('WeakMap.prototype.has', true); /** @type {import('.')} */ @@ -26599,11 +26146,9 @@ if ($setHas) { return false; } try { - // @ts-expect-error TS can't figure out that $setHas is always truthy here $setHas(x, $setHas); if ($mapHas) { try { - // @ts-expect-error this indeed might not be a weak collection $mapHas(x, $mapHas); } catch (e) { return true; @@ -26616,37 +26161,33 @@ if ($setHas) { }; } else { /** @type {import('.')} */ - // @ts-expect-error - module.exports = function isWeakSet(x) { // eslint-disable-line no-unused-vars + // eslint-disable-next-line no-unused-vars + module.exports = function isWeakSet(x) { // `WeakSet` does not exist, or does not have a `has` method return false; }; } -},{"call-bound":62,"get-intrinsic":427}],471:[function(require,module,exports){ +},{"call-bind/callBound":54,"get-intrinsic":419}],460:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],472:[function(require,module,exports){ +},{}],461:[function(require,module,exports){ 'use strict'; -/** @type {typeof JSON.stringify} */ var jsonStringify = (typeof JSON !== 'undefined' ? JSON : require('jsonify')).stringify; var isArray = require('isarray'); var objectKeys = require('object-keys'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var $join = callBound('Array.prototype.join'); -var $indexOf = callBound('Array.prototype.indexOf'); -var $splice = callBound('Array.prototype.splice'); -var $sort = callBound('Array.prototype.sort'); +var $push = callBound('Array.prototype.push'); -/** @type {(n: number, char: string) => string} */ var strRepeat = function repeat(n, char) { var str = ''; for (var i = 0; i < n; i += 1) { @@ -26655,103 +26196,85 @@ var strRepeat = function repeat(n, char) { return str; }; -/** @type {(parent: import('.').Node, key: import('.').Key, value: unknown) => unknown} */ -var defaultReplacer = function (_parent, _key, value) { return value; }; +var defaultReplacer = function (parent, key, value) { return value; }; -/** @type {import('.')} */ module.exports = function stableStringify(obj) { - /** @type {Parameters[1]} */ var opts = arguments.length > 1 ? arguments[1] : void undefined; var space = (opts && opts.space) || ''; if (typeof space === 'number') { space = strRepeat(space, ' '); } var cycles = !!opts && typeof opts.cycles === 'boolean' && opts.cycles; - /** @type {undefined | typeof defaultReplacer} */ var replacer = opts && opts.replacer ? callBind(opts.replacer) : defaultReplacer; var cmpOpt = typeof opts === 'function' ? opts : opts && opts.cmp; - /** @type {undefined | ((node: T) => (a: Exclude, b: Exclude) => number)} */ var cmp = cmpOpt && function (node) { - // eslint-disable-next-line no-extra-parens - var get = /** @type {NonNullable} */ (cmpOpt).length > 2 - && /** @type {import('.').Getter['get']} */ function get(k) { return node[k]; }; + var get = cmpOpt.length > 2 && function get(k) { return node[k]; }; return function (a, b) { - // eslint-disable-next-line no-extra-parens - return /** @type {NonNullable} */ (cmpOpt)( + return cmpOpt( { key: a, value: node[a] }, { key: b, value: node[b] }, - // @ts-expect-error TS doesn't understand the optimization used here - get ? /** @type {import('.').Getter} */ { __proto__: null, get: get } : void undefined + get ? { __proto__: null, get: get } : void undefined ); }; }; - /** @type {import('.').Node[]} */ var seen = []; - return (/** @type {(parent: import('.').Node, key: string | number, node: unknown, level: number) => string | undefined} */ - function stringify(parent, key, node, level) { - var indent = space ? '\n' + strRepeat(level, space) : ''; - var colonSeparator = space ? ': ' : ':'; + return (function stringify(parent, key, node, level) { + var indent = space ? '\n' + strRepeat(level, space) : ''; + var colonSeparator = space ? ': ' : ':'; - // eslint-disable-next-line no-extra-parens - if (node && /** @type {{ toJSON?: unknown }} */ (node).toJSON && typeof /** @type {{ toJSON?: unknown }} */ (node).toJSON === 'function') { - // eslint-disable-next-line no-extra-parens - node = /** @type {{ toJSON: Function }} */ (node).toJSON(); - } + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON(); + } - node = replacer(parent, key, node); + node = replacer(parent, key, node); - if (node === undefined) { - return; - } - if (typeof node !== 'object' || node === null) { - return jsonStringify(node); - } - if (isArray(node)) { - var out = []; - for (var i = 0; i < node.length; i++) { - var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); - out[out.length] = indent + space + item; - } - return '[' + $join(out, ',') + indent + ']'; + if (node === undefined) { + return; + } + if (typeof node !== 'object' || node === null) { + return jsonStringify(node); + } + if (isArray(node)) { + var out = []; + for (var i = 0; i < node.length; i++) { + var item = stringify(node, i, node[i], level + 1) || jsonStringify(null); + $push(out, indent + space + item); } + return '[' + $join(out, ',') + indent + ']'; + } - if ($indexOf(seen, node) !== -1) { - if (cycles) { return jsonStringify('__cycle__'); } - throw new TypeError('Converting circular structure to JSON'); - } else { - seen[seen.length] = /** @type {import('.').NonArrayNode} */ (node); - } + if (seen.indexOf(node) !== -1) { + if (cycles) { return jsonStringify('__cycle__'); } + throw new TypeError('Converting circular structure to JSON'); + } else { $push(seen, node); } - /** @type {import('.').Key[]} */ - // eslint-disable-next-line no-extra-parens - var keys = $sort(objectKeys(node), cmp && cmp(/** @type {import('.').NonArrayNode} */ (node))); - var out = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - // eslint-disable-next-line no-extra-parens - var value = stringify(/** @type {import('.').Node} */ (node), key, /** @type {import('.').NonArrayNode} */ (node)[key], level + 1); + var keys = objectKeys(node).sort(cmp && cmp(node)); + var out = []; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = stringify(node, key, node[key], level + 1); - if (!value) { continue; } + if (!value) { continue; } - var keyValue = jsonStringify(key) - + colonSeparator - + value; + var keyValue = jsonStringify(key) + + colonSeparator + + value; - out[out.length] = indent + space + keyValue; - } - $splice(seen, $indexOf(seen, node), 1); - return '{' + $join(out, ',') + indent + '}'; - }({ '': obj }, '', obj, 0) - ); + $push(out, indent + space + keyValue); + } + seen.splice(seen.indexOf(node), 1); + return '{' + $join(out, ',') + indent + '}'; + + }({ '': obj }, '', obj, 0)); }; -},{"call-bind":61,"call-bound":62,"isarray":471,"jsonify":473,"object-keys":494}],473:[function(require,module,exports){ +},{"call-bind":55,"call-bind/callBound":54,"isarray":460,"jsonify":462,"object-keys":475}],462:[function(require,module,exports){ 'use strict'; exports.parse = require('./lib/parse'); exports.stringify = require('./lib/stringify'); -},{"./lib/parse":474,"./lib/stringify":475}],474:[function(require,module,exports){ +},{"./lib/parse":463,"./lib/stringify":464}],463:[function(require,module,exports){ 'use strict'; var at; // The index of the current character @@ -27014,7 +26537,7 @@ module.exports = function (source, reviver) { }({ '': result }, '')) : result; }; -},{}],475:[function(require,module,exports){ +},{}],464:[function(require,module,exports){ 'use strict'; var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; @@ -27167,7 +26690,7 @@ module.exports = function (value, replacer, space) { return str('', { '': value }); }; -},{}],476:[function(require,module,exports){ +},{}],465:[function(require,module,exports){ /* * loglevel - https://github.com/pimterry/loglevel * @@ -27526,64 +27049,7 @@ module.exports = function (value, replacer, space) { return defaultLogger; })); -},{}],477:[function(require,module,exports){ -'use strict'; - -/** @type {import('./abs')} */ -module.exports = Math.abs; - -},{}],478:[function(require,module,exports){ -'use strict'; - -/** @type {import('./floor')} */ -module.exports = Math.floor; - -},{}],479:[function(require,module,exports){ -'use strict'; - -/** @type {import('./isNaN')} */ -module.exports = Number.isNaN || function isNaN(a) { - return a !== a; -}; - -},{}],480:[function(require,module,exports){ -'use strict'; - -/** @type {import('./max')} */ -module.exports = Math.max; - -},{}],481:[function(require,module,exports){ -'use strict'; - -/** @type {import('./min')} */ -module.exports = Math.min; - -},{}],482:[function(require,module,exports){ -'use strict'; - -/** @type {import('./pow')} */ -module.exports = Math.pow; - -},{}],483:[function(require,module,exports){ -'use strict'; - -/** @type {import('./round')} */ -module.exports = Math.round; - -},{}],484:[function(require,module,exports){ -'use strict'; - -var $isNaN = require('./isNaN'); - -/** @type {import('./sign')} */ -module.exports = function sign(number) { - if ($isNaN(number) || number === 0) { - return number; - } - return number < 0 ? -1 : +1; -}; - -},{"./isNaN":479}],485:[function(require,module,exports){ +},{}],466:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -27596,7 +27062,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],486:[function(require,module,exports){ +},{}],467:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -27656,7 +27122,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],487:[function(require,module,exports){ +},{}],468:[function(require,module,exports){ /** * Helpers. */ @@ -27682,7 +27148,7 @@ var y = d * 365.25; * @api public */ -module.exports = function (val, options) { +module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { @@ -27820,7 +27286,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],488:[function(require,module,exports){ +},{}],469:[function(require,module,exports){ (function (global){(function (){ var hasMap = typeof Map === 'function' && Map.prototype; var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; @@ -27893,21 +27359,10 @@ var utilInspect = require('./util.inspect'); var inspectCustom = utilInspect.custom; var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null; -var quotes = { - __proto__: null, - 'double': '"', - single: "'" -}; -var quoteREs = { - __proto__: null, - 'double': /(["\\])/g, - single: /(['\\])/g -}; - module.exports = function inspect_(obj, options, depth, seen) { var opts = options || {}; - if (has(opts, 'quoteStyle') && !has(quotes, opts.quoteStyle)) { + if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) { throw new TypeError('option "quoteStyle" must be "single" or "double"'); } if ( @@ -28079,10 +27534,7 @@ module.exports = function inspect_(obj, options, depth, seen) { if (typeof window !== 'undefined' && obj === window) { return '{ [object Window] }'; } - if ( - (typeof globalThis !== 'undefined' && obj === globalThis) - || (typeof global !== 'undefined' && obj === global) - ) { + if (obj === global) { return '{ [object globalThis] }'; } if (!isDate(obj) && !isRegExp(obj)) { @@ -28102,8 +27554,7 @@ module.exports = function inspect_(obj, options, depth, seen) { }; function wrapQuotes(s, defaultStyle, opts) { - var style = opts.quoteStyle || defaultStyle; - var quoteChar = quotes[style]; + var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; return quoteChar + s + quoteChar; } @@ -28261,10 +27712,8 @@ function inspectString(str, opts) { var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : ''); return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer; } - var quoteRE = quoteREs[opts.quoteStyle || 'single']; - quoteRE.lastIndex = 0; // eslint-disable-next-line no-control-regex - var s = $replace.call($replace.call(str, quoteRE, '\\$1'), /[\x00-\x1f]/g, lowbyte); + var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte); return wrapQuotes(s, 'single', opts); } @@ -28365,7 +27814,7 @@ function arrObjKeys(obj, inspect) { } }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./util.inspect":52}],489:[function(require,module,exports){ +},{"./util.inspect":52}],470:[function(require,module,exports){ 'use strict'; var numberIsNaN = function (value) { @@ -28386,7 +27835,7 @@ module.exports = function is(a, b) { }; -},{}],490:[function(require,module,exports){ +},{}],471:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -28406,7 +27855,7 @@ define(polyfill, { module.exports = polyfill; -},{"./implementation":489,"./polyfill":491,"./shim":492,"call-bind":61,"define-properties":371}],491:[function(require,module,exports){ +},{"./implementation":470,"./polyfill":472,"./shim":473,"call-bind":55,"define-properties":366}],472:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -28415,7 +27864,7 @@ module.exports = function getPolyfill() { return typeof Object.is === 'function' ? Object.is : implementation; }; -},{"./implementation":489}],492:[function(require,module,exports){ +},{"./implementation":470}],473:[function(require,module,exports){ 'use strict'; var getPolyfill = require('./polyfill'); @@ -28431,7 +27880,7 @@ module.exports = function shimObjectIs() { return polyfill; }; -},{"./polyfill":491,"define-properties":371}],493:[function(require,module,exports){ +},{"./polyfill":472,"define-properties":366}],474:[function(require,module,exports){ 'use strict'; var keysShim; @@ -28555,7 +28004,7 @@ if (!Object.keys) { } module.exports = keysShim; -},{"./isArguments":495}],494:[function(require,module,exports){ +},{"./isArguments":476}],475:[function(require,module,exports){ 'use strict'; var slice = Array.prototype.slice; @@ -28589,7 +28038,7 @@ keysShim.shim = function shimObjectKeys() { module.exports = keysShim; -},{"./implementation":493,"./isArguments":495}],495:[function(require,module,exports){ +},{"./implementation":474,"./isArguments":476}],476:[function(require,module,exports){ 'use strict'; var toStr = Object.prototype.toString; @@ -28608,31 +28057,31 @@ module.exports = function isArguments(value) { return isArgs; }; -},{}],496:[function(require,module,exports){ +},{}],477:[function(require,module,exports){ 'use strict'; // modified from https://github.com/es-shims/es6-shim var objectKeys = require('object-keys'); var hasSymbols = require('has-symbols/shams')(); -var callBound = require('call-bound'); -var $Object = require('es-object-atoms'); +var callBound = require('call-bind/callBound'); +var toObject = Object; var $push = callBound('Array.prototype.push'); var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable'); -var originalGetSymbols = hasSymbols ? $Object.getOwnPropertySymbols : null; +var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null; // eslint-disable-next-line no-unused-vars module.exports = function assign(target, source1) { if (target == null) { throw new TypeError('target must be an object'); } - var to = $Object(target); // step 1 + var to = toObject(target); // step 1 if (arguments.length === 1) { return to; // step 2 } for (var s = 1; s < arguments.length; ++s) { - var from = $Object(arguments[s]); // step 3.a.i + var from = toObject(arguments[s]); // step 3.a.i // step 3.a.ii: var keys = objectKeys(from); - var getSymbols = hasSymbols && ($Object.getOwnPropertySymbols || originalGetSymbols); + var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols); if (getSymbols) { var syms = getSymbols(from); for (var j = 0; j < syms.length; ++j) { @@ -28656,7 +28105,7 @@ module.exports = function assign(target, source1) { return to; // step 4 }; -},{"call-bound":62,"es-object-atoms":420,"has-symbols/shams":436,"object-keys":494}],497:[function(require,module,exports){ +},{"call-bind/callBound":54,"has-symbols/shams":425,"object-keys":475}],478:[function(require,module,exports){ 'use strict'; var defineProperties = require('define-properties'); @@ -28680,7 +28129,7 @@ defineProperties(bound, { module.exports = bound; -},{"./implementation":496,"./polyfill":498,"./shim":499,"call-bind":61,"define-properties":371}],498:[function(require,module,exports){ +},{"./implementation":477,"./polyfill":479,"./shim":480,"call-bind":55,"define-properties":366}],479:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -28737,7 +28186,7 @@ module.exports = function getPolyfill() { return Object.assign; }; -},{"./implementation":496}],499:[function(require,module,exports){ +},{"./implementation":477}],480:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -28753,7 +28202,7 @@ module.exports = function shimAssign() { return polyfill; }; -},{"./polyfill":498,"define-properties":371}],500:[function(require,module,exports){ +},{"./polyfill":479,"define-properties":366}],481:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; @@ -28782,7 +28231,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const pkg = __importStar(require("./index.js")); module.exports = pkg; -},{"./index.js":501}],501:[function(require,module,exports){ +},{"./index.js":482}],482:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.now = exports.removeTooOldValues = exports.ObliviousSet = void 0; @@ -28859,7 +28308,7 @@ function now() { } exports.now = now; -},{}],502:[function(require,module,exports){ +},{}],483:[function(require,module,exports){ 'use strict'; /** @type {import('.')} */ @@ -28877,7 +28326,7 @@ module.exports = [ 'BigUint64Array' ]; -},{}],503:[function(require,module,exports){ +},{}],484:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -29063,7 +28512,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],504:[function(require,module,exports){ +},{}],485:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -29826,7 +29275,7 @@ try { } } -},{}],505:[function(require,module,exports){ +},{}],486:[function(require,module,exports){ 'use strict'; var setFunctionName = require('set-function-name'); @@ -29867,7 +29316,7 @@ module.exports = setFunctionName(function flags() { }, 'get flags', true); -},{"es-errors/type":417,"set-function-name":511}],506:[function(require,module,exports){ +},{"es-errors/type":410,"set-function-name":491}],487:[function(require,module,exports){ 'use strict'; var define = require('define-properties'); @@ -29887,7 +29336,7 @@ define(flagsBound, { module.exports = flagsBound; -},{"./implementation":505,"./polyfill":507,"./shim":508,"call-bind":61,"define-properties":371}],507:[function(require,module,exports){ +},{"./implementation":486,"./polyfill":488,"./shim":489,"call-bind":55,"define-properties":366}],488:[function(require,module,exports){ 'use strict'; var implementation = require('./implementation'); @@ -29901,8 +29350,8 @@ module.exports = function getPolyfill() { if ( descriptor && typeof descriptor.get === 'function' - && 'dotAll' in RegExp.prototype - && 'hasIndices' in RegExp.prototype + && typeof RegExp.prototype.dotAll === 'boolean' + && typeof RegExp.prototype.hasIndices === 'boolean' ) { /* eslint getter-return: 0 */ var calls = ''; @@ -29917,9 +29366,6 @@ module.exports = function getPolyfill() { calls += 'y'; } }); - - descriptor.get.call(o); - if (calls === 'dy') { return descriptor.get; } @@ -29928,20 +29374,20 @@ module.exports = function getPolyfill() { return implementation; }; -},{"./implementation":505,"define-properties":371}],508:[function(require,module,exports){ +},{"./implementation":486,"define-properties":366}],489:[function(require,module,exports){ 'use strict'; var supportsDescriptors = require('define-properties').supportsDescriptors; var getPolyfill = require('./polyfill'); -var gOPD = require('gopd'); +var gOPD = Object.getOwnPropertyDescriptor; var defineProperty = Object.defineProperty; -var $TypeError = require('es-errors'); -var getProto = require('get-proto'); +var TypeErr = TypeError; +var getProto = Object.getPrototypeOf; var regex = /a/; module.exports = function shimFlags() { if (!supportsDescriptors || !getProto) { - throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); + throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); } var polyfill = getPolyfill(); var proto = getProto(regex); @@ -29956,26 +29402,7 @@ module.exports = function shimFlags() { return polyfill; }; -},{"./polyfill":507,"define-properties":371,"es-errors":413,"get-proto":430,"gopd":432}],509:[function(require,module,exports){ -'use strict'; - -var callBound = require('call-bound'); -var isRegex = require('is-regex'); - -var $exec = callBound('RegExp.prototype.exec'); -var $TypeError = require('es-errors/type'); - -/** @type {import('.')} */ -module.exports = function regexTester(regex) { - if (!isRegex(regex)) { - throw new $TypeError('`regex` must be a RegExp'); - } - return function test(s) { - return $exec(regex, s) !== null; - }; -}; - -},{"call-bound":62,"es-errors/type":417,"is-regex":464}],510:[function(require,module,exports){ +},{"./polyfill":488,"define-properties":366}],490:[function(require,module,exports){ 'use strict'; var GetIntrinsic = require('get-intrinsic'); @@ -30019,7 +29446,7 @@ module.exports = function setFunctionLength(fn, length) { return fn; }; -},{"define-data-property":370,"es-errors/type":417,"get-intrinsic":427,"gopd":432,"has-property-descriptors":434}],511:[function(require,module,exports){ +},{"define-data-property":365,"es-errors/type":410,"get-intrinsic":419,"gopd":420,"has-property-descriptors":422}],491:[function(require,module,exports){ 'use strict'; var define = require('define-data-property'); @@ -30044,323 +29471,138 @@ module.exports = function setFunctionName(fn, name) { return fn; }; -},{"define-data-property":370,"es-errors/type":417,"functions-have-names":426,"has-property-descriptors":434}],512:[function(require,module,exports){ +},{"define-data-property":365,"es-errors/type":410,"functions-have-names":418,"has-property-descriptors":422}],492:[function(require,module,exports){ 'use strict'; +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); var inspect = require('object-inspect'); var $TypeError = require('es-errors/type'); +var $WeakMap = GetIntrinsic('%WeakMap%', true); +var $Map = GetIntrinsic('%Map%', true); + +var $weakMapGet = callBound('WeakMap.prototype.get', true); +var $weakMapSet = callBound('WeakMap.prototype.set', true); +var $weakMapHas = callBound('WeakMap.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSet = callBound('Map.prototype.set', true); +var $mapHas = callBound('Map.prototype.has', true); /* * This function traverses the list returning the node corresponding to the given key. * -* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. -* By doing so, all the recently used nodes can be accessed relatively quickly. +* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. By doing so, all the recently used nodes can be accessed relatively quickly. */ -/** @type {import('./list.d.ts').listGetNode} */ -// eslint-disable-next-line consistent-return -var listGetNode = function (list, key, isDelete) { +/** @type {import('.').listGetNode} */ +var listGetNode = function (list, key) { // eslint-disable-line consistent-return /** @type {typeof list | NonNullable<(typeof list)['next']>} */ var prev = list; /** @type {(typeof list)['next']} */ var curr; - // eslint-disable-next-line eqeqeq - for (; (curr = prev.next) != null; prev = curr) { + for (; (curr = prev.next) !== null; prev = curr) { if (curr.key === key) { prev.next = curr.next; - if (!isDelete) { - // eslint-disable-next-line no-extra-parens - curr.next = /** @type {NonNullable} */ (list.next); - list.next = curr; // eslint-disable-line no-param-reassign - } + // eslint-disable-next-line no-extra-parens + curr.next = /** @type {NonNullable} */ (list.next); + list.next = curr; // eslint-disable-line no-param-reassign return curr; } } }; -/** @type {import('./list.d.ts').listGet} */ +/** @type {import('.').listGet} */ var listGet = function (objects, key) { - if (!objects) { - return void undefined; - } var node = listGetNode(objects, key); return node && node.value; }; -/** @type {import('./list.d.ts').listSet} */ +/** @type {import('.').listSet} */ var listSet = function (objects, key, value) { var node = listGetNode(objects, key); if (node) { node.value = value; } else { // Prepend the new node to the beginning of the list - objects.next = /** @type {import('./list.d.ts').ListNode} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens + objects.next = /** @type {import('.').ListNode} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens key: key, next: objects.next, value: value }); } }; -/** @type {import('./list.d.ts').listHas} */ +/** @type {import('.').listHas} */ var listHas = function (objects, key) { - if (!objects) { - return false; - } return !!listGetNode(objects, key); }; -/** @type {import('./list.d.ts').listDelete} */ -// eslint-disable-next-line consistent-return -var listDelete = function (objects, key) { - if (objects) { - return listGetNode(objects, key, true); - } -}; - -/** @type {import('.')} */ -module.exports = function getSideChannelList() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {import('./list.d.ts').RootNode | undefined} */ var $o; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - var root = $o && $o.next; - var deletedNode = listDelete($o, key); - if (deletedNode && root && root === deletedNode) { - $o = void undefined; - } - return !!deletedNode; - }, - get: function (key) { - return listGet($o, key); - }, - has: function (key) { - return listHas($o, key); - }, - set: function (key, value) { - if (!$o) { - // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head - $o = { - next: void undefined - }; - } - // eslint-disable-next-line no-extra-parens - listSet(/** @type {NonNullable} */ ($o), key, value); - } - }; - // @ts-expect-error TODO: figure out why this is erroring - return channel; -}; - -},{"es-errors/type":417,"object-inspect":488}],513:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); -var inspect = require('object-inspect'); - -var $TypeError = require('es-errors/type'); -var $Map = GetIntrinsic('%Map%', true); - -/** @type {(thisArg: Map, key: K) => V} */ -var $mapGet = callBound('Map.prototype.get', true); -/** @type {(thisArg: Map, key: K, value: V) => void} */ -var $mapSet = callBound('Map.prototype.set', true); -/** @type {(thisArg: Map, key: K) => boolean} */ -var $mapHas = callBound('Map.prototype.has', true); -/** @type {(thisArg: Map, key: K) => boolean} */ -var $mapDelete = callBound('Map.prototype.delete', true); -/** @type {(thisArg: Map) => number} */ -var $mapSize = callBound('Map.prototype.size', true); /** @type {import('.')} */ -module.exports = !!$Map && /** @type {Exclude} */ function getSideChannelMap() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {Map | undefined} */ var $m; +module.exports = function getSideChannel() { + /** @type {WeakMap} */ var $wm; + /** @type {Map} */ var $m; + /** @type {import('.').RootNode} */ var $o; - /** @type {Channel} */ + /** @type {import('.').Channel} */ var channel = { assert: function (key) { if (!channel.has(key)) { throw new $TypeError('Side channel does not contain ' + inspect(key)); } }, - 'delete': function (key) { - if ($m) { - var result = $mapDelete($m, key); - if ($mapSize($m) === 0) { - $m = void undefined; - } - return result; - } - return false; - }, get: function (key) { // eslint-disable-line consistent-return - if ($m) { - return $mapGet($m, key); + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapGet($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapGet($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return listGet($o, key); + } } }, has: function (key) { - if ($m) { - return $mapHas($m, key); + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapHas($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapHas($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return listHas($o, key); + } } return false; }, set: function (key, value) { - if (!$m) { - // @ts-expect-error TS can't handle narrowing a variable inside a closure - $m = new $Map(); - } - $mapSet($m, key, value); - } - }; - - // @ts-expect-error TODO: figure out why TS is erroring here - return channel; -}; - -},{"call-bound":62,"es-errors/type":417,"get-intrinsic":427,"object-inspect":488}],514:[function(require,module,exports){ -'use strict'; - -var GetIntrinsic = require('get-intrinsic'); -var callBound = require('call-bound'); -var inspect = require('object-inspect'); -var getSideChannelMap = require('side-channel-map'); - -var $TypeError = require('es-errors/type'); -var $WeakMap = GetIntrinsic('%WeakMap%', true); - -/** @type {(thisArg: WeakMap, key: K) => V} */ -var $weakMapGet = callBound('WeakMap.prototype.get', true); -/** @type {(thisArg: WeakMap, key: K, value: V) => void} */ -var $weakMapSet = callBound('WeakMap.prototype.set', true); -/** @type {(thisArg: WeakMap, key: K) => boolean} */ -var $weakMapHas = callBound('WeakMap.prototype.has', true); -/** @type {(thisArg: WeakMap, key: K) => boolean} */ -var $weakMapDelete = callBound('WeakMap.prototype.delete', true); - -/** @type {import('.')} */ -module.exports = $WeakMap - ? /** @type {Exclude} */ function getSideChannelWeakMap() { - /** @typedef {ReturnType} Channel */ - /** @typedef {Parameters[0]} K */ - /** @typedef {Parameters[1]} V */ - - /** @type {WeakMap | undefined} */ var $wm; - /** @type {Channel | undefined} */ var $m; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapDelete($wm, key); - } - } else if (getSideChannelMap) { - if ($m) { - return $m['delete'](key); - } + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if (!$wm) { + $wm = new $WeakMap(); } - return false; - }, - get: function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapGet($wm, key); - } - } - return $m && $m.get(key); - }, - has: function (key) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if ($wm) { - return $weakMapHas($wm, key); - } + $weakMapSet($wm, key, value); + } else if ($Map) { + if (!$m) { + $m = new $Map(); } - return !!$m && $m.has(key); - }, - set: function (key, value) { - if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { - if (!$wm) { - $wm = new $WeakMap(); - } - $weakMapSet($wm, key, value); - } else if (getSideChannelMap) { - if (!$m) { - $m = getSideChannelMap(); - } - // eslint-disable-next-line no-extra-parens - /** @type {NonNullable} */ ($m).set(key, value); + $mapSet($m, key, value); + } else { + if (!$o) { + // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head + $o = { key: {}, next: null }; } + listSet($o, key, value); } - }; - - // @ts-expect-error TODO: figure out why this is erroring - return channel; - } - : getSideChannelMap; - -},{"call-bound":62,"es-errors/type":417,"get-intrinsic":427,"object-inspect":488,"side-channel-map":513}],515:[function(require,module,exports){ -'use strict'; - -var $TypeError = require('es-errors/type'); -var inspect = require('object-inspect'); -var getSideChannelList = require('side-channel-list'); -var getSideChannelMap = require('side-channel-map'); -var getSideChannelWeakMap = require('side-channel-weakmap'); - -var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList; - -/** @type {import('.')} */ -module.exports = function getSideChannel() { - /** @typedef {ReturnType} Channel */ - - /** @type {Channel | undefined} */ var $channelData; - - /** @type {Channel} */ - var channel = { - assert: function (key) { - if (!channel.has(key)) { - throw new $TypeError('Side channel does not contain ' + inspect(key)); - } - }, - 'delete': function (key) { - return !!$channelData && $channelData['delete'](key); - }, - get: function (key) { - return $channelData && $channelData.get(key); - }, - has: function (key) { - return !!$channelData && $channelData.has(key); - }, - set: function (key, value) { - if (!$channelData) { - $channelData = makeChannel(); - } - - $channelData.set(key, value); } }; - // @ts-expect-error TODO: figure out why this is erroring return channel; }; -},{"es-errors/type":417,"object-inspect":488,"side-channel-list":512,"side-channel-map":513,"side-channel-weakmap":514}],516:[function(require,module,exports){ +},{"call-bind/callBound":54,"es-errors/type":410,"get-intrinsic":419,"object-inspect":469}],493:[function(require,module,exports){ "use strict"; /** * Initialize backoff timer with `opts`. @@ -30374,7 +29616,7 @@ module.exports = function getSideChannel() { * @api public */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.Backoff = Backoff; +exports.Backoff = void 0; function Backoff(opts) { opts = opts || {}; this.ms = opts.min || 100; @@ -30383,6 +29625,7 @@ function Backoff(opts) { this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; this.attempts = 0; } +exports.Backoff = Backoff; /** * Return the backoff duration. * @@ -30431,23 +29674,20 @@ Backoff.prototype.setJitter = function (jitter) { this.jitter = jitter; }; -},{}],517:[function(require,module,exports){ +},{}],494:[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.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.Socket = exports.Manager = exports.protocol = void 0; -exports.io = lookup; -exports.connect = lookup; -exports.default = lookup; +exports.default = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0; const url_js_1 = require("./url.js"); const manager_js_1 = require("./manager.js"); Object.defineProperty(exports, "Manager", { enumerable: true, get: function () { return manager_js_1.Manager; } }); const socket_js_1 = require("./socket.js"); Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_js_1.Socket; } }); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client"); // debug() +const debug = debug_1.default("socket.io-client"); // debug() /** * Managers cache. */ @@ -30458,7 +29698,7 @@ function lookup(uri, opts) { uri = undefined; } opts = opts || {}; - const parsed = (0, url_js_1.url)(uri, opts.path || "/socket.io"); + const parsed = url_js_1.url(uri, opts.path || "/socket.io"); const source = parsed.source; const id = parsed.id; const path = parsed.path; @@ -30484,6 +29724,9 @@ function lookup(uri, opts) { } return io.socket(parsed.path, opts); } +exports.io = lookup; +exports.connect = lookup; +exports.default = lookup; // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a // namespace (e.g. `io.connect(...)`), for backward compatibility Object.assign(lookup, { @@ -30499,25 +29742,14 @@ Object.assign(lookup, { */ var socket_io_parser_1 = require("socket.io-parser"); Object.defineProperty(exports, "protocol", { enumerable: true, get: function () { return socket_io_parser_1.protocol; } }); -var engine_io_client_1 = require("engine.io-client"); -Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return engine_io_client_1.Fetch; } }); -Object.defineProperty(exports, "NodeXHR", { enumerable: true, get: function () { return engine_io_client_1.NodeXHR; } }); -Object.defineProperty(exports, "XHR", { enumerable: true, get: function () { return engine_io_client_1.XHR; } }); -Object.defineProperty(exports, "NodeWebSocket", { enumerable: true, get: function () { return engine_io_client_1.NodeWebSocket; } }); -Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return engine_io_client_1.WebSocket; } }); -Object.defineProperty(exports, "WebTransport", { enumerable: true, get: function () { return engine_io_client_1.WebTransport; } }); module.exports = lookup; -},{"./manager.js":518,"./socket.js":520,"./url.js":521,"debug":522,"engine.io-client":394,"socket.io-parser":525}],518:[function(require,module,exports){ +},{"./manager.js":495,"./socket.js":497,"./url.js":498,"debug":361,"socket.io-parser":500}],495:[function(require,module,exports){ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); + 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]; @@ -30546,7 +29778,7 @@ const on_js_1 = require("./on.js"); const backo2_js_1 = require("./contrib/backo2.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:manager"); // debug() +const debug = debug_1.default("socket.io-client:manager"); // debug() class Manager extends component_emitter_1.Emitter { constructor(uri, opts) { var _a; @@ -30560,7 +29792,7 @@ class Manager extends component_emitter_1.Emitter { opts = opts || {}; opts.path = opts.path || "/socket.io"; this.opts = opts; - (0, engine_io_client_1.installTimerFunctions)(this, opts); + engine_io_client_1.installTimerFunctions(this, opts); this.reconnection(opts.reconnection !== false); this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); this.reconnectionDelay(opts.reconnectionDelay || 1000); @@ -30585,9 +29817,6 @@ class Manager extends component_emitter_1.Emitter { if (!arguments.length) return this._reconnection; this._reconnection = !!v; - if (!v) { - this.skipReconnect = true; - } return this; } reconnectionAttempts(v) { @@ -30659,7 +29888,7 @@ class Manager extends component_emitter_1.Emitter { this._readyState = "opening"; this.skipReconnect = false; // emit `open` - const openSubDestroy = (0, on_js_1.on)(socket, "open", function () { + const openSubDestroy = on_js_1.on(socket, "open", function () { self.onopen(); fn && fn(); }); @@ -30677,7 +29906,7 @@ class Manager extends component_emitter_1.Emitter { } }; // emit `error` - const errorSub = (0, on_js_1.on)(socket, "error", onError); + const errorSub = on_js_1.on(socket, "error", onError); if (false !== this._timeout) { const timeout = this._timeout; debug("connect attempt will timeout after %d", timeout); @@ -30722,9 +29951,7 @@ class Manager extends component_emitter_1.Emitter { this.emitReserved("open"); // add new subs const socket = this.engine; - this.subs.push((0, on_js_1.on)(socket, "ping", this.onping.bind(this)), (0, on_js_1.on)(socket, "data", this.ondata.bind(this)), (0, on_js_1.on)(socket, "error", this.onerror.bind(this)), (0, on_js_1.on)(socket, "close", this.onclose.bind(this)), - // @ts-ignore - (0, on_js_1.on)(this.decoder, "decoded", this.ondecoded.bind(this))); + this.subs.push(on_js_1.on(socket, "ping", this.onping.bind(this)), on_js_1.on(socket, "data", this.ondata.bind(this)), on_js_1.on(socket, "error", this.onerror.bind(this)), on_js_1.on(socket, "close", this.onclose.bind(this)), on_js_1.on(this.decoder, "decoded", this.ondecoded.bind(this))); } /** * Called upon a ping. @@ -30754,7 +29981,7 @@ class Manager extends component_emitter_1.Emitter { */ ondecoded(packet) { // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error" - (0, engine_io_client_1.nextTick)(() => { + engine_io_client_1.nextTick(() => { this.emitReserved("packet", packet); }, this.setTimeoutFn); } @@ -30835,6 +30062,8 @@ class Manager extends component_emitter_1.Emitter { this.skipReconnect = true; this._reconnecting = false; this.onclose("forced close"); + if (this.engine) + this.engine.close(); } /** * Alias for close() @@ -30845,19 +30074,13 @@ class Manager extends component_emitter_1.Emitter { return this._close(); } /** - * Called when: - * - * - the low-level engine is closed - * - the parser encountered a badly formatted packet - * - all sockets are disconnected + * Called upon engine close. * * @private */ onclose(reason, description) { - var _a; debug("closed due to %s", reason); this.cleanup(); - (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close(); this.backoff.reset(); this._readyState = "closed"; this.emitReserved("close", reason, description); @@ -30927,18 +30150,19 @@ class Manager extends component_emitter_1.Emitter { } exports.Manager = Manager; -},{"./contrib/backo2.js":516,"./on.js":519,"./socket.js":520,"@socket.io/component-emitter":23,"debug":522,"engine.io-client":394,"socket.io-parser":525}],519:[function(require,module,exports){ +},{"./contrib/backo2.js":493,"./on.js":496,"./socket.js":497,"@socket.io/component-emitter":23,"debug":361,"engine.io-client":389,"socket.io-parser":500}],496:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.on = on; +exports.on = void 0; function on(obj, ev, fn) { obj.on(ev, fn); return function subDestroy() { obj.off(ev, fn); }; } +exports.on = on; -},{}],520:[function(require,module,exports){ +},{}],497:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -30949,7 +30173,7 @@ const socket_io_parser_1 = require("socket.io-parser"); const on_js_1 = require("./on.js"); const component_emitter_1 = require("@socket.io/component-emitter"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:socket"); // debug() +const debug = debug_1.default("socket.io-client:socket"); // debug() /** * Internal events. * These events can't be emitted by the user. @@ -31095,10 +30319,10 @@ class Socket extends component_emitter_1.Emitter { return; const io = this.io; this.subs = [ - (0, on_js_1.on)(io, "open", this.onopen.bind(this)), - (0, on_js_1.on)(io, "packet", this.onpacket.bind(this)), - (0, on_js_1.on)(io, "error", this.onerror.bind(this)), - (0, on_js_1.on)(io, "close", this.onclose.bind(this)), + on_js_1.on(io, "open", this.onopen.bind(this)), + on_js_1.on(io, "packet", this.onpacket.bind(this)), + on_js_1.on(io, "error", this.onerror.bind(this)), + on_js_1.on(io, "close", this.onclose.bind(this)), ]; } /** @@ -31185,7 +30409,6 @@ class Socket extends component_emitter_1.Emitter { * @return self */ emit(ev, ...args) { - var _a, _b, _c; if (RESERVED_EVENTS.hasOwnProperty(ev)) { throw new Error('"' + ev.toString() + '" is a reserved event name'); } @@ -31208,13 +30431,14 @@ class Socket extends component_emitter_1.Emitter { this._registerAckCallback(id, ack); packet.id = id; } - const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable; - const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired()); - const discardPacket = this.flags.volatile && !isTransportWritable; + const isTransportWritable = this.io.engine && + this.io.engine.transport && + this.io.engine.transport.writable; + const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected); if (discardPacket) { debug("discard packet as the transport is not currently writable"); } - else if (isConnected) { + else if (this.connected) { this.notifyOutgoingListeners(packet); this.packet(packet); } @@ -31850,16 +31074,16 @@ class Socket extends component_emitter_1.Emitter { } exports.Socket = Socket; -},{"./on.js":519,"@socket.io/component-emitter":23,"debug":522,"socket.io-parser":525}],521:[function(require,module,exports){ +},{"./on.js":496,"@socket.io/component-emitter":23,"debug":361,"socket.io-parser":500}],498:[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.url = url; +exports.url = void 0; const engine_io_client_1 = require("engine.io-client"); const debug_1 = __importDefault(require("debug")); // debug() -const debug = (0, debug_1.default)("socket.io-client:url"); // debug() +const debug = debug_1.default("socket.io-client:url"); // debug() /** * URL parser. * @@ -31896,7 +31120,7 @@ function url(uri, path = "", loc) { } // parse debug("parse %s", uri); - obj = (0, engine_io_client_1.parse)(uri); + obj = engine_io_client_1.parse(uri); } // make sure we treat `localhost:80` and `localhost` equally if (!obj.port) { @@ -31920,12 +31144,9 @@ function url(uri, path = "", loc) { (loc && loc.port === obj.port ? "" : ":" + obj.port); return obj; } +exports.url = url; -},{"debug":522,"engine.io-client":394}],522:[function(require,module,exports){ -arguments[4][404][0].apply(exports,arguments) -},{"./common":523,"_process":503,"dup":404}],523:[function(require,module,exports){ -arguments[4][405][0].apply(exports,arguments) -},{"dup":405,"ms":487}],524:[function(require,module,exports){ +},{"debug":361,"engine.io-client":389}],499:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reconstructPacket = exports.deconstructPacket = void 0; @@ -32015,7 +31236,7 @@ function _reconstructPacket(data, buffers) { return data; } -},{"./is-binary.js":526}],525:[function(require,module,exports){ +},{"./is-binary.js":501}],500:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0; @@ -32338,7 +31559,7 @@ class BinaryReconstructor { } } -},{"./binary.js":524,"./is-binary.js":526,"@socket.io/component-emitter":23,"debug":527}],526:[function(require,module,exports){ +},{"./binary.js":499,"./is-binary.js":501,"@socket.io/component-emitter":23,"debug":361}],501:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasBinary = exports.isBinary = void 0; @@ -32395,19 +31616,14 @@ function hasBinary(obj, toJSON) { } exports.hasBinary = hasBinary; -},{}],527:[function(require,module,exports){ -arguments[4][404][0].apply(exports,arguments) -},{"./common":528,"_process":503,"dup":404}],528:[function(require,module,exports){ -arguments[4][405][0].apply(exports,arguments) -},{"dup":405,"ms":487}],529:[function(require,module,exports){ +},{}],502:[function(require,module,exports){ 'use strict'; var SLOT = require('internal-slot'); -var $SyntaxError = require('es-errors/syntax'); +var $SyntaxError = SyntaxError; var $StopIteration = typeof StopIteration === 'object' ? StopIteration : null; -/** @type {import('.')} */ module.exports = function getStopIterationIterator(origIterator) { if (!$StopIteration) { throw new $SyntaxError('this environment lacks StopIteration'); @@ -32415,18 +31631,14 @@ module.exports = function getStopIterationIterator(origIterator) { SLOT.set(origIterator, '[[Done]]', false); - /** @template T @typedef {T extends Iterator ? U : never} IteratorType */ - /** @typedef {IteratorType>} T */ var siIterator = { - next: /** @type {() => IteratorResult} */ function next() { - // eslint-disable-next-line no-extra-parens - var iterator = /** @type {typeof origIterator} */ (SLOT.get(this, '[[Iterator]]')); - var done = !!SLOT.get(iterator, '[[Done]]'); + next: function next() { + var iterator = SLOT.get(this, '[[Iterator]]'); + var done = SLOT.get(iterator, '[[Done]]'); try { return { done: done, - // eslint-disable-next-line no-extra-parens - value: done ? void undefined : /** @type {T} */ (iterator.next()) + value: done ? void undefined : iterator.next() }; } catch (e) { SLOT.set(iterator, '[[Done]]', true); @@ -32443,11 +31655,10 @@ module.exports = function getStopIterationIterator(origIterator) { SLOT.set(siIterator, '[[Iterator]]', origIterator); - // @ts-expect-error TODO FIXME return siIterator; }; -},{"es-errors/syntax":416,"internal-slot":454}],530:[function(require,module,exports){ +},{"internal-slot":443}],503:[function(require,module,exports){ 'use strict'; var isString = require('is-string'); @@ -32456,7 +31667,6 @@ var isBoolean = require('is-boolean-object'); var isSymbol = require('is-symbol'); var isBigInt = require('is-bigint'); -/** @type {import('.')} */ // eslint-disable-next-line consistent-return module.exports = function whichBoxedPrimitive(value) { // eslint-disable-next-line eqeqeq @@ -32480,7 +31690,7 @@ module.exports = function whichBoxedPrimitive(value) { } }; -},{"is-bigint":457,"is-boolean-object":458,"is-number-object":463,"is-string":467,"is-symbol":468}],531:[function(require,module,exports){ +},{"is-bigint":446,"is-boolean-object":447,"is-number-object":452,"is-string":456,"is-symbol":457}],504:[function(require,module,exports){ 'use strict'; var isMap = require('is-map'); @@ -32507,14 +31717,14 @@ module.exports = function whichCollection(/** @type {unknown} */ value) { return false; }; -},{"is-map":461,"is-set":465,"is-weakmap":469,"is-weakset":470}],532:[function(require,module,exports){ +},{"is-map":450,"is-set":454,"is-weakmap":458,"is-weakset":459}],505:[function(require,module,exports){ (function (global){(function (){ 'use strict'; var forEach = require('for-each'); var availableTypedArrays = require('available-typed-arrays'); var callBind = require('call-bind'); -var callBound = require('call-bound'); +var callBound = require('call-bind/callBound'); var gOPD = require('gopd'); /** @type {(O: object) => string} */ @@ -32627,7 +31837,7 @@ module.exports = function whichTypedArray(value) { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"available-typed-arrays":49,"call-bind":61,"call-bound":62,"for-each":423,"gopd":432,"has-tostringtag/shams":437}],533:[function(require,module,exports){ +},{"available-typed-arrays":49,"call-bind":55,"call-bind/callBound":54,"for-each":415,"gopd":420,"has-tostringtag/shams":426}],506:[function(require,module,exports){ /* eslint-disable */ /** * used in the test-docs as web-worker @@ -32697,4 +31907,4 @@ self.addEventListener('message', function (e) { } ; }, false); -},{"../../":2,"@babel/polyfill":11,"async-test-util":34}]},{},[533]); +},{"../../":2,"@babel/polyfill":11,"async-test-util":34}]},{},[506]);