@pooflabs/web 0.0.76 → 0.0.77
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/README.md +32 -0
- package/dist/{index-BilNgDSc.js → index-Bfk81d8_.js} +883 -25
- package/dist/index-Bfk81d8_.js.map +1 -0
- package/dist/{index-C5Cnn7Hq.esm.js → index-CFh1x-M0.esm.js} +353 -156
- package/dist/index-CFh1x-M0.esm.js.map +1 -0
- package/dist/index-CdOv7Nw2.esm.js +6 -0
- package/dist/index-CdOv7Nw2.esm.js.map +1 -0
- package/dist/{index-DeVykeX4.esm.js → index-CeQ8hE3s.esm.js} +881 -24
- package/dist/index-CeQ8hE3s.esm.js.map +1 -0
- package/dist/index-DDXzCx2W.js +8 -0
- package/dist/index-DDXzCx2W.js.map +1 -0
- package/dist/{index-BrlvWT1Q.js → index-DQVpAl5t.js} +353 -156
- package/dist/index-DQVpAl5t.js.map +1 -0
- package/dist/{index-COMIXUxl.js → index-KUU0aVzP.js} +882 -24
- package/dist/index-KUU0aVzP.js.map +1 -0
- package/dist/{index-Dsh0H37n.esm.js → index-R7t9pRt_.esm.js} +882 -23
- package/dist/index-R7t9pRt_.esm.js.map +1 -0
- package/dist/{index.browser-CSTWylhG.esm.js → index.browser-BE44CEaJ.esm.js} +3 -3
- package/dist/{index.browser-CSTWylhG.esm.js.map → index.browser-BE44CEaJ.esm.js.map} +1 -1
- package/dist/{index.browser-DZjyUgtx.esm.js → index.browser-C-_FEr5M.esm.js} +449 -479
- package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
- package/dist/index.browser-C9bFQZyQ.esm.js +1373 -0
- package/dist/index.browser-C9bFQZyQ.esm.js.map +1 -0
- package/dist/index.browser-Dbq5Qf1G.esm.js +242 -0
- package/dist/index.browser-Dbq5Qf1G.esm.js.map +1 -0
- package/dist/index.browser-Df7yN8D5.js +245 -0
- package/dist/index.browser-Df7yN8D5.js.map +1 -0
- package/dist/{index.browser-CMO2pjaF.js → index.browser-Di1_YZpi.js} +3 -3
- package/dist/{index.browser-CMO2pjaF.js.map → index.browser-Di1_YZpi.js.map} +1 -1
- package/dist/{index.browser-BOJRGZWX.js → index.browser-DjEZSiqI.js} +449 -479
- package/dist/index.browser-DjEZSiqI.js.map +1 -0
- package/dist/index.browser-dszs5oe5.js +1376 -0
- package/dist/index.browser-dszs5oe5.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.native-CkUXrvPQ.js → index.native-CKd2b3_F.js} +2756 -188
- package/dist/index.native-CKd2b3_F.js.map +1 -0
- package/dist/{index.native-H-fEcP_L.esm.js → index.native-DAyMVhFq.esm.js} +2755 -189
- package/dist/index.native-DAyMVhFq.esm.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +2 -1
- package/dist/index.native.js.map +1 -1
- package/dist/{phantom-wallet-provider-DrNrxSUL.js → phantom-wallet-provider-DJ6qf2VB.js} +4 -4
- package/dist/{phantom-wallet-provider-DrNrxSUL.js.map → phantom-wallet-provider-DJ6qf2VB.js.map} +1 -1
- package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js → phantom-wallet-provider-DQ0uhl2v.esm.js} +4 -4
- package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js.map → phantom-wallet-provider-DQ0uhl2v.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-BtLH1dpY.esm.js → privy-wallet-provider-BhiHnphv.esm.js} +3 -3
- package/dist/privy-wallet-provider-BhiHnphv.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-CrRfcONv.js → privy-wallet-provider-CMCv5g3O.js} +3 -3
- package/dist/privy-wallet-provider-CMCv5g3O.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js → solana-mobile-wallet-provider-DSSk_6CR.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js.map → solana-mobile-wallet-provider-DSSk_6CR.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-QcGazewW.js → solana-mobile-wallet-provider-DaFNesCe.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-QcGazewW.js.map → solana-mobile-wallet-provider-DaFNesCe.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-Bdcc5821.js +0 -2375
- package/dist/index-Bdcc5821.js.map +0 -1
- package/dist/index-BilNgDSc.js.map +0 -1
- package/dist/index-BrlvWT1Q.js.map +0 -1
- package/dist/index-C5Cnn7Hq.esm.js.map +0 -1
- package/dist/index-COMIXUxl.js.map +0 -1
- package/dist/index-CrOVJFX9.esm.js +0 -2373
- package/dist/index-CrOVJFX9.esm.js.map +0 -1
- package/dist/index-DeVykeX4.esm.js.map +0 -1
- package/dist/index-Dsh0H37n.esm.js.map +0 -1
- package/dist/index.browser--rDwfvXH.esm.js +0 -307
- package/dist/index.browser--rDwfvXH.esm.js.map +0 -1
- package/dist/index.browser-BOJRGZWX.js.map +0 -1
- package/dist/index.browser-CLZv9v_y.js +0 -310
- package/dist/index.browser-CLZv9v_y.js.map +0 -1
- package/dist/index.browser-DQKnuR3q.esm.js +0 -1468
- package/dist/index.browser-DQKnuR3q.esm.js.map +0 -1
- package/dist/index.browser-DZjyUgtx.esm.js.map +0 -1
- package/dist/index.browser-DqO3G-HJ.js +0 -1471
- package/dist/index.browser-DqO3G-HJ.js.map +0 -1
- package/dist/index.native-CkUXrvPQ.js.map +0 -1
- package/dist/index.native-H-fEcP_L.esm.js.map +0 -1
- package/dist/privy-wallet-provider-BtLH1dpY.esm.js.map +0 -1
- package/dist/privy-wallet-provider-CrRfcONv.js.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useContext, createContext, useState, useMemo, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import globalAxios, { isAxiosError } from 'axios';
|
|
4
|
-
import { b as bufferExports } from './index-
|
|
5
|
-
import { o as getDefaultExportFromCjs, d as bs58$1 } from './index.native-H-fEcP_L.esm.js';
|
|
4
|
+
import { b as bufferExports, g as getDefaultExportFromCjs } from './index-CFh1x-M0.esm.js';
|
|
6
5
|
import { Transaction as Transaction$1, VersionedTransaction } from '@solana/web3.js';
|
|
7
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
7
|
import '@coral-xyz/anchor';
|
|
@@ -1131,17 +1130,17 @@ function requireSrc () {
|
|
|
1131
1130
|
return src;
|
|
1132
1131
|
}
|
|
1133
1132
|
|
|
1134
|
-
var bs58;
|
|
1133
|
+
var bs58$3;
|
|
1135
1134
|
var hasRequiredBs58;
|
|
1136
1135
|
|
|
1137
1136
|
function requireBs58 () {
|
|
1138
|
-
if (hasRequiredBs58) return bs58;
|
|
1137
|
+
if (hasRequiredBs58) return bs58$3;
|
|
1139
1138
|
hasRequiredBs58 = 1;
|
|
1140
1139
|
const basex = requireSrc();
|
|
1141
1140
|
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
1142
1141
|
|
|
1143
|
-
bs58 = basex(ALPHABET);
|
|
1144
|
-
return bs58;
|
|
1142
|
+
bs58$3 = basex(ALPHABET);
|
|
1143
|
+
return bs58$3;
|
|
1145
1144
|
}
|
|
1146
1145
|
|
|
1147
1146
|
requireBs58();
|
|
@@ -3101,13 +3100,13 @@ function createAutoConfirmPlugin() {
|
|
|
3101
3100
|
};
|
|
3102
3101
|
}
|
|
3103
3102
|
|
|
3104
|
-
var eventemitter3 = {exports: {}};
|
|
3103
|
+
var eventemitter3$1 = {exports: {}};
|
|
3105
3104
|
|
|
3106
|
-
var hasRequiredEventemitter3;
|
|
3105
|
+
var hasRequiredEventemitter3$1;
|
|
3107
3106
|
|
|
3108
|
-
function requireEventemitter3 () {
|
|
3109
|
-
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
3110
|
-
hasRequiredEventemitter3 = 1;
|
|
3107
|
+
function requireEventemitter3$1 () {
|
|
3108
|
+
if (hasRequiredEventemitter3$1) return eventemitter3$1.exports;
|
|
3109
|
+
hasRequiredEventemitter3$1 = 1;
|
|
3111
3110
|
(function (module) {
|
|
3112
3111
|
|
|
3113
3112
|
var has = Object.prototype.hasOwnProperty
|
|
@@ -3444,12 +3443,12 @@ function requireEventemitter3 () {
|
|
|
3444
3443
|
{
|
|
3445
3444
|
module.exports = EventEmitter;
|
|
3446
3445
|
}
|
|
3447
|
-
} (eventemitter3));
|
|
3448
|
-
return eventemitter3.exports;
|
|
3446
|
+
} (eventemitter3$1));
|
|
3447
|
+
return eventemitter3$1.exports;
|
|
3449
3448
|
}
|
|
3450
3449
|
|
|
3451
|
-
var eventemitter3Exports = requireEventemitter3();
|
|
3452
|
-
var EventEmitter3 = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
3450
|
+
var eventemitter3Exports$1 = requireEventemitter3$1();
|
|
3451
|
+
var EventEmitter3 = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports$1);
|
|
3453
3452
|
|
|
3454
3453
|
// src/index.ts
|
|
3455
3454
|
var isBrowser = typeof window !== "undefined" && typeof window.btoa !== "undefined";
|
|
@@ -8778,6 +8777,133 @@ class Transaction {
|
|
|
8778
8777
|
}
|
|
8779
8778
|
}
|
|
8780
8779
|
|
|
8780
|
+
// base-x encoding / decoding
|
|
8781
|
+
// Copyright (c) 2018 base-x contributors
|
|
8782
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
8783
|
+
// Distributed under the MIT software license, see the accompanying
|
|
8784
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
8785
|
+
function base$3 (ALPHABET) {
|
|
8786
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
8787
|
+
const BASE_MAP = new Uint8Array(256);
|
|
8788
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
8789
|
+
BASE_MAP[j] = 255;
|
|
8790
|
+
}
|
|
8791
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
8792
|
+
const x = ALPHABET.charAt(i);
|
|
8793
|
+
const xc = x.charCodeAt(0);
|
|
8794
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
8795
|
+
BASE_MAP[xc] = i;
|
|
8796
|
+
}
|
|
8797
|
+
const BASE = ALPHABET.length;
|
|
8798
|
+
const LEADER = ALPHABET.charAt(0);
|
|
8799
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
8800
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
8801
|
+
function encode (source) {
|
|
8802
|
+
// eslint-disable-next-line no-empty
|
|
8803
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
8804
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
8805
|
+
} else if (Array.isArray(source)) {
|
|
8806
|
+
source = Uint8Array.from(source);
|
|
8807
|
+
}
|
|
8808
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
8809
|
+
if (source.length === 0) { return '' }
|
|
8810
|
+
// Skip & count leading zeroes.
|
|
8811
|
+
let zeroes = 0;
|
|
8812
|
+
let length = 0;
|
|
8813
|
+
let pbegin = 0;
|
|
8814
|
+
const pend = source.length;
|
|
8815
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
8816
|
+
pbegin++;
|
|
8817
|
+
zeroes++;
|
|
8818
|
+
}
|
|
8819
|
+
// Allocate enough space in big-endian base58 representation.
|
|
8820
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
8821
|
+
const b58 = new Uint8Array(size);
|
|
8822
|
+
// Process the bytes.
|
|
8823
|
+
while (pbegin !== pend) {
|
|
8824
|
+
let carry = source[pbegin];
|
|
8825
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
8826
|
+
let i = 0;
|
|
8827
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
8828
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
8829
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
8830
|
+
carry = (carry / BASE) >>> 0;
|
|
8831
|
+
}
|
|
8832
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
8833
|
+
length = i;
|
|
8834
|
+
pbegin++;
|
|
8835
|
+
}
|
|
8836
|
+
// Skip leading zeroes in base58 result.
|
|
8837
|
+
let it2 = size - length;
|
|
8838
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
8839
|
+
it2++;
|
|
8840
|
+
}
|
|
8841
|
+
// Translate the result into a string.
|
|
8842
|
+
let str = LEADER.repeat(zeroes);
|
|
8843
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
8844
|
+
return str
|
|
8845
|
+
}
|
|
8846
|
+
function decodeUnsafe (source) {
|
|
8847
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
8848
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
8849
|
+
let psz = 0;
|
|
8850
|
+
// Skip and count leading '1's.
|
|
8851
|
+
let zeroes = 0;
|
|
8852
|
+
let length = 0;
|
|
8853
|
+
while (source[psz] === LEADER) {
|
|
8854
|
+
zeroes++;
|
|
8855
|
+
psz++;
|
|
8856
|
+
}
|
|
8857
|
+
// Allocate enough space in big-endian base256 representation.
|
|
8858
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
8859
|
+
const b256 = new Uint8Array(size);
|
|
8860
|
+
// Process the characters.
|
|
8861
|
+
while (psz < source.length) {
|
|
8862
|
+
// Find code of next character
|
|
8863
|
+
const charCode = source.charCodeAt(psz);
|
|
8864
|
+
// Base map can not be indexed using char code
|
|
8865
|
+
if (charCode > 255) { return }
|
|
8866
|
+
// Decode character
|
|
8867
|
+
let carry = BASE_MAP[charCode];
|
|
8868
|
+
// Invalid character
|
|
8869
|
+
if (carry === 255) { return }
|
|
8870
|
+
let i = 0;
|
|
8871
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
8872
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
8873
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
8874
|
+
carry = (carry / 256) >>> 0;
|
|
8875
|
+
}
|
|
8876
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
8877
|
+
length = i;
|
|
8878
|
+
psz++;
|
|
8879
|
+
}
|
|
8880
|
+
// Skip leading zeroes in b256.
|
|
8881
|
+
let it4 = size - length;
|
|
8882
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
8883
|
+
it4++;
|
|
8884
|
+
}
|
|
8885
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
8886
|
+
let j = zeroes;
|
|
8887
|
+
while (it4 !== size) {
|
|
8888
|
+
vch[j++] = b256[it4++];
|
|
8889
|
+
}
|
|
8890
|
+
return vch
|
|
8891
|
+
}
|
|
8892
|
+
function decode (string) {
|
|
8893
|
+
const buffer = decodeUnsafe(string);
|
|
8894
|
+
if (buffer) { return buffer }
|
|
8895
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
8896
|
+
}
|
|
8897
|
+
return {
|
|
8898
|
+
encode,
|
|
8899
|
+
decodeUnsafe,
|
|
8900
|
+
decode
|
|
8901
|
+
}
|
|
8902
|
+
}
|
|
8903
|
+
|
|
8904
|
+
var ALPHABET$3 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
8905
|
+
var bs58$2 = base$3(ALPHABET$3);
|
|
8906
|
+
|
|
8781
8907
|
// src/index.ts
|
|
8782
8908
|
function parseSignMessageResponse(base64Response, networkId) {
|
|
8783
8909
|
const networkPrefix = networkId.split(":")[0].toLowerCase();
|
|
@@ -8824,7 +8950,7 @@ function parseTransactionResponse(base64RawTransaction, networkId, hash) {
|
|
|
8824
8950
|
function parseSolanaSignatureResponse(base64Response) {
|
|
8825
8951
|
try {
|
|
8826
8952
|
const signatureBytes = base64urlDecode(base64Response);
|
|
8827
|
-
const signature = bs58$
|
|
8953
|
+
const signature = bs58$2.encode(signatureBytes);
|
|
8828
8954
|
return {
|
|
8829
8955
|
signature,
|
|
8830
8956
|
rawSignature: base64Response
|
|
@@ -9064,6 +9190,610 @@ function parseBitcoinTransactionToBase64Url(transaction) {
|
|
|
9064
9190
|
throw new Error("Unsupported Bitcoin transaction format");
|
|
9065
9191
|
}
|
|
9066
9192
|
|
|
9193
|
+
// base-x encoding / decoding
|
|
9194
|
+
// Copyright (c) 2018 base-x contributors
|
|
9195
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9196
|
+
// Distributed under the MIT software license, see the accompanying
|
|
9197
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9198
|
+
function base$2 (ALPHABET) {
|
|
9199
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9200
|
+
const BASE_MAP = new Uint8Array(256);
|
|
9201
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
9202
|
+
BASE_MAP[j] = 255;
|
|
9203
|
+
}
|
|
9204
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
9205
|
+
const x = ALPHABET.charAt(i);
|
|
9206
|
+
const xc = x.charCodeAt(0);
|
|
9207
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
9208
|
+
BASE_MAP[xc] = i;
|
|
9209
|
+
}
|
|
9210
|
+
const BASE = ALPHABET.length;
|
|
9211
|
+
const LEADER = ALPHABET.charAt(0);
|
|
9212
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
9213
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
9214
|
+
function encode (source) {
|
|
9215
|
+
// eslint-disable-next-line no-empty
|
|
9216
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
9217
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
9218
|
+
} else if (Array.isArray(source)) {
|
|
9219
|
+
source = Uint8Array.from(source);
|
|
9220
|
+
}
|
|
9221
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
9222
|
+
if (source.length === 0) { return '' }
|
|
9223
|
+
// Skip & count leading zeroes.
|
|
9224
|
+
let zeroes = 0;
|
|
9225
|
+
let length = 0;
|
|
9226
|
+
let pbegin = 0;
|
|
9227
|
+
const pend = source.length;
|
|
9228
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
9229
|
+
pbegin++;
|
|
9230
|
+
zeroes++;
|
|
9231
|
+
}
|
|
9232
|
+
// Allocate enough space in big-endian base58 representation.
|
|
9233
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
9234
|
+
const b58 = new Uint8Array(size);
|
|
9235
|
+
// Process the bytes.
|
|
9236
|
+
while (pbegin !== pend) {
|
|
9237
|
+
let carry = source[pbegin];
|
|
9238
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
9239
|
+
let i = 0;
|
|
9240
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
9241
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
9242
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
9243
|
+
carry = (carry / BASE) >>> 0;
|
|
9244
|
+
}
|
|
9245
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9246
|
+
length = i;
|
|
9247
|
+
pbegin++;
|
|
9248
|
+
}
|
|
9249
|
+
// Skip leading zeroes in base58 result.
|
|
9250
|
+
let it2 = size - length;
|
|
9251
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
9252
|
+
it2++;
|
|
9253
|
+
}
|
|
9254
|
+
// Translate the result into a string.
|
|
9255
|
+
let str = LEADER.repeat(zeroes);
|
|
9256
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
9257
|
+
return str
|
|
9258
|
+
}
|
|
9259
|
+
function decodeUnsafe (source) {
|
|
9260
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
9261
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
9262
|
+
let psz = 0;
|
|
9263
|
+
// Skip and count leading '1's.
|
|
9264
|
+
let zeroes = 0;
|
|
9265
|
+
let length = 0;
|
|
9266
|
+
while (source[psz] === LEADER) {
|
|
9267
|
+
zeroes++;
|
|
9268
|
+
psz++;
|
|
9269
|
+
}
|
|
9270
|
+
// Allocate enough space in big-endian base256 representation.
|
|
9271
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
9272
|
+
const b256 = new Uint8Array(size);
|
|
9273
|
+
// Process the characters.
|
|
9274
|
+
while (psz < source.length) {
|
|
9275
|
+
// Find code of next character
|
|
9276
|
+
const charCode = source.charCodeAt(psz);
|
|
9277
|
+
// Base map can not be indexed using char code
|
|
9278
|
+
if (charCode > 255) { return }
|
|
9279
|
+
// Decode character
|
|
9280
|
+
let carry = BASE_MAP[charCode];
|
|
9281
|
+
// Invalid character
|
|
9282
|
+
if (carry === 255) { return }
|
|
9283
|
+
let i = 0;
|
|
9284
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
9285
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
9286
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
9287
|
+
carry = (carry / 256) >>> 0;
|
|
9288
|
+
}
|
|
9289
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9290
|
+
length = i;
|
|
9291
|
+
psz++;
|
|
9292
|
+
}
|
|
9293
|
+
// Skip leading zeroes in b256.
|
|
9294
|
+
let it4 = size - length;
|
|
9295
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
9296
|
+
it4++;
|
|
9297
|
+
}
|
|
9298
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
9299
|
+
let j = zeroes;
|
|
9300
|
+
while (it4 !== size) {
|
|
9301
|
+
vch[j++] = b256[it4++];
|
|
9302
|
+
}
|
|
9303
|
+
return vch
|
|
9304
|
+
}
|
|
9305
|
+
function decode (string) {
|
|
9306
|
+
const buffer = decodeUnsafe(string);
|
|
9307
|
+
if (buffer) { return buffer }
|
|
9308
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
9309
|
+
}
|
|
9310
|
+
return {
|
|
9311
|
+
encode,
|
|
9312
|
+
decodeUnsafe,
|
|
9313
|
+
decode
|
|
9314
|
+
}
|
|
9315
|
+
}
|
|
9316
|
+
|
|
9317
|
+
var ALPHABET$2 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9318
|
+
var bs58$1 = base$2(ALPHABET$2);
|
|
9319
|
+
|
|
9320
|
+
// base-x encoding / decoding
|
|
9321
|
+
// Copyright (c) 2018 base-x contributors
|
|
9322
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9323
|
+
// Distributed under the MIT software license, see the accompanying
|
|
9324
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9325
|
+
function base$1 (ALPHABET) {
|
|
9326
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9327
|
+
const BASE_MAP = new Uint8Array(256);
|
|
9328
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
9329
|
+
BASE_MAP[j] = 255;
|
|
9330
|
+
}
|
|
9331
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
9332
|
+
const x = ALPHABET.charAt(i);
|
|
9333
|
+
const xc = x.charCodeAt(0);
|
|
9334
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
9335
|
+
BASE_MAP[xc] = i;
|
|
9336
|
+
}
|
|
9337
|
+
const BASE = ALPHABET.length;
|
|
9338
|
+
const LEADER = ALPHABET.charAt(0);
|
|
9339
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
9340
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
9341
|
+
function encode (source) {
|
|
9342
|
+
// eslint-disable-next-line no-empty
|
|
9343
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
9344
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
9345
|
+
} else if (Array.isArray(source)) {
|
|
9346
|
+
source = Uint8Array.from(source);
|
|
9347
|
+
}
|
|
9348
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
9349
|
+
if (source.length === 0) { return '' }
|
|
9350
|
+
// Skip & count leading zeroes.
|
|
9351
|
+
let zeroes = 0;
|
|
9352
|
+
let length = 0;
|
|
9353
|
+
let pbegin = 0;
|
|
9354
|
+
const pend = source.length;
|
|
9355
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
9356
|
+
pbegin++;
|
|
9357
|
+
zeroes++;
|
|
9358
|
+
}
|
|
9359
|
+
// Allocate enough space in big-endian base58 representation.
|
|
9360
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
9361
|
+
const b58 = new Uint8Array(size);
|
|
9362
|
+
// Process the bytes.
|
|
9363
|
+
while (pbegin !== pend) {
|
|
9364
|
+
let carry = source[pbegin];
|
|
9365
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
9366
|
+
let i = 0;
|
|
9367
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
9368
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
9369
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
9370
|
+
carry = (carry / BASE) >>> 0;
|
|
9371
|
+
}
|
|
9372
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9373
|
+
length = i;
|
|
9374
|
+
pbegin++;
|
|
9375
|
+
}
|
|
9376
|
+
// Skip leading zeroes in base58 result.
|
|
9377
|
+
let it2 = size - length;
|
|
9378
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
9379
|
+
it2++;
|
|
9380
|
+
}
|
|
9381
|
+
// Translate the result into a string.
|
|
9382
|
+
let str = LEADER.repeat(zeroes);
|
|
9383
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
9384
|
+
return str
|
|
9385
|
+
}
|
|
9386
|
+
function decodeUnsafe (source) {
|
|
9387
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
9388
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
9389
|
+
let psz = 0;
|
|
9390
|
+
// Skip and count leading '1's.
|
|
9391
|
+
let zeroes = 0;
|
|
9392
|
+
let length = 0;
|
|
9393
|
+
while (source[psz] === LEADER) {
|
|
9394
|
+
zeroes++;
|
|
9395
|
+
psz++;
|
|
9396
|
+
}
|
|
9397
|
+
// Allocate enough space in big-endian base256 representation.
|
|
9398
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
9399
|
+
const b256 = new Uint8Array(size);
|
|
9400
|
+
// Process the characters.
|
|
9401
|
+
while (psz < source.length) {
|
|
9402
|
+
// Find code of next character
|
|
9403
|
+
const charCode = source.charCodeAt(psz);
|
|
9404
|
+
// Base map can not be indexed using char code
|
|
9405
|
+
if (charCode > 255) { return }
|
|
9406
|
+
// Decode character
|
|
9407
|
+
let carry = BASE_MAP[charCode];
|
|
9408
|
+
// Invalid character
|
|
9409
|
+
if (carry === 255) { return }
|
|
9410
|
+
let i = 0;
|
|
9411
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
9412
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
9413
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
9414
|
+
carry = (carry / 256) >>> 0;
|
|
9415
|
+
}
|
|
9416
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9417
|
+
length = i;
|
|
9418
|
+
psz++;
|
|
9419
|
+
}
|
|
9420
|
+
// Skip leading zeroes in b256.
|
|
9421
|
+
let it4 = size - length;
|
|
9422
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
9423
|
+
it4++;
|
|
9424
|
+
}
|
|
9425
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
9426
|
+
let j = zeroes;
|
|
9427
|
+
while (it4 !== size) {
|
|
9428
|
+
vch[j++] = b256[it4++];
|
|
9429
|
+
}
|
|
9430
|
+
return vch
|
|
9431
|
+
}
|
|
9432
|
+
function decode (string) {
|
|
9433
|
+
const buffer = decodeUnsafe(string);
|
|
9434
|
+
if (buffer) { return buffer }
|
|
9435
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
9436
|
+
}
|
|
9437
|
+
return {
|
|
9438
|
+
encode,
|
|
9439
|
+
decodeUnsafe,
|
|
9440
|
+
decode
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
var ALPHABET$1 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9445
|
+
var bs582 = base$1(ALPHABET$1);
|
|
9446
|
+
|
|
9447
|
+
var eventemitter3 = {exports: {}};
|
|
9448
|
+
|
|
9449
|
+
var hasRequiredEventemitter3;
|
|
9450
|
+
|
|
9451
|
+
function requireEventemitter3 () {
|
|
9452
|
+
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
9453
|
+
hasRequiredEventemitter3 = 1;
|
|
9454
|
+
(function (module) {
|
|
9455
|
+
|
|
9456
|
+
var has = Object.prototype.hasOwnProperty
|
|
9457
|
+
, prefix = '~';
|
|
9458
|
+
|
|
9459
|
+
/**
|
|
9460
|
+
* Constructor to create a storage for our `EE` objects.
|
|
9461
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
9462
|
+
*
|
|
9463
|
+
* @constructor
|
|
9464
|
+
* @private
|
|
9465
|
+
*/
|
|
9466
|
+
function Events() {}
|
|
9467
|
+
|
|
9468
|
+
//
|
|
9469
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
9470
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
9471
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
9472
|
+
// character to make sure that the built-in object properties are not
|
|
9473
|
+
// overridden or used as an attack vector.
|
|
9474
|
+
//
|
|
9475
|
+
if (Object.create) {
|
|
9476
|
+
Events.prototype = Object.create(null);
|
|
9477
|
+
|
|
9478
|
+
//
|
|
9479
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
9480
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
9481
|
+
//
|
|
9482
|
+
if (!new Events().__proto__) prefix = false;
|
|
9483
|
+
}
|
|
9484
|
+
|
|
9485
|
+
/**
|
|
9486
|
+
* Representation of a single event listener.
|
|
9487
|
+
*
|
|
9488
|
+
* @param {Function} fn The listener function.
|
|
9489
|
+
* @param {*} context The context to invoke the listener with.
|
|
9490
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
9491
|
+
* @constructor
|
|
9492
|
+
* @private
|
|
9493
|
+
*/
|
|
9494
|
+
function EE(fn, context, once) {
|
|
9495
|
+
this.fn = fn;
|
|
9496
|
+
this.context = context;
|
|
9497
|
+
this.once = once || false;
|
|
9498
|
+
}
|
|
9499
|
+
|
|
9500
|
+
/**
|
|
9501
|
+
* Add a listener for a given event.
|
|
9502
|
+
*
|
|
9503
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
9504
|
+
* @param {(String|Symbol)} event The event name.
|
|
9505
|
+
* @param {Function} fn The listener function.
|
|
9506
|
+
* @param {*} context The context to invoke the listener with.
|
|
9507
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
9508
|
+
* @returns {EventEmitter}
|
|
9509
|
+
* @private
|
|
9510
|
+
*/
|
|
9511
|
+
function addListener(emitter, event, fn, context, once) {
|
|
9512
|
+
if (typeof fn !== 'function') {
|
|
9513
|
+
throw new TypeError('The listener must be a function');
|
|
9514
|
+
}
|
|
9515
|
+
|
|
9516
|
+
var listener = new EE(fn, context || emitter, once)
|
|
9517
|
+
, evt = prefix ? prefix + event : event;
|
|
9518
|
+
|
|
9519
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
9520
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
9521
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
9522
|
+
|
|
9523
|
+
return emitter;
|
|
9524
|
+
}
|
|
9525
|
+
|
|
9526
|
+
/**
|
|
9527
|
+
* Clear event by name.
|
|
9528
|
+
*
|
|
9529
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
9530
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
9531
|
+
* @private
|
|
9532
|
+
*/
|
|
9533
|
+
function clearEvent(emitter, evt) {
|
|
9534
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
9535
|
+
else delete emitter._events[evt];
|
|
9536
|
+
}
|
|
9537
|
+
|
|
9538
|
+
/**
|
|
9539
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
9540
|
+
* `EventEmitter` interface.
|
|
9541
|
+
*
|
|
9542
|
+
* @constructor
|
|
9543
|
+
* @public
|
|
9544
|
+
*/
|
|
9545
|
+
function EventEmitter() {
|
|
9546
|
+
this._events = new Events();
|
|
9547
|
+
this._eventsCount = 0;
|
|
9548
|
+
}
|
|
9549
|
+
|
|
9550
|
+
/**
|
|
9551
|
+
* Return an array listing the events for which the emitter has registered
|
|
9552
|
+
* listeners.
|
|
9553
|
+
*
|
|
9554
|
+
* @returns {Array}
|
|
9555
|
+
* @public
|
|
9556
|
+
*/
|
|
9557
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
9558
|
+
var names = []
|
|
9559
|
+
, events
|
|
9560
|
+
, name;
|
|
9561
|
+
|
|
9562
|
+
if (this._eventsCount === 0) return names;
|
|
9563
|
+
|
|
9564
|
+
for (name in (events = this._events)) {
|
|
9565
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
9566
|
+
}
|
|
9567
|
+
|
|
9568
|
+
if (Object.getOwnPropertySymbols) {
|
|
9569
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
9570
|
+
}
|
|
9571
|
+
|
|
9572
|
+
return names;
|
|
9573
|
+
};
|
|
9574
|
+
|
|
9575
|
+
/**
|
|
9576
|
+
* Return the listeners registered for a given event.
|
|
9577
|
+
*
|
|
9578
|
+
* @param {(String|Symbol)} event The event name.
|
|
9579
|
+
* @returns {Array} The registered listeners.
|
|
9580
|
+
* @public
|
|
9581
|
+
*/
|
|
9582
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
9583
|
+
var evt = prefix ? prefix + event : event
|
|
9584
|
+
, handlers = this._events[evt];
|
|
9585
|
+
|
|
9586
|
+
if (!handlers) return [];
|
|
9587
|
+
if (handlers.fn) return [handlers.fn];
|
|
9588
|
+
|
|
9589
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
9590
|
+
ee[i] = handlers[i].fn;
|
|
9591
|
+
}
|
|
9592
|
+
|
|
9593
|
+
return ee;
|
|
9594
|
+
};
|
|
9595
|
+
|
|
9596
|
+
/**
|
|
9597
|
+
* Return the number of listeners listening to a given event.
|
|
9598
|
+
*
|
|
9599
|
+
* @param {(String|Symbol)} event The event name.
|
|
9600
|
+
* @returns {Number} The number of listeners.
|
|
9601
|
+
* @public
|
|
9602
|
+
*/
|
|
9603
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
9604
|
+
var evt = prefix ? prefix + event : event
|
|
9605
|
+
, listeners = this._events[evt];
|
|
9606
|
+
|
|
9607
|
+
if (!listeners) return 0;
|
|
9608
|
+
if (listeners.fn) return 1;
|
|
9609
|
+
return listeners.length;
|
|
9610
|
+
};
|
|
9611
|
+
|
|
9612
|
+
/**
|
|
9613
|
+
* Calls each of the listeners registered for a given event.
|
|
9614
|
+
*
|
|
9615
|
+
* @param {(String|Symbol)} event The event name.
|
|
9616
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
9617
|
+
* @public
|
|
9618
|
+
*/
|
|
9619
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
9620
|
+
var evt = prefix ? prefix + event : event;
|
|
9621
|
+
|
|
9622
|
+
if (!this._events[evt]) return false;
|
|
9623
|
+
|
|
9624
|
+
var listeners = this._events[evt]
|
|
9625
|
+
, len = arguments.length
|
|
9626
|
+
, args
|
|
9627
|
+
, i;
|
|
9628
|
+
|
|
9629
|
+
if (listeners.fn) {
|
|
9630
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
9631
|
+
|
|
9632
|
+
switch (len) {
|
|
9633
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
9634
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
9635
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
9636
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
9637
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
9638
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
9639
|
+
}
|
|
9640
|
+
|
|
9641
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
9642
|
+
args[i - 1] = arguments[i];
|
|
9643
|
+
}
|
|
9644
|
+
|
|
9645
|
+
listeners.fn.apply(listeners.context, args);
|
|
9646
|
+
} else {
|
|
9647
|
+
var length = listeners.length
|
|
9648
|
+
, j;
|
|
9649
|
+
|
|
9650
|
+
for (i = 0; i < length; i++) {
|
|
9651
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
9652
|
+
|
|
9653
|
+
switch (len) {
|
|
9654
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
9655
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
9656
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
9657
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
9658
|
+
default:
|
|
9659
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
9660
|
+
args[j - 1] = arguments[j];
|
|
9661
|
+
}
|
|
9662
|
+
|
|
9663
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
}
|
|
9667
|
+
|
|
9668
|
+
return true;
|
|
9669
|
+
};
|
|
9670
|
+
|
|
9671
|
+
/**
|
|
9672
|
+
* Add a listener for a given event.
|
|
9673
|
+
*
|
|
9674
|
+
* @param {(String|Symbol)} event The event name.
|
|
9675
|
+
* @param {Function} fn The listener function.
|
|
9676
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
9677
|
+
* @returns {EventEmitter} `this`.
|
|
9678
|
+
* @public
|
|
9679
|
+
*/
|
|
9680
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
9681
|
+
return addListener(this, event, fn, context, false);
|
|
9682
|
+
};
|
|
9683
|
+
|
|
9684
|
+
/**
|
|
9685
|
+
* Add a one-time listener for a given event.
|
|
9686
|
+
*
|
|
9687
|
+
* @param {(String|Symbol)} event The event name.
|
|
9688
|
+
* @param {Function} fn The listener function.
|
|
9689
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
9690
|
+
* @returns {EventEmitter} `this`.
|
|
9691
|
+
* @public
|
|
9692
|
+
*/
|
|
9693
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
9694
|
+
return addListener(this, event, fn, context, true);
|
|
9695
|
+
};
|
|
9696
|
+
|
|
9697
|
+
/**
|
|
9698
|
+
* Remove the listeners of a given event.
|
|
9699
|
+
*
|
|
9700
|
+
* @param {(String|Symbol)} event The event name.
|
|
9701
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
9702
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
9703
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
9704
|
+
* @returns {EventEmitter} `this`.
|
|
9705
|
+
* @public
|
|
9706
|
+
*/
|
|
9707
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
9708
|
+
var evt = prefix ? prefix + event : event;
|
|
9709
|
+
|
|
9710
|
+
if (!this._events[evt]) return this;
|
|
9711
|
+
if (!fn) {
|
|
9712
|
+
clearEvent(this, evt);
|
|
9713
|
+
return this;
|
|
9714
|
+
}
|
|
9715
|
+
|
|
9716
|
+
var listeners = this._events[evt];
|
|
9717
|
+
|
|
9718
|
+
if (listeners.fn) {
|
|
9719
|
+
if (
|
|
9720
|
+
listeners.fn === fn &&
|
|
9721
|
+
(!once || listeners.once) &&
|
|
9722
|
+
(!context || listeners.context === context)
|
|
9723
|
+
) {
|
|
9724
|
+
clearEvent(this, evt);
|
|
9725
|
+
}
|
|
9726
|
+
} else {
|
|
9727
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
9728
|
+
if (
|
|
9729
|
+
listeners[i].fn !== fn ||
|
|
9730
|
+
(once && !listeners[i].once) ||
|
|
9731
|
+
(context && listeners[i].context !== context)
|
|
9732
|
+
) {
|
|
9733
|
+
events.push(listeners[i]);
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
|
|
9737
|
+
//
|
|
9738
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
9739
|
+
//
|
|
9740
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
9741
|
+
else clearEvent(this, evt);
|
|
9742
|
+
}
|
|
9743
|
+
|
|
9744
|
+
return this;
|
|
9745
|
+
};
|
|
9746
|
+
|
|
9747
|
+
/**
|
|
9748
|
+
* Remove all listeners, or those of the specified event.
|
|
9749
|
+
*
|
|
9750
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
9751
|
+
* @returns {EventEmitter} `this`.
|
|
9752
|
+
* @public
|
|
9753
|
+
*/
|
|
9754
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
9755
|
+
var evt;
|
|
9756
|
+
|
|
9757
|
+
if (event) {
|
|
9758
|
+
evt = prefix ? prefix + event : event;
|
|
9759
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
9760
|
+
} else {
|
|
9761
|
+
this._events = new Events();
|
|
9762
|
+
this._eventsCount = 0;
|
|
9763
|
+
}
|
|
9764
|
+
|
|
9765
|
+
return this;
|
|
9766
|
+
};
|
|
9767
|
+
|
|
9768
|
+
//
|
|
9769
|
+
// Alias methods names because people roll like that.
|
|
9770
|
+
//
|
|
9771
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
9772
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
9773
|
+
|
|
9774
|
+
//
|
|
9775
|
+
// Expose the prefix.
|
|
9776
|
+
//
|
|
9777
|
+
EventEmitter.prefixed = prefix;
|
|
9778
|
+
|
|
9779
|
+
//
|
|
9780
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
9781
|
+
//
|
|
9782
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
9783
|
+
|
|
9784
|
+
//
|
|
9785
|
+
// Expose the module.
|
|
9786
|
+
//
|
|
9787
|
+
{
|
|
9788
|
+
module.exports = EventEmitter;
|
|
9789
|
+
}
|
|
9790
|
+
} (eventemitter3));
|
|
9791
|
+
return eventemitter3.exports;
|
|
9792
|
+
}
|
|
9793
|
+
|
|
9794
|
+
var eventemitter3Exports = requireEventemitter3();
|
|
9795
|
+
var EventEmitter2 = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
9796
|
+
|
|
9067
9797
|
// src/embedded-provider.ts
|
|
9068
9798
|
|
|
9069
9799
|
// src/constants.ts
|
|
@@ -9075,7 +9805,7 @@ var EmbeddedSolanaChain = class {
|
|
|
9075
9805
|
this.currentNetworkId = NetworkId.SOLANA_MAINNET;
|
|
9076
9806
|
this._connected = false;
|
|
9077
9807
|
this._publicKey = null;
|
|
9078
|
-
this.eventEmitter = new
|
|
9808
|
+
this.eventEmitter = new EventEmitter2();
|
|
9079
9809
|
this.setupEventListeners();
|
|
9080
9810
|
this.syncInitialState();
|
|
9081
9811
|
}
|
|
@@ -9099,7 +9829,7 @@ var EmbeddedSolanaChain = class {
|
|
|
9099
9829
|
message: messageStr,
|
|
9100
9830
|
networkId: this.currentNetworkId
|
|
9101
9831
|
});
|
|
9102
|
-
const signature = typeof result.signature === "string" ? new Uint8Array(
|
|
9832
|
+
const signature = typeof result.signature === "string" ? new Uint8Array(bs582.decode(result.signature)) : result.signature;
|
|
9103
9833
|
return {
|
|
9104
9834
|
signature,
|
|
9105
9835
|
publicKey: this._publicKey || ""
|
|
@@ -9205,7 +9935,7 @@ var EmbeddedEthereumChain = class {
|
|
|
9205
9935
|
this.currentNetworkId = NetworkId.ETHEREUM_MAINNET;
|
|
9206
9936
|
this._connected = false;
|
|
9207
9937
|
this._accounts = [];
|
|
9208
|
-
this.eventEmitter = new
|
|
9938
|
+
this.eventEmitter = new EventEmitter2();
|
|
9209
9939
|
this.setupEventListeners();
|
|
9210
9940
|
this.syncInitialState();
|
|
9211
9941
|
}
|
|
@@ -9782,7 +10512,7 @@ var EmbeddedProvider$1 = class EmbeddedProvider {
|
|
|
9782
10512
|
publicKey: stamperInfo.publicKey,
|
|
9783
10513
|
platform: platformName
|
|
9784
10514
|
});
|
|
9785
|
-
const base64urlPublicKey = base64urlEncode(
|
|
10515
|
+
const base64urlPublicKey = base64urlEncode(bs582.decode(stamperInfo.publicKey));
|
|
9786
10516
|
const username = `user-${randomUUID()}`;
|
|
9787
10517
|
const { organizationId } = await tempClient.createOrganization(organizationName, [
|
|
9788
10518
|
{
|
|
@@ -10371,6 +11101,133 @@ var EmbeddedProvider$1 = class EmbeddedProvider {
|
|
|
10371
11101
|
}
|
|
10372
11102
|
};
|
|
10373
11103
|
|
|
11104
|
+
// base-x encoding / decoding
|
|
11105
|
+
// Copyright (c) 2018 base-x contributors
|
|
11106
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
11107
|
+
// Distributed under the MIT software license, see the accompanying
|
|
11108
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
11109
|
+
function base (ALPHABET) {
|
|
11110
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
11111
|
+
const BASE_MAP = new Uint8Array(256);
|
|
11112
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
11113
|
+
BASE_MAP[j] = 255;
|
|
11114
|
+
}
|
|
11115
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
11116
|
+
const x = ALPHABET.charAt(i);
|
|
11117
|
+
const xc = x.charCodeAt(0);
|
|
11118
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
11119
|
+
BASE_MAP[xc] = i;
|
|
11120
|
+
}
|
|
11121
|
+
const BASE = ALPHABET.length;
|
|
11122
|
+
const LEADER = ALPHABET.charAt(0);
|
|
11123
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
11124
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
11125
|
+
function encode (source) {
|
|
11126
|
+
// eslint-disable-next-line no-empty
|
|
11127
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
11128
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
11129
|
+
} else if (Array.isArray(source)) {
|
|
11130
|
+
source = Uint8Array.from(source);
|
|
11131
|
+
}
|
|
11132
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
11133
|
+
if (source.length === 0) { return '' }
|
|
11134
|
+
// Skip & count leading zeroes.
|
|
11135
|
+
let zeroes = 0;
|
|
11136
|
+
let length = 0;
|
|
11137
|
+
let pbegin = 0;
|
|
11138
|
+
const pend = source.length;
|
|
11139
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
11140
|
+
pbegin++;
|
|
11141
|
+
zeroes++;
|
|
11142
|
+
}
|
|
11143
|
+
// Allocate enough space in big-endian base58 representation.
|
|
11144
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
11145
|
+
const b58 = new Uint8Array(size);
|
|
11146
|
+
// Process the bytes.
|
|
11147
|
+
while (pbegin !== pend) {
|
|
11148
|
+
let carry = source[pbegin];
|
|
11149
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
11150
|
+
let i = 0;
|
|
11151
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
11152
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
11153
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
11154
|
+
carry = (carry / BASE) >>> 0;
|
|
11155
|
+
}
|
|
11156
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
11157
|
+
length = i;
|
|
11158
|
+
pbegin++;
|
|
11159
|
+
}
|
|
11160
|
+
// Skip leading zeroes in base58 result.
|
|
11161
|
+
let it2 = size - length;
|
|
11162
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
11163
|
+
it2++;
|
|
11164
|
+
}
|
|
11165
|
+
// Translate the result into a string.
|
|
11166
|
+
let str = LEADER.repeat(zeroes);
|
|
11167
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
11168
|
+
return str
|
|
11169
|
+
}
|
|
11170
|
+
function decodeUnsafe (source) {
|
|
11171
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
11172
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
11173
|
+
let psz = 0;
|
|
11174
|
+
// Skip and count leading '1's.
|
|
11175
|
+
let zeroes = 0;
|
|
11176
|
+
let length = 0;
|
|
11177
|
+
while (source[psz] === LEADER) {
|
|
11178
|
+
zeroes++;
|
|
11179
|
+
psz++;
|
|
11180
|
+
}
|
|
11181
|
+
// Allocate enough space in big-endian base256 representation.
|
|
11182
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
11183
|
+
const b256 = new Uint8Array(size);
|
|
11184
|
+
// Process the characters.
|
|
11185
|
+
while (psz < source.length) {
|
|
11186
|
+
// Find code of next character
|
|
11187
|
+
const charCode = source.charCodeAt(psz);
|
|
11188
|
+
// Base map can not be indexed using char code
|
|
11189
|
+
if (charCode > 255) { return }
|
|
11190
|
+
// Decode character
|
|
11191
|
+
let carry = BASE_MAP[charCode];
|
|
11192
|
+
// Invalid character
|
|
11193
|
+
if (carry === 255) { return }
|
|
11194
|
+
let i = 0;
|
|
11195
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
11196
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
11197
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
11198
|
+
carry = (carry / 256) >>> 0;
|
|
11199
|
+
}
|
|
11200
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
11201
|
+
length = i;
|
|
11202
|
+
psz++;
|
|
11203
|
+
}
|
|
11204
|
+
// Skip leading zeroes in b256.
|
|
11205
|
+
let it4 = size - length;
|
|
11206
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
11207
|
+
it4++;
|
|
11208
|
+
}
|
|
11209
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
11210
|
+
let j = zeroes;
|
|
11211
|
+
while (it4 !== size) {
|
|
11212
|
+
vch[j++] = b256[it4++];
|
|
11213
|
+
}
|
|
11214
|
+
return vch
|
|
11215
|
+
}
|
|
11216
|
+
function decode (string) {
|
|
11217
|
+
const buffer = decodeUnsafe(string);
|
|
11218
|
+
if (buffer) { return buffer }
|
|
11219
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
11220
|
+
}
|
|
11221
|
+
return {
|
|
11222
|
+
encode,
|
|
11223
|
+
decodeUnsafe,
|
|
11224
|
+
decode
|
|
11225
|
+
}
|
|
11226
|
+
}
|
|
11227
|
+
|
|
11228
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
11229
|
+
var bs58 = base(ALPHABET);
|
|
11230
|
+
|
|
10374
11231
|
// src/index.ts
|
|
10375
11232
|
var IndexedDbStamper = class {
|
|
10376
11233
|
// Optional for PKI, required for OIDC
|
|
@@ -10444,14 +11301,14 @@ var IndexedDbStamper = class {
|
|
|
10444
11301
|
const salt = params.type === "OIDC" ? params.salt : this.salt;
|
|
10445
11302
|
const stampData = stampType === "PKI" ? {
|
|
10446
11303
|
// Decode base58 public key to bytes, then encode as base64url (consistent with ApiKeyStamper)
|
|
10447
|
-
publicKey: base64urlEncode(bs58
|
|
11304
|
+
publicKey: base64urlEncode(bs58.decode(this.activeKeyPairRecord.keyInfo.publicKey)),
|
|
10448
11305
|
signature: signatureBase64url,
|
|
10449
11306
|
kind: "PKI",
|
|
10450
11307
|
algorithm: this.algorithm
|
|
10451
11308
|
} : {
|
|
10452
11309
|
kind: "OIDC",
|
|
10453
11310
|
idToken,
|
|
10454
|
-
publicKey: base64urlEncode(bs58
|
|
11311
|
+
publicKey: base64urlEncode(bs58.decode(this.activeKeyPairRecord.keyInfo.publicKey)),
|
|
10455
11312
|
salt,
|
|
10456
11313
|
algorithm: this.algorithm,
|
|
10457
11314
|
signature: signatureBase64url
|
|
@@ -10554,7 +11411,7 @@ var IndexedDbStamper = class {
|
|
|
10554
11411
|
["sign", "verify"]
|
|
10555
11412
|
);
|
|
10556
11413
|
const rawPublicKeyBuffer = await crypto.subtle.exportKey("raw", keyPair.publicKey);
|
|
10557
|
-
const publicKeyBase58 = bs58
|
|
11414
|
+
const publicKeyBase58 = bs58.encode(new Uint8Array(rawPublicKeyBuffer));
|
|
10558
11415
|
const keyIdBuffer = await crypto.subtle.digest("SHA-256", rawPublicKeyBuffer);
|
|
10559
11416
|
const keyId = base64urlEncode(new Uint8Array(keyIdBuffer)).substring(0, 16);
|
|
10560
11417
|
const now = Date.now();
|
|
@@ -15884,4 +16741,4 @@ function ConnectBox({ maxWidth = "350px", transparent = false, appIcon, appName
|
|
|
15884
16741
|
}
|
|
15885
16742
|
|
|
15886
16743
|
export { DerivationInfoAddressFormatEnum as AddressType, ConnectBox, ConnectButton, DebugLevel, NetworkId, PhantomProvider, darkTheme, debug, isMobileDevice, lightTheme, mergeTheme, useAccounts, useAutoConfirm, useConnect, useDisconnect, useDiscoveredWallets, useEthereum, useIsExtensionInstalled, useIsPhantomLoginAvailable, useModal, usePhantom, useSolana, useTheme };
|
|
15887
|
-
//# sourceMappingURL=index-
|
|
16744
|
+
//# sourceMappingURL=index-CeQ8hE3s.esm.js.map
|