@solana/web3.js 1.70.0 → 1.70.1-pr-29195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.cjs.js +62 -3
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +60 -3
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +62 -3
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +60 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +2190 -2200
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +62 -3
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/__forks__/node/rpc-websocket-factory.ts +1 -0
- package/src/connection.ts +1 -1
- package/src/publickey.ts +4 -0
- package/src/rpc-websocket-factory.ts +4 -0
- package/src/rpc-websocket.ts +75 -0
package/lib/index.iife.js
CHANGED
|
@@ -3,6 +3,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
3
3
|
|
|
4
4
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
5
|
|
|
6
|
+
function getDefaultExportFromCjs (x) {
|
|
7
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
function getAugmentedNamespace(n) {
|
|
7
11
|
var f = n.default;
|
|
8
12
|
if (typeof f == "function") {
|
|
@@ -8301,6 +8305,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
8301
8305
|
}
|
|
8302
8306
|
const SOLANA_SCHEMA = new Map();
|
|
8303
8307
|
|
|
8308
|
+
let _Symbol$toStringTag;
|
|
8304
8309
|
/**
|
|
8305
8310
|
* Maximum length of derived pubkey seed
|
|
8306
8311
|
*/
|
|
@@ -8325,6 +8330,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
8325
8330
|
* A public key
|
|
8326
8331
|
*/
|
|
8327
8332
|
|
|
8333
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
8328
8334
|
class PublicKey extends Struct$1 {
|
|
8329
8335
|
/** @internal */
|
|
8330
8336
|
|
|
@@ -8415,6 +8421,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
8415
8421
|
b.copy(zeroPad, 32 - b.length);
|
|
8416
8422
|
return zeroPad;
|
|
8417
8423
|
}
|
|
8424
|
+
|
|
8425
|
+
get [_Symbol$toStringTag]() {
|
|
8426
|
+
return `PublicKey(${this.toString()})`;
|
|
8427
|
+
}
|
|
8418
8428
|
/**
|
|
8419
8429
|
* Return the base-58 representation of the public key
|
|
8420
8430
|
*/
|
|
@@ -14528,2639 +14538,2619 @@ var solanaWeb3 = (function (exports) {
|
|
|
14528
14538
|
});
|
|
14529
14539
|
}
|
|
14530
14540
|
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14541
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
14542
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
14543
|
+
// generators (like Math.random()).
|
|
14544
|
+
var getRandomValues;
|
|
14545
|
+
var rnds8 = new Uint8Array(16);
|
|
14546
|
+
function rng() {
|
|
14547
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
14548
|
+
if (!getRandomValues) {
|
|
14549
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
|
14550
|
+
// find the complete implementation of crypto (msCrypto) on IE11.
|
|
14551
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
14534
14552
|
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
};
|
|
14540
|
-
}
|
|
14553
|
+
if (!getRandomValues) {
|
|
14554
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
14555
|
+
}
|
|
14556
|
+
}
|
|
14541
14557
|
|
|
14542
|
-
|
|
14543
|
-
}
|
|
14558
|
+
return getRandomValues(rnds8);
|
|
14559
|
+
}
|
|
14544
14560
|
|
|
14545
|
-
var
|
|
14561
|
+
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
14546
14562
|
|
|
14547
|
-
|
|
14563
|
+
function validate(uuid) {
|
|
14564
|
+
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
14565
|
+
}
|
|
14548
14566
|
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
function _defineProperties(target, props) {
|
|
14554
|
-
for (var i = 0; i < props.length; i++) {
|
|
14555
|
-
var descriptor = props[i];
|
|
14556
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14557
|
-
descriptor.configurable = true;
|
|
14558
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
14559
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14560
|
-
}
|
|
14561
|
-
}
|
|
14567
|
+
/**
|
|
14568
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
14569
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
14570
|
+
*/
|
|
14562
14571
|
|
|
14563
|
-
|
|
14564
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
14565
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
14566
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
14567
|
-
writable: false
|
|
14568
|
-
});
|
|
14569
|
-
return Constructor;
|
|
14570
|
-
}
|
|
14572
|
+
var byteToHex = [];
|
|
14571
14573
|
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
return createClass.exports;
|
|
14574
|
+
for (var i = 0; i < 256; ++i) {
|
|
14575
|
+
byteToHex.push((i + 0x100).toString(16).substr(1));
|
|
14575
14576
|
}
|
|
14576
14577
|
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14578
|
+
function stringify(arr) {
|
|
14579
|
+
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
14580
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
14581
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
14582
|
+
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
14583
|
+
// of the following:
|
|
14584
|
+
// - One or more input array values don't map to a hex octet (leading to
|
|
14585
|
+
// "undefined" in the uuid)
|
|
14586
|
+
// - Invalid input values for the RFC `version` or `variant` fields
|
|
14580
14587
|
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
(function (module) {
|
|
14585
|
-
function _classCallCheck(instance, Constructor) {
|
|
14586
|
-
if (!(instance instanceof Constructor)) {
|
|
14587
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14588
|
-
}
|
|
14589
|
-
}
|
|
14588
|
+
if (!validate(uuid)) {
|
|
14589
|
+
throw TypeError('Stringified UUID is invalid');
|
|
14590
|
+
}
|
|
14590
14591
|
|
|
14591
|
-
|
|
14592
|
-
} (classCallCheck));
|
|
14593
|
-
return classCallCheck.exports;
|
|
14592
|
+
return uuid;
|
|
14594
14593
|
}
|
|
14595
14594
|
|
|
14596
|
-
|
|
14595
|
+
//
|
|
14596
|
+
// Inspired by https://github.com/LiosK/UUID.js
|
|
14597
|
+
// and http://docs.python.org/library/uuid.html
|
|
14597
14598
|
|
|
14598
|
-
var
|
|
14599
|
+
var _nodeId;
|
|
14599
14600
|
|
|
14600
|
-
var
|
|
14601
|
+
var _clockseq; // Previous uuid creation time
|
|
14601
14602
|
|
|
14602
|
-
function requireSetPrototypeOf () {
|
|
14603
|
-
if (hasRequiredSetPrototypeOf) return setPrototypeOf.exports;
|
|
14604
|
-
hasRequiredSetPrototypeOf = 1;
|
|
14605
|
-
(function (module) {
|
|
14606
|
-
function _setPrototypeOf(o, p) {
|
|
14607
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
14608
|
-
o.__proto__ = p;
|
|
14609
|
-
return o;
|
|
14610
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
14611
|
-
return _setPrototypeOf(o, p);
|
|
14612
|
-
}
|
|
14613
14603
|
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
return setPrototypeOf.exports;
|
|
14617
|
-
}
|
|
14604
|
+
var _lastMSecs = 0;
|
|
14605
|
+
var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
|
14618
14606
|
|
|
14619
|
-
|
|
14607
|
+
function v1(options, buf, offset) {
|
|
14608
|
+
var i = buf && offset || 0;
|
|
14609
|
+
var b = buf || new Array(16);
|
|
14610
|
+
options = options || {};
|
|
14611
|
+
var node = options.node || _nodeId;
|
|
14612
|
+
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
14613
|
+
// specified. We do this lazily to minimize issues related to insufficient
|
|
14614
|
+
// system entropy. See #189
|
|
14620
14615
|
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
hasRequiredInherits = 1;
|
|
14624
|
-
(function (module) {
|
|
14625
|
-
var setPrototypeOf = requireSetPrototypeOf();
|
|
14616
|
+
if (node == null || clockseq == null) {
|
|
14617
|
+
var seedBytes = options.random || (options.rng || rng)();
|
|
14626
14618
|
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14619
|
+
if (node == null) {
|
|
14620
|
+
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
14621
|
+
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
|
14622
|
+
}
|
|
14631
14623
|
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
writable: false
|
|
14641
|
-
});
|
|
14642
|
-
if (superClass) setPrototypeOf(subClass, superClass);
|
|
14643
|
-
}
|
|
14624
|
+
if (clockseq == null) {
|
|
14625
|
+
// Per 4.2.2, randomize (14 bit) clockseq
|
|
14626
|
+
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
|
14627
|
+
}
|
|
14628
|
+
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
|
14629
|
+
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
14630
|
+
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
14631
|
+
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
14644
14632
|
|
|
14645
|
-
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
14646
|
-
} (inherits));
|
|
14647
|
-
return inherits.exports;
|
|
14648
|
-
}
|
|
14649
14633
|
|
|
14650
|
-
|
|
14634
|
+
var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
14635
|
+
// cycle to simulate higher resolution clock
|
|
14651
14636
|
|
|
14652
|
-
|
|
14637
|
+
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
|
14653
14638
|
|
|
14654
|
-
|
|
14639
|
+
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
|
14655
14640
|
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
function _typeof(obj) {
|
|
14661
|
-
"@babel/helpers - typeof";
|
|
14641
|
+
if (dt < 0 && options.clockseq === undefined) {
|
|
14642
|
+
clockseq = clockseq + 1 & 0x3fff;
|
|
14643
|
+
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
|
14644
|
+
// time interval
|
|
14662
14645
|
|
|
14663
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
14664
|
-
return typeof obj;
|
|
14665
|
-
} : function (obj) {
|
|
14666
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
14667
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
14668
|
-
}
|
|
14669
14646
|
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
}
|
|
14647
|
+
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
|
|
14648
|
+
nsecs = 0;
|
|
14649
|
+
} // Per 4.2.1.2 Throw error if too many uuids are requested
|
|
14674
14650
|
|
|
14675
|
-
var assertThisInitialized = {exports: {}};
|
|
14676
14651
|
|
|
14677
|
-
|
|
14652
|
+
if (nsecs >= 10000) {
|
|
14653
|
+
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
14654
|
+
}
|
|
14678
14655
|
|
|
14679
|
-
|
|
14680
|
-
|
|
14681
|
-
|
|
14682
|
-
(function (module) {
|
|
14683
|
-
function _assertThisInitialized(self) {
|
|
14684
|
-
if (self === void 0) {
|
|
14685
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
14686
|
-
}
|
|
14656
|
+
_lastMSecs = msecs;
|
|
14657
|
+
_lastNSecs = nsecs;
|
|
14658
|
+
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
14687
14659
|
|
|
14688
|
-
|
|
14689
|
-
}
|
|
14660
|
+
msecs += 12219292800000; // `time_low`
|
|
14690
14661
|
|
|
14691
|
-
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14662
|
+
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
14663
|
+
b[i++] = tl >>> 24 & 0xff;
|
|
14664
|
+
b[i++] = tl >>> 16 & 0xff;
|
|
14665
|
+
b[i++] = tl >>> 8 & 0xff;
|
|
14666
|
+
b[i++] = tl & 0xff; // `time_mid`
|
|
14695
14667
|
|
|
14696
|
-
|
|
14668
|
+
var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
|
14669
|
+
b[i++] = tmh >>> 8 & 0xff;
|
|
14670
|
+
b[i++] = tmh & 0xff; // `time_high_and_version`
|
|
14697
14671
|
|
|
14698
|
-
|
|
14699
|
-
if (hasRequiredPossibleConstructorReturn) return possibleConstructorReturn.exports;
|
|
14700
|
-
hasRequiredPossibleConstructorReturn = 1;
|
|
14701
|
-
(function (module) {
|
|
14702
|
-
var _typeof = require_typeof()["default"];
|
|
14672
|
+
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
|
14703
14673
|
|
|
14704
|
-
|
|
14674
|
+
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
|
14705
14675
|
|
|
14706
|
-
|
|
14707
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
14708
|
-
return call;
|
|
14709
|
-
} else if (call !== void 0) {
|
|
14710
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
14711
|
-
}
|
|
14676
|
+
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
|
|
14712
14677
|
|
|
14713
|
-
|
|
14714
|
-
}
|
|
14678
|
+
b[i++] = clockseq & 0xff; // `node`
|
|
14715
14679
|
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
|
|
14719
|
-
}
|
|
14680
|
+
for (var n = 0; n < 6; ++n) {
|
|
14681
|
+
b[i + n] = node[n];
|
|
14682
|
+
}
|
|
14720
14683
|
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
var hasRequiredGetPrototypeOf;
|
|
14724
|
-
|
|
14725
|
-
function requireGetPrototypeOf () {
|
|
14726
|
-
if (hasRequiredGetPrototypeOf) return getPrototypeOf.exports;
|
|
14727
|
-
hasRequiredGetPrototypeOf = 1;
|
|
14728
|
-
(function (module) {
|
|
14729
|
-
function _getPrototypeOf(o) {
|
|
14730
|
-
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
14731
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
14732
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
14733
|
-
return _getPrototypeOf(o);
|
|
14734
|
-
}
|
|
14735
|
-
|
|
14736
|
-
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
14737
|
-
} (getPrototypeOf));
|
|
14738
|
-
return getPrototypeOf.exports;
|
|
14684
|
+
return buf || stringify(b);
|
|
14739
14685
|
}
|
|
14740
14686
|
|
|
14741
|
-
|
|
14687
|
+
function parse(uuid) {
|
|
14688
|
+
if (!validate(uuid)) {
|
|
14689
|
+
throw TypeError('Invalid UUID');
|
|
14690
|
+
}
|
|
14742
14691
|
|
|
14743
|
-
|
|
14692
|
+
var v;
|
|
14693
|
+
var arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
14744
14694
|
|
|
14745
|
-
|
|
14695
|
+
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
14696
|
+
arr[1] = v >>> 16 & 0xff;
|
|
14697
|
+
arr[2] = v >>> 8 & 0xff;
|
|
14698
|
+
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
14746
14699
|
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
hasRequiredEventemitter3 = 1;
|
|
14750
|
-
(function (module) {
|
|
14700
|
+
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
14701
|
+
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
14751
14702
|
|
|
14752
|
-
|
|
14753
|
-
|
|
14703
|
+
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
14704
|
+
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
14754
14705
|
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
*
|
|
14759
|
-
* @constructor
|
|
14760
|
-
* @private
|
|
14761
|
-
*/
|
|
14762
|
-
function Events() {}
|
|
14706
|
+
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
14707
|
+
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
14708
|
+
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
14763
14709
|
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
Events.prototype = Object.create(null);
|
|
14710
|
+
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
14711
|
+
arr[11] = v / 0x100000000 & 0xff;
|
|
14712
|
+
arr[12] = v >>> 24 & 0xff;
|
|
14713
|
+
arr[13] = v >>> 16 & 0xff;
|
|
14714
|
+
arr[14] = v >>> 8 & 0xff;
|
|
14715
|
+
arr[15] = v & 0xff;
|
|
14716
|
+
return arr;
|
|
14717
|
+
}
|
|
14773
14718
|
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
14777
|
-
//
|
|
14778
|
-
if (!new Events().__proto__) prefix = false;
|
|
14779
|
-
}
|
|
14719
|
+
function stringToBytes(str) {
|
|
14720
|
+
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
14780
14721
|
|
|
14781
|
-
|
|
14782
|
-
* Representation of a single event listener.
|
|
14783
|
-
*
|
|
14784
|
-
* @param {Function} fn The listener function.
|
|
14785
|
-
* @param {*} context The context to invoke the listener with.
|
|
14786
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
14787
|
-
* @constructor
|
|
14788
|
-
* @private
|
|
14789
|
-
*/
|
|
14790
|
-
function EE(fn, context, once) {
|
|
14791
|
-
this.fn = fn;
|
|
14792
|
-
this.context = context;
|
|
14793
|
-
this.once = once || false;
|
|
14794
|
-
}
|
|
14722
|
+
var bytes = [];
|
|
14795
14723
|
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
14800
|
-
* @param {(String|Symbol)} event The event name.
|
|
14801
|
-
* @param {Function} fn The listener function.
|
|
14802
|
-
* @param {*} context The context to invoke the listener with.
|
|
14803
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
14804
|
-
* @returns {EventEmitter}
|
|
14805
|
-
* @private
|
|
14806
|
-
*/
|
|
14807
|
-
function addListener(emitter, event, fn, context, once) {
|
|
14808
|
-
if (typeof fn !== 'function') {
|
|
14809
|
-
throw new TypeError('The listener must be a function');
|
|
14810
|
-
}
|
|
14724
|
+
for (var i = 0; i < str.length; ++i) {
|
|
14725
|
+
bytes.push(str.charCodeAt(i));
|
|
14726
|
+
}
|
|
14811
14727
|
|
|
14812
|
-
|
|
14813
|
-
|
|
14728
|
+
return bytes;
|
|
14729
|
+
}
|
|
14814
14730
|
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14731
|
+
var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
14732
|
+
var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
14733
|
+
function v35 (name, version, hashfunc) {
|
|
14734
|
+
function generateUUID(value, namespace, buf, offset) {
|
|
14735
|
+
if (typeof value === 'string') {
|
|
14736
|
+
value = stringToBytes(value);
|
|
14737
|
+
}
|
|
14818
14738
|
|
|
14819
|
-
|
|
14820
|
-
|
|
14739
|
+
if (typeof namespace === 'string') {
|
|
14740
|
+
namespace = parse(namespace);
|
|
14741
|
+
}
|
|
14821
14742
|
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14827
|
-
* @private
|
|
14828
|
-
*/
|
|
14829
|
-
function clearEvent(emitter, evt) {
|
|
14830
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
14831
|
-
else delete emitter._events[evt];
|
|
14832
|
-
}
|
|
14743
|
+
if (namespace.length !== 16) {
|
|
14744
|
+
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
14745
|
+
} // Compute hash of namespace and value, Per 4.3
|
|
14746
|
+
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
14747
|
+
// hashfunc([...namespace, ... value])`
|
|
14833
14748
|
|
|
14834
|
-
/**
|
|
14835
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
14836
|
-
* `EventEmitter` interface.
|
|
14837
|
-
*
|
|
14838
|
-
* @constructor
|
|
14839
|
-
* @public
|
|
14840
|
-
*/
|
|
14841
|
-
function EventEmitter() {
|
|
14842
|
-
this._events = new Events();
|
|
14843
|
-
this._eventsCount = 0;
|
|
14844
|
-
}
|
|
14845
14749
|
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
*/
|
|
14853
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
14854
|
-
var names = []
|
|
14855
|
-
, events
|
|
14856
|
-
, name;
|
|
14750
|
+
var bytes = new Uint8Array(16 + value.length);
|
|
14751
|
+
bytes.set(namespace);
|
|
14752
|
+
bytes.set(value, namespace.length);
|
|
14753
|
+
bytes = hashfunc(bytes);
|
|
14754
|
+
bytes[6] = bytes[6] & 0x0f | version;
|
|
14755
|
+
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
14857
14756
|
|
|
14858
|
-
|
|
14757
|
+
if (buf) {
|
|
14758
|
+
offset = offset || 0;
|
|
14859
14759
|
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14760
|
+
for (var i = 0; i < 16; ++i) {
|
|
14761
|
+
buf[offset + i] = bytes[i];
|
|
14762
|
+
}
|
|
14863
14763
|
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
}
|
|
14764
|
+
return buf;
|
|
14765
|
+
}
|
|
14867
14766
|
|
|
14868
|
-
|
|
14869
|
-
|
|
14767
|
+
return stringify(bytes);
|
|
14768
|
+
} // Function#name is not settable on some platforms (#270)
|
|
14870
14769
|
|
|
14871
|
-
/**
|
|
14872
|
-
* Return the listeners registered for a given event.
|
|
14873
|
-
*
|
|
14874
|
-
* @param {(String|Symbol)} event The event name.
|
|
14875
|
-
* @returns {Array} The registered listeners.
|
|
14876
|
-
* @public
|
|
14877
|
-
*/
|
|
14878
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
14879
|
-
var evt = prefix ? prefix + event : event
|
|
14880
|
-
, handlers = this._events[evt];
|
|
14881
14770
|
|
|
14882
|
-
|
|
14883
|
-
|
|
14771
|
+
try {
|
|
14772
|
+
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
14773
|
+
} catch (err) {} // For CommonJS default export support
|
|
14884
14774
|
|
|
14885
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
14886
|
-
ee[i] = handlers[i].fn;
|
|
14887
|
-
}
|
|
14888
14775
|
|
|
14889
|
-
|
|
14890
|
-
|
|
14776
|
+
generateUUID.DNS = DNS;
|
|
14777
|
+
generateUUID.URL = URL;
|
|
14778
|
+
return generateUUID;
|
|
14779
|
+
}
|
|
14891
14780
|
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14781
|
+
/*
|
|
14782
|
+
* Browser-compatible JavaScript MD5
|
|
14783
|
+
*
|
|
14784
|
+
* Modification of JavaScript MD5
|
|
14785
|
+
* https://github.com/blueimp/JavaScript-MD5
|
|
14786
|
+
*
|
|
14787
|
+
* Copyright 2011, Sebastian Tschan
|
|
14788
|
+
* https://blueimp.net
|
|
14789
|
+
*
|
|
14790
|
+
* Licensed under the MIT license:
|
|
14791
|
+
* https://opensource.org/licenses/MIT
|
|
14792
|
+
*
|
|
14793
|
+
* Based on
|
|
14794
|
+
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
|
14795
|
+
* Digest Algorithm, as defined in RFC 1321.
|
|
14796
|
+
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
|
14797
|
+
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
|
14798
|
+
* Distributed under the BSD License
|
|
14799
|
+
* See http://pajhome.org.uk/crypt/md5 for more info.
|
|
14800
|
+
*/
|
|
14801
|
+
function md5(bytes) {
|
|
14802
|
+
if (typeof bytes === 'string') {
|
|
14803
|
+
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
14902
14804
|
|
|
14903
|
-
|
|
14904
|
-
if (listeners.fn) return 1;
|
|
14905
|
-
return listeners.length;
|
|
14906
|
-
};
|
|
14805
|
+
bytes = new Uint8Array(msg.length);
|
|
14907
14806
|
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
14913
|
-
* @public
|
|
14914
|
-
*/
|
|
14915
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
14916
|
-
var evt = prefix ? prefix + event : event;
|
|
14807
|
+
for (var i = 0; i < msg.length; ++i) {
|
|
14808
|
+
bytes[i] = msg.charCodeAt(i);
|
|
14809
|
+
}
|
|
14810
|
+
}
|
|
14917
14811
|
|
|
14918
|
-
|
|
14812
|
+
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
|
|
14813
|
+
}
|
|
14814
|
+
/*
|
|
14815
|
+
* Convert an array of little-endian words to an array of bytes
|
|
14816
|
+
*/
|
|
14919
14817
|
|
|
14920
|
-
var listeners = this._events[evt]
|
|
14921
|
-
, len = arguments.length
|
|
14922
|
-
, args
|
|
14923
|
-
, i;
|
|
14924
14818
|
|
|
14925
|
-
|
|
14926
|
-
|
|
14819
|
+
function md5ToHexEncodedArray(input) {
|
|
14820
|
+
var output = [];
|
|
14821
|
+
var length32 = input.length * 32;
|
|
14822
|
+
var hexTab = '0123456789abcdef';
|
|
14927
14823
|
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
14934
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
14935
|
-
}
|
|
14824
|
+
for (var i = 0; i < length32; i += 8) {
|
|
14825
|
+
var x = input[i >> 5] >>> i % 32 & 0xff;
|
|
14826
|
+
var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
|
|
14827
|
+
output.push(hex);
|
|
14828
|
+
}
|
|
14936
14829
|
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14830
|
+
return output;
|
|
14831
|
+
}
|
|
14832
|
+
/**
|
|
14833
|
+
* Calculate output length with padding and bit length
|
|
14834
|
+
*/
|
|
14940
14835
|
|
|
14941
|
-
listeners.fn.apply(listeners.context, args);
|
|
14942
|
-
} else {
|
|
14943
|
-
var length = listeners.length
|
|
14944
|
-
, j;
|
|
14945
14836
|
|
|
14946
|
-
|
|
14947
|
-
|
|
14837
|
+
function getOutputLength(inputLength8) {
|
|
14838
|
+
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
|
|
14839
|
+
}
|
|
14840
|
+
/*
|
|
14841
|
+
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
|
14842
|
+
*/
|
|
14948
14843
|
|
|
14949
|
-
switch (len) {
|
|
14950
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
14951
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
14952
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
14953
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
14954
|
-
default:
|
|
14955
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
14956
|
-
args[j - 1] = arguments[j];
|
|
14957
|
-
}
|
|
14958
14844
|
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14845
|
+
function wordsToMd5(x, len) {
|
|
14846
|
+
/* append padding */
|
|
14847
|
+
x[len >> 5] |= 0x80 << len % 32;
|
|
14848
|
+
x[getOutputLength(len) - 1] = len;
|
|
14849
|
+
var a = 1732584193;
|
|
14850
|
+
var b = -271733879;
|
|
14851
|
+
var c = -1732584194;
|
|
14852
|
+
var d = 271733878;
|
|
14963
14853
|
|
|
14964
|
-
|
|
14965
|
-
|
|
14854
|
+
for (var i = 0; i < x.length; i += 16) {
|
|
14855
|
+
var olda = a;
|
|
14856
|
+
var oldb = b;
|
|
14857
|
+
var oldc = c;
|
|
14858
|
+
var oldd = d;
|
|
14859
|
+
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
|
14860
|
+
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
14861
|
+
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
14862
|
+
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
14863
|
+
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
14864
|
+
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
14865
|
+
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
14866
|
+
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
14867
|
+
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
14868
|
+
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
14869
|
+
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
14870
|
+
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
14871
|
+
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
14872
|
+
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
14873
|
+
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
14874
|
+
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
14875
|
+
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
14876
|
+
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
14877
|
+
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
14878
|
+
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
|
14879
|
+
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
14880
|
+
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
14881
|
+
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
14882
|
+
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
14883
|
+
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
14884
|
+
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
14885
|
+
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
14886
|
+
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
14887
|
+
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
14888
|
+
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
14889
|
+
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
14890
|
+
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
14891
|
+
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
14892
|
+
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
14893
|
+
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
14894
|
+
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
14895
|
+
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
14896
|
+
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
14897
|
+
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
14898
|
+
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
14899
|
+
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
14900
|
+
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
|
14901
|
+
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
14902
|
+
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
14903
|
+
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
14904
|
+
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
14905
|
+
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
14906
|
+
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
14907
|
+
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
|
14908
|
+
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
14909
|
+
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
14910
|
+
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
14911
|
+
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
14912
|
+
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
14913
|
+
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
14914
|
+
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
14915
|
+
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
14916
|
+
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
14917
|
+
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
14918
|
+
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
14919
|
+
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
14920
|
+
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
14921
|
+
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
14922
|
+
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
14923
|
+
a = safeAdd(a, olda);
|
|
14924
|
+
b = safeAdd(b, oldb);
|
|
14925
|
+
c = safeAdd(c, oldc);
|
|
14926
|
+
d = safeAdd(d, oldd);
|
|
14927
|
+
}
|
|
14966
14928
|
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
* @returns {EventEmitter} `this`.
|
|
14974
|
-
* @public
|
|
14975
|
-
*/
|
|
14976
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
14977
|
-
return addListener(this, event, fn, context, false);
|
|
14978
|
-
};
|
|
14929
|
+
return [a, b, c, d];
|
|
14930
|
+
}
|
|
14931
|
+
/*
|
|
14932
|
+
* Convert an array bytes to an array of little-endian words
|
|
14933
|
+
* Characters >255 have their high-byte silently ignored.
|
|
14934
|
+
*/
|
|
14979
14935
|
|
|
14980
|
-
/**
|
|
14981
|
-
* Add a one-time listener for a given event.
|
|
14982
|
-
*
|
|
14983
|
-
* @param {(String|Symbol)} event The event name.
|
|
14984
|
-
* @param {Function} fn The listener function.
|
|
14985
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
14986
|
-
* @returns {EventEmitter} `this`.
|
|
14987
|
-
* @public
|
|
14988
|
-
*/
|
|
14989
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
14990
|
-
return addListener(this, event, fn, context, true);
|
|
14991
|
-
};
|
|
14992
14936
|
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
14998
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
14999
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
15000
|
-
* @returns {EventEmitter} `this`.
|
|
15001
|
-
* @public
|
|
15002
|
-
*/
|
|
15003
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
15004
|
-
var evt = prefix ? prefix + event : event;
|
|
14937
|
+
function bytesToWords(input) {
|
|
14938
|
+
if (input.length === 0) {
|
|
14939
|
+
return [];
|
|
14940
|
+
}
|
|
15005
14941
|
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
clearEvent(this, evt);
|
|
15009
|
-
return this;
|
|
15010
|
-
}
|
|
14942
|
+
var length8 = input.length * 8;
|
|
14943
|
+
var output = new Uint32Array(getOutputLength(length8));
|
|
15011
14944
|
|
|
15012
|
-
|
|
14945
|
+
for (var i = 0; i < length8; i += 8) {
|
|
14946
|
+
output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
|
|
14947
|
+
}
|
|
15013
14948
|
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
clearEvent(this, evt);
|
|
15021
|
-
}
|
|
15022
|
-
} else {
|
|
15023
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
15024
|
-
if (
|
|
15025
|
-
listeners[i].fn !== fn ||
|
|
15026
|
-
(once && !listeners[i].once) ||
|
|
15027
|
-
(context && listeners[i].context !== context)
|
|
15028
|
-
) {
|
|
15029
|
-
events.push(listeners[i]);
|
|
15030
|
-
}
|
|
15031
|
-
}
|
|
14949
|
+
return output;
|
|
14950
|
+
}
|
|
14951
|
+
/*
|
|
14952
|
+
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
14953
|
+
* to work around bugs in some JS interpreters.
|
|
14954
|
+
*/
|
|
15032
14955
|
|
|
15033
|
-
//
|
|
15034
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
15035
|
-
//
|
|
15036
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
15037
|
-
else clearEvent(this, evt);
|
|
15038
|
-
}
|
|
15039
14956
|
|
|
15040
|
-
|
|
15041
|
-
|
|
14957
|
+
function safeAdd(x, y) {
|
|
14958
|
+
var lsw = (x & 0xffff) + (y & 0xffff);
|
|
14959
|
+
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
14960
|
+
return msw << 16 | lsw & 0xffff;
|
|
14961
|
+
}
|
|
14962
|
+
/*
|
|
14963
|
+
* Bitwise rotate a 32-bit number to the left.
|
|
14964
|
+
*/
|
|
15042
14965
|
|
|
15043
|
-
/**
|
|
15044
|
-
* Remove all listeners, or those of the specified event.
|
|
15045
|
-
*
|
|
15046
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
15047
|
-
* @returns {EventEmitter} `this`.
|
|
15048
|
-
* @public
|
|
15049
|
-
*/
|
|
15050
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
15051
|
-
var evt;
|
|
15052
14966
|
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
}
|
|
14967
|
+
function bitRotateLeft(num, cnt) {
|
|
14968
|
+
return num << cnt | num >>> 32 - cnt;
|
|
14969
|
+
}
|
|
14970
|
+
/*
|
|
14971
|
+
* These functions implement the four basic operations the algorithm uses.
|
|
14972
|
+
*/
|
|
15060
14973
|
|
|
15061
|
-
return this;
|
|
15062
|
-
};
|
|
15063
14974
|
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
15068
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
14975
|
+
function md5cmn(q, a, b, x, s, t) {
|
|
14976
|
+
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
|
14977
|
+
}
|
|
15069
14978
|
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
EventEmitter.prefixed = prefix;
|
|
14979
|
+
function md5ff(a, b, c, d, x, s, t) {
|
|
14980
|
+
return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
|
14981
|
+
}
|
|
15074
14982
|
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
14983
|
+
function md5gg(a, b, c, d, x, s, t) {
|
|
14984
|
+
return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
|
14985
|
+
}
|
|
15079
14986
|
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
//
|
|
15083
|
-
{
|
|
15084
|
-
module.exports = EventEmitter;
|
|
15085
|
-
}
|
|
15086
|
-
} (eventemitter3));
|
|
15087
|
-
return eventemitter3.exports;
|
|
14987
|
+
function md5hh(a, b, c, d, x, s, t) {
|
|
14988
|
+
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
|
15088
14989
|
}
|
|
15089
14990
|
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
*/
|
|
14991
|
+
function md5ii(a, b, c, d, x, s, t) {
|
|
14992
|
+
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
14993
|
+
}
|
|
15094
14994
|
|
|
15095
|
-
var
|
|
14995
|
+
var v3 = v35('v3', 0x30, md5);
|
|
14996
|
+
var v3$1 = v3;
|
|
15096
14997
|
|
|
15097
|
-
function
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
(function (exports) {
|
|
14998
|
+
function v4(options, buf, offset) {
|
|
14999
|
+
options = options || {};
|
|
15000
|
+
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
15101
15001
|
|
|
15102
|
-
|
|
15002
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
15003
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
15103
15004
|
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
});
|
|
15107
|
-
exports["default"] = _default;
|
|
15005
|
+
if (buf) {
|
|
15006
|
+
offset = offset || 0;
|
|
15108
15007
|
|
|
15109
|
-
|
|
15008
|
+
for (var i = 0; i < 16; ++i) {
|
|
15009
|
+
buf[offset + i] = rnds[i];
|
|
15010
|
+
}
|
|
15110
15011
|
|
|
15111
|
-
|
|
15012
|
+
return buf;
|
|
15013
|
+
}
|
|
15112
15014
|
|
|
15113
|
-
|
|
15015
|
+
return stringify(rnds);
|
|
15016
|
+
}
|
|
15114
15017
|
|
|
15115
|
-
|
|
15018
|
+
// Adapted from Chris Veness' SHA1 code at
|
|
15019
|
+
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
15020
|
+
function f(s, x, y, z) {
|
|
15021
|
+
switch (s) {
|
|
15022
|
+
case 0:
|
|
15023
|
+
return x & y ^ ~x & z;
|
|
15116
15024
|
|
|
15117
|
-
|
|
15025
|
+
case 1:
|
|
15026
|
+
return x ^ y ^ z;
|
|
15118
15027
|
|
|
15119
|
-
|
|
15028
|
+
case 2:
|
|
15029
|
+
return x & y ^ x & z ^ y & z;
|
|
15120
15030
|
|
|
15121
|
-
|
|
15031
|
+
case 3:
|
|
15032
|
+
return x ^ y ^ z;
|
|
15033
|
+
}
|
|
15034
|
+
}
|
|
15122
15035
|
|
|
15123
|
-
|
|
15036
|
+
function ROTL(x, n) {
|
|
15037
|
+
return x << n | x >>> 32 - n;
|
|
15038
|
+
}
|
|
15124
15039
|
|
|
15125
|
-
|
|
15126
|
-
|
|
15040
|
+
function sha1(bytes) {
|
|
15041
|
+
var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
15042
|
+
var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
15127
15043
|
|
|
15128
|
-
|
|
15044
|
+
if (typeof bytes === 'string') {
|
|
15045
|
+
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
15129
15046
|
|
|
15130
|
-
|
|
15131
|
-
* @constructor
|
|
15132
|
-
* @param {String} address - url to a websocket server
|
|
15133
|
-
* @param {(Object)} options - websocket options
|
|
15134
|
-
* @param {(String|Array)} protocols - a list of protocols
|
|
15135
|
-
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
15136
|
-
*/
|
|
15137
|
-
function WebSocketBrowserImpl(address, options, protocols) {
|
|
15138
|
-
var _this;
|
|
15047
|
+
bytes = [];
|
|
15139
15048
|
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15049
|
+
for (var i = 0; i < msg.length; ++i) {
|
|
15050
|
+
bytes.push(msg.charCodeAt(i));
|
|
15051
|
+
}
|
|
15052
|
+
} else if (!Array.isArray(bytes)) {
|
|
15053
|
+
// Convert Array-like to Array
|
|
15054
|
+
bytes = Array.prototype.slice.call(bytes);
|
|
15055
|
+
}
|
|
15143
15056
|
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15057
|
+
bytes.push(0x80);
|
|
15058
|
+
var l = bytes.length / 4 + 2;
|
|
15059
|
+
var N = Math.ceil(l / 16);
|
|
15060
|
+
var M = new Array(N);
|
|
15147
15061
|
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
};
|
|
15062
|
+
for (var _i = 0; _i < N; ++_i) {
|
|
15063
|
+
var arr = new Uint32Array(16);
|
|
15151
15064
|
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15065
|
+
for (var j = 0; j < 16; ++j) {
|
|
15066
|
+
arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
|
|
15067
|
+
}
|
|
15155
15068
|
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
};
|
|
15069
|
+
M[_i] = arr;
|
|
15070
|
+
}
|
|
15159
15071
|
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
|
|
15163
|
-
* Sends data through a websocket connection
|
|
15164
|
-
* @method
|
|
15165
|
-
* @param {(String|Object)} data - data to be sent via websocket
|
|
15166
|
-
* @param {Object} optionsOrCallback - ws options
|
|
15167
|
-
* @param {Function} callback - a callback called once the data is sent
|
|
15168
|
-
* @return {Undefined}
|
|
15169
|
-
*/
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
(0, _createClass2["default"])(WebSocketBrowserImpl, [{
|
|
15173
|
-
key: "send",
|
|
15174
|
-
value: function send(data, optionsOrCallback, callback) {
|
|
15175
|
-
var cb = callback || optionsOrCallback;
|
|
15176
|
-
|
|
15177
|
-
try {
|
|
15178
|
-
this.socket.send(data);
|
|
15179
|
-
cb();
|
|
15180
|
-
} catch (error) {
|
|
15181
|
-
cb(error);
|
|
15182
|
-
}
|
|
15183
|
-
}
|
|
15184
|
-
/**
|
|
15185
|
-
* Closes an underlying socket
|
|
15186
|
-
* @method
|
|
15187
|
-
* @param {Number} code - status code explaining why the connection is being closed
|
|
15188
|
-
* @param {String} reason - a description why the connection is closing
|
|
15189
|
-
* @return {Undefined}
|
|
15190
|
-
* @throws {Error}
|
|
15191
|
-
*/
|
|
15192
|
-
|
|
15193
|
-
}, {
|
|
15194
|
-
key: "close",
|
|
15195
|
-
value: function close(code, reason) {
|
|
15196
|
-
this.socket.close(code, reason);
|
|
15197
|
-
}
|
|
15198
|
-
}, {
|
|
15199
|
-
key: "addEventListener",
|
|
15200
|
-
value: function addEventListener(type, listener, options) {
|
|
15201
|
-
this.socket.addEventListener(type, listener, options);
|
|
15202
|
-
}
|
|
15203
|
-
}]);
|
|
15204
|
-
return WebSocketBrowserImpl;
|
|
15205
|
-
}(_eventemitter.EventEmitter);
|
|
15206
|
-
/**
|
|
15207
|
-
* factory method for common WebSocket instance
|
|
15208
|
-
* @method
|
|
15209
|
-
* @param {String} address - url to a websocket server
|
|
15210
|
-
* @param {(Object)} options - websocket options
|
|
15211
|
-
* @return {Undefined}
|
|
15212
|
-
*/
|
|
15072
|
+
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
15073
|
+
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
15074
|
+
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
15213
15075
|
|
|
15076
|
+
for (var _i2 = 0; _i2 < N; ++_i2) {
|
|
15077
|
+
var W = new Uint32Array(80);
|
|
15214
15078
|
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
} (websocket_browser));
|
|
15219
|
-
return websocket_browser;
|
|
15220
|
-
}
|
|
15079
|
+
for (var t = 0; t < 16; ++t) {
|
|
15080
|
+
W[t] = M[_i2][t];
|
|
15081
|
+
}
|
|
15221
15082
|
|
|
15222
|
-
|
|
15083
|
+
for (var _t = 16; _t < 80; ++_t) {
|
|
15084
|
+
W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
|
|
15085
|
+
}
|
|
15223
15086
|
|
|
15224
|
-
|
|
15087
|
+
var a = H[0];
|
|
15088
|
+
var b = H[1];
|
|
15089
|
+
var c = H[2];
|
|
15090
|
+
var d = H[3];
|
|
15091
|
+
var e = H[4];
|
|
15225
15092
|
|
|
15226
|
-
|
|
15093
|
+
for (var _t2 = 0; _t2 < 80; ++_t2) {
|
|
15094
|
+
var s = Math.floor(_t2 / 20);
|
|
15095
|
+
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
|
|
15096
|
+
e = d;
|
|
15097
|
+
d = c;
|
|
15098
|
+
c = ROTL(b, 30) >>> 0;
|
|
15099
|
+
b = a;
|
|
15100
|
+
a = T;
|
|
15101
|
+
}
|
|
15227
15102
|
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15103
|
+
H[0] = H[0] + a >>> 0;
|
|
15104
|
+
H[1] = H[1] + b >>> 0;
|
|
15105
|
+
H[2] = H[2] + c >>> 0;
|
|
15106
|
+
H[3] = H[3] + d >>> 0;
|
|
15107
|
+
H[4] = H[4] + e >>> 0;
|
|
15108
|
+
}
|
|
15233
15109
|
|
|
15234
|
-
|
|
15235
|
-
|
|
15110
|
+
return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
|
|
15111
|
+
}
|
|
15236
15112
|
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15240
|
-
var exports = {},
|
|
15241
|
-
Op = Object.prototype,
|
|
15242
|
-
hasOwn = Op.hasOwnProperty,
|
|
15243
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
15244
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
15245
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
15246
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
15113
|
+
var v5 = v35('v5', 0x50, sha1);
|
|
15114
|
+
var v5$1 = v5;
|
|
15247
15115
|
|
|
15248
|
-
|
|
15249
|
-
return Object.defineProperty(obj, key, {
|
|
15250
|
-
value: value,
|
|
15251
|
-
enumerable: !0,
|
|
15252
|
-
configurable: !0,
|
|
15253
|
-
writable: !0
|
|
15254
|
-
}), obj[key];
|
|
15255
|
-
}
|
|
15116
|
+
var nil = '00000000-0000-0000-0000-000000000000';
|
|
15256
15117
|
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
return obj[key] = value;
|
|
15262
|
-
};
|
|
15263
|
-
}
|
|
15118
|
+
function version(uuid) {
|
|
15119
|
+
if (!validate(uuid)) {
|
|
15120
|
+
throw TypeError('Invalid UUID');
|
|
15121
|
+
}
|
|
15264
15122
|
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
generator = Object.create(protoGenerator.prototype),
|
|
15268
|
-
context = new Context(tryLocsList || []);
|
|
15269
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
15270
|
-
var state = "suspendedStart";
|
|
15271
|
-
return function (method, arg) {
|
|
15272
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
15123
|
+
return parseInt(uuid.substr(14, 1), 16);
|
|
15124
|
+
}
|
|
15273
15125
|
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15126
|
+
var esmBrowser = /*#__PURE__*/Object.freeze({
|
|
15127
|
+
__proto__: null,
|
|
15128
|
+
v1: v1,
|
|
15129
|
+
v3: v3$1,
|
|
15130
|
+
v4: v4,
|
|
15131
|
+
v5: v5$1,
|
|
15132
|
+
NIL: nil,
|
|
15133
|
+
version: version,
|
|
15134
|
+
validate: validate,
|
|
15135
|
+
stringify: stringify,
|
|
15136
|
+
parse: parse
|
|
15137
|
+
});
|
|
15278
15138
|
|
|
15279
|
-
|
|
15280
|
-
|
|
15139
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
|
|
15140
|
+
|
|
15141
|
+
const uuid$1 = require$$0.v4;
|
|
15142
|
+
|
|
15143
|
+
/**
|
|
15144
|
+
* Generates a JSON-RPC 1.0 or 2.0 request
|
|
15145
|
+
* @param {String} method Name of method to call
|
|
15146
|
+
* @param {Array|Object} params Array of parameters passed to the method as specified, or an object of parameter names and corresponding value
|
|
15147
|
+
* @param {String|Number|null} [id] Request ID can be a string, number, null for explicit notification or left out for automatic generation
|
|
15148
|
+
* @param {Object} [options]
|
|
15149
|
+
* @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)
|
|
15150
|
+
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
|
|
15151
|
+
* @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID
|
|
15152
|
+
* @throws {TypeError} If any of the parameters are invalid
|
|
15153
|
+
* @return {Object} A JSON-RPC 1.0 or 2.0 request
|
|
15154
|
+
* @memberOf Utils
|
|
15155
|
+
*/
|
|
15156
|
+
const generateRequest$1 = function(method, params, id, options) {
|
|
15157
|
+
if(typeof method !== 'string') {
|
|
15158
|
+
throw new TypeError(method + ' must be a string');
|
|
15159
|
+
}
|
|
15281
15160
|
|
|
15282
|
-
|
|
15283
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
15161
|
+
options = options || {};
|
|
15284
15162
|
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15163
|
+
// check valid version provided
|
|
15164
|
+
const version = typeof options.version === 'number' ? options.version : 2;
|
|
15165
|
+
if (version !== 1 && version !== 2) {
|
|
15166
|
+
throw new TypeError(version + ' must be 1 or 2');
|
|
15167
|
+
}
|
|
15290
15168
|
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
15295
|
-
state = "executing";
|
|
15296
|
-
var record = tryCatch(innerFn, self, context);
|
|
15169
|
+
const request = {
|
|
15170
|
+
method: method
|
|
15171
|
+
};
|
|
15297
15172
|
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
value: record.arg,
|
|
15302
|
-
done: context.done
|
|
15303
|
-
};
|
|
15304
|
-
}
|
|
15173
|
+
if(version === 2) {
|
|
15174
|
+
request.jsonrpc = '2.0';
|
|
15175
|
+
}
|
|
15305
15176
|
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15177
|
+
if(params) {
|
|
15178
|
+
// params given, but invalid?
|
|
15179
|
+
if(typeof params !== 'object' && !Array.isArray(params)) {
|
|
15180
|
+
throw new TypeError(params + ' must be an object, array or omitted');
|
|
15181
|
+
}
|
|
15182
|
+
request.params = params;
|
|
15183
|
+
}
|
|
15311
15184
|
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
}
|
|
15185
|
+
// if id was left out, generate one (null means explicit notification)
|
|
15186
|
+
if(typeof(id) === 'undefined') {
|
|
15187
|
+
const generator = typeof options.generator === 'function' ? options.generator : function() { return uuid$1(); };
|
|
15188
|
+
request.id = generator(request, options);
|
|
15189
|
+
} else if (version === 2 && id === null) {
|
|
15190
|
+
// we have a version 2 notification
|
|
15191
|
+
if (options.notificationIdNull) {
|
|
15192
|
+
request.id = null; // id will not be set at all unless option provided
|
|
15193
|
+
}
|
|
15194
|
+
} else {
|
|
15195
|
+
request.id = id;
|
|
15196
|
+
}
|
|
15325
15197
|
|
|
15326
|
-
|
|
15327
|
-
|
|
15198
|
+
return request;
|
|
15199
|
+
};
|
|
15328
15200
|
|
|
15329
|
-
|
|
15201
|
+
var generateRequest_1 = generateRequest$1;
|
|
15330
15202
|
|
|
15331
|
-
|
|
15203
|
+
const uuid = require$$0.v4;
|
|
15204
|
+
const generateRequest = generateRequest_1;
|
|
15332
15205
|
|
|
15333
|
-
|
|
15206
|
+
/**
|
|
15207
|
+
* Constructor for a Jayson Browser Client that does not depend any node.js core libraries
|
|
15208
|
+
* @class ClientBrowser
|
|
15209
|
+
* @param {Function} callServer Method that calls the server, receives the stringified request and a regular node-style callback
|
|
15210
|
+
* @param {Object} [options]
|
|
15211
|
+
* @param {Function} [options.reviver] Reviver function for JSON
|
|
15212
|
+
* @param {Function} [options.replacer] Replacer function for JSON
|
|
15213
|
+
* @param {Number} [options.version=2] JSON-RPC version to use (1|2)
|
|
15214
|
+
* @param {Function} [options.generator] Function to use for generating request IDs
|
|
15215
|
+
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
|
|
15216
|
+
* @return {ClientBrowser}
|
|
15217
|
+
*/
|
|
15218
|
+
const ClientBrowser = function(callServer, options) {
|
|
15219
|
+
if(!(this instanceof ClientBrowser)) {
|
|
15220
|
+
return new ClientBrowser(callServer, options);
|
|
15221
|
+
}
|
|
15334
15222
|
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
});
|
|
15339
|
-
var getProto = Object.getPrototypeOf,
|
|
15340
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
15341
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
15342
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
15223
|
+
if (!options) {
|
|
15224
|
+
options = {};
|
|
15225
|
+
}
|
|
15343
15226
|
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15227
|
+
this.options = {
|
|
15228
|
+
reviver: typeof options.reviver !== 'undefined' ? options.reviver : null,
|
|
15229
|
+
replacer: typeof options.replacer !== 'undefined' ? options.replacer : null,
|
|
15230
|
+
generator: typeof options.generator !== 'undefined' ? options.generator : function() { return uuid(); },
|
|
15231
|
+
version: typeof options.version !== 'undefined' ? options.version : 2,
|
|
15232
|
+
notificationIdNull: typeof options.notificationIdNull === 'boolean' ? options.notificationIdNull : false,
|
|
15233
|
+
};
|
|
15351
15234
|
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
15235
|
+
this.callServer = callServer;
|
|
15236
|
+
};
|
|
15355
15237
|
|
|
15356
|
-
|
|
15357
|
-
var result = record.arg,
|
|
15358
|
-
value = result.value;
|
|
15359
|
-
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
15360
|
-
invoke("next", value, resolve, reject);
|
|
15361
|
-
}, function (err) {
|
|
15362
|
-
invoke("throw", err, resolve, reject);
|
|
15363
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
15364
|
-
result.value = unwrapped, resolve(result);
|
|
15365
|
-
}, function (error) {
|
|
15366
|
-
return invoke("throw", error, resolve, reject);
|
|
15367
|
-
});
|
|
15368
|
-
}
|
|
15238
|
+
var browser = ClientBrowser;
|
|
15369
15239
|
|
|
15370
|
-
|
|
15371
|
-
|
|
15240
|
+
/**
|
|
15241
|
+
* Creates a request and dispatches it if given a callback.
|
|
15242
|
+
* @param {String|Array} method A batch request if passed an Array, or a method name if passed a String
|
|
15243
|
+
* @param {Array|Object} [params] Parameters for the method
|
|
15244
|
+
* @param {String|Number} [id] Optional id. If undefined an id will be generated. If null it creates a notification request
|
|
15245
|
+
* @param {Function} [callback] Request callback. If specified, executes the request rather than only returning it.
|
|
15246
|
+
* @throws {TypeError} Invalid parameters
|
|
15247
|
+
* @return {Object} JSON-RPC 1.0 or 2.0 compatible request
|
|
15248
|
+
*/
|
|
15249
|
+
ClientBrowser.prototype.request = function(method, params, id, callback) {
|
|
15250
|
+
const self = this;
|
|
15251
|
+
let request = null;
|
|
15372
15252
|
|
|
15373
|
-
|
|
15253
|
+
// is this a batch request?
|
|
15254
|
+
const isBatch = Array.isArray(method) && typeof params === 'function';
|
|
15374
15255
|
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
invoke(method, arg, resolve, reject);
|
|
15379
|
-
});
|
|
15380
|
-
}
|
|
15256
|
+
if (this.options.version === 1 && isBatch) {
|
|
15257
|
+
throw new TypeError('JSON-RPC 1.0 does not support batching');
|
|
15258
|
+
}
|
|
15381
15259
|
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
}
|
|
15260
|
+
// is this a raw request?
|
|
15261
|
+
const isRaw = !isBatch && method && typeof method === 'object' && typeof params === 'function';
|
|
15385
15262
|
|
|
15386
|
-
|
|
15387
|
-
|
|
15263
|
+
if(isBatch || isRaw) {
|
|
15264
|
+
callback = params;
|
|
15265
|
+
request = method;
|
|
15266
|
+
} else {
|
|
15267
|
+
if(typeof id === 'function') {
|
|
15268
|
+
callback = id;
|
|
15269
|
+
// specifically undefined because "null" is a notification request
|
|
15270
|
+
id = undefined;
|
|
15271
|
+
}
|
|
15388
15272
|
|
|
15389
|
-
|
|
15390
|
-
if (context.delegate = null, "throw" === context.method) {
|
|
15391
|
-
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
15392
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
15393
|
-
}
|
|
15273
|
+
const hasCallback = typeof callback === 'function';
|
|
15394
15274
|
|
|
15395
|
-
|
|
15396
|
-
|
|
15275
|
+
try {
|
|
15276
|
+
request = generateRequest(method, params, id, {
|
|
15277
|
+
generator: this.options.generator,
|
|
15278
|
+
version: this.options.version,
|
|
15279
|
+
notificationIdNull: this.options.notificationIdNull,
|
|
15280
|
+
});
|
|
15281
|
+
} catch(err) {
|
|
15282
|
+
if(hasCallback) {
|
|
15283
|
+
return callback(err);
|
|
15284
|
+
}
|
|
15285
|
+
throw err;
|
|
15286
|
+
}
|
|
15397
15287
|
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
}
|
|
15288
|
+
// no callback means we should just return a raw request
|
|
15289
|
+
if(!hasCallback) {
|
|
15290
|
+
return request;
|
|
15291
|
+
}
|
|
15403
15292
|
|
|
15404
|
-
|
|
15405
|
-
var entry = {
|
|
15406
|
-
tryLoc: locs[0]
|
|
15407
|
-
};
|
|
15408
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
15409
|
-
}
|
|
15293
|
+
}
|
|
15410
15294
|
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15295
|
+
let message;
|
|
15296
|
+
try {
|
|
15297
|
+
message = JSON.stringify(request, this.options.replacer);
|
|
15298
|
+
} catch(err) {
|
|
15299
|
+
return callback(err);
|
|
15300
|
+
}
|
|
15415
15301
|
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
15420
|
-
}
|
|
15302
|
+
this.callServer(message, function(err, response) {
|
|
15303
|
+
self._parseResponse(err, response, callback);
|
|
15304
|
+
});
|
|
15421
15305
|
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
15426
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
15306
|
+
// always return the raw request
|
|
15307
|
+
return request;
|
|
15308
|
+
};
|
|
15427
15309
|
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15310
|
+
/**
|
|
15311
|
+
* Parses a response from a server
|
|
15312
|
+
* @param {Object} err Error to pass on that is unrelated to the actual response
|
|
15313
|
+
* @param {String} responseText JSON-RPC 1.0 or 2.0 response
|
|
15314
|
+
* @param {Function} callback Callback that will receive different arguments depending on the amount of parameters
|
|
15315
|
+
* @private
|
|
15316
|
+
*/
|
|
15317
|
+
ClientBrowser.prototype._parseResponse = function(err, responseText, callback) {
|
|
15318
|
+
if(err) {
|
|
15319
|
+
callback(err);
|
|
15320
|
+
return;
|
|
15321
|
+
}
|
|
15434
15322
|
|
|
15435
|
-
|
|
15436
|
-
|
|
15323
|
+
if(!responseText) {
|
|
15324
|
+
// empty response text, assume that is correct because it could be a
|
|
15325
|
+
// notification which jayson does not give any body for
|
|
15326
|
+
return callback();
|
|
15327
|
+
}
|
|
15437
15328
|
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15329
|
+
let response;
|
|
15330
|
+
try {
|
|
15331
|
+
response = JSON.parse(responseText, this.options.reviver);
|
|
15332
|
+
} catch(err) {
|
|
15333
|
+
return callback(err);
|
|
15334
|
+
}
|
|
15441
15335
|
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
};
|
|
15445
|
-
}
|
|
15336
|
+
if(callback.length === 3) {
|
|
15337
|
+
// if callback length is 3, we split callback arguments on error and response
|
|
15446
15338
|
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
value: undefined,
|
|
15450
|
-
done: !0
|
|
15451
|
-
};
|
|
15452
|
-
}
|
|
15339
|
+
// is batch response?
|
|
15340
|
+
if(Array.isArray(response)) {
|
|
15453
15341
|
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
15459
|
-
}, exports.awrap = function (arg) {
|
|
15460
|
-
return {
|
|
15461
|
-
__await: arg
|
|
15462
|
-
};
|
|
15463
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
15464
|
-
return this;
|
|
15465
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
15466
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
15467
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
15468
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
15469
|
-
return result.done ? result.value : iter.next();
|
|
15470
|
-
});
|
|
15471
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
15472
|
-
return this;
|
|
15473
|
-
}), define(Gp, "toString", function () {
|
|
15474
|
-
return "[object Generator]";
|
|
15475
|
-
}), exports.keys = function (object) {
|
|
15476
|
-
var keys = [];
|
|
15342
|
+
// neccesary to split strictly on validity according to spec here
|
|
15343
|
+
const isError = function(res) {
|
|
15344
|
+
return typeof res.error !== 'undefined';
|
|
15345
|
+
};
|
|
15477
15346
|
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
15347
|
+
const isNotError = function (res) {
|
|
15348
|
+
return !isError(res);
|
|
15349
|
+
};
|
|
15481
15350
|
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
15486
|
-
}
|
|
15351
|
+
return callback(null, response.filter(isError), response.filter(isNotError));
|
|
15352
|
+
|
|
15353
|
+
} else {
|
|
15487
15354
|
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
15495
|
-
}
|
|
15496
|
-
},
|
|
15497
|
-
stop: function stop() {
|
|
15498
|
-
this.done = !0;
|
|
15499
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
15500
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
15501
|
-
return this.rval;
|
|
15502
|
-
},
|
|
15503
|
-
dispatchException: function dispatchException(exception) {
|
|
15504
|
-
if (this.done) throw exception;
|
|
15505
|
-
var context = this;
|
|
15355
|
+
// split regardless of validity
|
|
15356
|
+
return callback(null, response.error, response.result);
|
|
15357
|
+
|
|
15358
|
+
}
|
|
15359
|
+
|
|
15360
|
+
}
|
|
15506
15361
|
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
}
|
|
15362
|
+
callback(null, response);
|
|
15363
|
+
};
|
|
15510
15364
|
|
|
15511
|
-
|
|
15512
|
-
var entry = this.tryEntries[i],
|
|
15513
|
-
record = entry.completion;
|
|
15514
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
15365
|
+
var RpcClient = browser;
|
|
15515
15366
|
|
|
15516
|
-
|
|
15517
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
15518
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
15367
|
+
const MINIMUM_SLOT_PER_EPOCH = 32; // Returns the number of trailing zeros in the binary representation of self.
|
|
15519
15368
|
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
15523
|
-
} else if (hasCatch) {
|
|
15524
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
15525
|
-
} else {
|
|
15526
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
15527
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
15528
|
-
}
|
|
15529
|
-
}
|
|
15530
|
-
}
|
|
15531
|
-
},
|
|
15532
|
-
abrupt: function abrupt(type, arg) {
|
|
15533
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15534
|
-
var entry = this.tryEntries[i];
|
|
15369
|
+
function trailingZeros(n) {
|
|
15370
|
+
let trailingZeros = 0;
|
|
15535
15371
|
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
}
|
|
15372
|
+
while (n > 1) {
|
|
15373
|
+
n /= 2;
|
|
15374
|
+
trailingZeros++;
|
|
15375
|
+
}
|
|
15541
15376
|
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
15545
|
-
},
|
|
15546
|
-
complete: function complete(record, afterLoc) {
|
|
15547
|
-
if ("throw" === record.type) throw record.arg;
|
|
15548
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
15549
|
-
},
|
|
15550
|
-
finish: function finish(finallyLoc) {
|
|
15551
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15552
|
-
var entry = this.tryEntries[i];
|
|
15553
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
15554
|
-
}
|
|
15555
|
-
},
|
|
15556
|
-
"catch": function _catch(tryLoc) {
|
|
15557
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15558
|
-
var entry = this.tryEntries[i];
|
|
15377
|
+
return trailingZeros;
|
|
15378
|
+
} // Returns the smallest power of two greater than or equal to n
|
|
15559
15379
|
|
|
15560
|
-
if (entry.tryLoc === tryLoc) {
|
|
15561
|
-
var record = entry.completion;
|
|
15562
15380
|
|
|
15563
|
-
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15381
|
+
function nextPowerOfTwo(n) {
|
|
15382
|
+
if (n === 0) return 1;
|
|
15383
|
+
n--;
|
|
15384
|
+
n |= n >> 1;
|
|
15385
|
+
n |= n >> 2;
|
|
15386
|
+
n |= n >> 4;
|
|
15387
|
+
n |= n >> 8;
|
|
15388
|
+
n |= n >> 16;
|
|
15389
|
+
n |= n >> 32;
|
|
15390
|
+
return n + 1;
|
|
15391
|
+
}
|
|
15392
|
+
/**
|
|
15393
|
+
* Epoch schedule
|
|
15394
|
+
* (see https://docs.solana.com/terminology#epoch)
|
|
15395
|
+
* Can be retrieved with the {@link Connection.getEpochSchedule} method
|
|
15396
|
+
*/
|
|
15567
15397
|
|
|
15568
|
-
return thrown;
|
|
15569
|
-
}
|
|
15570
|
-
}
|
|
15571
15398
|
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
15575
|
-
return this.delegate = {
|
|
15576
|
-
iterator: values(iterable),
|
|
15577
|
-
resultName: resultName,
|
|
15578
|
-
nextLoc: nextLoc
|
|
15579
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
15580
|
-
}
|
|
15581
|
-
}, exports;
|
|
15582
|
-
}
|
|
15399
|
+
class EpochSchedule {
|
|
15400
|
+
/** The maximum number of slots in each epoch */
|
|
15583
15401
|
|
|
15584
|
-
|
|
15585
|
-
} (regeneratorRuntime));
|
|
15586
|
-
return regeneratorRuntime.exports;
|
|
15587
|
-
}
|
|
15402
|
+
/** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */
|
|
15588
15403
|
|
|
15589
|
-
|
|
15590
|
-
var hasRequiredRegenerator;
|
|
15404
|
+
/** Indicates whether epochs start short and grow */
|
|
15591
15405
|
|
|
15592
|
-
|
|
15593
|
-
if (hasRequiredRegenerator) return regenerator;
|
|
15594
|
-
hasRequiredRegenerator = 1;
|
|
15595
|
-
regenerator = requireRegeneratorRuntime()();
|
|
15596
|
-
return regenerator;
|
|
15597
|
-
}
|
|
15406
|
+
/** The first epoch with `slotsPerEpoch` slots */
|
|
15598
15407
|
|
|
15599
|
-
|
|
15408
|
+
/** The first slot of `firstNormalEpoch` */
|
|
15409
|
+
constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
|
|
15410
|
+
this.slotsPerEpoch = void 0;
|
|
15411
|
+
this.leaderScheduleSlotOffset = void 0;
|
|
15412
|
+
this.warmup = void 0;
|
|
15413
|
+
this.firstNormalEpoch = void 0;
|
|
15414
|
+
this.firstNormalSlot = void 0;
|
|
15415
|
+
this.slotsPerEpoch = slotsPerEpoch;
|
|
15416
|
+
this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
|
|
15417
|
+
this.warmup = warmup;
|
|
15418
|
+
this.firstNormalEpoch = firstNormalEpoch;
|
|
15419
|
+
this.firstNormalSlot = firstNormalSlot;
|
|
15420
|
+
}
|
|
15600
15421
|
|
|
15601
|
-
|
|
15422
|
+
getEpoch(slot) {
|
|
15423
|
+
return this.getEpochAndSlotIndex(slot)[0];
|
|
15424
|
+
}
|
|
15602
15425
|
|
|
15603
|
-
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15426
|
+
getEpochAndSlotIndex(slot) {
|
|
15427
|
+
if (slot < this.firstNormalSlot) {
|
|
15428
|
+
const epoch = trailingZeros(nextPowerOfTwo(slot + MINIMUM_SLOT_PER_EPOCH + 1)) - trailingZeros(MINIMUM_SLOT_PER_EPOCH) - 1;
|
|
15429
|
+
const epochLen = this.getSlotsInEpoch(epoch);
|
|
15430
|
+
const slotIndex = slot - (epochLen - MINIMUM_SLOT_PER_EPOCH);
|
|
15431
|
+
return [epoch, slotIndex];
|
|
15432
|
+
} else {
|
|
15433
|
+
const normalSlotIndex = slot - this.firstNormalSlot;
|
|
15434
|
+
const normalEpochIndex = Math.floor(normalSlotIndex / this.slotsPerEpoch);
|
|
15435
|
+
const epoch = this.firstNormalEpoch + normalEpochIndex;
|
|
15436
|
+
const slotIndex = normalSlotIndex % this.slotsPerEpoch;
|
|
15437
|
+
return [epoch, slotIndex];
|
|
15438
|
+
}
|
|
15439
|
+
}
|
|
15615
15440
|
|
|
15616
|
-
|
|
15617
|
-
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15441
|
+
getFirstSlotInEpoch(epoch) {
|
|
15442
|
+
if (epoch <= this.firstNormalEpoch) {
|
|
15443
|
+
return (Math.pow(2, epoch) - 1) * MINIMUM_SLOT_PER_EPOCH;
|
|
15444
|
+
} else {
|
|
15445
|
+
return (epoch - this.firstNormalEpoch) * this.slotsPerEpoch + this.firstNormalSlot;
|
|
15446
|
+
}
|
|
15447
|
+
}
|
|
15622
15448
|
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
args = arguments;
|
|
15627
|
-
return new Promise(function (resolve, reject) {
|
|
15628
|
-
var gen = fn.apply(self, args);
|
|
15449
|
+
getLastSlotInEpoch(epoch) {
|
|
15450
|
+
return this.getFirstSlotInEpoch(epoch) + this.getSlotsInEpoch(epoch) - 1;
|
|
15451
|
+
}
|
|
15629
15452
|
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15453
|
+
getSlotsInEpoch(epoch) {
|
|
15454
|
+
if (epoch < this.firstNormalEpoch) {
|
|
15455
|
+
return Math.pow(2, epoch + trailingZeros(MINIMUM_SLOT_PER_EPOCH));
|
|
15456
|
+
} else {
|
|
15457
|
+
return this.slotsPerEpoch;
|
|
15458
|
+
}
|
|
15459
|
+
}
|
|
15633
15460
|
|
|
15634
|
-
|
|
15635
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
15636
|
-
}
|
|
15461
|
+
}
|
|
15637
15462
|
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15463
|
+
class SendTransactionError extends Error {
|
|
15464
|
+
constructor(message, logs) {
|
|
15465
|
+
super(message);
|
|
15466
|
+
this.logs = void 0;
|
|
15467
|
+
this.logs = logs;
|
|
15468
|
+
}
|
|
15642
15469
|
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
return asyncToGenerator.exports;
|
|
15646
|
-
}
|
|
15470
|
+
} // Keep in sync with client/src/rpc_custom_errors.rs
|
|
15471
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
15647
15472
|
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15473
|
+
const SolanaJSONRPCErrorCode = {
|
|
15474
|
+
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
15475
|
+
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
15476
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
15477
|
+
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
15478
|
+
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
15479
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
15480
|
+
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
15481
|
+
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
15482
|
+
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
15483
|
+
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
15484
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
15485
|
+
JSON_RPC_SCAN_ERROR: -32012,
|
|
15486
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
15487
|
+
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
15488
|
+
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
15489
|
+
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
15490
|
+
};
|
|
15491
|
+
class SolanaJSONRPCError extends Error {
|
|
15492
|
+
constructor({
|
|
15493
|
+
code,
|
|
15494
|
+
message,
|
|
15495
|
+
data
|
|
15496
|
+
}, customMessage) {
|
|
15497
|
+
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
15498
|
+
this.code = void 0;
|
|
15499
|
+
this.data = void 0;
|
|
15500
|
+
this.code = code;
|
|
15501
|
+
this.data = data;
|
|
15502
|
+
this.name = 'SolanaJSONRPCError';
|
|
15503
|
+
}
|
|
15653
15504
|
|
|
15654
|
-
|
|
15505
|
+
}
|
|
15655
15506
|
|
|
15656
|
-
|
|
15657
|
-
if (hasRequiredClient) return client;
|
|
15658
|
-
hasRequiredClient = 1;
|
|
15659
|
-
(function (exports) {
|
|
15507
|
+
var fetchImpl = globalThis.fetch;
|
|
15660
15508
|
|
|
15661
|
-
|
|
15509
|
+
var client = {};
|
|
15662
15510
|
|
|
15663
|
-
|
|
15664
|
-
value: true
|
|
15665
|
-
});
|
|
15666
|
-
exports["default"] = void 0;
|
|
15511
|
+
var interopRequireDefault = {exports: {}};
|
|
15667
15512
|
|
|
15668
|
-
|
|
15513
|
+
(function (module) {
|
|
15514
|
+
function _interopRequireDefault(obj) {
|
|
15515
|
+
return obj && obj.__esModule ? obj : {
|
|
15516
|
+
"default": obj
|
|
15517
|
+
};
|
|
15518
|
+
}
|
|
15669
15519
|
|
|
15670
|
-
|
|
15520
|
+
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15521
|
+
} (interopRequireDefault));
|
|
15671
15522
|
|
|
15672
|
-
|
|
15523
|
+
var regeneratorRuntime = {exports: {}};
|
|
15673
15524
|
|
|
15674
|
-
|
|
15525
|
+
var _typeof = {exports: {}};
|
|
15675
15526
|
|
|
15676
|
-
|
|
15527
|
+
var hasRequired_typeof;
|
|
15677
15528
|
|
|
15678
|
-
|
|
15529
|
+
function require_typeof () {
|
|
15530
|
+
if (hasRequired_typeof) return _typeof.exports;
|
|
15531
|
+
hasRequired_typeof = 1;
|
|
15532
|
+
(function (module) {
|
|
15533
|
+
function _typeof(obj) {
|
|
15534
|
+
"@babel/helpers - typeof";
|
|
15679
15535
|
|
|
15680
|
-
|
|
15536
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
15537
|
+
return typeof obj;
|
|
15538
|
+
} : function (obj) {
|
|
15539
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
15540
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
15541
|
+
}
|
|
15681
15542
|
|
|
15682
|
-
|
|
15543
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15544
|
+
} (_typeof));
|
|
15545
|
+
return _typeof.exports;
|
|
15546
|
+
}
|
|
15683
15547
|
|
|
15684
|
-
|
|
15548
|
+
var hasRequiredRegeneratorRuntime;
|
|
15685
15549
|
|
|
15686
|
-
|
|
15550
|
+
function requireRegeneratorRuntime () {
|
|
15551
|
+
if (hasRequiredRegeneratorRuntime) return regeneratorRuntime.exports;
|
|
15552
|
+
hasRequiredRegeneratorRuntime = 1;
|
|
15553
|
+
(function (module) {
|
|
15554
|
+
var _typeof = require_typeof()["default"];
|
|
15687
15555
|
|
|
15688
|
-
function
|
|
15556
|
+
function _regeneratorRuntime() {
|
|
15557
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
15689
15558
|
|
|
15690
|
-
|
|
15691
|
-
|
|
15559
|
+
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
15560
|
+
return exports;
|
|
15561
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15562
|
+
var exports = {},
|
|
15563
|
+
Op = Object.prototype,
|
|
15564
|
+
hasOwn = Op.hasOwnProperty,
|
|
15565
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
15566
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
15567
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
15568
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
15692
15569
|
|
|
15693
|
-
|
|
15694
|
-
|
|
15570
|
+
function define(obj, key, value) {
|
|
15571
|
+
return Object.defineProperty(obj, key, {
|
|
15572
|
+
value: value,
|
|
15573
|
+
enumerable: !0,
|
|
15574
|
+
configurable: !0,
|
|
15575
|
+
writable: !0
|
|
15576
|
+
}), obj[key];
|
|
15695
15577
|
}
|
|
15696
15578
|
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
}
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
var CommonClient = /*#__PURE__*/function (_EventEmitter) {
|
|
15705
|
-
(0, _inherits2["default"])(CommonClient, _EventEmitter);
|
|
15706
|
-
|
|
15707
|
-
var _super = _createSuper(CommonClient);
|
|
15708
|
-
|
|
15709
|
-
/**
|
|
15710
|
-
* Instantiate a Client class.
|
|
15711
|
-
* @constructor
|
|
15712
|
-
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
15713
|
-
* @param {String} address - url to a websocket server
|
|
15714
|
-
* @param {Object} options - ws options object with reconnect parameters
|
|
15715
|
-
* @param {Function} generate_request_id - custom generation request Id
|
|
15716
|
-
* @return {CommonClient}
|
|
15717
|
-
*/
|
|
15718
|
-
function CommonClient(webSocketFactory) {
|
|
15719
|
-
var _this;
|
|
15720
|
-
|
|
15721
|
-
var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ws://localhost:8080";
|
|
15722
|
-
|
|
15723
|
-
var _a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
15724
|
-
|
|
15725
|
-
var generate_request_id = arguments.length > 3 ? arguments[3] : undefined;
|
|
15726
|
-
(0, _classCallCheck2["default"])(this, CommonClient);
|
|
15727
|
-
|
|
15728
|
-
var _a$autoconnect = _a.autoconnect,
|
|
15729
|
-
autoconnect = _a$autoconnect === void 0 ? true : _a$autoconnect,
|
|
15730
|
-
_a$reconnect = _a.reconnect,
|
|
15731
|
-
reconnect = _a$reconnect === void 0 ? true : _a$reconnect,
|
|
15732
|
-
_a$reconnect_interval = _a.reconnect_interval,
|
|
15733
|
-
reconnect_interval = _a$reconnect_interval === void 0 ? 1000 : _a$reconnect_interval,
|
|
15734
|
-
_a$max_reconnects = _a.max_reconnects,
|
|
15735
|
-
max_reconnects = _a$max_reconnects === void 0 ? 5 : _a$max_reconnects,
|
|
15736
|
-
rest_options = __rest(_a, ["autoconnect", "reconnect", "reconnect_interval", "max_reconnects"]);
|
|
15737
|
-
|
|
15738
|
-
_this = _super.call(this);
|
|
15739
|
-
_this.webSocketFactory = webSocketFactory;
|
|
15740
|
-
_this.queue = {};
|
|
15741
|
-
_this.rpc_id = 0;
|
|
15742
|
-
_this.address = address;
|
|
15743
|
-
_this.autoconnect = autoconnect;
|
|
15744
|
-
_this.ready = false;
|
|
15745
|
-
_this.reconnect = reconnect;
|
|
15746
|
-
_this.reconnect_interval = reconnect_interval;
|
|
15747
|
-
_this.max_reconnects = max_reconnects;
|
|
15748
|
-
_this.rest_options = rest_options;
|
|
15749
|
-
_this.current_reconnects = 0;
|
|
15750
|
-
|
|
15751
|
-
_this.generate_request_id = generate_request_id || function () {
|
|
15752
|
-
return ++_this.rpc_id;
|
|
15579
|
+
try {
|
|
15580
|
+
define({}, "");
|
|
15581
|
+
} catch (err) {
|
|
15582
|
+
define = function define(obj, key, value) {
|
|
15583
|
+
return obj[key] = value;
|
|
15753
15584
|
};
|
|
15754
|
-
|
|
15755
|
-
if (_this.autoconnect) _this._connect(_this.address, Object.assign({
|
|
15756
|
-
autoconnect: _this.autoconnect,
|
|
15757
|
-
reconnect: _this.reconnect,
|
|
15758
|
-
reconnect_interval: _this.reconnect_interval,
|
|
15759
|
-
max_reconnects: _this.max_reconnects
|
|
15760
|
-
}, _this.rest_options));
|
|
15761
|
-
return _this;
|
|
15762
15585
|
}
|
|
15763
|
-
/**
|
|
15764
|
-
* Connects to a defined server if not connected already.
|
|
15765
|
-
* @method
|
|
15766
|
-
* @return {Undefined}
|
|
15767
|
-
*/
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
(0, _createClass2["default"])(CommonClient, [{
|
|
15771
|
-
key: "connect",
|
|
15772
|
-
value: function connect() {
|
|
15773
|
-
if (this.socket) return;
|
|
15774
|
-
|
|
15775
|
-
this._connect(this.address, Object.assign({
|
|
15776
|
-
autoconnect: this.autoconnect,
|
|
15777
|
-
reconnect: this.reconnect,
|
|
15778
|
-
reconnect_interval: this.reconnect_interval,
|
|
15779
|
-
max_reconnects: this.max_reconnects
|
|
15780
|
-
}, this.rest_options));
|
|
15781
|
-
}
|
|
15782
|
-
/**
|
|
15783
|
-
* Calls a registered RPC method on server.
|
|
15784
|
-
* @method
|
|
15785
|
-
* @param {String} method - RPC method name
|
|
15786
|
-
* @param {Object|Array} params - optional method parameters
|
|
15787
|
-
* @param {Number} timeout - RPC reply timeout value
|
|
15788
|
-
* @param {Object} ws_opts - options passed to ws
|
|
15789
|
-
* @return {Promise}
|
|
15790
|
-
*/
|
|
15791
|
-
|
|
15792
|
-
}, {
|
|
15793
|
-
key: "call",
|
|
15794
|
-
value: function call(method, params, timeout, ws_opts) {
|
|
15795
|
-
var _this2 = this;
|
|
15796
|
-
|
|
15797
|
-
if (!ws_opts && "object" === (0, _typeof2["default"])(timeout)) {
|
|
15798
|
-
ws_opts = timeout;
|
|
15799
|
-
timeout = null;
|
|
15800
|
-
}
|
|
15801
|
-
|
|
15802
|
-
return new Promise(function (resolve, reject) {
|
|
15803
|
-
if (!_this2.ready) return reject(new Error("socket not ready"));
|
|
15804
|
-
|
|
15805
|
-
var rpc_id = _this2.generate_request_id(method, params);
|
|
15806
15586
|
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
if (error) return reject(error);
|
|
15816
|
-
_this2.queue[rpc_id] = {
|
|
15817
|
-
promise: [resolve, reject]
|
|
15818
|
-
};
|
|
15819
|
-
|
|
15820
|
-
if (timeout) {
|
|
15821
|
-
_this2.queue[rpc_id].timeout = setTimeout(function () {
|
|
15822
|
-
delete _this2.queue[rpc_id];
|
|
15823
|
-
reject(new Error("reply timeout"));
|
|
15824
|
-
}, timeout);
|
|
15825
|
-
}
|
|
15826
|
-
});
|
|
15827
|
-
});
|
|
15828
|
-
}
|
|
15829
|
-
/**
|
|
15830
|
-
* Logins with the other side of the connection.
|
|
15831
|
-
* @method
|
|
15832
|
-
* @param {Object} params - Login credentials object
|
|
15833
|
-
* @return {Promise}
|
|
15834
|
-
*/
|
|
15835
|
-
|
|
15836
|
-
}, {
|
|
15837
|
-
key: "login",
|
|
15838
|
-
value: function () {
|
|
15839
|
-
var _login = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(params) {
|
|
15840
|
-
var resp;
|
|
15841
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
15842
|
-
while (1) {
|
|
15843
|
-
switch (_context.prev = _context.next) {
|
|
15844
|
-
case 0:
|
|
15845
|
-
_context.next = 2;
|
|
15846
|
-
return this.call("rpc.login", params);
|
|
15847
|
-
|
|
15848
|
-
case 2:
|
|
15849
|
-
resp = _context.sent;
|
|
15850
|
-
|
|
15851
|
-
if (resp) {
|
|
15852
|
-
_context.next = 5;
|
|
15853
|
-
break;
|
|
15854
|
-
}
|
|
15855
|
-
|
|
15856
|
-
throw new Error("authentication failed");
|
|
15857
|
-
|
|
15858
|
-
case 5:
|
|
15859
|
-
return _context.abrupt("return", resp);
|
|
15860
|
-
|
|
15861
|
-
case 6:
|
|
15862
|
-
case "end":
|
|
15863
|
-
return _context.stop();
|
|
15864
|
-
}
|
|
15865
|
-
}
|
|
15866
|
-
}, _callee, this);
|
|
15867
|
-
}));
|
|
15868
|
-
|
|
15869
|
-
function login(_x) {
|
|
15870
|
-
return _login.apply(this, arguments);
|
|
15871
|
-
}
|
|
15587
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
15588
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
15589
|
+
generator = Object.create(protoGenerator.prototype),
|
|
15590
|
+
context = new Context(tryLocsList || []);
|
|
15591
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
15592
|
+
var state = "suspendedStart";
|
|
15593
|
+
return function (method, arg) {
|
|
15594
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
15872
15595
|
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
* @method
|
|
15878
|
-
* @return {Array}
|
|
15879
|
-
*/
|
|
15880
|
-
|
|
15881
|
-
}, {
|
|
15882
|
-
key: "listMethods",
|
|
15883
|
-
value: function () {
|
|
15884
|
-
var _listMethods = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
15885
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
15886
|
-
while (1) {
|
|
15887
|
-
switch (_context2.prev = _context2.next) {
|
|
15888
|
-
case 0:
|
|
15889
|
-
_context2.next = 2;
|
|
15890
|
-
return this.call("__listMethods");
|
|
15891
|
-
|
|
15892
|
-
case 2:
|
|
15893
|
-
return _context2.abrupt("return", _context2.sent);
|
|
15894
|
-
|
|
15895
|
-
case 3:
|
|
15896
|
-
case "end":
|
|
15897
|
-
return _context2.stop();
|
|
15898
|
-
}
|
|
15899
|
-
}
|
|
15900
|
-
}, _callee2, this);
|
|
15901
|
-
}));
|
|
15596
|
+
if ("completed" === state) {
|
|
15597
|
+
if ("throw" === method) throw arg;
|
|
15598
|
+
return doneResult();
|
|
15599
|
+
}
|
|
15902
15600
|
|
|
15903
|
-
|
|
15904
|
-
|
|
15905
|
-
}
|
|
15601
|
+
for (context.method = method, context.arg = arg;;) {
|
|
15602
|
+
var delegate = context.delegate;
|
|
15906
15603
|
|
|
15907
|
-
|
|
15908
|
-
|
|
15909
|
-
/**
|
|
15910
|
-
* Sends a JSON-RPC 2.0 notification to server.
|
|
15911
|
-
* @method
|
|
15912
|
-
* @param {String} method - RPC method name
|
|
15913
|
-
* @param {Object} params - optional method parameters
|
|
15914
|
-
* @return {Promise}
|
|
15915
|
-
*/
|
|
15916
|
-
|
|
15917
|
-
}, {
|
|
15918
|
-
key: "notify",
|
|
15919
|
-
value: function notify(method, params) {
|
|
15920
|
-
var _this3 = this;
|
|
15921
|
-
|
|
15922
|
-
return new Promise(function (resolve, reject) {
|
|
15923
|
-
if (!_this3.ready) return reject(new Error("socket not ready"));
|
|
15924
|
-
var message = {
|
|
15925
|
-
jsonrpc: "2.0",
|
|
15926
|
-
method: method,
|
|
15927
|
-
params: params || null
|
|
15928
|
-
};
|
|
15604
|
+
if (delegate) {
|
|
15605
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
15929
15606
|
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
});
|
|
15934
|
-
});
|
|
15935
|
-
}
|
|
15936
|
-
/**
|
|
15937
|
-
* Subscribes for a defined event.
|
|
15938
|
-
* @method
|
|
15939
|
-
* @param {String|Array} event - event name
|
|
15940
|
-
* @return {Undefined}
|
|
15941
|
-
* @throws {Error}
|
|
15942
|
-
*/
|
|
15943
|
-
|
|
15944
|
-
}, {
|
|
15945
|
-
key: "subscribe",
|
|
15946
|
-
value: function () {
|
|
15947
|
-
var _subscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(event) {
|
|
15948
|
-
var result;
|
|
15949
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
15950
|
-
while (1) {
|
|
15951
|
-
switch (_context3.prev = _context3.next) {
|
|
15952
|
-
case 0:
|
|
15953
|
-
if (typeof event === "string") event = [event];
|
|
15954
|
-
_context3.next = 3;
|
|
15955
|
-
return this.call("rpc.on", event);
|
|
15956
|
-
|
|
15957
|
-
case 3:
|
|
15958
|
-
result = _context3.sent;
|
|
15959
|
-
|
|
15960
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
15961
|
-
_context3.next = 6;
|
|
15962
|
-
break;
|
|
15963
|
-
}
|
|
15964
|
-
|
|
15965
|
-
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
15966
|
-
|
|
15967
|
-
case 6:
|
|
15968
|
-
return _context3.abrupt("return", result);
|
|
15969
|
-
|
|
15970
|
-
case 7:
|
|
15971
|
-
case "end":
|
|
15972
|
-
return _context3.stop();
|
|
15607
|
+
if (delegateResult) {
|
|
15608
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
15609
|
+
return delegateResult;
|
|
15973
15610
|
}
|
|
15974
15611
|
}
|
|
15975
|
-
}, _callee3, this);
|
|
15976
|
-
}));
|
|
15977
15612
|
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15613
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
15614
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
15615
|
+
context.dispatchException(context.arg);
|
|
15616
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
15617
|
+
state = "executing";
|
|
15618
|
+
var record = tryCatch(innerFn, self, context);
|
|
15981
15619
|
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
|
|
15988
|
-
* @return {Undefined}
|
|
15989
|
-
* @throws {Error}
|
|
15990
|
-
*/
|
|
15991
|
-
|
|
15992
|
-
}, {
|
|
15993
|
-
key: "unsubscribe",
|
|
15994
|
-
value: function () {
|
|
15995
|
-
var _unsubscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event) {
|
|
15996
|
-
var result;
|
|
15997
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
15998
|
-
while (1) {
|
|
15999
|
-
switch (_context4.prev = _context4.next) {
|
|
16000
|
-
case 0:
|
|
16001
|
-
if (typeof event === "string") event = [event];
|
|
16002
|
-
_context4.next = 3;
|
|
16003
|
-
return this.call("rpc.off", event);
|
|
16004
|
-
|
|
16005
|
-
case 3:
|
|
16006
|
-
result = _context4.sent;
|
|
16007
|
-
|
|
16008
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
16009
|
-
_context4.next = 6;
|
|
16010
|
-
break;
|
|
16011
|
-
}
|
|
16012
|
-
|
|
16013
|
-
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
16014
|
-
|
|
16015
|
-
case 6:
|
|
16016
|
-
return _context4.abrupt("return", result);
|
|
16017
|
-
|
|
16018
|
-
case 7:
|
|
16019
|
-
case "end":
|
|
16020
|
-
return _context4.stop();
|
|
16021
|
-
}
|
|
15620
|
+
if ("normal" === record.type) {
|
|
15621
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
15622
|
+
return {
|
|
15623
|
+
value: record.arg,
|
|
15624
|
+
done: context.done
|
|
15625
|
+
};
|
|
16022
15626
|
}
|
|
16023
|
-
}, _callee4, this);
|
|
16024
|
-
}));
|
|
16025
|
-
|
|
16026
|
-
function unsubscribe(_x3) {
|
|
16027
|
-
return _unsubscribe.apply(this, arguments);
|
|
16028
|
-
}
|
|
16029
15627
|
|
|
16030
|
-
|
|
16031
|
-
}()
|
|
16032
|
-
/**
|
|
16033
|
-
* Closes a WebSocket connection gracefully.
|
|
16034
|
-
* @method
|
|
16035
|
-
* @param {Number} code - socket close code
|
|
16036
|
-
* @param {String} data - optional data to be sent before closing
|
|
16037
|
-
* @return {Undefined}
|
|
16038
|
-
*/
|
|
16039
|
-
|
|
16040
|
-
}, {
|
|
16041
|
-
key: "close",
|
|
16042
|
-
value: function close(code, data) {
|
|
16043
|
-
this.socket.close(code || 1000, data);
|
|
16044
|
-
}
|
|
16045
|
-
/**
|
|
16046
|
-
* Connection/Message handler.
|
|
16047
|
-
* @method
|
|
16048
|
-
* @private
|
|
16049
|
-
* @param {String} address - WebSocket API address
|
|
16050
|
-
* @param {Object} options - ws options object
|
|
16051
|
-
* @return {Undefined}
|
|
16052
|
-
*/
|
|
16053
|
-
|
|
16054
|
-
}, {
|
|
16055
|
-
key: "_connect",
|
|
16056
|
-
value: function _connect(address, options) {
|
|
16057
|
-
var _this4 = this;
|
|
16058
|
-
|
|
16059
|
-
this.socket = this.webSocketFactory(address, options);
|
|
16060
|
-
this.socket.addEventListener("open", function () {
|
|
16061
|
-
_this4.ready = true;
|
|
16062
|
-
|
|
16063
|
-
_this4.emit("open");
|
|
16064
|
-
|
|
16065
|
-
_this4.current_reconnects = 0;
|
|
16066
|
-
});
|
|
16067
|
-
this.socket.addEventListener("message", function (_ref) {
|
|
16068
|
-
var message = _ref.data;
|
|
16069
|
-
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
16070
|
-
|
|
16071
|
-
try {
|
|
16072
|
-
message = JSON.parse(message);
|
|
16073
|
-
} catch (error) {
|
|
16074
|
-
return;
|
|
16075
|
-
} // check if any listeners are attached and forward event
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
if (message.notification && _this4.listeners(message.notification).length) {
|
|
16079
|
-
if (!Object.keys(message.params).length) return _this4.emit(message.notification);
|
|
16080
|
-
var args = [message.notification];
|
|
16081
|
-
if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
|
|
16082
|
-
for (var i = 0; i < message.params.length; i++) {
|
|
16083
|
-
args.push(message.params[i]);
|
|
16084
|
-
} // run as microtask so that pending queue messages are resolved first
|
|
16085
|
-
// eslint-disable-next-line prefer-spread
|
|
16086
|
-
|
|
16087
|
-
return Promise.resolve().then(function () {
|
|
16088
|
-
_this4.emit.apply(_this4, args);
|
|
16089
|
-
});
|
|
15628
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
16090
15629
|
}
|
|
15630
|
+
};
|
|
15631
|
+
}(innerFn, self, context), generator;
|
|
15632
|
+
}
|
|
16091
15633
|
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
|
|
16105
|
-
if ("error" in message === "result" in message) _this4.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" + " or \"error\", but not both."));
|
|
16106
|
-
if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
|
|
16107
|
-
if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
|
|
16108
|
-
delete _this4.queue[message.id];
|
|
16109
|
-
});
|
|
16110
|
-
this.socket.addEventListener("error", function (error) {
|
|
16111
|
-
return _this4.emit("error", error);
|
|
16112
|
-
});
|
|
16113
|
-
this.socket.addEventListener("close", function (_ref2) {
|
|
16114
|
-
var code = _ref2.code,
|
|
16115
|
-
reason = _ref2.reason;
|
|
16116
|
-
if (_this4.ready) // Delay close event until internal state is updated
|
|
16117
|
-
setTimeout(function () {
|
|
16118
|
-
return _this4.emit("close", code, reason);
|
|
16119
|
-
}, 0);
|
|
16120
|
-
_this4.ready = false;
|
|
16121
|
-
_this4.socket = undefined;
|
|
16122
|
-
if (code === 1000) return;
|
|
16123
|
-
_this4.current_reconnects++;
|
|
16124
|
-
if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) setTimeout(function () {
|
|
16125
|
-
return _this4._connect(address, options);
|
|
16126
|
-
}, _this4.reconnect_interval);
|
|
16127
|
-
});
|
|
15634
|
+
function tryCatch(fn, obj, arg) {
|
|
15635
|
+
try {
|
|
15636
|
+
return {
|
|
15637
|
+
type: "normal",
|
|
15638
|
+
arg: fn.call(obj, arg)
|
|
15639
|
+
};
|
|
15640
|
+
} catch (err) {
|
|
15641
|
+
return {
|
|
15642
|
+
type: "throw",
|
|
15643
|
+
arg: err
|
|
15644
|
+
};
|
|
16128
15645
|
}
|
|
16129
|
-
}
|
|
16130
|
-
return CommonClient;
|
|
16131
|
-
}(_eventemitter.EventEmitter);
|
|
16132
|
-
|
|
16133
|
-
exports["default"] = CommonClient;
|
|
16134
|
-
} (client));
|
|
16135
|
-
return client;
|
|
16136
|
-
}
|
|
16137
|
-
|
|
16138
|
-
var _interopRequireDefault = interopRequireDefault.exports;
|
|
16139
|
-
|
|
16140
|
-
Object.defineProperty(index_browser, "__esModule", {
|
|
16141
|
-
value: true
|
|
16142
|
-
});
|
|
16143
|
-
var Client_1 = index_browser.Client = void 0;
|
|
16144
|
-
|
|
16145
|
-
var _createClass2 = _interopRequireDefault(requireCreateClass());
|
|
16146
|
-
|
|
16147
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
15646
|
+
}
|
|
16148
15647
|
|
|
16149
|
-
|
|
15648
|
+
exports.wrap = wrap;
|
|
15649
|
+
var ContinueSentinel = {};
|
|
16150
15650
|
|
|
16151
|
-
|
|
15651
|
+
function Generator() {}
|
|
16152
15652
|
|
|
16153
|
-
|
|
15653
|
+
function GeneratorFunction() {}
|
|
16154
15654
|
|
|
16155
|
-
|
|
15655
|
+
function GeneratorFunctionPrototype() {}
|
|
16156
15656
|
|
|
16157
|
-
|
|
15657
|
+
var IteratorPrototype = {};
|
|
15658
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
15659
|
+
return this;
|
|
15660
|
+
});
|
|
15661
|
+
var getProto = Object.getPrototypeOf,
|
|
15662
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
15663
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
15664
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
16158
15665
|
|
|
16159
|
-
|
|
15666
|
+
function defineIteratorMethods(prototype) {
|
|
15667
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
15668
|
+
define(prototype, method, function (arg) {
|
|
15669
|
+
return this._invoke(method, arg);
|
|
15670
|
+
});
|
|
15671
|
+
});
|
|
15672
|
+
}
|
|
16160
15673
|
|
|
16161
|
-
|
|
15674
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
15675
|
+
function invoke(method, arg, resolve, reject) {
|
|
15676
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
16162
15677
|
|
|
16163
|
-
|
|
16164
|
-
|
|
15678
|
+
if ("throw" !== record.type) {
|
|
15679
|
+
var result = record.arg,
|
|
15680
|
+
value = result.value;
|
|
15681
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
15682
|
+
invoke("next", value, resolve, reject);
|
|
15683
|
+
}, function (err) {
|
|
15684
|
+
invoke("throw", err, resolve, reject);
|
|
15685
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
15686
|
+
result.value = unwrapped, resolve(result);
|
|
15687
|
+
}, function (error) {
|
|
15688
|
+
return invoke("throw", error, resolve, reject);
|
|
15689
|
+
});
|
|
15690
|
+
}
|
|
16165
15691
|
|
|
16166
|
-
|
|
15692
|
+
reject(record.arg);
|
|
15693
|
+
}
|
|
16167
15694
|
|
|
16168
|
-
|
|
16169
|
-
var address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://localhost:8080";
|
|
15695
|
+
var previousPromise;
|
|
16170
15696
|
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
reconnect_interval = _ref$reconnect_interv === void 0 ? 1000 : _ref$reconnect_interv,
|
|
16178
|
-
_ref$max_reconnects = _ref.max_reconnects,
|
|
16179
|
-
max_reconnects = _ref$max_reconnects === void 0 ? 5 : _ref$max_reconnects;
|
|
15697
|
+
this._invoke = function (method, arg) {
|
|
15698
|
+
function callInvokeWithMethodAndArg() {
|
|
15699
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
15700
|
+
invoke(method, arg, resolve, reject);
|
|
15701
|
+
});
|
|
15702
|
+
}
|
|
16180
15703
|
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
autoconnect: autoconnect,
|
|
16185
|
-
reconnect: reconnect,
|
|
16186
|
-
reconnect_interval: reconnect_interval,
|
|
16187
|
-
max_reconnects: max_reconnects
|
|
16188
|
-
}, generate_request_id);
|
|
16189
|
-
}
|
|
15704
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
15705
|
+
};
|
|
15706
|
+
}
|
|
16190
15707
|
|
|
16191
|
-
|
|
16192
|
-
|
|
15708
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
15709
|
+
var method = delegate.iterator[context.method];
|
|
16193
15710
|
|
|
16194
|
-
|
|
15711
|
+
if (undefined === method) {
|
|
15712
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
15713
|
+
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
15714
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
15715
|
+
}
|
|
16195
15716
|
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
// generators (like Math.random()).
|
|
16199
|
-
var getRandomValues;
|
|
16200
|
-
var rnds8 = new Uint8Array(16);
|
|
16201
|
-
function rng() {
|
|
16202
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
16203
|
-
if (!getRandomValues) {
|
|
16204
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
|
16205
|
-
// find the complete implementation of crypto (msCrypto) on IE11.
|
|
16206
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
15717
|
+
return ContinueSentinel;
|
|
15718
|
+
}
|
|
16207
15719
|
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
15720
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
15721
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
15722
|
+
var info = record.arg;
|
|
15723
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
15724
|
+
}
|
|
16212
15725
|
|
|
16213
|
-
|
|
16214
|
-
|
|
15726
|
+
function pushTryEntry(locs) {
|
|
15727
|
+
var entry = {
|
|
15728
|
+
tryLoc: locs[0]
|
|
15729
|
+
};
|
|
15730
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
15731
|
+
}
|
|
16215
15732
|
|
|
16216
|
-
|
|
15733
|
+
function resetTryEntry(entry) {
|
|
15734
|
+
var record = entry.completion || {};
|
|
15735
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
15736
|
+
}
|
|
16217
15737
|
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
15738
|
+
function Context(tryLocsList) {
|
|
15739
|
+
this.tryEntries = [{
|
|
15740
|
+
tryLoc: "root"
|
|
15741
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
15742
|
+
}
|
|
16221
15743
|
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
15744
|
+
function values(iterable) {
|
|
15745
|
+
if (iterable) {
|
|
15746
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
15747
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
15748
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
16226
15749
|
|
|
16227
|
-
|
|
15750
|
+
if (!isNaN(iterable.length)) {
|
|
15751
|
+
var i = -1,
|
|
15752
|
+
next = function next() {
|
|
15753
|
+
for (; ++i < iterable.length;) {
|
|
15754
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
15755
|
+
}
|
|
16228
15756
|
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
}
|
|
15757
|
+
return next.value = undefined, next.done = !0, next;
|
|
15758
|
+
};
|
|
16232
15759
|
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
16237
|
-
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
16238
|
-
// of the following:
|
|
16239
|
-
// - One or more input array values don't map to a hex octet (leading to
|
|
16240
|
-
// "undefined" in the uuid)
|
|
16241
|
-
// - Invalid input values for the RFC `version` or `variant` fields
|
|
15760
|
+
return next.next = next;
|
|
15761
|
+
}
|
|
15762
|
+
}
|
|
16242
15763
|
|
|
16243
|
-
|
|
16244
|
-
|
|
16245
|
-
|
|
15764
|
+
return {
|
|
15765
|
+
next: doneResult
|
|
15766
|
+
};
|
|
15767
|
+
}
|
|
16246
15768
|
|
|
16247
|
-
|
|
16248
|
-
|
|
15769
|
+
function doneResult() {
|
|
15770
|
+
return {
|
|
15771
|
+
value: undefined,
|
|
15772
|
+
done: !0
|
|
15773
|
+
};
|
|
15774
|
+
}
|
|
16249
15775
|
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
15776
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
15777
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
15778
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
15779
|
+
}, exports.mark = function (genFun) {
|
|
15780
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
15781
|
+
}, exports.awrap = function (arg) {
|
|
15782
|
+
return {
|
|
15783
|
+
__await: arg
|
|
15784
|
+
};
|
|
15785
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
15786
|
+
return this;
|
|
15787
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
15788
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
15789
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
15790
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
15791
|
+
return result.done ? result.value : iter.next();
|
|
15792
|
+
});
|
|
15793
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
15794
|
+
return this;
|
|
15795
|
+
}), define(Gp, "toString", function () {
|
|
15796
|
+
return "[object Generator]";
|
|
15797
|
+
}), exports.keys = function (object) {
|
|
15798
|
+
var keys = [];
|
|
16253
15799
|
|
|
16254
|
-
|
|
15800
|
+
for (var key in object) {
|
|
15801
|
+
keys.push(key);
|
|
15802
|
+
}
|
|
16255
15803
|
|
|
16256
|
-
|
|
15804
|
+
return keys.reverse(), function next() {
|
|
15805
|
+
for (; keys.length;) {
|
|
15806
|
+
var key = keys.pop();
|
|
15807
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
15808
|
+
}
|
|
16257
15809
|
|
|
15810
|
+
return next.done = !0, next;
|
|
15811
|
+
};
|
|
15812
|
+
}, exports.values = values, Context.prototype = {
|
|
15813
|
+
constructor: Context,
|
|
15814
|
+
reset: function reset(skipTempReset) {
|
|
15815
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
15816
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
15817
|
+
}
|
|
15818
|
+
},
|
|
15819
|
+
stop: function stop() {
|
|
15820
|
+
this.done = !0;
|
|
15821
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
15822
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
15823
|
+
return this.rval;
|
|
15824
|
+
},
|
|
15825
|
+
dispatchException: function dispatchException(exception) {
|
|
15826
|
+
if (this.done) throw exception;
|
|
15827
|
+
var context = this;
|
|
16258
15828
|
|
|
16259
|
-
|
|
16260
|
-
|
|
15829
|
+
function handle(loc, caught) {
|
|
15830
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
15831
|
+
}
|
|
16261
15832
|
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
var node = options.node || _nodeId;
|
|
16267
|
-
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
16268
|
-
// specified. We do this lazily to minimize issues related to insufficient
|
|
16269
|
-
// system entropy. See #189
|
|
15833
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15834
|
+
var entry = this.tryEntries[i],
|
|
15835
|
+
record = entry.completion;
|
|
15836
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
16270
15837
|
|
|
16271
|
-
|
|
16272
|
-
|
|
15838
|
+
if (entry.tryLoc <= this.prev) {
|
|
15839
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
15840
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
16273
15841
|
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
15842
|
+
if (hasCatch && hasFinally) {
|
|
15843
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
15844
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
15845
|
+
} else if (hasCatch) {
|
|
15846
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
15847
|
+
} else {
|
|
15848
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
15849
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
15850
|
+
}
|
|
15851
|
+
}
|
|
15852
|
+
}
|
|
15853
|
+
},
|
|
15854
|
+
abrupt: function abrupt(type, arg) {
|
|
15855
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15856
|
+
var entry = this.tryEntries[i];
|
|
16278
15857
|
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
16285
|
-
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
16286
|
-
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
15858
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
15859
|
+
var finallyEntry = entry;
|
|
15860
|
+
break;
|
|
15861
|
+
}
|
|
15862
|
+
}
|
|
16287
15863
|
|
|
15864
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
15865
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
15866
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
15867
|
+
},
|
|
15868
|
+
complete: function complete(record, afterLoc) {
|
|
15869
|
+
if ("throw" === record.type) throw record.arg;
|
|
15870
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
15871
|
+
},
|
|
15872
|
+
finish: function finish(finallyLoc) {
|
|
15873
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15874
|
+
var entry = this.tryEntries[i];
|
|
15875
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
15876
|
+
}
|
|
15877
|
+
},
|
|
15878
|
+
"catch": function _catch(tryLoc) {
|
|
15879
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
15880
|
+
var entry = this.tryEntries[i];
|
|
16288
15881
|
|
|
16289
|
-
|
|
16290
|
-
|
|
15882
|
+
if (entry.tryLoc === tryLoc) {
|
|
15883
|
+
var record = entry.completion;
|
|
16291
15884
|
|
|
16292
|
-
|
|
15885
|
+
if ("throw" === record.type) {
|
|
15886
|
+
var thrown = record.arg;
|
|
15887
|
+
resetTryEntry(entry);
|
|
15888
|
+
}
|
|
16293
15889
|
|
|
16294
|
-
|
|
15890
|
+
return thrown;
|
|
15891
|
+
}
|
|
15892
|
+
}
|
|
16295
15893
|
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
|
|
15894
|
+
throw new Error("illegal catch attempt");
|
|
15895
|
+
},
|
|
15896
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
15897
|
+
return this.delegate = {
|
|
15898
|
+
iterator: values(iterable),
|
|
15899
|
+
resultName: resultName,
|
|
15900
|
+
nextLoc: nextLoc
|
|
15901
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
15902
|
+
}
|
|
15903
|
+
}, exports;
|
|
15904
|
+
}
|
|
16300
15905
|
|
|
15906
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15907
|
+
} (regeneratorRuntime));
|
|
15908
|
+
return regeneratorRuntime.exports;
|
|
15909
|
+
}
|
|
16301
15910
|
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
} // Per 4.2.1.2 Throw error if too many uuids are requested
|
|
15911
|
+
var regenerator;
|
|
15912
|
+
var hasRequiredRegenerator;
|
|
16305
15913
|
|
|
15914
|
+
function requireRegenerator () {
|
|
15915
|
+
if (hasRequiredRegenerator) return regenerator;
|
|
15916
|
+
hasRequiredRegenerator = 1;
|
|
15917
|
+
regenerator = requireRegeneratorRuntime()();
|
|
15918
|
+
return regenerator;
|
|
15919
|
+
}
|
|
16306
15920
|
|
|
16307
|
-
|
|
16308
|
-
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
16309
|
-
}
|
|
15921
|
+
var asyncToGenerator = {exports: {}};
|
|
16310
15922
|
|
|
16311
|
-
|
|
16312
|
-
_lastNSecs = nsecs;
|
|
16313
|
-
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
15923
|
+
var hasRequiredAsyncToGenerator;
|
|
16314
15924
|
|
|
16315
|
-
|
|
15925
|
+
function requireAsyncToGenerator () {
|
|
15926
|
+
if (hasRequiredAsyncToGenerator) return asyncToGenerator.exports;
|
|
15927
|
+
hasRequiredAsyncToGenerator = 1;
|
|
15928
|
+
(function (module) {
|
|
15929
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15930
|
+
try {
|
|
15931
|
+
var info = gen[key](arg);
|
|
15932
|
+
var value = info.value;
|
|
15933
|
+
} catch (error) {
|
|
15934
|
+
reject(error);
|
|
15935
|
+
return;
|
|
15936
|
+
}
|
|
16316
15937
|
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
15938
|
+
if (info.done) {
|
|
15939
|
+
resolve(value);
|
|
15940
|
+
} else {
|
|
15941
|
+
Promise.resolve(value).then(_next, _throw);
|
|
15942
|
+
}
|
|
15943
|
+
}
|
|
16322
15944
|
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
15945
|
+
function _asyncToGenerator(fn) {
|
|
15946
|
+
return function () {
|
|
15947
|
+
var self = this,
|
|
15948
|
+
args = arguments;
|
|
15949
|
+
return new Promise(function (resolve, reject) {
|
|
15950
|
+
var gen = fn.apply(self, args);
|
|
16326
15951
|
|
|
16327
|
-
|
|
15952
|
+
function _next(value) {
|
|
15953
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
15954
|
+
}
|
|
16328
15955
|
|
|
16329
|
-
|
|
15956
|
+
function _throw(err) {
|
|
15957
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
15958
|
+
}
|
|
16330
15959
|
|
|
16331
|
-
|
|
15960
|
+
_next(undefined);
|
|
15961
|
+
});
|
|
15962
|
+
};
|
|
15963
|
+
}
|
|
16332
15964
|
|
|
16333
|
-
|
|
15965
|
+
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15966
|
+
} (asyncToGenerator));
|
|
15967
|
+
return asyncToGenerator.exports;
|
|
15968
|
+
}
|
|
16334
15969
|
|
|
16335
|
-
|
|
16336
|
-
b[i + n] = node[n];
|
|
16337
|
-
}
|
|
15970
|
+
var classCallCheck = {exports: {}};
|
|
16338
15971
|
|
|
16339
|
-
|
|
16340
|
-
}
|
|
15972
|
+
var hasRequiredClassCallCheck;
|
|
16341
15973
|
|
|
16342
|
-
function
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
|
|
15974
|
+
function requireClassCallCheck () {
|
|
15975
|
+
if (hasRequiredClassCallCheck) return classCallCheck.exports;
|
|
15976
|
+
hasRequiredClassCallCheck = 1;
|
|
15977
|
+
(function (module) {
|
|
15978
|
+
function _classCallCheck(instance, Constructor) {
|
|
15979
|
+
if (!(instance instanceof Constructor)) {
|
|
15980
|
+
throw new TypeError("Cannot call a class as a function");
|
|
15981
|
+
}
|
|
15982
|
+
}
|
|
16346
15983
|
|
|
16347
|
-
|
|
16348
|
-
|
|
15984
|
+
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
15985
|
+
} (classCallCheck));
|
|
15986
|
+
return classCallCheck.exports;
|
|
15987
|
+
}
|
|
16349
15988
|
|
|
16350
|
-
|
|
16351
|
-
arr[1] = v >>> 16 & 0xff;
|
|
16352
|
-
arr[2] = v >>> 8 & 0xff;
|
|
16353
|
-
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
15989
|
+
var createClass = {exports: {}};
|
|
16354
15990
|
|
|
16355
|
-
|
|
16356
|
-
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
15991
|
+
var hasRequiredCreateClass;
|
|
16357
15992
|
|
|
16358
|
-
|
|
16359
|
-
|
|
15993
|
+
function requireCreateClass () {
|
|
15994
|
+
if (hasRequiredCreateClass) return createClass.exports;
|
|
15995
|
+
hasRequiredCreateClass = 1;
|
|
15996
|
+
(function (module) {
|
|
15997
|
+
function _defineProperties(target, props) {
|
|
15998
|
+
for (var i = 0; i < props.length; i++) {
|
|
15999
|
+
var descriptor = props[i];
|
|
16000
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
16001
|
+
descriptor.configurable = true;
|
|
16002
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
16003
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
16004
|
+
}
|
|
16005
|
+
}
|
|
16360
16006
|
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16007
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
16008
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
16009
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
16010
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
16011
|
+
writable: false
|
|
16012
|
+
});
|
|
16013
|
+
return Constructor;
|
|
16014
|
+
}
|
|
16364
16015
|
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16368
|
-
arr[13] = v >>> 16 & 0xff;
|
|
16369
|
-
arr[14] = v >>> 8 & 0xff;
|
|
16370
|
-
arr[15] = v & 0xff;
|
|
16371
|
-
return arr;
|
|
16016
|
+
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16017
|
+
} (createClass));
|
|
16018
|
+
return createClass.exports;
|
|
16372
16019
|
}
|
|
16373
16020
|
|
|
16374
|
-
|
|
16375
|
-
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
16376
|
-
|
|
16377
|
-
var bytes = [];
|
|
16021
|
+
var inherits = {exports: {}};
|
|
16378
16022
|
|
|
16379
|
-
|
|
16380
|
-
bytes.push(str.charCodeAt(i));
|
|
16381
|
-
}
|
|
16023
|
+
var setPrototypeOf = {exports: {}};
|
|
16382
16024
|
|
|
16383
|
-
|
|
16384
|
-
}
|
|
16025
|
+
var hasRequiredSetPrototypeOf;
|
|
16385
16026
|
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16027
|
+
function requireSetPrototypeOf () {
|
|
16028
|
+
if (hasRequiredSetPrototypeOf) return setPrototypeOf.exports;
|
|
16029
|
+
hasRequiredSetPrototypeOf = 1;
|
|
16030
|
+
(function (module) {
|
|
16031
|
+
function _setPrototypeOf(o, p) {
|
|
16032
|
+
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
16033
|
+
o.__proto__ = p;
|
|
16034
|
+
return o;
|
|
16035
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16036
|
+
return _setPrototypeOf(o, p);
|
|
16037
|
+
}
|
|
16393
16038
|
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
|
|
16039
|
+
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16040
|
+
} (setPrototypeOf));
|
|
16041
|
+
return setPrototypeOf.exports;
|
|
16042
|
+
}
|
|
16397
16043
|
|
|
16398
|
-
|
|
16399
|
-
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
16400
|
-
} // Compute hash of namespace and value, Per 4.3
|
|
16401
|
-
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
16402
|
-
// hashfunc([...namespace, ... value])`
|
|
16044
|
+
var hasRequiredInherits;
|
|
16403
16045
|
|
|
16046
|
+
function requireInherits () {
|
|
16047
|
+
if (hasRequiredInherits) return inherits.exports;
|
|
16048
|
+
hasRequiredInherits = 1;
|
|
16049
|
+
(function (module) {
|
|
16050
|
+
var setPrototypeOf = requireSetPrototypeOf();
|
|
16404
16051
|
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
bytes[6] = bytes[6] & 0x0f | version;
|
|
16410
|
-
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
16052
|
+
function _inherits(subClass, superClass) {
|
|
16053
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
16054
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
16055
|
+
}
|
|
16411
16056
|
|
|
16412
|
-
|
|
16413
|
-
|
|
16057
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
16058
|
+
constructor: {
|
|
16059
|
+
value: subClass,
|
|
16060
|
+
writable: true,
|
|
16061
|
+
configurable: true
|
|
16062
|
+
}
|
|
16063
|
+
});
|
|
16064
|
+
Object.defineProperty(subClass, "prototype", {
|
|
16065
|
+
writable: false
|
|
16066
|
+
});
|
|
16067
|
+
if (superClass) setPrototypeOf(subClass, superClass);
|
|
16068
|
+
}
|
|
16414
16069
|
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16070
|
+
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16071
|
+
} (inherits));
|
|
16072
|
+
return inherits.exports;
|
|
16073
|
+
}
|
|
16418
16074
|
|
|
16419
|
-
|
|
16420
|
-
}
|
|
16075
|
+
var possibleConstructorReturn = {exports: {}};
|
|
16421
16076
|
|
|
16422
|
-
|
|
16423
|
-
} // Function#name is not settable on some platforms (#270)
|
|
16077
|
+
var assertThisInitialized = {exports: {}};
|
|
16424
16078
|
|
|
16079
|
+
var hasRequiredAssertThisInitialized;
|
|
16425
16080
|
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16081
|
+
function requireAssertThisInitialized () {
|
|
16082
|
+
if (hasRequiredAssertThisInitialized) return assertThisInitialized.exports;
|
|
16083
|
+
hasRequiredAssertThisInitialized = 1;
|
|
16084
|
+
(function (module) {
|
|
16085
|
+
function _assertThisInitialized(self) {
|
|
16086
|
+
if (self === void 0) {
|
|
16087
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16088
|
+
}
|
|
16429
16089
|
|
|
16090
|
+
return self;
|
|
16091
|
+
}
|
|
16430
16092
|
|
|
16431
|
-
|
|
16432
|
-
|
|
16433
|
-
|
|
16093
|
+
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16094
|
+
} (assertThisInitialized));
|
|
16095
|
+
return assertThisInitialized.exports;
|
|
16434
16096
|
}
|
|
16435
16097
|
|
|
16436
|
-
|
|
16437
|
-
* Browser-compatible JavaScript MD5
|
|
16438
|
-
*
|
|
16439
|
-
* Modification of JavaScript MD5
|
|
16440
|
-
* https://github.com/blueimp/JavaScript-MD5
|
|
16441
|
-
*
|
|
16442
|
-
* Copyright 2011, Sebastian Tschan
|
|
16443
|
-
* https://blueimp.net
|
|
16444
|
-
*
|
|
16445
|
-
* Licensed under the MIT license:
|
|
16446
|
-
* https://opensource.org/licenses/MIT
|
|
16447
|
-
*
|
|
16448
|
-
* Based on
|
|
16449
|
-
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
|
16450
|
-
* Digest Algorithm, as defined in RFC 1321.
|
|
16451
|
-
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
|
16452
|
-
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
|
16453
|
-
* Distributed under the BSD License
|
|
16454
|
-
* See http://pajhome.org.uk/crypt/md5 for more info.
|
|
16455
|
-
*/
|
|
16456
|
-
function md5(bytes) {
|
|
16457
|
-
if (typeof bytes === 'string') {
|
|
16458
|
-
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
16098
|
+
var hasRequiredPossibleConstructorReturn;
|
|
16459
16099
|
|
|
16460
|
-
|
|
16100
|
+
function requirePossibleConstructorReturn () {
|
|
16101
|
+
if (hasRequiredPossibleConstructorReturn) return possibleConstructorReturn.exports;
|
|
16102
|
+
hasRequiredPossibleConstructorReturn = 1;
|
|
16103
|
+
(function (module) {
|
|
16104
|
+
var _typeof = require_typeof()["default"];
|
|
16461
16105
|
|
|
16462
|
-
|
|
16463
|
-
bytes[i] = msg.charCodeAt(i);
|
|
16464
|
-
}
|
|
16465
|
-
}
|
|
16106
|
+
var assertThisInitialized = requireAssertThisInitialized();
|
|
16466
16107
|
|
|
16467
|
-
|
|
16108
|
+
function _possibleConstructorReturn(self, call) {
|
|
16109
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
16110
|
+
return call;
|
|
16111
|
+
} else if (call !== void 0) {
|
|
16112
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
16113
|
+
}
|
|
16114
|
+
|
|
16115
|
+
return assertThisInitialized(self);
|
|
16116
|
+
}
|
|
16117
|
+
|
|
16118
|
+
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16119
|
+
} (possibleConstructorReturn));
|
|
16120
|
+
return possibleConstructorReturn.exports;
|
|
16468
16121
|
}
|
|
16469
|
-
/*
|
|
16470
|
-
* Convert an array of little-endian words to an array of bytes
|
|
16471
|
-
*/
|
|
16472
16122
|
|
|
16123
|
+
var getPrototypeOf = {exports: {}};
|
|
16473
16124
|
|
|
16474
|
-
|
|
16475
|
-
var output = [];
|
|
16476
|
-
var length32 = input.length * 32;
|
|
16477
|
-
var hexTab = '0123456789abcdef';
|
|
16125
|
+
var hasRequiredGetPrototypeOf;
|
|
16478
16126
|
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16127
|
+
function requireGetPrototypeOf () {
|
|
16128
|
+
if (hasRequiredGetPrototypeOf) return getPrototypeOf.exports;
|
|
16129
|
+
hasRequiredGetPrototypeOf = 1;
|
|
16130
|
+
(function (module) {
|
|
16131
|
+
function _getPrototypeOf(o) {
|
|
16132
|
+
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
16133
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
16134
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16135
|
+
return _getPrototypeOf(o);
|
|
16136
|
+
}
|
|
16484
16137
|
|
|
16485
|
-
|
|
16138
|
+
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16139
|
+
} (getPrototypeOf));
|
|
16140
|
+
return getPrototypeOf.exports;
|
|
16486
16141
|
}
|
|
16487
|
-
/**
|
|
16488
|
-
* Calculate output length with padding and bit length
|
|
16489
|
-
*/
|
|
16490
16142
|
|
|
16143
|
+
var eventemitter3 = {exports: {}};
|
|
16491
16144
|
|
|
16492
|
-
|
|
16493
|
-
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
|
|
16494
|
-
}
|
|
16495
|
-
/*
|
|
16496
|
-
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
|
16497
|
-
*/
|
|
16145
|
+
var hasRequiredEventemitter3;
|
|
16498
16146
|
|
|
16147
|
+
function requireEventemitter3 () {
|
|
16148
|
+
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
16149
|
+
hasRequiredEventemitter3 = 1;
|
|
16150
|
+
(function (module) {
|
|
16499
16151
|
|
|
16500
|
-
|
|
16501
|
-
|
|
16502
|
-
x[len >> 5] |= 0x80 << len % 32;
|
|
16503
|
-
x[getOutputLength(len) - 1] = len;
|
|
16504
|
-
var a = 1732584193;
|
|
16505
|
-
var b = -271733879;
|
|
16506
|
-
var c = -1732584194;
|
|
16507
|
-
var d = 271733878;
|
|
16152
|
+
var has = Object.prototype.hasOwnProperty
|
|
16153
|
+
, prefix = '~';
|
|
16508
16154
|
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16517
|
-
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
16518
|
-
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
16519
|
-
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
16520
|
-
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
16521
|
-
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
16522
|
-
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
16523
|
-
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
16524
|
-
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
16525
|
-
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
16526
|
-
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
16527
|
-
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
16528
|
-
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
16529
|
-
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
16530
|
-
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
16531
|
-
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
16532
|
-
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
16533
|
-
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
|
16534
|
-
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
16535
|
-
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
16536
|
-
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
16537
|
-
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
16538
|
-
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
16539
|
-
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
16540
|
-
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
16541
|
-
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
16542
|
-
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
16543
|
-
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
16544
|
-
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
16545
|
-
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
16546
|
-
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
16547
|
-
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
16548
|
-
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
16549
|
-
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
16550
|
-
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
16551
|
-
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
16552
|
-
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
16553
|
-
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
16554
|
-
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
16555
|
-
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
|
16556
|
-
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
16557
|
-
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
16558
|
-
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
16559
|
-
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
16560
|
-
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
16561
|
-
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
16562
|
-
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
|
16563
|
-
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
16564
|
-
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
16565
|
-
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
16566
|
-
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
16567
|
-
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
16568
|
-
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
16569
|
-
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
16570
|
-
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
16571
|
-
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
16572
|
-
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
16573
|
-
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
16574
|
-
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
16575
|
-
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
16576
|
-
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
16577
|
-
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
16578
|
-
a = safeAdd(a, olda);
|
|
16579
|
-
b = safeAdd(b, oldb);
|
|
16580
|
-
c = safeAdd(c, oldc);
|
|
16581
|
-
d = safeAdd(d, oldd);
|
|
16582
|
-
}
|
|
16155
|
+
/**
|
|
16156
|
+
* Constructor to create a storage for our `EE` objects.
|
|
16157
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
16158
|
+
*
|
|
16159
|
+
* @constructor
|
|
16160
|
+
* @private
|
|
16161
|
+
*/
|
|
16162
|
+
function Events() {}
|
|
16583
16163
|
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16164
|
+
//
|
|
16165
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
16166
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
16167
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
16168
|
+
// character to make sure that the built-in object properties are not
|
|
16169
|
+
// overridden or used as an attack vector.
|
|
16170
|
+
//
|
|
16171
|
+
if (Object.create) {
|
|
16172
|
+
Events.prototype = Object.create(null);
|
|
16173
|
+
|
|
16174
|
+
//
|
|
16175
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
16176
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
16177
|
+
//
|
|
16178
|
+
if (!new Events().__proto__) prefix = false;
|
|
16179
|
+
}
|
|
16180
|
+
|
|
16181
|
+
/**
|
|
16182
|
+
* Representation of a single event listener.
|
|
16183
|
+
*
|
|
16184
|
+
* @param {Function} fn The listener function.
|
|
16185
|
+
* @param {*} context The context to invoke the listener with.
|
|
16186
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
16187
|
+
* @constructor
|
|
16188
|
+
* @private
|
|
16189
|
+
*/
|
|
16190
|
+
function EE(fn, context, once) {
|
|
16191
|
+
this.fn = fn;
|
|
16192
|
+
this.context = context;
|
|
16193
|
+
this.once = once || false;
|
|
16194
|
+
}
|
|
16590
16195
|
|
|
16196
|
+
/**
|
|
16197
|
+
* Add a listener for a given event.
|
|
16198
|
+
*
|
|
16199
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16200
|
+
* @param {(String|Symbol)} event The event name.
|
|
16201
|
+
* @param {Function} fn The listener function.
|
|
16202
|
+
* @param {*} context The context to invoke the listener with.
|
|
16203
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
16204
|
+
* @returns {EventEmitter}
|
|
16205
|
+
* @private
|
|
16206
|
+
*/
|
|
16207
|
+
function addListener(emitter, event, fn, context, once) {
|
|
16208
|
+
if (typeof fn !== 'function') {
|
|
16209
|
+
throw new TypeError('The listener must be a function');
|
|
16210
|
+
}
|
|
16591
16211
|
|
|
16592
|
-
|
|
16593
|
-
|
|
16594
|
-
return [];
|
|
16595
|
-
}
|
|
16212
|
+
var listener = new EE(fn, context || emitter, once)
|
|
16213
|
+
, evt = prefix ? prefix + event : event;
|
|
16596
16214
|
|
|
16597
|
-
|
|
16598
|
-
|
|
16215
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
16216
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
16217
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
16599
16218
|
|
|
16600
|
-
|
|
16601
|
-
|
|
16602
|
-
}
|
|
16219
|
+
return emitter;
|
|
16220
|
+
}
|
|
16603
16221
|
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
|
|
16222
|
+
/**
|
|
16223
|
+
* Clear event by name.
|
|
16224
|
+
*
|
|
16225
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16226
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
16227
|
+
* @private
|
|
16228
|
+
*/
|
|
16229
|
+
function clearEvent(emitter, evt) {
|
|
16230
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
16231
|
+
else delete emitter._events[evt];
|
|
16232
|
+
}
|
|
16610
16233
|
|
|
16234
|
+
/**
|
|
16235
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
16236
|
+
* `EventEmitter` interface.
|
|
16237
|
+
*
|
|
16238
|
+
* @constructor
|
|
16239
|
+
* @public
|
|
16240
|
+
*/
|
|
16241
|
+
function EventEmitter() {
|
|
16242
|
+
this._events = new Events();
|
|
16243
|
+
this._eventsCount = 0;
|
|
16244
|
+
}
|
|
16611
16245
|
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16246
|
+
/**
|
|
16247
|
+
* Return an array listing the events for which the emitter has registered
|
|
16248
|
+
* listeners.
|
|
16249
|
+
*
|
|
16250
|
+
* @returns {Array}
|
|
16251
|
+
* @public
|
|
16252
|
+
*/
|
|
16253
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
16254
|
+
var names = []
|
|
16255
|
+
, events
|
|
16256
|
+
, name;
|
|
16620
16257
|
|
|
16258
|
+
if (this._eventsCount === 0) return names;
|
|
16621
16259
|
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
/*
|
|
16626
|
-
* These functions implement the four basic operations the algorithm uses.
|
|
16627
|
-
*/
|
|
16260
|
+
for (name in (events = this._events)) {
|
|
16261
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
16262
|
+
}
|
|
16628
16263
|
|
|
16264
|
+
if (Object.getOwnPropertySymbols) {
|
|
16265
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
16266
|
+
}
|
|
16629
16267
|
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
}
|
|
16268
|
+
return names;
|
|
16269
|
+
};
|
|
16633
16270
|
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16271
|
+
/**
|
|
16272
|
+
* Return the listeners registered for a given event.
|
|
16273
|
+
*
|
|
16274
|
+
* @param {(String|Symbol)} event The event name.
|
|
16275
|
+
* @returns {Array} The registered listeners.
|
|
16276
|
+
* @public
|
|
16277
|
+
*/
|
|
16278
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
16279
|
+
var evt = prefix ? prefix + event : event
|
|
16280
|
+
, handlers = this._events[evt];
|
|
16637
16281
|
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
}
|
|
16282
|
+
if (!handlers) return [];
|
|
16283
|
+
if (handlers.fn) return [handlers.fn];
|
|
16641
16284
|
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16285
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
16286
|
+
ee[i] = handlers[i].fn;
|
|
16287
|
+
}
|
|
16645
16288
|
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
}
|
|
16289
|
+
return ee;
|
|
16290
|
+
};
|
|
16649
16291
|
|
|
16650
|
-
|
|
16651
|
-
|
|
16292
|
+
/**
|
|
16293
|
+
* Return the number of listeners listening to a given event.
|
|
16294
|
+
*
|
|
16295
|
+
* @param {(String|Symbol)} event The event name.
|
|
16296
|
+
* @returns {Number} The number of listeners.
|
|
16297
|
+
* @public
|
|
16298
|
+
*/
|
|
16299
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
16300
|
+
var evt = prefix ? prefix + event : event
|
|
16301
|
+
, listeners = this._events[evt];
|
|
16652
16302
|
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
16303
|
+
if (!listeners) return 0;
|
|
16304
|
+
if (listeners.fn) return 1;
|
|
16305
|
+
return listeners.length;
|
|
16306
|
+
};
|
|
16656
16307
|
|
|
16657
|
-
|
|
16658
|
-
|
|
16308
|
+
/**
|
|
16309
|
+
* Calls each of the listeners registered for a given event.
|
|
16310
|
+
*
|
|
16311
|
+
* @param {(String|Symbol)} event The event name.
|
|
16312
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
16313
|
+
* @public
|
|
16314
|
+
*/
|
|
16315
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
16316
|
+
var evt = prefix ? prefix + event : event;
|
|
16659
16317
|
|
|
16660
|
-
|
|
16661
|
-
offset = offset || 0;
|
|
16318
|
+
if (!this._events[evt]) return false;
|
|
16662
16319
|
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16320
|
+
var listeners = this._events[evt]
|
|
16321
|
+
, len = arguments.length
|
|
16322
|
+
, args
|
|
16323
|
+
, i;
|
|
16666
16324
|
|
|
16667
|
-
|
|
16668
|
-
|
|
16325
|
+
if (listeners.fn) {
|
|
16326
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
16669
16327
|
|
|
16670
|
-
|
|
16671
|
-
|
|
16328
|
+
switch (len) {
|
|
16329
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
16330
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
16331
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
16332
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
16333
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
16334
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
16335
|
+
}
|
|
16672
16336
|
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
switch (s) {
|
|
16677
|
-
case 0:
|
|
16678
|
-
return x & y ^ ~x & z;
|
|
16337
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
16338
|
+
args[i - 1] = arguments[i];
|
|
16339
|
+
}
|
|
16679
16340
|
|
|
16680
|
-
|
|
16681
|
-
|
|
16341
|
+
listeners.fn.apply(listeners.context, args);
|
|
16342
|
+
} else {
|
|
16343
|
+
var length = listeners.length
|
|
16344
|
+
, j;
|
|
16682
16345
|
|
|
16683
|
-
|
|
16684
|
-
|
|
16346
|
+
for (i = 0; i < length; i++) {
|
|
16347
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
16685
16348
|
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16349
|
+
switch (len) {
|
|
16350
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
16351
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
16352
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
16353
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
16354
|
+
default:
|
|
16355
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
16356
|
+
args[j - 1] = arguments[j];
|
|
16357
|
+
}
|
|
16690
16358
|
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
|
|
16359
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
16360
|
+
}
|
|
16361
|
+
}
|
|
16362
|
+
}
|
|
16694
16363
|
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
16364
|
+
return true;
|
|
16365
|
+
};
|
|
16698
16366
|
|
|
16699
|
-
|
|
16700
|
-
|
|
16367
|
+
/**
|
|
16368
|
+
* Add a listener for a given event.
|
|
16369
|
+
*
|
|
16370
|
+
* @param {(String|Symbol)} event The event name.
|
|
16371
|
+
* @param {Function} fn The listener function.
|
|
16372
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16373
|
+
* @returns {EventEmitter} `this`.
|
|
16374
|
+
* @public
|
|
16375
|
+
*/
|
|
16376
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
16377
|
+
return addListener(this, event, fn, context, false);
|
|
16378
|
+
};
|
|
16701
16379
|
|
|
16702
|
-
|
|
16380
|
+
/**
|
|
16381
|
+
* Add a one-time listener for a given event.
|
|
16382
|
+
*
|
|
16383
|
+
* @param {(String|Symbol)} event The event name.
|
|
16384
|
+
* @param {Function} fn The listener function.
|
|
16385
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16386
|
+
* @returns {EventEmitter} `this`.
|
|
16387
|
+
* @public
|
|
16388
|
+
*/
|
|
16389
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
16390
|
+
return addListener(this, event, fn, context, true);
|
|
16391
|
+
};
|
|
16703
16392
|
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
16707
|
-
|
|
16708
|
-
|
|
16709
|
-
|
|
16710
|
-
|
|
16393
|
+
/**
|
|
16394
|
+
* Remove the listeners of a given event.
|
|
16395
|
+
*
|
|
16396
|
+
* @param {(String|Symbol)} event The event name.
|
|
16397
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
16398
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
16399
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
16400
|
+
* @returns {EventEmitter} `this`.
|
|
16401
|
+
* @public
|
|
16402
|
+
*/
|
|
16403
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
16404
|
+
var evt = prefix ? prefix + event : event;
|
|
16711
16405
|
|
|
16712
|
-
|
|
16713
|
-
|
|
16714
|
-
|
|
16715
|
-
|
|
16406
|
+
if (!this._events[evt]) return this;
|
|
16407
|
+
if (!fn) {
|
|
16408
|
+
clearEvent(this, evt);
|
|
16409
|
+
return this;
|
|
16410
|
+
}
|
|
16716
16411
|
|
|
16717
|
-
|
|
16718
|
-
var arr = new Uint32Array(16);
|
|
16412
|
+
var listeners = this._events[evt];
|
|
16719
16413
|
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16414
|
+
if (listeners.fn) {
|
|
16415
|
+
if (
|
|
16416
|
+
listeners.fn === fn &&
|
|
16417
|
+
(!once || listeners.once) &&
|
|
16418
|
+
(!context || listeners.context === context)
|
|
16419
|
+
) {
|
|
16420
|
+
clearEvent(this, evt);
|
|
16421
|
+
}
|
|
16422
|
+
} else {
|
|
16423
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
16424
|
+
if (
|
|
16425
|
+
listeners[i].fn !== fn ||
|
|
16426
|
+
(once && !listeners[i].once) ||
|
|
16427
|
+
(context && listeners[i].context !== context)
|
|
16428
|
+
) {
|
|
16429
|
+
events.push(listeners[i]);
|
|
16430
|
+
}
|
|
16431
|
+
}
|
|
16723
16432
|
|
|
16724
|
-
|
|
16725
|
-
|
|
16433
|
+
//
|
|
16434
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
16435
|
+
//
|
|
16436
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
16437
|
+
else clearEvent(this, evt);
|
|
16438
|
+
}
|
|
16726
16439
|
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
16440
|
+
return this;
|
|
16441
|
+
};
|
|
16730
16442
|
|
|
16731
|
-
|
|
16732
|
-
|
|
16443
|
+
/**
|
|
16444
|
+
* Remove all listeners, or those of the specified event.
|
|
16445
|
+
*
|
|
16446
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
16447
|
+
* @returns {EventEmitter} `this`.
|
|
16448
|
+
* @public
|
|
16449
|
+
*/
|
|
16450
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
16451
|
+
var evt;
|
|
16733
16452
|
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16453
|
+
if (event) {
|
|
16454
|
+
evt = prefix ? prefix + event : event;
|
|
16455
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
16456
|
+
} else {
|
|
16457
|
+
this._events = new Events();
|
|
16458
|
+
this._eventsCount = 0;
|
|
16459
|
+
}
|
|
16737
16460
|
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
}
|
|
16461
|
+
return this;
|
|
16462
|
+
};
|
|
16741
16463
|
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
|
|
16746
|
-
|
|
16464
|
+
//
|
|
16465
|
+
// Alias methods names because people roll like that.
|
|
16466
|
+
//
|
|
16467
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
16468
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
16747
16469
|
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
16752
|
-
d = c;
|
|
16753
|
-
c = ROTL(b, 30) >>> 0;
|
|
16754
|
-
b = a;
|
|
16755
|
-
a = T;
|
|
16756
|
-
}
|
|
16470
|
+
//
|
|
16471
|
+
// Expose the prefix.
|
|
16472
|
+
//
|
|
16473
|
+
EventEmitter.prefixed = prefix;
|
|
16757
16474
|
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
H[4] = H[4] + e >>> 0;
|
|
16763
|
-
}
|
|
16475
|
+
//
|
|
16476
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
16477
|
+
//
|
|
16478
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
16764
16479
|
|
|
16765
|
-
|
|
16480
|
+
//
|
|
16481
|
+
// Expose the module.
|
|
16482
|
+
//
|
|
16483
|
+
{
|
|
16484
|
+
module.exports = EventEmitter;
|
|
16485
|
+
}
|
|
16486
|
+
} (eventemitter3));
|
|
16487
|
+
return eventemitter3.exports;
|
|
16766
16488
|
}
|
|
16767
16489
|
|
|
16768
|
-
|
|
16769
|
-
|
|
16490
|
+
/**
|
|
16491
|
+
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
16492
|
+
* according to the environment providing JSON RPC 2.0 support on top.
|
|
16493
|
+
* @module Client
|
|
16494
|
+
*/
|
|
16770
16495
|
|
|
16771
|
-
|
|
16496
|
+
(function (exports) {
|
|
16772
16497
|
|
|
16773
|
-
|
|
16774
|
-
if (!validate(uuid)) {
|
|
16775
|
-
throw TypeError('Invalid UUID');
|
|
16776
|
-
}
|
|
16498
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
16777
16499
|
|
|
16778
|
-
|
|
16779
|
-
|
|
16500
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16501
|
+
value: true
|
|
16502
|
+
});
|
|
16503
|
+
exports["default"] = void 0;
|
|
16780
16504
|
|
|
16781
|
-
|
|
16782
|
-
__proto__: null,
|
|
16783
|
-
v1: v1,
|
|
16784
|
-
v3: v3$1,
|
|
16785
|
-
v4: v4,
|
|
16786
|
-
v5: v5$1,
|
|
16787
|
-
NIL: nil,
|
|
16788
|
-
version: version,
|
|
16789
|
-
validate: validate,
|
|
16790
|
-
stringify: stringify,
|
|
16791
|
-
parse: parse
|
|
16792
|
-
});
|
|
16505
|
+
var _regenerator = _interopRequireDefault(requireRegenerator());
|
|
16793
16506
|
|
|
16794
|
-
|
|
16507
|
+
var _asyncToGenerator2 = _interopRequireDefault(requireAsyncToGenerator());
|
|
16795
16508
|
|
|
16796
|
-
|
|
16509
|
+
var _typeof2 = _interopRequireDefault(require_typeof());
|
|
16797
16510
|
|
|
16798
|
-
|
|
16799
|
-
* Generates a JSON-RPC 1.0 or 2.0 request
|
|
16800
|
-
* @param {String} method Name of method to call
|
|
16801
|
-
* @param {Array|Object} params Array of parameters passed to the method as specified, or an object of parameter names and corresponding value
|
|
16802
|
-
* @param {String|Number|null} [id] Request ID can be a string, number, null for explicit notification or left out for automatic generation
|
|
16803
|
-
* @param {Object} [options]
|
|
16804
|
-
* @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)
|
|
16805
|
-
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
|
|
16806
|
-
* @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID
|
|
16807
|
-
* @throws {TypeError} If any of the parameters are invalid
|
|
16808
|
-
* @return {Object} A JSON-RPC 1.0 or 2.0 request
|
|
16809
|
-
* @memberOf Utils
|
|
16810
|
-
*/
|
|
16811
|
-
const generateRequest$1 = function(method, params, id, options) {
|
|
16812
|
-
if(typeof method !== 'string') {
|
|
16813
|
-
throw new TypeError(method + ' must be a string');
|
|
16814
|
-
}
|
|
16511
|
+
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
16815
16512
|
|
|
16816
|
-
|
|
16513
|
+
var _createClass2 = _interopRequireDefault(requireCreateClass());
|
|
16817
16514
|
|
|
16818
|
-
|
|
16819
|
-
const version = typeof options.version === 'number' ? options.version : 2;
|
|
16820
|
-
if (version !== 1 && version !== 2) {
|
|
16821
|
-
throw new TypeError(version + ' must be 1 or 2');
|
|
16822
|
-
}
|
|
16515
|
+
var _inherits2 = _interopRequireDefault(requireInherits());
|
|
16823
16516
|
|
|
16824
|
-
|
|
16825
|
-
method: method
|
|
16826
|
-
};
|
|
16517
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(requirePossibleConstructorReturn());
|
|
16827
16518
|
|
|
16828
|
-
|
|
16829
|
-
request.jsonrpc = '2.0';
|
|
16830
|
-
}
|
|
16519
|
+
var _getPrototypeOf2 = _interopRequireDefault(requireGetPrototypeOf());
|
|
16831
16520
|
|
|
16832
|
-
|
|
16833
|
-
// params given, but invalid?
|
|
16834
|
-
if(typeof params !== 'object' && !Array.isArray(params)) {
|
|
16835
|
-
throw new TypeError(params + ' must be an object, array or omitted');
|
|
16836
|
-
}
|
|
16837
|
-
request.params = params;
|
|
16838
|
-
}
|
|
16521
|
+
var _eventemitter = requireEventemitter3();
|
|
16839
16522
|
|
|
16840
|
-
|
|
16841
|
-
if(typeof(id) === 'undefined') {
|
|
16842
|
-
const generator = typeof options.generator === 'function' ? options.generator : function() { return uuid$1(); };
|
|
16843
|
-
request.id = generator(request, options);
|
|
16844
|
-
} else if (version === 2 && id === null) {
|
|
16845
|
-
// we have a version 2 notification
|
|
16846
|
-
if (options.notificationIdNull) {
|
|
16847
|
-
request.id = null; // id will not be set at all unless option provided
|
|
16848
|
-
}
|
|
16849
|
-
} else {
|
|
16850
|
-
request.id = id;
|
|
16851
|
-
}
|
|
16523
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
16852
16524
|
|
|
16853
|
-
|
|
16854
|
-
};
|
|
16525
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16855
16526
|
|
|
16856
|
-
|
|
16527
|
+
var __rest = function (s, e) {
|
|
16528
|
+
var t = {};
|
|
16857
16529
|
|
|
16858
|
-
|
|
16859
|
-
|
|
16530
|
+
for (var p in s) {
|
|
16531
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
16532
|
+
}
|
|
16860
16533
|
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
16876
|
-
|
|
16534
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16535
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
16536
|
+
}
|
|
16537
|
+
return t;
|
|
16538
|
+
}; // @ts-ignore
|
|
16539
|
+
|
|
16540
|
+
|
|
16541
|
+
var CommonClient = /*#__PURE__*/function (_EventEmitter) {
|
|
16542
|
+
(0, _inherits2["default"])(CommonClient, _EventEmitter);
|
|
16543
|
+
|
|
16544
|
+
var _super = _createSuper(CommonClient);
|
|
16545
|
+
|
|
16546
|
+
/**
|
|
16547
|
+
* Instantiate a Client class.
|
|
16548
|
+
* @constructor
|
|
16549
|
+
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
16550
|
+
* @param {String} address - url to a websocket server
|
|
16551
|
+
* @param {Object} options - ws options object with reconnect parameters
|
|
16552
|
+
* @param {Function} generate_request_id - custom generation request Id
|
|
16553
|
+
* @return {CommonClient}
|
|
16554
|
+
*/
|
|
16555
|
+
function CommonClient(webSocketFactory) {
|
|
16556
|
+
var _this;
|
|
16557
|
+
|
|
16558
|
+
var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ws://localhost:8080";
|
|
16559
|
+
|
|
16560
|
+
var _a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16561
|
+
|
|
16562
|
+
var generate_request_id = arguments.length > 3 ? arguments[3] : undefined;
|
|
16563
|
+
(0, _classCallCheck2["default"])(this, CommonClient);
|
|
16564
|
+
|
|
16565
|
+
var _a$autoconnect = _a.autoconnect,
|
|
16566
|
+
autoconnect = _a$autoconnect === void 0 ? true : _a$autoconnect,
|
|
16567
|
+
_a$reconnect = _a.reconnect,
|
|
16568
|
+
reconnect = _a$reconnect === void 0 ? true : _a$reconnect,
|
|
16569
|
+
_a$reconnect_interval = _a.reconnect_interval,
|
|
16570
|
+
reconnect_interval = _a$reconnect_interval === void 0 ? 1000 : _a$reconnect_interval,
|
|
16571
|
+
_a$max_reconnects = _a.max_reconnects,
|
|
16572
|
+
max_reconnects = _a$max_reconnects === void 0 ? 5 : _a$max_reconnects,
|
|
16573
|
+
rest_options = __rest(_a, ["autoconnect", "reconnect", "reconnect_interval", "max_reconnects"]);
|
|
16574
|
+
|
|
16575
|
+
_this = _super.call(this);
|
|
16576
|
+
_this.webSocketFactory = webSocketFactory;
|
|
16577
|
+
_this.queue = {};
|
|
16578
|
+
_this.rpc_id = 0;
|
|
16579
|
+
_this.address = address;
|
|
16580
|
+
_this.autoconnect = autoconnect;
|
|
16581
|
+
_this.ready = false;
|
|
16582
|
+
_this.reconnect = reconnect;
|
|
16583
|
+
_this.reconnect_interval = reconnect_interval;
|
|
16584
|
+
_this.max_reconnects = max_reconnects;
|
|
16585
|
+
_this.rest_options = rest_options;
|
|
16586
|
+
_this.current_reconnects = 0;
|
|
16587
|
+
|
|
16588
|
+
_this.generate_request_id = generate_request_id || function () {
|
|
16589
|
+
return ++_this.rpc_id;
|
|
16590
|
+
};
|
|
16877
16591
|
|
|
16878
|
-
|
|
16879
|
-
|
|
16880
|
-
|
|
16592
|
+
if (_this.autoconnect) _this._connect(_this.address, Object.assign({
|
|
16593
|
+
autoconnect: _this.autoconnect,
|
|
16594
|
+
reconnect: _this.reconnect,
|
|
16595
|
+
reconnect_interval: _this.reconnect_interval,
|
|
16596
|
+
max_reconnects: _this.max_reconnects
|
|
16597
|
+
}, _this.rest_options));
|
|
16598
|
+
return _this;
|
|
16599
|
+
}
|
|
16600
|
+
/**
|
|
16601
|
+
* Connects to a defined server if not connected already.
|
|
16602
|
+
* @method
|
|
16603
|
+
* @return {Undefined}
|
|
16604
|
+
*/
|
|
16605
|
+
|
|
16606
|
+
|
|
16607
|
+
(0, _createClass2["default"])(CommonClient, [{
|
|
16608
|
+
key: "connect",
|
|
16609
|
+
value: function connect() {
|
|
16610
|
+
if (this.socket) return;
|
|
16611
|
+
|
|
16612
|
+
this._connect(this.address, Object.assign({
|
|
16613
|
+
autoconnect: this.autoconnect,
|
|
16614
|
+
reconnect: this.reconnect,
|
|
16615
|
+
reconnect_interval: this.reconnect_interval,
|
|
16616
|
+
max_reconnects: this.max_reconnects
|
|
16617
|
+
}, this.rest_options));
|
|
16618
|
+
}
|
|
16619
|
+
/**
|
|
16620
|
+
* Calls a registered RPC method on server.
|
|
16621
|
+
* @method
|
|
16622
|
+
* @param {String} method - RPC method name
|
|
16623
|
+
* @param {Object|Array} params - optional method parameters
|
|
16624
|
+
* @param {Number} timeout - RPC reply timeout value
|
|
16625
|
+
* @param {Object} ws_opts - options passed to ws
|
|
16626
|
+
* @return {Promise}
|
|
16627
|
+
*/
|
|
16628
|
+
|
|
16629
|
+
}, {
|
|
16630
|
+
key: "call",
|
|
16631
|
+
value: function call(method, params, timeout, ws_opts) {
|
|
16632
|
+
var _this2 = this;
|
|
16633
|
+
|
|
16634
|
+
if (!ws_opts && "object" === (0, _typeof2["default"])(timeout)) {
|
|
16635
|
+
ws_opts = timeout;
|
|
16636
|
+
timeout = null;
|
|
16637
|
+
}
|
|
16881
16638
|
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
replacer: typeof options.replacer !== 'undefined' ? options.replacer : null,
|
|
16885
|
-
generator: typeof options.generator !== 'undefined' ? options.generator : function() { return uuid(); },
|
|
16886
|
-
version: typeof options.version !== 'undefined' ? options.version : 2,
|
|
16887
|
-
notificationIdNull: typeof options.notificationIdNull === 'boolean' ? options.notificationIdNull : false,
|
|
16888
|
-
};
|
|
16639
|
+
return new Promise(function (resolve, reject) {
|
|
16640
|
+
if (!_this2.ready) return reject(new Error("socket not ready"));
|
|
16889
16641
|
|
|
16890
|
-
|
|
16891
|
-
};
|
|
16642
|
+
var rpc_id = _this2.generate_request_id(method, params);
|
|
16892
16643
|
|
|
16893
|
-
|
|
16644
|
+
var message = {
|
|
16645
|
+
jsonrpc: "2.0",
|
|
16646
|
+
method: method,
|
|
16647
|
+
params: params || null,
|
|
16648
|
+
id: rpc_id
|
|
16649
|
+
};
|
|
16894
16650
|
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16651
|
+
_this2.socket.send(JSON.stringify(message), ws_opts, function (error) {
|
|
16652
|
+
if (error) return reject(error);
|
|
16653
|
+
_this2.queue[rpc_id] = {
|
|
16654
|
+
promise: [resolve, reject]
|
|
16655
|
+
};
|
|
16656
|
+
|
|
16657
|
+
if (timeout) {
|
|
16658
|
+
_this2.queue[rpc_id].timeout = setTimeout(function () {
|
|
16659
|
+
delete _this2.queue[rpc_id];
|
|
16660
|
+
reject(new Error("reply timeout"));
|
|
16661
|
+
}, timeout);
|
|
16662
|
+
}
|
|
16663
|
+
});
|
|
16664
|
+
});
|
|
16665
|
+
}
|
|
16666
|
+
/**
|
|
16667
|
+
* Logins with the other side of the connection.
|
|
16668
|
+
* @method
|
|
16669
|
+
* @param {Object} params - Login credentials object
|
|
16670
|
+
* @return {Promise}
|
|
16671
|
+
*/
|
|
16672
|
+
|
|
16673
|
+
}, {
|
|
16674
|
+
key: "login",
|
|
16675
|
+
value: function () {
|
|
16676
|
+
var _login = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(params) {
|
|
16677
|
+
var resp;
|
|
16678
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
16679
|
+
while (1) {
|
|
16680
|
+
switch (_context.prev = _context.next) {
|
|
16681
|
+
case 0:
|
|
16682
|
+
_context.next = 2;
|
|
16683
|
+
return this.call("rpc.login", params);
|
|
16684
|
+
|
|
16685
|
+
case 2:
|
|
16686
|
+
resp = _context.sent;
|
|
16687
|
+
|
|
16688
|
+
if (resp) {
|
|
16689
|
+
_context.next = 5;
|
|
16690
|
+
break;
|
|
16691
|
+
}
|
|
16692
|
+
|
|
16693
|
+
throw new Error("authentication failed");
|
|
16694
|
+
|
|
16695
|
+
case 5:
|
|
16696
|
+
return _context.abrupt("return", resp);
|
|
16697
|
+
|
|
16698
|
+
case 6:
|
|
16699
|
+
case "end":
|
|
16700
|
+
return _context.stop();
|
|
16701
|
+
}
|
|
16702
|
+
}
|
|
16703
|
+
}, _callee, this);
|
|
16704
|
+
}));
|
|
16705
|
+
|
|
16706
|
+
function login(_x) {
|
|
16707
|
+
return _login.apply(this, arguments);
|
|
16708
|
+
}
|
|
16907
16709
|
|
|
16908
|
-
|
|
16909
|
-
|
|
16710
|
+
return login;
|
|
16711
|
+
}()
|
|
16712
|
+
/**
|
|
16713
|
+
* Fetches a list of client's methods registered on server.
|
|
16714
|
+
* @method
|
|
16715
|
+
* @return {Array}
|
|
16716
|
+
*/
|
|
16717
|
+
|
|
16718
|
+
}, {
|
|
16719
|
+
key: "listMethods",
|
|
16720
|
+
value: function () {
|
|
16721
|
+
var _listMethods = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
16722
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
16723
|
+
while (1) {
|
|
16724
|
+
switch (_context2.prev = _context2.next) {
|
|
16725
|
+
case 0:
|
|
16726
|
+
_context2.next = 2;
|
|
16727
|
+
return this.call("__listMethods");
|
|
16728
|
+
|
|
16729
|
+
case 2:
|
|
16730
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16731
|
+
|
|
16732
|
+
case 3:
|
|
16733
|
+
case "end":
|
|
16734
|
+
return _context2.stop();
|
|
16735
|
+
}
|
|
16736
|
+
}
|
|
16737
|
+
}, _callee2, this);
|
|
16738
|
+
}));
|
|
16910
16739
|
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16740
|
+
function listMethods() {
|
|
16741
|
+
return _listMethods.apply(this, arguments);
|
|
16742
|
+
}
|
|
16914
16743
|
|
|
16915
|
-
|
|
16916
|
-
|
|
16744
|
+
return listMethods;
|
|
16745
|
+
}()
|
|
16746
|
+
/**
|
|
16747
|
+
* Sends a JSON-RPC 2.0 notification to server.
|
|
16748
|
+
* @method
|
|
16749
|
+
* @param {String} method - RPC method name
|
|
16750
|
+
* @param {Object} params - optional method parameters
|
|
16751
|
+
* @return {Promise}
|
|
16752
|
+
*/
|
|
16753
|
+
|
|
16754
|
+
}, {
|
|
16755
|
+
key: "notify",
|
|
16756
|
+
value: function notify(method, params) {
|
|
16757
|
+
var _this3 = this;
|
|
16758
|
+
|
|
16759
|
+
return new Promise(function (resolve, reject) {
|
|
16760
|
+
if (!_this3.ready) return reject(new Error("socket not ready"));
|
|
16761
|
+
var message = {
|
|
16762
|
+
jsonrpc: "2.0",
|
|
16763
|
+
method: method,
|
|
16764
|
+
params: params || null
|
|
16765
|
+
};
|
|
16917
16766
|
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
16926
|
-
|
|
16767
|
+
_this3.socket.send(JSON.stringify(message), function (error) {
|
|
16768
|
+
if (error) return reject(error);
|
|
16769
|
+
resolve();
|
|
16770
|
+
});
|
|
16771
|
+
});
|
|
16772
|
+
}
|
|
16773
|
+
/**
|
|
16774
|
+
* Subscribes for a defined event.
|
|
16775
|
+
* @method
|
|
16776
|
+
* @param {String|Array} event - event name
|
|
16777
|
+
* @return {Undefined}
|
|
16778
|
+
* @throws {Error}
|
|
16779
|
+
*/
|
|
16780
|
+
|
|
16781
|
+
}, {
|
|
16782
|
+
key: "subscribe",
|
|
16783
|
+
value: function () {
|
|
16784
|
+
var _subscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(event) {
|
|
16785
|
+
var result;
|
|
16786
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
16787
|
+
while (1) {
|
|
16788
|
+
switch (_context3.prev = _context3.next) {
|
|
16789
|
+
case 0:
|
|
16790
|
+
if (typeof event === "string") event = [event];
|
|
16791
|
+
_context3.next = 3;
|
|
16792
|
+
return this.call("rpc.on", event);
|
|
16793
|
+
|
|
16794
|
+
case 3:
|
|
16795
|
+
result = _context3.sent;
|
|
16796
|
+
|
|
16797
|
+
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
16798
|
+
_context3.next = 6;
|
|
16799
|
+
break;
|
|
16800
|
+
}
|
|
16801
|
+
|
|
16802
|
+
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
16803
|
+
|
|
16804
|
+
case 6:
|
|
16805
|
+
return _context3.abrupt("return", result);
|
|
16806
|
+
|
|
16807
|
+
case 7:
|
|
16808
|
+
case "end":
|
|
16809
|
+
return _context3.stop();
|
|
16810
|
+
}
|
|
16811
|
+
}
|
|
16812
|
+
}, _callee3, this);
|
|
16813
|
+
}));
|
|
16927
16814
|
|
|
16928
|
-
|
|
16815
|
+
function subscribe(_x2) {
|
|
16816
|
+
return _subscribe.apply(this, arguments);
|
|
16817
|
+
}
|
|
16929
16818
|
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16819
|
+
return subscribe;
|
|
16820
|
+
}()
|
|
16821
|
+
/**
|
|
16822
|
+
* Unsubscribes from a defined event.
|
|
16823
|
+
* @method
|
|
16824
|
+
* @param {String|Array} event - event name
|
|
16825
|
+
* @return {Undefined}
|
|
16826
|
+
* @throws {Error}
|
|
16827
|
+
*/
|
|
16828
|
+
|
|
16829
|
+
}, {
|
|
16830
|
+
key: "unsubscribe",
|
|
16831
|
+
value: function () {
|
|
16832
|
+
var _unsubscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event) {
|
|
16833
|
+
var result;
|
|
16834
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
16835
|
+
while (1) {
|
|
16836
|
+
switch (_context4.prev = _context4.next) {
|
|
16837
|
+
case 0:
|
|
16838
|
+
if (typeof event === "string") event = [event];
|
|
16839
|
+
_context4.next = 3;
|
|
16840
|
+
return this.call("rpc.off", event);
|
|
16841
|
+
|
|
16842
|
+
case 3:
|
|
16843
|
+
result = _context4.sent;
|
|
16844
|
+
|
|
16845
|
+
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
16846
|
+
_context4.next = 6;
|
|
16847
|
+
break;
|
|
16848
|
+
}
|
|
16849
|
+
|
|
16850
|
+
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
16851
|
+
|
|
16852
|
+
case 6:
|
|
16853
|
+
return _context4.abrupt("return", result);
|
|
16854
|
+
|
|
16855
|
+
case 7:
|
|
16856
|
+
case "end":
|
|
16857
|
+
return _context4.stop();
|
|
16858
|
+
}
|
|
16859
|
+
}
|
|
16860
|
+
}, _callee4, this);
|
|
16861
|
+
}));
|
|
16942
16862
|
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
}
|
|
16863
|
+
function unsubscribe(_x3) {
|
|
16864
|
+
return _unsubscribe.apply(this, arguments);
|
|
16865
|
+
}
|
|
16947
16866
|
|
|
16948
|
-
|
|
16867
|
+
return unsubscribe;
|
|
16868
|
+
}()
|
|
16869
|
+
/**
|
|
16870
|
+
* Closes a WebSocket connection gracefully.
|
|
16871
|
+
* @method
|
|
16872
|
+
* @param {Number} code - socket close code
|
|
16873
|
+
* @param {String} data - optional data to be sent before closing
|
|
16874
|
+
* @return {Undefined}
|
|
16875
|
+
*/
|
|
16876
|
+
|
|
16877
|
+
}, {
|
|
16878
|
+
key: "close",
|
|
16879
|
+
value: function close(code, data) {
|
|
16880
|
+
this.socket.close(code || 1000, data);
|
|
16881
|
+
}
|
|
16882
|
+
/**
|
|
16883
|
+
* Connection/Message handler.
|
|
16884
|
+
* @method
|
|
16885
|
+
* @private
|
|
16886
|
+
* @param {String} address - WebSocket API address
|
|
16887
|
+
* @param {Object} options - ws options object
|
|
16888
|
+
* @return {Undefined}
|
|
16889
|
+
*/
|
|
16890
|
+
|
|
16891
|
+
}, {
|
|
16892
|
+
key: "_connect",
|
|
16893
|
+
value: function _connect(address, options) {
|
|
16894
|
+
var _this4 = this;
|
|
16895
|
+
|
|
16896
|
+
this.socket = this.webSocketFactory(address, options);
|
|
16897
|
+
this.socket.addEventListener("open", function () {
|
|
16898
|
+
_this4.ready = true;
|
|
16899
|
+
|
|
16900
|
+
_this4.emit("open");
|
|
16901
|
+
|
|
16902
|
+
_this4.current_reconnects = 0;
|
|
16903
|
+
});
|
|
16904
|
+
this.socket.addEventListener("message", function (_ref) {
|
|
16905
|
+
var message = _ref.data;
|
|
16906
|
+
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
16907
|
+
|
|
16908
|
+
try {
|
|
16909
|
+
message = JSON.parse(message);
|
|
16910
|
+
} catch (error) {
|
|
16911
|
+
return;
|
|
16912
|
+
} // check if any listeners are attached and forward event
|
|
16913
|
+
|
|
16914
|
+
|
|
16915
|
+
if (message.notification && _this4.listeners(message.notification).length) {
|
|
16916
|
+
if (!Object.keys(message.params).length) return _this4.emit(message.notification);
|
|
16917
|
+
var args = [message.notification];
|
|
16918
|
+
if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
|
|
16919
|
+
for (var i = 0; i < message.params.length; i++) {
|
|
16920
|
+
args.push(message.params[i]);
|
|
16921
|
+
} // run as microtask so that pending queue messages are resolved first
|
|
16922
|
+
// eslint-disable-next-line prefer-spread
|
|
16923
|
+
|
|
16924
|
+
return Promise.resolve().then(function () {
|
|
16925
|
+
_this4.emit.apply(_this4, args);
|
|
16926
|
+
});
|
|
16927
|
+
}
|
|
16949
16928
|
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
|
|
16929
|
+
if (!_this4.queue[message.id]) {
|
|
16930
|
+
// general JSON RPC 2.0 events
|
|
16931
|
+
if (message.method && message.params) {
|
|
16932
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16933
|
+
return Promise.resolve().then(function () {
|
|
16934
|
+
_this4.emit(message.method, message.params);
|
|
16935
|
+
});
|
|
16936
|
+
}
|
|
16956
16937
|
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
});
|
|
16938
|
+
return;
|
|
16939
|
+
} // reject early since server's response is invalid
|
|
16960
16940
|
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16941
|
+
|
|
16942
|
+
if ("error" in message === "result" in message) _this4.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" + " or \"error\", but not both."));
|
|
16943
|
+
if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
|
|
16944
|
+
if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
|
|
16945
|
+
delete _this4.queue[message.id];
|
|
16946
|
+
});
|
|
16947
|
+
this.socket.addEventListener("error", function (error) {
|
|
16948
|
+
return _this4.emit("error", error);
|
|
16949
|
+
});
|
|
16950
|
+
this.socket.addEventListener("close", function (_ref2) {
|
|
16951
|
+
var code = _ref2.code,
|
|
16952
|
+
reason = _ref2.reason;
|
|
16953
|
+
if (_this4.ready) // Delay close event until internal state is updated
|
|
16954
|
+
setTimeout(function () {
|
|
16955
|
+
return _this4.emit("close", code, reason);
|
|
16956
|
+
}, 0);
|
|
16957
|
+
_this4.ready = false;
|
|
16958
|
+
_this4.socket = undefined;
|
|
16959
|
+
if (code === 1000) return;
|
|
16960
|
+
_this4.current_reconnects++;
|
|
16961
|
+
if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) setTimeout(function () {
|
|
16962
|
+
return _this4._connect(address, options);
|
|
16963
|
+
}, _this4.reconnect_interval);
|
|
16964
|
+
});
|
|
16965
|
+
}
|
|
16966
|
+
}]);
|
|
16967
|
+
return CommonClient;
|
|
16968
|
+
}(_eventemitter.EventEmitter);
|
|
16969
|
+
|
|
16970
|
+
exports["default"] = CommonClient;
|
|
16971
|
+
} (client));
|
|
16972
|
+
|
|
16973
|
+
var RpcWebSocketCommonClient = /*@__PURE__*/getDefaultExportFromCjs(client);
|
|
16974
|
+
|
|
16975
|
+
var websocket_browser = {};
|
|
16964
16976
|
|
|
16965
16977
|
/**
|
|
16966
|
-
*
|
|
16967
|
-
* @
|
|
16968
|
-
* @param {String} responseText JSON-RPC 1.0 or 2.0 response
|
|
16969
|
-
* @param {Function} callback Callback that will receive different arguments depending on the amount of parameters
|
|
16970
|
-
* @private
|
|
16978
|
+
* WebSocket implements a browser-side WebSocket specification.
|
|
16979
|
+
* @module Client
|
|
16971
16980
|
*/
|
|
16972
|
-
ClientBrowser.prototype._parseResponse = function(err, responseText, callback) {
|
|
16973
|
-
if(err) {
|
|
16974
|
-
callback(err);
|
|
16975
|
-
return;
|
|
16976
|
-
}
|
|
16977
16981
|
|
|
16978
|
-
|
|
16979
|
-
// empty response text, assume that is correct because it could be a
|
|
16980
|
-
// notification which jayson does not give any body for
|
|
16981
|
-
return callback();
|
|
16982
|
-
}
|
|
16982
|
+
(function (exports) {
|
|
16983
16983
|
|
|
16984
|
-
|
|
16985
|
-
try {
|
|
16986
|
-
response = JSON.parse(responseText, this.options.reviver);
|
|
16987
|
-
} catch(err) {
|
|
16988
|
-
return callback(err);
|
|
16989
|
-
}
|
|
16984
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
16990
16985
|
|
|
16991
|
-
|
|
16992
|
-
|
|
16986
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16987
|
+
value: true
|
|
16988
|
+
});
|
|
16989
|
+
exports["default"] = _default;
|
|
16993
16990
|
|
|
16994
|
-
|
|
16995
|
-
if(Array.isArray(response)) {
|
|
16991
|
+
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
16996
16992
|
|
|
16997
|
-
|
|
16998
|
-
const isError = function(res) {
|
|
16999
|
-
return typeof res.error !== 'undefined';
|
|
17000
|
-
};
|
|
16993
|
+
var _createClass2 = _interopRequireDefault(requireCreateClass());
|
|
17001
16994
|
|
|
17002
|
-
|
|
17003
|
-
return !isError(res);
|
|
17004
|
-
};
|
|
16995
|
+
var _inherits2 = _interopRequireDefault(requireInherits());
|
|
17005
16996
|
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
} else {
|
|
16997
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(requirePossibleConstructorReturn());
|
|
17009
16998
|
|
|
17010
|
-
|
|
17011
|
-
return callback(null, response.error, response.result);
|
|
17012
|
-
|
|
17013
|
-
}
|
|
17014
|
-
|
|
17015
|
-
}
|
|
16999
|
+
var _getPrototypeOf2 = _interopRequireDefault(requireGetPrototypeOf());
|
|
17016
17000
|
|
|
17017
|
-
|
|
17018
|
-
};
|
|
17001
|
+
var _eventemitter = requireEventemitter3();
|
|
17019
17002
|
|
|
17020
|
-
|
|
17003
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
17021
17004
|
|
|
17022
|
-
|
|
17005
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17023
17006
|
|
|
17024
|
-
|
|
17025
|
-
|
|
17007
|
+
var WebSocketBrowserImpl = /*#__PURE__*/function (_EventEmitter) {
|
|
17008
|
+
(0, _inherits2["default"])(WebSocketBrowserImpl, _EventEmitter);
|
|
17026
17009
|
|
|
17027
|
-
|
|
17028
|
-
n /= 2;
|
|
17029
|
-
trailingZeros++;
|
|
17030
|
-
}
|
|
17010
|
+
var _super = _createSuper(WebSocketBrowserImpl);
|
|
17031
17011
|
|
|
17032
|
-
|
|
17033
|
-
|
|
17012
|
+
/** Instantiate a WebSocket class
|
|
17013
|
+
* @constructor
|
|
17014
|
+
* @param {String} address - url to a websocket server
|
|
17015
|
+
* @param {(Object)} options - websocket options
|
|
17016
|
+
* @param {(String|Array)} protocols - a list of protocols
|
|
17017
|
+
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
17018
|
+
*/
|
|
17019
|
+
function WebSocketBrowserImpl(address, options, protocols) {
|
|
17020
|
+
var _this;
|
|
17034
17021
|
|
|
17022
|
+
(0, _classCallCheck2["default"])(this, WebSocketBrowserImpl);
|
|
17023
|
+
_this = _super.call(this);
|
|
17024
|
+
_this.socket = new window.WebSocket(address, protocols);
|
|
17035
17025
|
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
n |= n >> 1;
|
|
17040
|
-
n |= n >> 2;
|
|
17041
|
-
n |= n >> 4;
|
|
17042
|
-
n |= n >> 8;
|
|
17043
|
-
n |= n >> 16;
|
|
17044
|
-
n |= n >> 32;
|
|
17045
|
-
return n + 1;
|
|
17046
|
-
}
|
|
17047
|
-
/**
|
|
17048
|
-
* Epoch schedule
|
|
17049
|
-
* (see https://docs.solana.com/terminology#epoch)
|
|
17050
|
-
* Can be retrieved with the {@link Connection.getEpochSchedule} method
|
|
17051
|
-
*/
|
|
17026
|
+
_this.socket.onopen = function () {
|
|
17027
|
+
return _this.emit("open");
|
|
17028
|
+
};
|
|
17052
17029
|
|
|
17030
|
+
_this.socket.onmessage = function (event) {
|
|
17031
|
+
return _this.emit("message", event.data);
|
|
17032
|
+
};
|
|
17053
17033
|
|
|
17054
|
-
|
|
17055
|
-
|
|
17034
|
+
_this.socket.onerror = function (error) {
|
|
17035
|
+
return _this.emit("error", error);
|
|
17036
|
+
};
|
|
17056
17037
|
|
|
17057
|
-
|
|
17038
|
+
_this.socket.onclose = function (event) {
|
|
17039
|
+
_this.emit("close", event.code, event.reason);
|
|
17040
|
+
};
|
|
17058
17041
|
|
|
17059
|
-
|
|
17042
|
+
return _this;
|
|
17043
|
+
}
|
|
17044
|
+
/**
|
|
17045
|
+
* Sends data through a websocket connection
|
|
17046
|
+
* @method
|
|
17047
|
+
* @param {(String|Object)} data - data to be sent via websocket
|
|
17048
|
+
* @param {Object} optionsOrCallback - ws options
|
|
17049
|
+
* @param {Function} callback - a callback called once the data is sent
|
|
17050
|
+
* @return {Undefined}
|
|
17051
|
+
*/
|
|
17052
|
+
|
|
17053
|
+
|
|
17054
|
+
(0, _createClass2["default"])(WebSocketBrowserImpl, [{
|
|
17055
|
+
key: "send",
|
|
17056
|
+
value: function send(data, optionsOrCallback, callback) {
|
|
17057
|
+
var cb = callback || optionsOrCallback;
|
|
17058
|
+
|
|
17059
|
+
try {
|
|
17060
|
+
this.socket.send(data);
|
|
17061
|
+
cb();
|
|
17062
|
+
} catch (error) {
|
|
17063
|
+
cb(error);
|
|
17064
|
+
}
|
|
17065
|
+
}
|
|
17066
|
+
/**
|
|
17067
|
+
* Closes an underlying socket
|
|
17068
|
+
* @method
|
|
17069
|
+
* @param {Number} code - status code explaining why the connection is being closed
|
|
17070
|
+
* @param {String} reason - a description why the connection is closing
|
|
17071
|
+
* @return {Undefined}
|
|
17072
|
+
* @throws {Error}
|
|
17073
|
+
*/
|
|
17074
|
+
|
|
17075
|
+
}, {
|
|
17076
|
+
key: "close",
|
|
17077
|
+
value: function close(code, reason) {
|
|
17078
|
+
this.socket.close(code, reason);
|
|
17079
|
+
}
|
|
17080
|
+
}, {
|
|
17081
|
+
key: "addEventListener",
|
|
17082
|
+
value: function addEventListener(type, listener, options) {
|
|
17083
|
+
this.socket.addEventListener(type, listener, options);
|
|
17084
|
+
}
|
|
17085
|
+
}]);
|
|
17086
|
+
return WebSocketBrowserImpl;
|
|
17087
|
+
}(_eventemitter.EventEmitter);
|
|
17088
|
+
/**
|
|
17089
|
+
* factory method for common WebSocket instance
|
|
17090
|
+
* @method
|
|
17091
|
+
* @param {String} address - url to a websocket server
|
|
17092
|
+
* @param {(Object)} options - websocket options
|
|
17093
|
+
* @return {Undefined}
|
|
17094
|
+
*/
|
|
17060
17095
|
|
|
17061
|
-
/** The first epoch with `slotsPerEpoch` slots */
|
|
17062
17096
|
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
this.warmup = void 0;
|
|
17068
|
-
this.firstNormalEpoch = void 0;
|
|
17069
|
-
this.firstNormalSlot = void 0;
|
|
17070
|
-
this.slotsPerEpoch = slotsPerEpoch;
|
|
17071
|
-
this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
|
|
17072
|
-
this.warmup = warmup;
|
|
17073
|
-
this.firstNormalEpoch = firstNormalEpoch;
|
|
17074
|
-
this.firstNormalSlot = firstNormalSlot;
|
|
17075
|
-
}
|
|
17097
|
+
function _default(address, options) {
|
|
17098
|
+
return new WebSocketBrowserImpl(address, options);
|
|
17099
|
+
}
|
|
17100
|
+
} (websocket_browser));
|
|
17076
17101
|
|
|
17077
|
-
|
|
17078
|
-
|
|
17079
|
-
|
|
17102
|
+
var WebsocketFactory = /*@__PURE__*/getDefaultExportFromCjs(websocket_browser);
|
|
17103
|
+
|
|
17104
|
+
class RpcWebSocketClient extends RpcWebSocketCommonClient {
|
|
17105
|
+
constructor(address, options, generate_request_id) {
|
|
17106
|
+
const webSocketFactory = url => {
|
|
17107
|
+
const rpc = WebsocketFactory(url, {
|
|
17108
|
+
autoconnect: true,
|
|
17109
|
+
max_reconnects: 5,
|
|
17110
|
+
reconnect: true,
|
|
17111
|
+
reconnect_interval: 1000,
|
|
17112
|
+
...options
|
|
17113
|
+
});
|
|
17080
17114
|
|
|
17081
|
-
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
17085
|
-
|
|
17086
|
-
return [epoch, slotIndex];
|
|
17087
|
-
} else {
|
|
17088
|
-
const normalSlotIndex = slot - this.firstNormalSlot;
|
|
17089
|
-
const normalEpochIndex = Math.floor(normalSlotIndex / this.slotsPerEpoch);
|
|
17090
|
-
const epoch = this.firstNormalEpoch + normalEpochIndex;
|
|
17091
|
-
const slotIndex = normalSlotIndex % this.slotsPerEpoch;
|
|
17092
|
-
return [epoch, slotIndex];
|
|
17093
|
-
}
|
|
17094
|
-
}
|
|
17115
|
+
if ('socket' in rpc) {
|
|
17116
|
+
this.underlyingSocket = rpc.socket;
|
|
17117
|
+
} else {
|
|
17118
|
+
this.underlyingSocket = rpc;
|
|
17119
|
+
}
|
|
17095
17120
|
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
return (Math.pow(2, epoch) - 1) * MINIMUM_SLOT_PER_EPOCH;
|
|
17099
|
-
} else {
|
|
17100
|
-
return (epoch - this.firstNormalEpoch) * this.slotsPerEpoch + this.firstNormalSlot;
|
|
17101
|
-
}
|
|
17102
|
-
}
|
|
17121
|
+
return rpc;
|
|
17122
|
+
};
|
|
17103
17123
|
|
|
17104
|
-
|
|
17105
|
-
|
|
17124
|
+
super(webSocketFactory, address, options, generate_request_id);
|
|
17125
|
+
this.underlyingSocket = void 0;
|
|
17106
17126
|
}
|
|
17107
17127
|
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17128
|
+
call(...args) {
|
|
17129
|
+
var _this$underlyingSocke;
|
|
17130
|
+
|
|
17131
|
+
const readyState = (_this$underlyingSocke = this.underlyingSocket) === null || _this$underlyingSocke === void 0 ? void 0 : _this$underlyingSocke.readyState;
|
|
17132
|
+
|
|
17133
|
+
if (readyState === WebSocket.OPEN) {
|
|
17134
|
+
return super.call(...args);
|
|
17113
17135
|
}
|
|
17136
|
+
|
|
17137
|
+
throw new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
|
|
17114
17138
|
}
|
|
17115
17139
|
|
|
17116
|
-
|
|
17140
|
+
notify(...args) {
|
|
17141
|
+
var _this$underlyingSocke2;
|
|
17117
17142
|
|
|
17118
|
-
|
|
17119
|
-
constructor(message, logs) {
|
|
17120
|
-
super(message);
|
|
17121
|
-
this.logs = void 0;
|
|
17122
|
-
this.logs = logs;
|
|
17123
|
-
}
|
|
17143
|
+
const readyState = (_this$underlyingSocke2 = this.underlyingSocket) === null || _this$underlyingSocke2 === void 0 ? void 0 : _this$underlyingSocke2.readyState;
|
|
17124
17144
|
|
|
17125
|
-
|
|
17126
|
-
|
|
17145
|
+
if (readyState === WebSocket.OPEN) {
|
|
17146
|
+
return super.notify(...args);
|
|
17147
|
+
}
|
|
17127
17148
|
|
|
17128
|
-
|
|
17129
|
-
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
17130
|
-
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
17131
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
17132
|
-
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
17133
|
-
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
17134
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
17135
|
-
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
17136
|
-
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
17137
|
-
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
17138
|
-
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
17139
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
17140
|
-
JSON_RPC_SCAN_ERROR: -32012,
|
|
17141
|
-
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
17142
|
-
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
17143
|
-
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
17144
|
-
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
17145
|
-
};
|
|
17146
|
-
class SolanaJSONRPCError extends Error {
|
|
17147
|
-
constructor({
|
|
17148
|
-
code,
|
|
17149
|
-
message,
|
|
17150
|
-
data
|
|
17151
|
-
}, customMessage) {
|
|
17152
|
-
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
17153
|
-
this.code = void 0;
|
|
17154
|
-
this.data = void 0;
|
|
17155
|
-
this.code = code;
|
|
17156
|
-
this.data = data;
|
|
17157
|
-
this.name = 'SolanaJSONRPCError';
|
|
17149
|
+
throw new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')');
|
|
17158
17150
|
}
|
|
17159
17151
|
|
|
17160
17152
|
}
|
|
17161
17153
|
|
|
17162
|
-
var fetchImpl = globalThis.fetch;
|
|
17163
|
-
|
|
17164
17154
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
17165
17155
|
// Syscall account
|
|
17166
17156
|
|
|
@@ -18319,7 +18309,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18319
18309
|
|
|
18320
18310
|
/** @internal */
|
|
18321
18311
|
const COMMON_HTTP_HEADERS = {
|
|
18322
|
-
'solana-client': `js/${(_process$env$npm_pack = "
|
|
18312
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.70.1-pr-29195") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
18323
18313
|
};
|
|
18324
18314
|
/**
|
|
18325
18315
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -18449,7 +18439,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18449
18439
|
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
18450
18440
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
18451
18441
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
18452
|
-
this._rpcWebSocket = new
|
|
18442
|
+
this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {
|
|
18453
18443
|
autoconnect: false,
|
|
18454
18444
|
max_reconnects: Infinity
|
|
18455
18445
|
});
|