@solana/web3.js 1.91.6 → 1.91.8
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 +7 -9
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +7 -9
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +7 -9
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +7 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +926 -2025
- 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 +7 -9
- package/lib/index.native.js.map +1 -1
- package/package.json +6 -6
package/lib/index.iife.js
CHANGED
|
@@ -2381,30 +2381,35 @@ var solanaWeb3 = (function (exports) {
|
|
|
2381
2381
|
}
|
|
2382
2382
|
} (buffer));
|
|
2383
2383
|
|
|
2384
|
-
function number$
|
|
2384
|
+
function number$1(n) {
|
|
2385
2385
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
2386
|
-
throw new Error(`
|
|
2386
|
+
throw new Error(`positive integer expected, not ${n}`);
|
|
2387
|
+
}
|
|
2388
|
+
// copied from utils
|
|
2389
|
+
function isBytes$1(a) {
|
|
2390
|
+
return (a instanceof Uint8Array ||
|
|
2391
|
+
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2387
2392
|
}
|
|
2388
|
-
function bytes
|
|
2389
|
-
if (!(b
|
|
2390
|
-
throw new Error('
|
|
2393
|
+
function bytes(b, ...lengths) {
|
|
2394
|
+
if (!isBytes$1(b))
|
|
2395
|
+
throw new Error('Uint8Array expected');
|
|
2391
2396
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
2392
|
-
throw new Error(`
|
|
2397
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
2393
2398
|
}
|
|
2394
|
-
function hash(
|
|
2395
|
-
if (typeof
|
|
2399
|
+
function hash(h) {
|
|
2400
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
2396
2401
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
2397
|
-
number$
|
|
2398
|
-
number$
|
|
2402
|
+
number$1(h.outputLen);
|
|
2403
|
+
number$1(h.blockLen);
|
|
2399
2404
|
}
|
|
2400
|
-
function exists
|
|
2405
|
+
function exists(instance, checkFinished = true) {
|
|
2401
2406
|
if (instance.destroyed)
|
|
2402
2407
|
throw new Error('Hash instance has been destroyed');
|
|
2403
2408
|
if (checkFinished && instance.finished)
|
|
2404
2409
|
throw new Error('Hash#digest() has already been called');
|
|
2405
2410
|
}
|
|
2406
|
-
function output
|
|
2407
|
-
bytes
|
|
2411
|
+
function output(out, instance) {
|
|
2412
|
+
bytes(out);
|
|
2408
2413
|
const min = instance.outputLen;
|
|
2409
2414
|
if (out.length < min) {
|
|
2410
2415
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
@@ -2419,21 +2424,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
2419
2424
|
// For node.js, package.json#exports field mapping rewrites import
|
|
2420
2425
|
// from `crypto` to `cryptoNode`, which imports native module.
|
|
2421
2426
|
// Makes the utils un-importable in browsers without a bundler.
|
|
2422
|
-
// Once node.js 18 is deprecated, we can just drop the import.
|
|
2423
|
-
const
|
|
2427
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
2428
|
+
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
2424
2429
|
// Cast array to view
|
|
2425
|
-
const createView
|
|
2430
|
+
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
2426
2431
|
// The rotate right (circular right shift) operation for uint32
|
|
2427
|
-
const rotr
|
|
2428
|
-
|
|
2429
|
-
//
|
|
2430
|
-
const
|
|
2431
|
-
|
|
2432
|
-
|
|
2432
|
+
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
2433
|
+
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
2434
|
+
// The byte swap operation for uint32
|
|
2435
|
+
const byteSwap = (word) => ((word << 24) & 0xff000000) |
|
|
2436
|
+
((word << 8) & 0xff0000) |
|
|
2437
|
+
((word >>> 8) & 0xff00) |
|
|
2438
|
+
((word >>> 24) & 0xff);
|
|
2439
|
+
// In place byte swap for Uint32Array
|
|
2440
|
+
function byteSwap32(arr) {
|
|
2441
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2442
|
+
arr[i] = byteSwap(arr[i]);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2433
2445
|
/**
|
|
2434
2446
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2435
2447
|
*/
|
|
2436
|
-
function utf8ToBytes$
|
|
2448
|
+
function utf8ToBytes$1(str) {
|
|
2437
2449
|
if (typeof str !== 'string')
|
|
2438
2450
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2439
2451
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -2443,36 +2455,39 @@ var solanaWeb3 = (function (exports) {
|
|
|
2443
2455
|
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
2444
2456
|
* Keep in mind for future mutable operations.
|
|
2445
2457
|
*/
|
|
2446
|
-
function toBytes
|
|
2458
|
+
function toBytes(data) {
|
|
2447
2459
|
if (typeof data === 'string')
|
|
2448
|
-
data = utf8ToBytes$
|
|
2449
|
-
|
|
2450
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
2460
|
+
data = utf8ToBytes$1(data);
|
|
2461
|
+
bytes(data);
|
|
2451
2462
|
return data;
|
|
2452
2463
|
}
|
|
2453
2464
|
/**
|
|
2454
2465
|
* Copies several Uint8Arrays into one.
|
|
2455
2466
|
*/
|
|
2456
2467
|
function concatBytes$1(...arrays) {
|
|
2457
|
-
|
|
2458
|
-
let
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2468
|
+
let sum = 0;
|
|
2469
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
2470
|
+
const a = arrays[i];
|
|
2471
|
+
bytes(a);
|
|
2472
|
+
sum += a.length;
|
|
2473
|
+
}
|
|
2474
|
+
const res = new Uint8Array(sum);
|
|
2475
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
2476
|
+
const a = arrays[i];
|
|
2477
|
+
res.set(a, pad);
|
|
2463
2478
|
pad += a.length;
|
|
2464
|
-
}
|
|
2465
|
-
return
|
|
2479
|
+
}
|
|
2480
|
+
return res;
|
|
2466
2481
|
}
|
|
2467
2482
|
// For runtime check if class implements interface
|
|
2468
|
-
|
|
2483
|
+
class Hash {
|
|
2469
2484
|
// Safe version that clones internal state
|
|
2470
2485
|
clone() {
|
|
2471
2486
|
return this._cloneInto();
|
|
2472
2487
|
}
|
|
2473
|
-
}
|
|
2474
|
-
function wrapConstructor
|
|
2475
|
-
const hashC = (msg) => hashCons().update(toBytes
|
|
2488
|
+
}
|
|
2489
|
+
function wrapConstructor(hashCons) {
|
|
2490
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
2476
2491
|
const tmp = hashCons();
|
|
2477
2492
|
hashC.outputLen = tmp.outputLen;
|
|
2478
2493
|
hashC.blockLen = tmp.blockLen;
|
|
@@ -2490,7 +2505,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2490
2505
|
}
|
|
2491
2506
|
|
|
2492
2507
|
// Polyfill for Safari 14
|
|
2493
|
-
function setBigUint64
|
|
2508
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
2494
2509
|
if (typeof view.setBigUint64 === 'function')
|
|
2495
2510
|
return view.setBigUint64(byteOffset, value, isLE);
|
|
2496
2511
|
const _32n = BigInt(32);
|
|
@@ -2502,8 +2517,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
2502
2517
|
view.setUint32(byteOffset + h, wh, isLE);
|
|
2503
2518
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
2504
2519
|
}
|
|
2505
|
-
//
|
|
2506
|
-
|
|
2520
|
+
// Choice: a ? b : c
|
|
2521
|
+
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
2522
|
+
// Majority function, true if any two inpust is true
|
|
2523
|
+
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
2524
|
+
/**
|
|
2525
|
+
* Merkle-Damgard hash construction base class.
|
|
2526
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
2527
|
+
*/
|
|
2528
|
+
class HashMD extends Hash {
|
|
2507
2529
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2508
2530
|
super();
|
|
2509
2531
|
this.blockLen = blockLen;
|
|
@@ -2515,18 +2537,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
2515
2537
|
this.pos = 0;
|
|
2516
2538
|
this.destroyed = false;
|
|
2517
2539
|
this.buffer = new Uint8Array(blockLen);
|
|
2518
|
-
this.view = createView
|
|
2540
|
+
this.view = createView(this.buffer);
|
|
2519
2541
|
}
|
|
2520
2542
|
update(data) {
|
|
2521
|
-
exists
|
|
2543
|
+
exists(this);
|
|
2522
2544
|
const { view, buffer, blockLen } = this;
|
|
2523
|
-
data = toBytes
|
|
2545
|
+
data = toBytes(data);
|
|
2524
2546
|
const len = data.length;
|
|
2525
2547
|
for (let pos = 0; pos < len;) {
|
|
2526
2548
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
2527
2549
|
// Fast path: we have at least one block in input, cast it to view and process
|
|
2528
2550
|
if (take === blockLen) {
|
|
2529
|
-
const dataView = createView
|
|
2551
|
+
const dataView = createView(data);
|
|
2530
2552
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
2531
2553
|
this.process(dataView, pos);
|
|
2532
2554
|
continue;
|
|
@@ -2544,8 +2566,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
2544
2566
|
return this;
|
|
2545
2567
|
}
|
|
2546
2568
|
digestInto(out) {
|
|
2547
|
-
exists
|
|
2548
|
-
output
|
|
2569
|
+
exists(this);
|
|
2570
|
+
output(out, this);
|
|
2549
2571
|
this.finished = true;
|
|
2550
2572
|
// Padding
|
|
2551
2573
|
// We can avoid allocation of buffer for padding completely if it
|
|
@@ -2555,7 +2577,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
2555
2577
|
// append the bit '1' to the message
|
|
2556
2578
|
buffer[pos++] = 0b10000000;
|
|
2557
2579
|
this.buffer.subarray(pos).fill(0);
|
|
2558
|
-
// we have less than padOffset left in buffer, so we cannot put length in
|
|
2580
|
+
// we have less than padOffset left in buffer, so we cannot put length in
|
|
2581
|
+
// current block, need process it and pad again
|
|
2559
2582
|
if (this.padOffset > blockLen - pos) {
|
|
2560
2583
|
this.process(view, 0);
|
|
2561
2584
|
pos = 0;
|
|
@@ -2566,9 +2589,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
2566
2589
|
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
2567
2590
|
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
2568
2591
|
// So we just write lowest 64 bits of that value.
|
|
2569
|
-
setBigUint64
|
|
2592
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
2570
2593
|
this.process(view, 0);
|
|
2571
|
-
const oview = createView
|
|
2594
|
+
const oview = createView(out);
|
|
2572
2595
|
const len = this.outputLen;
|
|
2573
2596
|
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
2574
2597
|
if (len % 4)
|
|
@@ -2599,26 +2622,26 @@ var solanaWeb3 = (function (exports) {
|
|
|
2599
2622
|
to.buffer.set(buffer);
|
|
2600
2623
|
return to;
|
|
2601
2624
|
}
|
|
2602
|
-
}
|
|
2625
|
+
}
|
|
2603
2626
|
|
|
2604
|
-
const U32_MASK64
|
|
2605
|
-
const _32n
|
|
2627
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2628
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
2606
2629
|
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
2607
|
-
function fromBig
|
|
2630
|
+
function fromBig(n, le = false) {
|
|
2608
2631
|
if (le)
|
|
2609
|
-
return { h: Number(n & U32_MASK64
|
|
2610
|
-
return { h: Number((n >> _32n
|
|
2632
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
2633
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
2611
2634
|
}
|
|
2612
|
-
function split
|
|
2635
|
+
function split(lst, le = false) {
|
|
2613
2636
|
let Ah = new Uint32Array(lst.length);
|
|
2614
2637
|
let Al = new Uint32Array(lst.length);
|
|
2615
2638
|
for (let i = 0; i < lst.length; i++) {
|
|
2616
|
-
const { h, l } = fromBig
|
|
2639
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2617
2640
|
[Ah[i], Al[i]] = [h, l];
|
|
2618
2641
|
}
|
|
2619
2642
|
return [Ah, Al];
|
|
2620
2643
|
}
|
|
2621
|
-
const toBig = (h, l) => (BigInt(h >>> 0) << _32n
|
|
2644
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
2622
2645
|
// for Shift in [0, 32)
|
|
2623
2646
|
const shrSH = (h, _l, s) => h >>> s;
|
|
2624
2647
|
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
@@ -2632,11 +2655,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2632
2655
|
const rotr32H = (_h, l) => l;
|
|
2633
2656
|
const rotr32L = (h, _l) => h;
|
|
2634
2657
|
// Left rotate for Shift in [1, 32)
|
|
2635
|
-
const rotlSH
|
|
2636
|
-
const rotlSL
|
|
2658
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
2659
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
2637
2660
|
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
2638
|
-
const rotlBH
|
|
2639
|
-
const rotlBL
|
|
2661
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
2662
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
2640
2663
|
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
2641
2664
|
// simple take carry out of low bit sum by shift, we need to use division.
|
|
2642
2665
|
function add(Ah, Al, Bh, Bl) {
|
|
@@ -2652,11 +2675,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
2652
2675
|
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
2653
2676
|
// prettier-ignore
|
|
2654
2677
|
const u64$1 = {
|
|
2655
|
-
fromBig
|
|
2678
|
+
fromBig, split, toBig,
|
|
2656
2679
|
shrSH, shrSL,
|
|
2657
2680
|
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
2658
2681
|
rotr32H, rotr32L,
|
|
2659
|
-
rotlSH
|
|
2682
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
2660
2683
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
2661
2684
|
};
|
|
2662
2685
|
|
|
@@ -2687,7 +2710,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2687
2710
|
// Temporary buffer, not used to store anything between runs
|
|
2688
2711
|
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
2689
2712
|
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
2690
|
-
class SHA512 extends
|
|
2713
|
+
class SHA512 extends HashMD {
|
|
2691
2714
|
constructor() {
|
|
2692
2715
|
super(128, 64, 16, false);
|
|
2693
2716
|
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
@@ -2814,7 +2837,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2814
2837
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2815
2838
|
}
|
|
2816
2839
|
}
|
|
2817
|
-
const sha512 = /* @__PURE__ */ wrapConstructor
|
|
2840
|
+
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
2818
2841
|
|
|
2819
2842
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2820
2843
|
// 100 lines of code in the file are duplicated from noble-hashes (utils).
|
|
@@ -2824,14 +2847,21 @@ var solanaWeb3 = (function (exports) {
|
|
|
2824
2847
|
const _0n$5 = BigInt(0);
|
|
2825
2848
|
const _1n$7 = BigInt(1);
|
|
2826
2849
|
const _2n$5 = BigInt(2);
|
|
2827
|
-
|
|
2850
|
+
function isBytes(a) {
|
|
2851
|
+
return (a instanceof Uint8Array ||
|
|
2852
|
+
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
2853
|
+
}
|
|
2854
|
+
function abytes(item) {
|
|
2855
|
+
if (!isBytes(item))
|
|
2856
|
+
throw new Error('Uint8Array expected');
|
|
2857
|
+
}
|
|
2858
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
2828
2859
|
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
2829
2860
|
/**
|
|
2830
2861
|
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
2831
2862
|
*/
|
|
2832
2863
|
function bytesToHex(bytes) {
|
|
2833
|
-
|
|
2834
|
-
throw new Error('Uint8Array expected');
|
|
2864
|
+
abytes(bytes);
|
|
2835
2865
|
// pre-caching improves the speed 6x
|
|
2836
2866
|
let hex = '';
|
|
2837
2867
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -2849,23 +2879,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
2849
2879
|
// Big Endian
|
|
2850
2880
|
return BigInt(hex === '' ? '0' : `0x${hex}`);
|
|
2851
2881
|
}
|
|
2882
|
+
// We use optimized technique to convert hex string to byte array
|
|
2883
|
+
const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
|
|
2884
|
+
function asciiToBase16(char) {
|
|
2885
|
+
if (char >= asciis._0 && char <= asciis._9)
|
|
2886
|
+
return char - asciis._0;
|
|
2887
|
+
if (char >= asciis._A && char <= asciis._F)
|
|
2888
|
+
return char - (asciis._A - 10);
|
|
2889
|
+
if (char >= asciis._a && char <= asciis._f)
|
|
2890
|
+
return char - (asciis._a - 10);
|
|
2891
|
+
return;
|
|
2892
|
+
}
|
|
2852
2893
|
/**
|
|
2853
2894
|
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
2854
2895
|
*/
|
|
2855
2896
|
function hexToBytes(hex) {
|
|
2856
2897
|
if (typeof hex !== 'string')
|
|
2857
2898
|
throw new Error('hex string expected, got ' + typeof hex);
|
|
2858
|
-
const
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
const
|
|
2865
|
-
const
|
|
2866
|
-
if (
|
|
2867
|
-
|
|
2868
|
-
|
|
2899
|
+
const hl = hex.length;
|
|
2900
|
+
const al = hl / 2;
|
|
2901
|
+
if (hl % 2)
|
|
2902
|
+
throw new Error('padded hex string expected, got unpadded hex of length ' + hl);
|
|
2903
|
+
const array = new Uint8Array(al);
|
|
2904
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
2905
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
2906
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
2907
|
+
if (n1 === undefined || n2 === undefined) {
|
|
2908
|
+
const char = hex[hi] + hex[hi + 1];
|
|
2909
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
2910
|
+
}
|
|
2911
|
+
array[ai] = n1 * 16 + n2;
|
|
2869
2912
|
}
|
|
2870
2913
|
return array;
|
|
2871
2914
|
}
|
|
@@ -2874,8 +2917,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2874
2917
|
return hexToNumber(bytesToHex(bytes));
|
|
2875
2918
|
}
|
|
2876
2919
|
function bytesToNumberLE(bytes) {
|
|
2877
|
-
|
|
2878
|
-
throw new Error('Uint8Array expected');
|
|
2920
|
+
abytes(bytes);
|
|
2879
2921
|
return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
2880
2922
|
}
|
|
2881
2923
|
function numberToBytesBE(n, len) {
|
|
@@ -2907,7 +2949,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
2907
2949
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
2908
2950
|
}
|
|
2909
2951
|
}
|
|
2910
|
-
else if (
|
|
2952
|
+
else if (isBytes(hex)) {
|
|
2911
2953
|
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
2912
2954
|
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
2913
2955
|
res = Uint8Array.from(hex);
|
|
@@ -2924,29 +2966,33 @@ var solanaWeb3 = (function (exports) {
|
|
|
2924
2966
|
* Copies several Uint8Arrays into one.
|
|
2925
2967
|
*/
|
|
2926
2968
|
function concatBytes(...arrays) {
|
|
2927
|
-
|
|
2928
|
-
let
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2969
|
+
let sum = 0;
|
|
2970
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
2971
|
+
const a = arrays[i];
|
|
2972
|
+
abytes(a);
|
|
2973
|
+
sum += a.length;
|
|
2974
|
+
}
|
|
2975
|
+
const res = new Uint8Array(sum);
|
|
2976
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
2977
|
+
const a = arrays[i];
|
|
2978
|
+
res.set(a, pad);
|
|
2933
2979
|
pad += a.length;
|
|
2934
|
-
}
|
|
2935
|
-
return
|
|
2980
|
+
}
|
|
2981
|
+
return res;
|
|
2936
2982
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
if (
|
|
2983
|
+
// Compares 2 u8a-s in kinda constant time
|
|
2984
|
+
function equalBytes(a, b) {
|
|
2985
|
+
if (a.length !== b.length)
|
|
2940
2986
|
return false;
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
return
|
|
2987
|
+
let diff = 0;
|
|
2988
|
+
for (let i = 0; i < a.length; i++)
|
|
2989
|
+
diff |= a[i] ^ b[i];
|
|
2990
|
+
return diff === 0;
|
|
2945
2991
|
}
|
|
2946
2992
|
/**
|
|
2947
2993
|
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
2948
2994
|
*/
|
|
2949
|
-
function utf8ToBytes
|
|
2995
|
+
function utf8ToBytes(str) {
|
|
2950
2996
|
if (typeof str !== 'string')
|
|
2951
2997
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
2952
2998
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
@@ -2973,9 +3019,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
2973
3019
|
/**
|
|
2974
3020
|
* Sets single bit at position.
|
|
2975
3021
|
*/
|
|
2976
|
-
|
|
3022
|
+
function bitSet(n, pos, value) {
|
|
2977
3023
|
return n | ((value ? _1n$7 : _0n$5) << BigInt(pos));
|
|
2978
|
-
}
|
|
3024
|
+
}
|
|
2979
3025
|
/**
|
|
2980
3026
|
* Calculate mask for N bits. Not using ** operator with bigints because of old engines.
|
|
2981
3027
|
* Same as BigInt(`0b${Array(i).fill('1').join('')}`)
|
|
@@ -3048,7 +3094,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3048
3094
|
function: (val) => typeof val === 'function',
|
|
3049
3095
|
boolean: (val) => typeof val === 'boolean',
|
|
3050
3096
|
string: (val) => typeof val === 'string',
|
|
3051
|
-
stringOrUint8Array: (val) => typeof val === 'string' || val
|
|
3097
|
+
stringOrUint8Array: (val) => typeof val === 'string' || isBytes(val),
|
|
3052
3098
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
3053
3099
|
array: (val) => Array.isArray(val),
|
|
3054
3100
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -3084,6 +3130,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
3084
3130
|
|
|
3085
3131
|
var ut = /*#__PURE__*/Object.freeze({
|
|
3086
3132
|
__proto__: null,
|
|
3133
|
+
abytes: abytes,
|
|
3087
3134
|
bitGet: bitGet,
|
|
3088
3135
|
bitLen: bitLen,
|
|
3089
3136
|
bitMask: bitMask,
|
|
@@ -3097,11 +3144,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
3097
3144
|
equalBytes: equalBytes,
|
|
3098
3145
|
hexToBytes: hexToBytes,
|
|
3099
3146
|
hexToNumber: hexToNumber,
|
|
3147
|
+
isBytes: isBytes,
|
|
3100
3148
|
numberToBytesBE: numberToBytesBE,
|
|
3101
3149
|
numberToBytesLE: numberToBytesLE,
|
|
3102
3150
|
numberToHexUnpadded: numberToHexUnpadded,
|
|
3103
3151
|
numberToVarBytesBE: numberToVarBytesBE,
|
|
3104
|
-
utf8ToBytes: utf8ToBytes
|
|
3152
|
+
utf8ToBytes: utf8ToBytes,
|
|
3105
3153
|
validateObject: validateObject
|
|
3106
3154
|
});
|
|
3107
3155
|
|
|
@@ -4104,7 +4152,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4104
4152
|
const Fp$1 = Field(ED25519_P, undefined, true);
|
|
4105
4153
|
const ed25519Defaults = {
|
|
4106
4154
|
// Param: a
|
|
4107
|
-
a: BigInt(-1),
|
|
4155
|
+
a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster
|
|
4108
4156
|
// d is equal to -121665/121666 over finite field.
|
|
4109
4157
|
// Negative number is P - number, and division is invert(number, P)
|
|
4110
4158
|
d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),
|
|
@@ -4130,7 +4178,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
4130
4178
|
function ed25519_domain(data, ctx, phflag) {
|
|
4131
4179
|
if (ctx.length > 255)
|
|
4132
4180
|
throw new Error('Context is too big');
|
|
4133
|
-
return concatBytes$1(utf8ToBytes$
|
|
4181
|
+
return concatBytes$1(utf8ToBytes$1('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
4134
4182
|
}
|
|
4135
4183
|
/* @__PURE__ */ twistedEdwards({
|
|
4136
4184
|
...ed25519Defaults,
|
|
@@ -7770,216 +7818,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
7770
7818
|
|
|
7771
7819
|
var bs58$1 = /*@__PURE__*/getDefaultExportFromCjs(bs58);
|
|
7772
7820
|
|
|
7773
|
-
function number$1(n) {
|
|
7774
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
7775
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
7776
|
-
}
|
|
7777
|
-
// copied from utils
|
|
7778
|
-
function isBytes$1(a) {
|
|
7779
|
-
return (a instanceof Uint8Array ||
|
|
7780
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7781
|
-
}
|
|
7782
|
-
function bytes(b, ...lengths) {
|
|
7783
|
-
if (!isBytes$1(b))
|
|
7784
|
-
throw new Error('Expected Uint8Array');
|
|
7785
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
7786
|
-
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
7787
|
-
}
|
|
7788
|
-
function exists(instance, checkFinished = true) {
|
|
7789
|
-
if (instance.destroyed)
|
|
7790
|
-
throw new Error('Hash instance has been destroyed');
|
|
7791
|
-
if (checkFinished && instance.finished)
|
|
7792
|
-
throw new Error('Hash#digest() has already been called');
|
|
7793
|
-
}
|
|
7794
|
-
function output(out, instance) {
|
|
7795
|
-
bytes(out);
|
|
7796
|
-
const min = instance.outputLen;
|
|
7797
|
-
if (out.length < min) {
|
|
7798
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
7799
|
-
}
|
|
7800
|
-
}
|
|
7801
|
-
|
|
7802
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7803
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
7804
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
7805
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
7806
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
7807
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
7808
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
7809
|
-
const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
7810
|
-
function isBytes(a) {
|
|
7811
|
-
return (a instanceof Uint8Array ||
|
|
7812
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
7813
|
-
}
|
|
7814
|
-
// Cast array to view
|
|
7815
|
-
const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
7816
|
-
// The rotate right (circular right shift) operation for uint32
|
|
7817
|
-
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
7818
|
-
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
7819
|
-
// early-throw an error because we don't support BE yet.
|
|
7820
|
-
// Other libraries would silently corrupt the data instead of throwing an error,
|
|
7821
|
-
// when they don't support it.
|
|
7822
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
7823
|
-
if (!isLE)
|
|
7824
|
-
throw new Error('Non little-endian hardware is not supported');
|
|
7825
|
-
/**
|
|
7826
|
-
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
7827
|
-
*/
|
|
7828
|
-
function utf8ToBytes(str) {
|
|
7829
|
-
if (typeof str !== 'string')
|
|
7830
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
7831
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
7832
|
-
}
|
|
7833
|
-
/**
|
|
7834
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
7835
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
7836
|
-
* Keep in mind for future mutable operations.
|
|
7837
|
-
*/
|
|
7838
|
-
function toBytes(data) {
|
|
7839
|
-
if (typeof data === 'string')
|
|
7840
|
-
data = utf8ToBytes(data);
|
|
7841
|
-
if (!isBytes(data))
|
|
7842
|
-
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
7843
|
-
return data;
|
|
7844
|
-
}
|
|
7845
|
-
// For runtime check if class implements interface
|
|
7846
|
-
class Hash {
|
|
7847
|
-
// Safe version that clones internal state
|
|
7848
|
-
clone() {
|
|
7849
|
-
return this._cloneInto();
|
|
7850
|
-
}
|
|
7851
|
-
}
|
|
7852
|
-
function wrapConstructor(hashCons) {
|
|
7853
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
7854
|
-
const tmp = hashCons();
|
|
7855
|
-
hashC.outputLen = tmp.outputLen;
|
|
7856
|
-
hashC.blockLen = tmp.blockLen;
|
|
7857
|
-
hashC.create = () => hashCons();
|
|
7858
|
-
return hashC;
|
|
7859
|
-
}
|
|
7860
|
-
|
|
7861
|
-
// Polyfill for Safari 14
|
|
7862
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
7863
|
-
if (typeof view.setBigUint64 === 'function')
|
|
7864
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
7865
|
-
const _32n = BigInt(32);
|
|
7866
|
-
const _u32_max = BigInt(0xffffffff);
|
|
7867
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
7868
|
-
const wl = Number(value & _u32_max);
|
|
7869
|
-
const h = isLE ? 4 : 0;
|
|
7870
|
-
const l = isLE ? 0 : 4;
|
|
7871
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
7872
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
7873
|
-
}
|
|
7874
|
-
// Base SHA2 class (RFC 6234)
|
|
7875
|
-
class SHA2 extends Hash {
|
|
7876
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
7877
|
-
super();
|
|
7878
|
-
this.blockLen = blockLen;
|
|
7879
|
-
this.outputLen = outputLen;
|
|
7880
|
-
this.padOffset = padOffset;
|
|
7881
|
-
this.isLE = isLE;
|
|
7882
|
-
this.finished = false;
|
|
7883
|
-
this.length = 0;
|
|
7884
|
-
this.pos = 0;
|
|
7885
|
-
this.destroyed = false;
|
|
7886
|
-
this.buffer = new Uint8Array(blockLen);
|
|
7887
|
-
this.view = createView(this.buffer);
|
|
7888
|
-
}
|
|
7889
|
-
update(data) {
|
|
7890
|
-
exists(this);
|
|
7891
|
-
const { view, buffer, blockLen } = this;
|
|
7892
|
-
data = toBytes(data);
|
|
7893
|
-
const len = data.length;
|
|
7894
|
-
for (let pos = 0; pos < len;) {
|
|
7895
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
7896
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
7897
|
-
if (take === blockLen) {
|
|
7898
|
-
const dataView = createView(data);
|
|
7899
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
7900
|
-
this.process(dataView, pos);
|
|
7901
|
-
continue;
|
|
7902
|
-
}
|
|
7903
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
7904
|
-
this.pos += take;
|
|
7905
|
-
pos += take;
|
|
7906
|
-
if (this.pos === blockLen) {
|
|
7907
|
-
this.process(view, 0);
|
|
7908
|
-
this.pos = 0;
|
|
7909
|
-
}
|
|
7910
|
-
}
|
|
7911
|
-
this.length += data.length;
|
|
7912
|
-
this.roundClean();
|
|
7913
|
-
return this;
|
|
7914
|
-
}
|
|
7915
|
-
digestInto(out) {
|
|
7916
|
-
exists(this);
|
|
7917
|
-
output(out, this);
|
|
7918
|
-
this.finished = true;
|
|
7919
|
-
// Padding
|
|
7920
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
7921
|
-
// was previously not allocated here. But it won't change performance.
|
|
7922
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
7923
|
-
let { pos } = this;
|
|
7924
|
-
// append the bit '1' to the message
|
|
7925
|
-
buffer[pos++] = 0b10000000;
|
|
7926
|
-
this.buffer.subarray(pos).fill(0);
|
|
7927
|
-
// we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
|
|
7928
|
-
if (this.padOffset > blockLen - pos) {
|
|
7929
|
-
this.process(view, 0);
|
|
7930
|
-
pos = 0;
|
|
7931
|
-
}
|
|
7932
|
-
// Pad until full block byte with zeros
|
|
7933
|
-
for (let i = pos; i < blockLen; i++)
|
|
7934
|
-
buffer[i] = 0;
|
|
7935
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
7936
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
7937
|
-
// So we just write lowest 64 bits of that value.
|
|
7938
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
7939
|
-
this.process(view, 0);
|
|
7940
|
-
const oview = createView(out);
|
|
7941
|
-
const len = this.outputLen;
|
|
7942
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
7943
|
-
if (len % 4)
|
|
7944
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
7945
|
-
const outLen = len / 4;
|
|
7946
|
-
const state = this.get();
|
|
7947
|
-
if (outLen > state.length)
|
|
7948
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
7949
|
-
for (let i = 0; i < outLen; i++)
|
|
7950
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
7951
|
-
}
|
|
7952
|
-
digest() {
|
|
7953
|
-
const { buffer, outputLen } = this;
|
|
7954
|
-
this.digestInto(buffer);
|
|
7955
|
-
const res = buffer.slice(0, outputLen);
|
|
7956
|
-
this.destroy();
|
|
7957
|
-
return res;
|
|
7958
|
-
}
|
|
7959
|
-
_cloneInto(to) {
|
|
7960
|
-
to || (to = new this.constructor());
|
|
7961
|
-
to.set(...this.get());
|
|
7962
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
7963
|
-
to.length = length;
|
|
7964
|
-
to.pos = pos;
|
|
7965
|
-
to.finished = finished;
|
|
7966
|
-
to.destroyed = destroyed;
|
|
7967
|
-
if (length % blockLen)
|
|
7968
|
-
to.buffer.set(buffer);
|
|
7969
|
-
return to;
|
|
7970
|
-
}
|
|
7971
|
-
}
|
|
7972
|
-
|
|
7973
7821
|
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
7974
7822
|
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
7975
|
-
// Choice: a ? b : c
|
|
7976
|
-
const Chi$1 = (a, b, c) => (a & b) ^ (~a & c);
|
|
7977
|
-
// Majority function, true if any two inpust is true
|
|
7978
|
-
const Maj$1 = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
7979
7823
|
// Round constants:
|
|
7980
7824
|
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
7981
7825
|
// prettier-ignore
|
|
7982
|
-
const SHA256_K
|
|
7826
|
+
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
7983
7827
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
7984
7828
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
7985
7829
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
@@ -7989,27 +7833,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
7989
7833
|
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
7990
7834
|
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
7991
7835
|
]);
|
|
7992
|
-
// Initial state
|
|
7836
|
+
// Initial state:
|
|
7837
|
+
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
7993
7838
|
// prettier-ignore
|
|
7994
|
-
const
|
|
7839
|
+
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
7995
7840
|
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
7996
7841
|
]);
|
|
7997
7842
|
// Temporary buffer, not used to store anything between runs
|
|
7998
7843
|
// Named this way because it matches specification.
|
|
7999
|
-
const SHA256_W
|
|
8000
|
-
|
|
7844
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
7845
|
+
class SHA256 extends HashMD {
|
|
8001
7846
|
constructor() {
|
|
8002
7847
|
super(64, 32, 8, false);
|
|
8003
7848
|
// We cannot use array here since array allows indexing by variable
|
|
8004
7849
|
// which means optimizer/compiler cannot use registers.
|
|
8005
|
-
this.A =
|
|
8006
|
-
this.B =
|
|
8007
|
-
this.C =
|
|
8008
|
-
this.D =
|
|
8009
|
-
this.E =
|
|
8010
|
-
this.F =
|
|
8011
|
-
this.G =
|
|
8012
|
-
this.H =
|
|
7850
|
+
this.A = SHA256_IV[0] | 0;
|
|
7851
|
+
this.B = SHA256_IV[1] | 0;
|
|
7852
|
+
this.C = SHA256_IV[2] | 0;
|
|
7853
|
+
this.D = SHA256_IV[3] | 0;
|
|
7854
|
+
this.E = SHA256_IV[4] | 0;
|
|
7855
|
+
this.F = SHA256_IV[5] | 0;
|
|
7856
|
+
this.G = SHA256_IV[6] | 0;
|
|
7857
|
+
this.H = SHA256_IV[7] | 0;
|
|
8013
7858
|
}
|
|
8014
7859
|
get() {
|
|
8015
7860
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -8029,21 +7874,21 @@ var solanaWeb3 = (function (exports) {
|
|
|
8029
7874
|
process(view, offset) {
|
|
8030
7875
|
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
8031
7876
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
8032
|
-
SHA256_W
|
|
7877
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
8033
7878
|
for (let i = 16; i < 64; i++) {
|
|
8034
|
-
const W15 = SHA256_W
|
|
8035
|
-
const W2 = SHA256_W
|
|
7879
|
+
const W15 = SHA256_W[i - 15];
|
|
7880
|
+
const W2 = SHA256_W[i - 2];
|
|
8036
7881
|
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
8037
7882
|
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
8038
|
-
SHA256_W
|
|
7883
|
+
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
8039
7884
|
}
|
|
8040
7885
|
// Compression function main loop, 64 rounds
|
|
8041
7886
|
let { A, B, C, D, E, F, G, H } = this;
|
|
8042
7887
|
for (let i = 0; i < 64; i++) {
|
|
8043
7888
|
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
8044
|
-
const T1 = (H + sigma1 + Chi
|
|
7889
|
+
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
8045
7890
|
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
8046
|
-
const T2 = (sigma0 + Maj
|
|
7891
|
+
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
8047
7892
|
H = G;
|
|
8048
7893
|
G = F;
|
|
8049
7894
|
F = E;
|
|
@@ -8065,18 +7910,18 @@ var solanaWeb3 = (function (exports) {
|
|
|
8065
7910
|
this.set(A, B, C, D, E, F, G, H);
|
|
8066
7911
|
}
|
|
8067
7912
|
roundClean() {
|
|
8068
|
-
SHA256_W
|
|
7913
|
+
SHA256_W.fill(0);
|
|
8069
7914
|
}
|
|
8070
7915
|
destroy() {
|
|
8071
7916
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
8072
7917
|
this.buffer.fill(0);
|
|
8073
7918
|
}
|
|
8074
|
-
}
|
|
7919
|
+
}
|
|
8075
7920
|
/**
|
|
8076
7921
|
* SHA2-256 hash function
|
|
8077
7922
|
* @param message - data that would be hashed
|
|
8078
7923
|
*/
|
|
8079
|
-
const sha256
|
|
7924
|
+
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
8080
7925
|
|
|
8081
7926
|
var lib = {};
|
|
8082
7927
|
|
|
@@ -9195,8 +9040,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9195
9040
|
}
|
|
9196
9041
|
const SOLANA_SCHEMA = new Map();
|
|
9197
9042
|
|
|
9198
|
-
var
|
|
9199
|
-
let _Symbol$toStringTag;
|
|
9043
|
+
var _PublicKey;
|
|
9200
9044
|
|
|
9201
9045
|
/**
|
|
9202
9046
|
* Maximum length of derived pubkey seed
|
|
@@ -9226,7 +9070,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
9226
9070
|
/**
|
|
9227
9071
|
* A public key
|
|
9228
9072
|
*/
|
|
9229
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
9230
9073
|
class PublicKey extends Struct$1 {
|
|
9231
9074
|
/**
|
|
9232
9075
|
* Create a new PublicKey object
|
|
@@ -9306,7 +9149,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9306
9149
|
b.copy(zeroPad, 32 - b.length);
|
|
9307
9150
|
return zeroPad;
|
|
9308
9151
|
}
|
|
9309
|
-
get [
|
|
9152
|
+
get [Symbol.toStringTag]() {
|
|
9310
9153
|
return `PublicKey(${this.toString()})`;
|
|
9311
9154
|
}
|
|
9312
9155
|
|
|
@@ -9325,7 +9168,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9325
9168
|
/* eslint-disable require-await */
|
|
9326
9169
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
9327
9170
|
const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
|
|
9328
|
-
const publicKeyBytes = sha256
|
|
9171
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9329
9172
|
return new PublicKey(publicKeyBytes);
|
|
9330
9173
|
}
|
|
9331
9174
|
|
|
@@ -9342,7 +9185,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
9342
9185
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
9343
9186
|
});
|
|
9344
9187
|
buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
|
|
9345
|
-
const publicKeyBytes = sha256
|
|
9188
|
+
const publicKeyBytes = sha256(buffer$1);
|
|
9346
9189
|
if (isOnCurve(publicKeyBytes)) {
|
|
9347
9190
|
throw new Error(`Invalid seeds, address must fall off the curve`);
|
|
9348
9191
|
}
|
|
@@ -9404,8 +9247,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
9404
9247
|
return isOnCurve(pubkey.toBytes());
|
|
9405
9248
|
}
|
|
9406
9249
|
}
|
|
9407
|
-
|
|
9408
|
-
PublicKey.default = new
|
|
9250
|
+
_PublicKey = PublicKey;
|
|
9251
|
+
PublicKey.default = new _PublicKey('11111111111111111111111111111111');
|
|
9409
9252
|
SOLANA_SCHEMA.set(PublicKey, {
|
|
9410
9253
|
kind: 'struct',
|
|
9411
9254
|
fields: [['_bn', 'u256']]
|
|
@@ -16357,1593 +16200,771 @@ var solanaWeb3 = (function (exports) {
|
|
|
16357
16200
|
|
|
16358
16201
|
var client = {};
|
|
16359
16202
|
|
|
16360
|
-
var
|
|
16203
|
+
var eventemitter3 = {exports: {}};
|
|
16361
16204
|
|
|
16362
16205
|
(function (module) {
|
|
16363
|
-
function _interopRequireDefault(obj) {
|
|
16364
|
-
return obj && obj.__esModule ? obj : {
|
|
16365
|
-
"default": obj
|
|
16366
|
-
};
|
|
16367
|
-
}
|
|
16368
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16369
|
-
} (interopRequireDefault));
|
|
16370
|
-
|
|
16371
|
-
var interopRequireDefaultExports = interopRequireDefault.exports;
|
|
16372
16206
|
|
|
16373
|
-
|
|
16207
|
+
var has = Object.prototype.hasOwnProperty
|
|
16208
|
+
, prefix = '~';
|
|
16374
16209
|
|
|
16375
|
-
|
|
16376
|
-
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
function _typeof(o) {
|
|
16384
|
-
"@babel/helpers - typeof";
|
|
16385
|
-
|
|
16386
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
16387
|
-
return typeof o;
|
|
16388
|
-
} : function (o) {
|
|
16389
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
16390
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
16391
|
-
}
|
|
16392
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16393
|
-
} (_typeof));
|
|
16394
|
-
return _typeof.exports;
|
|
16395
|
-
}
|
|
16396
|
-
|
|
16397
|
-
var hasRequiredRegeneratorRuntime;
|
|
16398
|
-
|
|
16399
|
-
function requireRegeneratorRuntime () {
|
|
16400
|
-
if (hasRequiredRegeneratorRuntime) return regeneratorRuntime$1.exports;
|
|
16401
|
-
hasRequiredRegeneratorRuntime = 1;
|
|
16402
|
-
(function (module) {
|
|
16403
|
-
var _typeof = require_typeof()["default"];
|
|
16404
|
-
function _regeneratorRuntime() {
|
|
16405
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
16406
|
-
return e;
|
|
16407
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16408
|
-
var t,
|
|
16409
|
-
e = {},
|
|
16410
|
-
r = Object.prototype,
|
|
16411
|
-
n = r.hasOwnProperty,
|
|
16412
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
16413
|
-
t[e] = r.value;
|
|
16414
|
-
},
|
|
16415
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
16416
|
-
a = i.iterator || "@@iterator",
|
|
16417
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
16418
|
-
u = i.toStringTag || "@@toStringTag";
|
|
16419
|
-
function define(t, e, r) {
|
|
16420
|
-
return Object.defineProperty(t, e, {
|
|
16421
|
-
value: r,
|
|
16422
|
-
enumerable: !0,
|
|
16423
|
-
configurable: !0,
|
|
16424
|
-
writable: !0
|
|
16425
|
-
}), t[e];
|
|
16426
|
-
}
|
|
16427
|
-
try {
|
|
16428
|
-
define({}, "");
|
|
16429
|
-
} catch (t) {
|
|
16430
|
-
define = function define(t, e, r) {
|
|
16431
|
-
return t[e] = r;
|
|
16432
|
-
};
|
|
16433
|
-
}
|
|
16434
|
-
function wrap(t, e, r, n) {
|
|
16435
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
16436
|
-
a = Object.create(i.prototype),
|
|
16437
|
-
c = new Context(n || []);
|
|
16438
|
-
return o(a, "_invoke", {
|
|
16439
|
-
value: makeInvokeMethod(t, r, c)
|
|
16440
|
-
}), a;
|
|
16441
|
-
}
|
|
16442
|
-
function tryCatch(t, e, r) {
|
|
16443
|
-
try {
|
|
16444
|
-
return {
|
|
16445
|
-
type: "normal",
|
|
16446
|
-
arg: t.call(e, r)
|
|
16447
|
-
};
|
|
16448
|
-
} catch (t) {
|
|
16449
|
-
return {
|
|
16450
|
-
type: "throw",
|
|
16451
|
-
arg: t
|
|
16452
|
-
};
|
|
16453
|
-
}
|
|
16454
|
-
}
|
|
16455
|
-
e.wrap = wrap;
|
|
16456
|
-
var h = "suspendedStart",
|
|
16457
|
-
l = "suspendedYield",
|
|
16458
|
-
f = "executing",
|
|
16459
|
-
s = "completed",
|
|
16460
|
-
y = {};
|
|
16461
|
-
function Generator() {}
|
|
16462
|
-
function GeneratorFunction() {}
|
|
16463
|
-
function GeneratorFunctionPrototype() {}
|
|
16464
|
-
var p = {};
|
|
16465
|
-
define(p, a, function () {
|
|
16466
|
-
return this;
|
|
16467
|
-
});
|
|
16468
|
-
var d = Object.getPrototypeOf,
|
|
16469
|
-
v = d && d(d(values([])));
|
|
16470
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
16471
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
16472
|
-
function defineIteratorMethods(t) {
|
|
16473
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
16474
|
-
define(t, e, function (t) {
|
|
16475
|
-
return this._invoke(e, t);
|
|
16476
|
-
});
|
|
16477
|
-
});
|
|
16478
|
-
}
|
|
16479
|
-
function AsyncIterator(t, e) {
|
|
16480
|
-
function invoke(r, o, i, a) {
|
|
16481
|
-
var c = tryCatch(t[r], t, o);
|
|
16482
|
-
if ("throw" !== c.type) {
|
|
16483
|
-
var u = c.arg,
|
|
16484
|
-
h = u.value;
|
|
16485
|
-
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
16486
|
-
invoke("next", t, i, a);
|
|
16487
|
-
}, function (t) {
|
|
16488
|
-
invoke("throw", t, i, a);
|
|
16489
|
-
}) : e.resolve(h).then(function (t) {
|
|
16490
|
-
u.value = t, i(u);
|
|
16491
|
-
}, function (t) {
|
|
16492
|
-
return invoke("throw", t, i, a);
|
|
16493
|
-
});
|
|
16494
|
-
}
|
|
16495
|
-
a(c.arg);
|
|
16496
|
-
}
|
|
16497
|
-
var r;
|
|
16498
|
-
o(this, "_invoke", {
|
|
16499
|
-
value: function value(t, n) {
|
|
16500
|
-
function callInvokeWithMethodAndArg() {
|
|
16501
|
-
return new e(function (e, r) {
|
|
16502
|
-
invoke(t, n, e, r);
|
|
16503
|
-
});
|
|
16504
|
-
}
|
|
16505
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
16506
|
-
}
|
|
16507
|
-
});
|
|
16508
|
-
}
|
|
16509
|
-
function makeInvokeMethod(e, r, n) {
|
|
16510
|
-
var o = h;
|
|
16511
|
-
return function (i, a) {
|
|
16512
|
-
if (o === f) throw new Error("Generator is already running");
|
|
16513
|
-
if (o === s) {
|
|
16514
|
-
if ("throw" === i) throw a;
|
|
16515
|
-
return {
|
|
16516
|
-
value: t,
|
|
16517
|
-
done: !0
|
|
16518
|
-
};
|
|
16519
|
-
}
|
|
16520
|
-
for (n.method = i, n.arg = a;;) {
|
|
16521
|
-
var c = n.delegate;
|
|
16522
|
-
if (c) {
|
|
16523
|
-
var u = maybeInvokeDelegate(c, n);
|
|
16524
|
-
if (u) {
|
|
16525
|
-
if (u === y) continue;
|
|
16526
|
-
return u;
|
|
16527
|
-
}
|
|
16528
|
-
}
|
|
16529
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
16530
|
-
if (o === h) throw o = s, n.arg;
|
|
16531
|
-
n.dispatchException(n.arg);
|
|
16532
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
16533
|
-
o = f;
|
|
16534
|
-
var p = tryCatch(e, r, n);
|
|
16535
|
-
if ("normal" === p.type) {
|
|
16536
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
16537
|
-
return {
|
|
16538
|
-
value: p.arg,
|
|
16539
|
-
done: n.done
|
|
16540
|
-
};
|
|
16541
|
-
}
|
|
16542
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
16543
|
-
}
|
|
16544
|
-
};
|
|
16545
|
-
}
|
|
16546
|
-
function maybeInvokeDelegate(e, r) {
|
|
16547
|
-
var n = r.method,
|
|
16548
|
-
o = e.iterator[n];
|
|
16549
|
-
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;
|
|
16550
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
16551
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
16552
|
-
var a = i.arg;
|
|
16553
|
-
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);
|
|
16554
|
-
}
|
|
16555
|
-
function pushTryEntry(t) {
|
|
16556
|
-
var e = {
|
|
16557
|
-
tryLoc: t[0]
|
|
16558
|
-
};
|
|
16559
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
16560
|
-
}
|
|
16561
|
-
function resetTryEntry(t) {
|
|
16562
|
-
var e = t.completion || {};
|
|
16563
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
16564
|
-
}
|
|
16565
|
-
function Context(t) {
|
|
16566
|
-
this.tryEntries = [{
|
|
16567
|
-
tryLoc: "root"
|
|
16568
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
16569
|
-
}
|
|
16570
|
-
function values(e) {
|
|
16571
|
-
if (e || "" === e) {
|
|
16572
|
-
var r = e[a];
|
|
16573
|
-
if (r) return r.call(e);
|
|
16574
|
-
if ("function" == typeof e.next) return e;
|
|
16575
|
-
if (!isNaN(e.length)) {
|
|
16576
|
-
var o = -1,
|
|
16577
|
-
i = function next() {
|
|
16578
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
16579
|
-
return next.value = t, next.done = !0, next;
|
|
16580
|
-
};
|
|
16581
|
-
return i.next = i;
|
|
16582
|
-
}
|
|
16583
|
-
}
|
|
16584
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
16585
|
-
}
|
|
16586
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
16587
|
-
value: GeneratorFunctionPrototype,
|
|
16588
|
-
configurable: !0
|
|
16589
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
16590
|
-
value: GeneratorFunction,
|
|
16591
|
-
configurable: !0
|
|
16592
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
16593
|
-
var e = "function" == typeof t && t.constructor;
|
|
16594
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
16595
|
-
}, e.mark = function (t) {
|
|
16596
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
16597
|
-
}, e.awrap = function (t) {
|
|
16598
|
-
return {
|
|
16599
|
-
__await: t
|
|
16600
|
-
};
|
|
16601
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
16602
|
-
return this;
|
|
16603
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
16604
|
-
void 0 === i && (i = Promise);
|
|
16605
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
16606
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
16607
|
-
return t.done ? t.value : a.next();
|
|
16608
|
-
});
|
|
16609
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
16610
|
-
return this;
|
|
16611
|
-
}), define(g, "toString", function () {
|
|
16612
|
-
return "[object Generator]";
|
|
16613
|
-
}), e.keys = function (t) {
|
|
16614
|
-
var e = Object(t),
|
|
16615
|
-
r = [];
|
|
16616
|
-
for (var n in e) r.push(n);
|
|
16617
|
-
return r.reverse(), function next() {
|
|
16618
|
-
for (; r.length;) {
|
|
16619
|
-
var t = r.pop();
|
|
16620
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
16621
|
-
}
|
|
16622
|
-
return next.done = !0, next;
|
|
16623
|
-
};
|
|
16624
|
-
}, e.values = values, Context.prototype = {
|
|
16625
|
-
constructor: Context,
|
|
16626
|
-
reset: function reset(e) {
|
|
16627
|
-
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);
|
|
16628
|
-
},
|
|
16629
|
-
stop: function stop() {
|
|
16630
|
-
this.done = !0;
|
|
16631
|
-
var t = this.tryEntries[0].completion;
|
|
16632
|
-
if ("throw" === t.type) throw t.arg;
|
|
16633
|
-
return this.rval;
|
|
16634
|
-
},
|
|
16635
|
-
dispatchException: function dispatchException(e) {
|
|
16636
|
-
if (this.done) throw e;
|
|
16637
|
-
var r = this;
|
|
16638
|
-
function handle(n, o) {
|
|
16639
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
16640
|
-
}
|
|
16641
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
16642
|
-
var i = this.tryEntries[o],
|
|
16643
|
-
a = i.completion;
|
|
16644
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
16645
|
-
if (i.tryLoc <= this.prev) {
|
|
16646
|
-
var c = n.call(i, "catchLoc"),
|
|
16647
|
-
u = n.call(i, "finallyLoc");
|
|
16648
|
-
if (c && u) {
|
|
16649
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16650
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16651
|
-
} else if (c) {
|
|
16652
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
16653
|
-
} else {
|
|
16654
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
16655
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
16656
|
-
}
|
|
16657
|
-
}
|
|
16658
|
-
}
|
|
16659
|
-
},
|
|
16660
|
-
abrupt: function abrupt(t, e) {
|
|
16661
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
16662
|
-
var o = this.tryEntries[r];
|
|
16663
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
16664
|
-
var i = o;
|
|
16665
|
-
break;
|
|
16666
|
-
}
|
|
16667
|
-
}
|
|
16668
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
16669
|
-
var a = i ? i.completion : {};
|
|
16670
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
16671
|
-
},
|
|
16672
|
-
complete: function complete(t, e) {
|
|
16673
|
-
if ("throw" === t.type) throw t.arg;
|
|
16674
|
-
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;
|
|
16675
|
-
},
|
|
16676
|
-
finish: function finish(t) {
|
|
16677
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16678
|
-
var r = this.tryEntries[e];
|
|
16679
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
16680
|
-
}
|
|
16681
|
-
},
|
|
16682
|
-
"catch": function _catch(t) {
|
|
16683
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
16684
|
-
var r = this.tryEntries[e];
|
|
16685
|
-
if (r.tryLoc === t) {
|
|
16686
|
-
var n = r.completion;
|
|
16687
|
-
if ("throw" === n.type) {
|
|
16688
|
-
var o = n.arg;
|
|
16689
|
-
resetTryEntry(r);
|
|
16690
|
-
}
|
|
16691
|
-
return o;
|
|
16692
|
-
}
|
|
16693
|
-
}
|
|
16694
|
-
throw new Error("illegal catch attempt");
|
|
16695
|
-
},
|
|
16696
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
16697
|
-
return this.delegate = {
|
|
16698
|
-
iterator: values(e),
|
|
16699
|
-
resultName: r,
|
|
16700
|
-
nextLoc: n
|
|
16701
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
16702
|
-
}
|
|
16703
|
-
}, e;
|
|
16704
|
-
}
|
|
16705
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16706
|
-
} (regeneratorRuntime$1));
|
|
16707
|
-
return regeneratorRuntime$1.exports;
|
|
16708
|
-
}
|
|
16709
|
-
|
|
16710
|
-
var regenerator;
|
|
16711
|
-
var hasRequiredRegenerator;
|
|
16712
|
-
|
|
16713
|
-
function requireRegenerator () {
|
|
16714
|
-
if (hasRequiredRegenerator) return regenerator;
|
|
16715
|
-
hasRequiredRegenerator = 1;
|
|
16716
|
-
// TODO(Babel 8): Remove this file.
|
|
16210
|
+
/**
|
|
16211
|
+
* Constructor to create a storage for our `EE` objects.
|
|
16212
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
16213
|
+
*
|
|
16214
|
+
* @constructor
|
|
16215
|
+
* @private
|
|
16216
|
+
*/
|
|
16217
|
+
function Events() {}
|
|
16717
16218
|
|
|
16718
|
-
|
|
16719
|
-
|
|
16219
|
+
//
|
|
16220
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
16221
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
16222
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
16223
|
+
// character to make sure that the built-in object properties are not
|
|
16224
|
+
// overridden or used as an attack vector.
|
|
16225
|
+
//
|
|
16226
|
+
if (Object.create) {
|
|
16227
|
+
Events.prototype = Object.create(null);
|
|
16720
16228
|
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
|
|
16725
|
-
if (
|
|
16726
|
-
globalThis.regeneratorRuntime = runtime;
|
|
16727
|
-
} else {
|
|
16728
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
16729
|
-
}
|
|
16229
|
+
//
|
|
16230
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
16231
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
16232
|
+
//
|
|
16233
|
+
if (!new Events().__proto__) prefix = false;
|
|
16730
16234
|
}
|
|
16731
|
-
return regenerator;
|
|
16732
|
-
}
|
|
16733
|
-
|
|
16734
|
-
var asyncToGenerator = {exports: {}};
|
|
16735
|
-
|
|
16736
|
-
var hasRequiredAsyncToGenerator;
|
|
16737
|
-
|
|
16738
|
-
function requireAsyncToGenerator () {
|
|
16739
|
-
if (hasRequiredAsyncToGenerator) return asyncToGenerator.exports;
|
|
16740
|
-
hasRequiredAsyncToGenerator = 1;
|
|
16741
|
-
(function (module) {
|
|
16742
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16743
|
-
try {
|
|
16744
|
-
var info = gen[key](arg);
|
|
16745
|
-
var value = info.value;
|
|
16746
|
-
} catch (error) {
|
|
16747
|
-
reject(error);
|
|
16748
|
-
return;
|
|
16749
|
-
}
|
|
16750
|
-
if (info.done) {
|
|
16751
|
-
resolve(value);
|
|
16752
|
-
} else {
|
|
16753
|
-
Promise.resolve(value).then(_next, _throw);
|
|
16754
|
-
}
|
|
16755
|
-
}
|
|
16756
|
-
function _asyncToGenerator(fn) {
|
|
16757
|
-
return function () {
|
|
16758
|
-
var self = this,
|
|
16759
|
-
args = arguments;
|
|
16760
|
-
return new Promise(function (resolve, reject) {
|
|
16761
|
-
var gen = fn.apply(self, args);
|
|
16762
|
-
function _next(value) {
|
|
16763
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
16764
|
-
}
|
|
16765
|
-
function _throw(err) {
|
|
16766
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
16767
|
-
}
|
|
16768
|
-
_next(undefined);
|
|
16769
|
-
});
|
|
16770
|
-
};
|
|
16771
|
-
}
|
|
16772
|
-
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16773
|
-
} (asyncToGenerator));
|
|
16774
|
-
return asyncToGenerator.exports;
|
|
16775
|
-
}
|
|
16776
|
-
|
|
16777
|
-
var classCallCheck = {exports: {}};
|
|
16778
|
-
|
|
16779
|
-
var hasRequiredClassCallCheck;
|
|
16780
|
-
|
|
16781
|
-
function requireClassCallCheck () {
|
|
16782
|
-
if (hasRequiredClassCallCheck) return classCallCheck.exports;
|
|
16783
|
-
hasRequiredClassCallCheck = 1;
|
|
16784
|
-
(function (module) {
|
|
16785
|
-
function _classCallCheck(instance, Constructor) {
|
|
16786
|
-
if (!(instance instanceof Constructor)) {
|
|
16787
|
-
throw new TypeError("Cannot call a class as a function");
|
|
16788
|
-
}
|
|
16789
|
-
}
|
|
16790
|
-
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16791
|
-
} (classCallCheck));
|
|
16792
|
-
return classCallCheck.exports;
|
|
16793
|
-
}
|
|
16794
|
-
|
|
16795
|
-
var createClass = {exports: {}};
|
|
16796
|
-
|
|
16797
|
-
var toPropertyKey = {exports: {}};
|
|
16798
|
-
|
|
16799
|
-
var toPrimitive = {exports: {}};
|
|
16800
|
-
|
|
16801
|
-
var hasRequiredToPrimitive;
|
|
16802
|
-
|
|
16803
|
-
function requireToPrimitive () {
|
|
16804
|
-
if (hasRequiredToPrimitive) return toPrimitive.exports;
|
|
16805
|
-
hasRequiredToPrimitive = 1;
|
|
16806
|
-
(function (module) {
|
|
16807
|
-
var _typeof = require_typeof()["default"];
|
|
16808
|
-
function _toPrimitive(input, hint) {
|
|
16809
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
16810
|
-
var prim = input[Symbol.toPrimitive];
|
|
16811
|
-
if (prim !== undefined) {
|
|
16812
|
-
var res = prim.call(input, hint || "default");
|
|
16813
|
-
if (_typeof(res) !== "object") return res;
|
|
16814
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16815
|
-
}
|
|
16816
|
-
return (hint === "string" ? String : Number)(input);
|
|
16817
|
-
}
|
|
16818
|
-
module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16819
|
-
} (toPrimitive));
|
|
16820
|
-
return toPrimitive.exports;
|
|
16821
|
-
}
|
|
16822
|
-
|
|
16823
|
-
var hasRequiredToPropertyKey;
|
|
16824
|
-
|
|
16825
|
-
function requireToPropertyKey () {
|
|
16826
|
-
if (hasRequiredToPropertyKey) return toPropertyKey.exports;
|
|
16827
|
-
hasRequiredToPropertyKey = 1;
|
|
16828
|
-
(function (module) {
|
|
16829
|
-
var _typeof = require_typeof()["default"];
|
|
16830
|
-
var toPrimitive = requireToPrimitive();
|
|
16831
|
-
function _toPropertyKey(arg) {
|
|
16832
|
-
var key = toPrimitive(arg, "string");
|
|
16833
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
16834
|
-
}
|
|
16835
|
-
module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16836
|
-
} (toPropertyKey));
|
|
16837
|
-
return toPropertyKey.exports;
|
|
16838
|
-
}
|
|
16839
|
-
|
|
16840
|
-
var hasRequiredCreateClass;
|
|
16841
|
-
|
|
16842
|
-
function requireCreateClass () {
|
|
16843
|
-
if (hasRequiredCreateClass) return createClass.exports;
|
|
16844
|
-
hasRequiredCreateClass = 1;
|
|
16845
|
-
(function (module) {
|
|
16846
|
-
var toPropertyKey = requireToPropertyKey();
|
|
16847
|
-
function _defineProperties(target, props) {
|
|
16848
|
-
for (var i = 0; i < props.length; i++) {
|
|
16849
|
-
var descriptor = props[i];
|
|
16850
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
16851
|
-
descriptor.configurable = true;
|
|
16852
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16853
|
-
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
16854
|
-
}
|
|
16855
|
-
}
|
|
16856
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
16857
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
16858
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
16859
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
16860
|
-
writable: false
|
|
16861
|
-
});
|
|
16862
|
-
return Constructor;
|
|
16863
|
-
}
|
|
16864
|
-
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16865
|
-
} (createClass));
|
|
16866
|
-
return createClass.exports;
|
|
16867
|
-
}
|
|
16868
|
-
|
|
16869
|
-
var inherits = {exports: {}};
|
|
16870
|
-
|
|
16871
|
-
var setPrototypeOf = {exports: {}};
|
|
16872
|
-
|
|
16873
|
-
var hasRequiredSetPrototypeOf;
|
|
16874
|
-
|
|
16875
|
-
function requireSetPrototypeOf () {
|
|
16876
|
-
if (hasRequiredSetPrototypeOf) return setPrototypeOf.exports;
|
|
16877
|
-
hasRequiredSetPrototypeOf = 1;
|
|
16878
|
-
(function (module) {
|
|
16879
|
-
function _setPrototypeOf(o, p) {
|
|
16880
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
16881
|
-
o.__proto__ = p;
|
|
16882
|
-
return o;
|
|
16883
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16884
|
-
return _setPrototypeOf(o, p);
|
|
16885
|
-
}
|
|
16886
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16887
|
-
} (setPrototypeOf));
|
|
16888
|
-
return setPrototypeOf.exports;
|
|
16889
|
-
}
|
|
16890
|
-
|
|
16891
|
-
var hasRequiredInherits;
|
|
16892
|
-
|
|
16893
|
-
function requireInherits () {
|
|
16894
|
-
if (hasRequiredInherits) return inherits.exports;
|
|
16895
|
-
hasRequiredInherits = 1;
|
|
16896
|
-
(function (module) {
|
|
16897
|
-
var setPrototypeOf = requireSetPrototypeOf();
|
|
16898
|
-
function _inherits(subClass, superClass) {
|
|
16899
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
16900
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
16901
|
-
}
|
|
16902
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
16903
|
-
constructor: {
|
|
16904
|
-
value: subClass,
|
|
16905
|
-
writable: true,
|
|
16906
|
-
configurable: true
|
|
16907
|
-
}
|
|
16908
|
-
});
|
|
16909
|
-
Object.defineProperty(subClass, "prototype", {
|
|
16910
|
-
writable: false
|
|
16911
|
-
});
|
|
16912
|
-
if (superClass) setPrototypeOf(subClass, superClass);
|
|
16913
|
-
}
|
|
16914
|
-
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16915
|
-
} (inherits));
|
|
16916
|
-
return inherits.exports;
|
|
16917
|
-
}
|
|
16918
|
-
|
|
16919
|
-
var possibleConstructorReturn = {exports: {}};
|
|
16920
|
-
|
|
16921
|
-
var assertThisInitialized = {exports: {}};
|
|
16922
|
-
|
|
16923
|
-
var hasRequiredAssertThisInitialized;
|
|
16924
|
-
|
|
16925
|
-
function requireAssertThisInitialized () {
|
|
16926
|
-
if (hasRequiredAssertThisInitialized) return assertThisInitialized.exports;
|
|
16927
|
-
hasRequiredAssertThisInitialized = 1;
|
|
16928
|
-
(function (module) {
|
|
16929
|
-
function _assertThisInitialized(self) {
|
|
16930
|
-
if (self === void 0) {
|
|
16931
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16932
|
-
}
|
|
16933
|
-
return self;
|
|
16934
|
-
}
|
|
16935
|
-
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16936
|
-
} (assertThisInitialized));
|
|
16937
|
-
return assertThisInitialized.exports;
|
|
16938
|
-
}
|
|
16939
|
-
|
|
16940
|
-
var hasRequiredPossibleConstructorReturn;
|
|
16941
|
-
|
|
16942
|
-
function requirePossibleConstructorReturn () {
|
|
16943
|
-
if (hasRequiredPossibleConstructorReturn) return possibleConstructorReturn.exports;
|
|
16944
|
-
hasRequiredPossibleConstructorReturn = 1;
|
|
16945
|
-
(function (module) {
|
|
16946
|
-
var _typeof = require_typeof()["default"];
|
|
16947
|
-
var assertThisInitialized = requireAssertThisInitialized();
|
|
16948
|
-
function _possibleConstructorReturn(self, call) {
|
|
16949
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
16950
|
-
return call;
|
|
16951
|
-
} else if (call !== void 0) {
|
|
16952
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
16953
|
-
}
|
|
16954
|
-
return assertThisInitialized(self);
|
|
16955
|
-
}
|
|
16956
|
-
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16957
|
-
} (possibleConstructorReturn));
|
|
16958
|
-
return possibleConstructorReturn.exports;
|
|
16959
|
-
}
|
|
16960
|
-
|
|
16961
|
-
var getPrototypeOf = {exports: {}};
|
|
16962
|
-
|
|
16963
|
-
var hasRequiredGetPrototypeOf;
|
|
16964
|
-
|
|
16965
|
-
function requireGetPrototypeOf () {
|
|
16966
|
-
if (hasRequiredGetPrototypeOf) return getPrototypeOf.exports;
|
|
16967
|
-
hasRequiredGetPrototypeOf = 1;
|
|
16968
|
-
(function (module) {
|
|
16969
|
-
function _getPrototypeOf(o) {
|
|
16970
|
-
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
16971
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
16972
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16973
|
-
return _getPrototypeOf(o);
|
|
16974
|
-
}
|
|
16975
|
-
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
16976
|
-
} (getPrototypeOf));
|
|
16977
|
-
return getPrototypeOf.exports;
|
|
16978
|
-
}
|
|
16979
|
-
|
|
16980
|
-
var eventemitter3 = {exports: {}};
|
|
16981
|
-
|
|
16982
|
-
var hasRequiredEventemitter3;
|
|
16983
|
-
|
|
16984
|
-
function requireEventemitter3 () {
|
|
16985
|
-
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
16986
|
-
hasRequiredEventemitter3 = 1;
|
|
16987
|
-
(function (module) {
|
|
16988
|
-
|
|
16989
|
-
var has = Object.prototype.hasOwnProperty
|
|
16990
|
-
, prefix = '~';
|
|
16991
|
-
|
|
16992
|
-
/**
|
|
16993
|
-
* Constructor to create a storage for our `EE` objects.
|
|
16994
|
-
* An `Events` instance is a plain object whose properties are event names.
|
|
16995
|
-
*
|
|
16996
|
-
* @constructor
|
|
16997
|
-
* @private
|
|
16998
|
-
*/
|
|
16999
|
-
function Events() {}
|
|
17000
|
-
|
|
17001
|
-
//
|
|
17002
|
-
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
17003
|
-
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
17004
|
-
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
17005
|
-
// character to make sure that the built-in object properties are not
|
|
17006
|
-
// overridden or used as an attack vector.
|
|
17007
|
-
//
|
|
17008
|
-
if (Object.create) {
|
|
17009
|
-
Events.prototype = Object.create(null);
|
|
17010
|
-
|
|
17011
|
-
//
|
|
17012
|
-
// This hack is needed because the `__proto__` property is still inherited in
|
|
17013
|
-
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
17014
|
-
//
|
|
17015
|
-
if (!new Events().__proto__) prefix = false;
|
|
17016
|
-
}
|
|
17017
|
-
|
|
17018
|
-
/**
|
|
17019
|
-
* Representation of a single event listener.
|
|
17020
|
-
*
|
|
17021
|
-
* @param {Function} fn The listener function.
|
|
17022
|
-
* @param {*} context The context to invoke the listener with.
|
|
17023
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
17024
|
-
* @constructor
|
|
17025
|
-
* @private
|
|
17026
|
-
*/
|
|
17027
|
-
function EE(fn, context, once) {
|
|
17028
|
-
this.fn = fn;
|
|
17029
|
-
this.context = context;
|
|
17030
|
-
this.once = once || false;
|
|
17031
|
-
}
|
|
17032
|
-
|
|
17033
|
-
/**
|
|
17034
|
-
* Add a listener for a given event.
|
|
17035
|
-
*
|
|
17036
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
17037
|
-
* @param {(String|Symbol)} event The event name.
|
|
17038
|
-
* @param {Function} fn The listener function.
|
|
17039
|
-
* @param {*} context The context to invoke the listener with.
|
|
17040
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
17041
|
-
* @returns {EventEmitter}
|
|
17042
|
-
* @private
|
|
17043
|
-
*/
|
|
17044
|
-
function addListener(emitter, event, fn, context, once) {
|
|
17045
|
-
if (typeof fn !== 'function') {
|
|
17046
|
-
throw new TypeError('The listener must be a function');
|
|
17047
|
-
}
|
|
17048
|
-
|
|
17049
|
-
var listener = new EE(fn, context || emitter, once)
|
|
17050
|
-
, evt = prefix ? prefix + event : event;
|
|
17051
|
-
|
|
17052
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
17053
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
17054
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
17055
|
-
|
|
17056
|
-
return emitter;
|
|
17057
|
-
}
|
|
17058
|
-
|
|
17059
|
-
/**
|
|
17060
|
-
* Clear event by name.
|
|
17061
|
-
*
|
|
17062
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
17063
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
17064
|
-
* @private
|
|
17065
|
-
*/
|
|
17066
|
-
function clearEvent(emitter, evt) {
|
|
17067
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
17068
|
-
else delete emitter._events[evt];
|
|
17069
|
-
}
|
|
17070
|
-
|
|
17071
|
-
/**
|
|
17072
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
17073
|
-
* `EventEmitter` interface.
|
|
17074
|
-
*
|
|
17075
|
-
* @constructor
|
|
17076
|
-
* @public
|
|
17077
|
-
*/
|
|
17078
|
-
function EventEmitter() {
|
|
17079
|
-
this._events = new Events();
|
|
17080
|
-
this._eventsCount = 0;
|
|
17081
|
-
}
|
|
17082
|
-
|
|
17083
|
-
/**
|
|
17084
|
-
* Return an array listing the events for which the emitter has registered
|
|
17085
|
-
* listeners.
|
|
17086
|
-
*
|
|
17087
|
-
* @returns {Array}
|
|
17088
|
-
* @public
|
|
17089
|
-
*/
|
|
17090
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
17091
|
-
var names = []
|
|
17092
|
-
, events
|
|
17093
|
-
, name;
|
|
17094
|
-
|
|
17095
|
-
if (this._eventsCount === 0) return names;
|
|
17096
|
-
|
|
17097
|
-
for (name in (events = this._events)) {
|
|
17098
|
-
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
17099
|
-
}
|
|
17100
|
-
|
|
17101
|
-
if (Object.getOwnPropertySymbols) {
|
|
17102
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
17103
|
-
}
|
|
17104
|
-
|
|
17105
|
-
return names;
|
|
17106
|
-
};
|
|
17107
|
-
|
|
17108
|
-
/**
|
|
17109
|
-
* Return the listeners registered for a given event.
|
|
17110
|
-
*
|
|
17111
|
-
* @param {(String|Symbol)} event The event name.
|
|
17112
|
-
* @returns {Array} The registered listeners.
|
|
17113
|
-
* @public
|
|
17114
|
-
*/
|
|
17115
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
17116
|
-
var evt = prefix ? prefix + event : event
|
|
17117
|
-
, handlers = this._events[evt];
|
|
17118
|
-
|
|
17119
|
-
if (!handlers) return [];
|
|
17120
|
-
if (handlers.fn) return [handlers.fn];
|
|
17121
|
-
|
|
17122
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
17123
|
-
ee[i] = handlers[i].fn;
|
|
17124
|
-
}
|
|
17125
|
-
|
|
17126
|
-
return ee;
|
|
17127
|
-
};
|
|
17128
|
-
|
|
17129
|
-
/**
|
|
17130
|
-
* Return the number of listeners listening to a given event.
|
|
17131
|
-
*
|
|
17132
|
-
* @param {(String|Symbol)} event The event name.
|
|
17133
|
-
* @returns {Number} The number of listeners.
|
|
17134
|
-
* @public
|
|
17135
|
-
*/
|
|
17136
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
17137
|
-
var evt = prefix ? prefix + event : event
|
|
17138
|
-
, listeners = this._events[evt];
|
|
17139
|
-
|
|
17140
|
-
if (!listeners) return 0;
|
|
17141
|
-
if (listeners.fn) return 1;
|
|
17142
|
-
return listeners.length;
|
|
17143
|
-
};
|
|
17144
|
-
|
|
17145
|
-
/**
|
|
17146
|
-
* Calls each of the listeners registered for a given event.
|
|
17147
|
-
*
|
|
17148
|
-
* @param {(String|Symbol)} event The event name.
|
|
17149
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
17150
|
-
* @public
|
|
17151
|
-
*/
|
|
17152
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
17153
|
-
var evt = prefix ? prefix + event : event;
|
|
17154
|
-
|
|
17155
|
-
if (!this._events[evt]) return false;
|
|
17156
|
-
|
|
17157
|
-
var listeners = this._events[evt]
|
|
17158
|
-
, len = arguments.length
|
|
17159
|
-
, args
|
|
17160
|
-
, i;
|
|
17161
|
-
|
|
17162
|
-
if (listeners.fn) {
|
|
17163
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
17164
|
-
|
|
17165
|
-
switch (len) {
|
|
17166
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
17167
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
17168
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
17169
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
17170
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
17171
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
17172
|
-
}
|
|
17173
|
-
|
|
17174
|
-
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
17175
|
-
args[i - 1] = arguments[i];
|
|
17176
|
-
}
|
|
17177
|
-
|
|
17178
|
-
listeners.fn.apply(listeners.context, args);
|
|
17179
|
-
} else {
|
|
17180
|
-
var length = listeners.length
|
|
17181
|
-
, j;
|
|
17182
|
-
|
|
17183
|
-
for (i = 0; i < length; i++) {
|
|
17184
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
17185
|
-
|
|
17186
|
-
switch (len) {
|
|
17187
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
17188
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
17189
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
17190
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
17191
|
-
default:
|
|
17192
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
17193
|
-
args[j - 1] = arguments[j];
|
|
17194
|
-
}
|
|
17195
|
-
|
|
17196
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
17197
|
-
}
|
|
17198
|
-
}
|
|
17199
|
-
}
|
|
17200
|
-
|
|
17201
|
-
return true;
|
|
17202
|
-
};
|
|
17203
|
-
|
|
17204
|
-
/**
|
|
17205
|
-
* Add a listener for a given event.
|
|
17206
|
-
*
|
|
17207
|
-
* @param {(String|Symbol)} event The event name.
|
|
17208
|
-
* @param {Function} fn The listener function.
|
|
17209
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
17210
|
-
* @returns {EventEmitter} `this`.
|
|
17211
|
-
* @public
|
|
17212
|
-
*/
|
|
17213
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
17214
|
-
return addListener(this, event, fn, context, false);
|
|
17215
|
-
};
|
|
17216
|
-
|
|
17217
|
-
/**
|
|
17218
|
-
* Add a one-time listener for a given event.
|
|
17219
|
-
*
|
|
17220
|
-
* @param {(String|Symbol)} event The event name.
|
|
17221
|
-
* @param {Function} fn The listener function.
|
|
17222
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
17223
|
-
* @returns {EventEmitter} `this`.
|
|
17224
|
-
* @public
|
|
17225
|
-
*/
|
|
17226
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
17227
|
-
return addListener(this, event, fn, context, true);
|
|
17228
|
-
};
|
|
17229
|
-
|
|
17230
|
-
/**
|
|
17231
|
-
* Remove the listeners of a given event.
|
|
17232
|
-
*
|
|
17233
|
-
* @param {(String|Symbol)} event The event name.
|
|
17234
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
17235
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
17236
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
17237
|
-
* @returns {EventEmitter} `this`.
|
|
17238
|
-
* @public
|
|
17239
|
-
*/
|
|
17240
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
17241
|
-
var evt = prefix ? prefix + event : event;
|
|
17242
|
-
|
|
17243
|
-
if (!this._events[evt]) return this;
|
|
17244
|
-
if (!fn) {
|
|
17245
|
-
clearEvent(this, evt);
|
|
17246
|
-
return this;
|
|
17247
|
-
}
|
|
17248
|
-
|
|
17249
|
-
var listeners = this._events[evt];
|
|
17250
|
-
|
|
17251
|
-
if (listeners.fn) {
|
|
17252
|
-
if (
|
|
17253
|
-
listeners.fn === fn &&
|
|
17254
|
-
(!once || listeners.once) &&
|
|
17255
|
-
(!context || listeners.context === context)
|
|
17256
|
-
) {
|
|
17257
|
-
clearEvent(this, evt);
|
|
17258
|
-
}
|
|
17259
|
-
} else {
|
|
17260
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
17261
|
-
if (
|
|
17262
|
-
listeners[i].fn !== fn ||
|
|
17263
|
-
(once && !listeners[i].once) ||
|
|
17264
|
-
(context && listeners[i].context !== context)
|
|
17265
|
-
) {
|
|
17266
|
-
events.push(listeners[i]);
|
|
17267
|
-
}
|
|
17268
|
-
}
|
|
17269
|
-
|
|
17270
|
-
//
|
|
17271
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
17272
|
-
//
|
|
17273
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
17274
|
-
else clearEvent(this, evt);
|
|
17275
|
-
}
|
|
17276
|
-
|
|
17277
|
-
return this;
|
|
17278
|
-
};
|
|
17279
|
-
|
|
17280
|
-
/**
|
|
17281
|
-
* Remove all listeners, or those of the specified event.
|
|
17282
|
-
*
|
|
17283
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
17284
|
-
* @returns {EventEmitter} `this`.
|
|
17285
|
-
* @public
|
|
17286
|
-
*/
|
|
17287
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
17288
|
-
var evt;
|
|
17289
|
-
|
|
17290
|
-
if (event) {
|
|
17291
|
-
evt = prefix ? prefix + event : event;
|
|
17292
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
17293
|
-
} else {
|
|
17294
|
-
this._events = new Events();
|
|
17295
|
-
this._eventsCount = 0;
|
|
17296
|
-
}
|
|
17297
|
-
|
|
17298
|
-
return this;
|
|
17299
|
-
};
|
|
17300
|
-
|
|
17301
|
-
//
|
|
17302
|
-
// Alias methods names because people roll like that.
|
|
17303
|
-
//
|
|
17304
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
17305
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
17306
|
-
|
|
17307
|
-
//
|
|
17308
|
-
// Expose the prefix.
|
|
17309
|
-
//
|
|
17310
|
-
EventEmitter.prefixed = prefix;
|
|
17311
|
-
|
|
17312
|
-
//
|
|
17313
|
-
// Allow `EventEmitter` to be imported as module namespace.
|
|
17314
|
-
//
|
|
17315
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
17316
|
-
|
|
17317
|
-
//
|
|
17318
|
-
// Expose the module.
|
|
17319
|
-
//
|
|
17320
|
-
{
|
|
17321
|
-
module.exports = EventEmitter;
|
|
17322
|
-
}
|
|
17323
|
-
} (eventemitter3));
|
|
17324
|
-
return eventemitter3.exports;
|
|
17325
|
-
}
|
|
17326
|
-
|
|
17327
|
-
/**
|
|
17328
|
-
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
17329
|
-
* according to the environment providing JSON RPC 2.0 support on top.
|
|
17330
|
-
* @module Client
|
|
17331
|
-
*/
|
|
17332
|
-
|
|
17333
|
-
(function (exports) {
|
|
17334
|
-
|
|
17335
|
-
var _interopRequireDefault = interopRequireDefaultExports;
|
|
17336
|
-
|
|
17337
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17338
|
-
value: true
|
|
17339
|
-
});
|
|
17340
|
-
exports["default"] = void 0;
|
|
17341
|
-
|
|
17342
|
-
var _regenerator = _interopRequireDefault(requireRegenerator());
|
|
17343
|
-
|
|
17344
|
-
var _asyncToGenerator2 = _interopRequireDefault(requireAsyncToGenerator());
|
|
17345
|
-
|
|
17346
|
-
var _typeof2 = _interopRequireDefault(require_typeof());
|
|
17347
|
-
|
|
17348
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
17349
16235
|
|
|
17350
|
-
|
|
16236
|
+
/**
|
|
16237
|
+
* Representation of a single event listener.
|
|
16238
|
+
*
|
|
16239
|
+
* @param {Function} fn The listener function.
|
|
16240
|
+
* @param {*} context The context to invoke the listener with.
|
|
16241
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
16242
|
+
* @constructor
|
|
16243
|
+
* @private
|
|
16244
|
+
*/
|
|
16245
|
+
function EE(fn, context, once) {
|
|
16246
|
+
this.fn = fn;
|
|
16247
|
+
this.context = context;
|
|
16248
|
+
this.once = once || false;
|
|
16249
|
+
}
|
|
17351
16250
|
|
|
17352
|
-
|
|
16251
|
+
/**
|
|
16252
|
+
* Add a listener for a given event.
|
|
16253
|
+
*
|
|
16254
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16255
|
+
* @param {(String|Symbol)} event The event name.
|
|
16256
|
+
* @param {Function} fn The listener function.
|
|
16257
|
+
* @param {*} context The context to invoke the listener with.
|
|
16258
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
16259
|
+
* @returns {EventEmitter}
|
|
16260
|
+
* @private
|
|
16261
|
+
*/
|
|
16262
|
+
function addListener(emitter, event, fn, context, once) {
|
|
16263
|
+
if (typeof fn !== 'function') {
|
|
16264
|
+
throw new TypeError('The listener must be a function');
|
|
16265
|
+
}
|
|
17353
16266
|
|
|
17354
|
-
|
|
16267
|
+
var listener = new EE(fn, context || emitter, once)
|
|
16268
|
+
, evt = prefix ? prefix + event : event;
|
|
17355
16269
|
|
|
17356
|
-
|
|
16270
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
16271
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
16272
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
17357
16273
|
|
|
17358
|
-
|
|
16274
|
+
return emitter;
|
|
16275
|
+
}
|
|
17359
16276
|
|
|
17360
|
-
|
|
16277
|
+
/**
|
|
16278
|
+
* Clear event by name.
|
|
16279
|
+
*
|
|
16280
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
16281
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
16282
|
+
* @private
|
|
16283
|
+
*/
|
|
16284
|
+
function clearEvent(emitter, evt) {
|
|
16285
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
16286
|
+
else delete emitter._events[evt];
|
|
16287
|
+
}
|
|
17361
16288
|
|
|
17362
|
-
|
|
16289
|
+
/**
|
|
16290
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
16291
|
+
* `EventEmitter` interface.
|
|
16292
|
+
*
|
|
16293
|
+
* @constructor
|
|
16294
|
+
* @public
|
|
16295
|
+
*/
|
|
16296
|
+
function EventEmitter() {
|
|
16297
|
+
this._events = new Events();
|
|
16298
|
+
this._eventsCount = 0;
|
|
16299
|
+
}
|
|
17363
16300
|
|
|
17364
|
-
|
|
17365
|
-
|
|
16301
|
+
/**
|
|
16302
|
+
* Return an array listing the events for which the emitter has registered
|
|
16303
|
+
* listeners.
|
|
16304
|
+
*
|
|
16305
|
+
* @returns {Array}
|
|
16306
|
+
* @public
|
|
16307
|
+
*/
|
|
16308
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
16309
|
+
var names = []
|
|
16310
|
+
, events
|
|
16311
|
+
, name;
|
|
17366
16312
|
|
|
17367
|
-
|
|
17368
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
17369
|
-
}
|
|
16313
|
+
if (this._eventsCount === 0) return names;
|
|
17370
16314
|
|
|
17371
|
-
|
|
17372
|
-
if (
|
|
16315
|
+
for (name in (events = this._events)) {
|
|
16316
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
17373
16317
|
}
|
|
17374
|
-
return t;
|
|
17375
|
-
}; // @ts-ignore
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
var CommonClient = /*#__PURE__*/function (_EventEmitter) {
|
|
17379
|
-
(0, _inherits2["default"])(CommonClient, _EventEmitter);
|
|
17380
|
-
|
|
17381
|
-
var _super = _createSuper(CommonClient);
|
|
17382
|
-
|
|
17383
|
-
/**
|
|
17384
|
-
* Instantiate a Client class.
|
|
17385
|
-
* @constructor
|
|
17386
|
-
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
17387
|
-
* @param {String} address - url to a websocket server
|
|
17388
|
-
* @param {Object} options - ws options object with reconnect parameters
|
|
17389
|
-
* @param {Function} generate_request_id - custom generation request Id
|
|
17390
|
-
* @return {CommonClient}
|
|
17391
|
-
*/
|
|
17392
|
-
function CommonClient(webSocketFactory) {
|
|
17393
|
-
var _this;
|
|
17394
|
-
|
|
17395
|
-
var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ws://localhost:8080";
|
|
17396
|
-
|
|
17397
|
-
var _a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
17398
|
-
|
|
17399
|
-
var generate_request_id = arguments.length > 3 ? arguments[3] : undefined;
|
|
17400
|
-
(0, _classCallCheck2["default"])(this, CommonClient);
|
|
17401
|
-
|
|
17402
|
-
var _a$autoconnect = _a.autoconnect,
|
|
17403
|
-
autoconnect = _a$autoconnect === void 0 ? true : _a$autoconnect,
|
|
17404
|
-
_a$reconnect = _a.reconnect,
|
|
17405
|
-
reconnect = _a$reconnect === void 0 ? true : _a$reconnect,
|
|
17406
|
-
_a$reconnect_interval = _a.reconnect_interval,
|
|
17407
|
-
reconnect_interval = _a$reconnect_interval === void 0 ? 1000 : _a$reconnect_interval,
|
|
17408
|
-
_a$max_reconnects = _a.max_reconnects,
|
|
17409
|
-
max_reconnects = _a$max_reconnects === void 0 ? 5 : _a$max_reconnects,
|
|
17410
|
-
rest_options = __rest(_a, ["autoconnect", "reconnect", "reconnect_interval", "max_reconnects"]);
|
|
17411
|
-
|
|
17412
|
-
_this = _super.call(this);
|
|
17413
|
-
_this.webSocketFactory = webSocketFactory;
|
|
17414
|
-
_this.queue = {};
|
|
17415
|
-
_this.rpc_id = 0;
|
|
17416
|
-
_this.address = address;
|
|
17417
|
-
_this.autoconnect = autoconnect;
|
|
17418
|
-
_this.ready = false;
|
|
17419
|
-
_this.reconnect = reconnect;
|
|
17420
|
-
_this.reconnect_timer_id = undefined;
|
|
17421
|
-
_this.reconnect_interval = reconnect_interval;
|
|
17422
|
-
_this.max_reconnects = max_reconnects;
|
|
17423
|
-
_this.rest_options = rest_options;
|
|
17424
|
-
_this.current_reconnects = 0;
|
|
17425
|
-
|
|
17426
|
-
_this.generate_request_id = generate_request_id || function () {
|
|
17427
|
-
return ++_this.rpc_id;
|
|
17428
|
-
};
|
|
17429
16318
|
|
|
17430
|
-
|
|
17431
|
-
|
|
17432
|
-
reconnect: _this.reconnect,
|
|
17433
|
-
reconnect_interval: _this.reconnect_interval,
|
|
17434
|
-
max_reconnects: _this.max_reconnects
|
|
17435
|
-
}, _this.rest_options));
|
|
17436
|
-
return _this;
|
|
16319
|
+
if (Object.getOwnPropertySymbols) {
|
|
16320
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
17437
16321
|
}
|
|
17438
|
-
/**
|
|
17439
|
-
* Connects to a defined server if not connected already.
|
|
17440
|
-
* @method
|
|
17441
|
-
* @return {Undefined}
|
|
17442
|
-
*/
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
(0, _createClass2["default"])(CommonClient, [{
|
|
17446
|
-
key: "connect",
|
|
17447
|
-
value: function connect() {
|
|
17448
|
-
if (this.socket) return;
|
|
17449
|
-
|
|
17450
|
-
this._connect(this.address, Object.assign({
|
|
17451
|
-
autoconnect: this.autoconnect,
|
|
17452
|
-
reconnect: this.reconnect,
|
|
17453
|
-
reconnect_interval: this.reconnect_interval,
|
|
17454
|
-
max_reconnects: this.max_reconnects
|
|
17455
|
-
}, this.rest_options));
|
|
17456
|
-
}
|
|
17457
|
-
/**
|
|
17458
|
-
* Calls a registered RPC method on server.
|
|
17459
|
-
* @method
|
|
17460
|
-
* @param {String} method - RPC method name
|
|
17461
|
-
* @param {Object|Array} params - optional method parameters
|
|
17462
|
-
* @param {Number} timeout - RPC reply timeout value
|
|
17463
|
-
* @param {Object} ws_opts - options passed to ws
|
|
17464
|
-
* @return {Promise}
|
|
17465
|
-
*/
|
|
17466
|
-
|
|
17467
|
-
}, {
|
|
17468
|
-
key: "call",
|
|
17469
|
-
value: function call(method, params, timeout, ws_opts) {
|
|
17470
|
-
var _this2 = this;
|
|
17471
|
-
|
|
17472
|
-
if (!ws_opts && "object" === (0, _typeof2["default"])(timeout)) {
|
|
17473
|
-
ws_opts = timeout;
|
|
17474
|
-
timeout = null;
|
|
17475
|
-
}
|
|
17476
|
-
|
|
17477
|
-
return new Promise(function (resolve, reject) {
|
|
17478
|
-
if (!_this2.ready) return reject(new Error("socket not ready"));
|
|
17479
16322
|
|
|
17480
|
-
|
|
16323
|
+
return names;
|
|
16324
|
+
};
|
|
17481
16325
|
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
16326
|
+
/**
|
|
16327
|
+
* Return the listeners registered for a given event.
|
|
16328
|
+
*
|
|
16329
|
+
* @param {(String|Symbol)} event The event name.
|
|
16330
|
+
* @returns {Array} The registered listeners.
|
|
16331
|
+
* @public
|
|
16332
|
+
*/
|
|
16333
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
16334
|
+
var evt = prefix ? prefix + event : event
|
|
16335
|
+
, handlers = this._events[evt];
|
|
17488
16336
|
|
|
17489
|
-
|
|
17490
|
-
|
|
17491
|
-
_this2.queue[rpc_id] = {
|
|
17492
|
-
promise: [resolve, reject]
|
|
17493
|
-
};
|
|
17494
|
-
|
|
17495
|
-
if (timeout) {
|
|
17496
|
-
_this2.queue[rpc_id].timeout = setTimeout(function () {
|
|
17497
|
-
delete _this2.queue[rpc_id];
|
|
17498
|
-
reject(new Error("reply timeout"));
|
|
17499
|
-
}, timeout);
|
|
17500
|
-
}
|
|
17501
|
-
});
|
|
17502
|
-
});
|
|
17503
|
-
}
|
|
17504
|
-
/**
|
|
17505
|
-
* Logins with the other side of the connection.
|
|
17506
|
-
* @method
|
|
17507
|
-
* @param {Object} params - Login credentials object
|
|
17508
|
-
* @return {Promise}
|
|
17509
|
-
*/
|
|
17510
|
-
|
|
17511
|
-
}, {
|
|
17512
|
-
key: "login",
|
|
17513
|
-
value: function () {
|
|
17514
|
-
var _login = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(params) {
|
|
17515
|
-
var resp;
|
|
17516
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17517
|
-
while (1) {
|
|
17518
|
-
switch (_context.prev = _context.next) {
|
|
17519
|
-
case 0:
|
|
17520
|
-
_context.next = 2;
|
|
17521
|
-
return this.call("rpc.login", params);
|
|
17522
|
-
|
|
17523
|
-
case 2:
|
|
17524
|
-
resp = _context.sent;
|
|
17525
|
-
|
|
17526
|
-
if (resp) {
|
|
17527
|
-
_context.next = 5;
|
|
17528
|
-
break;
|
|
17529
|
-
}
|
|
17530
|
-
|
|
17531
|
-
throw new Error("authentication failed");
|
|
17532
|
-
|
|
17533
|
-
case 5:
|
|
17534
|
-
return _context.abrupt("return", resp);
|
|
17535
|
-
|
|
17536
|
-
case 6:
|
|
17537
|
-
case "end":
|
|
17538
|
-
return _context.stop();
|
|
17539
|
-
}
|
|
17540
|
-
}
|
|
17541
|
-
}, _callee, this);
|
|
17542
|
-
}));
|
|
16337
|
+
if (!handlers) return [];
|
|
16338
|
+
if (handlers.fn) return [handlers.fn];
|
|
17543
16339
|
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
16340
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
16341
|
+
ee[i] = handlers[i].fn;
|
|
16342
|
+
}
|
|
17547
16343
|
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
/**
|
|
17551
|
-
* Fetches a list of client's methods registered on server.
|
|
17552
|
-
* @method
|
|
17553
|
-
* @return {Array}
|
|
17554
|
-
*/
|
|
17555
|
-
|
|
17556
|
-
}, {
|
|
17557
|
-
key: "listMethods",
|
|
17558
|
-
value: function () {
|
|
17559
|
-
var _listMethods = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
17560
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
17561
|
-
while (1) {
|
|
17562
|
-
switch (_context2.prev = _context2.next) {
|
|
17563
|
-
case 0:
|
|
17564
|
-
_context2.next = 2;
|
|
17565
|
-
return this.call("__listMethods");
|
|
17566
|
-
|
|
17567
|
-
case 2:
|
|
17568
|
-
return _context2.abrupt("return", _context2.sent);
|
|
17569
|
-
|
|
17570
|
-
case 3:
|
|
17571
|
-
case "end":
|
|
17572
|
-
return _context2.stop();
|
|
17573
|
-
}
|
|
17574
|
-
}
|
|
17575
|
-
}, _callee2, this);
|
|
17576
|
-
}));
|
|
16344
|
+
return ee;
|
|
16345
|
+
};
|
|
17577
16346
|
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
|
|
16347
|
+
/**
|
|
16348
|
+
* Return the number of listeners listening to a given event.
|
|
16349
|
+
*
|
|
16350
|
+
* @param {(String|Symbol)} event The event name.
|
|
16351
|
+
* @returns {Number} The number of listeners.
|
|
16352
|
+
* @public
|
|
16353
|
+
*/
|
|
16354
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
16355
|
+
var evt = prefix ? prefix + event : event
|
|
16356
|
+
, listeners = this._events[evt];
|
|
17581
16357
|
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
* @method
|
|
17587
|
-
* @param {String} method - RPC method name
|
|
17588
|
-
* @param {Object} params - optional method parameters
|
|
17589
|
-
* @return {Promise}
|
|
17590
|
-
*/
|
|
17591
|
-
|
|
17592
|
-
}, {
|
|
17593
|
-
key: "notify",
|
|
17594
|
-
value: function notify(method, params) {
|
|
17595
|
-
var _this3 = this;
|
|
17596
|
-
|
|
17597
|
-
return new Promise(function (resolve, reject) {
|
|
17598
|
-
if (!_this3.ready) return reject(new Error("socket not ready"));
|
|
17599
|
-
var message = {
|
|
17600
|
-
jsonrpc: "2.0",
|
|
17601
|
-
method: method,
|
|
17602
|
-
params: params || null
|
|
17603
|
-
};
|
|
16358
|
+
if (!listeners) return 0;
|
|
16359
|
+
if (listeners.fn) return 1;
|
|
16360
|
+
return listeners.length;
|
|
16361
|
+
};
|
|
17604
16362
|
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
16363
|
+
/**
|
|
16364
|
+
* Calls each of the listeners registered for a given event.
|
|
16365
|
+
*
|
|
16366
|
+
* @param {(String|Symbol)} event The event name.
|
|
16367
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
16368
|
+
* @public
|
|
16369
|
+
*/
|
|
16370
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
16371
|
+
var evt = prefix ? prefix + event : event;
|
|
16372
|
+
|
|
16373
|
+
if (!this._events[evt]) return false;
|
|
16374
|
+
|
|
16375
|
+
var listeners = this._events[evt]
|
|
16376
|
+
, len = arguments.length
|
|
16377
|
+
, args
|
|
16378
|
+
, i;
|
|
16379
|
+
|
|
16380
|
+
if (listeners.fn) {
|
|
16381
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
16382
|
+
|
|
16383
|
+
switch (len) {
|
|
16384
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
16385
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
16386
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
16387
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
16388
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
16389
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
17610
16390
|
}
|
|
17611
|
-
/**
|
|
17612
|
-
* Subscribes for a defined event.
|
|
17613
|
-
* @method
|
|
17614
|
-
* @param {String|Array} event - event name
|
|
17615
|
-
* @return {Undefined}
|
|
17616
|
-
* @throws {Error}
|
|
17617
|
-
*/
|
|
17618
|
-
|
|
17619
|
-
}, {
|
|
17620
|
-
key: "subscribe",
|
|
17621
|
-
value: function () {
|
|
17622
|
-
var _subscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(event) {
|
|
17623
|
-
var result;
|
|
17624
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
17625
|
-
while (1) {
|
|
17626
|
-
switch (_context3.prev = _context3.next) {
|
|
17627
|
-
case 0:
|
|
17628
|
-
if (typeof event === "string") event = [event];
|
|
17629
|
-
_context3.next = 3;
|
|
17630
|
-
return this.call("rpc.on", event);
|
|
17631
|
-
|
|
17632
|
-
case 3:
|
|
17633
|
-
result = _context3.sent;
|
|
17634
|
-
|
|
17635
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17636
|
-
_context3.next = 6;
|
|
17637
|
-
break;
|
|
17638
|
-
}
|
|
17639
|
-
|
|
17640
|
-
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
17641
|
-
|
|
17642
|
-
case 6:
|
|
17643
|
-
return _context3.abrupt("return", result);
|
|
17644
|
-
|
|
17645
|
-
case 7:
|
|
17646
|
-
case "end":
|
|
17647
|
-
return _context3.stop();
|
|
17648
|
-
}
|
|
17649
|
-
}
|
|
17650
|
-
}, _callee3, this);
|
|
17651
|
-
}));
|
|
17652
16391
|
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
}
|
|
17656
|
-
|
|
17657
|
-
return subscribe;
|
|
17658
|
-
}()
|
|
17659
|
-
/**
|
|
17660
|
-
* Unsubscribes from a defined event.
|
|
17661
|
-
* @method
|
|
17662
|
-
* @param {String|Array} event - event name
|
|
17663
|
-
* @return {Undefined}
|
|
17664
|
-
* @throws {Error}
|
|
17665
|
-
*/
|
|
17666
|
-
|
|
17667
|
-
}, {
|
|
17668
|
-
key: "unsubscribe",
|
|
17669
|
-
value: function () {
|
|
17670
|
-
var _unsubscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(event) {
|
|
17671
|
-
var result;
|
|
17672
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
17673
|
-
while (1) {
|
|
17674
|
-
switch (_context4.prev = _context4.next) {
|
|
17675
|
-
case 0:
|
|
17676
|
-
if (typeof event === "string") event = [event];
|
|
17677
|
-
_context4.next = 3;
|
|
17678
|
-
return this.call("rpc.off", event);
|
|
17679
|
-
|
|
17680
|
-
case 3:
|
|
17681
|
-
result = _context4.sent;
|
|
17682
|
-
|
|
17683
|
-
if (!(typeof event === "string" && result[event] !== "ok")) {
|
|
17684
|
-
_context4.next = 6;
|
|
17685
|
-
break;
|
|
17686
|
-
}
|
|
17687
|
-
|
|
17688
|
-
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
17689
|
-
|
|
17690
|
-
case 6:
|
|
17691
|
-
return _context4.abrupt("return", result);
|
|
17692
|
-
|
|
17693
|
-
case 7:
|
|
17694
|
-
case "end":
|
|
17695
|
-
return _context4.stop();
|
|
17696
|
-
}
|
|
17697
|
-
}
|
|
17698
|
-
}, _callee4, this);
|
|
17699
|
-
}));
|
|
17700
|
-
|
|
17701
|
-
function unsubscribe(_x3) {
|
|
17702
|
-
return _unsubscribe.apply(this, arguments);
|
|
17703
|
-
}
|
|
17704
|
-
|
|
17705
|
-
return unsubscribe;
|
|
17706
|
-
}()
|
|
17707
|
-
/**
|
|
17708
|
-
* Closes a WebSocket connection gracefully.
|
|
17709
|
-
* @method
|
|
17710
|
-
* @param {Number} code - socket close code
|
|
17711
|
-
* @param {String} data - optional data to be sent before closing
|
|
17712
|
-
* @return {Undefined}
|
|
17713
|
-
*/
|
|
17714
|
-
|
|
17715
|
-
}, {
|
|
17716
|
-
key: "close",
|
|
17717
|
-
value: function close(code, data) {
|
|
17718
|
-
this.socket.close(code || 1000, data);
|
|
16392
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
16393
|
+
args[i - 1] = arguments[i];
|
|
17719
16394
|
}
|
|
17720
|
-
/**
|
|
17721
|
-
* Connection/Message handler.
|
|
17722
|
-
* @method
|
|
17723
|
-
* @private
|
|
17724
|
-
* @param {String} address - WebSocket API address
|
|
17725
|
-
* @param {Object} options - ws options object
|
|
17726
|
-
* @return {Undefined}
|
|
17727
|
-
*/
|
|
17728
|
-
|
|
17729
|
-
}, {
|
|
17730
|
-
key: "_connect",
|
|
17731
|
-
value: function _connect(address, options) {
|
|
17732
|
-
var _this4 = this;
|
|
17733
|
-
|
|
17734
|
-
clearTimeout(this.reconnect_timer_id);
|
|
17735
|
-
this.socket = this.webSocketFactory(address, options);
|
|
17736
|
-
this.socket.addEventListener("open", function () {
|
|
17737
|
-
_this4.ready = true;
|
|
17738
|
-
|
|
17739
|
-
_this4.emit("open");
|
|
17740
|
-
|
|
17741
|
-
_this4.current_reconnects = 0;
|
|
17742
|
-
});
|
|
17743
|
-
this.socket.addEventListener("message", function (_ref) {
|
|
17744
|
-
var message = _ref.data;
|
|
17745
|
-
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
|
|
17746
|
-
|
|
17747
|
-
try {
|
|
17748
|
-
message = JSON.parse(message);
|
|
17749
|
-
} catch (error) {
|
|
17750
|
-
return;
|
|
17751
|
-
} // check if any listeners are attached and forward event
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
if (message.notification && _this4.listeners(message.notification).length) {
|
|
17755
|
-
if (!Object.keys(message.params).length) return _this4.emit(message.notification);
|
|
17756
|
-
var args = [message.notification];
|
|
17757
|
-
if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
|
|
17758
|
-
for (var i = 0; i < message.params.length; i++) {
|
|
17759
|
-
args.push(message.params[i]);
|
|
17760
|
-
} // run as microtask so that pending queue messages are resolved first
|
|
17761
|
-
// eslint-disable-next-line prefer-spread
|
|
17762
|
-
|
|
17763
|
-
return Promise.resolve().then(function () {
|
|
17764
|
-
_this4.emit.apply(_this4, args);
|
|
17765
|
-
});
|
|
17766
|
-
}
|
|
17767
16395
|
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
16396
|
+
listeners.fn.apply(listeners.context, args);
|
|
16397
|
+
} else {
|
|
16398
|
+
var length = listeners.length
|
|
16399
|
+
, j;
|
|
16400
|
+
|
|
16401
|
+
for (i = 0; i < length; i++) {
|
|
16402
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
16403
|
+
|
|
16404
|
+
switch (len) {
|
|
16405
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
16406
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
16407
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
16408
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
16409
|
+
default:
|
|
16410
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
16411
|
+
args[j - 1] = arguments[j];
|
|
17775
16412
|
}
|
|
17776
16413
|
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
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."));
|
|
17782
|
-
if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
|
|
17783
|
-
if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
|
|
17784
|
-
delete _this4.queue[message.id];
|
|
17785
|
-
});
|
|
17786
|
-
this.socket.addEventListener("error", function (error) {
|
|
17787
|
-
return _this4.emit("error", error);
|
|
17788
|
-
});
|
|
17789
|
-
this.socket.addEventListener("close", function (_ref2) {
|
|
17790
|
-
var code = _ref2.code,
|
|
17791
|
-
reason = _ref2.reason;
|
|
17792
|
-
if (_this4.ready) // Delay close event until internal state is updated
|
|
17793
|
-
setTimeout(function () {
|
|
17794
|
-
return _this4.emit("close", code, reason);
|
|
17795
|
-
}, 0);
|
|
17796
|
-
_this4.ready = false;
|
|
17797
|
-
_this4.socket = undefined;
|
|
17798
|
-
if (code === 1000) return;
|
|
17799
|
-
_this4.current_reconnects++;
|
|
17800
|
-
if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) _this4.reconnect_timer_id = setTimeout(function () {
|
|
17801
|
-
return _this4._connect(address, options);
|
|
17802
|
-
}, _this4.reconnect_interval);
|
|
17803
|
-
});
|
|
16414
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
16415
|
+
}
|
|
17804
16416
|
}
|
|
17805
|
-
}
|
|
17806
|
-
return CommonClient;
|
|
17807
|
-
}(_eventemitter.EventEmitter);
|
|
17808
|
-
|
|
17809
|
-
exports["default"] = CommonClient;
|
|
17810
|
-
} (client));
|
|
17811
|
-
|
|
17812
|
-
var RpcWebSocketCommonClient = /*@__PURE__*/getDefaultExportFromCjs(client);
|
|
17813
|
-
|
|
17814
|
-
var websocket_browser = {};
|
|
17815
|
-
|
|
17816
|
-
/**
|
|
17817
|
-
* WebSocket implements a browser-side WebSocket specification.
|
|
17818
|
-
* @module Client
|
|
17819
|
-
*/
|
|
17820
|
-
|
|
17821
|
-
(function (exports) {
|
|
17822
|
-
|
|
17823
|
-
var _interopRequireDefault = interopRequireDefaultExports;
|
|
17824
|
-
|
|
17825
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17826
|
-
value: true
|
|
17827
|
-
});
|
|
17828
|
-
exports["default"] = _default;
|
|
17829
|
-
|
|
17830
|
-
var _classCallCheck2 = _interopRequireDefault(requireClassCallCheck());
|
|
16417
|
+
}
|
|
17831
16418
|
|
|
17832
|
-
|
|
16419
|
+
return true;
|
|
16420
|
+
};
|
|
17833
16421
|
|
|
17834
|
-
|
|
16422
|
+
/**
|
|
16423
|
+
* Add a listener for a given event.
|
|
16424
|
+
*
|
|
16425
|
+
* @param {(String|Symbol)} event The event name.
|
|
16426
|
+
* @param {Function} fn The listener function.
|
|
16427
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16428
|
+
* @returns {EventEmitter} `this`.
|
|
16429
|
+
* @public
|
|
16430
|
+
*/
|
|
16431
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
16432
|
+
return addListener(this, event, fn, context, false);
|
|
16433
|
+
};
|
|
17835
16434
|
|
|
17836
|
-
|
|
16435
|
+
/**
|
|
16436
|
+
* Add a one-time listener for a given event.
|
|
16437
|
+
*
|
|
16438
|
+
* @param {(String|Symbol)} event The event name.
|
|
16439
|
+
* @param {Function} fn The listener function.
|
|
16440
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
16441
|
+
* @returns {EventEmitter} `this`.
|
|
16442
|
+
* @public
|
|
16443
|
+
*/
|
|
16444
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
16445
|
+
return addListener(this, event, fn, context, true);
|
|
16446
|
+
};
|
|
17837
16447
|
|
|
17838
|
-
|
|
16448
|
+
/**
|
|
16449
|
+
* Remove the listeners of a given event.
|
|
16450
|
+
*
|
|
16451
|
+
* @param {(String|Symbol)} event The event name.
|
|
16452
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
16453
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
16454
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
16455
|
+
* @returns {EventEmitter} `this`.
|
|
16456
|
+
* @public
|
|
16457
|
+
*/
|
|
16458
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
16459
|
+
var evt = prefix ? prefix + event : event;
|
|
17839
16460
|
|
|
17840
|
-
|
|
16461
|
+
if (!this._events[evt]) return this;
|
|
16462
|
+
if (!fn) {
|
|
16463
|
+
clearEvent(this, evt);
|
|
16464
|
+
return this;
|
|
16465
|
+
}
|
|
17841
16466
|
|
|
17842
|
-
|
|
16467
|
+
var listeners = this._events[evt];
|
|
17843
16468
|
|
|
17844
|
-
|
|
16469
|
+
if (listeners.fn) {
|
|
16470
|
+
if (
|
|
16471
|
+
listeners.fn === fn &&
|
|
16472
|
+
(!once || listeners.once) &&
|
|
16473
|
+
(!context || listeners.context === context)
|
|
16474
|
+
) {
|
|
16475
|
+
clearEvent(this, evt);
|
|
16476
|
+
}
|
|
16477
|
+
} else {
|
|
16478
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
16479
|
+
if (
|
|
16480
|
+
listeners[i].fn !== fn ||
|
|
16481
|
+
(once && !listeners[i].once) ||
|
|
16482
|
+
(context && listeners[i].context !== context)
|
|
16483
|
+
) {
|
|
16484
|
+
events.push(listeners[i]);
|
|
16485
|
+
}
|
|
16486
|
+
}
|
|
17845
16487
|
|
|
17846
|
-
|
|
17847
|
-
|
|
16488
|
+
//
|
|
16489
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
16490
|
+
//
|
|
16491
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
16492
|
+
else clearEvent(this, evt);
|
|
16493
|
+
}
|
|
17848
16494
|
|
|
17849
|
-
|
|
16495
|
+
return this;
|
|
16496
|
+
};
|
|
17850
16497
|
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
16498
|
+
/**
|
|
16499
|
+
* Remove all listeners, or those of the specified event.
|
|
16500
|
+
*
|
|
16501
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
16502
|
+
* @returns {EventEmitter} `this`.
|
|
16503
|
+
* @public
|
|
16504
|
+
*/
|
|
16505
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
16506
|
+
var evt;
|
|
17860
16507
|
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
16508
|
+
if (event) {
|
|
16509
|
+
evt = prefix ? prefix + event : event;
|
|
16510
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
16511
|
+
} else {
|
|
16512
|
+
this._events = new Events();
|
|
16513
|
+
this._eventsCount = 0;
|
|
16514
|
+
}
|
|
17864
16515
|
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
};
|
|
16516
|
+
return this;
|
|
16517
|
+
};
|
|
17868
16518
|
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
16519
|
+
//
|
|
16520
|
+
// Alias methods names because people roll like that.
|
|
16521
|
+
//
|
|
16522
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
16523
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
17872
16524
|
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
|
|
16525
|
+
//
|
|
16526
|
+
// Expose the prefix.
|
|
16527
|
+
//
|
|
16528
|
+
EventEmitter.prefixed = prefix;
|
|
17876
16529
|
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
16530
|
+
//
|
|
16531
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
16532
|
+
//
|
|
16533
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
17880
16534
|
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
* @param {(Object)} options - websocket options
|
|
17932
|
-
* @return {Undefined}
|
|
17933
|
-
*/
|
|
16535
|
+
//
|
|
16536
|
+
// Expose the module.
|
|
16537
|
+
//
|
|
16538
|
+
{
|
|
16539
|
+
module.exports = EventEmitter;
|
|
16540
|
+
}
|
|
16541
|
+
} (eventemitter3));
|
|
16542
|
+
|
|
16543
|
+
var eventemitter3Exports = eventemitter3.exports;
|
|
16544
|
+
|
|
16545
|
+
var utils = {};
|
|
16546
|
+
|
|
16547
|
+
Object.defineProperty(utils, "__esModule", { value: true });
|
|
16548
|
+
utils.createError = utils.DefaultDataPack = void 0;
|
|
16549
|
+
const errors = new Map([
|
|
16550
|
+
[-32000, "Event not provided"],
|
|
16551
|
+
[-32600, "Invalid Request"],
|
|
16552
|
+
[-32601, "Method not found"],
|
|
16553
|
+
[-32602, "Invalid params"],
|
|
16554
|
+
[-32603, "Internal error"],
|
|
16555
|
+
[-32604, "Params not found"],
|
|
16556
|
+
[-32605, "Method forbidden"],
|
|
16557
|
+
[-32606, "Event forbidden"],
|
|
16558
|
+
[-32700, "Parse error"]
|
|
16559
|
+
]);
|
|
16560
|
+
class DefaultDataPack {
|
|
16561
|
+
encode(value) {
|
|
16562
|
+
return JSON.stringify(value);
|
|
16563
|
+
}
|
|
16564
|
+
decode(value) {
|
|
16565
|
+
return JSON.parse(value);
|
|
16566
|
+
}
|
|
16567
|
+
}
|
|
16568
|
+
utils.DefaultDataPack = DefaultDataPack;
|
|
16569
|
+
/**
|
|
16570
|
+
* Creates a JSON-RPC 2.0-compliant error.
|
|
16571
|
+
* @param {Number} code - error code
|
|
16572
|
+
* @param {String} details - error details
|
|
16573
|
+
* @return {Object}
|
|
16574
|
+
*/
|
|
16575
|
+
function createError(code, details) {
|
|
16576
|
+
const error = {
|
|
16577
|
+
code: code,
|
|
16578
|
+
message: errors.get(code) || "Internal Server Error"
|
|
16579
|
+
};
|
|
16580
|
+
if (details)
|
|
16581
|
+
error["data"] = details;
|
|
16582
|
+
return error;
|
|
16583
|
+
}
|
|
16584
|
+
utils.createError = createError;
|
|
17934
16585
|
|
|
16586
|
+
/**
|
|
16587
|
+
* "Client" wraps "ws" or a browser-implemented "WebSocket" library
|
|
16588
|
+
* according to the environment providing JSON RPC 2.0 support on top.
|
|
16589
|
+
* @module Client
|
|
16590
|
+
*/
|
|
16591
|
+
Object.defineProperty(client, "__esModule", { value: true });
|
|
16592
|
+
// @ts-ignore
|
|
16593
|
+
const eventemitter3_1$1 = eventemitter3Exports;
|
|
16594
|
+
const utils_1 = utils;
|
|
16595
|
+
class CommonClient extends eventemitter3_1$1.EventEmitter {
|
|
16596
|
+
address;
|
|
16597
|
+
rpc_id;
|
|
16598
|
+
queue;
|
|
16599
|
+
options;
|
|
16600
|
+
autoconnect;
|
|
16601
|
+
ready;
|
|
16602
|
+
reconnect;
|
|
16603
|
+
reconnect_timer_id;
|
|
16604
|
+
reconnect_interval;
|
|
16605
|
+
max_reconnects;
|
|
16606
|
+
rest_options;
|
|
16607
|
+
current_reconnects;
|
|
16608
|
+
generate_request_id;
|
|
16609
|
+
socket;
|
|
16610
|
+
webSocketFactory;
|
|
16611
|
+
dataPack;
|
|
16612
|
+
/**
|
|
16613
|
+
* Instantiate a Client class.
|
|
16614
|
+
* @constructor
|
|
16615
|
+
* @param {webSocketFactory} webSocketFactory - factory method for WebSocket
|
|
16616
|
+
* @param {String} address - url to a websocket server
|
|
16617
|
+
* @param {Object} options - ws options object with reconnect parameters
|
|
16618
|
+
* @param {Function} generate_request_id - custom generation request Id
|
|
16619
|
+
* @param {DataPack} dataPack - data pack contains encoder and decoder
|
|
16620
|
+
* @return {CommonClient}
|
|
16621
|
+
*/
|
|
16622
|
+
constructor(webSocketFactory, address = "ws://localhost:8080", { autoconnect = true, reconnect = true, reconnect_interval = 1000, max_reconnects = 5, ...rest_options } = {}, generate_request_id, dataPack) {
|
|
16623
|
+
super();
|
|
16624
|
+
this.webSocketFactory = webSocketFactory;
|
|
16625
|
+
this.queue = {};
|
|
16626
|
+
this.rpc_id = 0;
|
|
16627
|
+
this.address = address;
|
|
16628
|
+
this.autoconnect = autoconnect;
|
|
16629
|
+
this.ready = false;
|
|
16630
|
+
this.reconnect = reconnect;
|
|
16631
|
+
this.reconnect_timer_id = undefined;
|
|
16632
|
+
this.reconnect_interval = reconnect_interval;
|
|
16633
|
+
this.max_reconnects = max_reconnects;
|
|
16634
|
+
this.rest_options = rest_options;
|
|
16635
|
+
this.current_reconnects = 0;
|
|
16636
|
+
this.generate_request_id = generate_request_id || (() => ++this.rpc_id);
|
|
16637
|
+
if (!dataPack)
|
|
16638
|
+
this.dataPack = new utils_1.DefaultDataPack();
|
|
16639
|
+
else
|
|
16640
|
+
this.dataPack = dataPack;
|
|
16641
|
+
if (this.autoconnect)
|
|
16642
|
+
this._connect(this.address, {
|
|
16643
|
+
autoconnect: this.autoconnect,
|
|
16644
|
+
reconnect: this.reconnect,
|
|
16645
|
+
reconnect_interval: this.reconnect_interval,
|
|
16646
|
+
max_reconnects: this.max_reconnects,
|
|
16647
|
+
...this.rest_options
|
|
16648
|
+
});
|
|
16649
|
+
}
|
|
16650
|
+
/**
|
|
16651
|
+
* Connects to a defined server if not connected already.
|
|
16652
|
+
* @method
|
|
16653
|
+
* @return {Undefined}
|
|
16654
|
+
*/
|
|
16655
|
+
connect() {
|
|
16656
|
+
if (this.socket)
|
|
16657
|
+
return;
|
|
16658
|
+
this._connect(this.address, {
|
|
16659
|
+
autoconnect: this.autoconnect,
|
|
16660
|
+
reconnect: this.reconnect,
|
|
16661
|
+
reconnect_interval: this.reconnect_interval,
|
|
16662
|
+
max_reconnects: this.max_reconnects,
|
|
16663
|
+
...this.rest_options
|
|
16664
|
+
});
|
|
16665
|
+
}
|
|
16666
|
+
/**
|
|
16667
|
+
* Calls a registered RPC method on server.
|
|
16668
|
+
* @method
|
|
16669
|
+
* @param {String} method - RPC method name
|
|
16670
|
+
* @param {Object|Array} params - optional method parameters
|
|
16671
|
+
* @param {Number} timeout - RPC reply timeout value
|
|
16672
|
+
* @param {Object} ws_opts - options passed to ws
|
|
16673
|
+
* @return {Promise}
|
|
16674
|
+
*/
|
|
16675
|
+
call(method, params, timeout, ws_opts) {
|
|
16676
|
+
if (!ws_opts && "object" === typeof timeout) {
|
|
16677
|
+
ws_opts = timeout;
|
|
16678
|
+
timeout = null;
|
|
16679
|
+
}
|
|
16680
|
+
return new Promise((resolve, reject) => {
|
|
16681
|
+
if (!this.ready)
|
|
16682
|
+
return reject(new Error("socket not ready"));
|
|
16683
|
+
const rpc_id = this.generate_request_id(method, params);
|
|
16684
|
+
const message = {
|
|
16685
|
+
jsonrpc: "2.0",
|
|
16686
|
+
method: method,
|
|
16687
|
+
params: params || undefined,
|
|
16688
|
+
id: rpc_id
|
|
16689
|
+
};
|
|
16690
|
+
this.socket.send(this.dataPack.encode(message), ws_opts, (error) => {
|
|
16691
|
+
if (error)
|
|
16692
|
+
return reject(error);
|
|
16693
|
+
this.queue[rpc_id] = { promise: [resolve, reject] };
|
|
16694
|
+
if (timeout) {
|
|
16695
|
+
this.queue[rpc_id].timeout = setTimeout(() => {
|
|
16696
|
+
delete this.queue[rpc_id];
|
|
16697
|
+
reject(new Error("reply timeout"));
|
|
16698
|
+
}, timeout);
|
|
16699
|
+
}
|
|
16700
|
+
});
|
|
16701
|
+
});
|
|
16702
|
+
}
|
|
16703
|
+
/**
|
|
16704
|
+
* Logins with the other side of the connection.
|
|
16705
|
+
* @method
|
|
16706
|
+
* @param {Object} params - Login credentials object
|
|
16707
|
+
* @return {Promise}
|
|
16708
|
+
*/
|
|
16709
|
+
async login(params) {
|
|
16710
|
+
const resp = await this.call("rpc.login", params);
|
|
16711
|
+
if (!resp)
|
|
16712
|
+
throw new Error("authentication failed");
|
|
16713
|
+
return resp;
|
|
16714
|
+
}
|
|
16715
|
+
/**
|
|
16716
|
+
* Fetches a list of client's methods registered on server.
|
|
16717
|
+
* @method
|
|
16718
|
+
* @return {Array}
|
|
16719
|
+
*/
|
|
16720
|
+
async listMethods() {
|
|
16721
|
+
return await this.call("__listMethods");
|
|
16722
|
+
}
|
|
16723
|
+
/**
|
|
16724
|
+
* Sends a JSON-RPC 2.0 notification to server.
|
|
16725
|
+
* @method
|
|
16726
|
+
* @param {String} method - RPC method name
|
|
16727
|
+
* @param {Object} params - optional method parameters
|
|
16728
|
+
* @return {Promise}
|
|
16729
|
+
*/
|
|
16730
|
+
notify(method, params) {
|
|
16731
|
+
return new Promise((resolve, reject) => {
|
|
16732
|
+
if (!this.ready)
|
|
16733
|
+
return reject(new Error("socket not ready"));
|
|
16734
|
+
const message = {
|
|
16735
|
+
jsonrpc: "2.0",
|
|
16736
|
+
method: method,
|
|
16737
|
+
params
|
|
16738
|
+
};
|
|
16739
|
+
this.socket.send(this.dataPack.encode(message), (error) => {
|
|
16740
|
+
if (error)
|
|
16741
|
+
return reject(error);
|
|
16742
|
+
resolve();
|
|
16743
|
+
});
|
|
16744
|
+
});
|
|
16745
|
+
}
|
|
16746
|
+
/**
|
|
16747
|
+
* Subscribes for a defined event.
|
|
16748
|
+
* @method
|
|
16749
|
+
* @param {String|Array} event - event name
|
|
16750
|
+
* @return {Undefined}
|
|
16751
|
+
* @throws {Error}
|
|
16752
|
+
*/
|
|
16753
|
+
async subscribe(event) {
|
|
16754
|
+
if (typeof event === "string")
|
|
16755
|
+
event = [event];
|
|
16756
|
+
const result = await this.call("rpc.on", event);
|
|
16757
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16758
|
+
throw new Error("Failed subscribing to an event '" + event + "' with: " + result[event]);
|
|
16759
|
+
return result;
|
|
16760
|
+
}
|
|
16761
|
+
/**
|
|
16762
|
+
* Unsubscribes from a defined event.
|
|
16763
|
+
* @method
|
|
16764
|
+
* @param {String|Array} event - event name
|
|
16765
|
+
* @return {Undefined}
|
|
16766
|
+
* @throws {Error}
|
|
16767
|
+
*/
|
|
16768
|
+
async unsubscribe(event) {
|
|
16769
|
+
if (typeof event === "string")
|
|
16770
|
+
event = [event];
|
|
16771
|
+
const result = await this.call("rpc.off", event);
|
|
16772
|
+
if (typeof event === "string" && result[event] !== "ok")
|
|
16773
|
+
throw new Error("Failed unsubscribing from an event with: " + result);
|
|
16774
|
+
return result;
|
|
16775
|
+
}
|
|
16776
|
+
/**
|
|
16777
|
+
* Closes a WebSocket connection gracefully.
|
|
16778
|
+
* @method
|
|
16779
|
+
* @param {Number} code - socket close code
|
|
16780
|
+
* @param {String} data - optional data to be sent before closing
|
|
16781
|
+
* @return {Undefined}
|
|
16782
|
+
*/
|
|
16783
|
+
close(code, data) {
|
|
16784
|
+
this.socket.close(code || 1000, data);
|
|
16785
|
+
}
|
|
16786
|
+
/**
|
|
16787
|
+
* Enable / disable automatic reconnection.
|
|
16788
|
+
* @method
|
|
16789
|
+
* @param {Boolean} reconnect - enable / disable reconnection
|
|
16790
|
+
* @return {Undefined}
|
|
16791
|
+
*/
|
|
16792
|
+
setAutoReconnect(reconnect) {
|
|
16793
|
+
this.reconnect = reconnect;
|
|
16794
|
+
}
|
|
16795
|
+
/**
|
|
16796
|
+
* Set the interval between reconnection attempts.
|
|
16797
|
+
* @method
|
|
16798
|
+
* @param {Number} interval - reconnection interval in milliseconds
|
|
16799
|
+
* @return {Undefined}
|
|
16800
|
+
*/
|
|
16801
|
+
setReconnectInterval(interval) {
|
|
16802
|
+
this.reconnect_interval = interval;
|
|
16803
|
+
}
|
|
16804
|
+
/**
|
|
16805
|
+
* Set the maximum number of reconnection attempts.
|
|
16806
|
+
* @method
|
|
16807
|
+
* @param {Number} max_reconnects - maximum reconnection attempts
|
|
16808
|
+
* @return {Undefined}
|
|
16809
|
+
*/
|
|
16810
|
+
setMaxReconnects(max_reconnects) {
|
|
16811
|
+
this.max_reconnects = max_reconnects;
|
|
16812
|
+
}
|
|
16813
|
+
/**
|
|
16814
|
+
* Connection/Message handler.
|
|
16815
|
+
* @method
|
|
16816
|
+
* @private
|
|
16817
|
+
* @param {String} address - WebSocket API address
|
|
16818
|
+
* @param {Object} options - ws options object
|
|
16819
|
+
* @return {Undefined}
|
|
16820
|
+
*/
|
|
16821
|
+
_connect(address, options) {
|
|
16822
|
+
clearTimeout(this.reconnect_timer_id);
|
|
16823
|
+
this.socket = this.webSocketFactory(address, options);
|
|
16824
|
+
this.socket.addEventListener("open", () => {
|
|
16825
|
+
this.ready = true;
|
|
16826
|
+
this.emit("open");
|
|
16827
|
+
this.current_reconnects = 0;
|
|
16828
|
+
});
|
|
16829
|
+
this.socket.addEventListener("message", ({ data: message }) => {
|
|
16830
|
+
if (message instanceof ArrayBuffer)
|
|
16831
|
+
message = Buffer.from(message).toString();
|
|
16832
|
+
try {
|
|
16833
|
+
message = this.dataPack.decode(message);
|
|
16834
|
+
}
|
|
16835
|
+
catch (error) {
|
|
16836
|
+
return;
|
|
16837
|
+
}
|
|
16838
|
+
// check if any listeners are attached and forward event
|
|
16839
|
+
if (message.notification && this.listeners(message.notification).length) {
|
|
16840
|
+
if (!Object.keys(message.params).length)
|
|
16841
|
+
return this.emit(message.notification);
|
|
16842
|
+
const args = [message.notification];
|
|
16843
|
+
if (message.params.constructor === Object)
|
|
16844
|
+
args.push(message.params);
|
|
16845
|
+
else
|
|
16846
|
+
// using for-loop instead of unshift/spread because performance is better
|
|
16847
|
+
for (let i = 0; i < message.params.length; i++)
|
|
16848
|
+
args.push(message.params[i]);
|
|
16849
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16850
|
+
// eslint-disable-next-line prefer-spread
|
|
16851
|
+
return Promise.resolve().then(() => { this.emit.apply(this, args); });
|
|
16852
|
+
}
|
|
16853
|
+
if (!this.queue[message.id]) {
|
|
16854
|
+
// general JSON RPC 2.0 events
|
|
16855
|
+
if (message.method) {
|
|
16856
|
+
// run as microtask so that pending queue messages are resolved first
|
|
16857
|
+
return Promise.resolve().then(() => {
|
|
16858
|
+
this.emit(message.method, message?.params);
|
|
16859
|
+
});
|
|
16860
|
+
}
|
|
16861
|
+
return;
|
|
16862
|
+
}
|
|
16863
|
+
// reject early since server's response is invalid
|
|
16864
|
+
if ("error" in message === "result" in message)
|
|
16865
|
+
this.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" +
|
|
16866
|
+
" or \"error\", but not both."));
|
|
16867
|
+
if (this.queue[message.id].timeout)
|
|
16868
|
+
clearTimeout(this.queue[message.id].timeout);
|
|
16869
|
+
if (message.error)
|
|
16870
|
+
this.queue[message.id].promise[1](message.error);
|
|
16871
|
+
else
|
|
16872
|
+
this.queue[message.id].promise[0](message.result);
|
|
16873
|
+
delete this.queue[message.id];
|
|
16874
|
+
});
|
|
16875
|
+
this.socket.addEventListener("error", (error) => this.emit("error", error));
|
|
16876
|
+
this.socket.addEventListener("close", ({ code, reason }) => {
|
|
16877
|
+
if (this.ready) // Delay close event until internal state is updated
|
|
16878
|
+
setTimeout(() => this.emit("close", code, reason), 0);
|
|
16879
|
+
this.ready = false;
|
|
16880
|
+
this.socket = undefined;
|
|
16881
|
+
if (code === 1000)
|
|
16882
|
+
return;
|
|
16883
|
+
this.current_reconnects++;
|
|
16884
|
+
if (this.reconnect && ((this.max_reconnects > this.current_reconnects) ||
|
|
16885
|
+
this.max_reconnects === 0))
|
|
16886
|
+
this.reconnect_timer_id = setTimeout(() => this._connect(address, options), this.reconnect_interval);
|
|
16887
|
+
});
|
|
16888
|
+
}
|
|
16889
|
+
}
|
|
16890
|
+
var _default$1 = client.default = CommonClient;
|
|
17935
16891
|
|
|
17936
|
-
|
|
17937
|
-
return new WebSocketBrowserImpl(address, options);
|
|
17938
|
-
}
|
|
17939
|
-
} (websocket_browser));
|
|
16892
|
+
var websocket_browser = {};
|
|
17940
16893
|
|
|
17941
|
-
|
|
16894
|
+
/**
|
|
16895
|
+
* WebSocket implements a browser-side WebSocket specification.
|
|
16896
|
+
* @module Client
|
|
16897
|
+
*/
|
|
16898
|
+
Object.defineProperty(websocket_browser, "__esModule", { value: true });
|
|
16899
|
+
const eventemitter3_1 = eventemitter3Exports;
|
|
16900
|
+
class WebSocketBrowserImpl extends eventemitter3_1.EventEmitter {
|
|
16901
|
+
socket;
|
|
16902
|
+
/** Instantiate a WebSocket class
|
|
16903
|
+
* @constructor
|
|
16904
|
+
* @param {String} address - url to a websocket server
|
|
16905
|
+
* @param {(Object)} options - websocket options
|
|
16906
|
+
* @param {(String|Array)} protocols - a list of protocols
|
|
16907
|
+
* @return {WebSocketBrowserImpl} - returns a WebSocket instance
|
|
16908
|
+
*/
|
|
16909
|
+
constructor(address, options, protocols) {
|
|
16910
|
+
super();
|
|
16911
|
+
this.socket = new window.WebSocket(address, protocols);
|
|
16912
|
+
this.socket.onopen = () => this.emit("open");
|
|
16913
|
+
this.socket.onmessage = (event) => this.emit("message", event.data);
|
|
16914
|
+
this.socket.onerror = (error) => this.emit("error", error);
|
|
16915
|
+
this.socket.onclose = (event) => {
|
|
16916
|
+
this.emit("close", event.code, event.reason);
|
|
16917
|
+
};
|
|
16918
|
+
}
|
|
16919
|
+
/**
|
|
16920
|
+
* Sends data through a websocket connection
|
|
16921
|
+
* @method
|
|
16922
|
+
* @param {(String|Object)} data - data to be sent via websocket
|
|
16923
|
+
* @param {Object} optionsOrCallback - ws options
|
|
16924
|
+
* @param {Function} callback - a callback called once the data is sent
|
|
16925
|
+
* @return {Undefined}
|
|
16926
|
+
*/
|
|
16927
|
+
send(data, optionsOrCallback, callback) {
|
|
16928
|
+
const cb = callback || optionsOrCallback;
|
|
16929
|
+
try {
|
|
16930
|
+
this.socket.send(data);
|
|
16931
|
+
cb();
|
|
16932
|
+
}
|
|
16933
|
+
catch (error) {
|
|
16934
|
+
cb(error);
|
|
16935
|
+
}
|
|
16936
|
+
}
|
|
16937
|
+
/**
|
|
16938
|
+
* Closes an underlying socket
|
|
16939
|
+
* @method
|
|
16940
|
+
* @param {Number} code - status code explaining why the connection is being closed
|
|
16941
|
+
* @param {String} reason - a description why the connection is closing
|
|
16942
|
+
* @return {Undefined}
|
|
16943
|
+
* @throws {Error}
|
|
16944
|
+
*/
|
|
16945
|
+
close(code, reason) {
|
|
16946
|
+
this.socket.close(code, reason);
|
|
16947
|
+
}
|
|
16948
|
+
addEventListener(type, listener, options) {
|
|
16949
|
+
this.socket.addEventListener(type, listener, options);
|
|
16950
|
+
}
|
|
16951
|
+
}
|
|
16952
|
+
/**
|
|
16953
|
+
* factory method for common WebSocket instance
|
|
16954
|
+
* @method
|
|
16955
|
+
* @param {String} address - url to a websocket server
|
|
16956
|
+
* @param {(Object)} options - websocket options
|
|
16957
|
+
* @return {Undefined}
|
|
16958
|
+
*/
|
|
16959
|
+
function default_1(address, options) {
|
|
16960
|
+
return new WebSocketBrowserImpl(address, options);
|
|
16961
|
+
}
|
|
16962
|
+
var _default = websocket_browser.default = default_1;
|
|
17942
16963
|
|
|
17943
|
-
class RpcWebSocketClient extends
|
|
16964
|
+
class RpcWebSocketClient extends _default$1 {
|
|
17944
16965
|
constructor(address, options, generate_request_id) {
|
|
17945
16966
|
const webSocketFactory = url => {
|
|
17946
|
-
const rpc =
|
|
16967
|
+
const rpc = _default(url, {
|
|
17947
16968
|
autoconnect: true,
|
|
17948
16969
|
max_reconnects: 5,
|
|
17949
16970
|
reconnect: true,
|
|
@@ -23136,34 +22157,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
23136
22157
|
}
|
|
23137
22158
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
23138
22159
|
|
|
23139
|
-
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
23140
|
-
const _32n = /* @__PURE__ */ BigInt(32);
|
|
23141
|
-
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
|
23142
|
-
function fromBig(n, le = false) {
|
|
23143
|
-
if (le)
|
|
23144
|
-
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
23145
|
-
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
23146
|
-
}
|
|
23147
|
-
function split(lst, le = false) {
|
|
23148
|
-
let Ah = new Uint32Array(lst.length);
|
|
23149
|
-
let Al = new Uint32Array(lst.length);
|
|
23150
|
-
for (let i = 0; i < lst.length; i++) {
|
|
23151
|
-
const { h, l } = fromBig(lst[i], le);
|
|
23152
|
-
[Ah[i], Al[i]] = [h, l];
|
|
23153
|
-
}
|
|
23154
|
-
return [Ah, Al];
|
|
23155
|
-
}
|
|
23156
|
-
// Left rotate for Shift in [1, 32)
|
|
23157
|
-
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
23158
|
-
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
23159
|
-
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
23160
|
-
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
23161
|
-
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
23162
|
-
|
|
23163
22160
|
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
|
23164
22161
|
// It's called a sponge function.
|
|
23165
22162
|
// Various per round constants calculations
|
|
23166
|
-
const
|
|
22163
|
+
const SHA3_PI = [];
|
|
22164
|
+
const SHA3_ROTL = [];
|
|
22165
|
+
const _SHA3_IOTA = [];
|
|
23167
22166
|
const _0n$1 = /* @__PURE__ */ BigInt(0);
|
|
23168
22167
|
const _1n$2 = /* @__PURE__ */ BigInt(1);
|
|
23169
22168
|
const _2n$1 = /* @__PURE__ */ BigInt(2);
|
|
@@ -23257,7 +22256,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
23257
22256
|
this.state32 = u32$1(this.state);
|
|
23258
22257
|
}
|
|
23259
22258
|
keccak() {
|
|
22259
|
+
if (!isLE)
|
|
22260
|
+
byteSwap32(this.state32);
|
|
23260
22261
|
keccakP(this.state32, this.rounds);
|
|
22262
|
+
if (!isLE)
|
|
22263
|
+
byteSwap32(this.state32);
|
|
23261
22264
|
this.posOut = 0;
|
|
23262
22265
|
this.pos = 0;
|
|
23263
22266
|
}
|
|
@@ -23351,114 +22354,6 @@ var solanaWeb3 = (function (exports) {
|
|
|
23351
22354
|
*/
|
|
23352
22355
|
const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
|
|
23353
22356
|
|
|
23354
|
-
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
23355
|
-
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
23356
|
-
// Choice: a ? b : c
|
|
23357
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
23358
|
-
// Majority function, true if any two inpust is true
|
|
23359
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
23360
|
-
// Round constants:
|
|
23361
|
-
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
23362
|
-
// prettier-ignore
|
|
23363
|
-
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
23364
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
23365
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
23366
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
23367
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
23368
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
23369
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
23370
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
23371
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
23372
|
-
]);
|
|
23373
|
-
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
23374
|
-
// prettier-ignore
|
|
23375
|
-
const IV = /* @__PURE__ */ new Uint32Array([
|
|
23376
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
23377
|
-
]);
|
|
23378
|
-
// Temporary buffer, not used to store anything between runs
|
|
23379
|
-
// Named this way because it matches specification.
|
|
23380
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
23381
|
-
class SHA256 extends SHA2$1 {
|
|
23382
|
-
constructor() {
|
|
23383
|
-
super(64, 32, 8, false);
|
|
23384
|
-
// We cannot use array here since array allows indexing by variable
|
|
23385
|
-
// which means optimizer/compiler cannot use registers.
|
|
23386
|
-
this.A = IV[0] | 0;
|
|
23387
|
-
this.B = IV[1] | 0;
|
|
23388
|
-
this.C = IV[2] | 0;
|
|
23389
|
-
this.D = IV[3] | 0;
|
|
23390
|
-
this.E = IV[4] | 0;
|
|
23391
|
-
this.F = IV[5] | 0;
|
|
23392
|
-
this.G = IV[6] | 0;
|
|
23393
|
-
this.H = IV[7] | 0;
|
|
23394
|
-
}
|
|
23395
|
-
get() {
|
|
23396
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
23397
|
-
return [A, B, C, D, E, F, G, H];
|
|
23398
|
-
}
|
|
23399
|
-
// prettier-ignore
|
|
23400
|
-
set(A, B, C, D, E, F, G, H) {
|
|
23401
|
-
this.A = A | 0;
|
|
23402
|
-
this.B = B | 0;
|
|
23403
|
-
this.C = C | 0;
|
|
23404
|
-
this.D = D | 0;
|
|
23405
|
-
this.E = E | 0;
|
|
23406
|
-
this.F = F | 0;
|
|
23407
|
-
this.G = G | 0;
|
|
23408
|
-
this.H = H | 0;
|
|
23409
|
-
}
|
|
23410
|
-
process(view, offset) {
|
|
23411
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
23412
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
23413
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
23414
|
-
for (let i = 16; i < 64; i++) {
|
|
23415
|
-
const W15 = SHA256_W[i - 15];
|
|
23416
|
-
const W2 = SHA256_W[i - 2];
|
|
23417
|
-
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);
|
|
23418
|
-
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);
|
|
23419
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
23420
|
-
}
|
|
23421
|
-
// Compression function main loop, 64 rounds
|
|
23422
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
23423
|
-
for (let i = 0; i < 64; i++) {
|
|
23424
|
-
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
23425
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
23426
|
-
const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);
|
|
23427
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
23428
|
-
H = G;
|
|
23429
|
-
G = F;
|
|
23430
|
-
F = E;
|
|
23431
|
-
E = (D + T1) | 0;
|
|
23432
|
-
D = C;
|
|
23433
|
-
C = B;
|
|
23434
|
-
B = A;
|
|
23435
|
-
A = (T1 + T2) | 0;
|
|
23436
|
-
}
|
|
23437
|
-
// Add the compressed chunk to the current hash value
|
|
23438
|
-
A = (A + this.A) | 0;
|
|
23439
|
-
B = (B + this.B) | 0;
|
|
23440
|
-
C = (C + this.C) | 0;
|
|
23441
|
-
D = (D + this.D) | 0;
|
|
23442
|
-
E = (E + this.E) | 0;
|
|
23443
|
-
F = (F + this.F) | 0;
|
|
23444
|
-
G = (G + this.G) | 0;
|
|
23445
|
-
H = (H + this.H) | 0;
|
|
23446
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
23447
|
-
}
|
|
23448
|
-
roundClean() {
|
|
23449
|
-
SHA256_W.fill(0);
|
|
23450
|
-
}
|
|
23451
|
-
destroy() {
|
|
23452
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
23453
|
-
this.buffer.fill(0);
|
|
23454
|
-
}
|
|
23455
|
-
}
|
|
23456
|
-
/**
|
|
23457
|
-
* SHA2-256 hash function
|
|
23458
|
-
* @param message - data that would be hashed
|
|
23459
|
-
*/
|
|
23460
|
-
const sha256 = /* @__PURE__ */ wrapConstructor$1(() => new SHA256());
|
|
23461
|
-
|
|
23462
22357
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
23463
22358
|
// Short Weierstrass curve. The formula is: y² = x³ + ax + b
|
|
23464
22359
|
function validatePointOpts(curve) {
|
|
@@ -23519,8 +22414,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23519
22414
|
// parse DER signature
|
|
23520
22415
|
const { Err: E } = DER;
|
|
23521
22416
|
const data = typeof hex === 'string' ? h2b(hex) : hex;
|
|
23522
|
-
|
|
23523
|
-
throw new Error('ui8a expected');
|
|
22417
|
+
abytes(data);
|
|
23524
22418
|
let l = data.length;
|
|
23525
22419
|
if (l < 2 || data[0] != 0x30)
|
|
23526
22420
|
throw new E('Invalid signature tag');
|
|
@@ -23597,7 +22491,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
23597
22491
|
function normPrivateKeyToScalar(key) {
|
|
23598
22492
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE;
|
|
23599
22493
|
if (lengths && typeof key !== 'bigint') {
|
|
23600
|
-
if (key
|
|
22494
|
+
if (isBytes(key))
|
|
23601
22495
|
key = bytesToHex(key);
|
|
23602
22496
|
// Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes
|
|
23603
22497
|
if (typeof key !== 'string' || !lengths.includes(key.length))
|
|
@@ -24028,7 +22922,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
24028
22922
|
if (!isValidFieldElement(x))
|
|
24029
22923
|
throw new Error('Point is not on curve');
|
|
24030
22924
|
const y2 = weierstrassEquation(x); // y² = x³ + ax + b
|
|
24031
|
-
let y
|
|
22925
|
+
let y;
|
|
22926
|
+
try {
|
|
22927
|
+
y = Fp.sqrt(y2); // y = y² ^ (p+1)/4
|
|
22928
|
+
}
|
|
22929
|
+
catch (sqrtError) {
|
|
22930
|
+
const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';
|
|
22931
|
+
throw new Error('Point is not on curve' + suffix);
|
|
22932
|
+
}
|
|
24032
22933
|
const isYOdd = (y & _1n$1) === _1n$1;
|
|
24033
22934
|
// ECDSA
|
|
24034
22935
|
const isHeadOdd = (head & 1) === 1;
|
|
@@ -24175,7 +23076,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24175
23076
|
* Quick and dirty check for item being public key. Does not validate hex, or being on-curve.
|
|
24176
23077
|
*/
|
|
24177
23078
|
function isProbPub(item) {
|
|
24178
|
-
const arr = item
|
|
23079
|
+
const arr = isBytes(item);
|
|
24179
23080
|
const str = typeof item === 'string';
|
|
24180
23081
|
const len = (arr || str) && item.length;
|
|
24181
23082
|
if (arr)
|
|
@@ -24255,7 +23156,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24255
23156
|
const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint
|
|
24256
23157
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
|
24257
23158
|
// extraEntropy. RFC6979 3.6: additional k' (optional).
|
|
24258
|
-
if (ent != null) {
|
|
23159
|
+
if (ent != null && ent !== false) {
|
|
24259
23160
|
// K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')
|
|
24260
23161
|
const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is
|
|
24261
23162
|
seedArgs.push(ensureBytes('extraEntropy', e)); // check for being bytes
|
|
@@ -24336,7 +23237,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24336
23237
|
let _sig = undefined;
|
|
24337
23238
|
let P;
|
|
24338
23239
|
try {
|
|
24339
|
-
if (typeof sg === 'string' || sg
|
|
23240
|
+
if (typeof sg === 'string' || isBytes(sg)) {
|
|
24340
23241
|
// Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).
|
|
24341
23242
|
// Since DER can also be 2*nByteLength bytes, we check for it first.
|
|
24342
23243
|
try {
|
|
@@ -24390,13 +23291,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24390
23291
|
}
|
|
24391
23292
|
|
|
24392
23293
|
// HMAC (RFC 2104)
|
|
24393
|
-
class HMAC extends Hash
|
|
23294
|
+
class HMAC extends Hash {
|
|
24394
23295
|
constructor(hash$1, _key) {
|
|
24395
23296
|
super();
|
|
24396
23297
|
this.finished = false;
|
|
24397
23298
|
this.destroyed = false;
|
|
24398
23299
|
hash(hash$1);
|
|
24399
|
-
const key = toBytes
|
|
23300
|
+
const key = toBytes(_key);
|
|
24400
23301
|
this.iHash = hash$1.create();
|
|
24401
23302
|
if (typeof this.iHash.update !== 'function')
|
|
24402
23303
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
@@ -24418,13 +23319,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
24418
23319
|
pad.fill(0);
|
|
24419
23320
|
}
|
|
24420
23321
|
update(buf) {
|
|
24421
|
-
exists
|
|
23322
|
+
exists(this);
|
|
24422
23323
|
this.iHash.update(buf);
|
|
24423
23324
|
return this;
|
|
24424
23325
|
}
|
|
24425
23326
|
digestInto(out) {
|
|
24426
|
-
exists
|
|
24427
|
-
bytes
|
|
23327
|
+
exists(this);
|
|
23328
|
+
bytes(out, this.outputLen);
|
|
24428
23329
|
this.finished = true;
|
|
24429
23330
|
this.iHash.digestInto(out);
|
|
24430
23331
|
this.oHash.update(out);
|
|
@@ -24514,15 +23415,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
24514
23415
|
}
|
|
24515
23416
|
const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
|
|
24516
23417
|
const secp256k1 = createCurve({
|
|
24517
|
-
a: BigInt(0),
|
|
24518
|
-
b: BigInt(7),
|
|
24519
|
-
Fp,
|
|
24520
|
-
n: secp256k1N,
|
|
23418
|
+
a: BigInt(0), // equation params: a, b
|
|
23419
|
+
b: BigInt(7), // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975
|
|
23420
|
+
Fp, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
|
|
23421
|
+
n: secp256k1N, // Curve order, total count of valid points in the field
|
|
24521
23422
|
// Base point (x, y) aka generator point
|
|
24522
23423
|
Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),
|
|
24523
23424
|
Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),
|
|
24524
|
-
h: BigInt(1),
|
|
24525
|
-
lowS: true,
|
|
23425
|
+
h: BigInt(1), // Cofactor
|
|
23426
|
+
lowS: true, // Allow only low-S signatures by default in sign() and verify()
|
|
24526
23427
|
/**
|
|
24527
23428
|
* secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.
|
|
24528
23429
|
* Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.
|
|
@@ -24709,7 +23610,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24709
23610
|
}
|
|
24710
23611
|
Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
|
|
24711
23612
|
|
|
24712
|
-
var
|
|
23613
|
+
var _Lockup;
|
|
24713
23614
|
|
|
24714
23615
|
/**
|
|
24715
23616
|
* Address of the stake config account which configures the rate
|
|
@@ -24758,8 +23659,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
24758
23659
|
* Default, inactive Lockup value
|
|
24759
23660
|
*/
|
|
24760
23661
|
}
|
|
24761
|
-
|
|
24762
|
-
Lockup.default = new
|
|
23662
|
+
_Lockup = Lockup;
|
|
23663
|
+
Lockup.default = new _Lockup(0, 0, PublicKey.default);
|
|
24763
23664
|
/**
|
|
24764
23665
|
* Create stake account transaction params
|
|
24765
23666
|
*/
|