@pooflabs/web 0.0.81 → 0.0.82
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/dist/{index-B2WGCssJ.js → index-BicMkamC.js} +221 -116
- package/dist/index-BicMkamC.js.map +1 -0
- package/dist/{index-nt_HQVrk.esm.js → index-BsY_Lgiu.esm.js} +222 -116
- package/dist/index-BsY_Lgiu.esm.js.map +1 -0
- package/dist/index-CHWmdXHE.esm.js +6 -0
- package/dist/index-CHWmdXHE.esm.js.map +1 -0
- package/dist/{index-CjHbp7Dq.esm.js → index-CK_2Zn89.esm.js} +135 -8
- package/dist/index-CK_2Zn89.esm.js.map +1 -0
- package/dist/{index-DXPkkq81.js → index-Ci3m3diI.js} +134 -7
- package/dist/index-Ci3m3diI.js.map +1 -0
- package/dist/{index-dcJIjFrs.esm.js → index-DWf2AOhe.esm.js} +134 -7
- package/dist/index-DWf2AOhe.esm.js.map +1 -0
- package/dist/{index-D_DiP8XQ.js → index-DlKo76M3.js} +135 -8
- package/dist/index-DlKo76M3.js.map +1 -0
- package/dist/index-Dz0bPXrU.js +8 -0
- package/dist/index-Dz0bPXrU.js.map +1 -0
- package/dist/{index.browser-CT6PUv9G.js → index.browser-BkMiHSON.js} +1366 -1569
- package/dist/index.browser-BkMiHSON.js.map +1 -0
- package/dist/index.browser-C-_FEr5M.esm.js +1134 -0
- 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-BNdFfyIg.esm.js → index.browser-DCOvqSUT.esm.js} +1366 -1569
- package/dist/index.browser-DCOvqSUT.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-DjEZSiqI.js +1137 -0
- 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 +1 -1
- package/dist/{index.native-CyA-RdvW.js → index.native-11supFRU.js} +2683 -207
- package/dist/index.native-11supFRU.js.map +1 -0
- package/dist/{index.native-BqYr--vb.esm.js → index.native-CLaHKvDv.esm.js} +2682 -207
- package/dist/index.native-CLaHKvDv.esm.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/{phantom-wallet-provider-K2V96G-G.esm.js → phantom-wallet-provider-BN47klTp.esm.js} +4 -4
- package/dist/{phantom-wallet-provider-K2V96G-G.esm.js.map → phantom-wallet-provider-BN47klTp.esm.js.map} +1 -1
- package/dist/{phantom-wallet-provider-DWCaMkyz.js → phantom-wallet-provider-Xb070-O6.js} +4 -4
- package/dist/{phantom-wallet-provider-DWCaMkyz.js.map → phantom-wallet-provider-Xb070-O6.js.map} +1 -1
- package/dist/{privy-wallet-provider-BMg_S_d0.js → privy-wallet-provider-Ch22rj_G.js} +4 -4
- package/dist/privy-wallet-provider-Ch22rj_G.js.map +1 -0
- package/dist/{privy-wallet-provider-DoX8q99w.esm.js → privy-wallet-provider-DUJS5viU.esm.js} +4 -4
- package/dist/privy-wallet-provider-DUJS5viU.esm.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-Cmphb3oB.esm.js → solana-mobile-wallet-provider-BF04Xp8P.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-Cmphb3oB.esm.js.map → solana-mobile-wallet-provider-BF04Xp8P.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-t22Ie8lY.js → solana-mobile-wallet-provider-BXm94fqW.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-t22Ie8lY.js.map → solana-mobile-wallet-provider-BXm94fqW.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-B2WGCssJ.js.map +0 -1
- package/dist/index-Bdcc5821.js +0 -2375
- package/dist/index-Bdcc5821.js.map +0 -1
- package/dist/index-CjHbp7Dq.esm.js.map +0 -1
- package/dist/index-CrOVJFX9.esm.js +0 -2373
- package/dist/index-CrOVJFX9.esm.js.map +0 -1
- package/dist/index-DXPkkq81.js.map +0 -1
- package/dist/index-D_DiP8XQ.js.map +0 -1
- package/dist/index-dcJIjFrs.esm.js.map +0 -1
- package/dist/index-nt_HQVrk.esm.js.map +0 -1
- package/dist/index.browser-BNdFfyIg.esm.js.map +0 -1
- package/dist/index.browser-CT6PUv9G.js.map +0 -1
- package/dist/index.browser-Cy21yaX0.esm.js +0 -1096
- package/dist/index.browser-Cy21yaX0.esm.js.map +0 -1
- package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
- package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
- package/dist/index.browser-ZD7Tz2bn.js +0 -1099
- package/dist/index.browser-ZD7Tz2bn.js.map +0 -1
- package/dist/index.browser-d0PlOXpF.js +0 -105
- package/dist/index.browser-d0PlOXpF.js.map +0 -1
- package/dist/index.browser-pE1s68e9.esm.js +0 -102
- package/dist/index.browser-pE1s68e9.esm.js.map +0 -1
- package/dist/index.browser-vuTr40so.js +0 -1008
- package/dist/index.browser-vuTr40so.js.map +0 -1
- package/dist/index.native-BqYr--vb.esm.js.map +0 -1
- package/dist/index.native-CyA-RdvW.js.map +0 -1
- package/dist/privy-wallet-provider-BMg_S_d0.js.map +0 -1
- package/dist/privy-wallet-provider-DoX8q99w.esm.js.map +0 -1
|
@@ -6902,19 +6902,19 @@ var webSessionManager = /*#__PURE__*/Object.freeze({
|
|
|
6902
6902
|
WebSessionManager: WebSessionManager
|
|
6903
6903
|
});
|
|
6904
6904
|
|
|
6905
|
-
var buffer = {};
|
|
6905
|
+
var buffer$1 = {};
|
|
6906
6906
|
|
|
6907
|
-
var base64Js = {};
|
|
6907
|
+
var base64Js$1 = {};
|
|
6908
6908
|
|
|
6909
|
-
var hasRequiredBase64Js;
|
|
6909
|
+
var hasRequiredBase64Js$1;
|
|
6910
6910
|
|
|
6911
|
-
function requireBase64Js () {
|
|
6912
|
-
if (hasRequiredBase64Js) return base64Js;
|
|
6913
|
-
hasRequiredBase64Js = 1;
|
|
6911
|
+
function requireBase64Js$1 () {
|
|
6912
|
+
if (hasRequiredBase64Js$1) return base64Js$1;
|
|
6913
|
+
hasRequiredBase64Js$1 = 1;
|
|
6914
6914
|
|
|
6915
|
-
base64Js.byteLength = byteLength;
|
|
6916
|
-
base64Js.toByteArray = toByteArray;
|
|
6917
|
-
base64Js.fromByteArray = fromByteArray;
|
|
6915
|
+
base64Js$1.byteLength = byteLength;
|
|
6916
|
+
base64Js$1.toByteArray = toByteArray;
|
|
6917
|
+
base64Js$1.fromByteArray = fromByteArray;
|
|
6918
6918
|
|
|
6919
6919
|
var lookup = [];
|
|
6920
6920
|
var revLookup = [];
|
|
@@ -7060,19 +7060,19 @@ function requireBase64Js () {
|
|
|
7060
7060
|
|
|
7061
7061
|
return parts.join('')
|
|
7062
7062
|
}
|
|
7063
|
-
return base64Js;
|
|
7063
|
+
return base64Js$1;
|
|
7064
7064
|
}
|
|
7065
7065
|
|
|
7066
|
-
var ieee754 = {};
|
|
7066
|
+
var ieee754$1 = {};
|
|
7067
7067
|
|
|
7068
7068
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
7069
7069
|
|
|
7070
|
-
var hasRequiredIeee754;
|
|
7070
|
+
var hasRequiredIeee754$1;
|
|
7071
7071
|
|
|
7072
|
-
function requireIeee754 () {
|
|
7073
|
-
if (hasRequiredIeee754) return ieee754;
|
|
7074
|
-
hasRequiredIeee754 = 1;
|
|
7075
|
-
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
7072
|
+
function requireIeee754$1 () {
|
|
7073
|
+
if (hasRequiredIeee754$1) return ieee754$1;
|
|
7074
|
+
hasRequiredIeee754$1 = 1;
|
|
7075
|
+
ieee754$1.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
7076
7076
|
var e, m;
|
|
7077
7077
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
7078
7078
|
var eMax = (1 << eLen) - 1;
|
|
@@ -7105,7 +7105,7 @@ function requireIeee754 () {
|
|
|
7105
7105
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
7106
7106
|
};
|
|
7107
7107
|
|
|
7108
|
-
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
7108
|
+
ieee754$1.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
7109
7109
|
var e, m, c;
|
|
7110
7110
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
7111
7111
|
var eMax = (1 << eLen) - 1;
|
|
@@ -7156,7 +7156,7 @@ function requireIeee754 () {
|
|
|
7156
7156
|
|
|
7157
7157
|
buffer[offset + i - d] |= s * 128;
|
|
7158
7158
|
};
|
|
7159
|
-
return ieee754;
|
|
7159
|
+
return ieee754$1;
|
|
7160
7160
|
}
|
|
7161
7161
|
|
|
7162
7162
|
/*!
|
|
@@ -7166,15 +7166,15 @@ function requireIeee754 () {
|
|
|
7166
7166
|
* @license MIT
|
|
7167
7167
|
*/
|
|
7168
7168
|
|
|
7169
|
-
var hasRequiredBuffer;
|
|
7169
|
+
var hasRequiredBuffer$1;
|
|
7170
7170
|
|
|
7171
|
-
function requireBuffer () {
|
|
7172
|
-
if (hasRequiredBuffer) return buffer;
|
|
7173
|
-
hasRequiredBuffer = 1;
|
|
7171
|
+
function requireBuffer$1 () {
|
|
7172
|
+
if (hasRequiredBuffer$1) return buffer$1;
|
|
7173
|
+
hasRequiredBuffer$1 = 1;
|
|
7174
7174
|
(function (exports$1) {
|
|
7175
7175
|
|
|
7176
|
-
const base64 = requireBase64Js();
|
|
7177
|
-
const ieee754 = requireIeee754();
|
|
7176
|
+
const base64 = requireBase64Js$1();
|
|
7177
|
+
const ieee754 = requireIeee754$1();
|
|
7178
7178
|
const customInspectSymbol =
|
|
7179
7179
|
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
7180
7180
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
@@ -9267,24 +9267,24 @@ function requireBuffer () {
|
|
|
9267
9267
|
function BufferBigIntNotDefined () {
|
|
9268
9268
|
throw new Error('BigInt not supported')
|
|
9269
9269
|
}
|
|
9270
|
-
} (buffer));
|
|
9271
|
-
return buffer;
|
|
9270
|
+
} (buffer$1));
|
|
9271
|
+
return buffer$1;
|
|
9272
9272
|
}
|
|
9273
9273
|
|
|
9274
|
-
var bufferExports = requireBuffer();
|
|
9274
|
+
var bufferExports = requireBuffer$1();
|
|
9275
9275
|
|
|
9276
|
-
var safeBuffer = {exports: {}};
|
|
9276
|
+
var safeBuffer$1 = {exports: {}};
|
|
9277
9277
|
|
|
9278
9278
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9279
9279
|
|
|
9280
|
-
var hasRequiredSafeBuffer;
|
|
9280
|
+
var hasRequiredSafeBuffer$1;
|
|
9281
9281
|
|
|
9282
|
-
function requireSafeBuffer () {
|
|
9283
|
-
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
9284
|
-
hasRequiredSafeBuffer = 1;
|
|
9282
|
+
function requireSafeBuffer$1 () {
|
|
9283
|
+
if (hasRequiredSafeBuffer$1) return safeBuffer$1.exports;
|
|
9284
|
+
hasRequiredSafeBuffer$1 = 1;
|
|
9285
9285
|
(function (module, exports$1) {
|
|
9286
9286
|
/* eslint-disable node/no-deprecated-api */
|
|
9287
|
-
var buffer = requireBuffer();
|
|
9287
|
+
var buffer = requireBuffer$1();
|
|
9288
9288
|
var Buffer = buffer.Buffer;
|
|
9289
9289
|
|
|
9290
9290
|
// alternative to using Object.keys for old browsers
|
|
@@ -9347,23 +9347,23 @@ function requireSafeBuffer () {
|
|
|
9347
9347
|
}
|
|
9348
9348
|
return buffer.SlowBuffer(size)
|
|
9349
9349
|
};
|
|
9350
|
-
} (safeBuffer, safeBuffer.exports));
|
|
9351
|
-
return safeBuffer.exports;
|
|
9350
|
+
} (safeBuffer$1, safeBuffer$1.exports));
|
|
9351
|
+
return safeBuffer$1.exports;
|
|
9352
9352
|
}
|
|
9353
9353
|
|
|
9354
|
-
var src;
|
|
9355
|
-
var hasRequiredSrc;
|
|
9354
|
+
var src$1;
|
|
9355
|
+
var hasRequiredSrc$1;
|
|
9356
9356
|
|
|
9357
|
-
function requireSrc () {
|
|
9358
|
-
if (hasRequiredSrc) return src;
|
|
9359
|
-
hasRequiredSrc = 1;
|
|
9357
|
+
function requireSrc$1 () {
|
|
9358
|
+
if (hasRequiredSrc$1) return src$1;
|
|
9359
|
+
hasRequiredSrc$1 = 1;
|
|
9360
9360
|
// base-x encoding / decoding
|
|
9361
9361
|
// Copyright (c) 2018 base-x contributors
|
|
9362
9362
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9363
9363
|
// Distributed under the MIT software license, see the accompanying
|
|
9364
9364
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9365
9365
|
// @ts-ignore
|
|
9366
|
-
var _Buffer = requireSafeBuffer().Buffer;
|
|
9366
|
+
var _Buffer = requireSafeBuffer$1().Buffer;
|
|
9367
9367
|
function base (ALPHABET) {
|
|
9368
9368
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9369
9369
|
var BASE_MAP = new Uint8Array(256);
|
|
@@ -9478,21 +9478,21 @@ function requireSrc () {
|
|
|
9478
9478
|
decode: decode
|
|
9479
9479
|
}
|
|
9480
9480
|
}
|
|
9481
|
-
src = base;
|
|
9482
|
-
return src;
|
|
9481
|
+
src$1 = base;
|
|
9482
|
+
return src$1;
|
|
9483
9483
|
}
|
|
9484
9484
|
|
|
9485
|
-
var bs58$1;
|
|
9485
|
+
var bs58$1$1;
|
|
9486
9486
|
var hasRequiredBs58$1;
|
|
9487
9487
|
|
|
9488
9488
|
function requireBs58$1 () {
|
|
9489
|
-
if (hasRequiredBs58$1) return bs58$1;
|
|
9489
|
+
if (hasRequiredBs58$1) return bs58$1$1;
|
|
9490
9490
|
hasRequiredBs58$1 = 1;
|
|
9491
|
-
var basex = requireSrc();
|
|
9491
|
+
var basex = requireSrc$1();
|
|
9492
9492
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9493
9493
|
|
|
9494
|
-
bs58$1 = basex(ALPHABET);
|
|
9495
|
-
return bs58$1;
|
|
9494
|
+
bs58$1$1 = basex(ALPHABET);
|
|
9495
|
+
return bs58$1$1;
|
|
9496
9496
|
}
|
|
9497
9497
|
|
|
9498
9498
|
var bs58Exports$1 = requireBs58$1();
|
|
@@ -9575,6 +9575,12 @@ async function genSolanaMessage(address, nonce) {
|
|
|
9575
9575
|
// Serialization Helpers
|
|
9576
9576
|
// ─────────────────────────────────────────────────────────────
|
|
9577
9577
|
function isHexString(value) {
|
|
9578
|
+
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
9579
|
+
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
9580
|
+
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
9581
|
+
// non-string blows up with TypeError.
|
|
9582
|
+
if (typeof value !== "string")
|
|
9583
|
+
return false;
|
|
9578
9584
|
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
9579
9585
|
let testValue = value;
|
|
9580
9586
|
// Handle negative values
|
|
@@ -9670,8 +9676,11 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
9670
9676
|
}
|
|
9671
9677
|
else if (idl.address === "poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp") {
|
|
9672
9678
|
const program = new anchor.Program(idl, anchorProvider);
|
|
9679
|
+
// Targets `set_documents_v2` (Vec<u8> ra_indices). The on-chain program
|
|
9680
|
+
// also exposes the legacy `set_documents` (Vec<u64>) so SDKs already on npm
|
|
9681
|
+
// continue to work — but new releases of this SDK speak v2 only.
|
|
9673
9682
|
tx = await program.methods
|
|
9674
|
-
.
|
|
9683
|
+
.setDocumentsV2(args.app_id, prepareAnchorArgs(args.documents), args.delete_paths, args.txData, simulate)
|
|
9675
9684
|
.preInstructions(instructions)
|
|
9676
9685
|
.accounts({
|
|
9677
9686
|
payer: payerPublicKey
|
|
@@ -10026,11 +10035,17 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
10026
10035
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
10027
10036
|
Object.assign(headers, _overrides.headers);
|
|
10028
10037
|
}
|
|
10038
|
+
// Writes (PUT/POST/DELETE) can take significantly longer than reads —
|
|
10039
|
+
// server-side they may trigger ad-hoc LUT creation (create + extend +
|
|
10040
|
+
// wait-for-finalization, ~15-30s on mainnet). Use a larger default for
|
|
10041
|
+
// non-GET so the SDK doesn't time out before client-api responds.
|
|
10042
|
+
const isRead = method.toUpperCase() === "GET";
|
|
10043
|
+
const defaultTimeout = isRead ? 30000 : 90000;
|
|
10029
10044
|
const requestConfig = {
|
|
10030
10045
|
method,
|
|
10031
10046
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
10032
10047
|
headers,
|
|
10033
|
-
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a :
|
|
10048
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : defaultTimeout,
|
|
10034
10049
|
};
|
|
10035
10050
|
if (method !== "GET" && method !== "get") {
|
|
10036
10051
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
@@ -10675,21 +10690,38 @@ async function setMany(many, options) {
|
|
|
10675
10690
|
setDocumentData: tx.transactionArgs.setDocumentData,
|
|
10676
10691
|
deletePaths: tx.transactionArgs.deletePaths,
|
|
10677
10692
|
idl: tx.idl,
|
|
10678
|
-
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => {
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10693
|
+
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
|
|
10694
|
+
pluginFunctionKey: txData.pluginFunctionKey,
|
|
10695
|
+
txData: bufferExports.Buffer.from(txData.txData),
|
|
10696
|
+
// raIndices is Vec<u8> on-chain (serialized as Buffer/bytes). The server may send
|
|
10697
|
+
// it as a Buffer, a number[], a Uint8Array, or — over JSON — as Node's serialized
|
|
10698
|
+
// Buffer shape {type: "Buffer", data: number[]} (the default `JSON.stringify(buf)`
|
|
10699
|
+
// output). Normalise all of those to Buffer here. Each value must fit in u8 (matches
|
|
10700
|
+
// Solana's instruction-level account indexing); throw clearly if anything is out of range.
|
|
10701
|
+
raIndices: (() => {
|
|
10702
|
+
const raw = txData.raIndices;
|
|
10703
|
+
if (raw == null)
|
|
10704
|
+
return bufferExports.Buffer.alloc(0);
|
|
10705
|
+
if (bufferExports.Buffer.isBuffer(raw))
|
|
10706
|
+
return raw;
|
|
10707
|
+
if (raw instanceof Uint8Array)
|
|
10708
|
+
return bufferExports.Buffer.from(raw);
|
|
10709
|
+
// Node's JSON-serialised Buffer: {type: "Buffer", data: number[]}
|
|
10710
|
+
const arrayLike = Array.isArray(raw)
|
|
10711
|
+
? raw
|
|
10712
|
+
: (raw && typeof raw === 'object' && Array.isArray(raw.data))
|
|
10713
|
+
? raw.data
|
|
10714
|
+
: (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
|
|
10715
|
+
const bytes = arrayLike.map((raIndex) => {
|
|
10716
|
+
const n = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
|
|
10717
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) {
|
|
10718
|
+
throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
|
|
10686
10719
|
}
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
})) !== null && _b !== void 0 ? _b : [],
|
|
10720
|
+
return n;
|
|
10721
|
+
});
|
|
10722
|
+
return bufferExports.Buffer.from(bytes);
|
|
10723
|
+
})(),
|
|
10724
|
+
}))) !== null && _b !== void 0 ? _b : [],
|
|
10693
10725
|
};
|
|
10694
10726
|
const config = await getConfig();
|
|
10695
10727
|
const solTransaction = {
|
|
@@ -12825,15 +12857,15 @@ function clearIncompatibleSession() {
|
|
|
12825
12857
|
// Lazy loaders for web-only providers.
|
|
12826
12858
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
12827
12859
|
async function loadPrivyWalletProvider() {
|
|
12828
|
-
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-
|
|
12860
|
+
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-Ch22rj_G.js'); });
|
|
12829
12861
|
return mod.PrivyWalletProvider;
|
|
12830
12862
|
}
|
|
12831
12863
|
async function loadPhantomWalletProvider() {
|
|
12832
|
-
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-
|
|
12864
|
+
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-Xb070-O6.js'); });
|
|
12833
12865
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
12834
12866
|
}
|
|
12835
12867
|
async function loadSolanaMobileWalletProvider() {
|
|
12836
|
-
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-
|
|
12868
|
+
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-BXm94fqW.js'); });
|
|
12837
12869
|
return mod.SolanaMobileWalletProvider;
|
|
12838
12870
|
}
|
|
12839
12871
|
async function hotSwapToPrivyProvider(config) {
|
|
@@ -13251,160 +13283,2603 @@ async function confirmAndCheckTransaction(connection, signature) {
|
|
|
13251
13283
|
throw new Error('Transaction confirmation timeout');
|
|
13252
13284
|
}
|
|
13253
13285
|
|
|
13254
|
-
var
|
|
13286
|
+
var safeBuffer = {exports: {}};
|
|
13255
13287
|
|
|
13256
|
-
var
|
|
13288
|
+
var buffer = {};
|
|
13257
13289
|
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13290
|
+
var base64Js = {};
|
|
13291
|
+
|
|
13292
|
+
var hasRequiredBase64Js;
|
|
13293
|
+
|
|
13294
|
+
function requireBase64Js () {
|
|
13295
|
+
if (hasRequiredBase64Js) return base64Js;
|
|
13296
|
+
hasRequiredBase64Js = 1;
|
|
13297
|
+
|
|
13298
|
+
base64Js.byteLength = byteLength;
|
|
13299
|
+
base64Js.toByteArray = toByteArray;
|
|
13300
|
+
base64Js.fromByteArray = fromByteArray;
|
|
13301
|
+
|
|
13302
|
+
var lookup = [];
|
|
13303
|
+
var revLookup = [];
|
|
13304
|
+
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
13305
|
+
|
|
13306
|
+
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
13307
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
13308
|
+
lookup[i] = code[i];
|
|
13309
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
13310
|
+
}
|
|
13311
|
+
|
|
13312
|
+
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
13313
|
+
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
13314
|
+
revLookup['-'.charCodeAt(0)] = 62;
|
|
13315
|
+
revLookup['_'.charCodeAt(0)] = 63;
|
|
13316
|
+
|
|
13317
|
+
function getLens (b64) {
|
|
13318
|
+
var len = b64.length;
|
|
13319
|
+
|
|
13320
|
+
if (len % 4 > 0) {
|
|
13321
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
13278
13322
|
}
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13323
|
+
|
|
13324
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
13325
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
13326
|
+
var validLen = b64.indexOf('=');
|
|
13327
|
+
if (validLen === -1) validLen = len;
|
|
13328
|
+
|
|
13329
|
+
var placeHoldersLen = validLen === len
|
|
13330
|
+
? 0
|
|
13331
|
+
: 4 - (validLen % 4);
|
|
13332
|
+
|
|
13333
|
+
return [validLen, placeHoldersLen]
|
|
13334
|
+
}
|
|
13335
|
+
|
|
13336
|
+
// base64 is 4/3 + up to two characters of the original data
|
|
13337
|
+
function byteLength (b64) {
|
|
13338
|
+
var lens = getLens(b64);
|
|
13339
|
+
var validLen = lens[0];
|
|
13340
|
+
var placeHoldersLen = lens[1];
|
|
13341
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
13342
|
+
}
|
|
13343
|
+
|
|
13344
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
13345
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
13346
|
+
}
|
|
13347
|
+
|
|
13348
|
+
function toByteArray (b64) {
|
|
13349
|
+
var tmp;
|
|
13350
|
+
var lens = getLens(b64);
|
|
13351
|
+
var validLen = lens[0];
|
|
13352
|
+
var placeHoldersLen = lens[1];
|
|
13353
|
+
|
|
13354
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
13355
|
+
|
|
13356
|
+
var curByte = 0;
|
|
13357
|
+
|
|
13358
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
|
13359
|
+
var len = placeHoldersLen > 0
|
|
13360
|
+
? validLen - 4
|
|
13361
|
+
: validLen;
|
|
13362
|
+
|
|
13363
|
+
var i;
|
|
13364
|
+
for (i = 0; i < len; i += 4) {
|
|
13365
|
+
tmp =
|
|
13366
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
13367
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
13368
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
13369
|
+
revLookup[b64.charCodeAt(i + 3)];
|
|
13370
|
+
arr[curByte++] = (tmp >> 16) & 0xFF;
|
|
13371
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
13372
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13327
13373
|
}
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
let length = 0;
|
|
13335
|
-
while (source[psz] === LEADER) {
|
|
13336
|
-
zeroes++;
|
|
13337
|
-
psz++;
|
|
13338
|
-
}
|
|
13339
|
-
// Allocate enough space in big-endian base256 representation.
|
|
13340
|
-
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
13341
|
-
const b256 = new Uint8Array(size);
|
|
13342
|
-
// Process the characters.
|
|
13343
|
-
while (psz < source.length) {
|
|
13344
|
-
// Find code of next character
|
|
13345
|
-
const charCode = source.charCodeAt(psz);
|
|
13346
|
-
// Base map can not be indexed using char code
|
|
13347
|
-
if (charCode > 255) { return }
|
|
13348
|
-
// Decode character
|
|
13349
|
-
let carry = BASE_MAP[charCode];
|
|
13350
|
-
// Invalid character
|
|
13351
|
-
if (carry === 255) { return }
|
|
13352
|
-
let i = 0;
|
|
13353
|
-
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
13354
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
13355
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
13356
|
-
carry = (carry / 256) >>> 0;
|
|
13357
|
-
}
|
|
13358
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
13359
|
-
length = i;
|
|
13360
|
-
psz++;
|
|
13361
|
-
}
|
|
13362
|
-
// Skip leading zeroes in b256.
|
|
13363
|
-
let it4 = size - length;
|
|
13364
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
13365
|
-
it4++;
|
|
13366
|
-
}
|
|
13367
|
-
const vch = new Uint8Array(zeroes + (size - it4));
|
|
13368
|
-
let j = zeroes;
|
|
13369
|
-
while (it4 !== size) {
|
|
13370
|
-
vch[j++] = b256[it4++];
|
|
13371
|
-
}
|
|
13372
|
-
return vch
|
|
13374
|
+
|
|
13375
|
+
if (placeHoldersLen === 2) {
|
|
13376
|
+
tmp =
|
|
13377
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
13378
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4);
|
|
13379
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13373
13380
|
}
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13381
|
+
|
|
13382
|
+
if (placeHoldersLen === 1) {
|
|
13383
|
+
tmp =
|
|
13384
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
13385
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
13386
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2);
|
|
13387
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
13388
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13378
13389
|
}
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13390
|
+
|
|
13391
|
+
return arr
|
|
13392
|
+
}
|
|
13393
|
+
|
|
13394
|
+
function tripletToBase64 (num) {
|
|
13395
|
+
return lookup[num >> 18 & 0x3F] +
|
|
13396
|
+
lookup[num >> 12 & 0x3F] +
|
|
13397
|
+
lookup[num >> 6 & 0x3F] +
|
|
13398
|
+
lookup[num & 0x3F]
|
|
13399
|
+
}
|
|
13400
|
+
|
|
13401
|
+
function encodeChunk (uint8, start, end) {
|
|
13402
|
+
var tmp;
|
|
13403
|
+
var output = [];
|
|
13404
|
+
for (var i = start; i < end; i += 3) {
|
|
13405
|
+
tmp =
|
|
13406
|
+
((uint8[i] << 16) & 0xFF0000) +
|
|
13407
|
+
((uint8[i + 1] << 8) & 0xFF00) +
|
|
13408
|
+
(uint8[i + 2] & 0xFF);
|
|
13409
|
+
output.push(tripletToBase64(tmp));
|
|
13383
13410
|
}
|
|
13411
|
+
return output.join('')
|
|
13384
13412
|
}
|
|
13385
|
-
cjs.default = base;
|
|
13386
|
-
return cjs;
|
|
13387
|
-
}
|
|
13388
13413
|
|
|
13389
|
-
|
|
13390
|
-
var
|
|
13414
|
+
function fromByteArray (uint8) {
|
|
13415
|
+
var tmp;
|
|
13416
|
+
var len = uint8.length;
|
|
13417
|
+
var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
|
13418
|
+
var parts = [];
|
|
13419
|
+
var maxChunkLength = 16383; // must be multiple of 3
|
|
13391
13420
|
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
13421
|
+
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
13422
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
13423
|
+
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
|
|
13424
|
+
}
|
|
13397
13425
|
|
|
13398
|
-
|
|
13399
|
-
|
|
13426
|
+
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
13427
|
+
if (extraBytes === 1) {
|
|
13428
|
+
tmp = uint8[len - 1];
|
|
13429
|
+
parts.push(
|
|
13430
|
+
lookup[tmp >> 2] +
|
|
13431
|
+
lookup[(tmp << 4) & 0x3F] +
|
|
13432
|
+
'=='
|
|
13433
|
+
);
|
|
13434
|
+
} else if (extraBytes === 2) {
|
|
13435
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
13436
|
+
parts.push(
|
|
13437
|
+
lookup[tmp >> 10] +
|
|
13438
|
+
lookup[(tmp >> 4) & 0x3F] +
|
|
13439
|
+
lookup[(tmp << 2) & 0x3F] +
|
|
13440
|
+
'='
|
|
13441
|
+
);
|
|
13442
|
+
}
|
|
13443
|
+
|
|
13444
|
+
return parts.join('')
|
|
13445
|
+
}
|
|
13446
|
+
return base64Js;
|
|
13447
|
+
}
|
|
13448
|
+
|
|
13449
|
+
var ieee754 = {};
|
|
13450
|
+
|
|
13451
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
13452
|
+
|
|
13453
|
+
var hasRequiredIeee754;
|
|
13454
|
+
|
|
13455
|
+
function requireIeee754 () {
|
|
13456
|
+
if (hasRequiredIeee754) return ieee754;
|
|
13457
|
+
hasRequiredIeee754 = 1;
|
|
13458
|
+
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
13459
|
+
var e, m;
|
|
13460
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
13461
|
+
var eMax = (1 << eLen) - 1;
|
|
13462
|
+
var eBias = eMax >> 1;
|
|
13463
|
+
var nBits = -7;
|
|
13464
|
+
var i = isLE ? (nBytes - 1) : 0;
|
|
13465
|
+
var d = isLE ? -1 : 1;
|
|
13466
|
+
var s = buffer[offset + i];
|
|
13467
|
+
|
|
13468
|
+
i += d;
|
|
13469
|
+
|
|
13470
|
+
e = s & ((1 << (-nBits)) - 1);
|
|
13471
|
+
s >>= (-nBits);
|
|
13472
|
+
nBits += eLen;
|
|
13473
|
+
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13474
|
+
|
|
13475
|
+
m = e & ((1 << (-nBits)) - 1);
|
|
13476
|
+
e >>= (-nBits);
|
|
13477
|
+
nBits += mLen;
|
|
13478
|
+
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13479
|
+
|
|
13480
|
+
if (e === 0) {
|
|
13481
|
+
e = 1 - eBias;
|
|
13482
|
+
} else if (e === eMax) {
|
|
13483
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
13484
|
+
} else {
|
|
13485
|
+
m = m + Math.pow(2, mLen);
|
|
13486
|
+
e = e - eBias;
|
|
13487
|
+
}
|
|
13488
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
13489
|
+
};
|
|
13490
|
+
|
|
13491
|
+
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
13492
|
+
var e, m, c;
|
|
13493
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
13494
|
+
var eMax = (1 << eLen) - 1;
|
|
13495
|
+
var eBias = eMax >> 1;
|
|
13496
|
+
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
|
|
13497
|
+
var i = isLE ? 0 : (nBytes - 1);
|
|
13498
|
+
var d = isLE ? 1 : -1;
|
|
13499
|
+
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
13500
|
+
|
|
13501
|
+
value = Math.abs(value);
|
|
13502
|
+
|
|
13503
|
+
if (isNaN(value) || value === Infinity) {
|
|
13504
|
+
m = isNaN(value) ? 1 : 0;
|
|
13505
|
+
e = eMax;
|
|
13506
|
+
} else {
|
|
13507
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
13508
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
13509
|
+
e--;
|
|
13510
|
+
c *= 2;
|
|
13511
|
+
}
|
|
13512
|
+
if (e + eBias >= 1) {
|
|
13513
|
+
value += rt / c;
|
|
13514
|
+
} else {
|
|
13515
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
13516
|
+
}
|
|
13517
|
+
if (value * c >= 2) {
|
|
13518
|
+
e++;
|
|
13519
|
+
c /= 2;
|
|
13520
|
+
}
|
|
13521
|
+
|
|
13522
|
+
if (e + eBias >= eMax) {
|
|
13523
|
+
m = 0;
|
|
13524
|
+
e = eMax;
|
|
13525
|
+
} else if (e + eBias >= 1) {
|
|
13526
|
+
m = ((value * c) - 1) * Math.pow(2, mLen);
|
|
13527
|
+
e = e + eBias;
|
|
13528
|
+
} else {
|
|
13529
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
13530
|
+
e = 0;
|
|
13531
|
+
}
|
|
13532
|
+
}
|
|
13533
|
+
|
|
13534
|
+
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
13535
|
+
|
|
13536
|
+
e = (e << mLen) | m;
|
|
13537
|
+
eLen += mLen;
|
|
13538
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
13539
|
+
|
|
13540
|
+
buffer[offset + i - d] |= s * 128;
|
|
13541
|
+
};
|
|
13542
|
+
return ieee754;
|
|
13543
|
+
}
|
|
13544
|
+
|
|
13545
|
+
/*!
|
|
13546
|
+
* The buffer module from node.js, for the browser.
|
|
13547
|
+
*
|
|
13548
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
13549
|
+
* @license MIT
|
|
13550
|
+
*/
|
|
13551
|
+
|
|
13552
|
+
var hasRequiredBuffer;
|
|
13553
|
+
|
|
13554
|
+
function requireBuffer () {
|
|
13555
|
+
if (hasRequiredBuffer) return buffer;
|
|
13556
|
+
hasRequiredBuffer = 1;
|
|
13557
|
+
(function (exports$1) {
|
|
13558
|
+
|
|
13559
|
+
const base64 = requireBase64Js();
|
|
13560
|
+
const ieee754 = requireIeee754();
|
|
13561
|
+
const customInspectSymbol =
|
|
13562
|
+
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
13563
|
+
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
13564
|
+
: null;
|
|
13565
|
+
|
|
13566
|
+
exports$1.Buffer = Buffer;
|
|
13567
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
13568
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
13569
|
+
|
|
13570
|
+
const K_MAX_LENGTH = 0x7fffffff;
|
|
13571
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
13572
|
+
|
|
13573
|
+
/**
|
|
13574
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
13575
|
+
* === true Use Uint8Array implementation (fastest)
|
|
13576
|
+
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
13577
|
+
* implementation (most compatible, even IE6)
|
|
13578
|
+
*
|
|
13579
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
13580
|
+
* Opera 11.6+, iOS 4.2+.
|
|
13581
|
+
*
|
|
13582
|
+
* We report that the browser does not support typed arrays if the are not subclassable
|
|
13583
|
+
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
13584
|
+
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
13585
|
+
* for __proto__ and has a buggy typed array implementation.
|
|
13586
|
+
*/
|
|
13587
|
+
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
13588
|
+
|
|
13589
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
13590
|
+
typeof console.error === 'function') {
|
|
13591
|
+
console.error(
|
|
13592
|
+
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
13593
|
+
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
13594
|
+
);
|
|
13595
|
+
}
|
|
13596
|
+
|
|
13597
|
+
function typedArraySupport () {
|
|
13598
|
+
// Can typed array instances can be augmented?
|
|
13599
|
+
try {
|
|
13600
|
+
const arr = new Uint8Array(1);
|
|
13601
|
+
const proto = { foo: function () { return 42 } };
|
|
13602
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
13603
|
+
Object.setPrototypeOf(arr, proto);
|
|
13604
|
+
return arr.foo() === 42
|
|
13605
|
+
} catch (e) {
|
|
13606
|
+
return false
|
|
13607
|
+
}
|
|
13608
|
+
}
|
|
13609
|
+
|
|
13610
|
+
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
13611
|
+
enumerable: true,
|
|
13612
|
+
get: function () {
|
|
13613
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
13614
|
+
return this.buffer
|
|
13615
|
+
}
|
|
13616
|
+
});
|
|
13617
|
+
|
|
13618
|
+
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
13619
|
+
enumerable: true,
|
|
13620
|
+
get: function () {
|
|
13621
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
13622
|
+
return this.byteOffset
|
|
13623
|
+
}
|
|
13624
|
+
});
|
|
13625
|
+
|
|
13626
|
+
function createBuffer (length) {
|
|
13627
|
+
if (length > K_MAX_LENGTH) {
|
|
13628
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
13629
|
+
}
|
|
13630
|
+
// Return an augmented `Uint8Array` instance
|
|
13631
|
+
const buf = new Uint8Array(length);
|
|
13632
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13633
|
+
return buf
|
|
13634
|
+
}
|
|
13635
|
+
|
|
13636
|
+
/**
|
|
13637
|
+
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
13638
|
+
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
13639
|
+
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
13640
|
+
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
13641
|
+
* returns a single octet.
|
|
13642
|
+
*
|
|
13643
|
+
* The `Uint8Array` prototype remains unmodified.
|
|
13644
|
+
*/
|
|
13645
|
+
|
|
13646
|
+
function Buffer (arg, encodingOrOffset, length) {
|
|
13647
|
+
// Common case.
|
|
13648
|
+
if (typeof arg === 'number') {
|
|
13649
|
+
if (typeof encodingOrOffset === 'string') {
|
|
13650
|
+
throw new TypeError(
|
|
13651
|
+
'The "string" argument must be of type string. Received type number'
|
|
13652
|
+
)
|
|
13653
|
+
}
|
|
13654
|
+
return allocUnsafe(arg)
|
|
13655
|
+
}
|
|
13656
|
+
return from(arg, encodingOrOffset, length)
|
|
13657
|
+
}
|
|
13658
|
+
|
|
13659
|
+
Buffer.poolSize = 8192; // not used by this implementation
|
|
13660
|
+
|
|
13661
|
+
function from (value, encodingOrOffset, length) {
|
|
13662
|
+
if (typeof value === 'string') {
|
|
13663
|
+
return fromString(value, encodingOrOffset)
|
|
13664
|
+
}
|
|
13665
|
+
|
|
13666
|
+
if (ArrayBuffer.isView(value)) {
|
|
13667
|
+
return fromArrayView(value)
|
|
13668
|
+
}
|
|
13669
|
+
|
|
13670
|
+
if (value == null) {
|
|
13671
|
+
throw new TypeError(
|
|
13672
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13673
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
13674
|
+
)
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13677
|
+
if (isInstance(value, ArrayBuffer) ||
|
|
13678
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
13679
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13680
|
+
}
|
|
13681
|
+
|
|
13682
|
+
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
13683
|
+
(isInstance(value, SharedArrayBuffer) ||
|
|
13684
|
+
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
13685
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13686
|
+
}
|
|
13687
|
+
|
|
13688
|
+
if (typeof value === 'number') {
|
|
13689
|
+
throw new TypeError(
|
|
13690
|
+
'The "value" argument must not be of type number. Received type number'
|
|
13691
|
+
)
|
|
13692
|
+
}
|
|
13693
|
+
|
|
13694
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
13695
|
+
if (valueOf != null && valueOf !== value) {
|
|
13696
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
13697
|
+
}
|
|
13698
|
+
|
|
13699
|
+
const b = fromObject(value);
|
|
13700
|
+
if (b) return b
|
|
13701
|
+
|
|
13702
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
13703
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
|
13704
|
+
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
|
13705
|
+
}
|
|
13706
|
+
|
|
13707
|
+
throw new TypeError(
|
|
13708
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13709
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
13710
|
+
)
|
|
13711
|
+
}
|
|
13712
|
+
|
|
13713
|
+
/**
|
|
13714
|
+
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
13715
|
+
* if value is a number.
|
|
13716
|
+
* Buffer.from(str[, encoding])
|
|
13717
|
+
* Buffer.from(array)
|
|
13718
|
+
* Buffer.from(buffer)
|
|
13719
|
+
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
13720
|
+
**/
|
|
13721
|
+
Buffer.from = function (value, encodingOrOffset, length) {
|
|
13722
|
+
return from(value, encodingOrOffset, length)
|
|
13723
|
+
};
|
|
13724
|
+
|
|
13725
|
+
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
13726
|
+
// https://github.com/feross/buffer/pull/148
|
|
13727
|
+
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
13728
|
+
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
13729
|
+
|
|
13730
|
+
function assertSize (size) {
|
|
13731
|
+
if (typeof size !== 'number') {
|
|
13732
|
+
throw new TypeError('"size" argument must be of type number')
|
|
13733
|
+
} else if (size < 0) {
|
|
13734
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
13735
|
+
}
|
|
13736
|
+
}
|
|
13737
|
+
|
|
13738
|
+
function alloc (size, fill, encoding) {
|
|
13739
|
+
assertSize(size);
|
|
13740
|
+
if (size <= 0) {
|
|
13741
|
+
return createBuffer(size)
|
|
13742
|
+
}
|
|
13743
|
+
if (fill !== undefined) {
|
|
13744
|
+
// Only pay attention to encoding if it's a string. This
|
|
13745
|
+
// prevents accidentally sending in a number that would
|
|
13746
|
+
// be interpreted as a start offset.
|
|
13747
|
+
return typeof encoding === 'string'
|
|
13748
|
+
? createBuffer(size).fill(fill, encoding)
|
|
13749
|
+
: createBuffer(size).fill(fill)
|
|
13750
|
+
}
|
|
13751
|
+
return createBuffer(size)
|
|
13752
|
+
}
|
|
13753
|
+
|
|
13754
|
+
/**
|
|
13755
|
+
* Creates a new filled Buffer instance.
|
|
13756
|
+
* alloc(size[, fill[, encoding]])
|
|
13757
|
+
**/
|
|
13758
|
+
Buffer.alloc = function (size, fill, encoding) {
|
|
13759
|
+
return alloc(size, fill, encoding)
|
|
13760
|
+
};
|
|
13761
|
+
|
|
13762
|
+
function allocUnsafe (size) {
|
|
13763
|
+
assertSize(size);
|
|
13764
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
13765
|
+
}
|
|
13766
|
+
|
|
13767
|
+
/**
|
|
13768
|
+
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13769
|
+
* */
|
|
13770
|
+
Buffer.allocUnsafe = function (size) {
|
|
13771
|
+
return allocUnsafe(size)
|
|
13772
|
+
};
|
|
13773
|
+
/**
|
|
13774
|
+
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13775
|
+
*/
|
|
13776
|
+
Buffer.allocUnsafeSlow = function (size) {
|
|
13777
|
+
return allocUnsafe(size)
|
|
13778
|
+
};
|
|
13779
|
+
|
|
13780
|
+
function fromString (string, encoding) {
|
|
13781
|
+
if (typeof encoding !== 'string' || encoding === '') {
|
|
13782
|
+
encoding = 'utf8';
|
|
13783
|
+
}
|
|
13784
|
+
|
|
13785
|
+
if (!Buffer.isEncoding(encoding)) {
|
|
13786
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
13787
|
+
}
|
|
13788
|
+
|
|
13789
|
+
const length = byteLength(string, encoding) | 0;
|
|
13790
|
+
let buf = createBuffer(length);
|
|
13791
|
+
|
|
13792
|
+
const actual = buf.write(string, encoding);
|
|
13793
|
+
|
|
13794
|
+
if (actual !== length) {
|
|
13795
|
+
// Writing a hex string, for example, that contains invalid characters will
|
|
13796
|
+
// cause everything after the first invalid character to be ignored. (e.g.
|
|
13797
|
+
// 'abxxcd' will be treated as 'ab')
|
|
13798
|
+
buf = buf.slice(0, actual);
|
|
13799
|
+
}
|
|
13800
|
+
|
|
13801
|
+
return buf
|
|
13802
|
+
}
|
|
13803
|
+
|
|
13804
|
+
function fromArrayLike (array) {
|
|
13805
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
13806
|
+
const buf = createBuffer(length);
|
|
13807
|
+
for (let i = 0; i < length; i += 1) {
|
|
13808
|
+
buf[i] = array[i] & 255;
|
|
13809
|
+
}
|
|
13810
|
+
return buf
|
|
13811
|
+
}
|
|
13812
|
+
|
|
13813
|
+
function fromArrayView (arrayView) {
|
|
13814
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
13815
|
+
const copy = new Uint8Array(arrayView);
|
|
13816
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
13817
|
+
}
|
|
13818
|
+
return fromArrayLike(arrayView)
|
|
13819
|
+
}
|
|
13820
|
+
|
|
13821
|
+
function fromArrayBuffer (array, byteOffset, length) {
|
|
13822
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
13823
|
+
throw new RangeError('"offset" is outside of buffer bounds')
|
|
13824
|
+
}
|
|
13825
|
+
|
|
13826
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
13827
|
+
throw new RangeError('"length" is outside of buffer bounds')
|
|
13828
|
+
}
|
|
13829
|
+
|
|
13830
|
+
let buf;
|
|
13831
|
+
if (byteOffset === undefined && length === undefined) {
|
|
13832
|
+
buf = new Uint8Array(array);
|
|
13833
|
+
} else if (length === undefined) {
|
|
13834
|
+
buf = new Uint8Array(array, byteOffset);
|
|
13835
|
+
} else {
|
|
13836
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
13837
|
+
}
|
|
13838
|
+
|
|
13839
|
+
// Return an augmented `Uint8Array` instance
|
|
13840
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13841
|
+
|
|
13842
|
+
return buf
|
|
13843
|
+
}
|
|
13844
|
+
|
|
13845
|
+
function fromObject (obj) {
|
|
13846
|
+
if (Buffer.isBuffer(obj)) {
|
|
13847
|
+
const len = checked(obj.length) | 0;
|
|
13848
|
+
const buf = createBuffer(len);
|
|
13849
|
+
|
|
13850
|
+
if (buf.length === 0) {
|
|
13851
|
+
return buf
|
|
13852
|
+
}
|
|
13853
|
+
|
|
13854
|
+
obj.copy(buf, 0, 0, len);
|
|
13855
|
+
return buf
|
|
13856
|
+
}
|
|
13857
|
+
|
|
13858
|
+
if (obj.length !== undefined) {
|
|
13859
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
13860
|
+
return createBuffer(0)
|
|
13861
|
+
}
|
|
13862
|
+
return fromArrayLike(obj)
|
|
13863
|
+
}
|
|
13864
|
+
|
|
13865
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
13866
|
+
return fromArrayLike(obj.data)
|
|
13867
|
+
}
|
|
13868
|
+
}
|
|
13869
|
+
|
|
13870
|
+
function checked (length) {
|
|
13871
|
+
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
13872
|
+
// length is NaN (which is otherwise coerced to zero.)
|
|
13873
|
+
if (length >= K_MAX_LENGTH) {
|
|
13874
|
+
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
13875
|
+
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
13876
|
+
}
|
|
13877
|
+
return length | 0
|
|
13878
|
+
}
|
|
13879
|
+
|
|
13880
|
+
function SlowBuffer (length) {
|
|
13881
|
+
if (+length != length) { // eslint-disable-line eqeqeq
|
|
13882
|
+
length = 0;
|
|
13883
|
+
}
|
|
13884
|
+
return Buffer.alloc(+length)
|
|
13885
|
+
}
|
|
13886
|
+
|
|
13887
|
+
Buffer.isBuffer = function isBuffer (b) {
|
|
13888
|
+
return b != null && b._isBuffer === true &&
|
|
13889
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
13890
|
+
};
|
|
13891
|
+
|
|
13892
|
+
Buffer.compare = function compare (a, b) {
|
|
13893
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
13894
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
13895
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
13896
|
+
throw new TypeError(
|
|
13897
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
13898
|
+
)
|
|
13899
|
+
}
|
|
13900
|
+
|
|
13901
|
+
if (a === b) return 0
|
|
13902
|
+
|
|
13903
|
+
let x = a.length;
|
|
13904
|
+
let y = b.length;
|
|
13905
|
+
|
|
13906
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
13907
|
+
if (a[i] !== b[i]) {
|
|
13908
|
+
x = a[i];
|
|
13909
|
+
y = b[i];
|
|
13910
|
+
break
|
|
13911
|
+
}
|
|
13912
|
+
}
|
|
13913
|
+
|
|
13914
|
+
if (x < y) return -1
|
|
13915
|
+
if (y < x) return 1
|
|
13916
|
+
return 0
|
|
13917
|
+
};
|
|
13918
|
+
|
|
13919
|
+
Buffer.isEncoding = function isEncoding (encoding) {
|
|
13920
|
+
switch (String(encoding).toLowerCase()) {
|
|
13921
|
+
case 'hex':
|
|
13922
|
+
case 'utf8':
|
|
13923
|
+
case 'utf-8':
|
|
13924
|
+
case 'ascii':
|
|
13925
|
+
case 'latin1':
|
|
13926
|
+
case 'binary':
|
|
13927
|
+
case 'base64':
|
|
13928
|
+
case 'ucs2':
|
|
13929
|
+
case 'ucs-2':
|
|
13930
|
+
case 'utf16le':
|
|
13931
|
+
case 'utf-16le':
|
|
13932
|
+
return true
|
|
13933
|
+
default:
|
|
13934
|
+
return false
|
|
13935
|
+
}
|
|
13936
|
+
};
|
|
13937
|
+
|
|
13938
|
+
Buffer.concat = function concat (list, length) {
|
|
13939
|
+
if (!Array.isArray(list)) {
|
|
13940
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13941
|
+
}
|
|
13942
|
+
|
|
13943
|
+
if (list.length === 0) {
|
|
13944
|
+
return Buffer.alloc(0)
|
|
13945
|
+
}
|
|
13946
|
+
|
|
13947
|
+
let i;
|
|
13948
|
+
if (length === undefined) {
|
|
13949
|
+
length = 0;
|
|
13950
|
+
for (i = 0; i < list.length; ++i) {
|
|
13951
|
+
length += list[i].length;
|
|
13952
|
+
}
|
|
13953
|
+
}
|
|
13954
|
+
|
|
13955
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
13956
|
+
let pos = 0;
|
|
13957
|
+
for (i = 0; i < list.length; ++i) {
|
|
13958
|
+
let buf = list[i];
|
|
13959
|
+
if (isInstance(buf, Uint8Array)) {
|
|
13960
|
+
if (pos + buf.length > buffer.length) {
|
|
13961
|
+
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
|
|
13962
|
+
buf.copy(buffer, pos);
|
|
13963
|
+
} else {
|
|
13964
|
+
Uint8Array.prototype.set.call(
|
|
13965
|
+
buffer,
|
|
13966
|
+
buf,
|
|
13967
|
+
pos
|
|
13968
|
+
);
|
|
13969
|
+
}
|
|
13970
|
+
} else if (!Buffer.isBuffer(buf)) {
|
|
13971
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13972
|
+
} else {
|
|
13973
|
+
buf.copy(buffer, pos);
|
|
13974
|
+
}
|
|
13975
|
+
pos += buf.length;
|
|
13976
|
+
}
|
|
13977
|
+
return buffer
|
|
13978
|
+
};
|
|
13979
|
+
|
|
13980
|
+
function byteLength (string, encoding) {
|
|
13981
|
+
if (Buffer.isBuffer(string)) {
|
|
13982
|
+
return string.length
|
|
13983
|
+
}
|
|
13984
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
13985
|
+
return string.byteLength
|
|
13986
|
+
}
|
|
13987
|
+
if (typeof string !== 'string') {
|
|
13988
|
+
throw new TypeError(
|
|
13989
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
13990
|
+
'Received type ' + typeof string
|
|
13991
|
+
)
|
|
13992
|
+
}
|
|
13993
|
+
|
|
13994
|
+
const len = string.length;
|
|
13995
|
+
const mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
13996
|
+
if (!mustMatch && len === 0) return 0
|
|
13997
|
+
|
|
13998
|
+
// Use a for loop to avoid recursion
|
|
13999
|
+
let loweredCase = false;
|
|
14000
|
+
for (;;) {
|
|
14001
|
+
switch (encoding) {
|
|
14002
|
+
case 'ascii':
|
|
14003
|
+
case 'latin1':
|
|
14004
|
+
case 'binary':
|
|
14005
|
+
return len
|
|
14006
|
+
case 'utf8':
|
|
14007
|
+
case 'utf-8':
|
|
14008
|
+
return utf8ToBytes(string).length
|
|
14009
|
+
case 'ucs2':
|
|
14010
|
+
case 'ucs-2':
|
|
14011
|
+
case 'utf16le':
|
|
14012
|
+
case 'utf-16le':
|
|
14013
|
+
return len * 2
|
|
14014
|
+
case 'hex':
|
|
14015
|
+
return len >>> 1
|
|
14016
|
+
case 'base64':
|
|
14017
|
+
return base64ToBytes(string).length
|
|
14018
|
+
default:
|
|
14019
|
+
if (loweredCase) {
|
|
14020
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
14021
|
+
}
|
|
14022
|
+
encoding = ('' + encoding).toLowerCase();
|
|
14023
|
+
loweredCase = true;
|
|
14024
|
+
}
|
|
14025
|
+
}
|
|
14026
|
+
}
|
|
14027
|
+
Buffer.byteLength = byteLength;
|
|
14028
|
+
|
|
14029
|
+
function slowToString (encoding, start, end) {
|
|
14030
|
+
let loweredCase = false;
|
|
14031
|
+
|
|
14032
|
+
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
14033
|
+
// property of a typed array.
|
|
14034
|
+
|
|
14035
|
+
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
14036
|
+
// to their upper/lower bounds if the value passed is out of range.
|
|
14037
|
+
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
14038
|
+
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
14039
|
+
if (start === undefined || start < 0) {
|
|
14040
|
+
start = 0;
|
|
14041
|
+
}
|
|
14042
|
+
// Return early if start > this.length. Done here to prevent potential uint32
|
|
14043
|
+
// coercion fail below.
|
|
14044
|
+
if (start > this.length) {
|
|
14045
|
+
return ''
|
|
14046
|
+
}
|
|
14047
|
+
|
|
14048
|
+
if (end === undefined || end > this.length) {
|
|
14049
|
+
end = this.length;
|
|
14050
|
+
}
|
|
14051
|
+
|
|
14052
|
+
if (end <= 0) {
|
|
14053
|
+
return ''
|
|
14054
|
+
}
|
|
14055
|
+
|
|
14056
|
+
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
14057
|
+
end >>>= 0;
|
|
14058
|
+
start >>>= 0;
|
|
14059
|
+
|
|
14060
|
+
if (end <= start) {
|
|
14061
|
+
return ''
|
|
14062
|
+
}
|
|
14063
|
+
|
|
14064
|
+
if (!encoding) encoding = 'utf8';
|
|
14065
|
+
|
|
14066
|
+
while (true) {
|
|
14067
|
+
switch (encoding) {
|
|
14068
|
+
case 'hex':
|
|
14069
|
+
return hexSlice(this, start, end)
|
|
14070
|
+
|
|
14071
|
+
case 'utf8':
|
|
14072
|
+
case 'utf-8':
|
|
14073
|
+
return utf8Slice(this, start, end)
|
|
14074
|
+
|
|
14075
|
+
case 'ascii':
|
|
14076
|
+
return asciiSlice(this, start, end)
|
|
14077
|
+
|
|
14078
|
+
case 'latin1':
|
|
14079
|
+
case 'binary':
|
|
14080
|
+
return latin1Slice(this, start, end)
|
|
14081
|
+
|
|
14082
|
+
case 'base64':
|
|
14083
|
+
return base64Slice(this, start, end)
|
|
14084
|
+
|
|
14085
|
+
case 'ucs2':
|
|
14086
|
+
case 'ucs-2':
|
|
14087
|
+
case 'utf16le':
|
|
14088
|
+
case 'utf-16le':
|
|
14089
|
+
return utf16leSlice(this, start, end)
|
|
14090
|
+
|
|
14091
|
+
default:
|
|
14092
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
14093
|
+
encoding = (encoding + '').toLowerCase();
|
|
14094
|
+
loweredCase = true;
|
|
14095
|
+
}
|
|
14096
|
+
}
|
|
14097
|
+
}
|
|
14098
|
+
|
|
14099
|
+
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
14100
|
+
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
14101
|
+
// reliably in a browserify context because there could be multiple different
|
|
14102
|
+
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
14103
|
+
// instances that were created from another copy of the `buffer` package.
|
|
14104
|
+
// See: https://github.com/feross/buffer/issues/154
|
|
14105
|
+
Buffer.prototype._isBuffer = true;
|
|
14106
|
+
|
|
14107
|
+
function swap (b, n, m) {
|
|
14108
|
+
const i = b[n];
|
|
14109
|
+
b[n] = b[m];
|
|
14110
|
+
b[m] = i;
|
|
14111
|
+
}
|
|
14112
|
+
|
|
14113
|
+
Buffer.prototype.swap16 = function swap16 () {
|
|
14114
|
+
const len = this.length;
|
|
14115
|
+
if (len % 2 !== 0) {
|
|
14116
|
+
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
14117
|
+
}
|
|
14118
|
+
for (let i = 0; i < len; i += 2) {
|
|
14119
|
+
swap(this, i, i + 1);
|
|
14120
|
+
}
|
|
14121
|
+
return this
|
|
14122
|
+
};
|
|
14123
|
+
|
|
14124
|
+
Buffer.prototype.swap32 = function swap32 () {
|
|
14125
|
+
const len = this.length;
|
|
14126
|
+
if (len % 4 !== 0) {
|
|
14127
|
+
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
14128
|
+
}
|
|
14129
|
+
for (let i = 0; i < len; i += 4) {
|
|
14130
|
+
swap(this, i, i + 3);
|
|
14131
|
+
swap(this, i + 1, i + 2);
|
|
14132
|
+
}
|
|
14133
|
+
return this
|
|
14134
|
+
};
|
|
14135
|
+
|
|
14136
|
+
Buffer.prototype.swap64 = function swap64 () {
|
|
14137
|
+
const len = this.length;
|
|
14138
|
+
if (len % 8 !== 0) {
|
|
14139
|
+
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
14140
|
+
}
|
|
14141
|
+
for (let i = 0; i < len; i += 8) {
|
|
14142
|
+
swap(this, i, i + 7);
|
|
14143
|
+
swap(this, i + 1, i + 6);
|
|
14144
|
+
swap(this, i + 2, i + 5);
|
|
14145
|
+
swap(this, i + 3, i + 4);
|
|
14146
|
+
}
|
|
14147
|
+
return this
|
|
14148
|
+
};
|
|
14149
|
+
|
|
14150
|
+
Buffer.prototype.toString = function toString () {
|
|
14151
|
+
const length = this.length;
|
|
14152
|
+
if (length === 0) return ''
|
|
14153
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
14154
|
+
return slowToString.apply(this, arguments)
|
|
14155
|
+
};
|
|
14156
|
+
|
|
14157
|
+
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
14158
|
+
|
|
14159
|
+
Buffer.prototype.equals = function equals (b) {
|
|
14160
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
14161
|
+
if (this === b) return true
|
|
14162
|
+
return Buffer.compare(this, b) === 0
|
|
14163
|
+
};
|
|
14164
|
+
|
|
14165
|
+
Buffer.prototype.inspect = function inspect () {
|
|
14166
|
+
let str = '';
|
|
14167
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
14168
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
14169
|
+
if (this.length > max) str += ' ... ';
|
|
14170
|
+
return '<Buffer ' + str + '>'
|
|
14171
|
+
};
|
|
14172
|
+
if (customInspectSymbol) {
|
|
14173
|
+
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
14174
|
+
}
|
|
14175
|
+
|
|
14176
|
+
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
14177
|
+
if (isInstance(target, Uint8Array)) {
|
|
14178
|
+
target = Buffer.from(target, target.offset, target.byteLength);
|
|
14179
|
+
}
|
|
14180
|
+
if (!Buffer.isBuffer(target)) {
|
|
14181
|
+
throw new TypeError(
|
|
14182
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
14183
|
+
'Received type ' + (typeof target)
|
|
14184
|
+
)
|
|
14185
|
+
}
|
|
14186
|
+
|
|
14187
|
+
if (start === undefined) {
|
|
14188
|
+
start = 0;
|
|
14189
|
+
}
|
|
14190
|
+
if (end === undefined) {
|
|
14191
|
+
end = target ? target.length : 0;
|
|
14192
|
+
}
|
|
14193
|
+
if (thisStart === undefined) {
|
|
14194
|
+
thisStart = 0;
|
|
14195
|
+
}
|
|
14196
|
+
if (thisEnd === undefined) {
|
|
14197
|
+
thisEnd = this.length;
|
|
14198
|
+
}
|
|
14199
|
+
|
|
14200
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
14201
|
+
throw new RangeError('out of range index')
|
|
14202
|
+
}
|
|
14203
|
+
|
|
14204
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
14205
|
+
return 0
|
|
14206
|
+
}
|
|
14207
|
+
if (thisStart >= thisEnd) {
|
|
14208
|
+
return -1
|
|
14209
|
+
}
|
|
14210
|
+
if (start >= end) {
|
|
14211
|
+
return 1
|
|
14212
|
+
}
|
|
14213
|
+
|
|
14214
|
+
start >>>= 0;
|
|
14215
|
+
end >>>= 0;
|
|
14216
|
+
thisStart >>>= 0;
|
|
14217
|
+
thisEnd >>>= 0;
|
|
14218
|
+
|
|
14219
|
+
if (this === target) return 0
|
|
14220
|
+
|
|
14221
|
+
let x = thisEnd - thisStart;
|
|
14222
|
+
let y = end - start;
|
|
14223
|
+
const len = Math.min(x, y);
|
|
14224
|
+
|
|
14225
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
14226
|
+
const targetCopy = target.slice(start, end);
|
|
14227
|
+
|
|
14228
|
+
for (let i = 0; i < len; ++i) {
|
|
14229
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
14230
|
+
x = thisCopy[i];
|
|
14231
|
+
y = targetCopy[i];
|
|
14232
|
+
break
|
|
14233
|
+
}
|
|
14234
|
+
}
|
|
14235
|
+
|
|
14236
|
+
if (x < y) return -1
|
|
14237
|
+
if (y < x) return 1
|
|
14238
|
+
return 0
|
|
14239
|
+
};
|
|
14240
|
+
|
|
14241
|
+
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
14242
|
+
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
14243
|
+
//
|
|
14244
|
+
// Arguments:
|
|
14245
|
+
// - buffer - a Buffer to search
|
|
14246
|
+
// - val - a string, Buffer, or number
|
|
14247
|
+
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
14248
|
+
// - encoding - an optional encoding, relevant is val is a string
|
|
14249
|
+
// - dir - true for indexOf, false for lastIndexOf
|
|
14250
|
+
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
14251
|
+
// Empty buffer means no match
|
|
14252
|
+
if (buffer.length === 0) return -1
|
|
14253
|
+
|
|
14254
|
+
// Normalize byteOffset
|
|
14255
|
+
if (typeof byteOffset === 'string') {
|
|
14256
|
+
encoding = byteOffset;
|
|
14257
|
+
byteOffset = 0;
|
|
14258
|
+
} else if (byteOffset > 0x7fffffff) {
|
|
14259
|
+
byteOffset = 0x7fffffff;
|
|
14260
|
+
} else if (byteOffset < -2147483648) {
|
|
14261
|
+
byteOffset = -2147483648;
|
|
14262
|
+
}
|
|
14263
|
+
byteOffset = +byteOffset; // Coerce to Number.
|
|
14264
|
+
if (numberIsNaN(byteOffset)) {
|
|
14265
|
+
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
14266
|
+
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
14267
|
+
}
|
|
14268
|
+
|
|
14269
|
+
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
14270
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
14271
|
+
if (byteOffset >= buffer.length) {
|
|
14272
|
+
if (dir) return -1
|
|
14273
|
+
else byteOffset = buffer.length - 1;
|
|
14274
|
+
} else if (byteOffset < 0) {
|
|
14275
|
+
if (dir) byteOffset = 0;
|
|
14276
|
+
else return -1
|
|
14277
|
+
}
|
|
14278
|
+
|
|
14279
|
+
// Normalize val
|
|
14280
|
+
if (typeof val === 'string') {
|
|
14281
|
+
val = Buffer.from(val, encoding);
|
|
14282
|
+
}
|
|
14283
|
+
|
|
14284
|
+
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
14285
|
+
if (Buffer.isBuffer(val)) {
|
|
14286
|
+
// Special case: looking for empty string/buffer always fails
|
|
14287
|
+
if (val.length === 0) {
|
|
14288
|
+
return -1
|
|
14289
|
+
}
|
|
14290
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
14291
|
+
} else if (typeof val === 'number') {
|
|
14292
|
+
val = val & 0xFF; // Search for a byte value [0-255]
|
|
14293
|
+
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
14294
|
+
if (dir) {
|
|
14295
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
14296
|
+
} else {
|
|
14297
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
14298
|
+
}
|
|
14299
|
+
}
|
|
14300
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
14301
|
+
}
|
|
14302
|
+
|
|
14303
|
+
throw new TypeError('val must be string, number or Buffer')
|
|
14304
|
+
}
|
|
14305
|
+
|
|
14306
|
+
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
14307
|
+
let indexSize = 1;
|
|
14308
|
+
let arrLength = arr.length;
|
|
14309
|
+
let valLength = val.length;
|
|
14310
|
+
|
|
14311
|
+
if (encoding !== undefined) {
|
|
14312
|
+
encoding = String(encoding).toLowerCase();
|
|
14313
|
+
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
14314
|
+
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
14315
|
+
if (arr.length < 2 || val.length < 2) {
|
|
14316
|
+
return -1
|
|
14317
|
+
}
|
|
14318
|
+
indexSize = 2;
|
|
14319
|
+
arrLength /= 2;
|
|
14320
|
+
valLength /= 2;
|
|
14321
|
+
byteOffset /= 2;
|
|
14322
|
+
}
|
|
14323
|
+
}
|
|
14324
|
+
|
|
14325
|
+
function read (buf, i) {
|
|
14326
|
+
if (indexSize === 1) {
|
|
14327
|
+
return buf[i]
|
|
14328
|
+
} else {
|
|
14329
|
+
return buf.readUInt16BE(i * indexSize)
|
|
14330
|
+
}
|
|
14331
|
+
}
|
|
14332
|
+
|
|
14333
|
+
let i;
|
|
14334
|
+
if (dir) {
|
|
14335
|
+
let foundIndex = -1;
|
|
14336
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
14337
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
14338
|
+
if (foundIndex === -1) foundIndex = i;
|
|
14339
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
14340
|
+
} else {
|
|
14341
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
14342
|
+
foundIndex = -1;
|
|
14343
|
+
}
|
|
14344
|
+
}
|
|
14345
|
+
} else {
|
|
14346
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
14347
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
14348
|
+
let found = true;
|
|
14349
|
+
for (let j = 0; j < valLength; j++) {
|
|
14350
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
14351
|
+
found = false;
|
|
14352
|
+
break
|
|
14353
|
+
}
|
|
14354
|
+
}
|
|
14355
|
+
if (found) return i
|
|
14356
|
+
}
|
|
14357
|
+
}
|
|
14358
|
+
|
|
14359
|
+
return -1
|
|
14360
|
+
}
|
|
14361
|
+
|
|
14362
|
+
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
14363
|
+
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
14364
|
+
};
|
|
14365
|
+
|
|
14366
|
+
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
14367
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
14368
|
+
};
|
|
14369
|
+
|
|
14370
|
+
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
14371
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
14372
|
+
};
|
|
14373
|
+
|
|
14374
|
+
function hexWrite (buf, string, offset, length) {
|
|
14375
|
+
offset = Number(offset) || 0;
|
|
14376
|
+
const remaining = buf.length - offset;
|
|
14377
|
+
if (!length) {
|
|
14378
|
+
length = remaining;
|
|
14379
|
+
} else {
|
|
14380
|
+
length = Number(length);
|
|
14381
|
+
if (length > remaining) {
|
|
14382
|
+
length = remaining;
|
|
14383
|
+
}
|
|
14384
|
+
}
|
|
14385
|
+
|
|
14386
|
+
const strLen = string.length;
|
|
14387
|
+
|
|
14388
|
+
if (length > strLen / 2) {
|
|
14389
|
+
length = strLen / 2;
|
|
14390
|
+
}
|
|
14391
|
+
let i;
|
|
14392
|
+
for (i = 0; i < length; ++i) {
|
|
14393
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
14394
|
+
if (numberIsNaN(parsed)) return i
|
|
14395
|
+
buf[offset + i] = parsed;
|
|
14396
|
+
}
|
|
14397
|
+
return i
|
|
14398
|
+
}
|
|
14399
|
+
|
|
14400
|
+
function utf8Write (buf, string, offset, length) {
|
|
14401
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
14402
|
+
}
|
|
14403
|
+
|
|
14404
|
+
function asciiWrite (buf, string, offset, length) {
|
|
14405
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
14406
|
+
}
|
|
14407
|
+
|
|
14408
|
+
function base64Write (buf, string, offset, length) {
|
|
14409
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
14410
|
+
}
|
|
14411
|
+
|
|
14412
|
+
function ucs2Write (buf, string, offset, length) {
|
|
14413
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
14414
|
+
}
|
|
14415
|
+
|
|
14416
|
+
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
14417
|
+
// Buffer#write(string)
|
|
14418
|
+
if (offset === undefined) {
|
|
14419
|
+
encoding = 'utf8';
|
|
14420
|
+
length = this.length;
|
|
14421
|
+
offset = 0;
|
|
14422
|
+
// Buffer#write(string, encoding)
|
|
14423
|
+
} else if (length === undefined && typeof offset === 'string') {
|
|
14424
|
+
encoding = offset;
|
|
14425
|
+
length = this.length;
|
|
14426
|
+
offset = 0;
|
|
14427
|
+
// Buffer#write(string, offset[, length][, encoding])
|
|
14428
|
+
} else if (isFinite(offset)) {
|
|
14429
|
+
offset = offset >>> 0;
|
|
14430
|
+
if (isFinite(length)) {
|
|
14431
|
+
length = length >>> 0;
|
|
14432
|
+
if (encoding === undefined) encoding = 'utf8';
|
|
14433
|
+
} else {
|
|
14434
|
+
encoding = length;
|
|
14435
|
+
length = undefined;
|
|
14436
|
+
}
|
|
14437
|
+
} else {
|
|
14438
|
+
throw new Error(
|
|
14439
|
+
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
14440
|
+
)
|
|
14441
|
+
}
|
|
14442
|
+
|
|
14443
|
+
const remaining = this.length - offset;
|
|
14444
|
+
if (length === undefined || length > remaining) length = remaining;
|
|
14445
|
+
|
|
14446
|
+
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
14447
|
+
throw new RangeError('Attempt to write outside buffer bounds')
|
|
14448
|
+
}
|
|
14449
|
+
|
|
14450
|
+
if (!encoding) encoding = 'utf8';
|
|
14451
|
+
|
|
14452
|
+
let loweredCase = false;
|
|
14453
|
+
for (;;) {
|
|
14454
|
+
switch (encoding) {
|
|
14455
|
+
case 'hex':
|
|
14456
|
+
return hexWrite(this, string, offset, length)
|
|
14457
|
+
|
|
14458
|
+
case 'utf8':
|
|
14459
|
+
case 'utf-8':
|
|
14460
|
+
return utf8Write(this, string, offset, length)
|
|
14461
|
+
|
|
14462
|
+
case 'ascii':
|
|
14463
|
+
case 'latin1':
|
|
14464
|
+
case 'binary':
|
|
14465
|
+
return asciiWrite(this, string, offset, length)
|
|
14466
|
+
|
|
14467
|
+
case 'base64':
|
|
14468
|
+
// Warning: maxLength not taken into account in base64Write
|
|
14469
|
+
return base64Write(this, string, offset, length)
|
|
14470
|
+
|
|
14471
|
+
case 'ucs2':
|
|
14472
|
+
case 'ucs-2':
|
|
14473
|
+
case 'utf16le':
|
|
14474
|
+
case 'utf-16le':
|
|
14475
|
+
return ucs2Write(this, string, offset, length)
|
|
14476
|
+
|
|
14477
|
+
default:
|
|
14478
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
14479
|
+
encoding = ('' + encoding).toLowerCase();
|
|
14480
|
+
loweredCase = true;
|
|
14481
|
+
}
|
|
14482
|
+
}
|
|
14483
|
+
};
|
|
14484
|
+
|
|
14485
|
+
Buffer.prototype.toJSON = function toJSON () {
|
|
14486
|
+
return {
|
|
14487
|
+
type: 'Buffer',
|
|
14488
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
14489
|
+
}
|
|
14490
|
+
};
|
|
14491
|
+
|
|
14492
|
+
function base64Slice (buf, start, end) {
|
|
14493
|
+
if (start === 0 && end === buf.length) {
|
|
14494
|
+
return base64.fromByteArray(buf)
|
|
14495
|
+
} else {
|
|
14496
|
+
return base64.fromByteArray(buf.slice(start, end))
|
|
14497
|
+
}
|
|
14498
|
+
}
|
|
14499
|
+
|
|
14500
|
+
function utf8Slice (buf, start, end) {
|
|
14501
|
+
end = Math.min(buf.length, end);
|
|
14502
|
+
const res = [];
|
|
14503
|
+
|
|
14504
|
+
let i = start;
|
|
14505
|
+
while (i < end) {
|
|
14506
|
+
const firstByte = buf[i];
|
|
14507
|
+
let codePoint = null;
|
|
14508
|
+
let bytesPerSequence = (firstByte > 0xEF)
|
|
14509
|
+
? 4
|
|
14510
|
+
: (firstByte > 0xDF)
|
|
14511
|
+
? 3
|
|
14512
|
+
: (firstByte > 0xBF)
|
|
14513
|
+
? 2
|
|
14514
|
+
: 1;
|
|
14515
|
+
|
|
14516
|
+
if (i + bytesPerSequence <= end) {
|
|
14517
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
14518
|
+
|
|
14519
|
+
switch (bytesPerSequence) {
|
|
14520
|
+
case 1:
|
|
14521
|
+
if (firstByte < 0x80) {
|
|
14522
|
+
codePoint = firstByte;
|
|
14523
|
+
}
|
|
14524
|
+
break
|
|
14525
|
+
case 2:
|
|
14526
|
+
secondByte = buf[i + 1];
|
|
14527
|
+
if ((secondByte & 0xC0) === 0x80) {
|
|
14528
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
14529
|
+
if (tempCodePoint > 0x7F) {
|
|
14530
|
+
codePoint = tempCodePoint;
|
|
14531
|
+
}
|
|
14532
|
+
}
|
|
14533
|
+
break
|
|
14534
|
+
case 3:
|
|
14535
|
+
secondByte = buf[i + 1];
|
|
14536
|
+
thirdByte = buf[i + 2];
|
|
14537
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
14538
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
14539
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
14540
|
+
codePoint = tempCodePoint;
|
|
14541
|
+
}
|
|
14542
|
+
}
|
|
14543
|
+
break
|
|
14544
|
+
case 4:
|
|
14545
|
+
secondByte = buf[i + 1];
|
|
14546
|
+
thirdByte = buf[i + 2];
|
|
14547
|
+
fourthByte = buf[i + 3];
|
|
14548
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
14549
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
14550
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
14551
|
+
codePoint = tempCodePoint;
|
|
14552
|
+
}
|
|
14553
|
+
}
|
|
14554
|
+
}
|
|
14555
|
+
}
|
|
14556
|
+
|
|
14557
|
+
if (codePoint === null) {
|
|
14558
|
+
// we did not generate a valid codePoint so insert a
|
|
14559
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
|
14560
|
+
codePoint = 0xFFFD;
|
|
14561
|
+
bytesPerSequence = 1;
|
|
14562
|
+
} else if (codePoint > 0xFFFF) {
|
|
14563
|
+
// encode to utf16 (surrogate pair dance)
|
|
14564
|
+
codePoint -= 0x10000;
|
|
14565
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
14566
|
+
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
14567
|
+
}
|
|
14568
|
+
|
|
14569
|
+
res.push(codePoint);
|
|
14570
|
+
i += bytesPerSequence;
|
|
14571
|
+
}
|
|
14572
|
+
|
|
14573
|
+
return decodeCodePointsArray(res)
|
|
14574
|
+
}
|
|
14575
|
+
|
|
14576
|
+
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
14577
|
+
// the lowest limit is Chrome, with 0x10000 args.
|
|
14578
|
+
// We go 1 magnitude less, for safety
|
|
14579
|
+
const MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
14580
|
+
|
|
14581
|
+
function decodeCodePointsArray (codePoints) {
|
|
14582
|
+
const len = codePoints.length;
|
|
14583
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
14584
|
+
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
14585
|
+
}
|
|
14586
|
+
|
|
14587
|
+
// Decode in chunks to avoid "call stack size exceeded".
|
|
14588
|
+
let res = '';
|
|
14589
|
+
let i = 0;
|
|
14590
|
+
while (i < len) {
|
|
14591
|
+
res += String.fromCharCode.apply(
|
|
14592
|
+
String,
|
|
14593
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
14594
|
+
);
|
|
14595
|
+
}
|
|
14596
|
+
return res
|
|
14597
|
+
}
|
|
14598
|
+
|
|
14599
|
+
function asciiSlice (buf, start, end) {
|
|
14600
|
+
let ret = '';
|
|
14601
|
+
end = Math.min(buf.length, end);
|
|
14602
|
+
|
|
14603
|
+
for (let i = start; i < end; ++i) {
|
|
14604
|
+
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
14605
|
+
}
|
|
14606
|
+
return ret
|
|
14607
|
+
}
|
|
14608
|
+
|
|
14609
|
+
function latin1Slice (buf, start, end) {
|
|
14610
|
+
let ret = '';
|
|
14611
|
+
end = Math.min(buf.length, end);
|
|
14612
|
+
|
|
14613
|
+
for (let i = start; i < end; ++i) {
|
|
14614
|
+
ret += String.fromCharCode(buf[i]);
|
|
14615
|
+
}
|
|
14616
|
+
return ret
|
|
14617
|
+
}
|
|
14618
|
+
|
|
14619
|
+
function hexSlice (buf, start, end) {
|
|
14620
|
+
const len = buf.length;
|
|
14621
|
+
|
|
14622
|
+
if (!start || start < 0) start = 0;
|
|
14623
|
+
if (!end || end < 0 || end > len) end = len;
|
|
14624
|
+
|
|
14625
|
+
let out = '';
|
|
14626
|
+
for (let i = start; i < end; ++i) {
|
|
14627
|
+
out += hexSliceLookupTable[buf[i]];
|
|
14628
|
+
}
|
|
14629
|
+
return out
|
|
14630
|
+
}
|
|
14631
|
+
|
|
14632
|
+
function utf16leSlice (buf, start, end) {
|
|
14633
|
+
const bytes = buf.slice(start, end);
|
|
14634
|
+
let res = '';
|
|
14635
|
+
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
14636
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
14637
|
+
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
14638
|
+
}
|
|
14639
|
+
return res
|
|
14640
|
+
}
|
|
14641
|
+
|
|
14642
|
+
Buffer.prototype.slice = function slice (start, end) {
|
|
14643
|
+
const len = this.length;
|
|
14644
|
+
start = ~~start;
|
|
14645
|
+
end = end === undefined ? len : ~~end;
|
|
14646
|
+
|
|
14647
|
+
if (start < 0) {
|
|
14648
|
+
start += len;
|
|
14649
|
+
if (start < 0) start = 0;
|
|
14650
|
+
} else if (start > len) {
|
|
14651
|
+
start = len;
|
|
14652
|
+
}
|
|
14653
|
+
|
|
14654
|
+
if (end < 0) {
|
|
14655
|
+
end += len;
|
|
14656
|
+
if (end < 0) end = 0;
|
|
14657
|
+
} else if (end > len) {
|
|
14658
|
+
end = len;
|
|
14659
|
+
}
|
|
14660
|
+
|
|
14661
|
+
if (end < start) end = start;
|
|
14662
|
+
|
|
14663
|
+
const newBuf = this.subarray(start, end);
|
|
14664
|
+
// Return an augmented `Uint8Array` instance
|
|
14665
|
+
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
14666
|
+
|
|
14667
|
+
return newBuf
|
|
14668
|
+
};
|
|
14669
|
+
|
|
14670
|
+
/*
|
|
14671
|
+
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
14672
|
+
*/
|
|
14673
|
+
function checkOffset (offset, ext, length) {
|
|
14674
|
+
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
14675
|
+
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
14676
|
+
}
|
|
14677
|
+
|
|
14678
|
+
Buffer.prototype.readUintLE =
|
|
14679
|
+
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
14680
|
+
offset = offset >>> 0;
|
|
14681
|
+
byteLength = byteLength >>> 0;
|
|
14682
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14683
|
+
|
|
14684
|
+
let val = this[offset];
|
|
14685
|
+
let mul = 1;
|
|
14686
|
+
let i = 0;
|
|
14687
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14688
|
+
val += this[offset + i] * mul;
|
|
14689
|
+
}
|
|
14690
|
+
|
|
14691
|
+
return val
|
|
14692
|
+
};
|
|
14693
|
+
|
|
14694
|
+
Buffer.prototype.readUintBE =
|
|
14695
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
14696
|
+
offset = offset >>> 0;
|
|
14697
|
+
byteLength = byteLength >>> 0;
|
|
14698
|
+
if (!noAssert) {
|
|
14699
|
+
checkOffset(offset, byteLength, this.length);
|
|
14700
|
+
}
|
|
14701
|
+
|
|
14702
|
+
let val = this[offset + --byteLength];
|
|
14703
|
+
let mul = 1;
|
|
14704
|
+
while (byteLength > 0 && (mul *= 0x100)) {
|
|
14705
|
+
val += this[offset + --byteLength] * mul;
|
|
14706
|
+
}
|
|
14707
|
+
|
|
14708
|
+
return val
|
|
14709
|
+
};
|
|
14710
|
+
|
|
14711
|
+
Buffer.prototype.readUint8 =
|
|
14712
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
14713
|
+
offset = offset >>> 0;
|
|
14714
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14715
|
+
return this[offset]
|
|
14716
|
+
};
|
|
14717
|
+
|
|
14718
|
+
Buffer.prototype.readUint16LE =
|
|
14719
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
14720
|
+
offset = offset >>> 0;
|
|
14721
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14722
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
14723
|
+
};
|
|
14724
|
+
|
|
14725
|
+
Buffer.prototype.readUint16BE =
|
|
14726
|
+
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
14727
|
+
offset = offset >>> 0;
|
|
14728
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14729
|
+
return (this[offset] << 8) | this[offset + 1]
|
|
14730
|
+
};
|
|
14731
|
+
|
|
14732
|
+
Buffer.prototype.readUint32LE =
|
|
14733
|
+
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
14734
|
+
offset = offset >>> 0;
|
|
14735
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14736
|
+
|
|
14737
|
+
return ((this[offset]) |
|
|
14738
|
+
(this[offset + 1] << 8) |
|
|
14739
|
+
(this[offset + 2] << 16)) +
|
|
14740
|
+
(this[offset + 3] * 0x1000000)
|
|
14741
|
+
};
|
|
14742
|
+
|
|
14743
|
+
Buffer.prototype.readUint32BE =
|
|
14744
|
+
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
14745
|
+
offset = offset >>> 0;
|
|
14746
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14747
|
+
|
|
14748
|
+
return (this[offset] * 0x1000000) +
|
|
14749
|
+
((this[offset + 1] << 16) |
|
|
14750
|
+
(this[offset + 2] << 8) |
|
|
14751
|
+
this[offset + 3])
|
|
14752
|
+
};
|
|
14753
|
+
|
|
14754
|
+
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
|
14755
|
+
offset = offset >>> 0;
|
|
14756
|
+
validateNumber(offset, 'offset');
|
|
14757
|
+
const first = this[offset];
|
|
14758
|
+
const last = this[offset + 7];
|
|
14759
|
+
if (first === undefined || last === undefined) {
|
|
14760
|
+
boundsError(offset, this.length - 8);
|
|
14761
|
+
}
|
|
14762
|
+
|
|
14763
|
+
const lo = first +
|
|
14764
|
+
this[++offset] * 2 ** 8 +
|
|
14765
|
+
this[++offset] * 2 ** 16 +
|
|
14766
|
+
this[++offset] * 2 ** 24;
|
|
14767
|
+
|
|
14768
|
+
const hi = this[++offset] +
|
|
14769
|
+
this[++offset] * 2 ** 8 +
|
|
14770
|
+
this[++offset] * 2 ** 16 +
|
|
14771
|
+
last * 2 ** 24;
|
|
14772
|
+
|
|
14773
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
|
14774
|
+
});
|
|
14775
|
+
|
|
14776
|
+
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
|
14777
|
+
offset = offset >>> 0;
|
|
14778
|
+
validateNumber(offset, 'offset');
|
|
14779
|
+
const first = this[offset];
|
|
14780
|
+
const last = this[offset + 7];
|
|
14781
|
+
if (first === undefined || last === undefined) {
|
|
14782
|
+
boundsError(offset, this.length - 8);
|
|
14783
|
+
}
|
|
14784
|
+
|
|
14785
|
+
const hi = first * 2 ** 24 +
|
|
14786
|
+
this[++offset] * 2 ** 16 +
|
|
14787
|
+
this[++offset] * 2 ** 8 +
|
|
14788
|
+
this[++offset];
|
|
14789
|
+
|
|
14790
|
+
const lo = this[++offset] * 2 ** 24 +
|
|
14791
|
+
this[++offset] * 2 ** 16 +
|
|
14792
|
+
this[++offset] * 2 ** 8 +
|
|
14793
|
+
last;
|
|
14794
|
+
|
|
14795
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
14796
|
+
});
|
|
14797
|
+
|
|
14798
|
+
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
14799
|
+
offset = offset >>> 0;
|
|
14800
|
+
byteLength = byteLength >>> 0;
|
|
14801
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14802
|
+
|
|
14803
|
+
let val = this[offset];
|
|
14804
|
+
let mul = 1;
|
|
14805
|
+
let i = 0;
|
|
14806
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14807
|
+
val += this[offset + i] * mul;
|
|
14808
|
+
}
|
|
14809
|
+
mul *= 0x80;
|
|
14810
|
+
|
|
14811
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14812
|
+
|
|
14813
|
+
return val
|
|
14814
|
+
};
|
|
14815
|
+
|
|
14816
|
+
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
14817
|
+
offset = offset >>> 0;
|
|
14818
|
+
byteLength = byteLength >>> 0;
|
|
14819
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14820
|
+
|
|
14821
|
+
let i = byteLength;
|
|
14822
|
+
let mul = 1;
|
|
14823
|
+
let val = this[offset + --i];
|
|
14824
|
+
while (i > 0 && (mul *= 0x100)) {
|
|
14825
|
+
val += this[offset + --i] * mul;
|
|
14826
|
+
}
|
|
14827
|
+
mul *= 0x80;
|
|
14828
|
+
|
|
14829
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14830
|
+
|
|
14831
|
+
return val
|
|
14832
|
+
};
|
|
14833
|
+
|
|
14834
|
+
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
14835
|
+
offset = offset >>> 0;
|
|
14836
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14837
|
+
if (!(this[offset] & 0x80)) return (this[offset])
|
|
14838
|
+
return ((0xff - this[offset] + 1) * -1)
|
|
14839
|
+
};
|
|
14840
|
+
|
|
14841
|
+
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
14842
|
+
offset = offset >>> 0;
|
|
14843
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14844
|
+
const val = this[offset] | (this[offset + 1] << 8);
|
|
14845
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14846
|
+
};
|
|
14847
|
+
|
|
14848
|
+
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
14849
|
+
offset = offset >>> 0;
|
|
14850
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14851
|
+
const val = this[offset + 1] | (this[offset] << 8);
|
|
14852
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14853
|
+
};
|
|
14854
|
+
|
|
14855
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
14856
|
+
offset = offset >>> 0;
|
|
14857
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14858
|
+
|
|
14859
|
+
return (this[offset]) |
|
|
14860
|
+
(this[offset + 1] << 8) |
|
|
14861
|
+
(this[offset + 2] << 16) |
|
|
14862
|
+
(this[offset + 3] << 24)
|
|
14863
|
+
};
|
|
14864
|
+
|
|
14865
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
14866
|
+
offset = offset >>> 0;
|
|
14867
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14868
|
+
|
|
14869
|
+
return (this[offset] << 24) |
|
|
14870
|
+
(this[offset + 1] << 16) |
|
|
14871
|
+
(this[offset + 2] << 8) |
|
|
14872
|
+
(this[offset + 3])
|
|
14873
|
+
};
|
|
14874
|
+
|
|
14875
|
+
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
|
|
14876
|
+
offset = offset >>> 0;
|
|
14877
|
+
validateNumber(offset, 'offset');
|
|
14878
|
+
const first = this[offset];
|
|
14879
|
+
const last = this[offset + 7];
|
|
14880
|
+
if (first === undefined || last === undefined) {
|
|
14881
|
+
boundsError(offset, this.length - 8);
|
|
14882
|
+
}
|
|
14883
|
+
|
|
14884
|
+
const val = this[offset + 4] +
|
|
14885
|
+
this[offset + 5] * 2 ** 8 +
|
|
14886
|
+
this[offset + 6] * 2 ** 16 +
|
|
14887
|
+
(last << 24); // Overflow
|
|
14888
|
+
|
|
14889
|
+
return (BigInt(val) << BigInt(32)) +
|
|
14890
|
+
BigInt(first +
|
|
14891
|
+
this[++offset] * 2 ** 8 +
|
|
14892
|
+
this[++offset] * 2 ** 16 +
|
|
14893
|
+
this[++offset] * 2 ** 24)
|
|
14894
|
+
});
|
|
14895
|
+
|
|
14896
|
+
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
|
14897
|
+
offset = offset >>> 0;
|
|
14898
|
+
validateNumber(offset, 'offset');
|
|
14899
|
+
const first = this[offset];
|
|
14900
|
+
const last = this[offset + 7];
|
|
14901
|
+
if (first === undefined || last === undefined) {
|
|
14902
|
+
boundsError(offset, this.length - 8);
|
|
14903
|
+
}
|
|
14904
|
+
|
|
14905
|
+
const val = (first << 24) + // Overflow
|
|
14906
|
+
this[++offset] * 2 ** 16 +
|
|
14907
|
+
this[++offset] * 2 ** 8 +
|
|
14908
|
+
this[++offset];
|
|
14909
|
+
|
|
14910
|
+
return (BigInt(val) << BigInt(32)) +
|
|
14911
|
+
BigInt(this[++offset] * 2 ** 24 +
|
|
14912
|
+
this[++offset] * 2 ** 16 +
|
|
14913
|
+
this[++offset] * 2 ** 8 +
|
|
14914
|
+
last)
|
|
14915
|
+
});
|
|
14916
|
+
|
|
14917
|
+
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
14918
|
+
offset = offset >>> 0;
|
|
14919
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14920
|
+
return ieee754.read(this, offset, true, 23, 4)
|
|
14921
|
+
};
|
|
14922
|
+
|
|
14923
|
+
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
14924
|
+
offset = offset >>> 0;
|
|
14925
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14926
|
+
return ieee754.read(this, offset, false, 23, 4)
|
|
14927
|
+
};
|
|
14928
|
+
|
|
14929
|
+
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
14930
|
+
offset = offset >>> 0;
|
|
14931
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14932
|
+
return ieee754.read(this, offset, true, 52, 8)
|
|
14933
|
+
};
|
|
14934
|
+
|
|
14935
|
+
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
14936
|
+
offset = offset >>> 0;
|
|
14937
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14938
|
+
return ieee754.read(this, offset, false, 52, 8)
|
|
14939
|
+
};
|
|
14940
|
+
|
|
14941
|
+
function checkInt (buf, value, offset, ext, max, min) {
|
|
14942
|
+
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
14943
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
14944
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
14945
|
+
}
|
|
14946
|
+
|
|
14947
|
+
Buffer.prototype.writeUintLE =
|
|
14948
|
+
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
14949
|
+
value = +value;
|
|
14950
|
+
offset = offset >>> 0;
|
|
14951
|
+
byteLength = byteLength >>> 0;
|
|
14952
|
+
if (!noAssert) {
|
|
14953
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14954
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14955
|
+
}
|
|
14956
|
+
|
|
14957
|
+
let mul = 1;
|
|
14958
|
+
let i = 0;
|
|
14959
|
+
this[offset] = value & 0xFF;
|
|
14960
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14961
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
14962
|
+
}
|
|
14963
|
+
|
|
14964
|
+
return offset + byteLength
|
|
14965
|
+
};
|
|
14966
|
+
|
|
14967
|
+
Buffer.prototype.writeUintBE =
|
|
14968
|
+
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
14969
|
+
value = +value;
|
|
14970
|
+
offset = offset >>> 0;
|
|
14971
|
+
byteLength = byteLength >>> 0;
|
|
14972
|
+
if (!noAssert) {
|
|
14973
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14974
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14975
|
+
}
|
|
14976
|
+
|
|
14977
|
+
let i = byteLength - 1;
|
|
14978
|
+
let mul = 1;
|
|
14979
|
+
this[offset + i] = value & 0xFF;
|
|
14980
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
14981
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
14982
|
+
}
|
|
14983
|
+
|
|
14984
|
+
return offset + byteLength
|
|
14985
|
+
};
|
|
14986
|
+
|
|
14987
|
+
Buffer.prototype.writeUint8 =
|
|
14988
|
+
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
14989
|
+
value = +value;
|
|
14990
|
+
offset = offset >>> 0;
|
|
14991
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
14992
|
+
this[offset] = (value & 0xff);
|
|
14993
|
+
return offset + 1
|
|
14994
|
+
};
|
|
14995
|
+
|
|
14996
|
+
Buffer.prototype.writeUint16LE =
|
|
14997
|
+
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
14998
|
+
value = +value;
|
|
14999
|
+
offset = offset >>> 0;
|
|
15000
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
15001
|
+
this[offset] = (value & 0xff);
|
|
15002
|
+
this[offset + 1] = (value >>> 8);
|
|
15003
|
+
return offset + 2
|
|
15004
|
+
};
|
|
15005
|
+
|
|
15006
|
+
Buffer.prototype.writeUint16BE =
|
|
15007
|
+
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
15008
|
+
value = +value;
|
|
15009
|
+
offset = offset >>> 0;
|
|
15010
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
15011
|
+
this[offset] = (value >>> 8);
|
|
15012
|
+
this[offset + 1] = (value & 0xff);
|
|
15013
|
+
return offset + 2
|
|
15014
|
+
};
|
|
15015
|
+
|
|
15016
|
+
Buffer.prototype.writeUint32LE =
|
|
15017
|
+
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
15018
|
+
value = +value;
|
|
15019
|
+
offset = offset >>> 0;
|
|
15020
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
15021
|
+
this[offset + 3] = (value >>> 24);
|
|
15022
|
+
this[offset + 2] = (value >>> 16);
|
|
15023
|
+
this[offset + 1] = (value >>> 8);
|
|
15024
|
+
this[offset] = (value & 0xff);
|
|
15025
|
+
return offset + 4
|
|
15026
|
+
};
|
|
15027
|
+
|
|
15028
|
+
Buffer.prototype.writeUint32BE =
|
|
15029
|
+
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
15030
|
+
value = +value;
|
|
15031
|
+
offset = offset >>> 0;
|
|
15032
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
15033
|
+
this[offset] = (value >>> 24);
|
|
15034
|
+
this[offset + 1] = (value >>> 16);
|
|
15035
|
+
this[offset + 2] = (value >>> 8);
|
|
15036
|
+
this[offset + 3] = (value & 0xff);
|
|
15037
|
+
return offset + 4
|
|
15038
|
+
};
|
|
15039
|
+
|
|
15040
|
+
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
|
15041
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
15042
|
+
|
|
15043
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
15044
|
+
buf[offset++] = lo;
|
|
15045
|
+
lo = lo >> 8;
|
|
15046
|
+
buf[offset++] = lo;
|
|
15047
|
+
lo = lo >> 8;
|
|
15048
|
+
buf[offset++] = lo;
|
|
15049
|
+
lo = lo >> 8;
|
|
15050
|
+
buf[offset++] = lo;
|
|
15051
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
15052
|
+
buf[offset++] = hi;
|
|
15053
|
+
hi = hi >> 8;
|
|
15054
|
+
buf[offset++] = hi;
|
|
15055
|
+
hi = hi >> 8;
|
|
15056
|
+
buf[offset++] = hi;
|
|
15057
|
+
hi = hi >> 8;
|
|
15058
|
+
buf[offset++] = hi;
|
|
15059
|
+
return offset
|
|
15060
|
+
}
|
|
15061
|
+
|
|
15062
|
+
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
|
15063
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
15064
|
+
|
|
15065
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
15066
|
+
buf[offset + 7] = lo;
|
|
15067
|
+
lo = lo >> 8;
|
|
15068
|
+
buf[offset + 6] = lo;
|
|
15069
|
+
lo = lo >> 8;
|
|
15070
|
+
buf[offset + 5] = lo;
|
|
15071
|
+
lo = lo >> 8;
|
|
15072
|
+
buf[offset + 4] = lo;
|
|
15073
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
15074
|
+
buf[offset + 3] = hi;
|
|
15075
|
+
hi = hi >> 8;
|
|
15076
|
+
buf[offset + 2] = hi;
|
|
15077
|
+
hi = hi >> 8;
|
|
15078
|
+
buf[offset + 1] = hi;
|
|
15079
|
+
hi = hi >> 8;
|
|
15080
|
+
buf[offset] = hi;
|
|
15081
|
+
return offset + 8
|
|
15082
|
+
}
|
|
15083
|
+
|
|
15084
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
15085
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
15086
|
+
});
|
|
15087
|
+
|
|
15088
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
15089
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
15090
|
+
});
|
|
15091
|
+
|
|
15092
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
15093
|
+
value = +value;
|
|
15094
|
+
offset = offset >>> 0;
|
|
15095
|
+
if (!noAssert) {
|
|
15096
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
15097
|
+
|
|
15098
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
15099
|
+
}
|
|
15100
|
+
|
|
15101
|
+
let i = 0;
|
|
15102
|
+
let mul = 1;
|
|
15103
|
+
let sub = 0;
|
|
15104
|
+
this[offset] = value & 0xFF;
|
|
15105
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
15106
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
15107
|
+
sub = 1;
|
|
15108
|
+
}
|
|
15109
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
15110
|
+
}
|
|
15111
|
+
|
|
15112
|
+
return offset + byteLength
|
|
15113
|
+
};
|
|
15114
|
+
|
|
15115
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
15116
|
+
value = +value;
|
|
15117
|
+
offset = offset >>> 0;
|
|
15118
|
+
if (!noAssert) {
|
|
15119
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
15120
|
+
|
|
15121
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
15122
|
+
}
|
|
15123
|
+
|
|
15124
|
+
let i = byteLength - 1;
|
|
15125
|
+
let mul = 1;
|
|
15126
|
+
let sub = 0;
|
|
15127
|
+
this[offset + i] = value & 0xFF;
|
|
15128
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
15129
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
15130
|
+
sub = 1;
|
|
15131
|
+
}
|
|
15132
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
15133
|
+
}
|
|
15134
|
+
|
|
15135
|
+
return offset + byteLength
|
|
15136
|
+
};
|
|
15137
|
+
|
|
15138
|
+
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
15139
|
+
value = +value;
|
|
15140
|
+
offset = offset >>> 0;
|
|
15141
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
|
|
15142
|
+
if (value < 0) value = 0xff + value + 1;
|
|
15143
|
+
this[offset] = (value & 0xff);
|
|
15144
|
+
return offset + 1
|
|
15145
|
+
};
|
|
15146
|
+
|
|
15147
|
+
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
15148
|
+
value = +value;
|
|
15149
|
+
offset = offset >>> 0;
|
|
15150
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
15151
|
+
this[offset] = (value & 0xff);
|
|
15152
|
+
this[offset + 1] = (value >>> 8);
|
|
15153
|
+
return offset + 2
|
|
15154
|
+
};
|
|
15155
|
+
|
|
15156
|
+
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
15157
|
+
value = +value;
|
|
15158
|
+
offset = offset >>> 0;
|
|
15159
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
15160
|
+
this[offset] = (value >>> 8);
|
|
15161
|
+
this[offset + 1] = (value & 0xff);
|
|
15162
|
+
return offset + 2
|
|
15163
|
+
};
|
|
15164
|
+
|
|
15165
|
+
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
15166
|
+
value = +value;
|
|
15167
|
+
offset = offset >>> 0;
|
|
15168
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
15169
|
+
this[offset] = (value & 0xff);
|
|
15170
|
+
this[offset + 1] = (value >>> 8);
|
|
15171
|
+
this[offset + 2] = (value >>> 16);
|
|
15172
|
+
this[offset + 3] = (value >>> 24);
|
|
15173
|
+
return offset + 4
|
|
15174
|
+
};
|
|
15175
|
+
|
|
15176
|
+
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
15177
|
+
value = +value;
|
|
15178
|
+
offset = offset >>> 0;
|
|
15179
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
15180
|
+
if (value < 0) value = 0xffffffff + value + 1;
|
|
15181
|
+
this[offset] = (value >>> 24);
|
|
15182
|
+
this[offset + 1] = (value >>> 16);
|
|
15183
|
+
this[offset + 2] = (value >>> 8);
|
|
15184
|
+
this[offset + 3] = (value & 0xff);
|
|
15185
|
+
return offset + 4
|
|
15186
|
+
};
|
|
15187
|
+
|
|
15188
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
15189
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
15190
|
+
});
|
|
15191
|
+
|
|
15192
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
15193
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
15194
|
+
});
|
|
15195
|
+
|
|
15196
|
+
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
15197
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
15198
|
+
if (offset < 0) throw new RangeError('Index out of range')
|
|
15199
|
+
}
|
|
15200
|
+
|
|
15201
|
+
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
15202
|
+
value = +value;
|
|
15203
|
+
offset = offset >>> 0;
|
|
15204
|
+
if (!noAssert) {
|
|
15205
|
+
checkIEEE754(buf, value, offset, 4);
|
|
15206
|
+
}
|
|
15207
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
15208
|
+
return offset + 4
|
|
15209
|
+
}
|
|
15210
|
+
|
|
15211
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
15212
|
+
return writeFloat(this, value, offset, true, noAssert)
|
|
15213
|
+
};
|
|
15214
|
+
|
|
15215
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
15216
|
+
return writeFloat(this, value, offset, false, noAssert)
|
|
15217
|
+
};
|
|
15218
|
+
|
|
15219
|
+
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
15220
|
+
value = +value;
|
|
15221
|
+
offset = offset >>> 0;
|
|
15222
|
+
if (!noAssert) {
|
|
15223
|
+
checkIEEE754(buf, value, offset, 8);
|
|
15224
|
+
}
|
|
15225
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
15226
|
+
return offset + 8
|
|
15227
|
+
}
|
|
15228
|
+
|
|
15229
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
15230
|
+
return writeDouble(this, value, offset, true, noAssert)
|
|
15231
|
+
};
|
|
15232
|
+
|
|
15233
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
15234
|
+
return writeDouble(this, value, offset, false, noAssert)
|
|
15235
|
+
};
|
|
15236
|
+
|
|
15237
|
+
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
15238
|
+
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
15239
|
+
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
15240
|
+
if (!start) start = 0;
|
|
15241
|
+
if (!end && end !== 0) end = this.length;
|
|
15242
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
15243
|
+
if (!targetStart) targetStart = 0;
|
|
15244
|
+
if (end > 0 && end < start) end = start;
|
|
15245
|
+
|
|
15246
|
+
// Copy 0 bytes; we're done
|
|
15247
|
+
if (end === start) return 0
|
|
15248
|
+
if (target.length === 0 || this.length === 0) return 0
|
|
15249
|
+
|
|
15250
|
+
// Fatal error conditions
|
|
15251
|
+
if (targetStart < 0) {
|
|
15252
|
+
throw new RangeError('targetStart out of bounds')
|
|
15253
|
+
}
|
|
15254
|
+
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
15255
|
+
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
15256
|
+
|
|
15257
|
+
// Are we oob?
|
|
15258
|
+
if (end > this.length) end = this.length;
|
|
15259
|
+
if (target.length - targetStart < end - start) {
|
|
15260
|
+
end = target.length - targetStart + start;
|
|
15261
|
+
}
|
|
15262
|
+
|
|
15263
|
+
const len = end - start;
|
|
15264
|
+
|
|
15265
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
15266
|
+
// Use built-in when available, missing from IE11
|
|
15267
|
+
this.copyWithin(targetStart, start, end);
|
|
15268
|
+
} else {
|
|
15269
|
+
Uint8Array.prototype.set.call(
|
|
15270
|
+
target,
|
|
15271
|
+
this.subarray(start, end),
|
|
15272
|
+
targetStart
|
|
15273
|
+
);
|
|
15274
|
+
}
|
|
15275
|
+
|
|
15276
|
+
return len
|
|
15277
|
+
};
|
|
15278
|
+
|
|
15279
|
+
// Usage:
|
|
15280
|
+
// buffer.fill(number[, offset[, end]])
|
|
15281
|
+
// buffer.fill(buffer[, offset[, end]])
|
|
15282
|
+
// buffer.fill(string[, offset[, end]][, encoding])
|
|
15283
|
+
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
15284
|
+
// Handle string cases:
|
|
15285
|
+
if (typeof val === 'string') {
|
|
15286
|
+
if (typeof start === 'string') {
|
|
15287
|
+
encoding = start;
|
|
15288
|
+
start = 0;
|
|
15289
|
+
end = this.length;
|
|
15290
|
+
} else if (typeof end === 'string') {
|
|
15291
|
+
encoding = end;
|
|
15292
|
+
end = this.length;
|
|
15293
|
+
}
|
|
15294
|
+
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
15295
|
+
throw new TypeError('encoding must be a string')
|
|
15296
|
+
}
|
|
15297
|
+
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
15298
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
15299
|
+
}
|
|
15300
|
+
if (val.length === 1) {
|
|
15301
|
+
const code = val.charCodeAt(0);
|
|
15302
|
+
if ((encoding === 'utf8' && code < 128) ||
|
|
15303
|
+
encoding === 'latin1') {
|
|
15304
|
+
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
15305
|
+
val = code;
|
|
15306
|
+
}
|
|
15307
|
+
}
|
|
15308
|
+
} else if (typeof val === 'number') {
|
|
15309
|
+
val = val & 255;
|
|
15310
|
+
} else if (typeof val === 'boolean') {
|
|
15311
|
+
val = Number(val);
|
|
15312
|
+
}
|
|
15313
|
+
|
|
15314
|
+
// Invalid ranges are not set to a default, so can range check early.
|
|
15315
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
15316
|
+
throw new RangeError('Out of range index')
|
|
15317
|
+
}
|
|
15318
|
+
|
|
15319
|
+
if (end <= start) {
|
|
15320
|
+
return this
|
|
15321
|
+
}
|
|
15322
|
+
|
|
15323
|
+
start = start >>> 0;
|
|
15324
|
+
end = end === undefined ? this.length : end >>> 0;
|
|
15325
|
+
|
|
15326
|
+
if (!val) val = 0;
|
|
15327
|
+
|
|
15328
|
+
let i;
|
|
15329
|
+
if (typeof val === 'number') {
|
|
15330
|
+
for (i = start; i < end; ++i) {
|
|
15331
|
+
this[i] = val;
|
|
15332
|
+
}
|
|
15333
|
+
} else {
|
|
15334
|
+
const bytes = Buffer.isBuffer(val)
|
|
15335
|
+
? val
|
|
15336
|
+
: Buffer.from(val, encoding);
|
|
15337
|
+
const len = bytes.length;
|
|
15338
|
+
if (len === 0) {
|
|
15339
|
+
throw new TypeError('The value "' + val +
|
|
15340
|
+
'" is invalid for argument "value"')
|
|
15341
|
+
}
|
|
15342
|
+
for (i = 0; i < end - start; ++i) {
|
|
15343
|
+
this[i + start] = bytes[i % len];
|
|
15344
|
+
}
|
|
15345
|
+
}
|
|
15346
|
+
|
|
15347
|
+
return this
|
|
15348
|
+
};
|
|
15349
|
+
|
|
15350
|
+
// CUSTOM ERRORS
|
|
15351
|
+
// =============
|
|
15352
|
+
|
|
15353
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
|
15354
|
+
const errors = {};
|
|
15355
|
+
function E (sym, getMessage, Base) {
|
|
15356
|
+
errors[sym] = class NodeError extends Base {
|
|
15357
|
+
constructor () {
|
|
15358
|
+
super();
|
|
15359
|
+
|
|
15360
|
+
Object.defineProperty(this, 'message', {
|
|
15361
|
+
value: getMessage.apply(this, arguments),
|
|
15362
|
+
writable: true,
|
|
15363
|
+
configurable: true
|
|
15364
|
+
});
|
|
15365
|
+
|
|
15366
|
+
// Add the error code to the name to include it in the stack trace.
|
|
15367
|
+
this.name = `${this.name} [${sym}]`;
|
|
15368
|
+
// Access the stack to generate the error message including the error code
|
|
15369
|
+
// from the name.
|
|
15370
|
+
this.stack; // eslint-disable-line no-unused-expressions
|
|
15371
|
+
// Reset the name to the actual name.
|
|
15372
|
+
delete this.name;
|
|
15373
|
+
}
|
|
15374
|
+
|
|
15375
|
+
get code () {
|
|
15376
|
+
return sym
|
|
15377
|
+
}
|
|
15378
|
+
|
|
15379
|
+
set code (value) {
|
|
15380
|
+
Object.defineProperty(this, 'code', {
|
|
15381
|
+
configurable: true,
|
|
15382
|
+
enumerable: true,
|
|
15383
|
+
value,
|
|
15384
|
+
writable: true
|
|
15385
|
+
});
|
|
15386
|
+
}
|
|
15387
|
+
|
|
15388
|
+
toString () {
|
|
15389
|
+
return `${this.name} [${sym}]: ${this.message}`
|
|
15390
|
+
}
|
|
15391
|
+
};
|
|
15392
|
+
}
|
|
15393
|
+
|
|
15394
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
15395
|
+
function (name) {
|
|
15396
|
+
if (name) {
|
|
15397
|
+
return `${name} is outside of buffer bounds`
|
|
15398
|
+
}
|
|
15399
|
+
|
|
15400
|
+
return 'Attempt to access memory outside buffer bounds'
|
|
15401
|
+
}, RangeError);
|
|
15402
|
+
E('ERR_INVALID_ARG_TYPE',
|
|
15403
|
+
function (name, actual) {
|
|
15404
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
15405
|
+
}, TypeError);
|
|
15406
|
+
E('ERR_OUT_OF_RANGE',
|
|
15407
|
+
function (str, range, input) {
|
|
15408
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
15409
|
+
let received = input;
|
|
15410
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
15411
|
+
received = addNumericalSeparator(String(input));
|
|
15412
|
+
} else if (typeof input === 'bigint') {
|
|
15413
|
+
received = String(input);
|
|
15414
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
15415
|
+
received = addNumericalSeparator(received);
|
|
15416
|
+
}
|
|
15417
|
+
received += 'n';
|
|
15418
|
+
}
|
|
15419
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
15420
|
+
return msg
|
|
15421
|
+
}, RangeError);
|
|
15422
|
+
|
|
15423
|
+
function addNumericalSeparator (val) {
|
|
15424
|
+
let res = '';
|
|
15425
|
+
let i = val.length;
|
|
15426
|
+
const start = val[0] === '-' ? 1 : 0;
|
|
15427
|
+
for (; i >= start + 4; i -= 3) {
|
|
15428
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
15429
|
+
}
|
|
15430
|
+
return `${val.slice(0, i)}${res}`
|
|
15431
|
+
}
|
|
15432
|
+
|
|
15433
|
+
// CHECK FUNCTIONS
|
|
15434
|
+
// ===============
|
|
15435
|
+
|
|
15436
|
+
function checkBounds (buf, offset, byteLength) {
|
|
15437
|
+
validateNumber(offset, 'offset');
|
|
15438
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
15439
|
+
boundsError(offset, buf.length - (byteLength + 1));
|
|
15440
|
+
}
|
|
15441
|
+
}
|
|
15442
|
+
|
|
15443
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
15444
|
+
if (value > max || value < min) {
|
|
15445
|
+
const n = typeof min === 'bigint' ? 'n' : '';
|
|
15446
|
+
let range;
|
|
15447
|
+
{
|
|
15448
|
+
if (min === 0 || min === BigInt(0)) {
|
|
15449
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
15450
|
+
} else {
|
|
15451
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
15452
|
+
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
15453
|
+
}
|
|
15454
|
+
}
|
|
15455
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
15456
|
+
}
|
|
15457
|
+
checkBounds(buf, offset, byteLength);
|
|
15458
|
+
}
|
|
15459
|
+
|
|
15460
|
+
function validateNumber (value, name) {
|
|
15461
|
+
if (typeof value !== 'number') {
|
|
15462
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
15463
|
+
}
|
|
15464
|
+
}
|
|
15465
|
+
|
|
15466
|
+
function boundsError (value, length, type) {
|
|
15467
|
+
if (Math.floor(value) !== value) {
|
|
15468
|
+
validateNumber(value, type);
|
|
15469
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
15470
|
+
}
|
|
15471
|
+
|
|
15472
|
+
if (length < 0) {
|
|
15473
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
15474
|
+
}
|
|
15475
|
+
|
|
15476
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
15477
|
+
`>= ${0} and <= ${length}`,
|
|
15478
|
+
value)
|
|
15479
|
+
}
|
|
15480
|
+
|
|
15481
|
+
// HELPER FUNCTIONS
|
|
15482
|
+
// ================
|
|
15483
|
+
|
|
15484
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
15485
|
+
|
|
15486
|
+
function base64clean (str) {
|
|
15487
|
+
// Node takes equal signs as end of the Base64 encoding
|
|
15488
|
+
str = str.split('=')[0];
|
|
15489
|
+
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
15490
|
+
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
15491
|
+
// Node converts strings with length < 2 to ''
|
|
15492
|
+
if (str.length < 2) return ''
|
|
15493
|
+
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
15494
|
+
while (str.length % 4 !== 0) {
|
|
15495
|
+
str = str + '=';
|
|
15496
|
+
}
|
|
15497
|
+
return str
|
|
15498
|
+
}
|
|
15499
|
+
|
|
15500
|
+
function utf8ToBytes (string, units) {
|
|
15501
|
+
units = units || Infinity;
|
|
15502
|
+
let codePoint;
|
|
15503
|
+
const length = string.length;
|
|
15504
|
+
let leadSurrogate = null;
|
|
15505
|
+
const bytes = [];
|
|
15506
|
+
|
|
15507
|
+
for (let i = 0; i < length; ++i) {
|
|
15508
|
+
codePoint = string.charCodeAt(i);
|
|
15509
|
+
|
|
15510
|
+
// is surrogate component
|
|
15511
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
15512
|
+
// last char was a lead
|
|
15513
|
+
if (!leadSurrogate) {
|
|
15514
|
+
// no lead yet
|
|
15515
|
+
if (codePoint > 0xDBFF) {
|
|
15516
|
+
// unexpected trail
|
|
15517
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15518
|
+
continue
|
|
15519
|
+
} else if (i + 1 === length) {
|
|
15520
|
+
// unpaired lead
|
|
15521
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15522
|
+
continue
|
|
15523
|
+
}
|
|
15524
|
+
|
|
15525
|
+
// valid lead
|
|
15526
|
+
leadSurrogate = codePoint;
|
|
15527
|
+
|
|
15528
|
+
continue
|
|
15529
|
+
}
|
|
15530
|
+
|
|
15531
|
+
// 2 leads in a row
|
|
15532
|
+
if (codePoint < 0xDC00) {
|
|
15533
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15534
|
+
leadSurrogate = codePoint;
|
|
15535
|
+
continue
|
|
15536
|
+
}
|
|
15537
|
+
|
|
15538
|
+
// valid surrogate pair
|
|
15539
|
+
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
15540
|
+
} else if (leadSurrogate) {
|
|
15541
|
+
// valid bmp char, but last char was a lead
|
|
15542
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15543
|
+
}
|
|
15544
|
+
|
|
15545
|
+
leadSurrogate = null;
|
|
15546
|
+
|
|
15547
|
+
// encode utf8
|
|
15548
|
+
if (codePoint < 0x80) {
|
|
15549
|
+
if ((units -= 1) < 0) break
|
|
15550
|
+
bytes.push(codePoint);
|
|
15551
|
+
} else if (codePoint < 0x800) {
|
|
15552
|
+
if ((units -= 2) < 0) break
|
|
15553
|
+
bytes.push(
|
|
15554
|
+
codePoint >> 0x6 | 0xC0,
|
|
15555
|
+
codePoint & 0x3F | 0x80
|
|
15556
|
+
);
|
|
15557
|
+
} else if (codePoint < 0x10000) {
|
|
15558
|
+
if ((units -= 3) < 0) break
|
|
15559
|
+
bytes.push(
|
|
15560
|
+
codePoint >> 0xC | 0xE0,
|
|
15561
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15562
|
+
codePoint & 0x3F | 0x80
|
|
15563
|
+
);
|
|
15564
|
+
} else if (codePoint < 0x110000) {
|
|
15565
|
+
if ((units -= 4) < 0) break
|
|
15566
|
+
bytes.push(
|
|
15567
|
+
codePoint >> 0x12 | 0xF0,
|
|
15568
|
+
codePoint >> 0xC & 0x3F | 0x80,
|
|
15569
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15570
|
+
codePoint & 0x3F | 0x80
|
|
15571
|
+
);
|
|
15572
|
+
} else {
|
|
15573
|
+
throw new Error('Invalid code point')
|
|
15574
|
+
}
|
|
15575
|
+
}
|
|
15576
|
+
|
|
15577
|
+
return bytes
|
|
15578
|
+
}
|
|
15579
|
+
|
|
15580
|
+
function asciiToBytes (str) {
|
|
15581
|
+
const byteArray = [];
|
|
15582
|
+
for (let i = 0; i < str.length; ++i) {
|
|
15583
|
+
// Node's code seems to be doing this and not & 0x7F..
|
|
15584
|
+
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
15585
|
+
}
|
|
15586
|
+
return byteArray
|
|
15587
|
+
}
|
|
15588
|
+
|
|
15589
|
+
function utf16leToBytes (str, units) {
|
|
15590
|
+
let c, hi, lo;
|
|
15591
|
+
const byteArray = [];
|
|
15592
|
+
for (let i = 0; i < str.length; ++i) {
|
|
15593
|
+
if ((units -= 2) < 0) break
|
|
15594
|
+
|
|
15595
|
+
c = str.charCodeAt(i);
|
|
15596
|
+
hi = c >> 8;
|
|
15597
|
+
lo = c % 256;
|
|
15598
|
+
byteArray.push(lo);
|
|
15599
|
+
byteArray.push(hi);
|
|
15600
|
+
}
|
|
15601
|
+
|
|
15602
|
+
return byteArray
|
|
15603
|
+
}
|
|
15604
|
+
|
|
15605
|
+
function base64ToBytes (str) {
|
|
15606
|
+
return base64.toByteArray(base64clean(str))
|
|
15607
|
+
}
|
|
15608
|
+
|
|
15609
|
+
function blitBuffer (src, dst, offset, length) {
|
|
15610
|
+
let i;
|
|
15611
|
+
for (i = 0; i < length; ++i) {
|
|
15612
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
15613
|
+
dst[i + offset] = src[i];
|
|
15614
|
+
}
|
|
15615
|
+
return i
|
|
15616
|
+
}
|
|
15617
|
+
|
|
15618
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
15619
|
+
// the `instanceof` check but they should be treated as of that type.
|
|
15620
|
+
// See: https://github.com/feross/buffer/issues/166
|
|
15621
|
+
function isInstance (obj, type) {
|
|
15622
|
+
return obj instanceof type ||
|
|
15623
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
15624
|
+
obj.constructor.name === type.name)
|
|
15625
|
+
}
|
|
15626
|
+
function numberIsNaN (obj) {
|
|
15627
|
+
// For IE11 support
|
|
15628
|
+
return obj !== obj // eslint-disable-line no-self-compare
|
|
15629
|
+
}
|
|
15630
|
+
|
|
15631
|
+
// Create lookup table for `toString('hex')`
|
|
15632
|
+
// See: https://github.com/feross/buffer/issues/219
|
|
15633
|
+
const hexSliceLookupTable = (function () {
|
|
15634
|
+
const alphabet = '0123456789abcdef';
|
|
15635
|
+
const table = new Array(256);
|
|
15636
|
+
for (let i = 0; i < 16; ++i) {
|
|
15637
|
+
const i16 = i * 16;
|
|
15638
|
+
for (let j = 0; j < 16; ++j) {
|
|
15639
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
15640
|
+
}
|
|
15641
|
+
}
|
|
15642
|
+
return table
|
|
15643
|
+
})();
|
|
15644
|
+
|
|
15645
|
+
// Return not function with Error if BigInt not supported
|
|
15646
|
+
function defineBigIntMethod (fn) {
|
|
15647
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
15648
|
+
}
|
|
15649
|
+
|
|
15650
|
+
function BufferBigIntNotDefined () {
|
|
15651
|
+
throw new Error('BigInt not supported')
|
|
15652
|
+
}
|
|
15653
|
+
} (buffer));
|
|
15654
|
+
return buffer;
|
|
15655
|
+
}
|
|
15656
|
+
|
|
15657
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
15658
|
+
|
|
15659
|
+
var hasRequiredSafeBuffer;
|
|
15660
|
+
|
|
15661
|
+
function requireSafeBuffer () {
|
|
15662
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
15663
|
+
hasRequiredSafeBuffer = 1;
|
|
15664
|
+
(function (module, exports$1) {
|
|
15665
|
+
/* eslint-disable node/no-deprecated-api */
|
|
15666
|
+
var buffer = requireBuffer();
|
|
15667
|
+
var Buffer = buffer.Buffer;
|
|
15668
|
+
|
|
15669
|
+
// alternative to using Object.keys for old browsers
|
|
15670
|
+
function copyProps (src, dst) {
|
|
15671
|
+
for (var key in src) {
|
|
15672
|
+
dst[key] = src[key];
|
|
15673
|
+
}
|
|
15674
|
+
}
|
|
15675
|
+
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
15676
|
+
module.exports = buffer;
|
|
15677
|
+
} else {
|
|
15678
|
+
// Copy properties from require('buffer')
|
|
15679
|
+
copyProps(buffer, exports$1);
|
|
15680
|
+
exports$1.Buffer = SafeBuffer;
|
|
15681
|
+
}
|
|
15682
|
+
|
|
15683
|
+
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
15684
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
15685
|
+
}
|
|
15686
|
+
|
|
15687
|
+
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
15688
|
+
|
|
15689
|
+
// Copy static methods from Buffer
|
|
15690
|
+
copyProps(Buffer, SafeBuffer);
|
|
15691
|
+
|
|
15692
|
+
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
15693
|
+
if (typeof arg === 'number') {
|
|
15694
|
+
throw new TypeError('Argument must not be a number')
|
|
15695
|
+
}
|
|
15696
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
15697
|
+
};
|
|
15698
|
+
|
|
15699
|
+
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
15700
|
+
if (typeof size !== 'number') {
|
|
15701
|
+
throw new TypeError('Argument must be a number')
|
|
15702
|
+
}
|
|
15703
|
+
var buf = Buffer(size);
|
|
15704
|
+
if (fill !== undefined) {
|
|
15705
|
+
if (typeof encoding === 'string') {
|
|
15706
|
+
buf.fill(fill, encoding);
|
|
15707
|
+
} else {
|
|
15708
|
+
buf.fill(fill);
|
|
15709
|
+
}
|
|
15710
|
+
} else {
|
|
15711
|
+
buf.fill(0);
|
|
15712
|
+
}
|
|
15713
|
+
return buf
|
|
15714
|
+
};
|
|
15715
|
+
|
|
15716
|
+
SafeBuffer.allocUnsafe = function (size) {
|
|
15717
|
+
if (typeof size !== 'number') {
|
|
15718
|
+
throw new TypeError('Argument must be a number')
|
|
15719
|
+
}
|
|
15720
|
+
return Buffer(size)
|
|
15721
|
+
};
|
|
15722
|
+
|
|
15723
|
+
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
15724
|
+
if (typeof size !== 'number') {
|
|
15725
|
+
throw new TypeError('Argument must be a number')
|
|
15726
|
+
}
|
|
15727
|
+
return buffer.SlowBuffer(size)
|
|
15728
|
+
};
|
|
15729
|
+
} (safeBuffer, safeBuffer.exports));
|
|
15730
|
+
return safeBuffer.exports;
|
|
15731
|
+
}
|
|
15732
|
+
|
|
15733
|
+
var src;
|
|
15734
|
+
var hasRequiredSrc;
|
|
15735
|
+
|
|
15736
|
+
function requireSrc () {
|
|
15737
|
+
if (hasRequiredSrc) return src;
|
|
15738
|
+
hasRequiredSrc = 1;
|
|
15739
|
+
// base-x encoding / decoding
|
|
15740
|
+
// Copyright (c) 2018 base-x contributors
|
|
15741
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
15742
|
+
// Distributed under the MIT software license, see the accompanying
|
|
15743
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
15744
|
+
// @ts-ignore
|
|
15745
|
+
var _Buffer = requireSafeBuffer().Buffer;
|
|
15746
|
+
function base (ALPHABET) {
|
|
15747
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
15748
|
+
var BASE_MAP = new Uint8Array(256);
|
|
15749
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
15750
|
+
BASE_MAP[j] = 255;
|
|
15751
|
+
}
|
|
15752
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
15753
|
+
var x = ALPHABET.charAt(i);
|
|
15754
|
+
var xc = x.charCodeAt(0);
|
|
15755
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
15756
|
+
BASE_MAP[xc] = i;
|
|
15757
|
+
}
|
|
15758
|
+
var BASE = ALPHABET.length;
|
|
15759
|
+
var LEADER = ALPHABET.charAt(0);
|
|
15760
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
15761
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
15762
|
+
function encode (source) {
|
|
15763
|
+
if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
|
|
15764
|
+
if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
|
|
15765
|
+
if (source.length === 0) { return '' }
|
|
15766
|
+
// Skip & count leading zeroes.
|
|
15767
|
+
var zeroes = 0;
|
|
15768
|
+
var length = 0;
|
|
15769
|
+
var pbegin = 0;
|
|
15770
|
+
var pend = source.length;
|
|
15771
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
15772
|
+
pbegin++;
|
|
15773
|
+
zeroes++;
|
|
15774
|
+
}
|
|
15775
|
+
// Allocate enough space in big-endian base58 representation.
|
|
15776
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
15777
|
+
var b58 = new Uint8Array(size);
|
|
15778
|
+
// Process the bytes.
|
|
15779
|
+
while (pbegin !== pend) {
|
|
15780
|
+
var carry = source[pbegin];
|
|
15781
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
15782
|
+
var i = 0;
|
|
15783
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
15784
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
15785
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
15786
|
+
carry = (carry / BASE) >>> 0;
|
|
15787
|
+
}
|
|
15788
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15789
|
+
length = i;
|
|
15790
|
+
pbegin++;
|
|
15791
|
+
}
|
|
15792
|
+
// Skip leading zeroes in base58 result.
|
|
15793
|
+
var it2 = size - length;
|
|
15794
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
15795
|
+
it2++;
|
|
15796
|
+
}
|
|
15797
|
+
// Translate the result into a string.
|
|
15798
|
+
var str = LEADER.repeat(zeroes);
|
|
15799
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
15800
|
+
return str
|
|
15801
|
+
}
|
|
15802
|
+
function decodeUnsafe (source) {
|
|
15803
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
15804
|
+
if (source.length === 0) { return _Buffer.alloc(0) }
|
|
15805
|
+
var psz = 0;
|
|
15806
|
+
// Skip and count leading '1's.
|
|
15807
|
+
var zeroes = 0;
|
|
15808
|
+
var length = 0;
|
|
15809
|
+
while (source[psz] === LEADER) {
|
|
15810
|
+
zeroes++;
|
|
15811
|
+
psz++;
|
|
15812
|
+
}
|
|
15813
|
+
// Allocate enough space in big-endian base256 representation.
|
|
15814
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
15815
|
+
var b256 = new Uint8Array(size);
|
|
15816
|
+
// Process the characters.
|
|
15817
|
+
while (psz < source.length) {
|
|
15818
|
+
// Find code of next character
|
|
15819
|
+
var charCode = source.charCodeAt(psz);
|
|
15820
|
+
// Base map can not be indexed using char code
|
|
15821
|
+
if (charCode > 255) { return }
|
|
15822
|
+
// Decode character
|
|
15823
|
+
var carry = BASE_MAP[charCode];
|
|
15824
|
+
// Invalid character
|
|
15825
|
+
if (carry === 255) { return }
|
|
15826
|
+
var i = 0;
|
|
15827
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
15828
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
15829
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
15830
|
+
carry = (carry / 256) >>> 0;
|
|
15831
|
+
}
|
|
15832
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15833
|
+
length = i;
|
|
15834
|
+
psz++;
|
|
15835
|
+
}
|
|
15836
|
+
// Skip leading zeroes in b256.
|
|
15837
|
+
var it4 = size - length;
|
|
15838
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
15839
|
+
it4++;
|
|
15840
|
+
}
|
|
15841
|
+
var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
|
|
15842
|
+
vch.fill(0x00, 0, zeroes);
|
|
15843
|
+
var j = zeroes;
|
|
15844
|
+
while (it4 !== size) {
|
|
15845
|
+
vch[j++] = b256[it4++];
|
|
15846
|
+
}
|
|
15847
|
+
return vch
|
|
15848
|
+
}
|
|
15849
|
+
function decode (string) {
|
|
15850
|
+
var buffer = decodeUnsafe(string);
|
|
15851
|
+
if (buffer) { return buffer }
|
|
15852
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
15853
|
+
}
|
|
15854
|
+
return {
|
|
15855
|
+
encode: encode,
|
|
15856
|
+
decodeUnsafe: decodeUnsafe,
|
|
15857
|
+
decode: decode
|
|
15858
|
+
}
|
|
15859
|
+
}
|
|
15860
|
+
src = base;
|
|
15861
|
+
return src;
|
|
15862
|
+
}
|
|
15863
|
+
|
|
15864
|
+
var bs58$1;
|
|
15865
|
+
var hasRequiredBs58;
|
|
15866
|
+
|
|
15867
|
+
function requireBs58 () {
|
|
15868
|
+
if (hasRequiredBs58) return bs58$1;
|
|
15869
|
+
hasRequiredBs58 = 1;
|
|
15870
|
+
var basex = requireSrc();
|
|
15871
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
15872
|
+
|
|
15873
|
+
bs58$1 = basex(ALPHABET);
|
|
15874
|
+
return bs58$1;
|
|
13400
15875
|
}
|
|
13401
15876
|
|
|
13402
15877
|
var bs58Exports = requireBs58();
|
|
13403
|
-
var
|
|
15878
|
+
var bs58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
|
|
13404
15879
|
|
|
13405
15880
|
var index = /*#__PURE__*/_mergeNamespaces({
|
|
13406
15881
|
__proto__: null,
|
|
13407
|
-
default:
|
|
15882
|
+
default: bs58
|
|
13408
15883
|
}, [bs58Exports]);
|
|
13409
15884
|
|
|
13410
15885
|
/**
|
|
@@ -13591,7 +16066,7 @@ class PrivyExpoProvider {
|
|
|
13591
16066
|
const wallet = await this.getWalletOrThrow();
|
|
13592
16067
|
const messageBytes = getPlatform().textEncode(message);
|
|
13593
16068
|
const result = await wallet.signMessage(messageBytes);
|
|
13594
|
-
return
|
|
16069
|
+
return bs58.encode(result.signature);
|
|
13595
16070
|
}
|
|
13596
16071
|
async signTransaction(transaction) {
|
|
13597
16072
|
await this.ensureReady();
|
|
@@ -13758,7 +16233,7 @@ exports.SURFNET_RPC_URL = SURFNET_RPC_URL$1;
|
|
|
13758
16233
|
exports.ServerSessionManager = ServerSessionManager;
|
|
13759
16234
|
exports.WebSessionManager = WebSessionManager;
|
|
13760
16235
|
exports.aggregate = aggregate;
|
|
13761
|
-
exports.
|
|
16236
|
+
exports.bs58 = bs58;
|
|
13762
16237
|
exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
|
|
13763
16238
|
exports.clearCache = clearCache;
|
|
13764
16239
|
exports.closeAllSubscriptions = closeAllSubscriptions;
|
|
@@ -13793,6 +16268,7 @@ exports.onAuthStateChanged = onAuthStateChanged;
|
|
|
13793
16268
|
exports.reconnectWithNewAuth = reconnectWithNewAuth;
|
|
13794
16269
|
exports.refreshSession = refreshSession;
|
|
13795
16270
|
exports.require$$0 = require$$0;
|
|
16271
|
+
exports.requireBuffer = requireBuffer;
|
|
13796
16272
|
exports.runExpression = runExpression;
|
|
13797
16273
|
exports.runExpressionMany = runExpressionMany;
|
|
13798
16274
|
exports.runQuery = runQuery;
|
|
@@ -13809,4 +16285,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
|
13809
16285
|
exports.signTransaction = signTransaction;
|
|
13810
16286
|
exports.subscribe = subscribe;
|
|
13811
16287
|
exports.useAuth = useAuth;
|
|
13812
|
-
//# sourceMappingURL=index.native-
|
|
16288
|
+
//# sourceMappingURL=index.native-11supFRU.js.map
|