@pooflabs/web 0.0.79 → 0.0.81-rc1
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/auth/providers/phantom-wallet-provider.d.ts +20 -0
- package/dist/{index-BHGEc97p.js → index-BSL3D7PC.js} +25 -883
- package/dist/index-BSL3D7PC.js.map +1 -0
- package/dist/{index-DwU9hjtr.js → index-BU6puWaY.js} +640 -294
- package/dist/index-BU6puWaY.js.map +1 -0
- package/dist/index-Bdcc5821.js +2375 -0
- package/dist/index-Bdcc5821.js.map +1 -0
- package/dist/{index-CsIXFm8d.esm.js → index-Cpw11-0x.esm.js} +640 -295
- package/dist/index-Cpw11-0x.esm.js.map +1 -0
- package/dist/index-CrOVJFX9.esm.js +2373 -0
- package/dist/index-CrOVJFX9.esm.js.map +1 -0
- package/dist/{index-U-xlsKRI.esm.js → index-CtwdL0-L.esm.js} +23 -881
- package/dist/index-CtwdL0-L.esm.js.map +1 -0
- package/dist/{index-CiwYJvf8.esm.js → index-DLfRKZI7.esm.js} +24 -882
- package/dist/index-DLfRKZI7.esm.js.map +1 -0
- package/dist/{index-zS_Y-wbi.js → index-Fo9o33oZ.js} +24 -882
- package/dist/index-Fo9o33oZ.js.map +1 -0
- package/dist/{index.browser-Dbq5Qf1G.esm.js → index.browser-9JJy5Y7o.esm.js} +5 -128
- package/dist/index.browser-9JJy5Y7o.esm.js.map +1 -0
- package/dist/{index.browser-dszs5oe5.js → index.browser-B4RzFwu2.js} +6 -129
- package/dist/index.browser-B4RzFwu2.js.map +1 -0
- package/dist/{index.browser-Cpi4W_1r.js → index.browser-CGfTdDXe.js} +2 -2
- package/dist/{index.browser-Cpi4W_1r.js.map → index.browser-CGfTdDXe.js.map} +1 -1
- package/dist/{index.browser-Df7yN8D5.js → index.browser-CQUvzkLr.js} +6 -129
- package/dist/index.browser-CQUvzkLr.js.map +1 -0
- package/dist/{index.browser-C9bFQZyQ.esm.js → index.browser-Dzo4A2XB.esm.js} +5 -128
- package/dist/index.browser-Dzo4A2XB.esm.js.map +1 -0
- package/dist/{index.browser-CMEwqnEe.esm.js → index.browser-HEDpODB5.esm.js} +2 -2
- package/dist/{index.browser-CMEwqnEe.esm.js.map → index.browser-HEDpODB5.esm.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index.native-DtxPWD00.js → index.native-DYI4vw0X.js} +547 -2688
- package/dist/index.native-DYI4vw0X.js.map +1 -0
- package/dist/{index.native-CEf5PJ_g.esm.js → index.native-UxpBL0TA.esm.js} +548 -2688
- package/dist/index.native-UxpBL0TA.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-BbyQIlro.js → phantom-wallet-provider-BPSAXPZ6.js} +127 -11
- package/dist/{phantom-wallet-provider-BbyQIlro.js.map → phantom-wallet-provider-BPSAXPZ6.js.map} +1 -1
- package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js → phantom-wallet-provider-DcMJW18_.esm.js} +127 -11
- package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js.map → phantom-wallet-provider-DcMJW18_.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-DGjYglh7.esm.js → privy-wallet-provider-CtIl8FgH.esm.js} +3 -3
- package/dist/privy-wallet-provider-CtIl8FgH.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-CoQzq0F4.js → privy-wallet-provider-Zu5K_vNN.js} +3 -3
- package/dist/privy-wallet-provider-Zu5K_vNN.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js → solana-mobile-wallet-provider-C31APzEp.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js.map → solana-mobile-wallet-provider-C31APzEp.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js → solana-mobile-wallet-provider-Dg9_h3QI.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js.map → solana-mobile-wallet-provider-Dg9_h3QI.js.map} +1 -1
- package/package.json +24 -24
- package/dist/index-6pNPzV1t.esm.js +0 -6
- package/dist/index-6pNPzV1t.esm.js.map +0 -1
- package/dist/index-BHGEc97p.js.map +0 -1
- package/dist/index-CiwYJvf8.esm.js.map +0 -1
- package/dist/index-CsIXFm8d.esm.js.map +0 -1
- package/dist/index-D9BY44i-.js +0 -8
- package/dist/index-D9BY44i-.js.map +0 -1
- package/dist/index-DwU9hjtr.js.map +0 -1
- package/dist/index-U-xlsKRI.esm.js.map +0 -1
- package/dist/index-zS_Y-wbi.js.map +0 -1
- package/dist/index.browser-C9bFQZyQ.esm.js.map +0 -1
- package/dist/index.browser-Dbq5Qf1G.esm.js.map +0 -1
- package/dist/index.browser-Df7yN8D5.js.map +0 -1
- package/dist/index.browser-dszs5oe5.js.map +0 -1
- package/dist/index.native-CEf5PJ_g.esm.js.map +0 -1
- package/dist/index.native-DtxPWD00.js.map +0 -1
- package/dist/privy-wallet-provider-CoQzq0F4.js.map +0 -1
- package/dist/privy-wallet-provider-DGjYglh7.esm.js.map +0 -1
|
@@ -4,21 +4,6 @@ import * as anchor from '@coral-xyz/anchor';
|
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
|
|
7
|
-
function _mergeNamespaces(n, m) {
|
|
8
|
-
m.forEach(function (e) {
|
|
9
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
10
|
-
if (k !== 'default' && !(k in n)) {
|
|
11
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return e[k]; }
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
7
|
function getDefaultExportFromCjs$1 (x) {
|
|
23
8
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
24
9
|
}
|
|
@@ -6394,6 +6379,261 @@ var ReconnectingWebSocket = /** @class */ (function () {
|
|
|
6394
6379
|
return ReconnectingWebSocket;
|
|
6395
6380
|
}());
|
|
6396
6381
|
|
|
6382
|
+
function getDefaultExportFromCjs (x) {
|
|
6383
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6384
|
+
}
|
|
6385
|
+
|
|
6386
|
+
var isRetryAllowed$1;
|
|
6387
|
+
var hasRequiredIsRetryAllowed;
|
|
6388
|
+
|
|
6389
|
+
function requireIsRetryAllowed () {
|
|
6390
|
+
if (hasRequiredIsRetryAllowed) return isRetryAllowed$1;
|
|
6391
|
+
hasRequiredIsRetryAllowed = 1;
|
|
6392
|
+
|
|
6393
|
+
const denyList = new Set([
|
|
6394
|
+
'ENOTFOUND',
|
|
6395
|
+
'ENETUNREACH',
|
|
6396
|
+
|
|
6397
|
+
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
|
|
6398
|
+
'UNABLE_TO_GET_ISSUER_CERT',
|
|
6399
|
+
'UNABLE_TO_GET_CRL',
|
|
6400
|
+
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
|
6401
|
+
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
|
|
6402
|
+
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
|
|
6403
|
+
'CERT_SIGNATURE_FAILURE',
|
|
6404
|
+
'CRL_SIGNATURE_FAILURE',
|
|
6405
|
+
'CERT_NOT_YET_VALID',
|
|
6406
|
+
'CERT_HAS_EXPIRED',
|
|
6407
|
+
'CRL_NOT_YET_VALID',
|
|
6408
|
+
'CRL_HAS_EXPIRED',
|
|
6409
|
+
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
|
|
6410
|
+
'ERROR_IN_CERT_NOT_AFTER_FIELD',
|
|
6411
|
+
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
|
|
6412
|
+
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
|
|
6413
|
+
'OUT_OF_MEM',
|
|
6414
|
+
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
6415
|
+
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
6416
|
+
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
6417
|
+
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
6418
|
+
'CERT_CHAIN_TOO_LONG',
|
|
6419
|
+
'CERT_REVOKED',
|
|
6420
|
+
'INVALID_CA',
|
|
6421
|
+
'PATH_LENGTH_EXCEEDED',
|
|
6422
|
+
'INVALID_PURPOSE',
|
|
6423
|
+
'CERT_UNTRUSTED',
|
|
6424
|
+
'CERT_REJECTED',
|
|
6425
|
+
'HOSTNAME_MISMATCH'
|
|
6426
|
+
]);
|
|
6427
|
+
|
|
6428
|
+
// TODO: Use `error?.code` when targeting Node.js 14
|
|
6429
|
+
isRetryAllowed$1 = error => !denyList.has(error && error.code);
|
|
6430
|
+
return isRetryAllowed$1;
|
|
6431
|
+
}
|
|
6432
|
+
|
|
6433
|
+
var isRetryAllowedExports = requireIsRetryAllowed();
|
|
6434
|
+
var isRetryAllowed = /*@__PURE__*/getDefaultExportFromCjs(isRetryAllowedExports);
|
|
6435
|
+
|
|
6436
|
+
const namespace = 'axios-retry';
|
|
6437
|
+
function isNetworkError(error) {
|
|
6438
|
+
const CODE_EXCLUDE_LIST = ['ERR_CANCELED', 'ECONNABORTED'];
|
|
6439
|
+
if (error.response) {
|
|
6440
|
+
return false;
|
|
6441
|
+
}
|
|
6442
|
+
if (!error.code) {
|
|
6443
|
+
return false;
|
|
6444
|
+
}
|
|
6445
|
+
// Prevents retrying timed out & cancelled requests
|
|
6446
|
+
if (CODE_EXCLUDE_LIST.includes(error.code)) {
|
|
6447
|
+
return false;
|
|
6448
|
+
}
|
|
6449
|
+
// Prevents retrying unsafe errors
|
|
6450
|
+
return isRetryAllowed(error);
|
|
6451
|
+
}
|
|
6452
|
+
const SAFE_HTTP_METHODS = ['get', 'head', 'options'];
|
|
6453
|
+
const IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
|
|
6454
|
+
function isRetryableError(error) {
|
|
6455
|
+
return (error.code !== 'ECONNABORTED' &&
|
|
6456
|
+
(!error.response ||
|
|
6457
|
+
error.response.status === 429 ||
|
|
6458
|
+
(error.response.status >= 500 && error.response.status <= 599)));
|
|
6459
|
+
}
|
|
6460
|
+
function isSafeRequestError(error) {
|
|
6461
|
+
if (!error.config?.method) {
|
|
6462
|
+
// Cannot determine if the request can be retried
|
|
6463
|
+
return false;
|
|
6464
|
+
}
|
|
6465
|
+
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6466
|
+
}
|
|
6467
|
+
function isIdempotentRequestError(error) {
|
|
6468
|
+
if (!error.config?.method) {
|
|
6469
|
+
// Cannot determine if the request can be retried
|
|
6470
|
+
return false;
|
|
6471
|
+
}
|
|
6472
|
+
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6473
|
+
}
|
|
6474
|
+
function isNetworkOrIdempotentRequestError(error) {
|
|
6475
|
+
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
6476
|
+
}
|
|
6477
|
+
function retryAfter(error = undefined) {
|
|
6478
|
+
const retryAfterHeader = error?.response?.headers['retry-after'];
|
|
6479
|
+
if (!retryAfterHeader) {
|
|
6480
|
+
return 0;
|
|
6481
|
+
}
|
|
6482
|
+
// if the retry after header is a number, convert it to milliseconds
|
|
6483
|
+
let retryAfterMs = (Number(retryAfterHeader) || 0) * 1000;
|
|
6484
|
+
// If the retry after header is a date, get the number of milliseconds until that date
|
|
6485
|
+
if (retryAfterMs === 0) {
|
|
6486
|
+
retryAfterMs = (new Date(retryAfterHeader).valueOf() || 0) - Date.now();
|
|
6487
|
+
}
|
|
6488
|
+
return Math.max(0, retryAfterMs);
|
|
6489
|
+
}
|
|
6490
|
+
function noDelay(_retryNumber = 0, error = undefined) {
|
|
6491
|
+
return Math.max(0, retryAfter(error));
|
|
6492
|
+
}
|
|
6493
|
+
function exponentialDelay(retryNumber = 0, error = undefined, delayFactor = 100) {
|
|
6494
|
+
const calculatedDelay = 2 ** retryNumber * delayFactor;
|
|
6495
|
+
const delay = Math.max(calculatedDelay, retryAfter(error));
|
|
6496
|
+
const randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay
|
|
6497
|
+
return delay + randomSum;
|
|
6498
|
+
}
|
|
6499
|
+
/**
|
|
6500
|
+
* Linear delay
|
|
6501
|
+
* @param {number | undefined} delayFactor - delay factor in milliseconds (default: 100)
|
|
6502
|
+
* @returns {function} (retryNumber: number, error: AxiosError | undefined) => number
|
|
6503
|
+
*/
|
|
6504
|
+
function linearDelay(delayFactor = 100) {
|
|
6505
|
+
return (retryNumber = 0, error = undefined) => {
|
|
6506
|
+
const delay = retryNumber * delayFactor;
|
|
6507
|
+
return Math.max(delay, retryAfter(error));
|
|
6508
|
+
};
|
|
6509
|
+
}
|
|
6510
|
+
const DEFAULT_OPTIONS = {
|
|
6511
|
+
retries: 3,
|
|
6512
|
+
retryCondition: isNetworkOrIdempotentRequestError,
|
|
6513
|
+
retryDelay: noDelay,
|
|
6514
|
+
shouldResetTimeout: false,
|
|
6515
|
+
onRetry: () => { },
|
|
6516
|
+
onMaxRetryTimesExceeded: () => { },
|
|
6517
|
+
validateResponse: null
|
|
6518
|
+
};
|
|
6519
|
+
function getRequestOptions(config, defaultOptions) {
|
|
6520
|
+
return { ...DEFAULT_OPTIONS, ...defaultOptions, ...config[namespace] };
|
|
6521
|
+
}
|
|
6522
|
+
function setCurrentState(config, defaultOptions, resetLastRequestTime = false) {
|
|
6523
|
+
const currentState = getRequestOptions(config, defaultOptions || {});
|
|
6524
|
+
currentState.retryCount = currentState.retryCount || 0;
|
|
6525
|
+
if (!currentState.lastRequestTime || resetLastRequestTime) {
|
|
6526
|
+
currentState.lastRequestTime = Date.now();
|
|
6527
|
+
}
|
|
6528
|
+
config[namespace] = currentState;
|
|
6529
|
+
return currentState;
|
|
6530
|
+
}
|
|
6531
|
+
function fixConfig(axiosInstance, config) {
|
|
6532
|
+
// @ts-ignore
|
|
6533
|
+
if (axiosInstance.defaults.agent === config.agent) {
|
|
6534
|
+
// @ts-ignore
|
|
6535
|
+
delete config.agent;
|
|
6536
|
+
}
|
|
6537
|
+
if (axiosInstance.defaults.httpAgent === config.httpAgent) {
|
|
6538
|
+
delete config.httpAgent;
|
|
6539
|
+
}
|
|
6540
|
+
if (axiosInstance.defaults.httpsAgent === config.httpsAgent) {
|
|
6541
|
+
delete config.httpsAgent;
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
async function shouldRetry(currentState, error) {
|
|
6545
|
+
const { retries, retryCondition } = currentState;
|
|
6546
|
+
const shouldRetryOrPromise = (currentState.retryCount || 0) < retries && retryCondition(error);
|
|
6547
|
+
// This could be a promise
|
|
6548
|
+
if (typeof shouldRetryOrPromise === 'object') {
|
|
6549
|
+
try {
|
|
6550
|
+
const shouldRetryPromiseResult = await shouldRetryOrPromise;
|
|
6551
|
+
// keep return true unless shouldRetryPromiseResult return false for compatibility
|
|
6552
|
+
return shouldRetryPromiseResult !== false;
|
|
6553
|
+
}
|
|
6554
|
+
catch (_err) {
|
|
6555
|
+
return false;
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
return shouldRetryOrPromise;
|
|
6559
|
+
}
|
|
6560
|
+
async function handleRetry(axiosInstance, currentState, error, config) {
|
|
6561
|
+
currentState.retryCount += 1;
|
|
6562
|
+
const { retryDelay, shouldResetTimeout, onRetry } = currentState;
|
|
6563
|
+
const delay = retryDelay(currentState.retryCount, error);
|
|
6564
|
+
// Axios fails merging this configuration to the default configuration because it has an issue
|
|
6565
|
+
// with circular structures: https://github.com/mzabriskie/axios/issues/370
|
|
6566
|
+
fixConfig(axiosInstance, config);
|
|
6567
|
+
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
6568
|
+
const lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
6569
|
+
const timeout = config.timeout - lastRequestDuration - delay;
|
|
6570
|
+
if (timeout <= 0) {
|
|
6571
|
+
return Promise.reject(error);
|
|
6572
|
+
}
|
|
6573
|
+
config.timeout = timeout;
|
|
6574
|
+
}
|
|
6575
|
+
config.transformRequest = [(data) => data];
|
|
6576
|
+
await onRetry(currentState.retryCount, error, config);
|
|
6577
|
+
if (config.signal?.aborted) {
|
|
6578
|
+
return Promise.resolve(axiosInstance(config));
|
|
6579
|
+
}
|
|
6580
|
+
return new Promise((resolve) => {
|
|
6581
|
+
const abortListener = () => {
|
|
6582
|
+
clearTimeout(timeout);
|
|
6583
|
+
resolve(axiosInstance(config));
|
|
6584
|
+
};
|
|
6585
|
+
const timeout = setTimeout(() => {
|
|
6586
|
+
resolve(axiosInstance(config));
|
|
6587
|
+
if (config.signal?.removeEventListener) {
|
|
6588
|
+
config.signal.removeEventListener('abort', abortListener);
|
|
6589
|
+
}
|
|
6590
|
+
}, delay);
|
|
6591
|
+
if (config.signal?.addEventListener) {
|
|
6592
|
+
config.signal.addEventListener('abort', abortListener, { once: true });
|
|
6593
|
+
}
|
|
6594
|
+
});
|
|
6595
|
+
}
|
|
6596
|
+
async function handleMaxRetryTimesExceeded(currentState, error) {
|
|
6597
|
+
if (currentState.retryCount >= currentState.retries)
|
|
6598
|
+
await currentState.onMaxRetryTimesExceeded(error, currentState.retryCount);
|
|
6599
|
+
}
|
|
6600
|
+
const axiosRetry = (axiosInstance, defaultOptions) => {
|
|
6601
|
+
const requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
|
|
6602
|
+
setCurrentState(config, defaultOptions, true);
|
|
6603
|
+
if (config[namespace]?.validateResponse) {
|
|
6604
|
+
// by setting this, all HTTP responses will be go through the error interceptor first
|
|
6605
|
+
config.validateStatus = () => false;
|
|
6606
|
+
}
|
|
6607
|
+
return config;
|
|
6608
|
+
});
|
|
6609
|
+
const responseInterceptorId = axiosInstance.interceptors.response.use(null, async (error) => {
|
|
6610
|
+
const { config } = error;
|
|
6611
|
+
// If we have no information to retry the request
|
|
6612
|
+
if (!config) {
|
|
6613
|
+
return Promise.reject(error);
|
|
6614
|
+
}
|
|
6615
|
+
const currentState = setCurrentState(config, defaultOptions);
|
|
6616
|
+
if (error.response && currentState.validateResponse?.(error.response)) {
|
|
6617
|
+
// no issue with response
|
|
6618
|
+
return error.response;
|
|
6619
|
+
}
|
|
6620
|
+
if (await shouldRetry(currentState, error)) {
|
|
6621
|
+
return handleRetry(axiosInstance, currentState, error, config);
|
|
6622
|
+
}
|
|
6623
|
+
await handleMaxRetryTimesExceeded(currentState, error);
|
|
6624
|
+
return Promise.reject(error);
|
|
6625
|
+
});
|
|
6626
|
+
return { requestInterceptorId, responseInterceptorId };
|
|
6627
|
+
};
|
|
6628
|
+
// Compatibility with CommonJS
|
|
6629
|
+
axiosRetry.isNetworkError = isNetworkError;
|
|
6630
|
+
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
6631
|
+
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
6632
|
+
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
6633
|
+
axiosRetry.exponentialDelay = exponentialDelay;
|
|
6634
|
+
axiosRetry.linearDelay = linearDelay;
|
|
6635
|
+
axiosRetry.isRetryableError = isRetryableError;
|
|
6636
|
+
|
|
6397
6637
|
let axiosClient;
|
|
6398
6638
|
async function getAxiosAuthClient() {
|
|
6399
6639
|
if (!axiosClient) {
|
|
@@ -6403,6 +6643,7 @@ async function getAxiosAuthClient() {
|
|
|
6403
6643
|
headers: {
|
|
6404
6644
|
'Content-Type': 'application/json',
|
|
6405
6645
|
},
|
|
6646
|
+
timeout: 30000, // 30s timeout, matching makeApiRequest
|
|
6406
6647
|
});
|
|
6407
6648
|
}
|
|
6408
6649
|
return axiosClient;
|
|
@@ -6449,15 +6690,41 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
|
|
|
6449
6690
|
});
|
|
6450
6691
|
return response.data;
|
|
6451
6692
|
}
|
|
6693
|
+
// Deduplicate concurrent refreshSession calls to prevent multiple code paths
|
|
6694
|
+
// (WebSocket reconnection, periodic refresh, API 401 retry) from all hitting
|
|
6695
|
+
// /session/refresh simultaneously.
|
|
6696
|
+
// Note: module-level state is shared across requests in SSR/Node — acceptable
|
|
6697
|
+
// since there is only one active session per server instance (same pattern as
|
|
6698
|
+
// refreshInFlight in api.ts).
|
|
6699
|
+
let refreshInFlight$1 = null;
|
|
6700
|
+
let refreshInFlightToken = null;
|
|
6452
6701
|
async function refreshSession(refreshToken) {
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6702
|
+
if (refreshInFlight$1 && refreshInFlightToken === refreshToken) {
|
|
6703
|
+
return refreshInFlight$1;
|
|
6704
|
+
}
|
|
6705
|
+
refreshInFlightToken = refreshToken;
|
|
6706
|
+
let currentFlight;
|
|
6707
|
+
currentFlight = refreshInFlight$1 = (async () => {
|
|
6708
|
+
try {
|
|
6709
|
+
const client = await getAxiosAuthClient();
|
|
6710
|
+
const config = await getConfig();
|
|
6711
|
+
const appId = config.appId;
|
|
6712
|
+
const response = await client.post('/session/refresh', {
|
|
6713
|
+
refreshToken,
|
|
6714
|
+
appId
|
|
6715
|
+
});
|
|
6716
|
+
return response.data;
|
|
6717
|
+
}
|
|
6718
|
+
finally {
|
|
6719
|
+
// Only clear if we're still the active in-flight request.
|
|
6720
|
+
// A second call with a different token may have replaced us.
|
|
6721
|
+
if (refreshInFlight$1 === currentFlight) {
|
|
6722
|
+
refreshInFlight$1 = null;
|
|
6723
|
+
refreshInFlightToken = null;
|
|
6724
|
+
}
|
|
6725
|
+
}
|
|
6726
|
+
})();
|
|
6727
|
+
return refreshInFlight$1;
|
|
6461
6728
|
}
|
|
6462
6729
|
async function signSessionCreateMessage(_signMessageFunction) {
|
|
6463
6730
|
}
|
|
@@ -6595,27 +6862,23 @@ class WebSessionManager {
|
|
|
6595
6862
|
WebSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
|
|
6596
6863
|
|
|
6597
6864
|
var webSessionManager = /*#__PURE__*/Object.freeze({
|
|
6598
|
-
|
|
6599
|
-
|
|
6865
|
+
__proto__: null,
|
|
6866
|
+
WebSessionManager: WebSessionManager
|
|
6600
6867
|
});
|
|
6601
6868
|
|
|
6602
|
-
|
|
6603
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6604
|
-
}
|
|
6605
|
-
|
|
6606
|
-
var buffer$1 = {};
|
|
6869
|
+
var buffer = {};
|
|
6607
6870
|
|
|
6608
|
-
var base64Js
|
|
6871
|
+
var base64Js = {};
|
|
6609
6872
|
|
|
6610
|
-
var hasRequiredBase64Js
|
|
6873
|
+
var hasRequiredBase64Js;
|
|
6611
6874
|
|
|
6612
|
-
function requireBase64Js
|
|
6613
|
-
if (hasRequiredBase64Js
|
|
6614
|
-
hasRequiredBase64Js
|
|
6875
|
+
function requireBase64Js () {
|
|
6876
|
+
if (hasRequiredBase64Js) return base64Js;
|
|
6877
|
+
hasRequiredBase64Js = 1;
|
|
6615
6878
|
|
|
6616
|
-
base64Js
|
|
6617
|
-
base64Js
|
|
6618
|
-
base64Js
|
|
6879
|
+
base64Js.byteLength = byteLength;
|
|
6880
|
+
base64Js.toByteArray = toByteArray;
|
|
6881
|
+
base64Js.fromByteArray = fromByteArray;
|
|
6619
6882
|
|
|
6620
6883
|
var lookup = [];
|
|
6621
6884
|
var revLookup = [];
|
|
@@ -6761,19 +7024,19 @@ function requireBase64Js$1 () {
|
|
|
6761
7024
|
|
|
6762
7025
|
return parts.join('')
|
|
6763
7026
|
}
|
|
6764
|
-
return base64Js
|
|
7027
|
+
return base64Js;
|
|
6765
7028
|
}
|
|
6766
7029
|
|
|
6767
|
-
var ieee754
|
|
7030
|
+
var ieee754 = {};
|
|
6768
7031
|
|
|
6769
7032
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
6770
7033
|
|
|
6771
|
-
var hasRequiredIeee754
|
|
7034
|
+
var hasRequiredIeee754;
|
|
6772
7035
|
|
|
6773
|
-
function requireIeee754
|
|
6774
|
-
if (hasRequiredIeee754
|
|
6775
|
-
hasRequiredIeee754
|
|
6776
|
-
ieee754
|
|
7036
|
+
function requireIeee754 () {
|
|
7037
|
+
if (hasRequiredIeee754) return ieee754;
|
|
7038
|
+
hasRequiredIeee754 = 1;
|
|
7039
|
+
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
6777
7040
|
var e, m;
|
|
6778
7041
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
6779
7042
|
var eMax = (1 << eLen) - 1;
|
|
@@ -6806,7 +7069,7 @@ function requireIeee754$1 () {
|
|
|
6806
7069
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
6807
7070
|
};
|
|
6808
7071
|
|
|
6809
|
-
ieee754
|
|
7072
|
+
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
6810
7073
|
var e, m, c;
|
|
6811
7074
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
6812
7075
|
var eMax = (1 << eLen) - 1;
|
|
@@ -6857,7 +7120,7 @@ function requireIeee754$1 () {
|
|
|
6857
7120
|
|
|
6858
7121
|
buffer[offset + i - d] |= s * 128;
|
|
6859
7122
|
};
|
|
6860
|
-
return ieee754
|
|
7123
|
+
return ieee754;
|
|
6861
7124
|
}
|
|
6862
7125
|
|
|
6863
7126
|
/*!
|
|
@@ -6867,15 +7130,15 @@ function requireIeee754$1 () {
|
|
|
6867
7130
|
* @license MIT
|
|
6868
7131
|
*/
|
|
6869
7132
|
|
|
6870
|
-
var hasRequiredBuffer
|
|
7133
|
+
var hasRequiredBuffer;
|
|
6871
7134
|
|
|
6872
|
-
function requireBuffer
|
|
6873
|
-
if (hasRequiredBuffer
|
|
6874
|
-
hasRequiredBuffer
|
|
7135
|
+
function requireBuffer () {
|
|
7136
|
+
if (hasRequiredBuffer) return buffer;
|
|
7137
|
+
hasRequiredBuffer = 1;
|
|
6875
7138
|
(function (exports$1) {
|
|
6876
7139
|
|
|
6877
|
-
const base64 = requireBase64Js
|
|
6878
|
-
const ieee754 = requireIeee754
|
|
7140
|
+
const base64 = requireBase64Js();
|
|
7141
|
+
const ieee754 = requireIeee754();
|
|
6879
7142
|
const customInspectSymbol =
|
|
6880
7143
|
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
6881
7144
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
@@ -8968,24 +9231,24 @@ function requireBuffer$1 () {
|
|
|
8968
9231
|
function BufferBigIntNotDefined () {
|
|
8969
9232
|
throw new Error('BigInt not supported')
|
|
8970
9233
|
}
|
|
8971
|
-
} (buffer
|
|
8972
|
-
return buffer
|
|
9234
|
+
} (buffer));
|
|
9235
|
+
return buffer;
|
|
8973
9236
|
}
|
|
8974
9237
|
|
|
8975
|
-
var bufferExports = requireBuffer
|
|
9238
|
+
var bufferExports = requireBuffer();
|
|
8976
9239
|
|
|
8977
|
-
var safeBuffer
|
|
9240
|
+
var safeBuffer = {exports: {}};
|
|
8978
9241
|
|
|
8979
9242
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
8980
9243
|
|
|
8981
|
-
var hasRequiredSafeBuffer
|
|
9244
|
+
var hasRequiredSafeBuffer;
|
|
8982
9245
|
|
|
8983
|
-
function requireSafeBuffer
|
|
8984
|
-
if (hasRequiredSafeBuffer
|
|
8985
|
-
hasRequiredSafeBuffer
|
|
9246
|
+
function requireSafeBuffer () {
|
|
9247
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
9248
|
+
hasRequiredSafeBuffer = 1;
|
|
8986
9249
|
(function (module, exports$1) {
|
|
8987
9250
|
/* eslint-disable node/no-deprecated-api */
|
|
8988
|
-
var buffer = requireBuffer
|
|
9251
|
+
var buffer = requireBuffer();
|
|
8989
9252
|
var Buffer = buffer.Buffer;
|
|
8990
9253
|
|
|
8991
9254
|
// alternative to using Object.keys for old browsers
|
|
@@ -9048,23 +9311,23 @@ function requireSafeBuffer$1 () {
|
|
|
9048
9311
|
}
|
|
9049
9312
|
return buffer.SlowBuffer(size)
|
|
9050
9313
|
};
|
|
9051
|
-
} (safeBuffer
|
|
9052
|
-
return safeBuffer
|
|
9314
|
+
} (safeBuffer, safeBuffer.exports));
|
|
9315
|
+
return safeBuffer.exports;
|
|
9053
9316
|
}
|
|
9054
9317
|
|
|
9055
|
-
var src
|
|
9056
|
-
var hasRequiredSrc
|
|
9318
|
+
var src;
|
|
9319
|
+
var hasRequiredSrc;
|
|
9057
9320
|
|
|
9058
|
-
function requireSrc
|
|
9059
|
-
if (hasRequiredSrc
|
|
9060
|
-
hasRequiredSrc
|
|
9321
|
+
function requireSrc () {
|
|
9322
|
+
if (hasRequiredSrc) return src;
|
|
9323
|
+
hasRequiredSrc = 1;
|
|
9061
9324
|
// base-x encoding / decoding
|
|
9062
9325
|
// Copyright (c) 2018 base-x contributors
|
|
9063
9326
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9064
9327
|
// Distributed under the MIT software license, see the accompanying
|
|
9065
9328
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9066
9329
|
// @ts-ignore
|
|
9067
|
-
var _Buffer = requireSafeBuffer
|
|
9330
|
+
var _Buffer = requireSafeBuffer().Buffer;
|
|
9068
9331
|
function base (ALPHABET) {
|
|
9069
9332
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9070
9333
|
var BASE_MAP = new Uint8Array(256);
|
|
@@ -9179,25 +9442,25 @@ function requireSrc$1 () {
|
|
|
9179
9442
|
decode: decode
|
|
9180
9443
|
}
|
|
9181
9444
|
}
|
|
9182
|
-
src
|
|
9183
|
-
return src
|
|
9445
|
+
src = base;
|
|
9446
|
+
return src;
|
|
9184
9447
|
}
|
|
9185
9448
|
|
|
9186
|
-
var bs58$1
|
|
9187
|
-
var hasRequiredBs58
|
|
9449
|
+
var bs58$1;
|
|
9450
|
+
var hasRequiredBs58;
|
|
9188
9451
|
|
|
9189
|
-
function requireBs58
|
|
9190
|
-
if (hasRequiredBs58
|
|
9191
|
-
hasRequiredBs58
|
|
9192
|
-
var basex = requireSrc
|
|
9452
|
+
function requireBs58 () {
|
|
9453
|
+
if (hasRequiredBs58) return bs58$1;
|
|
9454
|
+
hasRequiredBs58 = 1;
|
|
9455
|
+
var basex = requireSrc();
|
|
9193
9456
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9194
9457
|
|
|
9195
|
-
bs58$1
|
|
9196
|
-
return bs58$1
|
|
9458
|
+
bs58$1 = basex(ALPHABET);
|
|
9459
|
+
return bs58$1;
|
|
9197
9460
|
}
|
|
9198
9461
|
|
|
9199
|
-
var bs58Exports
|
|
9200
|
-
var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports
|
|
9462
|
+
var bs58Exports = requireBs58();
|
|
9463
|
+
var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
|
|
9201
9464
|
|
|
9202
9465
|
// ─────────────────────────────────────────────────────────────
|
|
9203
9466
|
// Local implementation of getSimulationComputeUnits
|
|
@@ -9399,7 +9662,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
9399
9662
|
}
|
|
9400
9663
|
}
|
|
9401
9664
|
else if (lutKey != null) {
|
|
9402
|
-
|
|
9665
|
+
// The LUT may have just been created server-side and the client's RPC node
|
|
9666
|
+
// may not have indexed it yet (load-balancer split). Retry with exponential
|
|
9667
|
+
// back-off; first retry at 100 ms almost always resolves it.
|
|
9668
|
+
let table = null;
|
|
9669
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
9670
|
+
const { value } = await connection.getAddressLookupTable(new PublicKey(lutKey));
|
|
9671
|
+
if (value) {
|
|
9672
|
+
table = value;
|
|
9673
|
+
break;
|
|
9674
|
+
}
|
|
9675
|
+
if (attempt < 4)
|
|
9676
|
+
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
9677
|
+
}
|
|
9403
9678
|
if (!table)
|
|
9404
9679
|
throw new Error('LUT not found after creation/extend');
|
|
9405
9680
|
lookupTables.push(table);
|
|
@@ -9534,8 +9809,8 @@ class ServerSessionManager {
|
|
|
9534
9809
|
ServerSessionManager.instance = new ServerSessionManager();
|
|
9535
9810
|
|
|
9536
9811
|
var serverSessionManager = /*#__PURE__*/Object.freeze({
|
|
9537
|
-
|
|
9538
|
-
|
|
9812
|
+
__proto__: null,
|
|
9813
|
+
ServerSessionManager: ServerSessionManager
|
|
9539
9814
|
});
|
|
9540
9815
|
|
|
9541
9816
|
/**
|
|
@@ -9634,6 +9909,23 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
|
|
|
9634
9909
|
await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
|
|
9635
9910
|
}
|
|
9636
9911
|
|
|
9912
|
+
const apiClient = globalAxios.create();
|
|
9913
|
+
axiosRetry(apiClient, {
|
|
9914
|
+
retries: 2,
|
|
9915
|
+
retryCondition: (error) => {
|
|
9916
|
+
var _a, _b;
|
|
9917
|
+
// Only retry GET requests on network errors (ECONNRESET, ETIMEDOUT, etc.)
|
|
9918
|
+
// Writes (POST/PUT) are not retried — the server may have processed
|
|
9919
|
+
// the request before the connection was reset.
|
|
9920
|
+
return axiosRetry.isNetworkError(error) && ((_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.method) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'get';
|
|
9921
|
+
},
|
|
9922
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
9923
|
+
shouldResetTimeout: true,
|
|
9924
|
+
onRetry: (retryCount, error, requestConfig) => {
|
|
9925
|
+
var _a;
|
|
9926
|
+
console.warn(`[tarobase-sdk] retry ${retryCount} for ${(_a = requestConfig.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${requestConfig.url} — ${error.code || error.message}`);
|
|
9927
|
+
},
|
|
9928
|
+
});
|
|
9637
9929
|
const refreshInFlight = new Map();
|
|
9638
9930
|
async function refreshAuthSessionOnce(appId, isServer) {
|
|
9639
9931
|
const key = `${isServer ? "server" : "web"}:${appId}`;
|
|
@@ -9680,6 +9972,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
9680
9972
|
ServerSessionManager.instance.clearSession();
|
|
9681
9973
|
};
|
|
9682
9974
|
async function executeRequest() {
|
|
9975
|
+
var _a;
|
|
9683
9976
|
// When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
|
|
9684
9977
|
// Otherwise use the global createAuthHeader (default path).
|
|
9685
9978
|
const authHeader = (_overrides === null || _overrides === void 0 ? void 0 : _overrides._getAuthHeaders)
|
|
@@ -9701,11 +9994,12 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
9701
9994
|
method,
|
|
9702
9995
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
9703
9996
|
headers,
|
|
9997
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : 30000,
|
|
9704
9998
|
};
|
|
9705
9999
|
if (method !== "GET" && method !== "get") {
|
|
9706
10000
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
9707
10001
|
}
|
|
9708
|
-
const response = await
|
|
10002
|
+
const response = await apiClient(requestConfig);
|
|
9709
10003
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
9710
10004
|
}
|
|
9711
10005
|
try {
|
|
@@ -10641,6 +10935,7 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10641
10935
|
// This replaces the old single setTimeout approach which was unreliable for long
|
|
10642
10936
|
// delays (browsers throttle/suspend timers in background tabs).
|
|
10643
10937
|
connection.tokenRefreshTimer = setInterval(async () => {
|
|
10938
|
+
var _a, _b;
|
|
10644
10939
|
try {
|
|
10645
10940
|
const currentToken = await getIdToken$1(isServer);
|
|
10646
10941
|
if (!currentToken)
|
|
@@ -10671,6 +10966,17 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10671
10966
|
}
|
|
10672
10967
|
}
|
|
10673
10968
|
catch (refreshError) {
|
|
10969
|
+
// If the refresh token itself is invalid (401/403), stop retrying —
|
|
10970
|
+
// the token won't magically become valid next interval, and continuing
|
|
10971
|
+
// to hammer /session/refresh causes 429 rate-limit storms.
|
|
10972
|
+
if (((_a = refreshError === null || refreshError === void 0 ? void 0 : refreshError.response) === null || _a === void 0 ? void 0 : _a.status) === 401 || ((_b = refreshError === null || refreshError === void 0 ? void 0 : refreshError.response) === null || _b === void 0 ? void 0 : _b.status) === 403) {
|
|
10973
|
+
console.warn('[WS v2] Refresh token rejected (401/403), stopping periodic refresh');
|
|
10974
|
+
if (connection.tokenRefreshTimer) {
|
|
10975
|
+
clearInterval(connection.tokenRefreshTimer);
|
|
10976
|
+
connection.tokenRefreshTimer = null;
|
|
10977
|
+
}
|
|
10978
|
+
return;
|
|
10979
|
+
}
|
|
10674
10980
|
console.warn('[WS v2] Proactive token refresh failed, will retry next interval:', refreshError);
|
|
10675
10981
|
}
|
|
10676
10982
|
}
|
|
@@ -10681,6 +10987,7 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10681
10987
|
}, TOKEN_CHECK_INTERVAL);
|
|
10682
10988
|
}
|
|
10683
10989
|
async function getFreshAuthToken(isServer) {
|
|
10990
|
+
var _a, _b;
|
|
10684
10991
|
const currentToken = await getIdToken$1(isServer);
|
|
10685
10992
|
if (!currentToken) {
|
|
10686
10993
|
return null;
|
|
@@ -10703,6 +11010,17 @@ async function getFreshAuthToken(isServer) {
|
|
|
10703
11010
|
}
|
|
10704
11011
|
catch (error) {
|
|
10705
11012
|
console.error('[WS v2] Error refreshing token:', error);
|
|
11013
|
+
// If the refresh token is permanently invalid (401/403), clear the stale
|
|
11014
|
+
// session from storage so future attempts don't keep retrying with it.
|
|
11015
|
+
if (!isServer && (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 || ((_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.status) === 403)) {
|
|
11016
|
+
try {
|
|
11017
|
+
const { WebSessionManager } = await Promise.resolve().then(function () { return webSessionManager; });
|
|
11018
|
+
WebSessionManager.clearSession();
|
|
11019
|
+
}
|
|
11020
|
+
catch (clearError) {
|
|
11021
|
+
console.warn('[WS v2] Failed to clear stale session:', clearError);
|
|
11022
|
+
}
|
|
11023
|
+
}
|
|
10706
11024
|
}
|
|
10707
11025
|
// Return null instead of the expired token to prevent infinite 401 reconnect storms.
|
|
10708
11026
|
// The server accepts unauthenticated connections; auth-required subscriptions will
|
|
@@ -10823,7 +11141,16 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10823
11141
|
ws.addEventListener('open', () => {
|
|
10824
11142
|
connection.isConnecting = false;
|
|
10825
11143
|
connection.isConnected = true;
|
|
10826
|
-
|
|
11144
|
+
// NOTE: Do NOT reset consecutiveAuthFailures here. It is reset when a
|
|
11145
|
+
// fresh auth token is actually obtained (in urlProvider, line ~389) or on
|
|
11146
|
+
// an explicit auth change (reconnectWithNewAuthV2, line ~854). Resetting
|
|
11147
|
+
// on every 'open' event created an infinite loop: auth fails 5x → connect
|
|
11148
|
+
// without auth → open resets counter → disconnect → auth fails 5x again →
|
|
11149
|
+
// repeat forever, hammering /session/refresh and causing 429s.
|
|
11150
|
+
//
|
|
11151
|
+
// An elevated counter is safe for anonymous/guest sessions: when there's no
|
|
11152
|
+
// token at all (getIdToken returns null), the counter is never checked —
|
|
11153
|
+
// urlProvider skips straight to unauthenticated connection.
|
|
10827
11154
|
// Schedule periodic token freshness checks
|
|
10828
11155
|
scheduleTokenRefresh(connection, isServer);
|
|
10829
11156
|
// Re-subscribe to all existing subscriptions after reconnect
|
|
@@ -12485,15 +12812,15 @@ function clearIncompatibleSession() {
|
|
|
12485
12812
|
// Lazy loaders for web-only providers.
|
|
12486
12813
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
12487
12814
|
async function loadPrivyWalletProvider() {
|
|
12488
|
-
const mod = await import('./privy-wallet-provider-
|
|
12815
|
+
const mod = await import('./privy-wallet-provider-CtIl8FgH.esm.js');
|
|
12489
12816
|
return mod.PrivyWalletProvider;
|
|
12490
12817
|
}
|
|
12491
12818
|
async function loadPhantomWalletProvider() {
|
|
12492
|
-
const mod = await import('./phantom-wallet-provider-
|
|
12819
|
+
const mod = await import('./phantom-wallet-provider-DcMJW18_.esm.js');
|
|
12493
12820
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
12494
12821
|
}
|
|
12495
12822
|
async function loadSolanaMobileWalletProvider() {
|
|
12496
|
-
const mod = await import('./solana-mobile-wallet-provider-
|
|
12823
|
+
const mod = await import('./solana-mobile-wallet-provider-C31APzEp.esm.js');
|
|
12497
12824
|
return mod.SolanaMobileWalletProvider;
|
|
12498
12825
|
}
|
|
12499
12826
|
async function hotSwapToPrivyProvider(config) {
|
|
@@ -12903,2604 +13230,137 @@ async function confirmAndCheckTransaction(connection, signature) {
|
|
|
12903
13230
|
throw new Error('Transaction confirmation timeout');
|
|
12904
13231
|
}
|
|
12905
13232
|
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
function fromByteArray (uint8) {
|
|
13035
|
-
var tmp;
|
|
13036
|
-
var len = uint8.length;
|
|
13037
|
-
var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
|
13038
|
-
var parts = [];
|
|
13039
|
-
var maxChunkLength = 16383; // must be multiple of 3
|
|
13040
|
-
|
|
13041
|
-
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
13042
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
13043
|
-
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
|
|
13044
|
-
}
|
|
13045
|
-
|
|
13046
|
-
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
13047
|
-
if (extraBytes === 1) {
|
|
13048
|
-
tmp = uint8[len - 1];
|
|
13049
|
-
parts.push(
|
|
13050
|
-
lookup[tmp >> 2] +
|
|
13051
|
-
lookup[(tmp << 4) & 0x3F] +
|
|
13052
|
-
'=='
|
|
13053
|
-
);
|
|
13054
|
-
} else if (extraBytes === 2) {
|
|
13055
|
-
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
13056
|
-
parts.push(
|
|
13057
|
-
lookup[tmp >> 10] +
|
|
13058
|
-
lookup[(tmp >> 4) & 0x3F] +
|
|
13059
|
-
lookup[(tmp << 2) & 0x3F] +
|
|
13060
|
-
'='
|
|
13061
|
-
);
|
|
13062
|
-
}
|
|
13063
|
-
|
|
13064
|
-
return parts.join('')
|
|
13065
|
-
}
|
|
13066
|
-
return base64Js;
|
|
13067
|
-
}
|
|
13068
|
-
|
|
13069
|
-
var ieee754 = {};
|
|
13070
|
-
|
|
13071
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
13072
|
-
|
|
13073
|
-
var hasRequiredIeee754;
|
|
13074
|
-
|
|
13075
|
-
function requireIeee754 () {
|
|
13076
|
-
if (hasRequiredIeee754) return ieee754;
|
|
13077
|
-
hasRequiredIeee754 = 1;
|
|
13078
|
-
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
13079
|
-
var e, m;
|
|
13080
|
-
var eLen = (nBytes * 8) - mLen - 1;
|
|
13081
|
-
var eMax = (1 << eLen) - 1;
|
|
13082
|
-
var eBias = eMax >> 1;
|
|
13083
|
-
var nBits = -7;
|
|
13084
|
-
var i = isLE ? (nBytes - 1) : 0;
|
|
13085
|
-
var d = isLE ? -1 : 1;
|
|
13086
|
-
var s = buffer[offset + i];
|
|
13087
|
-
|
|
13088
|
-
i += d;
|
|
13089
|
-
|
|
13090
|
-
e = s & ((1 << (-nBits)) - 1);
|
|
13091
|
-
s >>= (-nBits);
|
|
13092
|
-
nBits += eLen;
|
|
13093
|
-
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13094
|
-
|
|
13095
|
-
m = e & ((1 << (-nBits)) - 1);
|
|
13096
|
-
e >>= (-nBits);
|
|
13097
|
-
nBits += mLen;
|
|
13098
|
-
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13099
|
-
|
|
13100
|
-
if (e === 0) {
|
|
13101
|
-
e = 1 - eBias;
|
|
13102
|
-
} else if (e === eMax) {
|
|
13103
|
-
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
13104
|
-
} else {
|
|
13105
|
-
m = m + Math.pow(2, mLen);
|
|
13106
|
-
e = e - eBias;
|
|
13107
|
-
}
|
|
13108
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
13109
|
-
};
|
|
13110
|
-
|
|
13111
|
-
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
13112
|
-
var e, m, c;
|
|
13113
|
-
var eLen = (nBytes * 8) - mLen - 1;
|
|
13114
|
-
var eMax = (1 << eLen) - 1;
|
|
13115
|
-
var eBias = eMax >> 1;
|
|
13116
|
-
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
|
|
13117
|
-
var i = isLE ? 0 : (nBytes - 1);
|
|
13118
|
-
var d = isLE ? 1 : -1;
|
|
13119
|
-
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
13120
|
-
|
|
13121
|
-
value = Math.abs(value);
|
|
13122
|
-
|
|
13123
|
-
if (isNaN(value) || value === Infinity) {
|
|
13124
|
-
m = isNaN(value) ? 1 : 0;
|
|
13125
|
-
e = eMax;
|
|
13126
|
-
} else {
|
|
13127
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
13128
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
13129
|
-
e--;
|
|
13130
|
-
c *= 2;
|
|
13131
|
-
}
|
|
13132
|
-
if (e + eBias >= 1) {
|
|
13133
|
-
value += rt / c;
|
|
13134
|
-
} else {
|
|
13135
|
-
value += rt * Math.pow(2, 1 - eBias);
|
|
13136
|
-
}
|
|
13137
|
-
if (value * c >= 2) {
|
|
13138
|
-
e++;
|
|
13139
|
-
c /= 2;
|
|
13140
|
-
}
|
|
13141
|
-
|
|
13142
|
-
if (e + eBias >= eMax) {
|
|
13143
|
-
m = 0;
|
|
13144
|
-
e = eMax;
|
|
13145
|
-
} else if (e + eBias >= 1) {
|
|
13146
|
-
m = ((value * c) - 1) * Math.pow(2, mLen);
|
|
13147
|
-
e = e + eBias;
|
|
13148
|
-
} else {
|
|
13149
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
13150
|
-
e = 0;
|
|
13151
|
-
}
|
|
13152
|
-
}
|
|
13153
|
-
|
|
13154
|
-
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
13155
|
-
|
|
13156
|
-
e = (e << mLen) | m;
|
|
13157
|
-
eLen += mLen;
|
|
13158
|
-
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
13159
|
-
|
|
13160
|
-
buffer[offset + i - d] |= s * 128;
|
|
13161
|
-
};
|
|
13162
|
-
return ieee754;
|
|
13163
|
-
}
|
|
13164
|
-
|
|
13165
|
-
/*!
|
|
13166
|
-
* The buffer module from node.js, for the browser.
|
|
13167
|
-
*
|
|
13168
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
13169
|
-
* @license MIT
|
|
13170
|
-
*/
|
|
13171
|
-
|
|
13172
|
-
var hasRequiredBuffer;
|
|
13173
|
-
|
|
13174
|
-
function requireBuffer () {
|
|
13175
|
-
if (hasRequiredBuffer) return buffer;
|
|
13176
|
-
hasRequiredBuffer = 1;
|
|
13177
|
-
(function (exports$1) {
|
|
13178
|
-
|
|
13179
|
-
const base64 = requireBase64Js();
|
|
13180
|
-
const ieee754 = requireIeee754();
|
|
13181
|
-
const customInspectSymbol =
|
|
13182
|
-
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
13183
|
-
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
13184
|
-
: null;
|
|
13185
|
-
|
|
13186
|
-
exports$1.Buffer = Buffer;
|
|
13187
|
-
exports$1.SlowBuffer = SlowBuffer;
|
|
13188
|
-
exports$1.INSPECT_MAX_BYTES = 50;
|
|
13189
|
-
|
|
13190
|
-
const K_MAX_LENGTH = 0x7fffffff;
|
|
13191
|
-
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
13192
|
-
|
|
13193
|
-
/**
|
|
13194
|
-
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
13195
|
-
* === true Use Uint8Array implementation (fastest)
|
|
13196
|
-
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
13197
|
-
* implementation (most compatible, even IE6)
|
|
13198
|
-
*
|
|
13199
|
-
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
13200
|
-
* Opera 11.6+, iOS 4.2+.
|
|
13201
|
-
*
|
|
13202
|
-
* We report that the browser does not support typed arrays if the are not subclassable
|
|
13203
|
-
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
13204
|
-
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
13205
|
-
* for __proto__ and has a buggy typed array implementation.
|
|
13206
|
-
*/
|
|
13207
|
-
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
13208
|
-
|
|
13209
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
13210
|
-
typeof console.error === 'function') {
|
|
13211
|
-
console.error(
|
|
13212
|
-
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
13213
|
-
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
13214
|
-
);
|
|
13215
|
-
}
|
|
13216
|
-
|
|
13217
|
-
function typedArraySupport () {
|
|
13218
|
-
// Can typed array instances can be augmented?
|
|
13219
|
-
try {
|
|
13220
|
-
const arr = new Uint8Array(1);
|
|
13221
|
-
const proto = { foo: function () { return 42 } };
|
|
13222
|
-
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
13223
|
-
Object.setPrototypeOf(arr, proto);
|
|
13224
|
-
return arr.foo() === 42
|
|
13225
|
-
} catch (e) {
|
|
13226
|
-
return false
|
|
13227
|
-
}
|
|
13228
|
-
}
|
|
13229
|
-
|
|
13230
|
-
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
13231
|
-
enumerable: true,
|
|
13232
|
-
get: function () {
|
|
13233
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
13234
|
-
return this.buffer
|
|
13235
|
-
}
|
|
13236
|
-
});
|
|
13237
|
-
|
|
13238
|
-
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
13239
|
-
enumerable: true,
|
|
13240
|
-
get: function () {
|
|
13241
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
13242
|
-
return this.byteOffset
|
|
13243
|
-
}
|
|
13244
|
-
});
|
|
13245
|
-
|
|
13246
|
-
function createBuffer (length) {
|
|
13247
|
-
if (length > K_MAX_LENGTH) {
|
|
13248
|
-
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
13249
|
-
}
|
|
13250
|
-
// Return an augmented `Uint8Array` instance
|
|
13251
|
-
const buf = new Uint8Array(length);
|
|
13252
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13253
|
-
return buf
|
|
13254
|
-
}
|
|
13255
|
-
|
|
13256
|
-
/**
|
|
13257
|
-
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
13258
|
-
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
13259
|
-
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
13260
|
-
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
13261
|
-
* returns a single octet.
|
|
13262
|
-
*
|
|
13263
|
-
* The `Uint8Array` prototype remains unmodified.
|
|
13264
|
-
*/
|
|
13265
|
-
|
|
13266
|
-
function Buffer (arg, encodingOrOffset, length) {
|
|
13267
|
-
// Common case.
|
|
13268
|
-
if (typeof arg === 'number') {
|
|
13269
|
-
if (typeof encodingOrOffset === 'string') {
|
|
13270
|
-
throw new TypeError(
|
|
13271
|
-
'The "string" argument must be of type string. Received type number'
|
|
13272
|
-
)
|
|
13273
|
-
}
|
|
13274
|
-
return allocUnsafe(arg)
|
|
13275
|
-
}
|
|
13276
|
-
return from(arg, encodingOrOffset, length)
|
|
13277
|
-
}
|
|
13278
|
-
|
|
13279
|
-
Buffer.poolSize = 8192; // not used by this implementation
|
|
13280
|
-
|
|
13281
|
-
function from (value, encodingOrOffset, length) {
|
|
13282
|
-
if (typeof value === 'string') {
|
|
13283
|
-
return fromString(value, encodingOrOffset)
|
|
13284
|
-
}
|
|
13285
|
-
|
|
13286
|
-
if (ArrayBuffer.isView(value)) {
|
|
13287
|
-
return fromArrayView(value)
|
|
13288
|
-
}
|
|
13289
|
-
|
|
13290
|
-
if (value == null) {
|
|
13291
|
-
throw new TypeError(
|
|
13292
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13293
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
13294
|
-
)
|
|
13295
|
-
}
|
|
13296
|
-
|
|
13297
|
-
if (isInstance(value, ArrayBuffer) ||
|
|
13298
|
-
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
13299
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13300
|
-
}
|
|
13301
|
-
|
|
13302
|
-
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
13303
|
-
(isInstance(value, SharedArrayBuffer) ||
|
|
13304
|
-
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
13305
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13306
|
-
}
|
|
13307
|
-
|
|
13308
|
-
if (typeof value === 'number') {
|
|
13309
|
-
throw new TypeError(
|
|
13310
|
-
'The "value" argument must not be of type number. Received type number'
|
|
13311
|
-
)
|
|
13312
|
-
}
|
|
13313
|
-
|
|
13314
|
-
const valueOf = value.valueOf && value.valueOf();
|
|
13315
|
-
if (valueOf != null && valueOf !== value) {
|
|
13316
|
-
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
13317
|
-
}
|
|
13318
|
-
|
|
13319
|
-
const b = fromObject(value);
|
|
13320
|
-
if (b) return b
|
|
13321
|
-
|
|
13322
|
-
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
13323
|
-
typeof value[Symbol.toPrimitive] === 'function') {
|
|
13324
|
-
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
|
13325
|
-
}
|
|
13326
|
-
|
|
13327
|
-
throw new TypeError(
|
|
13328
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13329
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
13330
|
-
)
|
|
13331
|
-
}
|
|
13332
|
-
|
|
13333
|
-
/**
|
|
13334
|
-
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
13335
|
-
* if value is a number.
|
|
13336
|
-
* Buffer.from(str[, encoding])
|
|
13337
|
-
* Buffer.from(array)
|
|
13338
|
-
* Buffer.from(buffer)
|
|
13339
|
-
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
13340
|
-
**/
|
|
13341
|
-
Buffer.from = function (value, encodingOrOffset, length) {
|
|
13342
|
-
return from(value, encodingOrOffset, length)
|
|
13343
|
-
};
|
|
13344
|
-
|
|
13345
|
-
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
13346
|
-
// https://github.com/feross/buffer/pull/148
|
|
13347
|
-
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
13348
|
-
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
13349
|
-
|
|
13350
|
-
function assertSize (size) {
|
|
13351
|
-
if (typeof size !== 'number') {
|
|
13352
|
-
throw new TypeError('"size" argument must be of type number')
|
|
13353
|
-
} else if (size < 0) {
|
|
13354
|
-
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
13355
|
-
}
|
|
13356
|
-
}
|
|
13357
|
-
|
|
13358
|
-
function alloc (size, fill, encoding) {
|
|
13359
|
-
assertSize(size);
|
|
13360
|
-
if (size <= 0) {
|
|
13361
|
-
return createBuffer(size)
|
|
13362
|
-
}
|
|
13363
|
-
if (fill !== undefined) {
|
|
13364
|
-
// Only pay attention to encoding if it's a string. This
|
|
13365
|
-
// prevents accidentally sending in a number that would
|
|
13366
|
-
// be interpreted as a start offset.
|
|
13367
|
-
return typeof encoding === 'string'
|
|
13368
|
-
? createBuffer(size).fill(fill, encoding)
|
|
13369
|
-
: createBuffer(size).fill(fill)
|
|
13370
|
-
}
|
|
13371
|
-
return createBuffer(size)
|
|
13372
|
-
}
|
|
13373
|
-
|
|
13374
|
-
/**
|
|
13375
|
-
* Creates a new filled Buffer instance.
|
|
13376
|
-
* alloc(size[, fill[, encoding]])
|
|
13377
|
-
**/
|
|
13378
|
-
Buffer.alloc = function (size, fill, encoding) {
|
|
13379
|
-
return alloc(size, fill, encoding)
|
|
13380
|
-
};
|
|
13381
|
-
|
|
13382
|
-
function allocUnsafe (size) {
|
|
13383
|
-
assertSize(size);
|
|
13384
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
13385
|
-
}
|
|
13386
|
-
|
|
13387
|
-
/**
|
|
13388
|
-
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13389
|
-
* */
|
|
13390
|
-
Buffer.allocUnsafe = function (size) {
|
|
13391
|
-
return allocUnsafe(size)
|
|
13392
|
-
};
|
|
13393
|
-
/**
|
|
13394
|
-
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13395
|
-
*/
|
|
13396
|
-
Buffer.allocUnsafeSlow = function (size) {
|
|
13397
|
-
return allocUnsafe(size)
|
|
13398
|
-
};
|
|
13399
|
-
|
|
13400
|
-
function fromString (string, encoding) {
|
|
13401
|
-
if (typeof encoding !== 'string' || encoding === '') {
|
|
13402
|
-
encoding = 'utf8';
|
|
13403
|
-
}
|
|
13404
|
-
|
|
13405
|
-
if (!Buffer.isEncoding(encoding)) {
|
|
13406
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
13407
|
-
}
|
|
13408
|
-
|
|
13409
|
-
const length = byteLength(string, encoding) | 0;
|
|
13410
|
-
let buf = createBuffer(length);
|
|
13411
|
-
|
|
13412
|
-
const actual = buf.write(string, encoding);
|
|
13413
|
-
|
|
13414
|
-
if (actual !== length) {
|
|
13415
|
-
// Writing a hex string, for example, that contains invalid characters will
|
|
13416
|
-
// cause everything after the first invalid character to be ignored. (e.g.
|
|
13417
|
-
// 'abxxcd' will be treated as 'ab')
|
|
13418
|
-
buf = buf.slice(0, actual);
|
|
13419
|
-
}
|
|
13420
|
-
|
|
13421
|
-
return buf
|
|
13422
|
-
}
|
|
13423
|
-
|
|
13424
|
-
function fromArrayLike (array) {
|
|
13425
|
-
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
13426
|
-
const buf = createBuffer(length);
|
|
13427
|
-
for (let i = 0; i < length; i += 1) {
|
|
13428
|
-
buf[i] = array[i] & 255;
|
|
13429
|
-
}
|
|
13430
|
-
return buf
|
|
13431
|
-
}
|
|
13432
|
-
|
|
13433
|
-
function fromArrayView (arrayView) {
|
|
13434
|
-
if (isInstance(arrayView, Uint8Array)) {
|
|
13435
|
-
const copy = new Uint8Array(arrayView);
|
|
13436
|
-
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
13437
|
-
}
|
|
13438
|
-
return fromArrayLike(arrayView)
|
|
13439
|
-
}
|
|
13440
|
-
|
|
13441
|
-
function fromArrayBuffer (array, byteOffset, length) {
|
|
13442
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
13443
|
-
throw new RangeError('"offset" is outside of buffer bounds')
|
|
13444
|
-
}
|
|
13445
|
-
|
|
13446
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
13447
|
-
throw new RangeError('"length" is outside of buffer bounds')
|
|
13448
|
-
}
|
|
13449
|
-
|
|
13450
|
-
let buf;
|
|
13451
|
-
if (byteOffset === undefined && length === undefined) {
|
|
13452
|
-
buf = new Uint8Array(array);
|
|
13453
|
-
} else if (length === undefined) {
|
|
13454
|
-
buf = new Uint8Array(array, byteOffset);
|
|
13455
|
-
} else {
|
|
13456
|
-
buf = new Uint8Array(array, byteOffset, length);
|
|
13457
|
-
}
|
|
13458
|
-
|
|
13459
|
-
// Return an augmented `Uint8Array` instance
|
|
13460
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13461
|
-
|
|
13462
|
-
return buf
|
|
13463
|
-
}
|
|
13464
|
-
|
|
13465
|
-
function fromObject (obj) {
|
|
13466
|
-
if (Buffer.isBuffer(obj)) {
|
|
13467
|
-
const len = checked(obj.length) | 0;
|
|
13468
|
-
const buf = createBuffer(len);
|
|
13469
|
-
|
|
13470
|
-
if (buf.length === 0) {
|
|
13471
|
-
return buf
|
|
13472
|
-
}
|
|
13473
|
-
|
|
13474
|
-
obj.copy(buf, 0, 0, len);
|
|
13475
|
-
return buf
|
|
13476
|
-
}
|
|
13477
|
-
|
|
13478
|
-
if (obj.length !== undefined) {
|
|
13479
|
-
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
13480
|
-
return createBuffer(0)
|
|
13481
|
-
}
|
|
13482
|
-
return fromArrayLike(obj)
|
|
13483
|
-
}
|
|
13484
|
-
|
|
13485
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
13486
|
-
return fromArrayLike(obj.data)
|
|
13487
|
-
}
|
|
13488
|
-
}
|
|
13489
|
-
|
|
13490
|
-
function checked (length) {
|
|
13491
|
-
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
13492
|
-
// length is NaN (which is otherwise coerced to zero.)
|
|
13493
|
-
if (length >= K_MAX_LENGTH) {
|
|
13494
|
-
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
13495
|
-
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
13496
|
-
}
|
|
13497
|
-
return length | 0
|
|
13498
|
-
}
|
|
13499
|
-
|
|
13500
|
-
function SlowBuffer (length) {
|
|
13501
|
-
if (+length != length) { // eslint-disable-line eqeqeq
|
|
13502
|
-
length = 0;
|
|
13503
|
-
}
|
|
13504
|
-
return Buffer.alloc(+length)
|
|
13505
|
-
}
|
|
13506
|
-
|
|
13507
|
-
Buffer.isBuffer = function isBuffer (b) {
|
|
13508
|
-
return b != null && b._isBuffer === true &&
|
|
13509
|
-
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
13510
|
-
};
|
|
13511
|
-
|
|
13512
|
-
Buffer.compare = function compare (a, b) {
|
|
13513
|
-
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
13514
|
-
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
13515
|
-
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
13516
|
-
throw new TypeError(
|
|
13517
|
-
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
13518
|
-
)
|
|
13519
|
-
}
|
|
13520
|
-
|
|
13521
|
-
if (a === b) return 0
|
|
13522
|
-
|
|
13523
|
-
let x = a.length;
|
|
13524
|
-
let y = b.length;
|
|
13525
|
-
|
|
13526
|
-
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
13527
|
-
if (a[i] !== b[i]) {
|
|
13528
|
-
x = a[i];
|
|
13529
|
-
y = b[i];
|
|
13530
|
-
break
|
|
13531
|
-
}
|
|
13532
|
-
}
|
|
13533
|
-
|
|
13534
|
-
if (x < y) return -1
|
|
13535
|
-
if (y < x) return 1
|
|
13536
|
-
return 0
|
|
13537
|
-
};
|
|
13538
|
-
|
|
13539
|
-
Buffer.isEncoding = function isEncoding (encoding) {
|
|
13540
|
-
switch (String(encoding).toLowerCase()) {
|
|
13541
|
-
case 'hex':
|
|
13542
|
-
case 'utf8':
|
|
13543
|
-
case 'utf-8':
|
|
13544
|
-
case 'ascii':
|
|
13545
|
-
case 'latin1':
|
|
13546
|
-
case 'binary':
|
|
13547
|
-
case 'base64':
|
|
13548
|
-
case 'ucs2':
|
|
13549
|
-
case 'ucs-2':
|
|
13550
|
-
case 'utf16le':
|
|
13551
|
-
case 'utf-16le':
|
|
13552
|
-
return true
|
|
13553
|
-
default:
|
|
13554
|
-
return false
|
|
13555
|
-
}
|
|
13556
|
-
};
|
|
13557
|
-
|
|
13558
|
-
Buffer.concat = function concat (list, length) {
|
|
13559
|
-
if (!Array.isArray(list)) {
|
|
13560
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13561
|
-
}
|
|
13562
|
-
|
|
13563
|
-
if (list.length === 0) {
|
|
13564
|
-
return Buffer.alloc(0)
|
|
13565
|
-
}
|
|
13566
|
-
|
|
13567
|
-
let i;
|
|
13568
|
-
if (length === undefined) {
|
|
13569
|
-
length = 0;
|
|
13570
|
-
for (i = 0; i < list.length; ++i) {
|
|
13571
|
-
length += list[i].length;
|
|
13572
|
-
}
|
|
13573
|
-
}
|
|
13574
|
-
|
|
13575
|
-
const buffer = Buffer.allocUnsafe(length);
|
|
13576
|
-
let pos = 0;
|
|
13577
|
-
for (i = 0; i < list.length; ++i) {
|
|
13578
|
-
let buf = list[i];
|
|
13579
|
-
if (isInstance(buf, Uint8Array)) {
|
|
13580
|
-
if (pos + buf.length > buffer.length) {
|
|
13581
|
-
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
|
|
13582
|
-
buf.copy(buffer, pos);
|
|
13583
|
-
} else {
|
|
13584
|
-
Uint8Array.prototype.set.call(
|
|
13585
|
-
buffer,
|
|
13586
|
-
buf,
|
|
13587
|
-
pos
|
|
13588
|
-
);
|
|
13589
|
-
}
|
|
13590
|
-
} else if (!Buffer.isBuffer(buf)) {
|
|
13591
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13592
|
-
} else {
|
|
13593
|
-
buf.copy(buffer, pos);
|
|
13594
|
-
}
|
|
13595
|
-
pos += buf.length;
|
|
13596
|
-
}
|
|
13597
|
-
return buffer
|
|
13598
|
-
};
|
|
13599
|
-
|
|
13600
|
-
function byteLength (string, encoding) {
|
|
13601
|
-
if (Buffer.isBuffer(string)) {
|
|
13602
|
-
return string.length
|
|
13603
|
-
}
|
|
13604
|
-
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
13605
|
-
return string.byteLength
|
|
13606
|
-
}
|
|
13607
|
-
if (typeof string !== 'string') {
|
|
13608
|
-
throw new TypeError(
|
|
13609
|
-
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
13610
|
-
'Received type ' + typeof string
|
|
13611
|
-
)
|
|
13612
|
-
}
|
|
13613
|
-
|
|
13614
|
-
const len = string.length;
|
|
13615
|
-
const mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
13616
|
-
if (!mustMatch && len === 0) return 0
|
|
13617
|
-
|
|
13618
|
-
// Use a for loop to avoid recursion
|
|
13619
|
-
let loweredCase = false;
|
|
13620
|
-
for (;;) {
|
|
13621
|
-
switch (encoding) {
|
|
13622
|
-
case 'ascii':
|
|
13623
|
-
case 'latin1':
|
|
13624
|
-
case 'binary':
|
|
13625
|
-
return len
|
|
13626
|
-
case 'utf8':
|
|
13627
|
-
case 'utf-8':
|
|
13628
|
-
return utf8ToBytes(string).length
|
|
13629
|
-
case 'ucs2':
|
|
13630
|
-
case 'ucs-2':
|
|
13631
|
-
case 'utf16le':
|
|
13632
|
-
case 'utf-16le':
|
|
13633
|
-
return len * 2
|
|
13634
|
-
case 'hex':
|
|
13635
|
-
return len >>> 1
|
|
13636
|
-
case 'base64':
|
|
13637
|
-
return base64ToBytes(string).length
|
|
13638
|
-
default:
|
|
13639
|
-
if (loweredCase) {
|
|
13640
|
-
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
13641
|
-
}
|
|
13642
|
-
encoding = ('' + encoding).toLowerCase();
|
|
13643
|
-
loweredCase = true;
|
|
13644
|
-
}
|
|
13645
|
-
}
|
|
13646
|
-
}
|
|
13647
|
-
Buffer.byteLength = byteLength;
|
|
13648
|
-
|
|
13649
|
-
function slowToString (encoding, start, end) {
|
|
13650
|
-
let loweredCase = false;
|
|
13651
|
-
|
|
13652
|
-
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
13653
|
-
// property of a typed array.
|
|
13654
|
-
|
|
13655
|
-
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
13656
|
-
// to their upper/lower bounds if the value passed is out of range.
|
|
13657
|
-
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
13658
|
-
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
13659
|
-
if (start === undefined || start < 0) {
|
|
13660
|
-
start = 0;
|
|
13661
|
-
}
|
|
13662
|
-
// Return early if start > this.length. Done here to prevent potential uint32
|
|
13663
|
-
// coercion fail below.
|
|
13664
|
-
if (start > this.length) {
|
|
13665
|
-
return ''
|
|
13666
|
-
}
|
|
13667
|
-
|
|
13668
|
-
if (end === undefined || end > this.length) {
|
|
13669
|
-
end = this.length;
|
|
13670
|
-
}
|
|
13671
|
-
|
|
13672
|
-
if (end <= 0) {
|
|
13673
|
-
return ''
|
|
13674
|
-
}
|
|
13675
|
-
|
|
13676
|
-
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
13677
|
-
end >>>= 0;
|
|
13678
|
-
start >>>= 0;
|
|
13679
|
-
|
|
13680
|
-
if (end <= start) {
|
|
13681
|
-
return ''
|
|
13682
|
-
}
|
|
13683
|
-
|
|
13684
|
-
if (!encoding) encoding = 'utf8';
|
|
13685
|
-
|
|
13686
|
-
while (true) {
|
|
13687
|
-
switch (encoding) {
|
|
13688
|
-
case 'hex':
|
|
13689
|
-
return hexSlice(this, start, end)
|
|
13690
|
-
|
|
13691
|
-
case 'utf8':
|
|
13692
|
-
case 'utf-8':
|
|
13693
|
-
return utf8Slice(this, start, end)
|
|
13694
|
-
|
|
13695
|
-
case 'ascii':
|
|
13696
|
-
return asciiSlice(this, start, end)
|
|
13697
|
-
|
|
13698
|
-
case 'latin1':
|
|
13699
|
-
case 'binary':
|
|
13700
|
-
return latin1Slice(this, start, end)
|
|
13701
|
-
|
|
13702
|
-
case 'base64':
|
|
13703
|
-
return base64Slice(this, start, end)
|
|
13704
|
-
|
|
13705
|
-
case 'ucs2':
|
|
13706
|
-
case 'ucs-2':
|
|
13707
|
-
case 'utf16le':
|
|
13708
|
-
case 'utf-16le':
|
|
13709
|
-
return utf16leSlice(this, start, end)
|
|
13710
|
-
|
|
13711
|
-
default:
|
|
13712
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
13713
|
-
encoding = (encoding + '').toLowerCase();
|
|
13714
|
-
loweredCase = true;
|
|
13715
|
-
}
|
|
13716
|
-
}
|
|
13717
|
-
}
|
|
13718
|
-
|
|
13719
|
-
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
13720
|
-
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
13721
|
-
// reliably in a browserify context because there could be multiple different
|
|
13722
|
-
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
13723
|
-
// instances that were created from another copy of the `buffer` package.
|
|
13724
|
-
// See: https://github.com/feross/buffer/issues/154
|
|
13725
|
-
Buffer.prototype._isBuffer = true;
|
|
13726
|
-
|
|
13727
|
-
function swap (b, n, m) {
|
|
13728
|
-
const i = b[n];
|
|
13729
|
-
b[n] = b[m];
|
|
13730
|
-
b[m] = i;
|
|
13731
|
-
}
|
|
13732
|
-
|
|
13733
|
-
Buffer.prototype.swap16 = function swap16 () {
|
|
13734
|
-
const len = this.length;
|
|
13735
|
-
if (len % 2 !== 0) {
|
|
13736
|
-
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
13737
|
-
}
|
|
13738
|
-
for (let i = 0; i < len; i += 2) {
|
|
13739
|
-
swap(this, i, i + 1);
|
|
13740
|
-
}
|
|
13741
|
-
return this
|
|
13742
|
-
};
|
|
13743
|
-
|
|
13744
|
-
Buffer.prototype.swap32 = function swap32 () {
|
|
13745
|
-
const len = this.length;
|
|
13746
|
-
if (len % 4 !== 0) {
|
|
13747
|
-
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
13748
|
-
}
|
|
13749
|
-
for (let i = 0; i < len; i += 4) {
|
|
13750
|
-
swap(this, i, i + 3);
|
|
13751
|
-
swap(this, i + 1, i + 2);
|
|
13752
|
-
}
|
|
13753
|
-
return this
|
|
13754
|
-
};
|
|
13755
|
-
|
|
13756
|
-
Buffer.prototype.swap64 = function swap64 () {
|
|
13757
|
-
const len = this.length;
|
|
13758
|
-
if (len % 8 !== 0) {
|
|
13759
|
-
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
13760
|
-
}
|
|
13761
|
-
for (let i = 0; i < len; i += 8) {
|
|
13762
|
-
swap(this, i, i + 7);
|
|
13763
|
-
swap(this, i + 1, i + 6);
|
|
13764
|
-
swap(this, i + 2, i + 5);
|
|
13765
|
-
swap(this, i + 3, i + 4);
|
|
13766
|
-
}
|
|
13767
|
-
return this
|
|
13768
|
-
};
|
|
13769
|
-
|
|
13770
|
-
Buffer.prototype.toString = function toString () {
|
|
13771
|
-
const length = this.length;
|
|
13772
|
-
if (length === 0) return ''
|
|
13773
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
13774
|
-
return slowToString.apply(this, arguments)
|
|
13775
|
-
};
|
|
13776
|
-
|
|
13777
|
-
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
13778
|
-
|
|
13779
|
-
Buffer.prototype.equals = function equals (b) {
|
|
13780
|
-
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
13781
|
-
if (this === b) return true
|
|
13782
|
-
return Buffer.compare(this, b) === 0
|
|
13783
|
-
};
|
|
13784
|
-
|
|
13785
|
-
Buffer.prototype.inspect = function inspect () {
|
|
13786
|
-
let str = '';
|
|
13787
|
-
const max = exports$1.INSPECT_MAX_BYTES;
|
|
13788
|
-
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
13789
|
-
if (this.length > max) str += ' ... ';
|
|
13790
|
-
return '<Buffer ' + str + '>'
|
|
13791
|
-
};
|
|
13792
|
-
if (customInspectSymbol) {
|
|
13793
|
-
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
13794
|
-
}
|
|
13795
|
-
|
|
13796
|
-
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
13797
|
-
if (isInstance(target, Uint8Array)) {
|
|
13798
|
-
target = Buffer.from(target, target.offset, target.byteLength);
|
|
13799
|
-
}
|
|
13800
|
-
if (!Buffer.isBuffer(target)) {
|
|
13801
|
-
throw new TypeError(
|
|
13802
|
-
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
13803
|
-
'Received type ' + (typeof target)
|
|
13804
|
-
)
|
|
13805
|
-
}
|
|
13806
|
-
|
|
13807
|
-
if (start === undefined) {
|
|
13808
|
-
start = 0;
|
|
13809
|
-
}
|
|
13810
|
-
if (end === undefined) {
|
|
13811
|
-
end = target ? target.length : 0;
|
|
13812
|
-
}
|
|
13813
|
-
if (thisStart === undefined) {
|
|
13814
|
-
thisStart = 0;
|
|
13815
|
-
}
|
|
13816
|
-
if (thisEnd === undefined) {
|
|
13817
|
-
thisEnd = this.length;
|
|
13818
|
-
}
|
|
13819
|
-
|
|
13820
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
13821
|
-
throw new RangeError('out of range index')
|
|
13822
|
-
}
|
|
13823
|
-
|
|
13824
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
13825
|
-
return 0
|
|
13826
|
-
}
|
|
13827
|
-
if (thisStart >= thisEnd) {
|
|
13828
|
-
return -1
|
|
13829
|
-
}
|
|
13830
|
-
if (start >= end) {
|
|
13831
|
-
return 1
|
|
13832
|
-
}
|
|
13833
|
-
|
|
13834
|
-
start >>>= 0;
|
|
13835
|
-
end >>>= 0;
|
|
13836
|
-
thisStart >>>= 0;
|
|
13837
|
-
thisEnd >>>= 0;
|
|
13838
|
-
|
|
13839
|
-
if (this === target) return 0
|
|
13840
|
-
|
|
13841
|
-
let x = thisEnd - thisStart;
|
|
13842
|
-
let y = end - start;
|
|
13843
|
-
const len = Math.min(x, y);
|
|
13844
|
-
|
|
13845
|
-
const thisCopy = this.slice(thisStart, thisEnd);
|
|
13846
|
-
const targetCopy = target.slice(start, end);
|
|
13847
|
-
|
|
13848
|
-
for (let i = 0; i < len; ++i) {
|
|
13849
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
13850
|
-
x = thisCopy[i];
|
|
13851
|
-
y = targetCopy[i];
|
|
13852
|
-
break
|
|
13853
|
-
}
|
|
13854
|
-
}
|
|
13855
|
-
|
|
13856
|
-
if (x < y) return -1
|
|
13857
|
-
if (y < x) return 1
|
|
13858
|
-
return 0
|
|
13859
|
-
};
|
|
13860
|
-
|
|
13861
|
-
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
13862
|
-
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
13863
|
-
//
|
|
13864
|
-
// Arguments:
|
|
13865
|
-
// - buffer - a Buffer to search
|
|
13866
|
-
// - val - a string, Buffer, or number
|
|
13867
|
-
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
13868
|
-
// - encoding - an optional encoding, relevant is val is a string
|
|
13869
|
-
// - dir - true for indexOf, false for lastIndexOf
|
|
13870
|
-
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
13871
|
-
// Empty buffer means no match
|
|
13872
|
-
if (buffer.length === 0) return -1
|
|
13873
|
-
|
|
13874
|
-
// Normalize byteOffset
|
|
13875
|
-
if (typeof byteOffset === 'string') {
|
|
13876
|
-
encoding = byteOffset;
|
|
13877
|
-
byteOffset = 0;
|
|
13878
|
-
} else if (byteOffset > 0x7fffffff) {
|
|
13879
|
-
byteOffset = 0x7fffffff;
|
|
13880
|
-
} else if (byteOffset < -2147483648) {
|
|
13881
|
-
byteOffset = -2147483648;
|
|
13882
|
-
}
|
|
13883
|
-
byteOffset = +byteOffset; // Coerce to Number.
|
|
13884
|
-
if (numberIsNaN(byteOffset)) {
|
|
13885
|
-
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
13886
|
-
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
13887
|
-
}
|
|
13888
|
-
|
|
13889
|
-
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
13890
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
13891
|
-
if (byteOffset >= buffer.length) {
|
|
13892
|
-
if (dir) return -1
|
|
13893
|
-
else byteOffset = buffer.length - 1;
|
|
13894
|
-
} else if (byteOffset < 0) {
|
|
13895
|
-
if (dir) byteOffset = 0;
|
|
13896
|
-
else return -1
|
|
13897
|
-
}
|
|
13898
|
-
|
|
13899
|
-
// Normalize val
|
|
13900
|
-
if (typeof val === 'string') {
|
|
13901
|
-
val = Buffer.from(val, encoding);
|
|
13902
|
-
}
|
|
13903
|
-
|
|
13904
|
-
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
13905
|
-
if (Buffer.isBuffer(val)) {
|
|
13906
|
-
// Special case: looking for empty string/buffer always fails
|
|
13907
|
-
if (val.length === 0) {
|
|
13908
|
-
return -1
|
|
13909
|
-
}
|
|
13910
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
13911
|
-
} else if (typeof val === 'number') {
|
|
13912
|
-
val = val & 0xFF; // Search for a byte value [0-255]
|
|
13913
|
-
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
13914
|
-
if (dir) {
|
|
13915
|
-
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
13916
|
-
} else {
|
|
13917
|
-
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
13918
|
-
}
|
|
13919
|
-
}
|
|
13920
|
-
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
13921
|
-
}
|
|
13922
|
-
|
|
13923
|
-
throw new TypeError('val must be string, number or Buffer')
|
|
13924
|
-
}
|
|
13925
|
-
|
|
13926
|
-
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
13927
|
-
let indexSize = 1;
|
|
13928
|
-
let arrLength = arr.length;
|
|
13929
|
-
let valLength = val.length;
|
|
13930
|
-
|
|
13931
|
-
if (encoding !== undefined) {
|
|
13932
|
-
encoding = String(encoding).toLowerCase();
|
|
13933
|
-
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
13934
|
-
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
13935
|
-
if (arr.length < 2 || val.length < 2) {
|
|
13936
|
-
return -1
|
|
13937
|
-
}
|
|
13938
|
-
indexSize = 2;
|
|
13939
|
-
arrLength /= 2;
|
|
13940
|
-
valLength /= 2;
|
|
13941
|
-
byteOffset /= 2;
|
|
13942
|
-
}
|
|
13943
|
-
}
|
|
13944
|
-
|
|
13945
|
-
function read (buf, i) {
|
|
13946
|
-
if (indexSize === 1) {
|
|
13947
|
-
return buf[i]
|
|
13948
|
-
} else {
|
|
13949
|
-
return buf.readUInt16BE(i * indexSize)
|
|
13950
|
-
}
|
|
13951
|
-
}
|
|
13952
|
-
|
|
13953
|
-
let i;
|
|
13954
|
-
if (dir) {
|
|
13955
|
-
let foundIndex = -1;
|
|
13956
|
-
for (i = byteOffset; i < arrLength; i++) {
|
|
13957
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
13958
|
-
if (foundIndex === -1) foundIndex = i;
|
|
13959
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
13960
|
-
} else {
|
|
13961
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
|
13962
|
-
foundIndex = -1;
|
|
13963
|
-
}
|
|
13964
|
-
}
|
|
13965
|
-
} else {
|
|
13966
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
13967
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
13968
|
-
let found = true;
|
|
13969
|
-
for (let j = 0; j < valLength; j++) {
|
|
13970
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
13971
|
-
found = false;
|
|
13972
|
-
break
|
|
13973
|
-
}
|
|
13974
|
-
}
|
|
13975
|
-
if (found) return i
|
|
13976
|
-
}
|
|
13977
|
-
}
|
|
13978
|
-
|
|
13979
|
-
return -1
|
|
13980
|
-
}
|
|
13981
|
-
|
|
13982
|
-
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
13983
|
-
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
13984
|
-
};
|
|
13985
|
-
|
|
13986
|
-
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
13987
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
13988
|
-
};
|
|
13989
|
-
|
|
13990
|
-
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
13991
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
13992
|
-
};
|
|
13993
|
-
|
|
13994
|
-
function hexWrite (buf, string, offset, length) {
|
|
13995
|
-
offset = Number(offset) || 0;
|
|
13996
|
-
const remaining = buf.length - offset;
|
|
13997
|
-
if (!length) {
|
|
13998
|
-
length = remaining;
|
|
13999
|
-
} else {
|
|
14000
|
-
length = Number(length);
|
|
14001
|
-
if (length > remaining) {
|
|
14002
|
-
length = remaining;
|
|
14003
|
-
}
|
|
14004
|
-
}
|
|
14005
|
-
|
|
14006
|
-
const strLen = string.length;
|
|
14007
|
-
|
|
14008
|
-
if (length > strLen / 2) {
|
|
14009
|
-
length = strLen / 2;
|
|
14010
|
-
}
|
|
14011
|
-
let i;
|
|
14012
|
-
for (i = 0; i < length; ++i) {
|
|
14013
|
-
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
14014
|
-
if (numberIsNaN(parsed)) return i
|
|
14015
|
-
buf[offset + i] = parsed;
|
|
14016
|
-
}
|
|
14017
|
-
return i
|
|
14018
|
-
}
|
|
14019
|
-
|
|
14020
|
-
function utf8Write (buf, string, offset, length) {
|
|
14021
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
14022
|
-
}
|
|
14023
|
-
|
|
14024
|
-
function asciiWrite (buf, string, offset, length) {
|
|
14025
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
14026
|
-
}
|
|
14027
|
-
|
|
14028
|
-
function base64Write (buf, string, offset, length) {
|
|
14029
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
14030
|
-
}
|
|
14031
|
-
|
|
14032
|
-
function ucs2Write (buf, string, offset, length) {
|
|
14033
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
14034
|
-
}
|
|
14035
|
-
|
|
14036
|
-
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
14037
|
-
// Buffer#write(string)
|
|
14038
|
-
if (offset === undefined) {
|
|
14039
|
-
encoding = 'utf8';
|
|
14040
|
-
length = this.length;
|
|
14041
|
-
offset = 0;
|
|
14042
|
-
// Buffer#write(string, encoding)
|
|
14043
|
-
} else if (length === undefined && typeof offset === 'string') {
|
|
14044
|
-
encoding = offset;
|
|
14045
|
-
length = this.length;
|
|
14046
|
-
offset = 0;
|
|
14047
|
-
// Buffer#write(string, offset[, length][, encoding])
|
|
14048
|
-
} else if (isFinite(offset)) {
|
|
14049
|
-
offset = offset >>> 0;
|
|
14050
|
-
if (isFinite(length)) {
|
|
14051
|
-
length = length >>> 0;
|
|
14052
|
-
if (encoding === undefined) encoding = 'utf8';
|
|
14053
|
-
} else {
|
|
14054
|
-
encoding = length;
|
|
14055
|
-
length = undefined;
|
|
14056
|
-
}
|
|
14057
|
-
} else {
|
|
14058
|
-
throw new Error(
|
|
14059
|
-
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
14060
|
-
)
|
|
14061
|
-
}
|
|
14062
|
-
|
|
14063
|
-
const remaining = this.length - offset;
|
|
14064
|
-
if (length === undefined || length > remaining) length = remaining;
|
|
14065
|
-
|
|
14066
|
-
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
14067
|
-
throw new RangeError('Attempt to write outside buffer bounds')
|
|
14068
|
-
}
|
|
14069
|
-
|
|
14070
|
-
if (!encoding) encoding = 'utf8';
|
|
14071
|
-
|
|
14072
|
-
let loweredCase = false;
|
|
14073
|
-
for (;;) {
|
|
14074
|
-
switch (encoding) {
|
|
14075
|
-
case 'hex':
|
|
14076
|
-
return hexWrite(this, string, offset, length)
|
|
14077
|
-
|
|
14078
|
-
case 'utf8':
|
|
14079
|
-
case 'utf-8':
|
|
14080
|
-
return utf8Write(this, string, offset, length)
|
|
14081
|
-
|
|
14082
|
-
case 'ascii':
|
|
14083
|
-
case 'latin1':
|
|
14084
|
-
case 'binary':
|
|
14085
|
-
return asciiWrite(this, string, offset, length)
|
|
14086
|
-
|
|
14087
|
-
case 'base64':
|
|
14088
|
-
// Warning: maxLength not taken into account in base64Write
|
|
14089
|
-
return base64Write(this, string, offset, length)
|
|
14090
|
-
|
|
14091
|
-
case 'ucs2':
|
|
14092
|
-
case 'ucs-2':
|
|
14093
|
-
case 'utf16le':
|
|
14094
|
-
case 'utf-16le':
|
|
14095
|
-
return ucs2Write(this, string, offset, length)
|
|
14096
|
-
|
|
14097
|
-
default:
|
|
14098
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
14099
|
-
encoding = ('' + encoding).toLowerCase();
|
|
14100
|
-
loweredCase = true;
|
|
14101
|
-
}
|
|
14102
|
-
}
|
|
14103
|
-
};
|
|
14104
|
-
|
|
14105
|
-
Buffer.prototype.toJSON = function toJSON () {
|
|
14106
|
-
return {
|
|
14107
|
-
type: 'Buffer',
|
|
14108
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
14109
|
-
}
|
|
14110
|
-
};
|
|
14111
|
-
|
|
14112
|
-
function base64Slice (buf, start, end) {
|
|
14113
|
-
if (start === 0 && end === buf.length) {
|
|
14114
|
-
return base64.fromByteArray(buf)
|
|
14115
|
-
} else {
|
|
14116
|
-
return base64.fromByteArray(buf.slice(start, end))
|
|
14117
|
-
}
|
|
14118
|
-
}
|
|
14119
|
-
|
|
14120
|
-
function utf8Slice (buf, start, end) {
|
|
14121
|
-
end = Math.min(buf.length, end);
|
|
14122
|
-
const res = [];
|
|
14123
|
-
|
|
14124
|
-
let i = start;
|
|
14125
|
-
while (i < end) {
|
|
14126
|
-
const firstByte = buf[i];
|
|
14127
|
-
let codePoint = null;
|
|
14128
|
-
let bytesPerSequence = (firstByte > 0xEF)
|
|
14129
|
-
? 4
|
|
14130
|
-
: (firstByte > 0xDF)
|
|
14131
|
-
? 3
|
|
14132
|
-
: (firstByte > 0xBF)
|
|
14133
|
-
? 2
|
|
14134
|
-
: 1;
|
|
14135
|
-
|
|
14136
|
-
if (i + bytesPerSequence <= end) {
|
|
14137
|
-
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
14138
|
-
|
|
14139
|
-
switch (bytesPerSequence) {
|
|
14140
|
-
case 1:
|
|
14141
|
-
if (firstByte < 0x80) {
|
|
14142
|
-
codePoint = firstByte;
|
|
14143
|
-
}
|
|
14144
|
-
break
|
|
14145
|
-
case 2:
|
|
14146
|
-
secondByte = buf[i + 1];
|
|
14147
|
-
if ((secondByte & 0xC0) === 0x80) {
|
|
14148
|
-
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
14149
|
-
if (tempCodePoint > 0x7F) {
|
|
14150
|
-
codePoint = tempCodePoint;
|
|
14151
|
-
}
|
|
14152
|
-
}
|
|
14153
|
-
break
|
|
14154
|
-
case 3:
|
|
14155
|
-
secondByte = buf[i + 1];
|
|
14156
|
-
thirdByte = buf[i + 2];
|
|
14157
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
14158
|
-
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
14159
|
-
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
14160
|
-
codePoint = tempCodePoint;
|
|
14161
|
-
}
|
|
14162
|
-
}
|
|
14163
|
-
break
|
|
14164
|
-
case 4:
|
|
14165
|
-
secondByte = buf[i + 1];
|
|
14166
|
-
thirdByte = buf[i + 2];
|
|
14167
|
-
fourthByte = buf[i + 3];
|
|
14168
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
14169
|
-
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
14170
|
-
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
14171
|
-
codePoint = tempCodePoint;
|
|
14172
|
-
}
|
|
14173
|
-
}
|
|
14174
|
-
}
|
|
14175
|
-
}
|
|
14176
|
-
|
|
14177
|
-
if (codePoint === null) {
|
|
14178
|
-
// we did not generate a valid codePoint so insert a
|
|
14179
|
-
// replacement char (U+FFFD) and advance only 1 byte
|
|
14180
|
-
codePoint = 0xFFFD;
|
|
14181
|
-
bytesPerSequence = 1;
|
|
14182
|
-
} else if (codePoint > 0xFFFF) {
|
|
14183
|
-
// encode to utf16 (surrogate pair dance)
|
|
14184
|
-
codePoint -= 0x10000;
|
|
14185
|
-
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
14186
|
-
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
14187
|
-
}
|
|
14188
|
-
|
|
14189
|
-
res.push(codePoint);
|
|
14190
|
-
i += bytesPerSequence;
|
|
14191
|
-
}
|
|
14192
|
-
|
|
14193
|
-
return decodeCodePointsArray(res)
|
|
14194
|
-
}
|
|
14195
|
-
|
|
14196
|
-
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
14197
|
-
// the lowest limit is Chrome, with 0x10000 args.
|
|
14198
|
-
// We go 1 magnitude less, for safety
|
|
14199
|
-
const MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
14200
|
-
|
|
14201
|
-
function decodeCodePointsArray (codePoints) {
|
|
14202
|
-
const len = codePoints.length;
|
|
14203
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
14204
|
-
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
14205
|
-
}
|
|
14206
|
-
|
|
14207
|
-
// Decode in chunks to avoid "call stack size exceeded".
|
|
14208
|
-
let res = '';
|
|
14209
|
-
let i = 0;
|
|
14210
|
-
while (i < len) {
|
|
14211
|
-
res += String.fromCharCode.apply(
|
|
14212
|
-
String,
|
|
14213
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
14214
|
-
);
|
|
14215
|
-
}
|
|
14216
|
-
return res
|
|
14217
|
-
}
|
|
14218
|
-
|
|
14219
|
-
function asciiSlice (buf, start, end) {
|
|
14220
|
-
let ret = '';
|
|
14221
|
-
end = Math.min(buf.length, end);
|
|
14222
|
-
|
|
14223
|
-
for (let i = start; i < end; ++i) {
|
|
14224
|
-
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
14225
|
-
}
|
|
14226
|
-
return ret
|
|
14227
|
-
}
|
|
14228
|
-
|
|
14229
|
-
function latin1Slice (buf, start, end) {
|
|
14230
|
-
let ret = '';
|
|
14231
|
-
end = Math.min(buf.length, end);
|
|
14232
|
-
|
|
14233
|
-
for (let i = start; i < end; ++i) {
|
|
14234
|
-
ret += String.fromCharCode(buf[i]);
|
|
14235
|
-
}
|
|
14236
|
-
return ret
|
|
14237
|
-
}
|
|
14238
|
-
|
|
14239
|
-
function hexSlice (buf, start, end) {
|
|
14240
|
-
const len = buf.length;
|
|
14241
|
-
|
|
14242
|
-
if (!start || start < 0) start = 0;
|
|
14243
|
-
if (!end || end < 0 || end > len) end = len;
|
|
14244
|
-
|
|
14245
|
-
let out = '';
|
|
14246
|
-
for (let i = start; i < end; ++i) {
|
|
14247
|
-
out += hexSliceLookupTable[buf[i]];
|
|
14248
|
-
}
|
|
14249
|
-
return out
|
|
14250
|
-
}
|
|
14251
|
-
|
|
14252
|
-
function utf16leSlice (buf, start, end) {
|
|
14253
|
-
const bytes = buf.slice(start, end);
|
|
14254
|
-
let res = '';
|
|
14255
|
-
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
14256
|
-
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
14257
|
-
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
14258
|
-
}
|
|
14259
|
-
return res
|
|
14260
|
-
}
|
|
14261
|
-
|
|
14262
|
-
Buffer.prototype.slice = function slice (start, end) {
|
|
14263
|
-
const len = this.length;
|
|
14264
|
-
start = ~~start;
|
|
14265
|
-
end = end === undefined ? len : ~~end;
|
|
14266
|
-
|
|
14267
|
-
if (start < 0) {
|
|
14268
|
-
start += len;
|
|
14269
|
-
if (start < 0) start = 0;
|
|
14270
|
-
} else if (start > len) {
|
|
14271
|
-
start = len;
|
|
14272
|
-
}
|
|
14273
|
-
|
|
14274
|
-
if (end < 0) {
|
|
14275
|
-
end += len;
|
|
14276
|
-
if (end < 0) end = 0;
|
|
14277
|
-
} else if (end > len) {
|
|
14278
|
-
end = len;
|
|
14279
|
-
}
|
|
14280
|
-
|
|
14281
|
-
if (end < start) end = start;
|
|
14282
|
-
|
|
14283
|
-
const newBuf = this.subarray(start, end);
|
|
14284
|
-
// Return an augmented `Uint8Array` instance
|
|
14285
|
-
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
14286
|
-
|
|
14287
|
-
return newBuf
|
|
14288
|
-
};
|
|
14289
|
-
|
|
14290
|
-
/*
|
|
14291
|
-
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
14292
|
-
*/
|
|
14293
|
-
function checkOffset (offset, ext, length) {
|
|
14294
|
-
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
14295
|
-
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
14296
|
-
}
|
|
14297
|
-
|
|
14298
|
-
Buffer.prototype.readUintLE =
|
|
14299
|
-
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
14300
|
-
offset = offset >>> 0;
|
|
14301
|
-
byteLength = byteLength >>> 0;
|
|
14302
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14303
|
-
|
|
14304
|
-
let val = this[offset];
|
|
14305
|
-
let mul = 1;
|
|
14306
|
-
let i = 0;
|
|
14307
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
14308
|
-
val += this[offset + i] * mul;
|
|
14309
|
-
}
|
|
14310
|
-
|
|
14311
|
-
return val
|
|
14312
|
-
};
|
|
14313
|
-
|
|
14314
|
-
Buffer.prototype.readUintBE =
|
|
14315
|
-
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
14316
|
-
offset = offset >>> 0;
|
|
14317
|
-
byteLength = byteLength >>> 0;
|
|
14318
|
-
if (!noAssert) {
|
|
14319
|
-
checkOffset(offset, byteLength, this.length);
|
|
14320
|
-
}
|
|
14321
|
-
|
|
14322
|
-
let val = this[offset + --byteLength];
|
|
14323
|
-
let mul = 1;
|
|
14324
|
-
while (byteLength > 0 && (mul *= 0x100)) {
|
|
14325
|
-
val += this[offset + --byteLength] * mul;
|
|
14326
|
-
}
|
|
14327
|
-
|
|
14328
|
-
return val
|
|
14329
|
-
};
|
|
14330
|
-
|
|
14331
|
-
Buffer.prototype.readUint8 =
|
|
14332
|
-
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
14333
|
-
offset = offset >>> 0;
|
|
14334
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14335
|
-
return this[offset]
|
|
14336
|
-
};
|
|
14337
|
-
|
|
14338
|
-
Buffer.prototype.readUint16LE =
|
|
14339
|
-
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
14340
|
-
offset = offset >>> 0;
|
|
14341
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14342
|
-
return this[offset] | (this[offset + 1] << 8)
|
|
14343
|
-
};
|
|
14344
|
-
|
|
14345
|
-
Buffer.prototype.readUint16BE =
|
|
14346
|
-
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
14347
|
-
offset = offset >>> 0;
|
|
14348
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14349
|
-
return (this[offset] << 8) | this[offset + 1]
|
|
14350
|
-
};
|
|
14351
|
-
|
|
14352
|
-
Buffer.prototype.readUint32LE =
|
|
14353
|
-
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
14354
|
-
offset = offset >>> 0;
|
|
14355
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14356
|
-
|
|
14357
|
-
return ((this[offset]) |
|
|
14358
|
-
(this[offset + 1] << 8) |
|
|
14359
|
-
(this[offset + 2] << 16)) +
|
|
14360
|
-
(this[offset + 3] * 0x1000000)
|
|
14361
|
-
};
|
|
14362
|
-
|
|
14363
|
-
Buffer.prototype.readUint32BE =
|
|
14364
|
-
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
14365
|
-
offset = offset >>> 0;
|
|
14366
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14367
|
-
|
|
14368
|
-
return (this[offset] * 0x1000000) +
|
|
14369
|
-
((this[offset + 1] << 16) |
|
|
14370
|
-
(this[offset + 2] << 8) |
|
|
14371
|
-
this[offset + 3])
|
|
14372
|
-
};
|
|
14373
|
-
|
|
14374
|
-
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
|
14375
|
-
offset = offset >>> 0;
|
|
14376
|
-
validateNumber(offset, 'offset');
|
|
14377
|
-
const first = this[offset];
|
|
14378
|
-
const last = this[offset + 7];
|
|
14379
|
-
if (first === undefined || last === undefined) {
|
|
14380
|
-
boundsError(offset, this.length - 8);
|
|
14381
|
-
}
|
|
14382
|
-
|
|
14383
|
-
const lo = first +
|
|
14384
|
-
this[++offset] * 2 ** 8 +
|
|
14385
|
-
this[++offset] * 2 ** 16 +
|
|
14386
|
-
this[++offset] * 2 ** 24;
|
|
14387
|
-
|
|
14388
|
-
const hi = this[++offset] +
|
|
14389
|
-
this[++offset] * 2 ** 8 +
|
|
14390
|
-
this[++offset] * 2 ** 16 +
|
|
14391
|
-
last * 2 ** 24;
|
|
14392
|
-
|
|
14393
|
-
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
|
14394
|
-
});
|
|
14395
|
-
|
|
14396
|
-
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
|
14397
|
-
offset = offset >>> 0;
|
|
14398
|
-
validateNumber(offset, 'offset');
|
|
14399
|
-
const first = this[offset];
|
|
14400
|
-
const last = this[offset + 7];
|
|
14401
|
-
if (first === undefined || last === undefined) {
|
|
14402
|
-
boundsError(offset, this.length - 8);
|
|
14403
|
-
}
|
|
14404
|
-
|
|
14405
|
-
const hi = first * 2 ** 24 +
|
|
14406
|
-
this[++offset] * 2 ** 16 +
|
|
14407
|
-
this[++offset] * 2 ** 8 +
|
|
14408
|
-
this[++offset];
|
|
14409
|
-
|
|
14410
|
-
const lo = this[++offset] * 2 ** 24 +
|
|
14411
|
-
this[++offset] * 2 ** 16 +
|
|
14412
|
-
this[++offset] * 2 ** 8 +
|
|
14413
|
-
last;
|
|
14414
|
-
|
|
14415
|
-
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
14416
|
-
});
|
|
14417
|
-
|
|
14418
|
-
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
14419
|
-
offset = offset >>> 0;
|
|
14420
|
-
byteLength = byteLength >>> 0;
|
|
14421
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14422
|
-
|
|
14423
|
-
let val = this[offset];
|
|
14424
|
-
let mul = 1;
|
|
14425
|
-
let i = 0;
|
|
14426
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
14427
|
-
val += this[offset + i] * mul;
|
|
14428
|
-
}
|
|
14429
|
-
mul *= 0x80;
|
|
14430
|
-
|
|
14431
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14432
|
-
|
|
14433
|
-
return val
|
|
14434
|
-
};
|
|
14435
|
-
|
|
14436
|
-
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
14437
|
-
offset = offset >>> 0;
|
|
14438
|
-
byteLength = byteLength >>> 0;
|
|
14439
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14440
|
-
|
|
14441
|
-
let i = byteLength;
|
|
14442
|
-
let mul = 1;
|
|
14443
|
-
let val = this[offset + --i];
|
|
14444
|
-
while (i > 0 && (mul *= 0x100)) {
|
|
14445
|
-
val += this[offset + --i] * mul;
|
|
14446
|
-
}
|
|
14447
|
-
mul *= 0x80;
|
|
14448
|
-
|
|
14449
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14450
|
-
|
|
14451
|
-
return val
|
|
14452
|
-
};
|
|
14453
|
-
|
|
14454
|
-
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
14455
|
-
offset = offset >>> 0;
|
|
14456
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14457
|
-
if (!(this[offset] & 0x80)) return (this[offset])
|
|
14458
|
-
return ((0xff - this[offset] + 1) * -1)
|
|
14459
|
-
};
|
|
14460
|
-
|
|
14461
|
-
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
14462
|
-
offset = offset >>> 0;
|
|
14463
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14464
|
-
const val = this[offset] | (this[offset + 1] << 8);
|
|
14465
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14466
|
-
};
|
|
14467
|
-
|
|
14468
|
-
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
14469
|
-
offset = offset >>> 0;
|
|
14470
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14471
|
-
const val = this[offset + 1] | (this[offset] << 8);
|
|
14472
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14473
|
-
};
|
|
14474
|
-
|
|
14475
|
-
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
14476
|
-
offset = offset >>> 0;
|
|
14477
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14478
|
-
|
|
14479
|
-
return (this[offset]) |
|
|
14480
|
-
(this[offset + 1] << 8) |
|
|
14481
|
-
(this[offset + 2] << 16) |
|
|
14482
|
-
(this[offset + 3] << 24)
|
|
14483
|
-
};
|
|
14484
|
-
|
|
14485
|
-
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
14486
|
-
offset = offset >>> 0;
|
|
14487
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14488
|
-
|
|
14489
|
-
return (this[offset] << 24) |
|
|
14490
|
-
(this[offset + 1] << 16) |
|
|
14491
|
-
(this[offset + 2] << 8) |
|
|
14492
|
-
(this[offset + 3])
|
|
14493
|
-
};
|
|
14494
|
-
|
|
14495
|
-
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
|
|
14496
|
-
offset = offset >>> 0;
|
|
14497
|
-
validateNumber(offset, 'offset');
|
|
14498
|
-
const first = this[offset];
|
|
14499
|
-
const last = this[offset + 7];
|
|
14500
|
-
if (first === undefined || last === undefined) {
|
|
14501
|
-
boundsError(offset, this.length - 8);
|
|
14502
|
-
}
|
|
14503
|
-
|
|
14504
|
-
const val = this[offset + 4] +
|
|
14505
|
-
this[offset + 5] * 2 ** 8 +
|
|
14506
|
-
this[offset + 6] * 2 ** 16 +
|
|
14507
|
-
(last << 24); // Overflow
|
|
14508
|
-
|
|
14509
|
-
return (BigInt(val) << BigInt(32)) +
|
|
14510
|
-
BigInt(first +
|
|
14511
|
-
this[++offset] * 2 ** 8 +
|
|
14512
|
-
this[++offset] * 2 ** 16 +
|
|
14513
|
-
this[++offset] * 2 ** 24)
|
|
14514
|
-
});
|
|
14515
|
-
|
|
14516
|
-
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
|
14517
|
-
offset = offset >>> 0;
|
|
14518
|
-
validateNumber(offset, 'offset');
|
|
14519
|
-
const first = this[offset];
|
|
14520
|
-
const last = this[offset + 7];
|
|
14521
|
-
if (first === undefined || last === undefined) {
|
|
14522
|
-
boundsError(offset, this.length - 8);
|
|
14523
|
-
}
|
|
14524
|
-
|
|
14525
|
-
const val = (first << 24) + // Overflow
|
|
14526
|
-
this[++offset] * 2 ** 16 +
|
|
14527
|
-
this[++offset] * 2 ** 8 +
|
|
14528
|
-
this[++offset];
|
|
14529
|
-
|
|
14530
|
-
return (BigInt(val) << BigInt(32)) +
|
|
14531
|
-
BigInt(this[++offset] * 2 ** 24 +
|
|
14532
|
-
this[++offset] * 2 ** 16 +
|
|
14533
|
-
this[++offset] * 2 ** 8 +
|
|
14534
|
-
last)
|
|
14535
|
-
});
|
|
14536
|
-
|
|
14537
|
-
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
14538
|
-
offset = offset >>> 0;
|
|
14539
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14540
|
-
return ieee754.read(this, offset, true, 23, 4)
|
|
14541
|
-
};
|
|
14542
|
-
|
|
14543
|
-
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
14544
|
-
offset = offset >>> 0;
|
|
14545
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14546
|
-
return ieee754.read(this, offset, false, 23, 4)
|
|
14547
|
-
};
|
|
14548
|
-
|
|
14549
|
-
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
14550
|
-
offset = offset >>> 0;
|
|
14551
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14552
|
-
return ieee754.read(this, offset, true, 52, 8)
|
|
14553
|
-
};
|
|
14554
|
-
|
|
14555
|
-
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
14556
|
-
offset = offset >>> 0;
|
|
14557
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14558
|
-
return ieee754.read(this, offset, false, 52, 8)
|
|
14559
|
-
};
|
|
14560
|
-
|
|
14561
|
-
function checkInt (buf, value, offset, ext, max, min) {
|
|
14562
|
-
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
14563
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
14564
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
14565
|
-
}
|
|
14566
|
-
|
|
14567
|
-
Buffer.prototype.writeUintLE =
|
|
14568
|
-
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
14569
|
-
value = +value;
|
|
14570
|
-
offset = offset >>> 0;
|
|
14571
|
-
byteLength = byteLength >>> 0;
|
|
14572
|
-
if (!noAssert) {
|
|
14573
|
-
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14574
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14575
|
-
}
|
|
14576
|
-
|
|
14577
|
-
let mul = 1;
|
|
14578
|
-
let i = 0;
|
|
14579
|
-
this[offset] = value & 0xFF;
|
|
14580
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
14581
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
14582
|
-
}
|
|
14583
|
-
|
|
14584
|
-
return offset + byteLength
|
|
14585
|
-
};
|
|
14586
|
-
|
|
14587
|
-
Buffer.prototype.writeUintBE =
|
|
14588
|
-
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
14589
|
-
value = +value;
|
|
14590
|
-
offset = offset >>> 0;
|
|
14591
|
-
byteLength = byteLength >>> 0;
|
|
14592
|
-
if (!noAssert) {
|
|
14593
|
-
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14594
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14595
|
-
}
|
|
14596
|
-
|
|
14597
|
-
let i = byteLength - 1;
|
|
14598
|
-
let mul = 1;
|
|
14599
|
-
this[offset + i] = value & 0xFF;
|
|
14600
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
14601
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
14602
|
-
}
|
|
14603
|
-
|
|
14604
|
-
return offset + byteLength
|
|
14605
|
-
};
|
|
14606
|
-
|
|
14607
|
-
Buffer.prototype.writeUint8 =
|
|
14608
|
-
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
14609
|
-
value = +value;
|
|
14610
|
-
offset = offset >>> 0;
|
|
14611
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
14612
|
-
this[offset] = (value & 0xff);
|
|
14613
|
-
return offset + 1
|
|
14614
|
-
};
|
|
14615
|
-
|
|
14616
|
-
Buffer.prototype.writeUint16LE =
|
|
14617
|
-
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
14618
|
-
value = +value;
|
|
14619
|
-
offset = offset >>> 0;
|
|
14620
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
14621
|
-
this[offset] = (value & 0xff);
|
|
14622
|
-
this[offset + 1] = (value >>> 8);
|
|
14623
|
-
return offset + 2
|
|
14624
|
-
};
|
|
14625
|
-
|
|
14626
|
-
Buffer.prototype.writeUint16BE =
|
|
14627
|
-
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
14628
|
-
value = +value;
|
|
14629
|
-
offset = offset >>> 0;
|
|
14630
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
14631
|
-
this[offset] = (value >>> 8);
|
|
14632
|
-
this[offset + 1] = (value & 0xff);
|
|
14633
|
-
return offset + 2
|
|
14634
|
-
};
|
|
14635
|
-
|
|
14636
|
-
Buffer.prototype.writeUint32LE =
|
|
14637
|
-
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
14638
|
-
value = +value;
|
|
14639
|
-
offset = offset >>> 0;
|
|
14640
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
14641
|
-
this[offset + 3] = (value >>> 24);
|
|
14642
|
-
this[offset + 2] = (value >>> 16);
|
|
14643
|
-
this[offset + 1] = (value >>> 8);
|
|
14644
|
-
this[offset] = (value & 0xff);
|
|
14645
|
-
return offset + 4
|
|
14646
|
-
};
|
|
14647
|
-
|
|
14648
|
-
Buffer.prototype.writeUint32BE =
|
|
14649
|
-
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
14650
|
-
value = +value;
|
|
14651
|
-
offset = offset >>> 0;
|
|
14652
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
14653
|
-
this[offset] = (value >>> 24);
|
|
14654
|
-
this[offset + 1] = (value >>> 16);
|
|
14655
|
-
this[offset + 2] = (value >>> 8);
|
|
14656
|
-
this[offset + 3] = (value & 0xff);
|
|
14657
|
-
return offset + 4
|
|
14658
|
-
};
|
|
14659
|
-
|
|
14660
|
-
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
|
14661
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
|
14662
|
-
|
|
14663
|
-
let lo = Number(value & BigInt(0xffffffff));
|
|
14664
|
-
buf[offset++] = lo;
|
|
14665
|
-
lo = lo >> 8;
|
|
14666
|
-
buf[offset++] = lo;
|
|
14667
|
-
lo = lo >> 8;
|
|
14668
|
-
buf[offset++] = lo;
|
|
14669
|
-
lo = lo >> 8;
|
|
14670
|
-
buf[offset++] = lo;
|
|
14671
|
-
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
14672
|
-
buf[offset++] = hi;
|
|
14673
|
-
hi = hi >> 8;
|
|
14674
|
-
buf[offset++] = hi;
|
|
14675
|
-
hi = hi >> 8;
|
|
14676
|
-
buf[offset++] = hi;
|
|
14677
|
-
hi = hi >> 8;
|
|
14678
|
-
buf[offset++] = hi;
|
|
14679
|
-
return offset
|
|
14680
|
-
}
|
|
14681
|
-
|
|
14682
|
-
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
|
14683
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
|
14684
|
-
|
|
14685
|
-
let lo = Number(value & BigInt(0xffffffff));
|
|
14686
|
-
buf[offset + 7] = lo;
|
|
14687
|
-
lo = lo >> 8;
|
|
14688
|
-
buf[offset + 6] = lo;
|
|
14689
|
-
lo = lo >> 8;
|
|
14690
|
-
buf[offset + 5] = lo;
|
|
14691
|
-
lo = lo >> 8;
|
|
14692
|
-
buf[offset + 4] = lo;
|
|
14693
|
-
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
14694
|
-
buf[offset + 3] = hi;
|
|
14695
|
-
hi = hi >> 8;
|
|
14696
|
-
buf[offset + 2] = hi;
|
|
14697
|
-
hi = hi >> 8;
|
|
14698
|
-
buf[offset + 1] = hi;
|
|
14699
|
-
hi = hi >> 8;
|
|
14700
|
-
buf[offset] = hi;
|
|
14701
|
-
return offset + 8
|
|
14702
|
-
}
|
|
14703
|
-
|
|
14704
|
-
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
14705
|
-
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
14706
|
-
});
|
|
14707
|
-
|
|
14708
|
-
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
14709
|
-
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
14710
|
-
});
|
|
14711
|
-
|
|
14712
|
-
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
14713
|
-
value = +value;
|
|
14714
|
-
offset = offset >>> 0;
|
|
14715
|
-
if (!noAssert) {
|
|
14716
|
-
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
14717
|
-
|
|
14718
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
14719
|
-
}
|
|
14720
|
-
|
|
14721
|
-
let i = 0;
|
|
14722
|
-
let mul = 1;
|
|
14723
|
-
let sub = 0;
|
|
14724
|
-
this[offset] = value & 0xFF;
|
|
14725
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
14726
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
14727
|
-
sub = 1;
|
|
14728
|
-
}
|
|
14729
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
14730
|
-
}
|
|
14731
|
-
|
|
14732
|
-
return offset + byteLength
|
|
14733
|
-
};
|
|
14734
|
-
|
|
14735
|
-
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
14736
|
-
value = +value;
|
|
14737
|
-
offset = offset >>> 0;
|
|
14738
|
-
if (!noAssert) {
|
|
14739
|
-
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
14740
|
-
|
|
14741
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
14742
|
-
}
|
|
14743
|
-
|
|
14744
|
-
let i = byteLength - 1;
|
|
14745
|
-
let mul = 1;
|
|
14746
|
-
let sub = 0;
|
|
14747
|
-
this[offset + i] = value & 0xFF;
|
|
14748
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
14749
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
14750
|
-
sub = 1;
|
|
14751
|
-
}
|
|
14752
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
14753
|
-
}
|
|
14754
|
-
|
|
14755
|
-
return offset + byteLength
|
|
14756
|
-
};
|
|
14757
|
-
|
|
14758
|
-
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
14759
|
-
value = +value;
|
|
14760
|
-
offset = offset >>> 0;
|
|
14761
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
|
|
14762
|
-
if (value < 0) value = 0xff + value + 1;
|
|
14763
|
-
this[offset] = (value & 0xff);
|
|
14764
|
-
return offset + 1
|
|
14765
|
-
};
|
|
14766
|
-
|
|
14767
|
-
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
14768
|
-
value = +value;
|
|
14769
|
-
offset = offset >>> 0;
|
|
14770
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
14771
|
-
this[offset] = (value & 0xff);
|
|
14772
|
-
this[offset + 1] = (value >>> 8);
|
|
14773
|
-
return offset + 2
|
|
14774
|
-
};
|
|
14775
|
-
|
|
14776
|
-
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
14777
|
-
value = +value;
|
|
14778
|
-
offset = offset >>> 0;
|
|
14779
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
14780
|
-
this[offset] = (value >>> 8);
|
|
14781
|
-
this[offset + 1] = (value & 0xff);
|
|
14782
|
-
return offset + 2
|
|
14783
|
-
};
|
|
14784
|
-
|
|
14785
|
-
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
14786
|
-
value = +value;
|
|
14787
|
-
offset = offset >>> 0;
|
|
14788
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
14789
|
-
this[offset] = (value & 0xff);
|
|
14790
|
-
this[offset + 1] = (value >>> 8);
|
|
14791
|
-
this[offset + 2] = (value >>> 16);
|
|
14792
|
-
this[offset + 3] = (value >>> 24);
|
|
14793
|
-
return offset + 4
|
|
14794
|
-
};
|
|
14795
|
-
|
|
14796
|
-
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
14797
|
-
value = +value;
|
|
14798
|
-
offset = offset >>> 0;
|
|
14799
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
14800
|
-
if (value < 0) value = 0xffffffff + value + 1;
|
|
14801
|
-
this[offset] = (value >>> 24);
|
|
14802
|
-
this[offset + 1] = (value >>> 16);
|
|
14803
|
-
this[offset + 2] = (value >>> 8);
|
|
14804
|
-
this[offset + 3] = (value & 0xff);
|
|
14805
|
-
return offset + 4
|
|
14806
|
-
};
|
|
14807
|
-
|
|
14808
|
-
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
14809
|
-
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
14810
|
-
});
|
|
14811
|
-
|
|
14812
|
-
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
14813
|
-
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
14814
|
-
});
|
|
14815
|
-
|
|
14816
|
-
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
14817
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
14818
|
-
if (offset < 0) throw new RangeError('Index out of range')
|
|
14819
|
-
}
|
|
14820
|
-
|
|
14821
|
-
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
14822
|
-
value = +value;
|
|
14823
|
-
offset = offset >>> 0;
|
|
14824
|
-
if (!noAssert) {
|
|
14825
|
-
checkIEEE754(buf, value, offset, 4);
|
|
14826
|
-
}
|
|
14827
|
-
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
14828
|
-
return offset + 4
|
|
14829
|
-
}
|
|
14830
|
-
|
|
14831
|
-
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
14832
|
-
return writeFloat(this, value, offset, true, noAssert)
|
|
14833
|
-
};
|
|
14834
|
-
|
|
14835
|
-
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
14836
|
-
return writeFloat(this, value, offset, false, noAssert)
|
|
14837
|
-
};
|
|
14838
|
-
|
|
14839
|
-
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
14840
|
-
value = +value;
|
|
14841
|
-
offset = offset >>> 0;
|
|
14842
|
-
if (!noAssert) {
|
|
14843
|
-
checkIEEE754(buf, value, offset, 8);
|
|
14844
|
-
}
|
|
14845
|
-
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
14846
|
-
return offset + 8
|
|
14847
|
-
}
|
|
14848
|
-
|
|
14849
|
-
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
14850
|
-
return writeDouble(this, value, offset, true, noAssert)
|
|
14851
|
-
};
|
|
14852
|
-
|
|
14853
|
-
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
14854
|
-
return writeDouble(this, value, offset, false, noAssert)
|
|
14855
|
-
};
|
|
14856
|
-
|
|
14857
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
14858
|
-
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
14859
|
-
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
14860
|
-
if (!start) start = 0;
|
|
14861
|
-
if (!end && end !== 0) end = this.length;
|
|
14862
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
14863
|
-
if (!targetStart) targetStart = 0;
|
|
14864
|
-
if (end > 0 && end < start) end = start;
|
|
14865
|
-
|
|
14866
|
-
// Copy 0 bytes; we're done
|
|
14867
|
-
if (end === start) return 0
|
|
14868
|
-
if (target.length === 0 || this.length === 0) return 0
|
|
14869
|
-
|
|
14870
|
-
// Fatal error conditions
|
|
14871
|
-
if (targetStart < 0) {
|
|
14872
|
-
throw new RangeError('targetStart out of bounds')
|
|
14873
|
-
}
|
|
14874
|
-
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
14875
|
-
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
14876
|
-
|
|
14877
|
-
// Are we oob?
|
|
14878
|
-
if (end > this.length) end = this.length;
|
|
14879
|
-
if (target.length - targetStart < end - start) {
|
|
14880
|
-
end = target.length - targetStart + start;
|
|
14881
|
-
}
|
|
14882
|
-
|
|
14883
|
-
const len = end - start;
|
|
14884
|
-
|
|
14885
|
-
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
14886
|
-
// Use built-in when available, missing from IE11
|
|
14887
|
-
this.copyWithin(targetStart, start, end);
|
|
14888
|
-
} else {
|
|
14889
|
-
Uint8Array.prototype.set.call(
|
|
14890
|
-
target,
|
|
14891
|
-
this.subarray(start, end),
|
|
14892
|
-
targetStart
|
|
14893
|
-
);
|
|
14894
|
-
}
|
|
14895
|
-
|
|
14896
|
-
return len
|
|
14897
|
-
};
|
|
14898
|
-
|
|
14899
|
-
// Usage:
|
|
14900
|
-
// buffer.fill(number[, offset[, end]])
|
|
14901
|
-
// buffer.fill(buffer[, offset[, end]])
|
|
14902
|
-
// buffer.fill(string[, offset[, end]][, encoding])
|
|
14903
|
-
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
14904
|
-
// Handle string cases:
|
|
14905
|
-
if (typeof val === 'string') {
|
|
14906
|
-
if (typeof start === 'string') {
|
|
14907
|
-
encoding = start;
|
|
14908
|
-
start = 0;
|
|
14909
|
-
end = this.length;
|
|
14910
|
-
} else if (typeof end === 'string') {
|
|
14911
|
-
encoding = end;
|
|
14912
|
-
end = this.length;
|
|
14913
|
-
}
|
|
14914
|
-
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
14915
|
-
throw new TypeError('encoding must be a string')
|
|
14916
|
-
}
|
|
14917
|
-
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
14918
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
14919
|
-
}
|
|
14920
|
-
if (val.length === 1) {
|
|
14921
|
-
const code = val.charCodeAt(0);
|
|
14922
|
-
if ((encoding === 'utf8' && code < 128) ||
|
|
14923
|
-
encoding === 'latin1') {
|
|
14924
|
-
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
14925
|
-
val = code;
|
|
14926
|
-
}
|
|
14927
|
-
}
|
|
14928
|
-
} else if (typeof val === 'number') {
|
|
14929
|
-
val = val & 255;
|
|
14930
|
-
} else if (typeof val === 'boolean') {
|
|
14931
|
-
val = Number(val);
|
|
14932
|
-
}
|
|
14933
|
-
|
|
14934
|
-
// Invalid ranges are not set to a default, so can range check early.
|
|
14935
|
-
if (start < 0 || this.length < start || this.length < end) {
|
|
14936
|
-
throw new RangeError('Out of range index')
|
|
14937
|
-
}
|
|
14938
|
-
|
|
14939
|
-
if (end <= start) {
|
|
14940
|
-
return this
|
|
14941
|
-
}
|
|
14942
|
-
|
|
14943
|
-
start = start >>> 0;
|
|
14944
|
-
end = end === undefined ? this.length : end >>> 0;
|
|
14945
|
-
|
|
14946
|
-
if (!val) val = 0;
|
|
14947
|
-
|
|
14948
|
-
let i;
|
|
14949
|
-
if (typeof val === 'number') {
|
|
14950
|
-
for (i = start; i < end; ++i) {
|
|
14951
|
-
this[i] = val;
|
|
14952
|
-
}
|
|
14953
|
-
} else {
|
|
14954
|
-
const bytes = Buffer.isBuffer(val)
|
|
14955
|
-
? val
|
|
14956
|
-
: Buffer.from(val, encoding);
|
|
14957
|
-
const len = bytes.length;
|
|
14958
|
-
if (len === 0) {
|
|
14959
|
-
throw new TypeError('The value "' + val +
|
|
14960
|
-
'" is invalid for argument "value"')
|
|
14961
|
-
}
|
|
14962
|
-
for (i = 0; i < end - start; ++i) {
|
|
14963
|
-
this[i + start] = bytes[i % len];
|
|
14964
|
-
}
|
|
14965
|
-
}
|
|
14966
|
-
|
|
14967
|
-
return this
|
|
14968
|
-
};
|
|
14969
|
-
|
|
14970
|
-
// CUSTOM ERRORS
|
|
14971
|
-
// =============
|
|
14972
|
-
|
|
14973
|
-
// Simplified versions from Node, changed for Buffer-only usage
|
|
14974
|
-
const errors = {};
|
|
14975
|
-
function E (sym, getMessage, Base) {
|
|
14976
|
-
errors[sym] = class NodeError extends Base {
|
|
14977
|
-
constructor () {
|
|
14978
|
-
super();
|
|
14979
|
-
|
|
14980
|
-
Object.defineProperty(this, 'message', {
|
|
14981
|
-
value: getMessage.apply(this, arguments),
|
|
14982
|
-
writable: true,
|
|
14983
|
-
configurable: true
|
|
14984
|
-
});
|
|
14985
|
-
|
|
14986
|
-
// Add the error code to the name to include it in the stack trace.
|
|
14987
|
-
this.name = `${this.name} [${sym}]`;
|
|
14988
|
-
// Access the stack to generate the error message including the error code
|
|
14989
|
-
// from the name.
|
|
14990
|
-
this.stack; // eslint-disable-line no-unused-expressions
|
|
14991
|
-
// Reset the name to the actual name.
|
|
14992
|
-
delete this.name;
|
|
14993
|
-
}
|
|
14994
|
-
|
|
14995
|
-
get code () {
|
|
14996
|
-
return sym
|
|
14997
|
-
}
|
|
14998
|
-
|
|
14999
|
-
set code (value) {
|
|
15000
|
-
Object.defineProperty(this, 'code', {
|
|
15001
|
-
configurable: true,
|
|
15002
|
-
enumerable: true,
|
|
15003
|
-
value,
|
|
15004
|
-
writable: true
|
|
15005
|
-
});
|
|
15006
|
-
}
|
|
15007
|
-
|
|
15008
|
-
toString () {
|
|
15009
|
-
return `${this.name} [${sym}]: ${this.message}`
|
|
15010
|
-
}
|
|
15011
|
-
};
|
|
15012
|
-
}
|
|
15013
|
-
|
|
15014
|
-
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
15015
|
-
function (name) {
|
|
15016
|
-
if (name) {
|
|
15017
|
-
return `${name} is outside of buffer bounds`
|
|
15018
|
-
}
|
|
15019
|
-
|
|
15020
|
-
return 'Attempt to access memory outside buffer bounds'
|
|
15021
|
-
}, RangeError);
|
|
15022
|
-
E('ERR_INVALID_ARG_TYPE',
|
|
15023
|
-
function (name, actual) {
|
|
15024
|
-
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
15025
|
-
}, TypeError);
|
|
15026
|
-
E('ERR_OUT_OF_RANGE',
|
|
15027
|
-
function (str, range, input) {
|
|
15028
|
-
let msg = `The value of "${str}" is out of range.`;
|
|
15029
|
-
let received = input;
|
|
15030
|
-
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
15031
|
-
received = addNumericalSeparator(String(input));
|
|
15032
|
-
} else if (typeof input === 'bigint') {
|
|
15033
|
-
received = String(input);
|
|
15034
|
-
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
15035
|
-
received = addNumericalSeparator(received);
|
|
15036
|
-
}
|
|
15037
|
-
received += 'n';
|
|
15038
|
-
}
|
|
15039
|
-
msg += ` It must be ${range}. Received ${received}`;
|
|
15040
|
-
return msg
|
|
15041
|
-
}, RangeError);
|
|
15042
|
-
|
|
15043
|
-
function addNumericalSeparator (val) {
|
|
15044
|
-
let res = '';
|
|
15045
|
-
let i = val.length;
|
|
15046
|
-
const start = val[0] === '-' ? 1 : 0;
|
|
15047
|
-
for (; i >= start + 4; i -= 3) {
|
|
15048
|
-
res = `_${val.slice(i - 3, i)}${res}`;
|
|
15049
|
-
}
|
|
15050
|
-
return `${val.slice(0, i)}${res}`
|
|
15051
|
-
}
|
|
15052
|
-
|
|
15053
|
-
// CHECK FUNCTIONS
|
|
15054
|
-
// ===============
|
|
15055
|
-
|
|
15056
|
-
function checkBounds (buf, offset, byteLength) {
|
|
15057
|
-
validateNumber(offset, 'offset');
|
|
15058
|
-
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
15059
|
-
boundsError(offset, buf.length - (byteLength + 1));
|
|
15060
|
-
}
|
|
15061
|
-
}
|
|
15062
|
-
|
|
15063
|
-
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
15064
|
-
if (value > max || value < min) {
|
|
15065
|
-
const n = typeof min === 'bigint' ? 'n' : '';
|
|
15066
|
-
let range;
|
|
15067
|
-
{
|
|
15068
|
-
if (min === 0 || min === BigInt(0)) {
|
|
15069
|
-
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
15070
|
-
} else {
|
|
15071
|
-
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
15072
|
-
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
15073
|
-
}
|
|
15074
|
-
}
|
|
15075
|
-
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
15076
|
-
}
|
|
15077
|
-
checkBounds(buf, offset, byteLength);
|
|
15078
|
-
}
|
|
15079
|
-
|
|
15080
|
-
function validateNumber (value, name) {
|
|
15081
|
-
if (typeof value !== 'number') {
|
|
15082
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
15083
|
-
}
|
|
15084
|
-
}
|
|
15085
|
-
|
|
15086
|
-
function boundsError (value, length, type) {
|
|
15087
|
-
if (Math.floor(value) !== value) {
|
|
15088
|
-
validateNumber(value, type);
|
|
15089
|
-
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
15090
|
-
}
|
|
15091
|
-
|
|
15092
|
-
if (length < 0) {
|
|
15093
|
-
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
15094
|
-
}
|
|
15095
|
-
|
|
15096
|
-
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
15097
|
-
`>= ${0} and <= ${length}`,
|
|
15098
|
-
value)
|
|
15099
|
-
}
|
|
15100
|
-
|
|
15101
|
-
// HELPER FUNCTIONS
|
|
15102
|
-
// ================
|
|
15103
|
-
|
|
15104
|
-
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
15105
|
-
|
|
15106
|
-
function base64clean (str) {
|
|
15107
|
-
// Node takes equal signs as end of the Base64 encoding
|
|
15108
|
-
str = str.split('=')[0];
|
|
15109
|
-
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
15110
|
-
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
15111
|
-
// Node converts strings with length < 2 to ''
|
|
15112
|
-
if (str.length < 2) return ''
|
|
15113
|
-
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
15114
|
-
while (str.length % 4 !== 0) {
|
|
15115
|
-
str = str + '=';
|
|
15116
|
-
}
|
|
15117
|
-
return str
|
|
15118
|
-
}
|
|
15119
|
-
|
|
15120
|
-
function utf8ToBytes (string, units) {
|
|
15121
|
-
units = units || Infinity;
|
|
15122
|
-
let codePoint;
|
|
15123
|
-
const length = string.length;
|
|
15124
|
-
let leadSurrogate = null;
|
|
15125
|
-
const bytes = [];
|
|
15126
|
-
|
|
15127
|
-
for (let i = 0; i < length; ++i) {
|
|
15128
|
-
codePoint = string.charCodeAt(i);
|
|
15129
|
-
|
|
15130
|
-
// is surrogate component
|
|
15131
|
-
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
15132
|
-
// last char was a lead
|
|
15133
|
-
if (!leadSurrogate) {
|
|
15134
|
-
// no lead yet
|
|
15135
|
-
if (codePoint > 0xDBFF) {
|
|
15136
|
-
// unexpected trail
|
|
15137
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15138
|
-
continue
|
|
15139
|
-
} else if (i + 1 === length) {
|
|
15140
|
-
// unpaired lead
|
|
15141
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15142
|
-
continue
|
|
15143
|
-
}
|
|
15144
|
-
|
|
15145
|
-
// valid lead
|
|
15146
|
-
leadSurrogate = codePoint;
|
|
15147
|
-
|
|
15148
|
-
continue
|
|
15149
|
-
}
|
|
15150
|
-
|
|
15151
|
-
// 2 leads in a row
|
|
15152
|
-
if (codePoint < 0xDC00) {
|
|
15153
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15154
|
-
leadSurrogate = codePoint;
|
|
15155
|
-
continue
|
|
15156
|
-
}
|
|
15157
|
-
|
|
15158
|
-
// valid surrogate pair
|
|
15159
|
-
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
15160
|
-
} else if (leadSurrogate) {
|
|
15161
|
-
// valid bmp char, but last char was a lead
|
|
15162
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15163
|
-
}
|
|
15164
|
-
|
|
15165
|
-
leadSurrogate = null;
|
|
15166
|
-
|
|
15167
|
-
// encode utf8
|
|
15168
|
-
if (codePoint < 0x80) {
|
|
15169
|
-
if ((units -= 1) < 0) break
|
|
15170
|
-
bytes.push(codePoint);
|
|
15171
|
-
} else if (codePoint < 0x800) {
|
|
15172
|
-
if ((units -= 2) < 0) break
|
|
15173
|
-
bytes.push(
|
|
15174
|
-
codePoint >> 0x6 | 0xC0,
|
|
15175
|
-
codePoint & 0x3F | 0x80
|
|
15176
|
-
);
|
|
15177
|
-
} else if (codePoint < 0x10000) {
|
|
15178
|
-
if ((units -= 3) < 0) break
|
|
15179
|
-
bytes.push(
|
|
15180
|
-
codePoint >> 0xC | 0xE0,
|
|
15181
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15182
|
-
codePoint & 0x3F | 0x80
|
|
15183
|
-
);
|
|
15184
|
-
} else if (codePoint < 0x110000) {
|
|
15185
|
-
if ((units -= 4) < 0) break
|
|
15186
|
-
bytes.push(
|
|
15187
|
-
codePoint >> 0x12 | 0xF0,
|
|
15188
|
-
codePoint >> 0xC & 0x3F | 0x80,
|
|
15189
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15190
|
-
codePoint & 0x3F | 0x80
|
|
15191
|
-
);
|
|
15192
|
-
} else {
|
|
15193
|
-
throw new Error('Invalid code point')
|
|
15194
|
-
}
|
|
15195
|
-
}
|
|
15196
|
-
|
|
15197
|
-
return bytes
|
|
15198
|
-
}
|
|
15199
|
-
|
|
15200
|
-
function asciiToBytes (str) {
|
|
15201
|
-
const byteArray = [];
|
|
15202
|
-
for (let i = 0; i < str.length; ++i) {
|
|
15203
|
-
// Node's code seems to be doing this and not & 0x7F..
|
|
15204
|
-
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
15205
|
-
}
|
|
15206
|
-
return byteArray
|
|
15207
|
-
}
|
|
15208
|
-
|
|
15209
|
-
function utf16leToBytes (str, units) {
|
|
15210
|
-
let c, hi, lo;
|
|
15211
|
-
const byteArray = [];
|
|
15212
|
-
for (let i = 0; i < str.length; ++i) {
|
|
15213
|
-
if ((units -= 2) < 0) break
|
|
15214
|
-
|
|
15215
|
-
c = str.charCodeAt(i);
|
|
15216
|
-
hi = c >> 8;
|
|
15217
|
-
lo = c % 256;
|
|
15218
|
-
byteArray.push(lo);
|
|
15219
|
-
byteArray.push(hi);
|
|
15220
|
-
}
|
|
15221
|
-
|
|
15222
|
-
return byteArray
|
|
15223
|
-
}
|
|
15224
|
-
|
|
15225
|
-
function base64ToBytes (str) {
|
|
15226
|
-
return base64.toByteArray(base64clean(str))
|
|
15227
|
-
}
|
|
15228
|
-
|
|
15229
|
-
function blitBuffer (src, dst, offset, length) {
|
|
15230
|
-
let i;
|
|
15231
|
-
for (i = 0; i < length; ++i) {
|
|
15232
|
-
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
15233
|
-
dst[i + offset] = src[i];
|
|
15234
|
-
}
|
|
15235
|
-
return i
|
|
15236
|
-
}
|
|
15237
|
-
|
|
15238
|
-
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
15239
|
-
// the `instanceof` check but they should be treated as of that type.
|
|
15240
|
-
// See: https://github.com/feross/buffer/issues/166
|
|
15241
|
-
function isInstance (obj, type) {
|
|
15242
|
-
return obj instanceof type ||
|
|
15243
|
-
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
15244
|
-
obj.constructor.name === type.name)
|
|
15245
|
-
}
|
|
15246
|
-
function numberIsNaN (obj) {
|
|
15247
|
-
// For IE11 support
|
|
15248
|
-
return obj !== obj // eslint-disable-line no-self-compare
|
|
15249
|
-
}
|
|
15250
|
-
|
|
15251
|
-
// Create lookup table for `toString('hex')`
|
|
15252
|
-
// See: https://github.com/feross/buffer/issues/219
|
|
15253
|
-
const hexSliceLookupTable = (function () {
|
|
15254
|
-
const alphabet = '0123456789abcdef';
|
|
15255
|
-
const table = new Array(256);
|
|
15256
|
-
for (let i = 0; i < 16; ++i) {
|
|
15257
|
-
const i16 = i * 16;
|
|
15258
|
-
for (let j = 0; j < 16; ++j) {
|
|
15259
|
-
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
15260
|
-
}
|
|
15261
|
-
}
|
|
15262
|
-
return table
|
|
15263
|
-
})();
|
|
15264
|
-
|
|
15265
|
-
// Return not function with Error if BigInt not supported
|
|
15266
|
-
function defineBigIntMethod (fn) {
|
|
15267
|
-
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
15268
|
-
}
|
|
15269
|
-
|
|
15270
|
-
function BufferBigIntNotDefined () {
|
|
15271
|
-
throw new Error('BigInt not supported')
|
|
15272
|
-
}
|
|
15273
|
-
} (buffer));
|
|
15274
|
-
return buffer;
|
|
15275
|
-
}
|
|
15276
|
-
|
|
15277
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
15278
|
-
|
|
15279
|
-
var hasRequiredSafeBuffer;
|
|
15280
|
-
|
|
15281
|
-
function requireSafeBuffer () {
|
|
15282
|
-
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
15283
|
-
hasRequiredSafeBuffer = 1;
|
|
15284
|
-
(function (module, exports$1) {
|
|
15285
|
-
/* eslint-disable node/no-deprecated-api */
|
|
15286
|
-
var buffer = requireBuffer();
|
|
15287
|
-
var Buffer = buffer.Buffer;
|
|
15288
|
-
|
|
15289
|
-
// alternative to using Object.keys for old browsers
|
|
15290
|
-
function copyProps (src, dst) {
|
|
15291
|
-
for (var key in src) {
|
|
15292
|
-
dst[key] = src[key];
|
|
15293
|
-
}
|
|
15294
|
-
}
|
|
15295
|
-
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
15296
|
-
module.exports = buffer;
|
|
15297
|
-
} else {
|
|
15298
|
-
// Copy properties from require('buffer')
|
|
15299
|
-
copyProps(buffer, exports$1);
|
|
15300
|
-
exports$1.Buffer = SafeBuffer;
|
|
15301
|
-
}
|
|
15302
|
-
|
|
15303
|
-
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
15304
|
-
return Buffer(arg, encodingOrOffset, length)
|
|
15305
|
-
}
|
|
15306
|
-
|
|
15307
|
-
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
15308
|
-
|
|
15309
|
-
// Copy static methods from Buffer
|
|
15310
|
-
copyProps(Buffer, SafeBuffer);
|
|
15311
|
-
|
|
15312
|
-
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
15313
|
-
if (typeof arg === 'number') {
|
|
15314
|
-
throw new TypeError('Argument must not be a number')
|
|
15315
|
-
}
|
|
15316
|
-
return Buffer(arg, encodingOrOffset, length)
|
|
15317
|
-
};
|
|
15318
|
-
|
|
15319
|
-
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
15320
|
-
if (typeof size !== 'number') {
|
|
15321
|
-
throw new TypeError('Argument must be a number')
|
|
15322
|
-
}
|
|
15323
|
-
var buf = Buffer(size);
|
|
15324
|
-
if (fill !== undefined) {
|
|
15325
|
-
if (typeof encoding === 'string') {
|
|
15326
|
-
buf.fill(fill, encoding);
|
|
15327
|
-
} else {
|
|
15328
|
-
buf.fill(fill);
|
|
15329
|
-
}
|
|
15330
|
-
} else {
|
|
15331
|
-
buf.fill(0);
|
|
15332
|
-
}
|
|
15333
|
-
return buf
|
|
15334
|
-
};
|
|
15335
|
-
|
|
15336
|
-
SafeBuffer.allocUnsafe = function (size) {
|
|
15337
|
-
if (typeof size !== 'number') {
|
|
15338
|
-
throw new TypeError('Argument must be a number')
|
|
15339
|
-
}
|
|
15340
|
-
return Buffer(size)
|
|
15341
|
-
};
|
|
15342
|
-
|
|
15343
|
-
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
15344
|
-
if (typeof size !== 'number') {
|
|
15345
|
-
throw new TypeError('Argument must be a number')
|
|
15346
|
-
}
|
|
15347
|
-
return buffer.SlowBuffer(size)
|
|
15348
|
-
};
|
|
15349
|
-
} (safeBuffer, safeBuffer.exports));
|
|
15350
|
-
return safeBuffer.exports;
|
|
15351
|
-
}
|
|
15352
|
-
|
|
15353
|
-
var src;
|
|
15354
|
-
var hasRequiredSrc;
|
|
15355
|
-
|
|
15356
|
-
function requireSrc () {
|
|
15357
|
-
if (hasRequiredSrc) return src;
|
|
15358
|
-
hasRequiredSrc = 1;
|
|
15359
|
-
// base-x encoding / decoding
|
|
15360
|
-
// Copyright (c) 2018 base-x contributors
|
|
15361
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
15362
|
-
// Distributed under the MIT software license, see the accompanying
|
|
15363
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
15364
|
-
// @ts-ignore
|
|
15365
|
-
var _Buffer = requireSafeBuffer().Buffer;
|
|
15366
|
-
function base (ALPHABET) {
|
|
15367
|
-
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
15368
|
-
var BASE_MAP = new Uint8Array(256);
|
|
15369
|
-
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
15370
|
-
BASE_MAP[j] = 255;
|
|
15371
|
-
}
|
|
15372
|
-
for (var i = 0; i < ALPHABET.length; i++) {
|
|
15373
|
-
var x = ALPHABET.charAt(i);
|
|
15374
|
-
var xc = x.charCodeAt(0);
|
|
15375
|
-
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
15376
|
-
BASE_MAP[xc] = i;
|
|
15377
|
-
}
|
|
15378
|
-
var BASE = ALPHABET.length;
|
|
15379
|
-
var LEADER = ALPHABET.charAt(0);
|
|
15380
|
-
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
15381
|
-
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
15382
|
-
function encode (source) {
|
|
15383
|
-
if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
|
|
15384
|
-
if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
|
|
15385
|
-
if (source.length === 0) { return '' }
|
|
15386
|
-
// Skip & count leading zeroes.
|
|
15387
|
-
var zeroes = 0;
|
|
15388
|
-
var length = 0;
|
|
15389
|
-
var pbegin = 0;
|
|
15390
|
-
var pend = source.length;
|
|
15391
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
15392
|
-
pbegin++;
|
|
15393
|
-
zeroes++;
|
|
15394
|
-
}
|
|
15395
|
-
// Allocate enough space in big-endian base58 representation.
|
|
15396
|
-
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
15397
|
-
var b58 = new Uint8Array(size);
|
|
15398
|
-
// Process the bytes.
|
|
15399
|
-
while (pbegin !== pend) {
|
|
15400
|
-
var carry = source[pbegin];
|
|
15401
|
-
// Apply "b58 = b58 * 256 + ch".
|
|
15402
|
-
var i = 0;
|
|
15403
|
-
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
15404
|
-
carry += (256 * b58[it1]) >>> 0;
|
|
15405
|
-
b58[it1] = (carry % BASE) >>> 0;
|
|
15406
|
-
carry = (carry / BASE) >>> 0;
|
|
15407
|
-
}
|
|
15408
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15409
|
-
length = i;
|
|
15410
|
-
pbegin++;
|
|
15411
|
-
}
|
|
15412
|
-
// Skip leading zeroes in base58 result.
|
|
15413
|
-
var it2 = size - length;
|
|
15414
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
15415
|
-
it2++;
|
|
15416
|
-
}
|
|
15417
|
-
// Translate the result into a string.
|
|
15418
|
-
var str = LEADER.repeat(zeroes);
|
|
15419
|
-
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
15420
|
-
return str
|
|
15421
|
-
}
|
|
15422
|
-
function decodeUnsafe (source) {
|
|
15423
|
-
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
15424
|
-
if (source.length === 0) { return _Buffer.alloc(0) }
|
|
15425
|
-
var psz = 0;
|
|
15426
|
-
// Skip and count leading '1's.
|
|
15427
|
-
var zeroes = 0;
|
|
15428
|
-
var length = 0;
|
|
15429
|
-
while (source[psz] === LEADER) {
|
|
15430
|
-
zeroes++;
|
|
15431
|
-
psz++;
|
|
15432
|
-
}
|
|
15433
|
-
// Allocate enough space in big-endian base256 representation.
|
|
15434
|
-
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
15435
|
-
var b256 = new Uint8Array(size);
|
|
15436
|
-
// Process the characters.
|
|
15437
|
-
while (psz < source.length) {
|
|
15438
|
-
// Find code of next character
|
|
15439
|
-
var charCode = source.charCodeAt(psz);
|
|
15440
|
-
// Base map can not be indexed using char code
|
|
15441
|
-
if (charCode > 255) { return }
|
|
15442
|
-
// Decode character
|
|
15443
|
-
var carry = BASE_MAP[charCode];
|
|
15444
|
-
// Invalid character
|
|
15445
|
-
if (carry === 255) { return }
|
|
15446
|
-
var i = 0;
|
|
15447
|
-
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
15448
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
15449
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
15450
|
-
carry = (carry / 256) >>> 0;
|
|
15451
|
-
}
|
|
15452
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15453
|
-
length = i;
|
|
15454
|
-
psz++;
|
|
15455
|
-
}
|
|
15456
|
-
// Skip leading zeroes in b256.
|
|
15457
|
-
var it4 = size - length;
|
|
15458
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
15459
|
-
it4++;
|
|
15460
|
-
}
|
|
15461
|
-
var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
|
|
15462
|
-
vch.fill(0x00, 0, zeroes);
|
|
15463
|
-
var j = zeroes;
|
|
15464
|
-
while (it4 !== size) {
|
|
15465
|
-
vch[j++] = b256[it4++];
|
|
15466
|
-
}
|
|
15467
|
-
return vch
|
|
15468
|
-
}
|
|
15469
|
-
function decode (string) {
|
|
15470
|
-
var buffer = decodeUnsafe(string);
|
|
15471
|
-
if (buffer) { return buffer }
|
|
15472
|
-
throw new Error('Non-base' + BASE + ' character')
|
|
15473
|
-
}
|
|
15474
|
-
return {
|
|
15475
|
-
encode: encode,
|
|
15476
|
-
decodeUnsafe: decodeUnsafe,
|
|
15477
|
-
decode: decode
|
|
15478
|
-
}
|
|
15479
|
-
}
|
|
15480
|
-
src = base;
|
|
15481
|
-
return src;
|
|
15482
|
-
}
|
|
15483
|
-
|
|
15484
|
-
var bs58$1;
|
|
15485
|
-
var hasRequiredBs58;
|
|
15486
|
-
|
|
15487
|
-
function requireBs58 () {
|
|
15488
|
-
if (hasRequiredBs58) return bs58$1;
|
|
15489
|
-
hasRequiredBs58 = 1;
|
|
15490
|
-
var basex = requireSrc();
|
|
15491
|
-
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
15492
|
-
|
|
15493
|
-
bs58$1 = basex(ALPHABET);
|
|
15494
|
-
return bs58$1;
|
|
15495
|
-
}
|
|
15496
|
-
|
|
15497
|
-
var bs58Exports = requireBs58();
|
|
15498
|
-
var bs58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
|
|
15499
|
-
|
|
15500
|
-
var index = /*#__PURE__*/_mergeNamespaces({
|
|
13233
|
+
// base-x encoding / decoding
|
|
13234
|
+
// Copyright (c) 2018 base-x contributors
|
|
13235
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
13236
|
+
// Distributed under the MIT software license, see the accompanying
|
|
13237
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
13238
|
+
function base (ALPHABET) {
|
|
13239
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
13240
|
+
const BASE_MAP = new Uint8Array(256);
|
|
13241
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
13242
|
+
BASE_MAP[j] = 255;
|
|
13243
|
+
}
|
|
13244
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
13245
|
+
const x = ALPHABET.charAt(i);
|
|
13246
|
+
const xc = x.charCodeAt(0);
|
|
13247
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
13248
|
+
BASE_MAP[xc] = i;
|
|
13249
|
+
}
|
|
13250
|
+
const BASE = ALPHABET.length;
|
|
13251
|
+
const LEADER = ALPHABET.charAt(0);
|
|
13252
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
13253
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
13254
|
+
function encode (source) {
|
|
13255
|
+
// eslint-disable-next-line no-empty
|
|
13256
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
13257
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
13258
|
+
} else if (Array.isArray(source)) {
|
|
13259
|
+
source = Uint8Array.from(source);
|
|
13260
|
+
}
|
|
13261
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
13262
|
+
if (source.length === 0) { return '' }
|
|
13263
|
+
// Skip & count leading zeroes.
|
|
13264
|
+
let zeroes = 0;
|
|
13265
|
+
let length = 0;
|
|
13266
|
+
let pbegin = 0;
|
|
13267
|
+
const pend = source.length;
|
|
13268
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
13269
|
+
pbegin++;
|
|
13270
|
+
zeroes++;
|
|
13271
|
+
}
|
|
13272
|
+
// Allocate enough space in big-endian base58 representation.
|
|
13273
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
13274
|
+
const b58 = new Uint8Array(size);
|
|
13275
|
+
// Process the bytes.
|
|
13276
|
+
while (pbegin !== pend) {
|
|
13277
|
+
let carry = source[pbegin];
|
|
13278
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
13279
|
+
let i = 0;
|
|
13280
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
13281
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
13282
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
13283
|
+
carry = (carry / BASE) >>> 0;
|
|
13284
|
+
}
|
|
13285
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
13286
|
+
length = i;
|
|
13287
|
+
pbegin++;
|
|
13288
|
+
}
|
|
13289
|
+
// Skip leading zeroes in base58 result.
|
|
13290
|
+
let it2 = size - length;
|
|
13291
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
13292
|
+
it2++;
|
|
13293
|
+
}
|
|
13294
|
+
// Translate the result into a string.
|
|
13295
|
+
let str = LEADER.repeat(zeroes);
|
|
13296
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
13297
|
+
return str
|
|
13298
|
+
}
|
|
13299
|
+
function decodeUnsafe (source) {
|
|
13300
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
13301
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
13302
|
+
let psz = 0;
|
|
13303
|
+
// Skip and count leading '1's.
|
|
13304
|
+
let zeroes = 0;
|
|
13305
|
+
let length = 0;
|
|
13306
|
+
while (source[psz] === LEADER) {
|
|
13307
|
+
zeroes++;
|
|
13308
|
+
psz++;
|
|
13309
|
+
}
|
|
13310
|
+
// Allocate enough space in big-endian base256 representation.
|
|
13311
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
13312
|
+
const b256 = new Uint8Array(size);
|
|
13313
|
+
// Process the characters.
|
|
13314
|
+
while (psz < source.length) {
|
|
13315
|
+
// Find code of next character
|
|
13316
|
+
const charCode = source.charCodeAt(psz);
|
|
13317
|
+
// Base map can not be indexed using char code
|
|
13318
|
+
if (charCode > 255) { return }
|
|
13319
|
+
// Decode character
|
|
13320
|
+
let carry = BASE_MAP[charCode];
|
|
13321
|
+
// Invalid character
|
|
13322
|
+
if (carry === 255) { return }
|
|
13323
|
+
let i = 0;
|
|
13324
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
13325
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
13326
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
13327
|
+
carry = (carry / 256) >>> 0;
|
|
13328
|
+
}
|
|
13329
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
13330
|
+
length = i;
|
|
13331
|
+
psz++;
|
|
13332
|
+
}
|
|
13333
|
+
// Skip leading zeroes in b256.
|
|
13334
|
+
let it4 = size - length;
|
|
13335
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
13336
|
+
it4++;
|
|
13337
|
+
}
|
|
13338
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
13339
|
+
let j = zeroes;
|
|
13340
|
+
while (it4 !== size) {
|
|
13341
|
+
vch[j++] = b256[it4++];
|
|
13342
|
+
}
|
|
13343
|
+
return vch
|
|
13344
|
+
}
|
|
13345
|
+
function decode (string) {
|
|
13346
|
+
const buffer = decodeUnsafe(string);
|
|
13347
|
+
if (buffer) { return buffer }
|
|
13348
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
13349
|
+
}
|
|
13350
|
+
return {
|
|
13351
|
+
encode,
|
|
13352
|
+
decodeUnsafe,
|
|
13353
|
+
decode
|
|
13354
|
+
}
|
|
13355
|
+
}
|
|
13356
|
+
|
|
13357
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
13358
|
+
var bs58 = base(ALPHABET);
|
|
13359
|
+
|
|
13360
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
15501
13361
|
__proto__: null,
|
|
15502
13362
|
default: bs58
|
|
15503
|
-
}
|
|
13363
|
+
});
|
|
15504
13364
|
|
|
15505
13365
|
/**
|
|
15506
13366
|
* Privy Expo Auth Provider — React Native implementation of AuthProvider.
|
|
@@ -15841,5 +13701,5 @@ class PrivyExpoProvider {
|
|
|
15841
13701
|
}
|
|
15842
13702
|
}
|
|
15843
13703
|
|
|
15844
|
-
export {
|
|
15845
|
-
//# sourceMappingURL=index.native-
|
|
13704
|
+
export { clearCache as $, set as A, setMany as B, setFile as C, getFiles as D, runQuery as E, runQueryMany as F, runExpression as G, runExpressionMany as H, signMessage as I, signTransaction as J, signAndSubmitTransaction as K, count as L, aggregate as M, subscribe as N, useAuth as O, deserializeTransaction as P, getIdToken as Q, setPlatform as R, SOLANA_MAINNET_RPC_URL as S, MockAuthProvider as T, DEFAULT_TEST_ADDRESS as U, OffchainAuthProvider as V, WebSessionManager as W, PrivyExpoProvider as X, InsufficientBalanceError as Y, ReactNativeSessionManager as Z, ServerSessionManager as _, SOLANA_DEVNET_RPC_URL as a, closeAllSubscriptions as a0, getCachedData as a1, getMany as a2, reconnectWithNewAuth as a3, refreshSession as a4, signSessionCreateMessage as a5, index as a6, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, bs58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, detectAndroid as h, SURFNET_RPC_URL$1 as i, detectMobile as j, setAuthLoading as k, genAuthNonce as l, genSolanaMessage as m, createSessionWithSignature as n, getDefaultExportFromCjs$1 as o, init as p, getCurrentUser as q, onAuthStateChanged as r, setCurrentUser as s, onAuthLoadingChanged as t, getAuthLoading as u, login as v, logout as w, getConfig as x, getAuthProvider as y, get as z };
|
|
13705
|
+
//# sourceMappingURL=index.native-UxpBL0TA.esm.js.map
|