@solana/web3.js 1.91.7 → 1.91.9
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 +10 -12
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +10 -12
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +10 -12
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +10 -12
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +1192 -2397
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +7 -8
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +10 -12
- package/lib/index.native.js.map +1 -1
- package/package.json +6 -6
- package/src/__forks__/browser/rpc-websocket-factory.ts +1 -1
- package/src/__forks__/react-native/rpc-websocket-factory.ts +1 -1
- package/src/rpc-websocket-factory.ts +2 -2
- package/src/rpc-websocket.ts +6 -6
- package/src/utils/makeWebsocketUrl.ts +1 -1
package/lib/index.iife.js
CHANGED
|
@@ -2171,15 +2171,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
2171
2171
|
if (value > max || value < min) {
|
|
2172
2172
|
const n = typeof min === 'bigint' ? 'n' : '';
|
|
2173
2173
|
let range;
|
|
2174
|
-
|
|
2174
|
+
{
|
|
2175
2175
|
if (min === 0 || min === BigInt(0)) {
|
|
2176
2176
|
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
2177
2177
|
} else {
|
|
2178
2178
|
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
2179
2179
|
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
2180
2180
|
}
|
|
2181
|
-
} else {
|
|
2182
|
-
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
2183
2181
|
}
|
|
2184
2182
|
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
2185
2183
|
}
|
|
@@ -2195,15 +2193,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
2195
2193
|
function boundsError (value, length, type) {
|
|
2196
2194
|
if (Math.floor(value) !== value) {
|
|
2197
2195
|
validateNumber(value, type);
|
|
2198
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2196
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
2199
2197
|
}
|
|
2200
2198
|
|
|
2201
2199
|
if (length < 0) {
|
|
2202
2200
|
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
2203
2201
|
}
|
|
2204
2202
|
|
|
2205
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2206
|
-
`>= ${
|
|
2203
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
2204
|
+
`>= ${0} and <= ${length}`,
|
|
2207
2205
|
value)
|
|
2208
2206
|
}
|
|
2209
2207
|
|
|
@@ -2381,17 +2379,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
2381
2379
|
}
|
|
2382
2380
|
} (buffer));
|
|
2383
2381
|
|
|
2384
|
-
function number$
|
|
2382
|
+
function number$1(n) {
|
|
2385
2383
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
2386
2384
|
throw new Error(`positive integer expected, not ${n}`);
|
|
2387
2385
|
}
|
|
2388
2386
|
// copied from utils
|
|
2389
|
-
function isBytes$
|
|
2387
|
+
function isBytes$1(a) {
|
|
2390
2388
|
return (a instanceof Uint8Array ||
|
|
2391
2389
|
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2392
2390
|
}
|
|
2393
|
-
function bytes
|
|
2394
|
-
if (!isBytes$
|
|
2391
|
+
function bytes(b, ...lengths) {
|
|
2392
|
+
if (!isBytes$1(b))
|
|
2395
2393
|
throw new Error('Uint8Array expected');
|
|
2396
2394
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
2397
2395
|
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
@@ -2399,17 +2397,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
2399
2397
|
function hash(h) {
|
|
2400
2398
|
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
2401
2399
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
2402
|
-
number$
|
|
2403
|
-
number$
|
|
2400
|
+
number$1(h.outputLen);
|
|
2401
|
+
number$1(h.blockLen);
|
|
2404
2402
|
}
|
|
2405
|
-
function exists
|
|
2403
|
+
function exists(instance, checkFinished = true) {
|
|
2406
2404
|
if (instance.destroyed)
|
|
2407
2405
|
throw new Error('Hash instance has been destroyed');
|
|
2408
2406
|
if (checkFinished && instance.finished)
|
|
2409
2407
|
throw new Error('Hash#digest() has already been called');
|
|
2410
2408
|
}
|
|
2411
|
-
function output
|
|
2412
|
-
bytes
|
|
2409
|
+
function output(out, instance) {
|
|
2410
|
+
bytes(out);
|
|
2413
2411
|
const min = instance.outputLen;
|
|
2414
2412
|
if (out.length < min) {
|
|
2415
2413
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
@@ -2425,15 +2423,27 @@ var solanaWeb3 = (function (exports) {
|
|
|
2425
2423
|
// from `crypto` to `cryptoNode`, which imports native module.
|
|
2426
2424
|
// Makes the utils un-importable in browsers without a bundler.
|
|
2427
2425
|
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
2426
|
+
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
2428
2427
|
// Cast array to view
|
|
2429
|
-
const createView
|
|
2428
|
+
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
2430
2429
|
// The rotate right (circular right shift) operation for uint32
|
|
2431
|
-
const rotr
|
|
2432
|
-
new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2430
|
+
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
2431
|
+
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2432
|
+
// The byte swap operation for uint32
|
|
2433
|
+
const byteSwap = (word) => ((word << 24) & 0xff000000) |
|
|
2434
|
+
((word << 8) & 0xff0000) |
|
|
2435
|
+
((word >>> 8) & 0xff00) |
|
|
2436
|
+
((word >>> 24) & 0xff);
|
|
2437
|
+
// In place byte swap for Uint32Array
|
|
2438
|
+
function byteSwap32(arr) {
|
|
2439
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2440
|
+
arr[i] = byteSwap(arr[i]);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2433
2443
|
/**
|
|
2434
2444
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2435
2445
|
*/
|
|
2436
|
-
function utf8ToBytes$
|
|
2446
|
+
function utf8ToBytes$1(str) {
|
|
2437
2447
|
if (typeof str !== 'string')
|
|
2438
2448
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2439
2449
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -2443,10 +2453,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
2443
2453
|
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
2444
2454
|
* Keep in mind for future mutable operations.
|
|
2445
2455
|
*/
|
|
2446
|
-
function toBytes
|
|
2456
|
+
function toBytes(data) {
|
|
2447
2457
|
if (typeof data === 'string')
|
|
2448
|
-
data = utf8ToBytes$
|
|
2449
|
-
bytes
|
|
2458
|
+
data = utf8ToBytes$1(data);
|
|
2459
|
+
bytes(data);
|
|
2450
2460
|
return data;
|
|
2451
2461
|
}
|
|
2452
2462
|
/**
|
|
@@ -2456,7 +2466,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2456
2466
|
let sum = 0;
|
|
2457
2467
|
for (let i = 0; i < arrays.length; i++) {
|
|
2458
2468
|
const a = arrays[i];
|
|
2459
|
-
bytes
|
|
2469
|
+
bytes(a);
|
|
2460
2470
|
sum += a.length;
|
|
2461
2471
|
}
|
|
2462
2472
|
const res = new Uint8Array(sum);
|
|
@@ -2468,14 +2478,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
2468
2478
|
return res;
|
|
2469
2479
|
}
|
|
2470
2480
|
// For runtime check if class implements interface
|
|
2471
|
-
|
|
2481
|
+
class Hash {
|
|
2472
2482
|
// Safe version that clones internal state
|
|
2473
2483
|
clone() {
|
|
2474
2484
|
return this._cloneInto();
|
|
2475
2485
|
}
|
|
2476
|
-
}
|
|
2477
|
-
function wrapConstructor
|
|
2478
|
-
const hashC = (msg) => hashCons().update(toBytes
|
|
2486
|
+
}
|
|
2487
|
+
function wrapConstructor(hashCons) {
|
|
2488
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
2479
2489
|
const tmp = hashCons();
|
|
2480
2490
|
hashC.outputLen = tmp.outputLen;
|
|
2481
2491
|
hashC.blockLen = tmp.blockLen;
|
|
@@ -2493,7 +2503,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2493
2503
|
}
|
|
2494
2504
|
|
|
2495
2505
|
// Polyfill for Safari 14
|
|
2496
|
-
function setBigUint64
|
|
2506
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
2497
2507
|
if (typeof view.setBigUint64 === 'function')
|
|
2498
2508
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
2499
2509
|
const _32n = BigInt(32);
|
|
@@ -2506,14 +2516,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
2506
2516
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
2507
2517
|
}
|
|
2508
2518
|
// Choice: a ? b : c
|
|
2509
|
-
const Chi
|
|
2519
|
+
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
2510
2520
|
// Majority function, true if any two inpust is true
|
|
2511
|
-
const Maj
|
|
2521
|
+
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
2512
2522
|
/**
|
|
2513
2523
|
* Merkle-Damgard hash construction base class.
|
|
2514
2524
|
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
2515
2525
|
*/
|
|
2516
|
-
class HashMD extends Hash
|
|
2526
|
+
class HashMD extends Hash {
|
|
2517
2527
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2518
2528
|
super();
|
|
2519
2529
|
this.blockLen = blockLen;
|
|
@@ -2525,18 +2535,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
2525
2535
|
this.pos = 0;
|
|
2526
2536
|
this.destroyed = false;
|
|
2527
2537
|
this.buffer = new Uint8Array(blockLen);
|
|
2528
|
-
this.view = createView
|
|
2538
|
+
this.view = createView(this.buffer);
|
|
2529
2539
|
}
|
|
2530
2540
|
update(data) {
|
|
2531
|
-
exists
|
|
2541
|
+
exists(this);
|
|
2532
2542
|
const { view, buffer, blockLen } = this;
|
|
2533
|
-
data = toBytes
|
|
2543
|
+
data = toBytes(data);
|
|
2534
2544
|
const len = data.length;
|
|
2535
2545
|
for (let pos = 0; pos < len;) {
|
|
2536
2546
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
2537
2547
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
2538
2548
|
if (take === blockLen) {
|
|
2539
|
-
const dataView = createView
|
|
2549
|
+
const dataView = createView(data);
|
|
2540
2550
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
2541
2551
|
this.process(dataView, pos);
|
|
2542
2552
|
continue;
|
|
@@ -2554,8 +2564,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
2554
2564
|
return this;
|
|
2555
2565
|
}
|
|
2556
2566
|
digestInto(out) {
|
|
2557
|
-
exists
|
|
2558
|
-
output
|
|
2567
|
+
exists(this);
|
|
2568
|
+
output(out, this);
|
|
2559
2569
|
this.finished = true;
|
|
2560
2570
|
// Padding
|
|
2561
2571
|
// We can avoid allocation of buffer for padding completely if it
|
|
@@ -2577,9 +2587,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
2577
2587
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
2578
2588
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
2579
2589
|
// So we just write lowest 64 bits of that value.
|
|
2580
|
-
setBigUint64
|
|
2590
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
2581
2591
|
this.process(view, 0);
|
|
2582
|
-
const oview = createView
|
|
2592
|
+
const oview = createView(out);
|
|
2583
2593
|
const len = this.outputLen;
|
|
2584
2594
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
2585
2595
|
if (len % 4)
|
|
@@ -2612,24 +2622,24 @@ var solanaWeb3 = (function (exports) {
|
|
|
2612
2622
|
}
|
|
2613
2623
|
}
|
|
2614
2624
|
|
|
2615
|
-
const U32_MASK64
|
|
2616
|
-
const _32n
|
|
2625
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2626
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
2617
2627
|
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
2618
|
-
function fromBig
|
|
2628
|
+
function fromBig(n, le = false) {
|
|
2619
2629
|
if (le)
|
|
2620
|
-
return { h: Number(n & U32_MASK64
|
|
2621
|
-
return { h: Number((n >> _32n
|
|
2630
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
2631
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
2622
2632
|
}
|
|
2623
|
-
function split
|
|
2633
|
+
function split(lst, le = false) {
|
|
2624
2634
|
let Ah = new Uint32Array(lst.length);
|
|
2625
2635
|
let Al = new Uint32Array(lst.length);
|
|
2626
2636
|
for (let i = 0; i < lst.length; i++) {
|
|
2627
|
-
const { h, l } = fromBig
|
|
2637
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2628
2638
|
[Ah[i], Al[i]] = [h, l];
|
|
2629
2639
|
}
|
|
2630
2640
|
return [Ah, Al];
|
|
2631
2641
|
}
|
|
2632
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n
|
|
2642
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
2633
2643
|
// for Shift in [0, 32)
|
|
2634
2644
|
const shrSH = (h, _l, s) => h >>> s;
|
|
2635
2645
|
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
@@ -2643,11 +2653,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2643
2653
|
const rotr32H = (_h, l) => l;
|
|
2644
2654
|
const rotr32L = (h, _l) => h;
|
|
2645
2655
|
// Left rotate for Shift in [1, 32)
|
|
2646
|
-
const rotlSH
|
|
2647
|
-
const rotlSL
|
|
2656
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
2657
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
2648
2658
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
2649
|
-
const rotlBH
|
|
2650
|
-
const rotlBL
|
|
2659
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
2660
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
2651
2661
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
2652
2662
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
2653
2663
|
function add(Ah, Al, Bh, Bl) {
|
|
@@ -2663,11 +2673,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2663
2673
|
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
2664
2674
|
// prettier-ignore
|
|
2665
2675
|
const u64$1 = {
|
|
2666
|
-
fromBig
|
|
2676
|
+
fromBig, split, toBig,
|
|
2667
2677
|
shrSH, shrSL,
|
|
2668
2678
|
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
2669
2679
|
rotr32H, rotr32L,
|
|
2670
|
-
rotlSH
|
|
2680
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
2671
2681
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
2672
2682
|
};
|
|
2673
2683
|
|
|
@@ -2825,7 +2835,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2825
2835
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2826
2836
|
}
|
|
2827
2837
|
}
|
|
2828
|
-
const sha512 = /* @__PURE__ */ wrapConstructor
|
|
2838
|
+
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
2829
2839
|
|
|
2830
2840
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2831
2841
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
@@ -2835,12 +2845,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
2835
2845
|
const _0n$5 = BigInt(0);
|
|
2836
2846
|
const _1n$7 = BigInt(1);
|
|
2837
2847
|
const _2n$5 = BigInt(2);
|
|
2838
|
-
function isBytes
|
|
2848
|
+
function isBytes(a) {
|
|
2839
2849
|
return (a instanceof Uint8Array ||
|
|
2840
2850
|
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2841
2851
|
}
|
|
2842
2852
|
function abytes(item) {
|
|
2843
|
-
if (!isBytes
|
|
2853
|
+
if (!isBytes(item))
|
|
2844
2854
|
throw new Error('Uint8Array expected');
|
|
2845
2855
|
}
|
|
2846
2856
|
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
@@ -2937,7 +2947,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2937
2947
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
2938
2948
|
}
|
|
2939
2949
|
}
|
|
2940
|
-
else if (isBytes
|
|
2950
|
+
else if (isBytes(hex)) {
|
|
2941
2951
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
2942
2952
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
2943
2953
|
res = Uint8Array.from(hex);
|
|
@@ -2980,7 +2990,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2980
2990
|
/**
|
|
2981
2991
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2982
2992
|
*/
|
|
2983
|
-
function utf8ToBytes
|
|
2993
|
+
function utf8ToBytes(str) {
|
|
2984
2994
|
if (typeof str !== 'string')
|
|
2985
2995
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2986
2996
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -3082,7 +3092,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3082
3092
|
function: (val) => typeof val === 'function',
|
|
3083
3093
|
boolean: (val) => typeof val === 'boolean',
|
|
3084
3094
|
string: (val) => typeof val === 'string',
|
|
3085
|
-
stringOrUint8Array: (val) => typeof val === 'string' || isBytes
|
|
3095
|
+
stringOrUint8Array: (val) => typeof val === 'string' || isBytes(val),
|
|
3086
3096
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
3087
3097
|
array: (val) => Array.isArray(val),
|
|
3088
3098
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -3132,12 +3142,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
3132
3142
|
equalBytes: equalBytes,
|
|
3133
3143
|
hexToBytes: hexToBytes,
|
|
3134
3144
|
hexToNumber: hexToNumber,
|
|
3135
|
-
isBytes: isBytes
|
|
3145
|
+
isBytes: isBytes,
|
|
3136
3146
|
numberToBytesBE: numberToBytesBE,
|
|
3137
3147
|
numberToBytesLE: numberToBytesLE,
|
|
3138
3148
|
numberToHexUnpadded: numberToHexUnpadded,
|
|
3139
3149
|
numberToVarBytesBE: numberToVarBytesBE,
|
|
3140
|
-
utf8ToBytes: utf8ToBytes
|
|
3150
|
+
utf8ToBytes: utf8ToBytes,
|
|
3141
3151
|
validateObject: validateObject
|
|
3142
3152
|
});
|
|
3143
3153
|
|
|
@@ -4166,7 +4176,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4166
4176
|
function ed25519_domain(data, ctx, phflag) {
|
|
4167
4177
|
if (ctx.length > 255)
|
|
4168
4178
|
throw new Error('Context is too big');
|
|
4169
|
-
return concatBytes$1(utf8ToBytes$
|
|
4179
|
+
return concatBytes$1(utf8ToBytes$1('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
4170
4180
|
}
|
|
4171
4181
|
/* @__PURE__ */ twistedEdwards({
|
|
4172
4182
|
...ed25519Defaults,
|
|
@@ -7806,216 +7816,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
7806
7816
|
|
|
7807
7817
|
var bs58$1 = /*@__PURE__*/getDefaultExportFromCjs(bs58);
|
|
7808
7818
|
|
|
7809
|
-
function number$1(n) {
|
|
7810
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
7811
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
7812
|
-
}
|
|
7813
|
-
// copied from utils
|
|
7814
|
-
function isBytes$1(a) {
|
|
7815
|
-
return (a instanceof Uint8Array ||
|
|
7816
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7817
|
-
}
|
|
7818
|
-
function bytes(b, ...lengths) {
|
|
7819
|
-
if (!isBytes$1(b))
|
|
7820
|
-
throw new Error('Expected Uint8Array');
|
|
7821
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
7822
|
-
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
7823
|
-
}
|
|
7824
|
-
function exists(instance, checkFinished = true) {
|
|
7825
|
-
if (instance.destroyed)
|
|
7826
|
-
throw new Error('Hash instance has been destroyed');
|
|
7827
|
-
if (checkFinished && instance.finished)
|
|
7828
|
-
throw new Error('Hash#digest() has already been called');
|
|
7829
|
-
}
|
|
7830
|
-
function output(out, instance) {
|
|
7831
|
-
bytes(out);
|
|
7832
|
-
const min = instance.outputLen;
|
|
7833
|
-
if (out.length < min) {
|
|
7834
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
7835
|
-
}
|
|
7836
|
-
}
|
|
7837
|
-
|
|
7838
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7839
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
7840
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
7841
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
7842
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
7843
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
7844
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
7845
|
-
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
7846
|
-
function isBytes(a) {
|
|
7847
|
-
return (a instanceof Uint8Array ||
|
|
7848
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7849
|
-
}
|
|
7850
|
-
// Cast array to view
|
|
7851
|
-
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
7852
|
-
// The rotate right (circular right shift) operation for uint32
|
|
7853
|
-
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
7854
|
-
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
7855
|
-
// early-throw an error because we don't support BE yet.
|
|
7856
|
-
// Other libraries would silently corrupt the data instead of throwing an error,
|
|
7857
|
-
// when they don't support it.
|
|
7858
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
7859
|
-
if (!isLE)
|
|
7860
|
-
throw new Error('Non little-endian hardware is not supported');
|
|
7861
|
-
/**
|
|
7862
|
-
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
7863
|
-
*/
|
|
7864
|
-
function utf8ToBytes(str) {
|
|
7865
|
-
if (typeof str !== 'string')
|
|
7866
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
7867
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
7868
|
-
}
|
|
7869
|
-
/**
|
|
7870
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
7871
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
7872
|
-
* Keep in mind for future mutable operations.
|
|
7873
|
-
*/
|
|
7874
|
-
function toBytes(data) {
|
|
7875
|
-
if (typeof data === 'string')
|
|
7876
|
-
data = utf8ToBytes(data);
|
|
7877
|
-
if (!isBytes(data))
|
|
7878
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
7879
|
-
return data;
|
|
7880
|
-
}
|
|
7881
|
-
// For runtime check if class implements interface
|
|
7882
|
-
class Hash {
|
|
7883
|
-
// Safe version that clones internal state
|
|
7884
|
-
clone() {
|
|
7885
|
-
return this._cloneInto();
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
function wrapConstructor(hashCons) {
|
|
7889
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
7890
|
-
const tmp = hashCons();
|
|
7891
|
-
hashC.outputLen = tmp.outputLen;
|
|
7892
|
-
hashC.blockLen = tmp.blockLen;
|
|
7893
|
-
hashC.create = () => hashCons();
|
|
7894
|
-
return hashC;
|
|
7895
|
-
}
|
|
7896
|
-
|
|
7897
|
-
// Polyfill for Safari 14
|
|
7898
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
7899
|
-
if (typeof view.setBigUint64 === 'function')
|
|
7900
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
7901
|
-
const _32n = BigInt(32);
|
|
7902
|
-
const _u32_max = BigInt(0xffffffff);
|
|
7903
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
7904
|
-
const wl = Number(value & _u32_max);
|
|
7905
|
-
const h = isLE ? 4 : 0;
|
|
7906
|
-
const l = isLE ? 0 : 4;
|
|
7907
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
7908
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
7909
|
-
}
|
|
7910
|
-
// Base SHA2 class (RFC 6234)
|
|
7911
|
-
class SHA2 extends Hash {
|
|
7912
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
7913
|
-
super();
|
|
7914
|
-
this.blockLen = blockLen;
|
|
7915
|
-
this.outputLen = outputLen;
|
|
7916
|
-
this.padOffset = padOffset;
|
|
7917
|
-
this.isLE = isLE;
|
|
7918
|
-
this.finished = false;
|
|
7919
|
-
this.length = 0;
|
|
7920
|
-
this.pos = 0;
|
|
7921
|
-
this.destroyed = false;
|
|
7922
|
-
this.buffer = new Uint8Array(blockLen);
|
|
7923
|
-
this.view = createView(this.buffer);
|
|
7924
|
-
}
|
|
7925
|
-
update(data) {
|
|
7926
|
-
exists(this);
|
|
7927
|
-
const { view, buffer, blockLen } = this;
|
|
7928
|
-
data = toBytes(data);
|
|
7929
|
-
const len = data.length;
|
|
7930
|
-
for (let pos = 0; pos < len;) {
|
|
7931
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
7932
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
7933
|
-
if (take === blockLen) {
|
|
7934
|
-
const dataView = createView(data);
|
|
7935
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
7936
|
-
this.process(dataView, pos);
|
|
7937
|
-
continue;
|
|
7938
|
-
}
|
|
7939
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
7940
|
-
this.pos += take;
|
|
7941
|
-
pos += take;
|
|
7942
|
-
if (this.pos === blockLen) {
|
|
7943
|
-
this.process(view, 0);
|
|
7944
|
-
this.pos = 0;
|
|
7945
|
-
}
|
|
7946
|
-
}
|
|
7947
|
-
this.length += data.length;
|
|
7948
|
-
this.roundClean();
|
|
7949
|
-
return this;
|
|
7950
|
-
}
|
|
7951
|
-
digestInto(out) {
|
|
7952
|
-
exists(this);
|
|
7953
|
-
output(out, this);
|
|
7954
|
-
this.finished = true;
|
|
7955
|
-
// Padding
|
|
7956
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
7957
|
-
// was previously not allocated here. But it won't change performance.
|
|
7958
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
7959
|
-
let { pos } = this;
|
|
7960
|
-
// append the bit '1' to the message
|
|
7961
|
-
buffer[pos++] = 0b10000000;
|
|
7962
|
-
this.buffer.subarray(pos).fill(0);
|
|
7963
|
-
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
|
7964
|
-
if (this.padOffset > blockLen - pos) {
|
|
7965
|
-
this.process(view, 0);
|
|
7966
|
-
pos = 0;
|
|
7967
|
-
}
|
|
7968
|
-
// Pad until full block byte with zeros
|
|
7969
|
-
for (let i = pos; i < blockLen; i++)
|
|
7970
|
-
buffer[i] = 0;
|
|
7971
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
7972
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
7973
|
-
// So we just write lowest 64 bits of that value.
|
|
7974
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
7975
|
-
this.process(view, 0);
|
|
7976
|
-
const oview = createView(out);
|
|
7977
|
-
const len = this.outputLen;
|
|
7978
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
7979
|
-
if (len % 4)
|
|
7980
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
7981
|
-
const outLen = len / 4;
|
|
7982
|
-
const state = this.get();
|
|
7983
|
-
if (outLen > state.length)
|
|
7984
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
7985
|
-
for (let i = 0; i < outLen; i++)
|
|
7986
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
7987
|
-
}
|
|
7988
|
-
digest() {
|
|
7989
|
-
const { buffer, outputLen } = this;
|
|
7990
|
-
this.digestInto(buffer);
|
|
7991
|
-
const res = buffer.slice(0, outputLen);
|
|
7992
|
-
this.destroy();
|
|
7993
|
-
return res;
|
|
7994
|
-
}
|
|
7995
|
-
_cloneInto(to) {
|
|
7996
|
-
to || (to = new this.constructor());
|
|
7997
|
-
to.set(...this.get());
|
|
7998
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
7999
|
-
to.length = length;
|
|
8000
|
-
to.pos = pos;
|
|
8001
|
-
to.finished = finished;
|
|
8002
|
-
to.destroyed = destroyed;
|
|
8003
|
-
if (length % blockLen)
|
|
8004
|
-
to.buffer.set(buffer);
|
|
8005
|
-
return to;
|
|
8006
|
-
}
|
|
8007
|
-
}
|
|
8008
|
-
|
|
8009
7819
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
8010
7820
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
8011
|
-
// Choice: a ? b : c
|
|
8012
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
8013
|
-
// Majority function, true if any two inpust is true
|
|
8014
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
8015
7821
|
// Round constants:
|
|
8016
7822
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
8017
7823
|
// prettier-ignore
|
|
8018
|
-
const SHA256_K
|
|
7824
|
+
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
8019
7825
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
8020
7826
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
8021
7827
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -8025,27 +7831,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
8025
7831
|
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
8026
7832
|
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
8027
7833
|
]);
|
|
8028
|
-
// Initial state
|
|
7834
|
+
// Initial state:
|
|
7835
|
+
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
8029
7836
|
// prettier-ignore
|
|
8030
|
-
const
|
|
7837
|
+
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
8031
7838
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
8032
7839
|
]);
|
|
8033
7840
|
// Temporary buffer, not used to store anything between runs
|
|
8034
7841
|
// Named this way because it matches specification.
|
|
8035
|
-
const SHA256_W
|
|
8036
|
-
|
|
7842
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
7843
|
+
class SHA256 extends HashMD {
|
|
8037
7844
|
constructor() {
|
|
8038
7845
|
super(64, 32, 8, false);
|
|
8039
7846
|
// We cannot use array here since array allows indexing by variable
|
|
8040
7847
|
// which means optimizer/compiler cannot use registers.
|
|
8041
|
-
this.A =
|
|
8042
|
-
this.B =
|
|
8043
|
-
this.C =
|
|
8044
|
-
this.D =
|
|
8045
|
-
this.E =
|
|
8046
|
-
this.F =
|
|
8047
|
-
this.G =
|
|
8048
|
-
this.H =
|
|
7848
|
+
this.A = SHA256_IV[0] | 0;
|
|
7849
|
+
this.B = SHA256_IV[1] | 0;
|
|
7850
|
+
this.C = SHA256_IV[2] | 0;
|
|
7851
|
+
this.D = SHA256_IV[3] | 0;
|
|
7852
|
+
this.E = SHA256_IV[4] | 0;
|
|
7853
|
+
this.F = SHA256_IV[5] | 0;
|
|
7854
|
+
this.G = SHA256_IV[6] | 0;
|
|
7855
|
+
this.H = SHA256_IV[7] | 0;
|
|
8049
7856
|
}
|
|
8050
7857
|
get() {
|
|
8051
7858
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -8065,19 +7872,19 @@ var solanaWeb3 = (function (exports) {
|
|
|
8065
7872
|
process(view, offset) {
|
|
8066
7873
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
8067
7874
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
8068
|
-
SHA256_W
|
|
7875
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
8069
7876
|
for (let i = 16; i < 64; i++) {
|
|
8070
|
-
const W15 = SHA256_W
|
|
8071
|
-
const W2 = SHA256_W
|
|
7877
|
+
const W15 = SHA256_W[i - 15];
|
|
7878
|
+
const W2 = SHA256_W[i - 2];
|
|
8072
7879
|
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
8073
7880
|
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
8074
|
-
SHA256_W
|
|
7881
|
+
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
8075
7882
|
}
|
|
8076
7883
|
// Compression function main loop, 64 rounds
|
|
8077
7884
|
let { A, B, C, D, E, F, G, H } = this;
|
|
8078
7885
|
for (let i = 0; i < 64; i++) {
|
|
8079
7886
|
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
8080
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K
|
|
7887
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
8081
7888
|
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
8082
7889
|
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
8083
7890
|
H = G;
|
|
@@ -8101,18 +7908,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
8101
7908
|
this.set(A, B, C, D, E, F, G, H);
|
|
8102
7909
|
}
|
|
8103
7910
|
roundClean() {
|
|
8104
|
-
SHA256_W
|
|
7911
|
+
SHA256_W.fill(0);
|
|
8105
7912
|
}
|
|
8106
7913
|
destroy() {
|
|
8107
7914
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
8108
7915
|
this.buffer.fill(0);
|
|
8109
7916
|
}
|
|
8110
|
-
}
|
|
7917
|
+
}
|
|
8111
7918
|
/**
|
|
8112
7919
|
* SHA2-256 hash function
|
|
8113
7920
|
* @param message - data that would be hashed
|
|
8114
7921
|
*/
|
|
8115
|
-
const sha256
|
|
7922
|
+
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
8116
7923
|
|
|
8117
7924
|
var lib = {};
|
|
8118
7925
|
|
|
@@ -9231,8 +9038,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9231
9038
|
}
|
|
9232
9039
|
const SOLANA_SCHEMA = new Map();
|
|
9233
9040
|
|
|
9234
|
-
var
|
|
9235
|
-
let _Symbol$toStringTag;
|
|
9041
|
+
var _PublicKey;
|
|
9236
9042
|
|
|
9237
9043
|
/**
|
|
9238
9044
|
* Maximum length of derived pubkey seed
|
|
@@ -9262,7 +9068,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
9262
9068
|
/**
|
|
9263
9069
|
* A public key
|
|
9264
9070
|
*/
|
|
9265
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
9266
9071
|
class PublicKey extends Struct$1 {
|
|
9267
9072
|
/**
|
|
9268
9073
|
* Create a new PublicKey object
|
|
@@ -9342,7 +9147,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9342
9147
|
b.copy(zeroPad, 32 - b.length);
|
|
9343
9148
|
return zeroPad;
|
|
9344
9149
|
}
|
|
9345
|
-
get [
|
|
9150
|
+
get [Symbol.toStringTag]() {
|
|
9346
9151
|
return `PublicKey(${this.toString()})`;
|
|
9347
9152
|
}
|
|
9348
9153
|
|
|
@@ -9361,7 +9166,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9361
9166
|
/* eslint-disable require-await */
|
|
9362
9167
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
9363
9168
|
const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
|
|
9364
|
-
const publicKeyBytes = sha256
|
|
9169
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9365
9170
|
return new PublicKey(publicKeyBytes);
|
|
9366
9171
|
}
|
|
9367
9172
|
|
|
@@ -9378,7 +9183,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9378
9183
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
9379
9184
|
});
|
|
9380
9185
|
buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
|
|
9381
|
-
const publicKeyBytes = sha256
|
|
9186
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9382
9187
|
if (isOnCurve(publicKeyBytes)) {
|
|
9383
9188
|
throw new Error(`Invalid seeds, address must fall off the curve`);
|
|
9384
9189
|
}
|
|
@@ -9440,8 +9245,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
9440
9245
|
return isOnCurve(pubkey.toBytes());
|
|
9441
9246
|
}
|
|
9442
9247
|
}
|
|
9443
|
-
|
|
9444
|
-
PublicKey.default = new
|
|
9248
|
+
_PublicKey = PublicKey;
|
|
9249
|
+
PublicKey.default = new _PublicKey('11111111111111111111111111111111');
|
|
9445
9250
|
SOLANA_SCHEMA.set(PublicKey, {
|
|
9446
9251
|
kind: 'struct',
|
|
9447
9252
|
fields: [['_bn', 'u256']]
|
|
@@ -14829,7 +14634,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
14829
14634
|
/**
|
|
14830
14635
|
* A `StructFailure` represents a single specific failure in validation.
|
|
14831
14636
|
*/
|
|
14832
|
-
|
|
14833
14637
|
/**
|
|
14834
14638
|
* `StructError` objects are thrown (or returned) when validation fails.
|
|
14835
14639
|
*
|
|
@@ -14839,190 +14643,160 @@ var solanaWeb3 = (function (exports) {
|
|
|
14839
14643
|
* continue validation and receive all the failures in the data.
|
|
14840
14644
|
*/
|
|
14841
14645
|
class StructError extends TypeError {
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
this.failures = () => {
|
|
14857
|
-
var _cached;
|
|
14858
|
-
|
|
14859
|
-
return (_cached = cached) != null ? _cached : cached = [failure, ...failures()];
|
|
14860
|
-
};
|
|
14861
|
-
}
|
|
14862
|
-
|
|
14646
|
+
constructor(failure, failures) {
|
|
14647
|
+
let cached;
|
|
14648
|
+
const { message, explanation, ...rest } = failure;
|
|
14649
|
+
const { path } = failure;
|
|
14650
|
+
const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`;
|
|
14651
|
+
super(explanation ?? msg);
|
|
14652
|
+
if (explanation != null)
|
|
14653
|
+
this.cause = msg;
|
|
14654
|
+
Object.assign(this, rest);
|
|
14655
|
+
this.name = this.constructor.name;
|
|
14656
|
+
this.failures = () => {
|
|
14657
|
+
return (cached ?? (cached = [failure, ...failures()]));
|
|
14658
|
+
};
|
|
14659
|
+
}
|
|
14863
14660
|
}
|
|
14864
14661
|
|
|
14865
14662
|
/**
|
|
14866
14663
|
* Check if a value is an iterator.
|
|
14867
14664
|
*/
|
|
14868
14665
|
function isIterable(x) {
|
|
14869
|
-
|
|
14666
|
+
return isObject(x) && typeof x[Symbol.iterator] === 'function';
|
|
14870
14667
|
}
|
|
14871
14668
|
/**
|
|
14872
14669
|
* Check if a value is a plain object.
|
|
14873
14670
|
*/
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
14671
|
function isObject(x) {
|
|
14877
|
-
|
|
14672
|
+
return typeof x === 'object' && x != null;
|
|
14878
14673
|
}
|
|
14879
14674
|
/**
|
|
14880
14675
|
* Return a value as a printable string.
|
|
14881
14676
|
*/
|
|
14882
|
-
|
|
14883
14677
|
function print(value) {
|
|
14884
|
-
|
|
14678
|
+
if (typeof value === 'symbol') {
|
|
14679
|
+
return value.toString();
|
|
14680
|
+
}
|
|
14681
|
+
return typeof value === 'string' ? JSON.stringify(value) : `${value}`;
|
|
14885
14682
|
}
|
|
14886
14683
|
/**
|
|
14887
14684
|
* Shifts (removes and returns) the first value from the `input` iterator.
|
|
14888
14685
|
* Like `Array.prototype.shift()` but for an `Iterator`.
|
|
14889
14686
|
*/
|
|
14890
|
-
|
|
14891
14687
|
function shiftIterator(input) {
|
|
14892
|
-
|
|
14893
|
-
done
|
|
14894
|
-
value
|
|
14895
|
-
} = input.next();
|
|
14896
|
-
return done ? undefined : value;
|
|
14688
|
+
const { done, value } = input.next();
|
|
14689
|
+
return done ? undefined : value;
|
|
14897
14690
|
}
|
|
14898
14691
|
/**
|
|
14899
14692
|
* Convert a single validation result to a failure.
|
|
14900
14693
|
*/
|
|
14901
|
-
|
|
14902
14694
|
function toFailure(result, context, struct, value) {
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
result
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14695
|
+
if (result === true) {
|
|
14696
|
+
return;
|
|
14697
|
+
}
|
|
14698
|
+
else if (result === false) {
|
|
14699
|
+
result = {};
|
|
14700
|
+
}
|
|
14701
|
+
else if (typeof result === 'string') {
|
|
14702
|
+
result = { message: result };
|
|
14703
|
+
}
|
|
14704
|
+
const { path, branch } = context;
|
|
14705
|
+
const { type } = struct;
|
|
14706
|
+
const { refinement, message = `Expected a value of type \`${type}\`${refinement ? ` with refinement \`${refinement}\`` : ''}, but received: \`${print(value)}\``, } = result;
|
|
14707
|
+
return {
|
|
14708
|
+
value,
|
|
14709
|
+
type,
|
|
14710
|
+
refinement,
|
|
14711
|
+
key: path[path.length - 1],
|
|
14712
|
+
path,
|
|
14713
|
+
branch,
|
|
14714
|
+
...result,
|
|
14715
|
+
message,
|
|
14910
14716
|
};
|
|
14911
|
-
}
|
|
14912
|
-
|
|
14913
|
-
const {
|
|
14914
|
-
path,
|
|
14915
|
-
branch
|
|
14916
|
-
} = context;
|
|
14917
|
-
const {
|
|
14918
|
-
type
|
|
14919
|
-
} = struct;
|
|
14920
|
-
const {
|
|
14921
|
-
refinement,
|
|
14922
|
-
message = "Expected a value of type `" + type + "`" + (refinement ? " with refinement `" + refinement + "`" : '') + ", but received: `" + print(value) + "`"
|
|
14923
|
-
} = result;
|
|
14924
|
-
return {
|
|
14925
|
-
value,
|
|
14926
|
-
type,
|
|
14927
|
-
refinement,
|
|
14928
|
-
key: path[path.length - 1],
|
|
14929
|
-
path,
|
|
14930
|
-
branch,
|
|
14931
|
-
...result,
|
|
14932
|
-
message
|
|
14933
|
-
};
|
|
14934
14717
|
}
|
|
14935
14718
|
/**
|
|
14936
14719
|
* Convert a validation result to an iterable of failures.
|
|
14937
14720
|
*/
|
|
14938
|
-
|
|
14939
14721
|
function* toFailures(result, context, struct, value) {
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
yield failure;
|
|
14722
|
+
if (!isIterable(result)) {
|
|
14723
|
+
result = [result];
|
|
14724
|
+
}
|
|
14725
|
+
for (const r of result) {
|
|
14726
|
+
const failure = toFailure(r, context, struct, value);
|
|
14727
|
+
if (failure) {
|
|
14728
|
+
yield failure;
|
|
14729
|
+
}
|
|
14949
14730
|
}
|
|
14950
|
-
}
|
|
14951
14731
|
}
|
|
14952
14732
|
/**
|
|
14953
14733
|
* Check a value against a struct, traversing deeply into nested values, and
|
|
14954
14734
|
* returning an iterator of failures or success.
|
|
14955
14735
|
*/
|
|
14956
|
-
|
|
14957
14736
|
function* run(value, struct, options = {}) {
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
if (mask && struct.type !== 'type' && isObject(struct.schema) && isObject(value) && !Array.isArray(value)) {
|
|
14973
|
-
for (const key in value) {
|
|
14974
|
-
if (struct.schema[key] === undefined) {
|
|
14975
|
-
delete value[key];
|
|
14737
|
+
const { path = [], branch = [value], coerce = false, mask = false } = options;
|
|
14738
|
+
const ctx = { path, branch };
|
|
14739
|
+
if (coerce) {
|
|
14740
|
+
value = struct.coercer(value, ctx);
|
|
14741
|
+
if (mask &&
|
|
14742
|
+
struct.type !== 'type' &&
|
|
14743
|
+
isObject(struct.schema) &&
|
|
14744
|
+
isObject(value) &&
|
|
14745
|
+
!Array.isArray(value)) {
|
|
14746
|
+
for (const key in value) {
|
|
14747
|
+
if (struct.schema[key] === undefined) {
|
|
14748
|
+
delete value[key];
|
|
14749
|
+
}
|
|
14750
|
+
}
|
|
14976
14751
|
}
|
|
14977
|
-
}
|
|
14978
14752
|
}
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15008
|
-
|
|
15009
|
-
|
|
15010
|
-
|
|
14753
|
+
let status = 'valid';
|
|
14754
|
+
for (const failure of struct.validator(value, ctx)) {
|
|
14755
|
+
failure.explanation = options.message;
|
|
14756
|
+
status = 'not_valid';
|
|
14757
|
+
yield [failure, undefined];
|
|
14758
|
+
}
|
|
14759
|
+
for (let [k, v, s] of struct.entries(value, ctx)) {
|
|
14760
|
+
const ts = run(v, s, {
|
|
14761
|
+
path: k === undefined ? path : [...path, k],
|
|
14762
|
+
branch: k === undefined ? branch : [...branch, v],
|
|
14763
|
+
coerce,
|
|
14764
|
+
mask,
|
|
14765
|
+
message: options.message,
|
|
14766
|
+
});
|
|
14767
|
+
for (const t of ts) {
|
|
14768
|
+
if (t[0]) {
|
|
14769
|
+
status = t[0].refinement != null ? 'not_refined' : 'not_valid';
|
|
14770
|
+
yield [t[0], undefined];
|
|
14771
|
+
}
|
|
14772
|
+
else if (coerce) {
|
|
14773
|
+
v = t[1];
|
|
14774
|
+
if (k === undefined) {
|
|
14775
|
+
value = v;
|
|
14776
|
+
}
|
|
14777
|
+
else if (value instanceof Map) {
|
|
14778
|
+
value.set(k, v);
|
|
14779
|
+
}
|
|
14780
|
+
else if (value instanceof Set) {
|
|
14781
|
+
value.add(v);
|
|
14782
|
+
}
|
|
14783
|
+
else if (isObject(value)) {
|
|
14784
|
+
if (v !== undefined || k in value)
|
|
14785
|
+
value[k] = v;
|
|
14786
|
+
}
|
|
14787
|
+
}
|
|
15011
14788
|
}
|
|
15012
|
-
}
|
|
15013
14789
|
}
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
14790
|
+
if (status !== 'not_valid') {
|
|
14791
|
+
for (const failure of struct.refiner(value, ctx)) {
|
|
14792
|
+
failure.explanation = options.message;
|
|
14793
|
+
status = 'not_refined';
|
|
14794
|
+
yield [failure, undefined];
|
|
14795
|
+
}
|
|
14796
|
+
}
|
|
14797
|
+
if (status === 'valid') {
|
|
14798
|
+
yield [undefined, value];
|
|
15020
14799
|
}
|
|
15021
|
-
}
|
|
15022
|
-
|
|
15023
|
-
if (valid) {
|
|
15024
|
-
yield [undefined, value];
|
|
15025
|
-
}
|
|
15026
14800
|
}
|
|
15027
14801
|
|
|
15028
14802
|
/**
|
|
@@ -15030,269 +14804,227 @@ var solanaWeb3 = (function (exports) {
|
|
|
15030
14804
|
* values. Once constructed, you use the `assert`, `is` or `validate` helpers to
|
|
15031
14805
|
* validate unknown input data against the struct.
|
|
15032
14806
|
*/
|
|
15033
|
-
|
|
15034
14807
|
class Struct {
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
14808
|
+
constructor(props) {
|
|
14809
|
+
const { type, schema, validator, refiner, coercer = (value) => value, entries = function* () { }, } = props;
|
|
14810
|
+
this.type = type;
|
|
14811
|
+
this.schema = schema;
|
|
14812
|
+
this.entries = entries;
|
|
14813
|
+
this.coercer = coercer;
|
|
14814
|
+
if (validator) {
|
|
14815
|
+
this.validator = (value, context) => {
|
|
14816
|
+
const result = validator(value, context);
|
|
14817
|
+
return toFailures(result, context, this, value);
|
|
14818
|
+
};
|
|
14819
|
+
}
|
|
14820
|
+
else {
|
|
14821
|
+
this.validator = () => [];
|
|
14822
|
+
}
|
|
14823
|
+
if (refiner) {
|
|
14824
|
+
this.refiner = (value, context) => {
|
|
14825
|
+
const result = refiner(value, context);
|
|
14826
|
+
return toFailures(result, context, this, value);
|
|
14827
|
+
};
|
|
14828
|
+
}
|
|
14829
|
+
else {
|
|
14830
|
+
this.refiner = () => [];
|
|
14831
|
+
}
|
|
15056
14832
|
}
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
return
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
14833
|
+
/**
|
|
14834
|
+
* Assert that a value passes the struct's validation, throwing if it doesn't.
|
|
14835
|
+
*/
|
|
14836
|
+
assert(value, message) {
|
|
14837
|
+
return assert(value, this, message);
|
|
14838
|
+
}
|
|
14839
|
+
/**
|
|
14840
|
+
* Create a value with the struct's coercion logic, then validate it.
|
|
14841
|
+
*/
|
|
14842
|
+
create(value, message) {
|
|
14843
|
+
return create(value, this, message);
|
|
14844
|
+
}
|
|
14845
|
+
/**
|
|
14846
|
+
* Check if a value passes the struct's validation.
|
|
14847
|
+
*/
|
|
14848
|
+
is(value) {
|
|
14849
|
+
return is(value, this);
|
|
14850
|
+
}
|
|
14851
|
+
/**
|
|
14852
|
+
* Mask a value, coercing and validating it, but returning only the subset of
|
|
14853
|
+
* properties defined by the struct's schema.
|
|
14854
|
+
*/
|
|
14855
|
+
mask(value, message) {
|
|
14856
|
+
return mask(value, this, message);
|
|
14857
|
+
}
|
|
14858
|
+
/**
|
|
14859
|
+
* Validate a value with the struct's validation logic, returning a tuple
|
|
14860
|
+
* representing the result.
|
|
14861
|
+
*
|
|
14862
|
+
* You may optionally pass `true` for the `withCoercion` argument to coerce
|
|
14863
|
+
* the value before attempting to validate it. If you do, the result will
|
|
14864
|
+
* contain the coerced result when successful.
|
|
14865
|
+
*/
|
|
14866
|
+
validate(value, options = {}) {
|
|
14867
|
+
return validate$1(value, this, options);
|
|
15065
14868
|
}
|
|
15066
|
-
}
|
|
15067
|
-
/**
|
|
15068
|
-
* Assert that a value passes the struct's validation, throwing if it doesn't.
|
|
15069
|
-
*/
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
assert(value) {
|
|
15073
|
-
return assert(value, this);
|
|
15074
|
-
}
|
|
15075
|
-
/**
|
|
15076
|
-
* Create a value with the struct's coercion logic, then validate it.
|
|
15077
|
-
*/
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
create(value) {
|
|
15081
|
-
return create(value, this);
|
|
15082
|
-
}
|
|
15083
|
-
/**
|
|
15084
|
-
* Check if a value passes the struct's validation.
|
|
15085
|
-
*/
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
is(value) {
|
|
15089
|
-
return is(value, this);
|
|
15090
|
-
}
|
|
15091
|
-
/**
|
|
15092
|
-
* Mask a value, coercing and validating it, but returning only the subset of
|
|
15093
|
-
* properties defined by the struct's schema.
|
|
15094
|
-
*/
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
mask(value) {
|
|
15098
|
-
return mask(value, this);
|
|
15099
|
-
}
|
|
15100
|
-
/**
|
|
15101
|
-
* Validate a value with the struct's validation logic, returning a tuple
|
|
15102
|
-
* representing the result.
|
|
15103
|
-
*
|
|
15104
|
-
* You may optionally pass `true` for the `withCoercion` argument to coerce
|
|
15105
|
-
* the value before attempting to validate it. If you do, the result will
|
|
15106
|
-
* contain the coerced result when successful.
|
|
15107
|
-
*/
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
validate(value, options = {}) {
|
|
15111
|
-
return validate$1(value, this, options);
|
|
15112
|
-
}
|
|
15113
|
-
|
|
15114
14869
|
}
|
|
15115
14870
|
/**
|
|
15116
14871
|
* Assert that a value passes a struct, throwing if it doesn't.
|
|
15117
14872
|
*/
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
throw result[0];
|
|
15124
|
-
}
|
|
14873
|
+
function assert(value, struct, message) {
|
|
14874
|
+
const result = validate$1(value, struct, { message });
|
|
14875
|
+
if (result[0]) {
|
|
14876
|
+
throw result[0];
|
|
14877
|
+
}
|
|
15125
14878
|
}
|
|
15126
14879
|
/**
|
|
15127
14880
|
* Create a value with the coercion logic of struct and validate it.
|
|
15128
14881
|
*/
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
} else {
|
|
15138
|
-
return result[1];
|
|
15139
|
-
}
|
|
14882
|
+
function create(value, struct, message) {
|
|
14883
|
+
const result = validate$1(value, struct, { coerce: true, message });
|
|
14884
|
+
if (result[0]) {
|
|
14885
|
+
throw result[0];
|
|
14886
|
+
}
|
|
14887
|
+
else {
|
|
14888
|
+
return result[1];
|
|
14889
|
+
}
|
|
15140
14890
|
}
|
|
15141
14891
|
/**
|
|
15142
14892
|
* Mask a value, returning only the subset of properties defined by a struct.
|
|
15143
14893
|
*/
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
throw result[0];
|
|
15153
|
-
} else {
|
|
15154
|
-
return result[1];
|
|
15155
|
-
}
|
|
14894
|
+
function mask(value, struct, message) {
|
|
14895
|
+
const result = validate$1(value, struct, { coerce: true, mask: true, message });
|
|
14896
|
+
if (result[0]) {
|
|
14897
|
+
throw result[0];
|
|
14898
|
+
}
|
|
14899
|
+
else {
|
|
14900
|
+
return result[1];
|
|
14901
|
+
}
|
|
15156
14902
|
}
|
|
15157
14903
|
/**
|
|
15158
14904
|
* Check if a value passes a struct.
|
|
15159
14905
|
*/
|
|
15160
|
-
|
|
15161
14906
|
function is(value, struct) {
|
|
15162
|
-
|
|
15163
|
-
|
|
14907
|
+
const result = validate$1(value, struct);
|
|
14908
|
+
return !result[0];
|
|
15164
14909
|
}
|
|
15165
14910
|
/**
|
|
15166
14911
|
* Validate a value against a struct, returning an error if invalid, or the
|
|
15167
14912
|
* value (with potential coercion) if valid.
|
|
15168
14913
|
*/
|
|
15169
|
-
|
|
15170
14914
|
function validate$1(value, struct, options = {}) {
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
14915
|
+
const tuples = run(value, struct, options);
|
|
14916
|
+
const tuple = shiftIterator(tuples);
|
|
14917
|
+
if (tuple[0]) {
|
|
14918
|
+
const error = new StructError(tuple[0], function* () {
|
|
14919
|
+
for (const t of tuples) {
|
|
14920
|
+
if (t[0]) {
|
|
14921
|
+
yield t[0];
|
|
14922
|
+
}
|
|
14923
|
+
}
|
|
14924
|
+
});
|
|
14925
|
+
return [error, undefined];
|
|
14926
|
+
}
|
|
14927
|
+
else {
|
|
14928
|
+
const v = tuple[1];
|
|
14929
|
+
return [undefined, v];
|
|
14930
|
+
}
|
|
15187
14931
|
}
|
|
15188
14932
|
/**
|
|
15189
14933
|
* Define a new struct type with a custom validation function.
|
|
15190
14934
|
*/
|
|
15191
|
-
|
|
15192
14935
|
function define(name, validator) {
|
|
15193
|
-
|
|
15194
|
-
type: name,
|
|
15195
|
-
schema: null,
|
|
15196
|
-
validator
|
|
15197
|
-
});
|
|
14936
|
+
return new Struct({ type: name, schema: null, validator });
|
|
15198
14937
|
}
|
|
15199
14938
|
|
|
15200
14939
|
/**
|
|
15201
14940
|
* Ensure that any value passes validation.
|
|
15202
14941
|
*/
|
|
15203
|
-
|
|
15204
14942
|
function any() {
|
|
15205
|
-
|
|
14943
|
+
return define('any', () => true);
|
|
15206
14944
|
}
|
|
15207
14945
|
function array(Element) {
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
}
|
|
15227
|
-
|
|
15228
|
-
});
|
|
14946
|
+
return new Struct({
|
|
14947
|
+
type: 'array',
|
|
14948
|
+
schema: Element,
|
|
14949
|
+
*entries(value) {
|
|
14950
|
+
if (Element && Array.isArray(value)) {
|
|
14951
|
+
for (const [i, v] of value.entries()) {
|
|
14952
|
+
yield [i, v, Element];
|
|
14953
|
+
}
|
|
14954
|
+
}
|
|
14955
|
+
},
|
|
14956
|
+
coercer(value) {
|
|
14957
|
+
return Array.isArray(value) ? value.slice() : value;
|
|
14958
|
+
},
|
|
14959
|
+
validator(value) {
|
|
14960
|
+
return (Array.isArray(value) ||
|
|
14961
|
+
`Expected an array value, but received: ${print(value)}`);
|
|
14962
|
+
},
|
|
14963
|
+
});
|
|
15229
14964
|
}
|
|
15230
14965
|
/**
|
|
15231
14966
|
* Ensure that a value is a boolean.
|
|
15232
14967
|
*/
|
|
15233
|
-
|
|
15234
14968
|
function boolean() {
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
14969
|
+
return define('boolean', (value) => {
|
|
14970
|
+
return typeof value === 'boolean';
|
|
14971
|
+
});
|
|
15238
14972
|
}
|
|
15239
14973
|
/**
|
|
15240
14974
|
* Ensure that a value is an instance of a specific class.
|
|
15241
14975
|
*/
|
|
15242
|
-
|
|
15243
14976
|
function instance(Class) {
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
14977
|
+
return define('instance', (value) => {
|
|
14978
|
+
return (value instanceof Class ||
|
|
14979
|
+
`Expected a \`${Class.name}\` instance, but received: ${print(value)}`);
|
|
14980
|
+
});
|
|
15247
14981
|
}
|
|
15248
14982
|
function literal(constant) {
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
});
|
|
14983
|
+
const description = print(constant);
|
|
14984
|
+
const t = typeof constant;
|
|
14985
|
+
return new Struct({
|
|
14986
|
+
type: 'literal',
|
|
14987
|
+
schema: t === 'string' || t === 'number' || t === 'boolean' ? constant : null,
|
|
14988
|
+
validator(value) {
|
|
14989
|
+
return (value === constant ||
|
|
14990
|
+
`Expected the literal \`${description}\`, but received: ${print(value)}`);
|
|
14991
|
+
},
|
|
14992
|
+
});
|
|
15260
14993
|
}
|
|
15261
14994
|
/**
|
|
15262
14995
|
* Ensure that no value ever passes validation.
|
|
15263
14996
|
*/
|
|
15264
|
-
|
|
15265
14997
|
function never() {
|
|
15266
|
-
|
|
14998
|
+
return define('never', () => false);
|
|
15267
14999
|
}
|
|
15268
15000
|
/**
|
|
15269
15001
|
* Augment an existing struct to allow `null` values.
|
|
15270
15002
|
*/
|
|
15271
|
-
|
|
15272
15003
|
function nullable(struct) {
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15004
|
+
return new Struct({
|
|
15005
|
+
...struct,
|
|
15006
|
+
validator: (value, ctx) => value === null || struct.validator(value, ctx),
|
|
15007
|
+
refiner: (value, ctx) => value === null || struct.refiner(value, ctx),
|
|
15008
|
+
});
|
|
15277
15009
|
}
|
|
15278
15010
|
/**
|
|
15279
15011
|
* Ensure that a value is a number.
|
|
15280
15012
|
*/
|
|
15281
|
-
|
|
15282
15013
|
function number() {
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15014
|
+
return define('number', (value) => {
|
|
15015
|
+
return ((typeof value === 'number' && !isNaN(value)) ||
|
|
15016
|
+
`Expected a number, but received: ${print(value)}`);
|
|
15017
|
+
});
|
|
15286
15018
|
}
|
|
15287
15019
|
/**
|
|
15288
15020
|
* Augment a struct to allow `undefined` values.
|
|
15289
15021
|
*/
|
|
15290
|
-
|
|
15291
15022
|
function optional(struct) {
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15023
|
+
return new Struct({
|
|
15024
|
+
...struct,
|
|
15025
|
+
validator: (value, ctx) => value === undefined || struct.validator(value, ctx),
|
|
15026
|
+
refiner: (value, ctx) => value === undefined || struct.refiner(value, ctx),
|
|
15027
|
+
});
|
|
15296
15028
|
}
|
|
15297
15029
|
/**
|
|
15298
15030
|
* Ensure that a value is an object with keys and values of specific types, but
|
|
@@ -15300,58 +15032,55 @@ var solanaWeb3 = (function (exports) {
|
|
|
15300
15032
|
*
|
|
15301
15033
|
* Like TypeScript's `Record` utility.
|
|
15302
15034
|
*/
|
|
15303
|
-
|
|
15304
15035
|
function record(Key, Value) {
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
}
|
|
15322
|
-
|
|
15323
|
-
});
|
|
15036
|
+
return new Struct({
|
|
15037
|
+
type: 'record',
|
|
15038
|
+
schema: null,
|
|
15039
|
+
*entries(value) {
|
|
15040
|
+
if (isObject(value)) {
|
|
15041
|
+
for (const k in value) {
|
|
15042
|
+
const v = value[k];
|
|
15043
|
+
yield [k, k, Key];
|
|
15044
|
+
yield [k, v, Value];
|
|
15045
|
+
}
|
|
15046
|
+
}
|
|
15047
|
+
},
|
|
15048
|
+
validator(value) {
|
|
15049
|
+
return (isObject(value) || `Expected an object, but received: ${print(value)}`);
|
|
15050
|
+
},
|
|
15051
|
+
});
|
|
15324
15052
|
}
|
|
15325
15053
|
/**
|
|
15326
15054
|
* Ensure that a value is a string.
|
|
15327
15055
|
*/
|
|
15328
|
-
|
|
15329
15056
|
function string() {
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15057
|
+
return define('string', (value) => {
|
|
15058
|
+
return (typeof value === 'string' ||
|
|
15059
|
+
`Expected a string, but received: ${print(value)}`);
|
|
15060
|
+
});
|
|
15333
15061
|
}
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
|
|
15062
|
+
/**
|
|
15063
|
+
* Ensure that a value is a tuple of a specific length, and that each of its
|
|
15064
|
+
* elements is of a specific type.
|
|
15065
|
+
*/
|
|
15066
|
+
function tuple(Structs) {
|
|
15067
|
+
const Never = never();
|
|
15068
|
+
return new Struct({
|
|
15069
|
+
type: 'tuple',
|
|
15070
|
+
schema: null,
|
|
15071
|
+
*entries(value) {
|
|
15072
|
+
if (Array.isArray(value)) {
|
|
15073
|
+
const length = Math.max(Structs.length, value.length);
|
|
15074
|
+
for (let i = 0; i < length; i++) {
|
|
15075
|
+
yield [i, value[i], Structs[i] || Never];
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15078
|
+
},
|
|
15079
|
+
validator(value) {
|
|
15080
|
+
return (Array.isArray(value) ||
|
|
15081
|
+
`Expected an array, but received: ${print(value)}`);
|
|
15082
|
+
},
|
|
15083
|
+
});
|
|
15355
15084
|
}
|
|
15356
15085
|
/**
|
|
15357
15086
|
* Ensure that a value has a set of known properties of specific types.
|
|
@@ -15359,62 +15088,71 @@ var solanaWeb3 = (function (exports) {
|
|
|
15359
15088
|
* Note: Unrecognized properties are allowed and untouched. This is similar to
|
|
15360
15089
|
* how TypeScript's structural typing works.
|
|
15361
15090
|
*/
|
|
15362
|
-
|
|
15363
15091
|
function type(schema) {
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15092
|
+
const keys = Object.keys(schema);
|
|
15093
|
+
return new Struct({
|
|
15094
|
+
type: 'type',
|
|
15095
|
+
schema,
|
|
15096
|
+
*entries(value) {
|
|
15097
|
+
if (isObject(value)) {
|
|
15098
|
+
for (const k of keys) {
|
|
15099
|
+
yield [k, value[k], schema[k]];
|
|
15100
|
+
}
|
|
15101
|
+
}
|
|
15102
|
+
},
|
|
15103
|
+
validator(value) {
|
|
15104
|
+
return (isObject(value) || `Expected an object, but received: ${print(value)}`);
|
|
15105
|
+
},
|
|
15106
|
+
coercer(value) {
|
|
15107
|
+
return isObject(value) ? { ...value } : value;
|
|
15108
|
+
},
|
|
15109
|
+
});
|
|
15382
15110
|
}
|
|
15111
|
+
/**
|
|
15112
|
+
* Ensure that a value matches one of a set of types.
|
|
15113
|
+
*/
|
|
15383
15114
|
function union(Structs) {
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
const [first] = tuples;
|
|
15395
|
-
|
|
15396
|
-
if (!first[0]) {
|
|
15397
|
-
return [];
|
|
15398
|
-
} else {
|
|
15399
|
-
for (const [failure] of tuples) {
|
|
15400
|
-
if (failure) {
|
|
15401
|
-
failures.push(failure);
|
|
15115
|
+
const description = Structs.map((s) => s.type).join(' | ');
|
|
15116
|
+
return new Struct({
|
|
15117
|
+
type: 'union',
|
|
15118
|
+
schema: null,
|
|
15119
|
+
coercer(value) {
|
|
15120
|
+
for (const S of Structs) {
|
|
15121
|
+
const [error, coerced] = S.validate(value, { coerce: true });
|
|
15122
|
+
if (!error) {
|
|
15123
|
+
return coerced;
|
|
15124
|
+
}
|
|
15402
15125
|
}
|
|
15403
|
-
|
|
15404
|
-
}
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15408
|
-
|
|
15409
|
-
|
|
15410
|
-
|
|
15126
|
+
return value;
|
|
15127
|
+
},
|
|
15128
|
+
validator(value, ctx) {
|
|
15129
|
+
const failures = [];
|
|
15130
|
+
for (const S of Structs) {
|
|
15131
|
+
const [...tuples] = run(value, S, ctx);
|
|
15132
|
+
const [first] = tuples;
|
|
15133
|
+
if (!first[0]) {
|
|
15134
|
+
return [];
|
|
15135
|
+
}
|
|
15136
|
+
else {
|
|
15137
|
+
for (const [failure] of tuples) {
|
|
15138
|
+
if (failure) {
|
|
15139
|
+
failures.push(failure);
|
|
15140
|
+
}
|
|
15141
|
+
}
|
|
15142
|
+
}
|
|
15143
|
+
}
|
|
15144
|
+
return [
|
|
15145
|
+
`Expected the value to satisfy a union of \`${description}\`, but received: ${print(value)}`,
|
|
15146
|
+
...failures,
|
|
15147
|
+
];
|
|
15148
|
+
},
|
|
15149
|
+
});
|
|
15411
15150
|
}
|
|
15412
15151
|
/**
|
|
15413
15152
|
* Ensure that any value passes validation, without widening its type to `any`.
|
|
15414
15153
|
*/
|
|
15415
|
-
|
|
15416
15154
|
function unknown() {
|
|
15417
|
-
|
|
15155
|
+
return define('unknown', () => true);
|
|
15418
15156
|
}
|
|
15419
15157
|
|
|
15420
15158
|
/**
|
|
@@ -15427,13 +15165,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
15427
15165
|
* Note: You must use `create(value, Struct)` on the value to have the coercion
|
|
15428
15166
|
* take effect! Using simply `assert()` or `is()` will not use coercion.
|
|
15429
15167
|
*/
|
|
15430
|
-
|
|
15431
15168
|
function coerce(struct, condition, coercer) {
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15169
|
+
return new Struct({
|
|
15170
|
+
...struct,
|
|
15171
|
+
coercer: (value, ctx) => {
|
|
15172
|
+
return is(value, condition)
|
|
15173
|
+
? struct.coercer(coercer(value, ctx), ctx)
|
|
15174
|
+
: struct.coercer(value, ctx);
|
|
15175
|
+
},
|
|
15176
|
+
});
|
|
15437
15177
|
}
|
|
15438
15178
|
|
|
15439
15179
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
@@ -16393,1593 +16133,771 @@ var solanaWeb3 = (function (exports) {
|
|
|
16393
16133
|
|
|
16394
16134
|
var client = {};
|
|
16395
16135
|
|
|
16396
|
-
var
|
|
16136
|
+
var eventemitter3 = {exports: {}};
|
|
16397
16137
|
|
|
16398
16138
|
(function (module) {
|
|
16399
|
-
function _interopRequireDefault(obj) {
|
|
16400
|
-
return obj && obj.__esModule ? obj : {
|
|
16401
|
-
"default": obj
|
|
16402
|
-
};
|
|
16403
|
-
}
|
|
16404
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16405
|
-
} (interopRequireDefault));
|
|
16406
|
-
|
|
16407
|
-
var interopRequireDefaultExports = interopRequireDefault.exports;
|
|
16408
|
-
|
|
16409
|
-
var regeneratorRuntime$1 = {exports: {}};
|
|
16410
|
-
|
|
16411
|
-
var _typeof = {exports: {}};
|
|
16412
16139
|
|
|
16413
|
-
|
|
16140
|
+
var has = Object.prototype.hasOwnProperty
|
|
16141
|
+
, prefix = '~';
|
|
16414
16142
|
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
return typeof o;
|
|
16424
|
-
} : function (o) {
|
|
16425
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
16426
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
16427
|
-
}
|
|
16428
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16429
|
-
} (_typeof));
|
|
16430
|
-
return _typeof.exports;
|
|
16431
|
-
}
|
|
16432
|
-
|
|
16433
|
-
var hasRequiredRegeneratorRuntime;
|
|
16434
|
-
|
|
16435
|
-
function requireRegeneratorRuntime () {
|
|
16436
|
-
if (hasRequiredRegeneratorRuntime) return regeneratorRuntime$1.exports;
|
|
16437
|
-
hasRequiredRegeneratorRuntime = 1;
|
|
16438
|
-
(function (module) {
|
|
16439
|
-
var _typeof = require_typeof()["default"];
|
|
16440
|
-
function _regeneratorRuntime() {
|
|
16441
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
16442
|
-
return e;
|
|
16443
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16444
|
-
var t,
|
|
16445
|
-
e = {},
|
|
16446
|
-
r = Object.prototype,
|
|
16447
|
-
n = r.hasOwnProperty,
|
|
16448
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
16449
|
-
t[e] = r.value;
|
|
16450
|
-
},
|
|
16451
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
16452
|
-
a = i.iterator || "@@iterator",
|
|
16453
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
16454
|
-
u = i.toStringTag || "@@toStringTag";
|
|
16455
|
-
function define(t, e, r) {
|
|
16456
|
-
return Object.defineProperty(t, e, {
|
|
16457
|
-
value: r,
|
|
16458
|
-
enumerable: !0,
|
|
16459
|
-
configurable: !0,
|
|
16460
|
-
writable: !0
|
|
16461
|
-
}), t[e];
|
|
16462
|
-
}
|
|
16463
|
-
try {
|
|
16464
|
-
define({}, "");
|
|
16465
|
-
} catch (t) {
|
|
16466
|
-
define = function define(t, e, r) {
|
|
16467
|
-
return t[e] = r;
|
|
16468
|
-
};
|
|
16469
|
-
}
|
|
16470
|
-
function wrap(t, e, r, n) {
|
|
16471
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
16472
|
-
a = Object.create(i.prototype),
|
|
16473
|
-
c = new Context(n || []);
|
|
16474
|
-
return o(a, "_invoke", {
|
|
16475
|
-
value: makeInvokeMethod(t, r, c)
|
|
16476
|
-
}), a;
|
|
16477
|
-
}
|
|
16478
|
-
function tryCatch(t, e, r) {
|
|
16479
|
-
try {
|
|
16480
|
-
return {
|
|
16481
|
-
type: "normal",
|
|
16482
|
-
arg: t.call(e, r)
|
|
16483
|
-
};
|
|
16484
|
-
} catch (t) {
|
|
16485
|
-
return {
|
|
16486
|
-
type: "throw",
|
|
16487
|
-
arg: t
|
|
16488
|
-
};
|
|
16489
|
-
}
|
|
16490
|
-
}
|
|
16491
|
-
e.wrap = wrap;
|
|
16492
|
-
var h = "suspendedStart",
|
|
16493
|
-
l = "suspendedYield",
|
|
16494
|
-
f = "executing",
|
|
16495
|
-
s = "completed",
|
|
16496
|
-
y = {};
|
|
16497
|
-
function Generator() {}
|
|
16498
|
-
function GeneratorFunction() {}
|
|
16499
|
-
function GeneratorFunctionPrototype() {}
|
|
16500
|
-
var p = {};
|
|
16501
|
-
define(p, a, function () {
|
|
16502
|
-
return this;
|
|
16503
|
-
});
|
|
16504
|
-
var d = Object.getPrototypeOf,
|
|
16505
|
-
v = d && d(d(values([])));
|
|
16506
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
16507
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
16508
|
-
function defineIteratorMethods(t) {
|
|
16509
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
16510
|
-
define(t, e, function (t) {
|
|
16511
|
-
return this._invoke(e, t);
|
|
16512
|
-
});
|
|
16513
|
-
});
|
|
16514
|
-
}
|
|
16515
|
-
function AsyncIterator(t, e) {
|
|
16516
|
-
function invoke(r, o, i, a) {
|
|
16517
|
-
var c = tryCatch(t[r], t, o);
|
|
16518
|
-
if ("throw" !== c.type) {
|
|
16519
|
-
var u = c.arg,
|
|
16520
|
-
h = u.value;
|
|
16521
|
-
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
16522
|
-
invoke("next", t, i, a);
|
|
16523
|
-
}, function (t) {
|
|
16524
|
-
invoke("throw", t, i, a);
|
|
16525
|
-
}) : e.resolve(h).then(function (t) {
|
|
16526
|
-
u.value = t, i(u);
|
|
16527
|
-
}, function (t) {
|
|
16528
|
-
return invoke("throw", t, i, a);
|
|
16529
|
-
});
|
|
16530
|
-
}
|
|
16531
|
-
a(c.arg);
|
|
16532
|
-
}
|
|
16533
|
-
var r;
|
|
16534
|
-
o(this, "_invoke", {
|
|
16535
|
-
value: function value(t, n) {
|
|
16536
|
-
function callInvokeWithMethodAndArg() {
|
|
16537
|
-
return new e(function (e, r) {
|
|
16538
|
-
invoke(t, n, e, r);
|
|
16539
|
-
});
|
|
16540
|
-
}
|
|
16541
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
16542
|
-
}
|
|
16543
|
-
});
|
|
16544
|
-
}
|
|
16545
|
-
function makeInvokeMethod(e, r, n) {
|
|
16546
|
-
var o = h;
|
|
16547
|
-
return function (i, a) {
|
|
16548
|
-
if (o === f) throw new Error("Generator is already running");
|
|
16549
|
-
if (o === s) {
|
|
16550
|
-
if ("throw" === i) throw a;
|
|
16551
|
-
return {
|
|
16552
|
-
value: t,
|
|
16553
|
-
done: !0
|
|
16554
|
-
};
|
|
16555
|
-
}
|
|
16556
|
-
for (n.method = i, n.arg = a;;) {
|
|
16557
|
-
var c = n.delegate;
|
|
16558
|
-
if (c) {
|
|
16559
|
-
var u = maybeInvokeDelegate(c, n);
|
|
16560
|
-
if (u) {
|
|
16561
|
-
if (u === y) continue;
|
|
16562
|
-
return u;
|
|
16563
|
-
}
|
|
16564
|
-
}
|
|
16565
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
16566
|
-
if (o === h) throw o = s, n.arg;
|
|
16567
|
-
n.dispatchException(n.arg);
|
|
16568
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
16569
|
-
o = f;
|
|
16570
|
-
var p = tryCatch(e, r, n);
|
|
16571
|
-
if ("normal" === p.type) {
|
|
16572
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
16573
|
-
return {
|
|
16574
|
-
value: p.arg,
|
|
16575
|
-
done: n.done
|
|
16576
|
-
};
|
|
16577
|
-
}
|
|
16578
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
16579
|
-
}
|
|
16580
|
-
};
|
|
16581
|
-
}
|
|
16582
|
-
function maybeInvokeDelegate(e, r) {
|
|
16583
|
-
var n = r.method,
|
|
16584
|
-
o = e.iterator[n];
|
|
16585
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
16586
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
16587
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
16588
|
-
var a = i.arg;
|
|
16589
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
16590
|
-
}
|
|
16591
|
-
function pushTryEntry(t) {
|
|
16592
|
-
var e = {
|
|
16593
|
-
tryLoc: t[0]
|
|
16594
|
-
};
|
|
16595
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
16596
|
-
}
|
|
16597
|
-
function resetTryEntry(t) {
|
|
16598
|
-
var e = t.completion || {};
|
|
16599
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
16600
|
-
}
|
|
16601
|
-
function Context(t) {
|
|
16602
|
-
this.tryEntries = [{
|
|
16603
|
-
tryLoc: "root"
|
|
16604
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
16605
|
-
}
|
|
16606
|
-
function values(e) {
|
|
16607
|
-
if (e || "" === e) {
|
|
16608
|
-
var r = e[a];
|
|
16609
|
-
if (r) return r.call(e);
|
|
16610
|
-
if ("function" == typeof e.next) return e;
|
|
16611
|
-
if (!isNaN(e.length)) {
|
|
16612
|
-
var o = -1,
|
|
16613
|
-
i = function next() {
|
|
16614
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
16615
|
-
return next.value = t, next.done = !0, next;
|
|
16616
|
-
};
|
|
16617
|
-
return i.next = i;
|
|
16618
|
-
}
|
|
16619
|
-
}
|
|
16620
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
16621
|
-
}
|
|
16622
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
16623
|
-
value: GeneratorFunctionPrototype,
|
|
16624
|
-
configurable: !0
|
|
16625
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
16626
|
-
value: GeneratorFunction,
|
|
16627
|
-
configurable: !0
|
|
16628
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
16629
|
-
var e = "function" == typeof t && t.constructor;
|
|
16630
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
16631
|
-
}, e.mark = function (t) {
|
|
16632
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
16633
|
-
}, e.awrap = function (t) {
|
|
16634
|
-
return {
|
|
16635
|
-
__await: t
|
|
16636
|
-
};
|
|
16637
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
16638
|
-
return this;
|
|
16639
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
16640
|
-
void 0 === i && (i = Promise);
|
|
16641
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
16642
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
16643
|
-
return t.done ? t.value : a.next();
|
|
16644
|
-
});
|
|
16645
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
16646
|
-
return this;
|
|
16647
|
-
}), define(g, "toString", function () {
|
|
16648
|
-
return "[object Generator]";
|
|
16649
|
-
}), e.keys = function (t) {
|
|
16650
|
-
var e = Object(t),
|
|
16651
|
-
r = [];
|
|
16652
|
-
for (var n in e) r.push(n);
|
|
16653
|
-
return r.reverse(), function next() {
|
|
16654
|
-
for (; r.length;) {
|
|
16655
|
-
var t = r.pop();
|
|
16656
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
16657
|
-
}
|
|
16658
|
-
return next.done = !0, next;
|
|
16659
|
-
};
|
|
16660
|
-
}, e.values = values, Context.prototype = {
|
|
16661
|
-
constructor: Context,
|
|
16662
|
-
reset: function reset(e) {
|
|
16663
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
16664
|
-
},
|
|
16665
|
-
stop: function stop() {
|
|
16666
|
-
this.done = !0;
|
|
16667
|
-
var t = this.tryEntries[0].completion;
|
|
16668
|
-
if ("throw" === t.type) throw t.arg;
|
|
16669
|
-
return this.rval;
|
|
16670
|
-
},
|
|
16671
|
-
dispatchException: function dispatchException(e) {
|
|
16672
|
-
if (this.done) throw e;
|
|
16673
|
-
var r = this;
|
|
16674
|
-
function handle(n, o) {
|
|
16675
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
16676
|
-
}
|
|
16677
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
16678
|
-
var i = this.tryEntries[o],
|
|
16679
|
-
a = i.completion;
|
|
16680
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
16681
|
-
if (i.tryLoc <= this.prev) {
|
|
16682
|
-
var c = n.call(i, "catchLoc"),
|
|
16683
|
-
u = n.call(i, "finallyLoc");
|
|
16684
|
-
if (c && u) {
|
|
16685
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16686
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16687
|
-
} else if (c) {
|
|
16688
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16689
|
-
} else {
|
|
16690
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
16691
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16692
|
-
}
|
|
16693
|
-
}
|
|
16694
|
-
}
|
|
16695
|
-
},
|
|
16696
|
-
abrupt: function abrupt(t, e) {
|
|
16697
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
16698
|
-
var o = this.tryEntries[r];
|
|
16699
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
16700
|
-
var i = o;
|
|
16701
|
-
break;
|
|
16702
|
-
}
|
|
16703
|
-
}
|
|
16704
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
16705
|
-
var a = i ? i.completion : {};
|
|
16706
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
16707
|
-
},
|
|
16708
|
-
complete: function complete(t, e) {
|
|
16709
|
-
if ("throw" === t.type) throw t.arg;
|
|
16710
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
16711
|
-
},
|
|
16712
|
-
finish: function finish(t) {
|
|
16713
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16714
|
-
var r = this.tryEntries[e];
|
|
16715
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
16716
|
-
}
|
|
16717
|
-
},
|
|
16718
|
-
"catch": function _catch(t) {
|
|
16719
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16720
|
-
var r = this.tryEntries[e];
|
|
16721
|
-
if (r.tryLoc === t) {
|
|
16722
|
-
var n = r.completion;
|
|
16723
|
-
if ("throw" === n.type) {
|
|
16724
|
-
var o = n.arg;
|
|
16725
|
-
resetTryEntry(r);
|
|
16726
|
-
}
|
|
16727
|
-
return o;
|
|
16728
|
-
}
|
|
16729
|
-
}
|
|
16730
|
-
throw new Error("illegal catch attempt");
|
|
16731
|
-
},
|
|
16732
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
16733
|
-
return this.delegate = {
|
|
16734
|
-
iterator: values(e),
|
|
16735
|
-
resultName: r,
|
|
16736
|
-
nextLoc: n
|
|
16737
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
16738
|
-
}
|
|
16739
|
-
}, e;
|
|
16740
|
-
}
|
|
16741
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16742
|
-
} (regeneratorRuntime$1));
|
|
16743
|
-
return regeneratorRuntime$1.exports;
|
|
16744
|
-
}
|
|
16745
|
-
|
|
16746
|
-
var regenerator;
|
|
16747
|
-
var hasRequiredRegenerator;
|
|
16748
|
-
|
|
16749
|
-
function requireRegenerator () {
|
|
16750
|
-
if (hasRequiredRegenerator) return regenerator;
|
|
16751
|
-
hasRequiredRegenerator = 1;
|
|
16752
|
-
// TODO(Babel 8): Remove this file.
|
|
16143
|
+
/**
|
|
16144
|
+
* Constructor to create a storage for our `EE` objects.
|
|
16145
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
16146
|
+
*
|
|
16147
|
+
* @constructor
|
|
16148
|
+
* @private
|
|
16149
|
+
*/
|
|
16150
|
+
function Events() {}
|
|
16753
16151
|
|
|
16754
|
-
|
|
16755
|
-
|
|
16152
|
+
//
|
|
16153
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
16154
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
16155
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
16156
|
+
// character to make sure that the built-in object properties are not
|
|
16157
|
+
// overridden or used as an attack vector.
|
|
16158
|
+
//
|
|
16159
|
+
if (Object.create) {
|
|
16160
|
+
Events.prototype = Object.create(null);
|
|
16756
16161
|
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
if (
|
|
16762
|
-
globalThis.regeneratorRuntime = runtime;
|
|
16763
|
-
} else {
|
|
16764
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
16765
|
-
}
|
|
16162
|
+
//
|
|
16163
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
16164
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
16165
|
+
//
|
|
16166
|
+
if (!new Events().__proto__) prefix = false;
|
|
16766
16167
|
}
|
|
16767
|
-
return regenerator;
|
|
16768
|
-
}
|
|
16769
|
-
|
|
16770
|
-
var asyncToGenerator = {exports: {}};
|
|
16771
|
-
|
|
16772
|
-
var hasRequiredAsyncToGenerator;
|
|
16773
|
-
|
|
16774
|
-
function requireAsyncToGenerator () {
|
|
16775
|
-
if (hasRequiredAsyncToGenerator) return asyncToGenerator.exports;
|
|
16776
|
-
hasRequiredAsyncToGenerator = 1;
|
|
16777
|
-
(function (module) {
|
|
16778
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16779
|
-
try {
|
|
16780
|
-
var info = gen[key](arg);
|
|
16781
|
-
var value = info.value;
|
|
16782
|
-
} catch (error) {
|
|
16783
|
-
reject(error);
|
|
16784
|
-
return;
|
|
16785
|
-
}
|
|
16786
|
-
if (info.done) {
|
|
16787
|
-
resolve(value);
|
|
16788
|
-
} else {
|
|
16789
|
-
Promise.resolve(value).then(_next, _throw);
|
|
16790
|
-
}
|
|
16791
|
-
}
|
|
16792
|
-
function _asyncToGenerator(fn) {
|
|
16793
|
-
return function () {
|
|
16794
|
-
var self = this,
|
|
16795
|
-
args = arguments;
|
|
16796
|
-
return new Promise(function (resolve, reject) {
|
|
16797
|
-
var gen = fn.apply(self, args);
|
|
16798
|
-
function _next(value) {
|
|
16799
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
16800
|
-
}
|
|
16801
|
-
function _throw(err) {
|
|
16802
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
16803
|
-
}
|
|
16804
|
-
_next(undefined);
|
|
16805
|
-
});
|
|
16806
|
-
};
|
|
16807
|
-
}
|
|
16808
|
-
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16809
|
-
} (asyncToGenerator));
|
|
16810
|
-
return asyncToGenerator.exports;
|
|
16811
|
-
}
|
|
16812
|
-
|
|
16813
|
-
var classCallCheck = {exports: {}};
|
|
16814
|
-
|
|
16815
|
-
var hasRequiredClassCallCheck;
|
|
16816
|
-
|
|
16817
|
-
function requireClassCallCheck () {
|
|
16818
|
-
if (hasRequiredClassCallCheck) return classCallCheck.exports;
|
|
16819
|
-
hasRequiredClassCallCheck = 1;
|
|
16820
|
-
(function (module) {
|
|
16821
|
-
function _classCallCheck(instance, Constructor) {
|
|
16822
|
-
if (!(instance instanceof Constructor)) {
|
|
16823
|
-
throw new TypeError("Cannot call a class as a function");
|
|
16824
|
-
}
|
|
16825
|
-
}
|
|
16826
|
-
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16827
|
-
} (classCallCheck));
|
|
16828
|
-
return classCallCheck.exports;
|
|
16829
|
-
}
|
|
16830
|
-
|
|
16831
|
-
var createClass = {exports: {}};
|
|
16832
|
-
|
|
16833
|
-
var toPropertyKey = {exports: {}};
|
|
16834
|
-
|
|
16835
|
-
var toPrimitive = {exports: {}};
|
|
16836
|
-
|
|
16837
|
-
var hasRequiredToPrimitive;
|
|
16838
|
-
|
|
16839
|
-
function requireToPrimitive () {
|
|
16840
|
-
if (hasRequiredToPrimitive) return toPrimitive.exports;
|
|
16841
|
-
hasRequiredToPrimitive = 1;
|
|
16842
|
-
(function (module) {
|
|
16843
|
-
var _typeof = require_typeof()["default"];
|
|
16844
|
-
function _toPrimitive(input, hint) {
|
|
16845
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
16846
|
-
var prim = input[Symbol.toPrimitive];
|
|
16847
|
-
if (prim !== undefined) {
|
|
16848
|
-
var res = prim.call(input, hint || "default");
|
|
16849
|
-
if (_typeof(res) !== "object") return res;
|
|
16850
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16851
|
-
}
|
|
16852
|
-
return (hint === "string" ? String : Number)(input);
|
|
16853
|
-
}
|
|
16854
|
-
module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16855
|
-
} (toPrimitive));
|
|
16856
|
-
return toPrimitive.exports;
|
|
16857
|
-
}
|
|
16858
|
-
|
|
16859
|
-
var hasRequiredToPropertyKey;
|
|
16860
|
-
|
|
16861
|
-
function requireToPropertyKey () {
|
|
16862
|
-
if (hasRequiredToPropertyKey) return toPropertyKey.exports;
|
|
16863
|
-
hasRequiredToPropertyKey = 1;
|
|
16864
|
-
(function (module) {
|
|
16865
|
-
var _typeof = require_typeof()["default"];
|
|
16866
|
-
var toPrimitive = requireToPrimitive();
|
|
16867
|
-
function _toPropertyKey(arg) {
|
|
16868
|
-
var key = toPrimitive(arg, "string");
|
|
16869
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
16870
|
-
}
|
|
16871
|
-
module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16872
|
-
} (toPropertyKey));
|
|
16873
|
-
return toPropertyKey.exports;
|
|
16874
|
-
}
|
|
16875
|
-
|
|
16876
|
-
var hasRequiredCreateClass;
|
|
16877
|
-
|
|
16878
|
-
function requireCreateClass () {
|
|
16879
|
-
if (hasRequiredCreateClass) return createClass.exports;
|
|
16880
|
-
hasRequiredCreateClass = 1;
|
|
16881
|
-
(function (module) {
|
|
16882
|
-
var toPropertyKey = requireToPropertyKey();
|
|
16883
|
-
function _defineProperties(target, props) {
|
|
16884
|
-
for (var i = 0; i < props.length; i++) {
|
|
16885
|
-
var descriptor = props[i];
|
|
16886
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
16887
|
-
descriptor.configurable = true;
|
|
16888
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16889
|
-
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
16890
|
-
}
|
|
16891
|
-
}
|
|
16892
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
16893
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
16894
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
16895
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
16896
|
-
writable: false
|
|
16897
|
-
});
|
|
16898
|
-
return Constructor;
|
|
16899
|
-
}
|
|
16900
|
-
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16901
|
-
} (createClass));
|
|
16902
|
-
return createClass.exports;
|
|
16903
|
-
}
|
|
16904
|
-
|
|
16905
|
-
var inherits = {exports: {}};
|
|
16906
|
-
|
|
16907
|
-
var setPrototypeOf = {exports: {}};
|
|
16908
|
-
|
|
16909
|
-
var hasRequiredSetPrototypeOf;
|
|
16910
|
-
|
|
16911
|
-
function requireSetPrototypeOf () {
|
|
16912
|
-
if (hasRequiredSetPrototypeOf) return setPrototypeOf.exports;
|
|
16913
|
-
hasRequiredSetPrototypeOf = 1;
|
|
16914
|
-
(function (module) {
|
|
16915
|
-
function _setPrototypeOf(o, p) {
|
|
16916
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
16917
|
-
o.__proto__ = p;
|
|
16918
|
-
return o;
|
|
16919
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16920
|
-
return _setPrototypeOf(o, p);
|
|
16921
|
-
}
|
|
16922
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16923
|
-
} (setPrototypeOf));
|
|
16924
|
-
return setPrototypeOf.exports;
|
|
16925
|
-
}
|
|
16926
|
-
|
|
16927
|
-
var hasRequiredInherits;
|
|
16928
|
-
|
|
16929
|
-
function requireInherits () {
|
|
16930
|
-
if (hasRequiredInherits) return inherits.exports;
|
|
16931
|
-
hasRequiredInherits = 1;
|
|
16932
|
-
(function (module) {
|
|
16933
|
-
var setPrototypeOf = requireSetPrototypeOf();
|
|
16934
|
-
function _inherits(subClass, superClass) {
|
|
16935
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
16936
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
16937
|
-
}
|
|
16938
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
16939
|
-
constructor: {
|
|
16940
|
-
value: subClass,
|
|
16941
|
-
writable: true,
|
|
16942
|
-
configurable: true
|
|
16943
|
-
}
|
|
16944
|
-
});
|
|
16945
|
-
Object.defineProperty(subClass, "prototype", {
|
|
16946
|
-
writable: false
|
|
16947
|
-
});
|
|
16948
|
-
if (superClass) setPrototypeOf(subClass, superClass);
|
|
16949
|
-
}
|
|
16950
|
-
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16951
|
-
} (inherits));
|
|
16952
|
-
return inherits.exports;
|
|
16953
|
-
}
|
|
16954
|
-
|
|
16955
|
-
var possibleConstructorReturn = {exports: {}};
|
|
16956
|
-
|
|
16957
|
-
var assertThisInitialized = {exports: {}};
|
|
16958
|
-
|
|
16959
|
-
var hasRequiredAssertThisInitialized;
|
|
16960
|
-
|
|
16961
|
-
function requireAssertThisInitialized () {
|
|
16962
|
-
if (hasRequiredAssertThisInitialized) return assertThisInitialized.exports;
|
|
16963
|
-
hasRequiredAssertThisInitialized = 1;
|
|
16964
|
-
(function (module) {
|
|
16965
|
-
function _assertThisInitialized(self) {
|
|
16966
|
-
if (self === void 0) {
|
|
16967
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16968
|
-
}
|
|
16969
|
-
return self;
|
|
16970
|
-
}
|
|
16971
|
-
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16972
|
-
} (assertThisInitialized));
|
|
16973
|
-
return assertThisInitialized.exports;
|
|
16974
|
-
}
|
|
16975
|
-
|
|
16976
|
-
var hasRequiredPossibleConstructorReturn;
|
|
16977
|
-
|
|
16978
|
-
function requirePossibleConstructorReturn () {
|
|
16979
|
-
if (hasRequiredPossibleConstructorReturn) return possibleConstructorReturn.exports;
|
|
16980
|
-
hasRequiredPossibleConstructorReturn = 1;
|
|
16981
|
-
(function (module) {
|
|
16982
|
-
var _typeof = require_typeof()["default"];
|
|
16983
|
-
var assertThisInitialized = requireAssertThisInitialized();
|
|
16984
|
-
function _possibleConstructorReturn(self, call) {
|
|
16985
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
16986
|
-
return call;
|
|
16987
|
-
} else if (call !== void 0) {
|
|
16988
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
16989
|
-
}
|
|
16990
|
-
return assertThisInitialized(self);
|
|
16991
|
-
}
|
|
16992
|
-
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16993
|
-
} (possibleConstructorReturn));
|
|
16994
|
-
return possibleConstructorReturn.exports;
|
|
16995
|
-
}
|
|
16996
|
-
|
|
16997
|
-
var getPrototypeOf = {exports: {}};
|
|
16998
|
-
|
|
16999
|
-
var hasRequiredGetPrototypeOf;
|
|
17000
|
-
|
|
17001
|
-
function requireGetPrototypeOf () {
|
|
17002
|
-
if (hasRequiredGetPrototypeOf) return getPrototypeOf.exports;
|
|
17003
|
-
hasRequiredGetPrototypeOf = 1;
|
|
17004
|
-
(function (module) {
|
|
17005
|
-
function _getPrototypeOf(o) {
|
|
17006
|
-
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
17007
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
17008
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17009
|
-
return _getPrototypeOf(o);
|
|
17010
|
-
}
|
|
17011
|
-
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17012
|
-
} (getPrototypeOf));
|
|
17013
|
-
return getPrototypeOf.exports;
|
|
17014
|
-
}
|
|
17015
|
-
|
|
17016
|
-
var eventemitter3 = {exports: {}};
|
|
17017
|
-
|
|
17018
|
-
var hasRequiredEventemitter3;
|
|
17019
|
-
|
|
17020
|
-
function requireEventemitter3 () {
|
|
17021
|
-
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
17022
|
-
hasRequiredEventemitter3 = 1;
|
|
17023
|
-
(function (module) {
|
|
17024
|
-
|
|
17025
|
-
var has = Object.prototype.hasOwnProperty
|
|
17026
|
-
, prefix = '~';
|
|
17027
|
-
|
|
17028
|
-
/**
|
|
17029
|
-
* Constructor to create a storage for our `EE` objects.
|
|
17030
|
-
* An `Events` instance is a plain object whose properties are event names.
|
|
17031
|
-
*
|
|
17032
|
-
* @constructor
|
|
17033
|
-
* @private
|
|
17034
|
-
*/
|
|
17035
|
-
function Events() {}
|
|
17036
|
-
|
|
17037
|
-
//
|
|
17038
|
-
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
17039
|
-
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
17040
|
-
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
17041
|
-
// character to make sure that the built-in object properties are not
|
|
17042
|
-
// overridden or used as an attack vector.
|
|
17043
|
-
//
|
|
17044
|
-
if (Object.create) {
|
|
17045
|
-
Events.prototype = Object.create(null);
|
|
17046
|
-
|
|
17047
|
-
//
|
|
17048
|
-
// This hack is needed because the `__proto__` property is still inherited in
|
|
17049
|
-
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
17050
|
-
//
|
|
17051
|
-
if (!new Events().__proto__) prefix = false;
|
|
17052
|
-
}
|
|
17053
|
-
|
|
17054
|
-
/**
|
|
17055
|
-
* Representation of a single event listener.
|
|
17056
|
-
*
|
|
17057
|
-
* @param {Function} fn The listener function.
|
|
17058
|
-
* @param {*} context The context to invoke the listener with.
|
|
17059
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
17060
|
-
* @constructor
|
|
17061
|
-
* @private
|
|
17062
|
-
*/
|
|
17063
|
-
function EE(fn, context, once) {
|
|
17064
|
-
this.fn = fn;
|
|
17065
|
-
this.context = context;
|
|
17066
|
-
this.once = once || false;
|
|
17067
|
-
}
|
|
17068
|
-
|
|
17069
|
-
/**
|
|
17070
|
-
* Add a listener for a given event.
|
|
17071
|
-
*
|
|
17072
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
17073
|
-
* @param {(String|Symbol)} event The event name.
|
|
17074
|
-
* @param {Function} fn The listener function.
|
|
17075
|
-
* @param {*} context The context to invoke the listener with.
|
|
17076
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
17077
|
-
* @returns {EventEmitter}
|
|
17078
|
-
* @private
|
|
17079
|
-
*/
|
|
17080
|
-
function addListener(emitter, event, fn, context, once) {
|
|
17081
|
-
if (typeof fn !== 'function') {
|
|
17082
|
-
throw new TypeError('The listener must be a function');
|
|
17083
|
-
}
|
|
17084
|
-
|
|
17085
|
-
var listener = new EE(fn, context || emitter, once)
|
|
17086
|
-
, evt = prefix ? prefix + event : event;
|
|
17087
|
-
|
|
17088
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
17089
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
17090
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
17091
|
-
|
|
17092
|
-
return emitter;
|
|
17093
|
-
}
|
|
17094
|
-
|
|
17095
|
-
/**
|
|
17096
|
-
* Clear event by name.
|
|
17097
|
-
*
|
|
17098
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
17099
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
17100
|
-
* @private
|
|
17101
|
-
*/
|
|
17102
|
-
function clearEvent(emitter, evt) {
|
|
17103
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
17104
|
-
else delete emitter._events[evt];
|
|
17105
|
-
}
|
|
17106
|
-
|
|
17107
|
-
/**
|
|
17108
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
17109
|
-
* `EventEmitter` interface.
|
|
17110
|
-
*
|
|
17111
|
-
* @constructor
|
|
17112
|
-
* @public
|
|
17113
|
-
*/
|
|
17114
|
-
function EventEmitter() {
|
|
17115
|
-
this._events = new Events();
|
|
17116
|
-
this._eventsCount = 0;
|
|
17117
|
-
}
|
|
17118
|
-
|
|
17119
|
-
/**
|
|
17120
|
-
* Return an array listing the events for which the emitter has registered
|
|
17121
|
-
* listeners.
|
|
17122
|
-
*
|
|
17123
|
-
* @returns {Array}
|
|
17124
|
-
* @public
|
|
17125
|
-
*/
|
|
17126
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
17127
|
-
var names = []
|
|
17128
|
-
, events
|
|
17129
|
-
, name;
|
|
17130
|
-
|
|
17131
|
-
if (this._eventsCount === 0) return names;
|
|
17132
|
-
|
|
17133
|
-
for (name in (events = this._events)) {
|
|
17134
|
-
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
17135
|
-
}
|
|
17136
|
-
|
|
17137
|
-
if (Object.getOwnPropertySymbols) {
|
|
17138
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
17139
|
-
}
|
|
17140
|
-
|
|
17141
|
-
return names;
|
|
17142
|
-
};
|
|
17143
|
-
|
|
17144
|
-
/**
|
|
17145
|
-
* Return the listeners registered for a given event.
|
|
17146
|
-
*
|
|
17147
|
-
* @param {(String|Symbol)} event The event name.
|
|
17148
|
-
* @returns {Array} The registered listeners.
|
|
17149
|
-
* @public
|
|
17150
|
-
*/
|
|
17151
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
17152
|
-
var evt = prefix ? prefix + event : event
|
|
17153
|
-
, handlers = this._events[evt];
|
|
17154
|
-
|
|
17155
|
-
if (!handlers) return [];
|
|
17156
|
-
if (handlers.fn) return [handlers.fn];
|
|
17157
|
-
|
|
17158
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
17159
|
-
ee[i] = handlers[i].fn;
|
|
17160
|
-
}
|
|
17161
|
-
|
|
17162
|
-
return ee;
|
|
17163
|
-
};
|
|
17164
|
-
|
|
17165
|
-
/**
|
|
17166
|
-
* Return the number of listeners listening to a given event.
|
|
17167
|
-
*
|
|
17168
|
-
* @param {(String|Symbol)} event The event name.
|
|
17169
|
-
* @returns {Number} The number of listeners.
|
|
17170
|
-
* @public
|
|
17171
|
-
*/
|
|
17172
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
17173
|
-
var evt = prefix ? prefix + event : event
|
|
17174
|
-
, listeners = this._events[evt];
|
|
17175
|
-
|
|
17176
|
-
if (!listeners) return 0;
|
|
17177
|
-
if (listeners.fn) return 1;
|
|
17178
|
-
return listeners.length;
|
|
17179
|
-
};
|
|
17180
|
-
|
|
17181
|
-
/**
|
|
17182
|
-
* Calls each of the listeners registered for a given event.
|
|
17183
|
-
*
|
|
17184
|
-
* @param {(String|Symbol)} event The event name.
|
|
17185
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
17186
|
-
* @public
|
|
17187
|
-
*/
|
|
17188
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
17189
|
-
var evt = prefix ? prefix + event : event;
|
|
17190
|
-
|
|
17191
|
-
if (!this._events[evt]) return false;
|
|
17192
|
-
|
|
17193
|
-
var listeners = this._events[evt]
|
|
17194
|
-
, len = arguments.length
|
|
17195
|
-
, args
|
|
17196
|
-
, i;
|
|
17197
|
-
|
|
17198
|
-
if (listeners.fn) {
|
|
17199
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
17200
|
-
|
|
17201
|
-
switch (len) {
|
|
17202
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
17203
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
17204
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
17205
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
17206
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
17207
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
17208
|
-
}
|
|
17209
|
-
|
|
17210
|
-
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
17211
|
-
args[i - 1] = arguments[i];
|
|
17212
|
-
}
|
|
17213
|
-
|
|
17214
|
-
listeners.fn.apply(listeners.context, args);
|
|
17215
|
-
} else {
|
|
17216
|
-
var length = listeners.length
|
|
17217
|
-
, j;
|
|
17218
|
-
|
|
17219
|
-
for (i = 0; i < length; i++) {
|
|
17220
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
17221
|
-
|
|
17222
|
-
switch (len) {
|
|
17223
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
17224
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
17225
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
17226
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
17227
|
-
default:
|
|
17228
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
17229
|
-
args[j - 1] = arguments[j];
|
|
17230
|
-
}
|
|
17231
|
-
|
|
17232
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
17233
|
-
}
|
|
17234
|
-
}
|
|
17235
|
-
}
|
|
17236
|
-
|
|
17237
|
-
return true;
|
|
17238
|
-
};
|
|
17239
|
-
|
|
17240
|
-
/**
|
|
17241
|
-
* Add a listener for a given event.
|
|
17242
|
-
*
|
|
17243
|
-
* @param {(String|Symbol)} event The event name.
|
|
17244
|
-
* @param {Function} fn The listener function.
|
|
17245
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
17246
|
-
* @returns {EventEmitter} `this`.
|
|
17247
|
-
* @public
|
|
17248
|
-
*/
|
|
17249
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
17250
|
-
return addListener(this, event, fn, context, false);
|
|
17251
|
-
};
|
|
17252
|
-
|
|
17253
|
-
/**
|
|
17254
|
-
* Add a one-time listener for a given event.
|
|
17255
|
-
*
|
|
17256
|
-
* @param {(String|Symbol)} event The event name.
|
|
17257
|
-
* @param {Function} fn The listener function.
|
|
17258
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
17259
|
-
* @returns {EventEmitter} `this`.
|
|
17260
|
-
* @public
|
|
17261
|
-
*/
|
|
17262
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
17263
|
-
return addListener(this, event, fn, context, true);
|
|
17264
|
-
};
|
|
17265
|
-
|
|
17266
|
-
/**
|
|
17267
|
-
* Remove the listeners of a given event.
|
|
17268
|
-
*
|
|
17269
|
-
* @param {(String|Symbol)} event The event name.
|
|
17270
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
17271
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
17272
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
17273
|
-
* @returns {EventEmitter} `this`.
|
|
17274
|
-
* @public
|
|
17275
|
-
*/
|
|
17276
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
17277
|
-
var evt = prefix ? prefix + event : event;
|
|
17278
|
-
|
|
17279
|
-
if (!this._events[evt]) return this;
|
|
17280
|
-
if (!fn) {
|
|
17281
|
-
clearEvent(this, evt);
|
|
17282
|
-
return this;
|
|
17283
|
-
}
|
|
17284
|
-
|
|
17285
|
-
var listeners = this._events[evt];
|
|
17286
|
-
|
|
17287
|
-
if (listeners.fn) {
|
|
17288
|
-
if (
|
|
17289
|
-
listeners.fn === fn &&
|
|
17290
|
-
(!once || listeners.once) &&
|
|
17291
|
-
(!context || listeners.context === context)
|
|
17292
|
-
) {
|
|
17293
|
-
clearEvent(this, evt);
|
|
17294
|
-
}
|
|
17295
|
-
} else {
|
|
17296
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
17297
|
-
if (
|
|
17298
|
-
listeners[i].fn !== fn ||
|
|
17299
|
-
(once && !listeners[i].once) ||
|
|
17300
|
-
(context && listeners[i].context !== context)
|
|
17301
|
-
) {
|
|
17302
|
-
events.push(listeners[i]);
|
|
17303
|
-
}
|
|
17304
|
-
}
|
|
17305
|
-
|
|
17306
|
-
//
|
|
17307
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
17308
|
-
//
|
|
17309
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
17310
|
-
else clearEvent(this, evt);
|
|
17311
|
-
}
|
|
17312
|
-
|
|
17313
|
-
return this;
|
|
17314
|
-
};
|
|
17315
|
-
|
|
17316
|
-
/**
|
|
17317
|
-
* Remove all listeners, or those of the specified event.
|
|
17318
|
-
*
|
|
17319
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
17320
|
-
* @returns {EventEmitter} `this`.
|
|
17321
|
-
* @public
|
|
17322
|
-
*/
|
|
17323
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
17324
|
-
var evt;
|
|
17325
|
-
|
|
17326
|
-
if (event) {
|
|
17327
|
-
evt = prefix ? prefix + event : event;
|
|
17328
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
17329
|
-
} else {
|
|
17330
|
-
this._events = new Events();
|
|
17331
|
-
this._eventsCount = 0;
|
|
17332
|
-
}
|
|
17333
|
-
|
|
17334
|
-
return this;
|
|
17335
|
-
};
|
|
17336
|
-
|
|
17337
|
-
//
|
|
17338
|
-
// Alias methods names because people roll like that.
|
|
17339
|
-
//
|
|
17340
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
17341
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
17342
|
-
|
|
17343
|
-
//
|
|
17344
|
-
// Expose the prefix.
|
|
17345
|
-
//
|
|
17346
|
-
EventEmitter.prefixed = prefix;
|
|
17347
|
-
|
|
17348
|
-
//
|
|
17349
|
-
// Allow `EventEmitter` to be imported as module namespace.
|
|
17350
|
-
//
|
|
17351
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
17352
|
-
|
|
17353
|
-
//
|
|
17354
|
-
// Expose the module.
|
|
17355
|
-
//
|
|
17356
|
-
{
|
|
17357
|
-
module.exports = EventEmitter;
|
|
17358
|
-
}
|
|
17359
|
-
} (eventemitter3));
|
|
17360
|
-
return eventemitter3.exports;
|
|
17361
|
-
}
|
|
17362
16168
|
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
var _regenerator = _interopRequireDefault(requireRegenerator());
|
|
17379
|
-
|
|
17380
|
-
var _asyncToGenerator2 = _interopRequireDefault(requireAsyncToGenerator());
|
|
17381
|
-
|
|
17382
|
-
var _typeof2 = _interopRequireDefault(require_typeof());
|
|
17383
|
-
|
|
17384
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
17385
|
-
|
|
17386
|
-
var _createClass2 = _interopRequireDefault(requireCreateClass());
|
|
16169
|
+
/**
|
|
16170
|
+
* Representation of a single event listener.
|
|
16171
|
+
*
|
|
16172
|
+
* @param {Function} fn The listener function.
|
|
16173
|
+
* @param {*} context The context to invoke the listener with.
|
|
16174
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
16175
|
+
* @constructor
|
|
16176
|
+
* @private
|
|
16177
|
+
*/
|
|
16178
|
+
function EE(fn, context, once) {
|
|
16179
|
+
this.fn = fn;
|
|
16180
|
+
this.context = context;
|
|
16181
|
+
this.once = once || false;
|
|
16182
|
+
}
|
|
17387
16183
|
|
|
17388
|
-
|
|
16184
|
+
/**
|
|
16185
|
+
* Add a listener for a given event.
|
|
16186
|
+
*
|
|
16187
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16188
|
+
* @param {(String|Symbol)} event The event name.
|
|
16189
|
+
* @param {Function} fn The listener function.
|
|
16190
|
+
* @param {*} context The context to invoke the listener with.
|
|
16191
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
16192
|
+
* @returns {EventEmitter}
|
|
16193
|
+
* @private
|
|
16194
|
+
*/
|
|
16195
|
+
function addListener(emitter, event, fn, context, once) {
|
|
16196
|
+
if (typeof fn !== 'function') {
|
|
16197
|
+
throw new TypeError('The listener must be a function');
|
|
16198
|
+
}
|
|
17389
16199
|
|
|
17390
|
-
|
|
16200
|
+
var listener = new EE(fn, context || emitter, once)
|
|
16201
|
+
, evt = prefix ? prefix + event : event;
|
|
17391
16202
|
|
|
17392
|
-
|
|
16203
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
16204
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
16205
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
17393
16206
|
|
|
17394
|
-
|
|
16207
|
+
return emitter;
|
|
16208
|
+
}
|
|
17395
16209
|
|
|
17396
|
-
|
|
16210
|
+
/**
|
|
16211
|
+
* Clear event by name.
|
|
16212
|
+
*
|
|
16213
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16214
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
16215
|
+
* @private
|
|
16216
|
+
*/
|
|
16217
|
+
function clearEvent(emitter, evt) {
|
|
16218
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
16219
|
+
else delete emitter._events[evt];
|
|
16220
|
+
}
|
|
17397
16221
|
|
|
17398
|
-
|
|
16222
|
+
/**
|
|
16223
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
16224
|
+
* `EventEmitter` interface.
|
|
16225
|
+
*
|
|
16226
|
+
* @constructor
|
|
16227
|
+
* @public
|
|
16228
|
+
*/
|
|
16229
|
+
function EventEmitter() {
|
|
16230
|
+
this._events = new Events();
|
|
16231
|
+
this._eventsCount = 0;
|
|
16232
|
+
}
|
|
17399
16233
|
|
|
17400
|
-
|
|
17401
|
-
|
|
16234
|
+
/**
|
|
16235
|
+
* Return an array listing the events for which the emitter has registered
|
|
16236
|
+
* listeners.
|
|
16237
|
+
*
|
|
16238
|
+
* @returns {Array}
|
|
16239
|
+
* @public
|
|
16240
|
+
*/
|
|
16241
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
16242
|
+
var names = []
|
|
16243
|
+
, events
|
|
16244
|
+
, name;
|
|
17402
16245
|
|
|
17403
|
-
|
|
17404
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
17405
|
-
}
|
|
16246
|
+
if (this._eventsCount === 0) return names;
|
|
17406
16247
|
|
|
17407
|
-
|
|
17408
|
-
if (
|
|
16248
|
+
for (name in (events = this._events)) {
|
|
16249
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
17409
16250
|
}
|
|
17410
|
-
return t;
|
|
17411
|
-
}; // @ts-ignore
|
|
17412
|
-
|
|
17413
|
-
|
|
17414
|
-
var CommonClient = /*#__PURE__*/function (_EventEmitter) {
|
|
17415
|
-
(0, _inherits2["default"])(CommonClient, _EventEmitter);
|
|
17416
|
-
|
|
17417
|
-
var _super = _createSuper(CommonClient);
|
|
17418
|
-
|
|
17419
|
-
/**
|
|
17420
|
-
* Instantiate a Client class.
|
|
17421
|
-
* @constructor
|
|
17422
|
-
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
17423
|
-
* @param {String} address - url to a websocket server
|
|
17424
|
-
* @param {Object} options - ws options object with reconnect parameters
|
|
17425
|
-
* @param {Function} generate_request_id - custom generation request Id
|
|
17426
|
-
* @return {CommonClient}
|
|
17427
|
-
*/
|
|
17428
|
-
function CommonClient(webSocketFactory) {
|
|
17429
|
-
var _this;
|
|
17430
|
-
|
|
17431
|
-
var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ws://localhost:8080";
|
|
17432
|
-
|
|
17433
|
-
var _a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
17434
|
-
|
|
17435
|
-
var generate_request_id = arguments.length > 3 ? arguments[3] : undefined;
|
|
17436
|
-
(0, _classCallCheck2["default"])(this, CommonClient);
|
|
17437
|
-
|
|
17438
|
-
var _a$autoconnect = _a.autoconnect,
|
|
17439
|
-
autoconnect = _a$autoconnect === void 0 ? true : _a$autoconnect,
|
|
17440
|
-
_a$reconnect = _a.reconnect,
|
|
17441
|
-
reconnect = _a$reconnect === void 0 ? true : _a$reconnect,
|
|
17442
|
-
_a$reconnect_interval = _a.reconnect_interval,
|
|
17443
|
-
reconnect_interval = _a$reconnect_interval === void 0 ? 1000 : _a$reconnect_interval,
|
|
17444
|
-
_a$max_reconnects = _a.max_reconnects,
|
|
17445
|
-
max_reconnects = _a$max_reconnects === void 0 ? 5 : _a$max_reconnects,
|
|
17446
|
-
rest_options = __rest(_a, ["autoconnect", "reconnect", "reconnect_interval", "max_reconnects"]);
|
|
17447
|
-
|
|
17448
|
-
_this = _super.call(this);
|
|
17449
|
-
_this.webSocketFactory = webSocketFactory;
|
|
17450
|
-
_this.queue = {};
|
|
17451
|
-
_this.rpc_id = 0;
|
|
17452
|
-
_this.address = address;
|
|
17453
|
-
_this.autoconnect = autoconnect;
|
|
17454
|
-
_this.ready = false;
|
|
17455
|
-
_this.reconnect = reconnect;
|
|
17456
|
-
_this.reconnect_timer_id = undefined;
|
|
17457
|
-
_this.reconnect_interval = reconnect_interval;
|
|
17458
|
-
_this.max_reconnects = max_reconnects;
|
|
17459
|
-
_this.rest_options = rest_options;
|
|
17460
|
-
_this.current_reconnects = 0;
|
|
17461
|
-
|
|
17462
|
-
_this.generate_request_id = generate_request_id || function () {
|
|
17463
|
-
return ++_this.rpc_id;
|
|
17464
|
-
};
|
|
17465
16251
|
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
reconnect: _this.reconnect,
|
|
17469
|
-
reconnect_interval: _this.reconnect_interval,
|
|
17470
|
-
max_reconnects: _this.max_reconnects
|
|
17471
|
-
}, _this.rest_options));
|
|
17472
|
-
return _this;
|
|
16252
|
+
if (Object.getOwnPropertySymbols) {
|
|
16253
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
17473
16254
|
}
|
|
17474
|
-
/**
|
|
17475
|
-
* Connects to a defined server if not connected already.
|
|
17476
|
-
* @method
|
|
17477
|
-
* @return {Undefined}
|
|
17478
|
-
*/
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
(0, _createClass2["default"])(CommonClient, [{
|
|
17482
|
-
key: "connect",
|
|
17483
|
-
value: function connect() {
|
|
17484
|
-
if (this.socket) return;
|
|
17485
|
-
|
|
17486
|
-
this._connect(this.address, Object.assign({
|
|
17487
|
-
autoconnect: this.autoconnect,
|
|
17488
|
-
reconnect: this.reconnect,
|
|
17489
|
-
reconnect_interval: this.reconnect_interval,
|
|
17490
|
-
max_reconnects: this.max_reconnects
|
|
17491
|
-
}, this.rest_options));
|
|
17492
|
-
}
|
|
17493
|
-
/**
|
|
17494
|
-
* Calls a registered RPC method on server.
|
|
17495
|
-
* @method
|
|
17496
|
-
* @param {String} method - RPC method name
|
|
17497
|
-
* @param {Object|Array} params - optional method parameters
|
|
17498
|
-
* @param {Number} timeout - RPC reply timeout value
|
|
17499
|
-
* @param {Object} ws_opts - options passed to ws
|
|
17500
|
-
* @return {Promise}
|
|
17501
|
-
*/
|
|
17502
|
-
|
|
17503
|
-
}, {
|
|
17504
|
-
key: "call",
|
|
17505
|
-
value: function call(method, params, timeout, ws_opts) {
|
|
17506
|
-
var _this2 = this;
|
|
17507
|
-
|
|
17508
|
-
if (!ws_opts && "object" === (0, _typeof2["default"])(timeout)) {
|
|
17509
|
-
ws_opts = timeout;
|
|
17510
|
-
timeout = null;
|
|
17511
|
-
}
|
|
17512
16255
|
|
|
17513
|
-
|
|
17514
|
-
|
|
16256
|
+
return names;
|
|
16257
|
+
};
|
|
17515
16258
|
|
|
17516
|
-
|
|
16259
|
+
/**
|
|
16260
|
+
* Return the listeners registered for a given event.
|
|
16261
|
+
*
|
|
16262
|
+
* @param {(String|Symbol)} event The event name.
|
|
16263
|
+
* @returns {Array} The registered listeners.
|
|
16264
|
+
* @public
|
|
16265
|
+
*/
|
|
16266
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
16267
|
+
var evt = prefix ? prefix + event : event
|
|
16268
|
+
, handlers = this._events[evt];
|
|
17517
16269
|
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
method: method,
|
|
17521
|
-
params: params || null,
|
|
17522
|
-
id: rpc_id
|
|
17523
|
-
};
|
|
16270
|
+
if (!handlers) return [];
|
|
16271
|
+
if (handlers.fn) return [handlers.fn];
|
|
17524
16272
|
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
promise: [resolve, reject]
|
|
17529
|
-
};
|
|
17530
|
-
|
|
17531
|
-
if (timeout) {
|
|
17532
|
-
_this2.queue[rpc_id].timeout = setTimeout(function () {
|
|
17533
|
-
delete _this2.queue[rpc_id];
|
|
17534
|
-
reject(new Error("reply timeout"));
|
|
17535
|
-
}, timeout);
|
|
17536
|
-
}
|
|
17537
|
-
});
|
|
17538
|
-
});
|
|
17539
|
-
}
|
|
17540
|
-
/**
|
|
17541
|
-
* Logins with the other side of the connection.
|
|
17542
|
-
* @method
|
|
17543
|
-
* @param {Object} params - Login credentials object
|
|
17544
|
-
* @return {Promise}
|
|
17545
|
-
*/
|
|
17546
|
-
|
|
17547
|
-
}, {
|
|
17548
|
-
key: "login",
|
|
17549
|
-
value: function () {
|
|
17550
|
-
var _login = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(params) {
|
|
17551
|
-
var resp;
|
|
17552
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17553
|
-
while (1) {
|
|
17554
|
-
switch (_context.prev = _context.next) {
|
|
17555
|
-
case 0:
|
|
17556
|
-
_context.next = 2;
|
|
17557
|
-
return this.call("rpc.login", params);
|
|
17558
|
-
|
|
17559
|
-
case 2:
|
|
17560
|
-
resp = _context.sent;
|
|
17561
|
-
|
|
17562
|
-
if (resp) {
|
|
17563
|
-
_context.next = 5;
|
|
17564
|
-
break;
|
|
17565
|
-
}
|
|
17566
|
-
|
|
17567
|
-
throw new Error("authentication failed");
|
|
17568
|
-
|
|
17569
|
-
case 5:
|
|
17570
|
-
return _context.abrupt("return", resp);
|
|
17571
|
-
|
|
17572
|
-
case 6:
|
|
17573
|
-
case "end":
|
|
17574
|
-
return _context.stop();
|
|
17575
|
-
}
|
|
17576
|
-
}
|
|
17577
|
-
}, _callee, this);
|
|
17578
|
-
}));
|
|
17579
|
-
|
|
17580
|
-
function login(_x) {
|
|
17581
|
-
return _login.apply(this, arguments);
|
|
17582
|
-
}
|
|
16273
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
16274
|
+
ee[i] = handlers[i].fn;
|
|
16275
|
+
}
|
|
17583
16276
|
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
/**
|
|
17587
|
-
* Fetches a list of client's methods registered on server.
|
|
17588
|
-
* @method
|
|
17589
|
-
* @return {Array}
|
|
17590
|
-
*/
|
|
17591
|
-
|
|
17592
|
-
}, {
|
|
17593
|
-
key: "listMethods",
|
|
17594
|
-
value: function () {
|
|
17595
|
-
var _listMethods = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
17596
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
17597
|
-
while (1) {
|
|
17598
|
-
switch (_context2.prev = _context2.next) {
|
|
17599
|
-
case 0:
|
|
17600
|
-
_context2.next = 2;
|
|
17601
|
-
return this.call("__listMethods");
|
|
17602
|
-
|
|
17603
|
-
case 2:
|
|
17604
|
-
return _context2.abrupt("return", _context2.sent);
|
|
17605
|
-
|
|
17606
|
-
case 3:
|
|
17607
|
-
case "end":
|
|
17608
|
-
return _context2.stop();
|
|
17609
|
-
}
|
|
17610
|
-
}
|
|
17611
|
-
}, _callee2, this);
|
|
17612
|
-
}));
|
|
16277
|
+
return ee;
|
|
16278
|
+
};
|
|
17613
16279
|
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
16280
|
+
/**
|
|
16281
|
+
* Return the number of listeners listening to a given event.
|
|
16282
|
+
*
|
|
16283
|
+
* @param {(String|Symbol)} event The event name.
|
|
16284
|
+
* @returns {Number} The number of listeners.
|
|
16285
|
+
* @public
|
|
16286
|
+
*/
|
|
16287
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
16288
|
+
var evt = prefix ? prefix + event : event
|
|
16289
|
+
, listeners = this._events[evt];
|
|
17617
16290
|
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
* @method
|
|
17623
|
-
* @param {String} method - RPC method name
|
|
17624
|
-
* @param {Object} params - optional method parameters
|
|
17625
|
-
* @return {Promise}
|
|
17626
|
-
*/
|
|
17627
|
-
|
|
17628
|
-
}, {
|
|
17629
|
-
key: "notify",
|
|
17630
|
-
value: function notify(method, params) {
|
|
17631
|
-
var _this3 = this;
|
|
17632
|
-
|
|
17633
|
-
return new Promise(function (resolve, reject) {
|
|
17634
|
-
if (!_this3.ready) return reject(new Error("socket not ready"));
|
|
17635
|
-
var message = {
|
|
17636
|
-
jsonrpc: "2.0",
|
|
17637
|
-
method: method,
|
|
17638
|
-
params: params || null
|
|
17639
|
-
};
|
|
16291
|
+
if (!listeners) return 0;
|
|
16292
|
+
if (listeners.fn) return 1;
|
|
16293
|
+
return listeners.length;
|
|
16294
|
+
};
|
|
17640
16295
|
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
16296
|
+
/**
|
|
16297
|
+
* Calls each of the listeners registered for a given event.
|
|
16298
|
+
*
|
|
16299
|
+
* @param {(String|Symbol)} event The event name.
|
|
16300
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
16301
|
+
* @public
|
|
16302
|
+
*/
|
|
16303
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
16304
|
+
var evt = prefix ? prefix + event : event;
|
|
16305
|
+
|
|
16306
|
+
if (!this._events[evt]) return false;
|
|
16307
|
+
|
|
16308
|
+
var listeners = this._events[evt]
|
|
16309
|
+
, len = arguments.length
|
|
16310
|
+
, args
|
|
16311
|
+
, i;
|
|
16312
|
+
|
|
16313
|
+
if (listeners.fn) {
|
|
16314
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
16315
|
+
|
|
16316
|
+
switch (len) {
|
|
16317
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
16318
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
16319
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
16320
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
16321
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
16322
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
17646
16323
|
}
|
|
17647
|
-
/**
|
|
17648
|
-
* Subscribes for a defined event.
|
|
17649
|
-
* @method
|
|
17650
|
-
* @param {String|Array} event - event name
|
|
17651
|
-
* @return {Undefined}
|
|
17652
|
-
* @throws {Error}
|
|
17653
|
-
*/
|
|
17654
|
-
|
|
17655
|
-
}, {
|
|
17656
|
-
key: "subscribe",
|
|
17657
|
-
value: function () {
|
|
17658
|
-
var _subscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(event) {
|
|
17659
|
-
var result;
|
|
17660
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
17661
|
-
while (1) {
|
|
17662
|
-
switch (_context3.prev = _context3.next) {
|
|
17663
|
-
case 0:
|
|
17664
|
-
if (typeof event === "string") event = [event];
|
|
17665
|
-
_context3.next = 3;
|
|
17666
|
-
return this.call("rpc.on", event);
|
|
17667
|
-
|
|
17668
|
-
case 3:
|
|
17669
|
-
result = _context3.sent;
|
|
17670
|
-
|
|
17671
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17672
|
-
_context3.next = 6;
|
|
17673
|
-
break;
|
|
17674
|
-
}
|
|
17675
|
-
|
|
17676
|
-
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
17677
|
-
|
|
17678
|
-
case 6:
|
|
17679
|
-
return _context3.abrupt("return", result);
|
|
17680
|
-
|
|
17681
|
-
case 7:
|
|
17682
|
-
case "end":
|
|
17683
|
-
return _context3.stop();
|
|
17684
|
-
}
|
|
17685
|
-
}
|
|
17686
|
-
}, _callee3, this);
|
|
17687
|
-
}));
|
|
17688
|
-
|
|
17689
|
-
function subscribe(_x2) {
|
|
17690
|
-
return _subscribe.apply(this, arguments);
|
|
17691
|
-
}
|
|
17692
|
-
|
|
17693
|
-
return subscribe;
|
|
17694
|
-
}()
|
|
17695
|
-
/**
|
|
17696
|
-
* Unsubscribes from a defined event.
|
|
17697
|
-
* @method
|
|
17698
|
-
* @param {String|Array} event - event name
|
|
17699
|
-
* @return {Undefined}
|
|
17700
|
-
* @throws {Error}
|
|
17701
|
-
*/
|
|
17702
|
-
|
|
17703
|
-
}, {
|
|
17704
|
-
key: "unsubscribe",
|
|
17705
|
-
value: function () {
|
|
17706
|
-
var _unsubscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event) {
|
|
17707
|
-
var result;
|
|
17708
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
17709
|
-
while (1) {
|
|
17710
|
-
switch (_context4.prev = _context4.next) {
|
|
17711
|
-
case 0:
|
|
17712
|
-
if (typeof event === "string") event = [event];
|
|
17713
|
-
_context4.next = 3;
|
|
17714
|
-
return this.call("rpc.off", event);
|
|
17715
|
-
|
|
17716
|
-
case 3:
|
|
17717
|
-
result = _context4.sent;
|
|
17718
|
-
|
|
17719
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17720
|
-
_context4.next = 6;
|
|
17721
|
-
break;
|
|
17722
|
-
}
|
|
17723
|
-
|
|
17724
|
-
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
17725
|
-
|
|
17726
|
-
case 6:
|
|
17727
|
-
return _context4.abrupt("return", result);
|
|
17728
|
-
|
|
17729
|
-
case 7:
|
|
17730
|
-
case "end":
|
|
17731
|
-
return _context4.stop();
|
|
17732
|
-
}
|
|
17733
|
-
}
|
|
17734
|
-
}, _callee4, this);
|
|
17735
|
-
}));
|
|
17736
|
-
|
|
17737
|
-
function unsubscribe(_x3) {
|
|
17738
|
-
return _unsubscribe.apply(this, arguments);
|
|
17739
|
-
}
|
|
17740
16324
|
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
/**
|
|
17744
|
-
* Closes a WebSocket connection gracefully.
|
|
17745
|
-
* @method
|
|
17746
|
-
* @param {Number} code - socket close code
|
|
17747
|
-
* @param {String} data - optional data to be sent before closing
|
|
17748
|
-
* @return {Undefined}
|
|
17749
|
-
*/
|
|
17750
|
-
|
|
17751
|
-
}, {
|
|
17752
|
-
key: "close",
|
|
17753
|
-
value: function close(code, data) {
|
|
17754
|
-
this.socket.close(code || 1000, data);
|
|
16325
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
16326
|
+
args[i - 1] = arguments[i];
|
|
17755
16327
|
}
|
|
17756
|
-
/**
|
|
17757
|
-
* Connection/Message handler.
|
|
17758
|
-
* @method
|
|
17759
|
-
* @private
|
|
17760
|
-
* @param {String} address - WebSocket API address
|
|
17761
|
-
* @param {Object} options - ws options object
|
|
17762
|
-
* @return {Undefined}
|
|
17763
|
-
*/
|
|
17764
|
-
|
|
17765
|
-
}, {
|
|
17766
|
-
key: "_connect",
|
|
17767
|
-
value: function _connect(address, options) {
|
|
17768
|
-
var _this4 = this;
|
|
17769
|
-
|
|
17770
|
-
clearTimeout(this.reconnect_timer_id);
|
|
17771
|
-
this.socket = this.webSocketFactory(address, options);
|
|
17772
|
-
this.socket.addEventListener("open", function () {
|
|
17773
|
-
_this4.ready = true;
|
|
17774
|
-
|
|
17775
|
-
_this4.emit("open");
|
|
17776
|
-
|
|
17777
|
-
_this4.current_reconnects = 0;
|
|
17778
|
-
});
|
|
17779
|
-
this.socket.addEventListener("message", function (_ref) {
|
|
17780
|
-
var message = _ref.data;
|
|
17781
|
-
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
17782
|
-
|
|
17783
|
-
try {
|
|
17784
|
-
message = JSON.parse(message);
|
|
17785
|
-
} catch (error) {
|
|
17786
|
-
return;
|
|
17787
|
-
} // check if any listeners are attached and forward event
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
if (message.notification && _this4.listeners(message.notification).length) {
|
|
17791
|
-
if (!Object.keys(message.params).length) return _this4.emit(message.notification);
|
|
17792
|
-
var args = [message.notification];
|
|
17793
|
-
if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
|
|
17794
|
-
for (var i = 0; i < message.params.length; i++) {
|
|
17795
|
-
args.push(message.params[i]);
|
|
17796
|
-
} // run as microtask so that pending queue messages are resolved first
|
|
17797
|
-
// eslint-disable-next-line prefer-spread
|
|
17798
|
-
|
|
17799
|
-
return Promise.resolve().then(function () {
|
|
17800
|
-
_this4.emit.apply(_this4, args);
|
|
17801
|
-
});
|
|
17802
|
-
}
|
|
17803
16328
|
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
16329
|
+
listeners.fn.apply(listeners.context, args);
|
|
16330
|
+
} else {
|
|
16331
|
+
var length = listeners.length
|
|
16332
|
+
, j;
|
|
16333
|
+
|
|
16334
|
+
for (i = 0; i < length; i++) {
|
|
16335
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
16336
|
+
|
|
16337
|
+
switch (len) {
|
|
16338
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
16339
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
16340
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
16341
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
16342
|
+
default:
|
|
16343
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
16344
|
+
args[j - 1] = arguments[j];
|
|
17811
16345
|
}
|
|
17812
16346
|
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
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."));
|
|
17818
|
-
if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
|
|
17819
|
-
if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
|
|
17820
|
-
delete _this4.queue[message.id];
|
|
17821
|
-
});
|
|
17822
|
-
this.socket.addEventListener("error", function (error) {
|
|
17823
|
-
return _this4.emit("error", error);
|
|
17824
|
-
});
|
|
17825
|
-
this.socket.addEventListener("close", function (_ref2) {
|
|
17826
|
-
var code = _ref2.code,
|
|
17827
|
-
reason = _ref2.reason;
|
|
17828
|
-
if (_this4.ready) // Delay close event until internal state is updated
|
|
17829
|
-
setTimeout(function () {
|
|
17830
|
-
return _this4.emit("close", code, reason);
|
|
17831
|
-
}, 0);
|
|
17832
|
-
_this4.ready = false;
|
|
17833
|
-
_this4.socket = undefined;
|
|
17834
|
-
if (code === 1000) return;
|
|
17835
|
-
_this4.current_reconnects++;
|
|
17836
|
-
if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) _this4.reconnect_timer_id = setTimeout(function () {
|
|
17837
|
-
return _this4._connect(address, options);
|
|
17838
|
-
}, _this4.reconnect_interval);
|
|
17839
|
-
});
|
|
16347
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
16348
|
+
}
|
|
17840
16349
|
}
|
|
17841
|
-
}
|
|
17842
|
-
return CommonClient;
|
|
17843
|
-
}(_eventemitter.EventEmitter);
|
|
17844
|
-
|
|
17845
|
-
exports["default"] = CommonClient;
|
|
17846
|
-
} (client));
|
|
17847
|
-
|
|
17848
|
-
var RpcWebSocketCommonClient = /*@__PURE__*/getDefaultExportFromCjs(client);
|
|
17849
|
-
|
|
17850
|
-
var websocket_browser = {};
|
|
17851
|
-
|
|
17852
|
-
/**
|
|
17853
|
-
* WebSocket implements a browser-side WebSocket specification.
|
|
17854
|
-
* @module Client
|
|
17855
|
-
*/
|
|
17856
|
-
|
|
17857
|
-
(function (exports) {
|
|
17858
|
-
|
|
17859
|
-
var _interopRequireDefault = interopRequireDefaultExports;
|
|
17860
|
-
|
|
17861
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17862
|
-
value: true
|
|
17863
|
-
});
|
|
17864
|
-
exports["default"] = _default;
|
|
17865
|
-
|
|
17866
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
16350
|
+
}
|
|
17867
16351
|
|
|
17868
|
-
|
|
16352
|
+
return true;
|
|
16353
|
+
};
|
|
17869
16354
|
|
|
17870
|
-
|
|
16355
|
+
/**
|
|
16356
|
+
* Add a listener for a given event.
|
|
16357
|
+
*
|
|
16358
|
+
* @param {(String|Symbol)} event The event name.
|
|
16359
|
+
* @param {Function} fn The listener function.
|
|
16360
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16361
|
+
* @returns {EventEmitter} `this`.
|
|
16362
|
+
* @public
|
|
16363
|
+
*/
|
|
16364
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
16365
|
+
return addListener(this, event, fn, context, false);
|
|
16366
|
+
};
|
|
17871
16367
|
|
|
17872
|
-
|
|
16368
|
+
/**
|
|
16369
|
+
* Add a one-time listener for a given event.
|
|
16370
|
+
*
|
|
16371
|
+
* @param {(String|Symbol)} event The event name.
|
|
16372
|
+
* @param {Function} fn The listener function.
|
|
16373
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16374
|
+
* @returns {EventEmitter} `this`.
|
|
16375
|
+
* @public
|
|
16376
|
+
*/
|
|
16377
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
16378
|
+
return addListener(this, event, fn, context, true);
|
|
16379
|
+
};
|
|
17873
16380
|
|
|
17874
|
-
|
|
16381
|
+
/**
|
|
16382
|
+
* Remove the listeners of a given event.
|
|
16383
|
+
*
|
|
16384
|
+
* @param {(String|Symbol)} event The event name.
|
|
16385
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
16386
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
16387
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
16388
|
+
* @returns {EventEmitter} `this`.
|
|
16389
|
+
* @public
|
|
16390
|
+
*/
|
|
16391
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
16392
|
+
var evt = prefix ? prefix + event : event;
|
|
17875
16393
|
|
|
17876
|
-
|
|
16394
|
+
if (!this._events[evt]) return this;
|
|
16395
|
+
if (!fn) {
|
|
16396
|
+
clearEvent(this, evt);
|
|
16397
|
+
return this;
|
|
16398
|
+
}
|
|
17877
16399
|
|
|
17878
|
-
|
|
16400
|
+
var listeners = this._events[evt];
|
|
17879
16401
|
|
|
17880
|
-
|
|
16402
|
+
if (listeners.fn) {
|
|
16403
|
+
if (
|
|
16404
|
+
listeners.fn === fn &&
|
|
16405
|
+
(!once || listeners.once) &&
|
|
16406
|
+
(!context || listeners.context === context)
|
|
16407
|
+
) {
|
|
16408
|
+
clearEvent(this, evt);
|
|
16409
|
+
}
|
|
16410
|
+
} else {
|
|
16411
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
16412
|
+
if (
|
|
16413
|
+
listeners[i].fn !== fn ||
|
|
16414
|
+
(once && !listeners[i].once) ||
|
|
16415
|
+
(context && listeners[i].context !== context)
|
|
16416
|
+
) {
|
|
16417
|
+
events.push(listeners[i]);
|
|
16418
|
+
}
|
|
16419
|
+
}
|
|
17881
16420
|
|
|
17882
|
-
|
|
17883
|
-
|
|
16421
|
+
//
|
|
16422
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
16423
|
+
//
|
|
16424
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
16425
|
+
else clearEvent(this, evt);
|
|
16426
|
+
}
|
|
17884
16427
|
|
|
17885
|
-
|
|
16428
|
+
return this;
|
|
16429
|
+
};
|
|
17886
16430
|
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
16431
|
+
/**
|
|
16432
|
+
* Remove all listeners, or those of the specified event.
|
|
16433
|
+
*
|
|
16434
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
16435
|
+
* @returns {EventEmitter} `this`.
|
|
16436
|
+
* @public
|
|
16437
|
+
*/
|
|
16438
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
16439
|
+
var evt;
|
|
17896
16440
|
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
16441
|
+
if (event) {
|
|
16442
|
+
evt = prefix ? prefix + event : event;
|
|
16443
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
16444
|
+
} else {
|
|
16445
|
+
this._events = new Events();
|
|
16446
|
+
this._eventsCount = 0;
|
|
16447
|
+
}
|
|
17900
16448
|
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
};
|
|
16449
|
+
return this;
|
|
16450
|
+
};
|
|
17904
16451
|
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
16452
|
+
//
|
|
16453
|
+
// Alias methods names because people roll like that.
|
|
16454
|
+
//
|
|
16455
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
16456
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
17908
16457
|
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
16458
|
+
//
|
|
16459
|
+
// Expose the prefix.
|
|
16460
|
+
//
|
|
16461
|
+
EventEmitter.prefixed = prefix;
|
|
17912
16462
|
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
16463
|
+
//
|
|
16464
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
16465
|
+
//
|
|
16466
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
17916
16467
|
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
* @param {(Object)} options - websocket options
|
|
17968
|
-
* @return {Undefined}
|
|
17969
|
-
*/
|
|
16468
|
+
//
|
|
16469
|
+
// Expose the module.
|
|
16470
|
+
//
|
|
16471
|
+
{
|
|
16472
|
+
module.exports = EventEmitter;
|
|
16473
|
+
}
|
|
16474
|
+
} (eventemitter3));
|
|
16475
|
+
|
|
16476
|
+
var eventemitter3Exports = eventemitter3.exports;
|
|
16477
|
+
|
|
16478
|
+
var utils = {};
|
|
16479
|
+
|
|
16480
|
+
Object.defineProperty(utils, "__esModule", { value: true });
|
|
16481
|
+
utils.createError = utils.DefaultDataPack = void 0;
|
|
16482
|
+
const errors = new Map([
|
|
16483
|
+
[-32000, "Event not provided"],
|
|
16484
|
+
[-32600, "Invalid Request"],
|
|
16485
|
+
[-32601, "Method not found"],
|
|
16486
|
+
[-32602, "Invalid params"],
|
|
16487
|
+
[-32603, "Internal error"],
|
|
16488
|
+
[-32604, "Params not found"],
|
|
16489
|
+
[-32605, "Method forbidden"],
|
|
16490
|
+
[-32606, "Event forbidden"],
|
|
16491
|
+
[-32700, "Parse error"]
|
|
16492
|
+
]);
|
|
16493
|
+
class DefaultDataPack {
|
|
16494
|
+
encode(value) {
|
|
16495
|
+
return JSON.stringify(value);
|
|
16496
|
+
}
|
|
16497
|
+
decode(value) {
|
|
16498
|
+
return JSON.parse(value);
|
|
16499
|
+
}
|
|
16500
|
+
}
|
|
16501
|
+
utils.DefaultDataPack = DefaultDataPack;
|
|
16502
|
+
/**
|
|
16503
|
+
* Creates a JSON-RPC 2.0-compliant error.
|
|
16504
|
+
* @param {Number} code - error code
|
|
16505
|
+
* @param {String} details - error details
|
|
16506
|
+
* @return {Object}
|
|
16507
|
+
*/
|
|
16508
|
+
function createError(code, details) {
|
|
16509
|
+
const error = {
|
|
16510
|
+
code: code,
|
|
16511
|
+
message: errors.get(code) || "Internal Server Error"
|
|
16512
|
+
};
|
|
16513
|
+
if (details)
|
|
16514
|
+
error["data"] = details;
|
|
16515
|
+
return error;
|
|
16516
|
+
}
|
|
16517
|
+
utils.createError = createError;
|
|
17970
16518
|
|
|
16519
|
+
/**
|
|
16520
|
+
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
16521
|
+
* according to the environment providing JSON RPC 2.0 support on top.
|
|
16522
|
+
* @module Client
|
|
16523
|
+
*/
|
|
16524
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
16525
|
+
// @ts-ignore
|
|
16526
|
+
const eventemitter3_1$1 = eventemitter3Exports;
|
|
16527
|
+
const utils_cjs_1 = utils;
|
|
16528
|
+
class CommonClient extends eventemitter3_1$1.EventEmitter {
|
|
16529
|
+
address;
|
|
16530
|
+
rpc_id;
|
|
16531
|
+
queue;
|
|
16532
|
+
options;
|
|
16533
|
+
autoconnect;
|
|
16534
|
+
ready;
|
|
16535
|
+
reconnect;
|
|
16536
|
+
reconnect_timer_id;
|
|
16537
|
+
reconnect_interval;
|
|
16538
|
+
max_reconnects;
|
|
16539
|
+
rest_options;
|
|
16540
|
+
current_reconnects;
|
|
16541
|
+
generate_request_id;
|
|
16542
|
+
socket;
|
|
16543
|
+
webSocketFactory;
|
|
16544
|
+
dataPack;
|
|
16545
|
+
/**
|
|
16546
|
+
* Instantiate a Client class.
|
|
16547
|
+
* @constructor
|
|
16548
|
+
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
16549
|
+
* @param {String} address - url to a websocket server
|
|
16550
|
+
* @param {Object} options - ws options object with reconnect parameters
|
|
16551
|
+
* @param {Function} generate_request_id - custom generation request Id
|
|
16552
|
+
* @param {DataPack} dataPack - data pack contains encoder and decoder
|
|
16553
|
+
* @return {CommonClient}
|
|
16554
|
+
*/
|
|
16555
|
+
constructor(webSocketFactory, address = "ws://localhost:8080", { autoconnect = true, reconnect = true, reconnect_interval = 1000, max_reconnects = 5, ...rest_options } = {}, generate_request_id, dataPack) {
|
|
16556
|
+
super();
|
|
16557
|
+
this.webSocketFactory = webSocketFactory;
|
|
16558
|
+
this.queue = {};
|
|
16559
|
+
this.rpc_id = 0;
|
|
16560
|
+
this.address = address;
|
|
16561
|
+
this.autoconnect = autoconnect;
|
|
16562
|
+
this.ready = false;
|
|
16563
|
+
this.reconnect = reconnect;
|
|
16564
|
+
this.reconnect_timer_id = undefined;
|
|
16565
|
+
this.reconnect_interval = reconnect_interval;
|
|
16566
|
+
this.max_reconnects = max_reconnects;
|
|
16567
|
+
this.rest_options = rest_options;
|
|
16568
|
+
this.current_reconnects = 0;
|
|
16569
|
+
this.generate_request_id = generate_request_id || (() => ++this.rpc_id);
|
|
16570
|
+
if (!dataPack)
|
|
16571
|
+
this.dataPack = new utils_cjs_1.DefaultDataPack();
|
|
16572
|
+
else
|
|
16573
|
+
this.dataPack = dataPack;
|
|
16574
|
+
if (this.autoconnect)
|
|
16575
|
+
this._connect(this.address, {
|
|
16576
|
+
autoconnect: this.autoconnect,
|
|
16577
|
+
reconnect: this.reconnect,
|
|
16578
|
+
reconnect_interval: this.reconnect_interval,
|
|
16579
|
+
max_reconnects: this.max_reconnects,
|
|
16580
|
+
...this.rest_options
|
|
16581
|
+
});
|
|
16582
|
+
}
|
|
16583
|
+
/**
|
|
16584
|
+
* Connects to a defined server if not connected already.
|
|
16585
|
+
* @method
|
|
16586
|
+
* @return {Undefined}
|
|
16587
|
+
*/
|
|
16588
|
+
connect() {
|
|
16589
|
+
if (this.socket)
|
|
16590
|
+
return;
|
|
16591
|
+
this._connect(this.address, {
|
|
16592
|
+
autoconnect: this.autoconnect,
|
|
16593
|
+
reconnect: this.reconnect,
|
|
16594
|
+
reconnect_interval: this.reconnect_interval,
|
|
16595
|
+
max_reconnects: this.max_reconnects,
|
|
16596
|
+
...this.rest_options
|
|
16597
|
+
});
|
|
16598
|
+
}
|
|
16599
|
+
/**
|
|
16600
|
+
* Calls a registered RPC method on server.
|
|
16601
|
+
* @method
|
|
16602
|
+
* @param {String} method - RPC method name
|
|
16603
|
+
* @param {Object|Array} params - optional method parameters
|
|
16604
|
+
* @param {Number} timeout - RPC reply timeout value
|
|
16605
|
+
* @param {Object} ws_opts - options passed to ws
|
|
16606
|
+
* @return {Promise}
|
|
16607
|
+
*/
|
|
16608
|
+
call(method, params, timeout, ws_opts) {
|
|
16609
|
+
if (!ws_opts && "object" === typeof timeout) {
|
|
16610
|
+
ws_opts = timeout;
|
|
16611
|
+
timeout = null;
|
|
16612
|
+
}
|
|
16613
|
+
return new Promise((resolve, reject) => {
|
|
16614
|
+
if (!this.ready)
|
|
16615
|
+
return reject(new Error("socket not ready"));
|
|
16616
|
+
const rpc_id = this.generate_request_id(method, params);
|
|
16617
|
+
const message = {
|
|
16618
|
+
jsonrpc: "2.0",
|
|
16619
|
+
method: method,
|
|
16620
|
+
params: params || undefined,
|
|
16621
|
+
id: rpc_id
|
|
16622
|
+
};
|
|
16623
|
+
this.socket.send(this.dataPack.encode(message), ws_opts, (error) => {
|
|
16624
|
+
if (error)
|
|
16625
|
+
return reject(error);
|
|
16626
|
+
this.queue[rpc_id] = { promise: [resolve, reject] };
|
|
16627
|
+
if (timeout) {
|
|
16628
|
+
this.queue[rpc_id].timeout = setTimeout(() => {
|
|
16629
|
+
delete this.queue[rpc_id];
|
|
16630
|
+
reject(new Error("reply timeout"));
|
|
16631
|
+
}, timeout);
|
|
16632
|
+
}
|
|
16633
|
+
});
|
|
16634
|
+
});
|
|
16635
|
+
}
|
|
16636
|
+
/**
|
|
16637
|
+
* Logins with the other side of the connection.
|
|
16638
|
+
* @method
|
|
16639
|
+
* @param {Object} params - Login credentials object
|
|
16640
|
+
* @return {Promise}
|
|
16641
|
+
*/
|
|
16642
|
+
async login(params) {
|
|
16643
|
+
const resp = await this.call("rpc.login", params);
|
|
16644
|
+
if (!resp)
|
|
16645
|
+
throw new Error("authentication failed");
|
|
16646
|
+
return resp;
|
|
16647
|
+
}
|
|
16648
|
+
/**
|
|
16649
|
+
* Fetches a list of client's methods registered on server.
|
|
16650
|
+
* @method
|
|
16651
|
+
* @return {Array}
|
|
16652
|
+
*/
|
|
16653
|
+
async listMethods() {
|
|
16654
|
+
return await this.call("__listMethods");
|
|
16655
|
+
}
|
|
16656
|
+
/**
|
|
16657
|
+
* Sends a JSON-RPC 2.0 notification to server.
|
|
16658
|
+
* @method
|
|
16659
|
+
* @param {String} method - RPC method name
|
|
16660
|
+
* @param {Object} params - optional method parameters
|
|
16661
|
+
* @return {Promise}
|
|
16662
|
+
*/
|
|
16663
|
+
notify(method, params) {
|
|
16664
|
+
return new Promise((resolve, reject) => {
|
|
16665
|
+
if (!this.ready)
|
|
16666
|
+
return reject(new Error("socket not ready"));
|
|
16667
|
+
const message = {
|
|
16668
|
+
jsonrpc: "2.0",
|
|
16669
|
+
method: method,
|
|
16670
|
+
params
|
|
16671
|
+
};
|
|
16672
|
+
this.socket.send(this.dataPack.encode(message), (error) => {
|
|
16673
|
+
if (error)
|
|
16674
|
+
return reject(error);
|
|
16675
|
+
resolve();
|
|
16676
|
+
});
|
|
16677
|
+
});
|
|
16678
|
+
}
|
|
16679
|
+
/**
|
|
16680
|
+
* Subscribes for a defined event.
|
|
16681
|
+
* @method
|
|
16682
|
+
* @param {String|Array} event - event name
|
|
16683
|
+
* @return {Undefined}
|
|
16684
|
+
* @throws {Error}
|
|
16685
|
+
*/
|
|
16686
|
+
async subscribe(event) {
|
|
16687
|
+
if (typeof event === "string")
|
|
16688
|
+
event = [event];
|
|
16689
|
+
const result = await this.call("rpc.on", event);
|
|
16690
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16691
|
+
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
16692
|
+
return result;
|
|
16693
|
+
}
|
|
16694
|
+
/**
|
|
16695
|
+
* Unsubscribes from a defined event.
|
|
16696
|
+
* @method
|
|
16697
|
+
* @param {String|Array} event - event name
|
|
16698
|
+
* @return {Undefined}
|
|
16699
|
+
* @throws {Error}
|
|
16700
|
+
*/
|
|
16701
|
+
async unsubscribe(event) {
|
|
16702
|
+
if (typeof event === "string")
|
|
16703
|
+
event = [event];
|
|
16704
|
+
const result = await this.call("rpc.off", event);
|
|
16705
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16706
|
+
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
16707
|
+
return result;
|
|
16708
|
+
}
|
|
16709
|
+
/**
|
|
16710
|
+
* Closes a WebSocket connection gracefully.
|
|
16711
|
+
* @method
|
|
16712
|
+
* @param {Number} code - socket close code
|
|
16713
|
+
* @param {String} data - optional data to be sent before closing
|
|
16714
|
+
* @return {Undefined}
|
|
16715
|
+
*/
|
|
16716
|
+
close(code, data) {
|
|
16717
|
+
this.socket.close(code || 1000, data);
|
|
16718
|
+
}
|
|
16719
|
+
/**
|
|
16720
|
+
* Enable / disable automatic reconnection.
|
|
16721
|
+
* @method
|
|
16722
|
+
* @param {Boolean} reconnect - enable / disable reconnection
|
|
16723
|
+
* @return {Undefined}
|
|
16724
|
+
*/
|
|
16725
|
+
setAutoReconnect(reconnect) {
|
|
16726
|
+
this.reconnect = reconnect;
|
|
16727
|
+
}
|
|
16728
|
+
/**
|
|
16729
|
+
* Set the interval between reconnection attempts.
|
|
16730
|
+
* @method
|
|
16731
|
+
* @param {Number} interval - reconnection interval in milliseconds
|
|
16732
|
+
* @return {Undefined}
|
|
16733
|
+
*/
|
|
16734
|
+
setReconnectInterval(interval) {
|
|
16735
|
+
this.reconnect_interval = interval;
|
|
16736
|
+
}
|
|
16737
|
+
/**
|
|
16738
|
+
* Set the maximum number of reconnection attempts.
|
|
16739
|
+
* @method
|
|
16740
|
+
* @param {Number} max_reconnects - maximum reconnection attempts
|
|
16741
|
+
* @return {Undefined}
|
|
16742
|
+
*/
|
|
16743
|
+
setMaxReconnects(max_reconnects) {
|
|
16744
|
+
this.max_reconnects = max_reconnects;
|
|
16745
|
+
}
|
|
16746
|
+
/**
|
|
16747
|
+
* Connection/Message handler.
|
|
16748
|
+
* @method
|
|
16749
|
+
* @private
|
|
16750
|
+
* @param {String} address - WebSocket API address
|
|
16751
|
+
* @param {Object} options - ws options object
|
|
16752
|
+
* @return {Undefined}
|
|
16753
|
+
*/
|
|
16754
|
+
_connect(address, options) {
|
|
16755
|
+
clearTimeout(this.reconnect_timer_id);
|
|
16756
|
+
this.socket = this.webSocketFactory(address, options);
|
|
16757
|
+
this.socket.addEventListener("open", () => {
|
|
16758
|
+
this.ready = true;
|
|
16759
|
+
this.emit("open");
|
|
16760
|
+
this.current_reconnects = 0;
|
|
16761
|
+
});
|
|
16762
|
+
this.socket.addEventListener("message", ({ data: message }) => {
|
|
16763
|
+
if (message instanceof ArrayBuffer)
|
|
16764
|
+
message = Buffer.from(message).toString();
|
|
16765
|
+
try {
|
|
16766
|
+
message = this.dataPack.decode(message);
|
|
16767
|
+
}
|
|
16768
|
+
catch (error) {
|
|
16769
|
+
return;
|
|
16770
|
+
}
|
|
16771
|
+
// check if any listeners are attached and forward event
|
|
16772
|
+
if (message.notification && this.listeners(message.notification).length) {
|
|
16773
|
+
if (!Object.keys(message.params).length)
|
|
16774
|
+
return this.emit(message.notification);
|
|
16775
|
+
const args = [message.notification];
|
|
16776
|
+
if (message.params.constructor === Object)
|
|
16777
|
+
args.push(message.params);
|
|
16778
|
+
else
|
|
16779
|
+
// using for-loop instead of unshift/spread because performance is better
|
|
16780
|
+
for (let i = 0; i < message.params.length; i++)
|
|
16781
|
+
args.push(message.params[i]);
|
|
16782
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16783
|
+
// eslint-disable-next-line prefer-spread
|
|
16784
|
+
return Promise.resolve().then(() => { this.emit.apply(this, args); });
|
|
16785
|
+
}
|
|
16786
|
+
if (!this.queue[message.id]) {
|
|
16787
|
+
// general JSON RPC 2.0 events
|
|
16788
|
+
if (message.method) {
|
|
16789
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16790
|
+
return Promise.resolve().then(() => {
|
|
16791
|
+
this.emit(message.method, message?.params);
|
|
16792
|
+
});
|
|
16793
|
+
}
|
|
16794
|
+
return;
|
|
16795
|
+
}
|
|
16796
|
+
// reject early since server's response is invalid
|
|
16797
|
+
if ("error" in message === "result" in message)
|
|
16798
|
+
this.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" +
|
|
16799
|
+
" or \"error\", but not both."));
|
|
16800
|
+
if (this.queue[message.id].timeout)
|
|
16801
|
+
clearTimeout(this.queue[message.id].timeout);
|
|
16802
|
+
if (message.error)
|
|
16803
|
+
this.queue[message.id].promise[1](message.error);
|
|
16804
|
+
else
|
|
16805
|
+
this.queue[message.id].promise[0](message.result);
|
|
16806
|
+
delete this.queue[message.id];
|
|
16807
|
+
});
|
|
16808
|
+
this.socket.addEventListener("error", (error) => this.emit("error", error));
|
|
16809
|
+
this.socket.addEventListener("close", ({ code, reason }) => {
|
|
16810
|
+
if (this.ready) // Delay close event until internal state is updated
|
|
16811
|
+
setTimeout(() => this.emit("close", code, reason), 0);
|
|
16812
|
+
this.ready = false;
|
|
16813
|
+
this.socket = undefined;
|
|
16814
|
+
if (code === 1000)
|
|
16815
|
+
return;
|
|
16816
|
+
this.current_reconnects++;
|
|
16817
|
+
if (this.reconnect && ((this.max_reconnects > this.current_reconnects) ||
|
|
16818
|
+
this.max_reconnects === 0))
|
|
16819
|
+
this.reconnect_timer_id = setTimeout(() => this._connect(address, options), this.reconnect_interval);
|
|
16820
|
+
});
|
|
16821
|
+
}
|
|
16822
|
+
}
|
|
16823
|
+
var _default$1 = client.default = CommonClient;
|
|
17971
16824
|
|
|
17972
|
-
|
|
17973
|
-
return new WebSocketBrowserImpl(address, options);
|
|
17974
|
-
}
|
|
17975
|
-
} (websocket_browser));
|
|
16825
|
+
var websocket_browser = {};
|
|
17976
16826
|
|
|
17977
|
-
|
|
16827
|
+
/**
|
|
16828
|
+
* WebSocket implements a browser-side WebSocket specification.
|
|
16829
|
+
* @module Client
|
|
16830
|
+
*/
|
|
16831
|
+
Object.defineProperty(websocket_browser, "__esModule", { value: true });
|
|
16832
|
+
const eventemitter3_1 = eventemitter3Exports;
|
|
16833
|
+
class WebSocketBrowserImpl extends eventemitter3_1.EventEmitter {
|
|
16834
|
+
socket;
|
|
16835
|
+
/** Instantiate a WebSocket class
|
|
16836
|
+
* @constructor
|
|
16837
|
+
* @param {String} address - url to a websocket server
|
|
16838
|
+
* @param {(Object)} options - websocket options
|
|
16839
|
+
* @param {(String|Array)} protocols - a list of protocols
|
|
16840
|
+
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
16841
|
+
*/
|
|
16842
|
+
constructor(address, options, protocols) {
|
|
16843
|
+
super();
|
|
16844
|
+
this.socket = new window.WebSocket(address, protocols);
|
|
16845
|
+
this.socket.onopen = () => this.emit("open");
|
|
16846
|
+
this.socket.onmessage = (event) => this.emit("message", event.data);
|
|
16847
|
+
this.socket.onerror = (error) => this.emit("error", error);
|
|
16848
|
+
this.socket.onclose = (event) => {
|
|
16849
|
+
this.emit("close", event.code, event.reason);
|
|
16850
|
+
};
|
|
16851
|
+
}
|
|
16852
|
+
/**
|
|
16853
|
+
* Sends data through a websocket connection
|
|
16854
|
+
* @method
|
|
16855
|
+
* @param {(String|Object)} data - data to be sent via websocket
|
|
16856
|
+
* @param {Object} optionsOrCallback - ws options
|
|
16857
|
+
* @param {Function} callback - a callback called once the data is sent
|
|
16858
|
+
* @return {Undefined}
|
|
16859
|
+
*/
|
|
16860
|
+
send(data, optionsOrCallback, callback) {
|
|
16861
|
+
const cb = callback || optionsOrCallback;
|
|
16862
|
+
try {
|
|
16863
|
+
this.socket.send(data);
|
|
16864
|
+
cb();
|
|
16865
|
+
}
|
|
16866
|
+
catch (error) {
|
|
16867
|
+
cb(error);
|
|
16868
|
+
}
|
|
16869
|
+
}
|
|
16870
|
+
/**
|
|
16871
|
+
* Closes an underlying socket
|
|
16872
|
+
* @method
|
|
16873
|
+
* @param {Number} code - status code explaining why the connection is being closed
|
|
16874
|
+
* @param {String} reason - a description why the connection is closing
|
|
16875
|
+
* @return {Undefined}
|
|
16876
|
+
* @throws {Error}
|
|
16877
|
+
*/
|
|
16878
|
+
close(code, reason) {
|
|
16879
|
+
this.socket.close(code, reason);
|
|
16880
|
+
}
|
|
16881
|
+
addEventListener(type, listener, options) {
|
|
16882
|
+
this.socket.addEventListener(type, listener, options);
|
|
16883
|
+
}
|
|
16884
|
+
}
|
|
16885
|
+
/**
|
|
16886
|
+
* factory method for common WebSocket instance
|
|
16887
|
+
* @method
|
|
16888
|
+
* @param {String} address - url to a websocket server
|
|
16889
|
+
* @param {(Object)} options - websocket options
|
|
16890
|
+
* @return {Undefined}
|
|
16891
|
+
*/
|
|
16892
|
+
function default_1(address, options) {
|
|
16893
|
+
return new WebSocketBrowserImpl(address, options);
|
|
16894
|
+
}
|
|
16895
|
+
var _default = websocket_browser.default = default_1;
|
|
17978
16896
|
|
|
17979
|
-
class RpcWebSocketClient extends
|
|
16897
|
+
class RpcWebSocketClient extends _default$1 {
|
|
17980
16898
|
constructor(address, options, generate_request_id) {
|
|
17981
16899
|
const webSocketFactory = url => {
|
|
17982
|
-
const rpc =
|
|
16900
|
+
const rpc = _default(url, {
|
|
17983
16901
|
autoconnect: true,
|
|
17984
16902
|
max_reconnects: 5,
|
|
17985
16903
|
reconnect: true,
|
|
@@ -18085,7 +17003,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18085
17003
|
const websocketPort =
|
|
18086
17004
|
// Only shift the port by +1 as a convention for ws(s) only if given endpoint
|
|
18087
17005
|
// is explicitly specifying the endpoint port (HTTP-based RPC), assuming
|
|
18088
|
-
// we're directly trying to connect to
|
|
17006
|
+
// we're directly trying to connect to agave-validator's ws listening port.
|
|
18089
17007
|
// When the endpoint omits the port, we're connecting to the protocol
|
|
18090
17008
|
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
|
18091
17009
|
// proxy which manages WebSocket upgrade and backend port redirection.
|
|
@@ -23172,34 +22090,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23172
22090
|
}
|
|
23173
22091
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
23174
22092
|
|
|
23175
|
-
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
23176
|
-
const _32n = /* @__PURE__ */ BigInt(32);
|
|
23177
|
-
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
23178
|
-
function fromBig(n, le = false) {
|
|
23179
|
-
if (le)
|
|
23180
|
-
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
23181
|
-
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
23182
|
-
}
|
|
23183
|
-
function split(lst, le = false) {
|
|
23184
|
-
let Ah = new Uint32Array(lst.length);
|
|
23185
|
-
let Al = new Uint32Array(lst.length);
|
|
23186
|
-
for (let i = 0; i < lst.length; i++) {
|
|
23187
|
-
const { h, l } = fromBig(lst[i], le);
|
|
23188
|
-
[Ah[i], Al[i]] = [h, l];
|
|
23189
|
-
}
|
|
23190
|
-
return [Ah, Al];
|
|
23191
|
-
}
|
|
23192
|
-
// Left rotate for Shift in [1, 32)
|
|
23193
|
-
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
23194
|
-
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
23195
|
-
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
23196
|
-
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
23197
|
-
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
23198
|
-
|
|
23199
22093
|
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
|
23200
22094
|
// It's called a sponge function.
|
|
23201
22095
|
// Various per round constants calculations
|
|
23202
|
-
const
|
|
22096
|
+
const SHA3_PI = [];
|
|
22097
|
+
const SHA3_ROTL = [];
|
|
22098
|
+
const _SHA3_IOTA = [];
|
|
23203
22099
|
const _0n$1 = /* @__PURE__ */ BigInt(0);
|
|
23204
22100
|
const _1n$2 = /* @__PURE__ */ BigInt(1);
|
|
23205
22101
|
const _2n$1 = /* @__PURE__ */ BigInt(2);
|
|
@@ -23293,7 +22189,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
23293
22189
|
this.state32 = u32$1(this.state);
|
|
23294
22190
|
}
|
|
23295
22191
|
keccak() {
|
|
22192
|
+
if (!isLE)
|
|
22193
|
+
byteSwap32(this.state32);
|
|
23296
22194
|
keccakP(this.state32, this.rounds);
|
|
22195
|
+
if (!isLE)
|
|
22196
|
+
byteSwap32(this.state32);
|
|
23297
22197
|
this.posOut = 0;
|
|
23298
22198
|
this.pos = 0;
|
|
23299
22199
|
}
|
|
@@ -23387,111 +22287,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
23387
22287
|
*/
|
|
23388
22288
|
const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
|
|
23389
22289
|
|
|
23390
|
-
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
23391
|
-
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
23392
|
-
// Round constants:
|
|
23393
|
-
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
23394
|
-
// prettier-ignore
|
|
23395
|
-
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
23396
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
23397
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
23398
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
23399
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
23400
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
23401
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
23402
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
23403
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
23404
|
-
]);
|
|
23405
|
-
// Initial state:
|
|
23406
|
-
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
23407
|
-
// prettier-ignore
|
|
23408
|
-
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
23409
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
23410
|
-
]);
|
|
23411
|
-
// Temporary buffer, not used to store anything between runs
|
|
23412
|
-
// Named this way because it matches specification.
|
|
23413
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
23414
|
-
class SHA256 extends HashMD {
|
|
23415
|
-
constructor() {
|
|
23416
|
-
super(64, 32, 8, false);
|
|
23417
|
-
// We cannot use array here since array allows indexing by variable
|
|
23418
|
-
// which means optimizer/compiler cannot use registers.
|
|
23419
|
-
this.A = SHA256_IV[0] | 0;
|
|
23420
|
-
this.B = SHA256_IV[1] | 0;
|
|
23421
|
-
this.C = SHA256_IV[2] | 0;
|
|
23422
|
-
this.D = SHA256_IV[3] | 0;
|
|
23423
|
-
this.E = SHA256_IV[4] | 0;
|
|
23424
|
-
this.F = SHA256_IV[5] | 0;
|
|
23425
|
-
this.G = SHA256_IV[6] | 0;
|
|
23426
|
-
this.H = SHA256_IV[7] | 0;
|
|
23427
|
-
}
|
|
23428
|
-
get() {
|
|
23429
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
23430
|
-
return [A, B, C, D, E, F, G, H];
|
|
23431
|
-
}
|
|
23432
|
-
// prettier-ignore
|
|
23433
|
-
set(A, B, C, D, E, F, G, H) {
|
|
23434
|
-
this.A = A | 0;
|
|
23435
|
-
this.B = B | 0;
|
|
23436
|
-
this.C = C | 0;
|
|
23437
|
-
this.D = D | 0;
|
|
23438
|
-
this.E = E | 0;
|
|
23439
|
-
this.F = F | 0;
|
|
23440
|
-
this.G = G | 0;
|
|
23441
|
-
this.H = H | 0;
|
|
23442
|
-
}
|
|
23443
|
-
process(view, offset) {
|
|
23444
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
23445
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
23446
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
23447
|
-
for (let i = 16; i < 64; i++) {
|
|
23448
|
-
const W15 = SHA256_W[i - 15];
|
|
23449
|
-
const W2 = SHA256_W[i - 2];
|
|
23450
|
-
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
23451
|
-
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
23452
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
23453
|
-
}
|
|
23454
|
-
// Compression function main loop, 64 rounds
|
|
23455
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
23456
|
-
for (let i = 0; i < 64; i++) {
|
|
23457
|
-
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
23458
|
-
const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
23459
|
-
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
23460
|
-
const T2 = (sigma0 + Maj$1(A, B, C)) | 0;
|
|
23461
|
-
H = G;
|
|
23462
|
-
G = F;
|
|
23463
|
-
F = E;
|
|
23464
|
-
E = (D + T1) | 0;
|
|
23465
|
-
D = C;
|
|
23466
|
-
C = B;
|
|
23467
|
-
B = A;
|
|
23468
|
-
A = (T1 + T2) | 0;
|
|
23469
|
-
}
|
|
23470
|
-
// Add the compressed chunk to the current hash value
|
|
23471
|
-
A = (A + this.A) | 0;
|
|
23472
|
-
B = (B + this.B) | 0;
|
|
23473
|
-
C = (C + this.C) | 0;
|
|
23474
|
-
D = (D + this.D) | 0;
|
|
23475
|
-
E = (E + this.E) | 0;
|
|
23476
|
-
F = (F + this.F) | 0;
|
|
23477
|
-
G = (G + this.G) | 0;
|
|
23478
|
-
H = (H + this.H) | 0;
|
|
23479
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
23480
|
-
}
|
|
23481
|
-
roundClean() {
|
|
23482
|
-
SHA256_W.fill(0);
|
|
23483
|
-
}
|
|
23484
|
-
destroy() {
|
|
23485
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
23486
|
-
this.buffer.fill(0);
|
|
23487
|
-
}
|
|
23488
|
-
}
|
|
23489
|
-
/**
|
|
23490
|
-
* SHA2-256 hash function
|
|
23491
|
-
* @param message - data that would be hashed
|
|
23492
|
-
*/
|
|
23493
|
-
const sha256 = /* @__PURE__ */ wrapConstructor$1(() => new SHA256());
|
|
23494
|
-
|
|
23495
22290
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
23496
22291
|
// Short Weierstrass curve. The formula is: y² = x³ + ax + b
|
|
23497
22292
|
function validatePointOpts(curve) {
|
|
@@ -23629,7 +22424,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23629
22424
|
function normPrivateKeyToScalar(key) {
|
|
23630
22425
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;
|
|
23631
22426
|
if (lengths && typeof key !== 'bigint') {
|
|
23632
|
-
if (isBytes
|
|
22427
|
+
if (isBytes(key))
|
|
23633
22428
|
key = bytesToHex(key);
|
|
23634
22429
|
// Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes
|
|
23635
22430
|
if (typeof key !== 'string' || !lengths.includes(key.length))
|
|
@@ -24214,7 +23009,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24214
23009
|
* Quick and dirty check for item being public key. Does not validate hex, or being on-curve.
|
|
24215
23010
|
*/
|
|
24216
23011
|
function isProbPub(item) {
|
|
24217
|
-
const arr = isBytes
|
|
23012
|
+
const arr = isBytes(item);
|
|
24218
23013
|
const str = typeof item === 'string';
|
|
24219
23014
|
const len = (arr || str) && item.length;
|
|
24220
23015
|
if (arr)
|
|
@@ -24375,7 +23170,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24375
23170
|
let _sig = undefined;
|
|
24376
23171
|
let P;
|
|
24377
23172
|
try {
|
|
24378
|
-
if (typeof sg === 'string' || isBytes
|
|
23173
|
+
if (typeof sg === 'string' || isBytes(sg)) {
|
|
24379
23174
|
// Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).
|
|
24380
23175
|
// Since DER can also be 2*nByteLength bytes, we check for it first.
|
|
24381
23176
|
try {
|
|
@@ -24429,13 +23224,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24429
23224
|
}
|
|
24430
23225
|
|
|
24431
23226
|
// HMAC (RFC 2104)
|
|
24432
|
-
class HMAC extends Hash
|
|
23227
|
+
class HMAC extends Hash {
|
|
24433
23228
|
constructor(hash$1, _key) {
|
|
24434
23229
|
super();
|
|
24435
23230
|
this.finished = false;
|
|
24436
23231
|
this.destroyed = false;
|
|
24437
23232
|
hash(hash$1);
|
|
24438
|
-
const key = toBytes
|
|
23233
|
+
const key = toBytes(_key);
|
|
24439
23234
|
this.iHash = hash$1.create();
|
|
24440
23235
|
if (typeof this.iHash.update !== 'function')
|
|
24441
23236
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -24457,13 +23252,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24457
23252
|
pad.fill(0);
|
|
24458
23253
|
}
|
|
24459
23254
|
update(buf) {
|
|
24460
|
-
exists
|
|
23255
|
+
exists(this);
|
|
24461
23256
|
this.iHash.update(buf);
|
|
24462
23257
|
return this;
|
|
24463
23258
|
}
|
|
24464
23259
|
digestInto(out) {
|
|
24465
|
-
exists
|
|
24466
|
-
bytes
|
|
23260
|
+
exists(this);
|
|
23261
|
+
bytes(out, this.outputLen);
|
|
24467
23262
|
this.finished = true;
|
|
24468
23263
|
this.iHash.digestInto(out);
|
|
24469
23264
|
this.oHash.update(out);
|
|
@@ -24748,7 +23543,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24748
23543
|
}
|
|
24749
23544
|
Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
|
|
24750
23545
|
|
|
24751
|
-
var
|
|
23546
|
+
var _Lockup;
|
|
24752
23547
|
|
|
24753
23548
|
/**
|
|
24754
23549
|
* Address of the stake config account which configures the rate
|
|
@@ -24797,8 +23592,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24797
23592
|
* Default, inactive Lockup value
|
|
24798
23593
|
*/
|
|
24799
23594
|
}
|
|
24800
|
-
|
|
24801
|
-
Lockup.default = new
|
|
23595
|
+
_Lockup = Lockup;
|
|
23596
|
+
Lockup.default = new _Lockup(0, 0, PublicKey.default);
|
|
24802
23597
|
/**
|
|
24803
23598
|
* Create stake account transaction params
|
|
24804
23599
|
*/
|