@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var globalAxios = require('axios');
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-DQVpAl5t.js');
|
|
6
6
|
var web3_js = require('@solana/web3.js');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
require('@coral-xyz/anchor');
|
|
@@ -1150,17 +1150,17 @@ function requireSrc () {
|
|
|
1150
1150
|
return src;
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
-
var bs58;
|
|
1153
|
+
var bs58$3;
|
|
1154
1154
|
var hasRequiredBs58;
|
|
1155
1155
|
|
|
1156
1156
|
function requireBs58 () {
|
|
1157
|
-
if (hasRequiredBs58) return bs58;
|
|
1157
|
+
if (hasRequiredBs58) return bs58$3;
|
|
1158
1158
|
hasRequiredBs58 = 1;
|
|
1159
1159
|
const basex = requireSrc();
|
|
1160
1160
|
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
1161
1161
|
|
|
1162
|
-
bs58 = basex(ALPHABET);
|
|
1163
|
-
return bs58;
|
|
1162
|
+
bs58$3 = basex(ALPHABET);
|
|
1163
|
+
return bs58$3;
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
1166
|
requireBs58();
|
|
@@ -3120,13 +3120,13 @@ function createAutoConfirmPlugin() {
|
|
|
3120
3120
|
};
|
|
3121
3121
|
}
|
|
3122
3122
|
|
|
3123
|
-
var eventemitter3 = {exports: {}};
|
|
3123
|
+
var eventemitter3$1 = {exports: {}};
|
|
3124
3124
|
|
|
3125
|
-
var hasRequiredEventemitter3;
|
|
3125
|
+
var hasRequiredEventemitter3$1;
|
|
3126
3126
|
|
|
3127
|
-
function requireEventemitter3 () {
|
|
3128
|
-
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
3129
|
-
hasRequiredEventemitter3 = 1;
|
|
3127
|
+
function requireEventemitter3$1 () {
|
|
3128
|
+
if (hasRequiredEventemitter3$1) return eventemitter3$1.exports;
|
|
3129
|
+
hasRequiredEventemitter3$1 = 1;
|
|
3130
3130
|
(function (module) {
|
|
3131
3131
|
|
|
3132
3132
|
var has = Object.prototype.hasOwnProperty
|
|
@@ -3463,12 +3463,12 @@ function requireEventemitter3 () {
|
|
|
3463
3463
|
{
|
|
3464
3464
|
module.exports = EventEmitter;
|
|
3465
3465
|
}
|
|
3466
|
-
} (eventemitter3));
|
|
3467
|
-
return eventemitter3.exports;
|
|
3466
|
+
} (eventemitter3$1));
|
|
3467
|
+
return eventemitter3$1.exports;
|
|
3468
3468
|
}
|
|
3469
3469
|
|
|
3470
|
-
var eventemitter3Exports = requireEventemitter3();
|
|
3471
|
-
var EventEmitter3 = /*@__PURE__*/index.getDefaultExportFromCjs(eventemitter3Exports);
|
|
3470
|
+
var eventemitter3Exports$1 = requireEventemitter3$1();
|
|
3471
|
+
var EventEmitter3 = /*@__PURE__*/index.getDefaultExportFromCjs(eventemitter3Exports$1);
|
|
3472
3472
|
|
|
3473
3473
|
// src/index.ts
|
|
3474
3474
|
var isBrowser = typeof window !== "undefined" && typeof window.btoa !== "undefined";
|
|
@@ -8797,6 +8797,133 @@ class Transaction {
|
|
|
8797
8797
|
}
|
|
8798
8798
|
}
|
|
8799
8799
|
|
|
8800
|
+
// base-x encoding / decoding
|
|
8801
|
+
// Copyright (c) 2018 base-x contributors
|
|
8802
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
8803
|
+
// Distributed under the MIT software license, see the accompanying
|
|
8804
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
8805
|
+
function base$3 (ALPHABET) {
|
|
8806
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
8807
|
+
const BASE_MAP = new Uint8Array(256);
|
|
8808
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
8809
|
+
BASE_MAP[j] = 255;
|
|
8810
|
+
}
|
|
8811
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
8812
|
+
const x = ALPHABET.charAt(i);
|
|
8813
|
+
const xc = x.charCodeAt(0);
|
|
8814
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
8815
|
+
BASE_MAP[xc] = i;
|
|
8816
|
+
}
|
|
8817
|
+
const BASE = ALPHABET.length;
|
|
8818
|
+
const LEADER = ALPHABET.charAt(0);
|
|
8819
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
8820
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
8821
|
+
function encode (source) {
|
|
8822
|
+
// eslint-disable-next-line no-empty
|
|
8823
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
8824
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
8825
|
+
} else if (Array.isArray(source)) {
|
|
8826
|
+
source = Uint8Array.from(source);
|
|
8827
|
+
}
|
|
8828
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
8829
|
+
if (source.length === 0) { return '' }
|
|
8830
|
+
// Skip & count leading zeroes.
|
|
8831
|
+
let zeroes = 0;
|
|
8832
|
+
let length = 0;
|
|
8833
|
+
let pbegin = 0;
|
|
8834
|
+
const pend = source.length;
|
|
8835
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
8836
|
+
pbegin++;
|
|
8837
|
+
zeroes++;
|
|
8838
|
+
}
|
|
8839
|
+
// Allocate enough space in big-endian base58 representation.
|
|
8840
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
8841
|
+
const b58 = new Uint8Array(size);
|
|
8842
|
+
// Process the bytes.
|
|
8843
|
+
while (pbegin !== pend) {
|
|
8844
|
+
let carry = source[pbegin];
|
|
8845
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
8846
|
+
let i = 0;
|
|
8847
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
8848
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
8849
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
8850
|
+
carry = (carry / BASE) >>> 0;
|
|
8851
|
+
}
|
|
8852
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
8853
|
+
length = i;
|
|
8854
|
+
pbegin++;
|
|
8855
|
+
}
|
|
8856
|
+
// Skip leading zeroes in base58 result.
|
|
8857
|
+
let it2 = size - length;
|
|
8858
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
8859
|
+
it2++;
|
|
8860
|
+
}
|
|
8861
|
+
// Translate the result into a string.
|
|
8862
|
+
let str = LEADER.repeat(zeroes);
|
|
8863
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
8864
|
+
return str
|
|
8865
|
+
}
|
|
8866
|
+
function decodeUnsafe (source) {
|
|
8867
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
8868
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
8869
|
+
let psz = 0;
|
|
8870
|
+
// Skip and count leading '1's.
|
|
8871
|
+
let zeroes = 0;
|
|
8872
|
+
let length = 0;
|
|
8873
|
+
while (source[psz] === LEADER) {
|
|
8874
|
+
zeroes++;
|
|
8875
|
+
psz++;
|
|
8876
|
+
}
|
|
8877
|
+
// Allocate enough space in big-endian base256 representation.
|
|
8878
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
8879
|
+
const b256 = new Uint8Array(size);
|
|
8880
|
+
// Process the characters.
|
|
8881
|
+
while (psz < source.length) {
|
|
8882
|
+
// Find code of next character
|
|
8883
|
+
const charCode = source.charCodeAt(psz);
|
|
8884
|
+
// Base map can not be indexed using char code
|
|
8885
|
+
if (charCode > 255) { return }
|
|
8886
|
+
// Decode character
|
|
8887
|
+
let carry = BASE_MAP[charCode];
|
|
8888
|
+
// Invalid character
|
|
8889
|
+
if (carry === 255) { return }
|
|
8890
|
+
let i = 0;
|
|
8891
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
8892
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
8893
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
8894
|
+
carry = (carry / 256) >>> 0;
|
|
8895
|
+
}
|
|
8896
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
8897
|
+
length = i;
|
|
8898
|
+
psz++;
|
|
8899
|
+
}
|
|
8900
|
+
// Skip leading zeroes in b256.
|
|
8901
|
+
let it4 = size - length;
|
|
8902
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
8903
|
+
it4++;
|
|
8904
|
+
}
|
|
8905
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
8906
|
+
let j = zeroes;
|
|
8907
|
+
while (it4 !== size) {
|
|
8908
|
+
vch[j++] = b256[it4++];
|
|
8909
|
+
}
|
|
8910
|
+
return vch
|
|
8911
|
+
}
|
|
8912
|
+
function decode (string) {
|
|
8913
|
+
const buffer = decodeUnsafe(string);
|
|
8914
|
+
if (buffer) { return buffer }
|
|
8915
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
8916
|
+
}
|
|
8917
|
+
return {
|
|
8918
|
+
encode,
|
|
8919
|
+
decodeUnsafe,
|
|
8920
|
+
decode
|
|
8921
|
+
}
|
|
8922
|
+
}
|
|
8923
|
+
|
|
8924
|
+
var ALPHABET$3 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
8925
|
+
var bs58$2 = base$3(ALPHABET$3);
|
|
8926
|
+
|
|
8800
8927
|
// src/index.ts
|
|
8801
8928
|
function parseSignMessageResponse(base64Response, networkId) {
|
|
8802
8929
|
const networkPrefix = networkId.split(":")[0].toLowerCase();
|
|
@@ -8843,7 +8970,7 @@ function parseTransactionResponse(base64RawTransaction, networkId, hash) {
|
|
|
8843
8970
|
function parseSolanaSignatureResponse(base64Response) {
|
|
8844
8971
|
try {
|
|
8845
8972
|
const signatureBytes = base64urlDecode(base64Response);
|
|
8846
|
-
const signature =
|
|
8973
|
+
const signature = bs58$2.encode(signatureBytes);
|
|
8847
8974
|
return {
|
|
8848
8975
|
signature,
|
|
8849
8976
|
rawSignature: base64Response
|
|
@@ -9083,6 +9210,610 @@ function parseBitcoinTransactionToBase64Url(transaction) {
|
|
|
9083
9210
|
throw new Error("Unsupported Bitcoin transaction format");
|
|
9084
9211
|
}
|
|
9085
9212
|
|
|
9213
|
+
// base-x encoding / decoding
|
|
9214
|
+
// Copyright (c) 2018 base-x contributors
|
|
9215
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9216
|
+
// Distributed under the MIT software license, see the accompanying
|
|
9217
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9218
|
+
function base$2 (ALPHABET) {
|
|
9219
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9220
|
+
const BASE_MAP = new Uint8Array(256);
|
|
9221
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
9222
|
+
BASE_MAP[j] = 255;
|
|
9223
|
+
}
|
|
9224
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
9225
|
+
const x = ALPHABET.charAt(i);
|
|
9226
|
+
const xc = x.charCodeAt(0);
|
|
9227
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
9228
|
+
BASE_MAP[xc] = i;
|
|
9229
|
+
}
|
|
9230
|
+
const BASE = ALPHABET.length;
|
|
9231
|
+
const LEADER = ALPHABET.charAt(0);
|
|
9232
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
9233
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
9234
|
+
function encode (source) {
|
|
9235
|
+
// eslint-disable-next-line no-empty
|
|
9236
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
9237
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
9238
|
+
} else if (Array.isArray(source)) {
|
|
9239
|
+
source = Uint8Array.from(source);
|
|
9240
|
+
}
|
|
9241
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
9242
|
+
if (source.length === 0) { return '' }
|
|
9243
|
+
// Skip & count leading zeroes.
|
|
9244
|
+
let zeroes = 0;
|
|
9245
|
+
let length = 0;
|
|
9246
|
+
let pbegin = 0;
|
|
9247
|
+
const pend = source.length;
|
|
9248
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
9249
|
+
pbegin++;
|
|
9250
|
+
zeroes++;
|
|
9251
|
+
}
|
|
9252
|
+
// Allocate enough space in big-endian base58 representation.
|
|
9253
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
9254
|
+
const b58 = new Uint8Array(size);
|
|
9255
|
+
// Process the bytes.
|
|
9256
|
+
while (pbegin !== pend) {
|
|
9257
|
+
let carry = source[pbegin];
|
|
9258
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
9259
|
+
let i = 0;
|
|
9260
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
9261
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
9262
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
9263
|
+
carry = (carry / BASE) >>> 0;
|
|
9264
|
+
}
|
|
9265
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9266
|
+
length = i;
|
|
9267
|
+
pbegin++;
|
|
9268
|
+
}
|
|
9269
|
+
// Skip leading zeroes in base58 result.
|
|
9270
|
+
let it2 = size - length;
|
|
9271
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
9272
|
+
it2++;
|
|
9273
|
+
}
|
|
9274
|
+
// Translate the result into a string.
|
|
9275
|
+
let str = LEADER.repeat(zeroes);
|
|
9276
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
9277
|
+
return str
|
|
9278
|
+
}
|
|
9279
|
+
function decodeUnsafe (source) {
|
|
9280
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
9281
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
9282
|
+
let psz = 0;
|
|
9283
|
+
// Skip and count leading '1's.
|
|
9284
|
+
let zeroes = 0;
|
|
9285
|
+
let length = 0;
|
|
9286
|
+
while (source[psz] === LEADER) {
|
|
9287
|
+
zeroes++;
|
|
9288
|
+
psz++;
|
|
9289
|
+
}
|
|
9290
|
+
// Allocate enough space in big-endian base256 representation.
|
|
9291
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
9292
|
+
const b256 = new Uint8Array(size);
|
|
9293
|
+
// Process the characters.
|
|
9294
|
+
while (psz < source.length) {
|
|
9295
|
+
// Find code of next character
|
|
9296
|
+
const charCode = source.charCodeAt(psz);
|
|
9297
|
+
// Base map can not be indexed using char code
|
|
9298
|
+
if (charCode > 255) { return }
|
|
9299
|
+
// Decode character
|
|
9300
|
+
let carry = BASE_MAP[charCode];
|
|
9301
|
+
// Invalid character
|
|
9302
|
+
if (carry === 255) { return }
|
|
9303
|
+
let i = 0;
|
|
9304
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
9305
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
9306
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
9307
|
+
carry = (carry / 256) >>> 0;
|
|
9308
|
+
}
|
|
9309
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9310
|
+
length = i;
|
|
9311
|
+
psz++;
|
|
9312
|
+
}
|
|
9313
|
+
// Skip leading zeroes in b256.
|
|
9314
|
+
let it4 = size - length;
|
|
9315
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
9316
|
+
it4++;
|
|
9317
|
+
}
|
|
9318
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
9319
|
+
let j = zeroes;
|
|
9320
|
+
while (it4 !== size) {
|
|
9321
|
+
vch[j++] = b256[it4++];
|
|
9322
|
+
}
|
|
9323
|
+
return vch
|
|
9324
|
+
}
|
|
9325
|
+
function decode (string) {
|
|
9326
|
+
const buffer = decodeUnsafe(string);
|
|
9327
|
+
if (buffer) { return buffer }
|
|
9328
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
9329
|
+
}
|
|
9330
|
+
return {
|
|
9331
|
+
encode,
|
|
9332
|
+
decodeUnsafe,
|
|
9333
|
+
decode
|
|
9334
|
+
}
|
|
9335
|
+
}
|
|
9336
|
+
|
|
9337
|
+
var ALPHABET$2 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9338
|
+
var bs58$1 = base$2(ALPHABET$2);
|
|
9339
|
+
|
|
9340
|
+
// base-x encoding / decoding
|
|
9341
|
+
// Copyright (c) 2018 base-x contributors
|
|
9342
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9343
|
+
// Distributed under the MIT software license, see the accompanying
|
|
9344
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9345
|
+
function base$1 (ALPHABET) {
|
|
9346
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9347
|
+
const BASE_MAP = new Uint8Array(256);
|
|
9348
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
9349
|
+
BASE_MAP[j] = 255;
|
|
9350
|
+
}
|
|
9351
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
9352
|
+
const x = ALPHABET.charAt(i);
|
|
9353
|
+
const xc = x.charCodeAt(0);
|
|
9354
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
9355
|
+
BASE_MAP[xc] = i;
|
|
9356
|
+
}
|
|
9357
|
+
const BASE = ALPHABET.length;
|
|
9358
|
+
const LEADER = ALPHABET.charAt(0);
|
|
9359
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
9360
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
9361
|
+
function encode (source) {
|
|
9362
|
+
// eslint-disable-next-line no-empty
|
|
9363
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
9364
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
9365
|
+
} else if (Array.isArray(source)) {
|
|
9366
|
+
source = Uint8Array.from(source);
|
|
9367
|
+
}
|
|
9368
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
9369
|
+
if (source.length === 0) { return '' }
|
|
9370
|
+
// Skip & count leading zeroes.
|
|
9371
|
+
let zeroes = 0;
|
|
9372
|
+
let length = 0;
|
|
9373
|
+
let pbegin = 0;
|
|
9374
|
+
const pend = source.length;
|
|
9375
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
9376
|
+
pbegin++;
|
|
9377
|
+
zeroes++;
|
|
9378
|
+
}
|
|
9379
|
+
// Allocate enough space in big-endian base58 representation.
|
|
9380
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
9381
|
+
const b58 = new Uint8Array(size);
|
|
9382
|
+
// Process the bytes.
|
|
9383
|
+
while (pbegin !== pend) {
|
|
9384
|
+
let carry = source[pbegin];
|
|
9385
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
9386
|
+
let i = 0;
|
|
9387
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
9388
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
9389
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
9390
|
+
carry = (carry / BASE) >>> 0;
|
|
9391
|
+
}
|
|
9392
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9393
|
+
length = i;
|
|
9394
|
+
pbegin++;
|
|
9395
|
+
}
|
|
9396
|
+
// Skip leading zeroes in base58 result.
|
|
9397
|
+
let it2 = size - length;
|
|
9398
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
9399
|
+
it2++;
|
|
9400
|
+
}
|
|
9401
|
+
// Translate the result into a string.
|
|
9402
|
+
let str = LEADER.repeat(zeroes);
|
|
9403
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
9404
|
+
return str
|
|
9405
|
+
}
|
|
9406
|
+
function decodeUnsafe (source) {
|
|
9407
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
9408
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
9409
|
+
let psz = 0;
|
|
9410
|
+
// Skip and count leading '1's.
|
|
9411
|
+
let zeroes = 0;
|
|
9412
|
+
let length = 0;
|
|
9413
|
+
while (source[psz] === LEADER) {
|
|
9414
|
+
zeroes++;
|
|
9415
|
+
psz++;
|
|
9416
|
+
}
|
|
9417
|
+
// Allocate enough space in big-endian base256 representation.
|
|
9418
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
9419
|
+
const b256 = new Uint8Array(size);
|
|
9420
|
+
// Process the characters.
|
|
9421
|
+
while (psz < source.length) {
|
|
9422
|
+
// Find code of next character
|
|
9423
|
+
const charCode = source.charCodeAt(psz);
|
|
9424
|
+
// Base map can not be indexed using char code
|
|
9425
|
+
if (charCode > 255) { return }
|
|
9426
|
+
// Decode character
|
|
9427
|
+
let carry = BASE_MAP[charCode];
|
|
9428
|
+
// Invalid character
|
|
9429
|
+
if (carry === 255) { return }
|
|
9430
|
+
let i = 0;
|
|
9431
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
9432
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
9433
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
9434
|
+
carry = (carry / 256) >>> 0;
|
|
9435
|
+
}
|
|
9436
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
9437
|
+
length = i;
|
|
9438
|
+
psz++;
|
|
9439
|
+
}
|
|
9440
|
+
// Skip leading zeroes in b256.
|
|
9441
|
+
let it4 = size - length;
|
|
9442
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
9443
|
+
it4++;
|
|
9444
|
+
}
|
|
9445
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
9446
|
+
let j = zeroes;
|
|
9447
|
+
while (it4 !== size) {
|
|
9448
|
+
vch[j++] = b256[it4++];
|
|
9449
|
+
}
|
|
9450
|
+
return vch
|
|
9451
|
+
}
|
|
9452
|
+
function decode (string) {
|
|
9453
|
+
const buffer = decodeUnsafe(string);
|
|
9454
|
+
if (buffer) { return buffer }
|
|
9455
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
9456
|
+
}
|
|
9457
|
+
return {
|
|
9458
|
+
encode,
|
|
9459
|
+
decodeUnsafe,
|
|
9460
|
+
decode
|
|
9461
|
+
}
|
|
9462
|
+
}
|
|
9463
|
+
|
|
9464
|
+
var ALPHABET$1 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9465
|
+
var bs582 = base$1(ALPHABET$1);
|
|
9466
|
+
|
|
9467
|
+
var eventemitter3 = {exports: {}};
|
|
9468
|
+
|
|
9469
|
+
var hasRequiredEventemitter3;
|
|
9470
|
+
|
|
9471
|
+
function requireEventemitter3 () {
|
|
9472
|
+
if (hasRequiredEventemitter3) return eventemitter3.exports;
|
|
9473
|
+
hasRequiredEventemitter3 = 1;
|
|
9474
|
+
(function (module) {
|
|
9475
|
+
|
|
9476
|
+
var has = Object.prototype.hasOwnProperty
|
|
9477
|
+
, prefix = '~';
|
|
9478
|
+
|
|
9479
|
+
/**
|
|
9480
|
+
* Constructor to create a storage for our `EE` objects.
|
|
9481
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
9482
|
+
*
|
|
9483
|
+
* @constructor
|
|
9484
|
+
* @private
|
|
9485
|
+
*/
|
|
9486
|
+
function Events() {}
|
|
9487
|
+
|
|
9488
|
+
//
|
|
9489
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
9490
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
9491
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
9492
|
+
// character to make sure that the built-in object properties are not
|
|
9493
|
+
// overridden or used as an attack vector.
|
|
9494
|
+
//
|
|
9495
|
+
if (Object.create) {
|
|
9496
|
+
Events.prototype = Object.create(null);
|
|
9497
|
+
|
|
9498
|
+
//
|
|
9499
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
9500
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
9501
|
+
//
|
|
9502
|
+
if (!new Events().__proto__) prefix = false;
|
|
9503
|
+
}
|
|
9504
|
+
|
|
9505
|
+
/**
|
|
9506
|
+
* Representation of a single event listener.
|
|
9507
|
+
*
|
|
9508
|
+
* @param {Function} fn The listener function.
|
|
9509
|
+
* @param {*} context The context to invoke the listener with.
|
|
9510
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
9511
|
+
* @constructor
|
|
9512
|
+
* @private
|
|
9513
|
+
*/
|
|
9514
|
+
function EE(fn, context, once) {
|
|
9515
|
+
this.fn = fn;
|
|
9516
|
+
this.context = context;
|
|
9517
|
+
this.once = once || false;
|
|
9518
|
+
}
|
|
9519
|
+
|
|
9520
|
+
/**
|
|
9521
|
+
* Add a listener for a given event.
|
|
9522
|
+
*
|
|
9523
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
9524
|
+
* @param {(String|Symbol)} event The event name.
|
|
9525
|
+
* @param {Function} fn The listener function.
|
|
9526
|
+
* @param {*} context The context to invoke the listener with.
|
|
9527
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
9528
|
+
* @returns {EventEmitter}
|
|
9529
|
+
* @private
|
|
9530
|
+
*/
|
|
9531
|
+
function addListener(emitter, event, fn, context, once) {
|
|
9532
|
+
if (typeof fn !== 'function') {
|
|
9533
|
+
throw new TypeError('The listener must be a function');
|
|
9534
|
+
}
|
|
9535
|
+
|
|
9536
|
+
var listener = new EE(fn, context || emitter, once)
|
|
9537
|
+
, evt = prefix ? prefix + event : event;
|
|
9538
|
+
|
|
9539
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
9540
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
9541
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
9542
|
+
|
|
9543
|
+
return emitter;
|
|
9544
|
+
}
|
|
9545
|
+
|
|
9546
|
+
/**
|
|
9547
|
+
* Clear event by name.
|
|
9548
|
+
*
|
|
9549
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
9550
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
9551
|
+
* @private
|
|
9552
|
+
*/
|
|
9553
|
+
function clearEvent(emitter, evt) {
|
|
9554
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
9555
|
+
else delete emitter._events[evt];
|
|
9556
|
+
}
|
|
9557
|
+
|
|
9558
|
+
/**
|
|
9559
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
9560
|
+
* `EventEmitter` interface.
|
|
9561
|
+
*
|
|
9562
|
+
* @constructor
|
|
9563
|
+
* @public
|
|
9564
|
+
*/
|
|
9565
|
+
function EventEmitter() {
|
|
9566
|
+
this._events = new Events();
|
|
9567
|
+
this._eventsCount = 0;
|
|
9568
|
+
}
|
|
9569
|
+
|
|
9570
|
+
/**
|
|
9571
|
+
* Return an array listing the events for which the emitter has registered
|
|
9572
|
+
* listeners.
|
|
9573
|
+
*
|
|
9574
|
+
* @returns {Array}
|
|
9575
|
+
* @public
|
|
9576
|
+
*/
|
|
9577
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
9578
|
+
var names = []
|
|
9579
|
+
, events
|
|
9580
|
+
, name;
|
|
9581
|
+
|
|
9582
|
+
if (this._eventsCount === 0) return names;
|
|
9583
|
+
|
|
9584
|
+
for (name in (events = this._events)) {
|
|
9585
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
9586
|
+
}
|
|
9587
|
+
|
|
9588
|
+
if (Object.getOwnPropertySymbols) {
|
|
9589
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
9590
|
+
}
|
|
9591
|
+
|
|
9592
|
+
return names;
|
|
9593
|
+
};
|
|
9594
|
+
|
|
9595
|
+
/**
|
|
9596
|
+
* Return the listeners registered for a given event.
|
|
9597
|
+
*
|
|
9598
|
+
* @param {(String|Symbol)} event The event name.
|
|
9599
|
+
* @returns {Array} The registered listeners.
|
|
9600
|
+
* @public
|
|
9601
|
+
*/
|
|
9602
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
9603
|
+
var evt = prefix ? prefix + event : event
|
|
9604
|
+
, handlers = this._events[evt];
|
|
9605
|
+
|
|
9606
|
+
if (!handlers) return [];
|
|
9607
|
+
if (handlers.fn) return [handlers.fn];
|
|
9608
|
+
|
|
9609
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
9610
|
+
ee[i] = handlers[i].fn;
|
|
9611
|
+
}
|
|
9612
|
+
|
|
9613
|
+
return ee;
|
|
9614
|
+
};
|
|
9615
|
+
|
|
9616
|
+
/**
|
|
9617
|
+
* Return the number of listeners listening to a given event.
|
|
9618
|
+
*
|
|
9619
|
+
* @param {(String|Symbol)} event The event name.
|
|
9620
|
+
* @returns {Number} The number of listeners.
|
|
9621
|
+
* @public
|
|
9622
|
+
*/
|
|
9623
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
9624
|
+
var evt = prefix ? prefix + event : event
|
|
9625
|
+
, listeners = this._events[evt];
|
|
9626
|
+
|
|
9627
|
+
if (!listeners) return 0;
|
|
9628
|
+
if (listeners.fn) return 1;
|
|
9629
|
+
return listeners.length;
|
|
9630
|
+
};
|
|
9631
|
+
|
|
9632
|
+
/**
|
|
9633
|
+
* Calls each of the listeners registered for a given event.
|
|
9634
|
+
*
|
|
9635
|
+
* @param {(String|Symbol)} event The event name.
|
|
9636
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
9637
|
+
* @public
|
|
9638
|
+
*/
|
|
9639
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
9640
|
+
var evt = prefix ? prefix + event : event;
|
|
9641
|
+
|
|
9642
|
+
if (!this._events[evt]) return false;
|
|
9643
|
+
|
|
9644
|
+
var listeners = this._events[evt]
|
|
9645
|
+
, len = arguments.length
|
|
9646
|
+
, args
|
|
9647
|
+
, i;
|
|
9648
|
+
|
|
9649
|
+
if (listeners.fn) {
|
|
9650
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
9651
|
+
|
|
9652
|
+
switch (len) {
|
|
9653
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
9654
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
9655
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
9656
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
9657
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
9658
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
9659
|
+
}
|
|
9660
|
+
|
|
9661
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
9662
|
+
args[i - 1] = arguments[i];
|
|
9663
|
+
}
|
|
9664
|
+
|
|
9665
|
+
listeners.fn.apply(listeners.context, args);
|
|
9666
|
+
} else {
|
|
9667
|
+
var length = listeners.length
|
|
9668
|
+
, j;
|
|
9669
|
+
|
|
9670
|
+
for (i = 0; i < length; i++) {
|
|
9671
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
9672
|
+
|
|
9673
|
+
switch (len) {
|
|
9674
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
9675
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
9676
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
9677
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
9678
|
+
default:
|
|
9679
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
9680
|
+
args[j - 1] = arguments[j];
|
|
9681
|
+
}
|
|
9682
|
+
|
|
9683
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
9684
|
+
}
|
|
9685
|
+
}
|
|
9686
|
+
}
|
|
9687
|
+
|
|
9688
|
+
return true;
|
|
9689
|
+
};
|
|
9690
|
+
|
|
9691
|
+
/**
|
|
9692
|
+
* Add a listener for a given event.
|
|
9693
|
+
*
|
|
9694
|
+
* @param {(String|Symbol)} event The event name.
|
|
9695
|
+
* @param {Function} fn The listener function.
|
|
9696
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
9697
|
+
* @returns {EventEmitter} `this`.
|
|
9698
|
+
* @public
|
|
9699
|
+
*/
|
|
9700
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
9701
|
+
return addListener(this, event, fn, context, false);
|
|
9702
|
+
};
|
|
9703
|
+
|
|
9704
|
+
/**
|
|
9705
|
+
* Add a one-time listener for a given event.
|
|
9706
|
+
*
|
|
9707
|
+
* @param {(String|Symbol)} event The event name.
|
|
9708
|
+
* @param {Function} fn The listener function.
|
|
9709
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
9710
|
+
* @returns {EventEmitter} `this`.
|
|
9711
|
+
* @public
|
|
9712
|
+
*/
|
|
9713
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
9714
|
+
return addListener(this, event, fn, context, true);
|
|
9715
|
+
};
|
|
9716
|
+
|
|
9717
|
+
/**
|
|
9718
|
+
* Remove the listeners of a given event.
|
|
9719
|
+
*
|
|
9720
|
+
* @param {(String|Symbol)} event The event name.
|
|
9721
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
9722
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
9723
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
9724
|
+
* @returns {EventEmitter} `this`.
|
|
9725
|
+
* @public
|
|
9726
|
+
*/
|
|
9727
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
9728
|
+
var evt = prefix ? prefix + event : event;
|
|
9729
|
+
|
|
9730
|
+
if (!this._events[evt]) return this;
|
|
9731
|
+
if (!fn) {
|
|
9732
|
+
clearEvent(this, evt);
|
|
9733
|
+
return this;
|
|
9734
|
+
}
|
|
9735
|
+
|
|
9736
|
+
var listeners = this._events[evt];
|
|
9737
|
+
|
|
9738
|
+
if (listeners.fn) {
|
|
9739
|
+
if (
|
|
9740
|
+
listeners.fn === fn &&
|
|
9741
|
+
(!once || listeners.once) &&
|
|
9742
|
+
(!context || listeners.context === context)
|
|
9743
|
+
) {
|
|
9744
|
+
clearEvent(this, evt);
|
|
9745
|
+
}
|
|
9746
|
+
} else {
|
|
9747
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
9748
|
+
if (
|
|
9749
|
+
listeners[i].fn !== fn ||
|
|
9750
|
+
(once && !listeners[i].once) ||
|
|
9751
|
+
(context && listeners[i].context !== context)
|
|
9752
|
+
) {
|
|
9753
|
+
events.push(listeners[i]);
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
|
|
9757
|
+
//
|
|
9758
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
9759
|
+
//
|
|
9760
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
9761
|
+
else clearEvent(this, evt);
|
|
9762
|
+
}
|
|
9763
|
+
|
|
9764
|
+
return this;
|
|
9765
|
+
};
|
|
9766
|
+
|
|
9767
|
+
/**
|
|
9768
|
+
* Remove all listeners, or those of the specified event.
|
|
9769
|
+
*
|
|
9770
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
9771
|
+
* @returns {EventEmitter} `this`.
|
|
9772
|
+
* @public
|
|
9773
|
+
*/
|
|
9774
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
9775
|
+
var evt;
|
|
9776
|
+
|
|
9777
|
+
if (event) {
|
|
9778
|
+
evt = prefix ? prefix + event : event;
|
|
9779
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
9780
|
+
} else {
|
|
9781
|
+
this._events = new Events();
|
|
9782
|
+
this._eventsCount = 0;
|
|
9783
|
+
}
|
|
9784
|
+
|
|
9785
|
+
return this;
|
|
9786
|
+
};
|
|
9787
|
+
|
|
9788
|
+
//
|
|
9789
|
+
// Alias methods names because people roll like that.
|
|
9790
|
+
//
|
|
9791
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
9792
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
9793
|
+
|
|
9794
|
+
//
|
|
9795
|
+
// Expose the prefix.
|
|
9796
|
+
//
|
|
9797
|
+
EventEmitter.prefixed = prefix;
|
|
9798
|
+
|
|
9799
|
+
//
|
|
9800
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
9801
|
+
//
|
|
9802
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
9803
|
+
|
|
9804
|
+
//
|
|
9805
|
+
// Expose the module.
|
|
9806
|
+
//
|
|
9807
|
+
{
|
|
9808
|
+
module.exports = EventEmitter;
|
|
9809
|
+
}
|
|
9810
|
+
} (eventemitter3));
|
|
9811
|
+
return eventemitter3.exports;
|
|
9812
|
+
}
|
|
9813
|
+
|
|
9814
|
+
var eventemitter3Exports = requireEventemitter3();
|
|
9815
|
+
var EventEmitter2 = /*@__PURE__*/index.getDefaultExportFromCjs(eventemitter3Exports);
|
|
9816
|
+
|
|
9086
9817
|
// src/embedded-provider.ts
|
|
9087
9818
|
|
|
9088
9819
|
// src/constants.ts
|
|
@@ -9094,7 +9825,7 @@ var EmbeddedSolanaChain = class {
|
|
|
9094
9825
|
this.currentNetworkId = NetworkId.SOLANA_MAINNET;
|
|
9095
9826
|
this._connected = false;
|
|
9096
9827
|
this._publicKey = null;
|
|
9097
|
-
this.eventEmitter = new
|
|
9828
|
+
this.eventEmitter = new EventEmitter2();
|
|
9098
9829
|
this.setupEventListeners();
|
|
9099
9830
|
this.syncInitialState();
|
|
9100
9831
|
}
|
|
@@ -9118,7 +9849,7 @@ var EmbeddedSolanaChain = class {
|
|
|
9118
9849
|
message: messageStr,
|
|
9119
9850
|
networkId: this.currentNetworkId
|
|
9120
9851
|
});
|
|
9121
|
-
const signature = typeof result.signature === "string" ? new Uint8Array(
|
|
9852
|
+
const signature = typeof result.signature === "string" ? new Uint8Array(bs582.decode(result.signature)) : result.signature;
|
|
9122
9853
|
return {
|
|
9123
9854
|
signature,
|
|
9124
9855
|
publicKey: this._publicKey || ""
|
|
@@ -9224,7 +9955,7 @@ var EmbeddedEthereumChain = class {
|
|
|
9224
9955
|
this.currentNetworkId = NetworkId.ETHEREUM_MAINNET;
|
|
9225
9956
|
this._connected = false;
|
|
9226
9957
|
this._accounts = [];
|
|
9227
|
-
this.eventEmitter = new
|
|
9958
|
+
this.eventEmitter = new EventEmitter2();
|
|
9228
9959
|
this.setupEventListeners();
|
|
9229
9960
|
this.syncInitialState();
|
|
9230
9961
|
}
|
|
@@ -9801,7 +10532,7 @@ var EmbeddedProvider$1 = class EmbeddedProvider {
|
|
|
9801
10532
|
publicKey: stamperInfo.publicKey,
|
|
9802
10533
|
platform: platformName
|
|
9803
10534
|
});
|
|
9804
|
-
const base64urlPublicKey = base64urlEncode(
|
|
10535
|
+
const base64urlPublicKey = base64urlEncode(bs582.decode(stamperInfo.publicKey));
|
|
9805
10536
|
const username = `user-${randomUUID()}`;
|
|
9806
10537
|
const { organizationId } = await tempClient.createOrganization(organizationName, [
|
|
9807
10538
|
{
|
|
@@ -10390,6 +11121,133 @@ var EmbeddedProvider$1 = class EmbeddedProvider {
|
|
|
10390
11121
|
}
|
|
10391
11122
|
};
|
|
10392
11123
|
|
|
11124
|
+
// base-x encoding / decoding
|
|
11125
|
+
// Copyright (c) 2018 base-x contributors
|
|
11126
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
11127
|
+
// Distributed under the MIT software license, see the accompanying
|
|
11128
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
11129
|
+
function base (ALPHABET) {
|
|
11130
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
11131
|
+
const BASE_MAP = new Uint8Array(256);
|
|
11132
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
11133
|
+
BASE_MAP[j] = 255;
|
|
11134
|
+
}
|
|
11135
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
11136
|
+
const x = ALPHABET.charAt(i);
|
|
11137
|
+
const xc = x.charCodeAt(0);
|
|
11138
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
11139
|
+
BASE_MAP[xc] = i;
|
|
11140
|
+
}
|
|
11141
|
+
const BASE = ALPHABET.length;
|
|
11142
|
+
const LEADER = ALPHABET.charAt(0);
|
|
11143
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
11144
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
11145
|
+
function encode (source) {
|
|
11146
|
+
// eslint-disable-next-line no-empty
|
|
11147
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
11148
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
11149
|
+
} else if (Array.isArray(source)) {
|
|
11150
|
+
source = Uint8Array.from(source);
|
|
11151
|
+
}
|
|
11152
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
11153
|
+
if (source.length === 0) { return '' }
|
|
11154
|
+
// Skip & count leading zeroes.
|
|
11155
|
+
let zeroes = 0;
|
|
11156
|
+
let length = 0;
|
|
11157
|
+
let pbegin = 0;
|
|
11158
|
+
const pend = source.length;
|
|
11159
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
11160
|
+
pbegin++;
|
|
11161
|
+
zeroes++;
|
|
11162
|
+
}
|
|
11163
|
+
// Allocate enough space in big-endian base58 representation.
|
|
11164
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
11165
|
+
const b58 = new Uint8Array(size);
|
|
11166
|
+
// Process the bytes.
|
|
11167
|
+
while (pbegin !== pend) {
|
|
11168
|
+
let carry = source[pbegin];
|
|
11169
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
11170
|
+
let i = 0;
|
|
11171
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
11172
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
11173
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
11174
|
+
carry = (carry / BASE) >>> 0;
|
|
11175
|
+
}
|
|
11176
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
11177
|
+
length = i;
|
|
11178
|
+
pbegin++;
|
|
11179
|
+
}
|
|
11180
|
+
// Skip leading zeroes in base58 result.
|
|
11181
|
+
let it2 = size - length;
|
|
11182
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
11183
|
+
it2++;
|
|
11184
|
+
}
|
|
11185
|
+
// Translate the result into a string.
|
|
11186
|
+
let str = LEADER.repeat(zeroes);
|
|
11187
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
11188
|
+
return str
|
|
11189
|
+
}
|
|
11190
|
+
function decodeUnsafe (source) {
|
|
11191
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
11192
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
11193
|
+
let psz = 0;
|
|
11194
|
+
// Skip and count leading '1's.
|
|
11195
|
+
let zeroes = 0;
|
|
11196
|
+
let length = 0;
|
|
11197
|
+
while (source[psz] === LEADER) {
|
|
11198
|
+
zeroes++;
|
|
11199
|
+
psz++;
|
|
11200
|
+
}
|
|
11201
|
+
// Allocate enough space in big-endian base256 representation.
|
|
11202
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
11203
|
+
const b256 = new Uint8Array(size);
|
|
11204
|
+
// Process the characters.
|
|
11205
|
+
while (psz < source.length) {
|
|
11206
|
+
// Find code of next character
|
|
11207
|
+
const charCode = source.charCodeAt(psz);
|
|
11208
|
+
// Base map can not be indexed using char code
|
|
11209
|
+
if (charCode > 255) { return }
|
|
11210
|
+
// Decode character
|
|
11211
|
+
let carry = BASE_MAP[charCode];
|
|
11212
|
+
// Invalid character
|
|
11213
|
+
if (carry === 255) { return }
|
|
11214
|
+
let i = 0;
|
|
11215
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
11216
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
11217
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
11218
|
+
carry = (carry / 256) >>> 0;
|
|
11219
|
+
}
|
|
11220
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
11221
|
+
length = i;
|
|
11222
|
+
psz++;
|
|
11223
|
+
}
|
|
11224
|
+
// Skip leading zeroes in b256.
|
|
11225
|
+
let it4 = size - length;
|
|
11226
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
11227
|
+
it4++;
|
|
11228
|
+
}
|
|
11229
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
11230
|
+
let j = zeroes;
|
|
11231
|
+
while (it4 !== size) {
|
|
11232
|
+
vch[j++] = b256[it4++];
|
|
11233
|
+
}
|
|
11234
|
+
return vch
|
|
11235
|
+
}
|
|
11236
|
+
function decode (string) {
|
|
11237
|
+
const buffer = decodeUnsafe(string);
|
|
11238
|
+
if (buffer) { return buffer }
|
|
11239
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
11240
|
+
}
|
|
11241
|
+
return {
|
|
11242
|
+
encode,
|
|
11243
|
+
decodeUnsafe,
|
|
11244
|
+
decode
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
|
|
11248
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
11249
|
+
var bs58 = base(ALPHABET);
|
|
11250
|
+
|
|
10393
11251
|
// src/index.ts
|
|
10394
11252
|
var IndexedDbStamper = class {
|
|
10395
11253
|
// Optional for PKI, required for OIDC
|
|
@@ -10463,14 +11321,14 @@ var IndexedDbStamper = class {
|
|
|
10463
11321
|
const salt = params.type === "OIDC" ? params.salt : this.salt;
|
|
10464
11322
|
const stampData = stampType === "PKI" ? {
|
|
10465
11323
|
// Decode base58 public key to bytes, then encode as base64url (consistent with ApiKeyStamper)
|
|
10466
|
-
publicKey: base64urlEncode(
|
|
11324
|
+
publicKey: base64urlEncode(bs58.decode(this.activeKeyPairRecord.keyInfo.publicKey)),
|
|
10467
11325
|
signature: signatureBase64url,
|
|
10468
11326
|
kind: "PKI",
|
|
10469
11327
|
algorithm: this.algorithm
|
|
10470
11328
|
} : {
|
|
10471
11329
|
kind: "OIDC",
|
|
10472
11330
|
idToken,
|
|
10473
|
-
publicKey: base64urlEncode(
|
|
11331
|
+
publicKey: base64urlEncode(bs58.decode(this.activeKeyPairRecord.keyInfo.publicKey)),
|
|
10474
11332
|
salt,
|
|
10475
11333
|
algorithm: this.algorithm,
|
|
10476
11334
|
signature: signatureBase64url
|
|
@@ -10573,7 +11431,7 @@ var IndexedDbStamper = class {
|
|
|
10573
11431
|
["sign", "verify"]
|
|
10574
11432
|
);
|
|
10575
11433
|
const rawPublicKeyBuffer = await crypto.subtle.exportKey("raw", keyPair.publicKey);
|
|
10576
|
-
const publicKeyBase58 =
|
|
11434
|
+
const publicKeyBase58 = bs58.encode(new Uint8Array(rawPublicKeyBuffer));
|
|
10577
11435
|
const keyIdBuffer = await crypto.subtle.digest("SHA-256", rawPublicKeyBuffer);
|
|
10578
11436
|
const keyId = base64urlEncode(new Uint8Array(keyIdBuffer)).substring(0, 16);
|
|
10579
11437
|
const now = Date.now();
|
|
@@ -11492,7 +12350,7 @@ var WalletStandardSolanaAdapter = class {
|
|
|
11492
12350
|
throw new Error("No signature found in signAndSendTransaction result");
|
|
11493
12351
|
}
|
|
11494
12352
|
const signatureBytes = this.parseUint8Array(signatureOutput.signature);
|
|
11495
|
-
const signature =
|
|
12353
|
+
const signature = bs58$1.encode(signatureBytes);
|
|
11496
12354
|
return { signature };
|
|
11497
12355
|
} catch (error) {
|
|
11498
12356
|
debug.error(DebugCategory.INJECTED_PROVIDER, "Wallet Standard Solana signAndSendTransaction failed", {
|
|
@@ -15924,4 +16782,4 @@ exports.useModal = useModal;
|
|
|
15924
16782
|
exports.usePhantom = usePhantom;
|
|
15925
16783
|
exports.useSolana = useSolana;
|
|
15926
16784
|
exports.useTheme = useTheme;
|
|
15927
|
-
//# sourceMappingURL=index-
|
|
16785
|
+
//# sourceMappingURL=index-KUU0aVzP.js.map
|