@pooflabs/web 0.0.78 → 0.0.79-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-6pNPzV1t.esm.js +6 -0
- package/dist/index-6pNPzV1t.esm.js.map +1 -0
- package/dist/{index-DE7k2G22.js → index-BHGEc97p.js} +883 -25
- package/dist/index-BHGEc97p.js.map +1 -0
- package/dist/{index-OAJ0rndN.esm.js → index-CiwYJvf8.esm.js} +882 -24
- package/dist/index-CiwYJvf8.esm.js.map +1 -0
- package/dist/{index-CwGoYY0Y.esm.js → index-CsIXFm8d.esm.js} +335 -517
- package/dist/index-CsIXFm8d.esm.js.map +1 -0
- package/dist/index-D9BY44i-.js +8 -0
- package/dist/index-D9BY44i-.js.map +1 -0
- package/dist/{index-Cp727oEW.js → index-DwU9hjtr.js} +334 -517
- package/dist/index-DwU9hjtr.js.map +1 -0
- package/dist/{index-Cmu0PVJD.esm.js → index-U-xlsKRI.esm.js} +881 -23
- package/dist/index-U-xlsKRI.esm.js.map +1 -0
- package/dist/{index-CKaaE12K.js → index-zS_Y-wbi.js} +882 -24
- package/dist/index-zS_Y-wbi.js.map +1 -0
- package/dist/{index.browser-DFeGGyO7.esm.js → index.browser-C9bFQZyQ.esm.js} +128 -5
- package/dist/index.browser-C9bFQZyQ.esm.js.map +1 -0
- package/dist/{index.browser-B4een3Gz.esm.js → index.browser-CMEwqnEe.esm.js} +2 -2
- package/dist/{index.browser-B4een3Gz.esm.js.map → index.browser-CMEwqnEe.esm.js.map} +1 -1
- package/dist/{index.browser-AZQ5TnZ4.js → index.browser-Cpi4W_1r.js} +2 -2
- package/dist/{index.browser-AZQ5TnZ4.js.map → index.browser-Cpi4W_1r.js.map} +1 -1
- package/dist/{index.browser-x87QUr4N.esm.js → index.browser-Dbq5Qf1G.esm.js} +128 -5
- package/dist/index.browser-Dbq5Qf1G.esm.js.map +1 -0
- package/dist/{index.browser-BMtEulGJ.js → index.browser-Df7yN8D5.js} +129 -6
- package/dist/index.browser-Df7yN8D5.js.map +1 -0
- package/dist/{index.browser-QPkAiPQp.js → index.browser-dszs5oe5.js} +129 -6
- package/dist/index.browser-dszs5oe5.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index.native-CjEJXA9y.esm.js → index.native-CEf5PJ_g.esm.js} +2690 -550
- package/dist/index.native-CEf5PJ_g.esm.js.map +1 -0
- package/dist/{index.native-D7IrIMX1.js → index.native-DtxPWD00.js} +2690 -549
- package/dist/index.native-DtxPWD00.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/{phantom-wallet-provider-B1TleWsy.esm.js → phantom-wallet-provider-B0UmUtfB.esm.js} +51 -4
- package/dist/{phantom-wallet-provider-B1TleWsy.esm.js.map → phantom-wallet-provider-B0UmUtfB.esm.js.map} +1 -1
- package/dist/{phantom-wallet-provider-DwmdHVd-.js → phantom-wallet-provider-BbyQIlro.js} +51 -4
- package/dist/{phantom-wallet-provider-DwmdHVd-.js.map → phantom-wallet-provider-BbyQIlro.js.map} +1 -1
- package/dist/{privy-wallet-provider-Cf6WgpK1.js → privy-wallet-provider-CoQzq0F4.js} +3 -3
- package/dist/privy-wallet-provider-CoQzq0F4.js.map +1 -0
- package/dist/{privy-wallet-provider-CZgiUwUN.esm.js → privy-wallet-provider-DGjYglh7.esm.js} +3 -3
- package/dist/privy-wallet-provider-DGjYglh7.esm.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-DZmpeNIS.js → solana-mobile-wallet-provider-BLoovRsJ.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-DZmpeNIS.js.map → solana-mobile-wallet-provider-BLoovRsJ.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-C9j8O3mD.esm.js → solana-mobile-wallet-provider-DIyP-Az5.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-C9j8O3mD.esm.js.map → solana-mobile-wallet-provider-DIyP-Az5.esm.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-Bdcc5821.js +0 -2375
- package/dist/index-Bdcc5821.js.map +0 -1
- package/dist/index-CKaaE12K.js.map +0 -1
- package/dist/index-Cmu0PVJD.esm.js.map +0 -1
- package/dist/index-Cp727oEW.js.map +0 -1
- package/dist/index-CrOVJFX9.esm.js +0 -2373
- package/dist/index-CrOVJFX9.esm.js.map +0 -1
- package/dist/index-CwGoYY0Y.esm.js.map +0 -1
- package/dist/index-DE7k2G22.js.map +0 -1
- package/dist/index-OAJ0rndN.esm.js.map +0 -1
- package/dist/index.browser-BMtEulGJ.js.map +0 -1
- package/dist/index.browser-DFeGGyO7.esm.js.map +0 -1
- package/dist/index.browser-QPkAiPQp.js.map +0 -1
- package/dist/index.browser-x87QUr4N.esm.js.map +0 -1
- package/dist/index.native-CjEJXA9y.esm.js.map +0 -1
- package/dist/index.native-D7IrIMX1.js.map +0 -1
- package/dist/privy-wallet-provider-CZgiUwUN.esm.js.map +0 -1
- package/dist/privy-wallet-provider-Cf6WgpK1.js.map +0 -1
|
@@ -22,6 +22,21 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function _mergeNamespaces(n, m) {
|
|
26
|
+
m.forEach(function (e) {
|
|
27
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
28
|
+
if (k !== 'default' && !(k in n)) {
|
|
29
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return e[k]; }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return Object.freeze(n);
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
|
|
26
41
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
42
|
|
|
@@ -6400,261 +6415,6 @@ var ReconnectingWebSocket = /** @class */ (function () {
|
|
|
6400
6415
|
return ReconnectingWebSocket;
|
|
6401
6416
|
}());
|
|
6402
6417
|
|
|
6403
|
-
function getDefaultExportFromCjs (x) {
|
|
6404
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6405
|
-
}
|
|
6406
|
-
|
|
6407
|
-
var isRetryAllowed$1;
|
|
6408
|
-
var hasRequiredIsRetryAllowed;
|
|
6409
|
-
|
|
6410
|
-
function requireIsRetryAllowed () {
|
|
6411
|
-
if (hasRequiredIsRetryAllowed) return isRetryAllowed$1;
|
|
6412
|
-
hasRequiredIsRetryAllowed = 1;
|
|
6413
|
-
|
|
6414
|
-
const denyList = new Set([
|
|
6415
|
-
'ENOTFOUND',
|
|
6416
|
-
'ENETUNREACH',
|
|
6417
|
-
|
|
6418
|
-
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
|
|
6419
|
-
'UNABLE_TO_GET_ISSUER_CERT',
|
|
6420
|
-
'UNABLE_TO_GET_CRL',
|
|
6421
|
-
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
|
6422
|
-
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
|
|
6423
|
-
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
|
|
6424
|
-
'CERT_SIGNATURE_FAILURE',
|
|
6425
|
-
'CRL_SIGNATURE_FAILURE',
|
|
6426
|
-
'CERT_NOT_YET_VALID',
|
|
6427
|
-
'CERT_HAS_EXPIRED',
|
|
6428
|
-
'CRL_NOT_YET_VALID',
|
|
6429
|
-
'CRL_HAS_EXPIRED',
|
|
6430
|
-
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
|
|
6431
|
-
'ERROR_IN_CERT_NOT_AFTER_FIELD',
|
|
6432
|
-
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
|
|
6433
|
-
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
|
|
6434
|
-
'OUT_OF_MEM',
|
|
6435
|
-
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
6436
|
-
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
6437
|
-
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
6438
|
-
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
6439
|
-
'CERT_CHAIN_TOO_LONG',
|
|
6440
|
-
'CERT_REVOKED',
|
|
6441
|
-
'INVALID_CA',
|
|
6442
|
-
'PATH_LENGTH_EXCEEDED',
|
|
6443
|
-
'INVALID_PURPOSE',
|
|
6444
|
-
'CERT_UNTRUSTED',
|
|
6445
|
-
'CERT_REJECTED',
|
|
6446
|
-
'HOSTNAME_MISMATCH'
|
|
6447
|
-
]);
|
|
6448
|
-
|
|
6449
|
-
// TODO: Use `error?.code` when targeting Node.js 14
|
|
6450
|
-
isRetryAllowed$1 = error => !denyList.has(error && error.code);
|
|
6451
|
-
return isRetryAllowed$1;
|
|
6452
|
-
}
|
|
6453
|
-
|
|
6454
|
-
var isRetryAllowedExports = requireIsRetryAllowed();
|
|
6455
|
-
var isRetryAllowed = /*@__PURE__*/getDefaultExportFromCjs(isRetryAllowedExports);
|
|
6456
|
-
|
|
6457
|
-
const namespace = 'axios-retry';
|
|
6458
|
-
function isNetworkError(error) {
|
|
6459
|
-
const CODE_EXCLUDE_LIST = ['ERR_CANCELED', 'ECONNABORTED'];
|
|
6460
|
-
if (error.response) {
|
|
6461
|
-
return false;
|
|
6462
|
-
}
|
|
6463
|
-
if (!error.code) {
|
|
6464
|
-
return false;
|
|
6465
|
-
}
|
|
6466
|
-
// Prevents retrying timed out & cancelled requests
|
|
6467
|
-
if (CODE_EXCLUDE_LIST.includes(error.code)) {
|
|
6468
|
-
return false;
|
|
6469
|
-
}
|
|
6470
|
-
// Prevents retrying unsafe errors
|
|
6471
|
-
return isRetryAllowed(error);
|
|
6472
|
-
}
|
|
6473
|
-
const SAFE_HTTP_METHODS = ['get', 'head', 'options'];
|
|
6474
|
-
const IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
|
|
6475
|
-
function isRetryableError(error) {
|
|
6476
|
-
return (error.code !== 'ECONNABORTED' &&
|
|
6477
|
-
(!error.response ||
|
|
6478
|
-
error.response.status === 429 ||
|
|
6479
|
-
(error.response.status >= 500 && error.response.status <= 599)));
|
|
6480
|
-
}
|
|
6481
|
-
function isSafeRequestError(error) {
|
|
6482
|
-
if (!error.config?.method) {
|
|
6483
|
-
// Cannot determine if the request can be retried
|
|
6484
|
-
return false;
|
|
6485
|
-
}
|
|
6486
|
-
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6487
|
-
}
|
|
6488
|
-
function isIdempotentRequestError(error) {
|
|
6489
|
-
if (!error.config?.method) {
|
|
6490
|
-
// Cannot determine if the request can be retried
|
|
6491
|
-
return false;
|
|
6492
|
-
}
|
|
6493
|
-
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6494
|
-
}
|
|
6495
|
-
function isNetworkOrIdempotentRequestError(error) {
|
|
6496
|
-
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
6497
|
-
}
|
|
6498
|
-
function retryAfter(error = undefined) {
|
|
6499
|
-
const retryAfterHeader = error?.response?.headers['retry-after'];
|
|
6500
|
-
if (!retryAfterHeader) {
|
|
6501
|
-
return 0;
|
|
6502
|
-
}
|
|
6503
|
-
// if the retry after header is a number, convert it to milliseconds
|
|
6504
|
-
let retryAfterMs = (Number(retryAfterHeader) || 0) * 1000;
|
|
6505
|
-
// If the retry after header is a date, get the number of milliseconds until that date
|
|
6506
|
-
if (retryAfterMs === 0) {
|
|
6507
|
-
retryAfterMs = (new Date(retryAfterHeader).valueOf() || 0) - Date.now();
|
|
6508
|
-
}
|
|
6509
|
-
return Math.max(0, retryAfterMs);
|
|
6510
|
-
}
|
|
6511
|
-
function noDelay(_retryNumber = 0, error = undefined) {
|
|
6512
|
-
return Math.max(0, retryAfter(error));
|
|
6513
|
-
}
|
|
6514
|
-
function exponentialDelay(retryNumber = 0, error = undefined, delayFactor = 100) {
|
|
6515
|
-
const calculatedDelay = 2 ** retryNumber * delayFactor;
|
|
6516
|
-
const delay = Math.max(calculatedDelay, retryAfter(error));
|
|
6517
|
-
const randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay
|
|
6518
|
-
return delay + randomSum;
|
|
6519
|
-
}
|
|
6520
|
-
/**
|
|
6521
|
-
* Linear delay
|
|
6522
|
-
* @param {number | undefined} delayFactor - delay factor in milliseconds (default: 100)
|
|
6523
|
-
* @returns {function} (retryNumber: number, error: AxiosError | undefined) => number
|
|
6524
|
-
*/
|
|
6525
|
-
function linearDelay(delayFactor = 100) {
|
|
6526
|
-
return (retryNumber = 0, error = undefined) => {
|
|
6527
|
-
const delay = retryNumber * delayFactor;
|
|
6528
|
-
return Math.max(delay, retryAfter(error));
|
|
6529
|
-
};
|
|
6530
|
-
}
|
|
6531
|
-
const DEFAULT_OPTIONS = {
|
|
6532
|
-
retries: 3,
|
|
6533
|
-
retryCondition: isNetworkOrIdempotentRequestError,
|
|
6534
|
-
retryDelay: noDelay,
|
|
6535
|
-
shouldResetTimeout: false,
|
|
6536
|
-
onRetry: () => { },
|
|
6537
|
-
onMaxRetryTimesExceeded: () => { },
|
|
6538
|
-
validateResponse: null
|
|
6539
|
-
};
|
|
6540
|
-
function getRequestOptions(config, defaultOptions) {
|
|
6541
|
-
return { ...DEFAULT_OPTIONS, ...defaultOptions, ...config[namespace] };
|
|
6542
|
-
}
|
|
6543
|
-
function setCurrentState(config, defaultOptions, resetLastRequestTime = false) {
|
|
6544
|
-
const currentState = getRequestOptions(config, defaultOptions || {});
|
|
6545
|
-
currentState.retryCount = currentState.retryCount || 0;
|
|
6546
|
-
if (!currentState.lastRequestTime || resetLastRequestTime) {
|
|
6547
|
-
currentState.lastRequestTime = Date.now();
|
|
6548
|
-
}
|
|
6549
|
-
config[namespace] = currentState;
|
|
6550
|
-
return currentState;
|
|
6551
|
-
}
|
|
6552
|
-
function fixConfig(axiosInstance, config) {
|
|
6553
|
-
// @ts-ignore
|
|
6554
|
-
if (axiosInstance.defaults.agent === config.agent) {
|
|
6555
|
-
// @ts-ignore
|
|
6556
|
-
delete config.agent;
|
|
6557
|
-
}
|
|
6558
|
-
if (axiosInstance.defaults.httpAgent === config.httpAgent) {
|
|
6559
|
-
delete config.httpAgent;
|
|
6560
|
-
}
|
|
6561
|
-
if (axiosInstance.defaults.httpsAgent === config.httpsAgent) {
|
|
6562
|
-
delete config.httpsAgent;
|
|
6563
|
-
}
|
|
6564
|
-
}
|
|
6565
|
-
async function shouldRetry(currentState, error) {
|
|
6566
|
-
const { retries, retryCondition } = currentState;
|
|
6567
|
-
const shouldRetryOrPromise = (currentState.retryCount || 0) < retries && retryCondition(error);
|
|
6568
|
-
// This could be a promise
|
|
6569
|
-
if (typeof shouldRetryOrPromise === 'object') {
|
|
6570
|
-
try {
|
|
6571
|
-
const shouldRetryPromiseResult = await shouldRetryOrPromise;
|
|
6572
|
-
// keep return true unless shouldRetryPromiseResult return false for compatibility
|
|
6573
|
-
return shouldRetryPromiseResult !== false;
|
|
6574
|
-
}
|
|
6575
|
-
catch (_err) {
|
|
6576
|
-
return false;
|
|
6577
|
-
}
|
|
6578
|
-
}
|
|
6579
|
-
return shouldRetryOrPromise;
|
|
6580
|
-
}
|
|
6581
|
-
async function handleRetry(axiosInstance, currentState, error, config) {
|
|
6582
|
-
currentState.retryCount += 1;
|
|
6583
|
-
const { retryDelay, shouldResetTimeout, onRetry } = currentState;
|
|
6584
|
-
const delay = retryDelay(currentState.retryCount, error);
|
|
6585
|
-
// Axios fails merging this configuration to the default configuration because it has an issue
|
|
6586
|
-
// with circular structures: https://github.com/mzabriskie/axios/issues/370
|
|
6587
|
-
fixConfig(axiosInstance, config);
|
|
6588
|
-
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
6589
|
-
const lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
6590
|
-
const timeout = config.timeout - lastRequestDuration - delay;
|
|
6591
|
-
if (timeout <= 0) {
|
|
6592
|
-
return Promise.reject(error);
|
|
6593
|
-
}
|
|
6594
|
-
config.timeout = timeout;
|
|
6595
|
-
}
|
|
6596
|
-
config.transformRequest = [(data) => data];
|
|
6597
|
-
await onRetry(currentState.retryCount, error, config);
|
|
6598
|
-
if (config.signal?.aborted) {
|
|
6599
|
-
return Promise.resolve(axiosInstance(config));
|
|
6600
|
-
}
|
|
6601
|
-
return new Promise((resolve) => {
|
|
6602
|
-
const abortListener = () => {
|
|
6603
|
-
clearTimeout(timeout);
|
|
6604
|
-
resolve(axiosInstance(config));
|
|
6605
|
-
};
|
|
6606
|
-
const timeout = setTimeout(() => {
|
|
6607
|
-
resolve(axiosInstance(config));
|
|
6608
|
-
if (config.signal?.removeEventListener) {
|
|
6609
|
-
config.signal.removeEventListener('abort', abortListener);
|
|
6610
|
-
}
|
|
6611
|
-
}, delay);
|
|
6612
|
-
if (config.signal?.addEventListener) {
|
|
6613
|
-
config.signal.addEventListener('abort', abortListener, { once: true });
|
|
6614
|
-
}
|
|
6615
|
-
});
|
|
6616
|
-
}
|
|
6617
|
-
async function handleMaxRetryTimesExceeded(currentState, error) {
|
|
6618
|
-
if (currentState.retryCount >= currentState.retries)
|
|
6619
|
-
await currentState.onMaxRetryTimesExceeded(error, currentState.retryCount);
|
|
6620
|
-
}
|
|
6621
|
-
const axiosRetry = (axiosInstance, defaultOptions) => {
|
|
6622
|
-
const requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
|
|
6623
|
-
setCurrentState(config, defaultOptions, true);
|
|
6624
|
-
if (config[namespace]?.validateResponse) {
|
|
6625
|
-
// by setting this, all HTTP responses will be go through the error interceptor first
|
|
6626
|
-
config.validateStatus = () => false;
|
|
6627
|
-
}
|
|
6628
|
-
return config;
|
|
6629
|
-
});
|
|
6630
|
-
const responseInterceptorId = axiosInstance.interceptors.response.use(null, async (error) => {
|
|
6631
|
-
const { config } = error;
|
|
6632
|
-
// If we have no information to retry the request
|
|
6633
|
-
if (!config) {
|
|
6634
|
-
return Promise.reject(error);
|
|
6635
|
-
}
|
|
6636
|
-
const currentState = setCurrentState(config, defaultOptions);
|
|
6637
|
-
if (error.response && currentState.validateResponse?.(error.response)) {
|
|
6638
|
-
// no issue with response
|
|
6639
|
-
return error.response;
|
|
6640
|
-
}
|
|
6641
|
-
if (await shouldRetry(currentState, error)) {
|
|
6642
|
-
return handleRetry(axiosInstance, currentState, error, config);
|
|
6643
|
-
}
|
|
6644
|
-
await handleMaxRetryTimesExceeded(currentState, error);
|
|
6645
|
-
return Promise.reject(error);
|
|
6646
|
-
});
|
|
6647
|
-
return { requestInterceptorId, responseInterceptorId };
|
|
6648
|
-
};
|
|
6649
|
-
// Compatibility with CommonJS
|
|
6650
|
-
axiosRetry.isNetworkError = isNetworkError;
|
|
6651
|
-
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
6652
|
-
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
6653
|
-
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
6654
|
-
axiosRetry.exponentialDelay = exponentialDelay;
|
|
6655
|
-
axiosRetry.linearDelay = linearDelay;
|
|
6656
|
-
axiosRetry.isRetryableError = isRetryableError;
|
|
6657
|
-
|
|
6658
6418
|
let axiosClient;
|
|
6659
6419
|
async function getAxiosAuthClient() {
|
|
6660
6420
|
if (!axiosClient) {
|
|
@@ -6664,7 +6424,6 @@ async function getAxiosAuthClient() {
|
|
|
6664
6424
|
headers: {
|
|
6665
6425
|
'Content-Type': 'application/json',
|
|
6666
6426
|
},
|
|
6667
|
-
timeout: 30000, // 30s timeout, matching makeApiRequest
|
|
6668
6427
|
});
|
|
6669
6428
|
}
|
|
6670
6429
|
return axiosClient;
|
|
@@ -6711,41 +6470,15 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
|
|
|
6711
6470
|
});
|
|
6712
6471
|
return response.data;
|
|
6713
6472
|
}
|
|
6714
|
-
// Deduplicate concurrent refreshSession calls to prevent multiple code paths
|
|
6715
|
-
// (WebSocket reconnection, periodic refresh, API 401 retry) from all hitting
|
|
6716
|
-
// /session/refresh simultaneously.
|
|
6717
|
-
// Note: module-level state is shared across requests in SSR/Node — acceptable
|
|
6718
|
-
// since there is only one active session per server instance (same pattern as
|
|
6719
|
-
// refreshInFlight in api.ts).
|
|
6720
|
-
let refreshInFlight$1 = null;
|
|
6721
|
-
let refreshInFlightToken = null;
|
|
6722
6473
|
async function refreshSession(refreshToken) {
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
const config = await getConfig();
|
|
6732
|
-
const appId = config.appId;
|
|
6733
|
-
const response = await client.post('/session/refresh', {
|
|
6734
|
-
refreshToken,
|
|
6735
|
-
appId
|
|
6736
|
-
});
|
|
6737
|
-
return response.data;
|
|
6738
|
-
}
|
|
6739
|
-
finally {
|
|
6740
|
-
// Only clear if we're still the active in-flight request.
|
|
6741
|
-
// A second call with a different token may have replaced us.
|
|
6742
|
-
if (refreshInFlight$1 === currentFlight) {
|
|
6743
|
-
refreshInFlight$1 = null;
|
|
6744
|
-
refreshInFlightToken = null;
|
|
6745
|
-
}
|
|
6746
|
-
}
|
|
6747
|
-
})();
|
|
6748
|
-
return refreshInFlight$1;
|
|
6474
|
+
const client = await getAxiosAuthClient();
|
|
6475
|
+
const config = await getConfig();
|
|
6476
|
+
const appId = config.appId;
|
|
6477
|
+
const response = await client.post('/session/refresh', {
|
|
6478
|
+
refreshToken,
|
|
6479
|
+
appId
|
|
6480
|
+
});
|
|
6481
|
+
return response.data;
|
|
6749
6482
|
}
|
|
6750
6483
|
async function signSessionCreateMessage(_signMessageFunction) {
|
|
6751
6484
|
}
|
|
@@ -6883,23 +6616,27 @@ class WebSessionManager {
|
|
|
6883
6616
|
WebSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
|
|
6884
6617
|
|
|
6885
6618
|
var webSessionManager = /*#__PURE__*/Object.freeze({
|
|
6886
|
-
|
|
6887
|
-
|
|
6619
|
+
__proto__: null,
|
|
6620
|
+
WebSessionManager: WebSessionManager
|
|
6888
6621
|
});
|
|
6889
6622
|
|
|
6890
|
-
|
|
6623
|
+
function getDefaultExportFromCjs (x) {
|
|
6624
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6625
|
+
}
|
|
6891
6626
|
|
|
6892
|
-
var
|
|
6627
|
+
var buffer$1 = {};
|
|
6893
6628
|
|
|
6894
|
-
var
|
|
6629
|
+
var base64Js$1 = {};
|
|
6895
6630
|
|
|
6896
|
-
|
|
6897
|
-
if (hasRequiredBase64Js) return base64Js;
|
|
6898
|
-
hasRequiredBase64Js = 1;
|
|
6631
|
+
var hasRequiredBase64Js$1;
|
|
6899
6632
|
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6633
|
+
function requireBase64Js$1 () {
|
|
6634
|
+
if (hasRequiredBase64Js$1) return base64Js$1;
|
|
6635
|
+
hasRequiredBase64Js$1 = 1;
|
|
6636
|
+
|
|
6637
|
+
base64Js$1.byteLength = byteLength;
|
|
6638
|
+
base64Js$1.toByteArray = toByteArray;
|
|
6639
|
+
base64Js$1.fromByteArray = fromByteArray;
|
|
6903
6640
|
|
|
6904
6641
|
var lookup = [];
|
|
6905
6642
|
var revLookup = [];
|
|
@@ -7045,19 +6782,19 @@ function requireBase64Js () {
|
|
|
7045
6782
|
|
|
7046
6783
|
return parts.join('')
|
|
7047
6784
|
}
|
|
7048
|
-
return base64Js;
|
|
6785
|
+
return base64Js$1;
|
|
7049
6786
|
}
|
|
7050
6787
|
|
|
7051
|
-
var ieee754 = {};
|
|
6788
|
+
var ieee754$1 = {};
|
|
7052
6789
|
|
|
7053
6790
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
7054
6791
|
|
|
7055
|
-
var hasRequiredIeee754;
|
|
6792
|
+
var hasRequiredIeee754$1;
|
|
7056
6793
|
|
|
7057
|
-
function requireIeee754 () {
|
|
7058
|
-
if (hasRequiredIeee754) return ieee754;
|
|
7059
|
-
hasRequiredIeee754 = 1;
|
|
7060
|
-
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
6794
|
+
function requireIeee754$1 () {
|
|
6795
|
+
if (hasRequiredIeee754$1) return ieee754$1;
|
|
6796
|
+
hasRequiredIeee754$1 = 1;
|
|
6797
|
+
ieee754$1.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
7061
6798
|
var e, m;
|
|
7062
6799
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
7063
6800
|
var eMax = (1 << eLen) - 1;
|
|
@@ -7090,7 +6827,7 @@ function requireIeee754 () {
|
|
|
7090
6827
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
7091
6828
|
};
|
|
7092
6829
|
|
|
7093
|
-
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
6830
|
+
ieee754$1.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
7094
6831
|
var e, m, c;
|
|
7095
6832
|
var eLen = (nBytes * 8) - mLen - 1;
|
|
7096
6833
|
var eMax = (1 << eLen) - 1;
|
|
@@ -7141,7 +6878,7 @@ function requireIeee754 () {
|
|
|
7141
6878
|
|
|
7142
6879
|
buffer[offset + i - d] |= s * 128;
|
|
7143
6880
|
};
|
|
7144
|
-
return ieee754;
|
|
6881
|
+
return ieee754$1;
|
|
7145
6882
|
}
|
|
7146
6883
|
|
|
7147
6884
|
/*!
|
|
@@ -7151,15 +6888,15 @@ function requireIeee754 () {
|
|
|
7151
6888
|
* @license MIT
|
|
7152
6889
|
*/
|
|
7153
6890
|
|
|
7154
|
-
var hasRequiredBuffer;
|
|
6891
|
+
var hasRequiredBuffer$1;
|
|
7155
6892
|
|
|
7156
|
-
function requireBuffer () {
|
|
7157
|
-
if (hasRequiredBuffer) return buffer;
|
|
7158
|
-
hasRequiredBuffer = 1;
|
|
6893
|
+
function requireBuffer$1 () {
|
|
6894
|
+
if (hasRequiredBuffer$1) return buffer$1;
|
|
6895
|
+
hasRequiredBuffer$1 = 1;
|
|
7159
6896
|
(function (exports$1) {
|
|
7160
6897
|
|
|
7161
|
-
const base64 = requireBase64Js();
|
|
7162
|
-
const ieee754 = requireIeee754();
|
|
6898
|
+
const base64 = requireBase64Js$1();
|
|
6899
|
+
const ieee754 = requireIeee754$1();
|
|
7163
6900
|
const customInspectSymbol =
|
|
7164
6901
|
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
7165
6902
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
@@ -9252,24 +8989,24 @@ function requireBuffer () {
|
|
|
9252
8989
|
function BufferBigIntNotDefined () {
|
|
9253
8990
|
throw new Error('BigInt not supported')
|
|
9254
8991
|
}
|
|
9255
|
-
} (buffer));
|
|
9256
|
-
return buffer;
|
|
8992
|
+
} (buffer$1));
|
|
8993
|
+
return buffer$1;
|
|
9257
8994
|
}
|
|
9258
8995
|
|
|
9259
|
-
var bufferExports = requireBuffer();
|
|
8996
|
+
var bufferExports = requireBuffer$1();
|
|
9260
8997
|
|
|
9261
|
-
var safeBuffer = {exports: {}};
|
|
8998
|
+
var safeBuffer$1 = {exports: {}};
|
|
9262
8999
|
|
|
9263
9000
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9264
9001
|
|
|
9265
|
-
var hasRequiredSafeBuffer;
|
|
9002
|
+
var hasRequiredSafeBuffer$1;
|
|
9266
9003
|
|
|
9267
|
-
function requireSafeBuffer () {
|
|
9268
|
-
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
9269
|
-
hasRequiredSafeBuffer = 1;
|
|
9004
|
+
function requireSafeBuffer$1 () {
|
|
9005
|
+
if (hasRequiredSafeBuffer$1) return safeBuffer$1.exports;
|
|
9006
|
+
hasRequiredSafeBuffer$1 = 1;
|
|
9270
9007
|
(function (module, exports$1) {
|
|
9271
9008
|
/* eslint-disable node/no-deprecated-api */
|
|
9272
|
-
var buffer = requireBuffer();
|
|
9009
|
+
var buffer = requireBuffer$1();
|
|
9273
9010
|
var Buffer = buffer.Buffer;
|
|
9274
9011
|
|
|
9275
9012
|
// alternative to using Object.keys for old browsers
|
|
@@ -9332,23 +9069,23 @@ function requireSafeBuffer () {
|
|
|
9332
9069
|
}
|
|
9333
9070
|
return buffer.SlowBuffer(size)
|
|
9334
9071
|
};
|
|
9335
|
-
} (safeBuffer, safeBuffer.exports));
|
|
9336
|
-
return safeBuffer.exports;
|
|
9072
|
+
} (safeBuffer$1, safeBuffer$1.exports));
|
|
9073
|
+
return safeBuffer$1.exports;
|
|
9337
9074
|
}
|
|
9338
9075
|
|
|
9339
|
-
var src;
|
|
9340
|
-
var hasRequiredSrc;
|
|
9076
|
+
var src$1;
|
|
9077
|
+
var hasRequiredSrc$1;
|
|
9341
9078
|
|
|
9342
|
-
function requireSrc () {
|
|
9343
|
-
if (hasRequiredSrc) return src;
|
|
9344
|
-
hasRequiredSrc = 1;
|
|
9079
|
+
function requireSrc$1 () {
|
|
9080
|
+
if (hasRequiredSrc$1) return src$1;
|
|
9081
|
+
hasRequiredSrc$1 = 1;
|
|
9345
9082
|
// base-x encoding / decoding
|
|
9346
9083
|
// Copyright (c) 2018 base-x contributors
|
|
9347
9084
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9348
9085
|
// Distributed under the MIT software license, see the accompanying
|
|
9349
9086
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9350
9087
|
// @ts-ignore
|
|
9351
|
-
var _Buffer = requireSafeBuffer().Buffer;
|
|
9088
|
+
var _Buffer = requireSafeBuffer$1().Buffer;
|
|
9352
9089
|
function base (ALPHABET) {
|
|
9353
9090
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9354
9091
|
var BASE_MAP = new Uint8Array(256);
|
|
@@ -9463,25 +9200,25 @@ function requireSrc () {
|
|
|
9463
9200
|
decode: decode
|
|
9464
9201
|
}
|
|
9465
9202
|
}
|
|
9466
|
-
src = base;
|
|
9467
|
-
return src;
|
|
9203
|
+
src$1 = base;
|
|
9204
|
+
return src$1;
|
|
9468
9205
|
}
|
|
9469
9206
|
|
|
9470
|
-
var bs58$1;
|
|
9471
|
-
var hasRequiredBs58;
|
|
9207
|
+
var bs58$1$1;
|
|
9208
|
+
var hasRequiredBs58$1;
|
|
9472
9209
|
|
|
9473
|
-
function requireBs58 () {
|
|
9474
|
-
if (hasRequiredBs58) return bs58$1;
|
|
9475
|
-
hasRequiredBs58 = 1;
|
|
9476
|
-
var basex = requireSrc();
|
|
9210
|
+
function requireBs58$1 () {
|
|
9211
|
+
if (hasRequiredBs58$1) return bs58$1$1;
|
|
9212
|
+
hasRequiredBs58$1 = 1;
|
|
9213
|
+
var basex = requireSrc$1();
|
|
9477
9214
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9478
9215
|
|
|
9479
|
-
bs58$1 = basex(ALPHABET);
|
|
9480
|
-
return bs58$1;
|
|
9216
|
+
bs58$1$1 = basex(ALPHABET);
|
|
9217
|
+
return bs58$1$1;
|
|
9481
9218
|
}
|
|
9482
9219
|
|
|
9483
|
-
var bs58Exports = requireBs58();
|
|
9484
|
-
var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
|
|
9220
|
+
var bs58Exports$1 = requireBs58$1();
|
|
9221
|
+
var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports$1);
|
|
9485
9222
|
|
|
9486
9223
|
// ─────────────────────────────────────────────────────────────
|
|
9487
9224
|
// Local implementation of getSimulationComputeUnits
|
|
@@ -9683,19 +9420,7 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
9683
9420
|
}
|
|
9684
9421
|
}
|
|
9685
9422
|
else if (lutKey != null) {
|
|
9686
|
-
|
|
9687
|
-
// may not have indexed it yet (load-balancer split). Retry with exponential
|
|
9688
|
-
// back-off; first retry at 100 ms almost always resolves it.
|
|
9689
|
-
let table = null;
|
|
9690
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
9691
|
-
const { value } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
|
|
9692
|
-
if (value) {
|
|
9693
|
-
table = value;
|
|
9694
|
-
break;
|
|
9695
|
-
}
|
|
9696
|
-
if (attempt < 4)
|
|
9697
|
-
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
9698
|
-
}
|
|
9423
|
+
const { value: table } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
|
|
9699
9424
|
if (!table)
|
|
9700
9425
|
throw new Error('LUT not found after creation/extend');
|
|
9701
9426
|
lookupTables.push(table);
|
|
@@ -9830,8 +9555,8 @@ class ServerSessionManager {
|
|
|
9830
9555
|
ServerSessionManager.instance = new ServerSessionManager();
|
|
9831
9556
|
|
|
9832
9557
|
var serverSessionManager = /*#__PURE__*/Object.freeze({
|
|
9833
|
-
|
|
9834
|
-
|
|
9558
|
+
__proto__: null,
|
|
9559
|
+
ServerSessionManager: ServerSessionManager
|
|
9835
9560
|
});
|
|
9836
9561
|
|
|
9837
9562
|
/**
|
|
@@ -9930,23 +9655,6 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
|
|
|
9930
9655
|
await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
|
|
9931
9656
|
}
|
|
9932
9657
|
|
|
9933
|
-
const apiClient = globalAxios.create();
|
|
9934
|
-
axiosRetry(apiClient, {
|
|
9935
|
-
retries: 2,
|
|
9936
|
-
retryCondition: (error) => {
|
|
9937
|
-
var _a, _b;
|
|
9938
|
-
// Only retry GET requests on network errors (ECONNRESET, ETIMEDOUT, etc.)
|
|
9939
|
-
// Writes (POST/PUT) are not retried — the server may have processed
|
|
9940
|
-
// the request before the connection was reset.
|
|
9941
|
-
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';
|
|
9942
|
-
},
|
|
9943
|
-
retryDelay: axiosRetry.exponentialDelay,
|
|
9944
|
-
shouldResetTimeout: true,
|
|
9945
|
-
onRetry: (retryCount, error, requestConfig) => {
|
|
9946
|
-
var _a;
|
|
9947
|
-
console.warn(`[tarobase-sdk] retry ${retryCount} for ${(_a = requestConfig.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${requestConfig.url} — ${error.code || error.message}`);
|
|
9948
|
-
},
|
|
9949
|
-
});
|
|
9950
9658
|
const refreshInFlight = new Map();
|
|
9951
9659
|
async function refreshAuthSessionOnce(appId, isServer) {
|
|
9952
9660
|
const key = `${isServer ? "server" : "web"}:${appId}`;
|
|
@@ -9993,7 +9701,6 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
9993
9701
|
ServerSessionManager.instance.clearSession();
|
|
9994
9702
|
};
|
|
9995
9703
|
async function executeRequest() {
|
|
9996
|
-
var _a;
|
|
9997
9704
|
// When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
|
|
9998
9705
|
// Otherwise use the global createAuthHeader (default path).
|
|
9999
9706
|
const authHeader = (_overrides === null || _overrides === void 0 ? void 0 : _overrides._getAuthHeaders)
|
|
@@ -10015,12 +9722,11 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
10015
9722
|
method,
|
|
10016
9723
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
10017
9724
|
headers,
|
|
10018
|
-
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : 30000,
|
|
10019
9725
|
};
|
|
10020
9726
|
if (method !== "GET" && method !== "get") {
|
|
10021
9727
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
10022
9728
|
}
|
|
10023
|
-
const response = await
|
|
9729
|
+
const response = await globalAxios(requestConfig);
|
|
10024
9730
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
10025
9731
|
}
|
|
10026
9732
|
try {
|
|
@@ -10956,7 +10662,6 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10956
10662
|
// This replaces the old single setTimeout approach which was unreliable for long
|
|
10957
10663
|
// delays (browsers throttle/suspend timers in background tabs).
|
|
10958
10664
|
connection.tokenRefreshTimer = setInterval(async () => {
|
|
10959
|
-
var _a, _b;
|
|
10960
10665
|
try {
|
|
10961
10666
|
const currentToken = await getIdToken$1(isServer);
|
|
10962
10667
|
if (!currentToken)
|
|
@@ -10987,17 +10692,6 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10987
10692
|
}
|
|
10988
10693
|
}
|
|
10989
10694
|
catch (refreshError) {
|
|
10990
|
-
// If the refresh token itself is invalid (401/403), stop retrying —
|
|
10991
|
-
// the token won't magically become valid next interval, and continuing
|
|
10992
|
-
// to hammer /session/refresh causes 429 rate-limit storms.
|
|
10993
|
-
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) {
|
|
10994
|
-
console.warn('[WS v2] Refresh token rejected (401/403), stopping periodic refresh');
|
|
10995
|
-
if (connection.tokenRefreshTimer) {
|
|
10996
|
-
clearInterval(connection.tokenRefreshTimer);
|
|
10997
|
-
connection.tokenRefreshTimer = null;
|
|
10998
|
-
}
|
|
10999
|
-
return;
|
|
11000
|
-
}
|
|
11001
10695
|
console.warn('[WS v2] Proactive token refresh failed, will retry next interval:', refreshError);
|
|
11002
10696
|
}
|
|
11003
10697
|
}
|
|
@@ -11008,7 +10702,6 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
11008
10702
|
}, TOKEN_CHECK_INTERVAL);
|
|
11009
10703
|
}
|
|
11010
10704
|
async function getFreshAuthToken(isServer) {
|
|
11011
|
-
var _a, _b;
|
|
11012
10705
|
const currentToken = await getIdToken$1(isServer);
|
|
11013
10706
|
if (!currentToken) {
|
|
11014
10707
|
return null;
|
|
@@ -11031,17 +10724,6 @@ async function getFreshAuthToken(isServer) {
|
|
|
11031
10724
|
}
|
|
11032
10725
|
catch (error) {
|
|
11033
10726
|
console.error('[WS v2] Error refreshing token:', error);
|
|
11034
|
-
// If the refresh token is permanently invalid (401/403), clear the stale
|
|
11035
|
-
// session from storage so future attempts don't keep retrying with it.
|
|
11036
|
-
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)) {
|
|
11037
|
-
try {
|
|
11038
|
-
const { WebSessionManager } = await Promise.resolve().then(function () { return webSessionManager; });
|
|
11039
|
-
WebSessionManager.clearSession();
|
|
11040
|
-
}
|
|
11041
|
-
catch (clearError) {
|
|
11042
|
-
console.warn('[WS v2] Failed to clear stale session:', clearError);
|
|
11043
|
-
}
|
|
11044
|
-
}
|
|
11045
10727
|
}
|
|
11046
10728
|
// Return null instead of the expired token to prevent infinite 401 reconnect storms.
|
|
11047
10729
|
// The server accepts unauthenticated connections; auth-required subscriptions will
|
|
@@ -11162,16 +10844,7 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
11162
10844
|
ws.addEventListener('open', () => {
|
|
11163
10845
|
connection.isConnecting = false;
|
|
11164
10846
|
connection.isConnected = true;
|
|
11165
|
-
|
|
11166
|
-
// fresh auth token is actually obtained (in urlProvider, line ~389) or on
|
|
11167
|
-
// an explicit auth change (reconnectWithNewAuthV2, line ~854). Resetting
|
|
11168
|
-
// on every 'open' event created an infinite loop: auth fails 5x → connect
|
|
11169
|
-
// without auth → open resets counter → disconnect → auth fails 5x again →
|
|
11170
|
-
// repeat forever, hammering /session/refresh and causing 429s.
|
|
11171
|
-
//
|
|
11172
|
-
// An elevated counter is safe for anonymous/guest sessions: when there's no
|
|
11173
|
-
// token at all (getIdToken returns null), the counter is never checked —
|
|
11174
|
-
// urlProvider skips straight to unauthenticated connection.
|
|
10847
|
+
connection.consecutiveAuthFailures = 0;
|
|
11175
10848
|
// Schedule periodic token freshness checks
|
|
11176
10849
|
scheduleTokenRefresh(connection, isServer);
|
|
11177
10850
|
// Re-subscribe to all existing subscriptions after reconnect
|
|
@@ -12833,15 +12506,15 @@ function clearIncompatibleSession() {
|
|
|
12833
12506
|
// Lazy loaders for web-only providers.
|
|
12834
12507
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
12835
12508
|
async function loadPrivyWalletProvider() {
|
|
12836
|
-
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-
|
|
12509
|
+
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-CoQzq0F4.js'); });
|
|
12837
12510
|
return mod.PrivyWalletProvider;
|
|
12838
12511
|
}
|
|
12839
12512
|
async function loadPhantomWalletProvider() {
|
|
12840
|
-
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-
|
|
12513
|
+
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-BbyQIlro.js'); });
|
|
12841
12514
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
12842
12515
|
}
|
|
12843
12516
|
async function loadSolanaMobileWalletProvider() {
|
|
12844
|
-
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-
|
|
12517
|
+
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-BLoovRsJ.js'); });
|
|
12845
12518
|
return mod.SolanaMobileWalletProvider;
|
|
12846
12519
|
}
|
|
12847
12520
|
async function hotSwapToPrivyProvider(config) {
|
|
@@ -13251,137 +12924,2604 @@ async function confirmAndCheckTransaction(connection, signature) {
|
|
|
13251
12924
|
throw new Error('Transaction confirmation timeout');
|
|
13252
12925
|
}
|
|
13253
12926
|
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
12927
|
+
var safeBuffer = {exports: {}};
|
|
12928
|
+
|
|
12929
|
+
var buffer = {};
|
|
12930
|
+
|
|
12931
|
+
var base64Js = {};
|
|
12932
|
+
|
|
12933
|
+
var hasRequiredBase64Js;
|
|
12934
|
+
|
|
12935
|
+
function requireBase64Js () {
|
|
12936
|
+
if (hasRequiredBase64Js) return base64Js;
|
|
12937
|
+
hasRequiredBase64Js = 1;
|
|
12938
|
+
|
|
12939
|
+
base64Js.byteLength = byteLength;
|
|
12940
|
+
base64Js.toByteArray = toByteArray;
|
|
12941
|
+
base64Js.fromByteArray = fromByteArray;
|
|
12942
|
+
|
|
12943
|
+
var lookup = [];
|
|
12944
|
+
var revLookup = [];
|
|
12945
|
+
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
12946
|
+
|
|
12947
|
+
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
12948
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
12949
|
+
lookup[i] = code[i];
|
|
12950
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
12951
|
+
}
|
|
12952
|
+
|
|
12953
|
+
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
12954
|
+
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
12955
|
+
revLookup['-'.charCodeAt(0)] = 62;
|
|
12956
|
+
revLookup['_'.charCodeAt(0)] = 63;
|
|
12957
|
+
|
|
12958
|
+
function getLens (b64) {
|
|
12959
|
+
var len = b64.length;
|
|
12960
|
+
|
|
12961
|
+
if (len % 4 > 0) {
|
|
12962
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
12963
|
+
}
|
|
12964
|
+
|
|
12965
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
12966
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
12967
|
+
var validLen = b64.indexOf('=');
|
|
12968
|
+
if (validLen === -1) validLen = len;
|
|
12969
|
+
|
|
12970
|
+
var placeHoldersLen = validLen === len
|
|
12971
|
+
? 0
|
|
12972
|
+
: 4 - (validLen % 4);
|
|
12973
|
+
|
|
12974
|
+
return [validLen, placeHoldersLen]
|
|
12975
|
+
}
|
|
12976
|
+
|
|
12977
|
+
// base64 is 4/3 + up to two characters of the original data
|
|
12978
|
+
function byteLength (b64) {
|
|
12979
|
+
var lens = getLens(b64);
|
|
12980
|
+
var validLen = lens[0];
|
|
12981
|
+
var placeHoldersLen = lens[1];
|
|
12982
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
12983
|
+
}
|
|
12984
|
+
|
|
12985
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
12986
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
12987
|
+
}
|
|
12988
|
+
|
|
12989
|
+
function toByteArray (b64) {
|
|
12990
|
+
var tmp;
|
|
12991
|
+
var lens = getLens(b64);
|
|
12992
|
+
var validLen = lens[0];
|
|
12993
|
+
var placeHoldersLen = lens[1];
|
|
12994
|
+
|
|
12995
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
12996
|
+
|
|
12997
|
+
var curByte = 0;
|
|
12998
|
+
|
|
12999
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
|
13000
|
+
var len = placeHoldersLen > 0
|
|
13001
|
+
? validLen - 4
|
|
13002
|
+
: validLen;
|
|
13003
|
+
|
|
13004
|
+
var i;
|
|
13005
|
+
for (i = 0; i < len; i += 4) {
|
|
13006
|
+
tmp =
|
|
13007
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
13008
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
13009
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
13010
|
+
revLookup[b64.charCodeAt(i + 3)];
|
|
13011
|
+
arr[curByte++] = (tmp >> 16) & 0xFF;
|
|
13012
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
13013
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13014
|
+
}
|
|
13015
|
+
|
|
13016
|
+
if (placeHoldersLen === 2) {
|
|
13017
|
+
tmp =
|
|
13018
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
13019
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4);
|
|
13020
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13021
|
+
}
|
|
13022
|
+
|
|
13023
|
+
if (placeHoldersLen === 1) {
|
|
13024
|
+
tmp =
|
|
13025
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
13026
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
13027
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2);
|
|
13028
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
13029
|
+
arr[curByte++] = tmp & 0xFF;
|
|
13030
|
+
}
|
|
13031
|
+
|
|
13032
|
+
return arr
|
|
13033
|
+
}
|
|
13034
|
+
|
|
13035
|
+
function tripletToBase64 (num) {
|
|
13036
|
+
return lookup[num >> 18 & 0x3F] +
|
|
13037
|
+
lookup[num >> 12 & 0x3F] +
|
|
13038
|
+
lookup[num >> 6 & 0x3F] +
|
|
13039
|
+
lookup[num & 0x3F]
|
|
13040
|
+
}
|
|
13041
|
+
|
|
13042
|
+
function encodeChunk (uint8, start, end) {
|
|
13043
|
+
var tmp;
|
|
13044
|
+
var output = [];
|
|
13045
|
+
for (var i = start; i < end; i += 3) {
|
|
13046
|
+
tmp =
|
|
13047
|
+
((uint8[i] << 16) & 0xFF0000) +
|
|
13048
|
+
((uint8[i + 1] << 8) & 0xFF00) +
|
|
13049
|
+
(uint8[i + 2] & 0xFF);
|
|
13050
|
+
output.push(tripletToBase64(tmp));
|
|
13051
|
+
}
|
|
13052
|
+
return output.join('')
|
|
13053
|
+
}
|
|
13054
|
+
|
|
13055
|
+
function fromByteArray (uint8) {
|
|
13056
|
+
var tmp;
|
|
13057
|
+
var len = uint8.length;
|
|
13058
|
+
var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
|
13059
|
+
var parts = [];
|
|
13060
|
+
var maxChunkLength = 16383; // must be multiple of 3
|
|
13061
|
+
|
|
13062
|
+
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
13063
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
13064
|
+
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
|
|
13065
|
+
}
|
|
13066
|
+
|
|
13067
|
+
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
13068
|
+
if (extraBytes === 1) {
|
|
13069
|
+
tmp = uint8[len - 1];
|
|
13070
|
+
parts.push(
|
|
13071
|
+
lookup[tmp >> 2] +
|
|
13072
|
+
lookup[(tmp << 4) & 0x3F] +
|
|
13073
|
+
'=='
|
|
13074
|
+
);
|
|
13075
|
+
} else if (extraBytes === 2) {
|
|
13076
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
13077
|
+
parts.push(
|
|
13078
|
+
lookup[tmp >> 10] +
|
|
13079
|
+
lookup[(tmp >> 4) & 0x3F] +
|
|
13080
|
+
lookup[(tmp << 2) & 0x3F] +
|
|
13081
|
+
'='
|
|
13082
|
+
);
|
|
13083
|
+
}
|
|
13084
|
+
|
|
13085
|
+
return parts.join('')
|
|
13086
|
+
}
|
|
13087
|
+
return base64Js;
|
|
13088
|
+
}
|
|
13089
|
+
|
|
13090
|
+
var ieee754 = {};
|
|
13091
|
+
|
|
13092
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
13093
|
+
|
|
13094
|
+
var hasRequiredIeee754;
|
|
13095
|
+
|
|
13096
|
+
function requireIeee754 () {
|
|
13097
|
+
if (hasRequiredIeee754) return ieee754;
|
|
13098
|
+
hasRequiredIeee754 = 1;
|
|
13099
|
+
ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
13100
|
+
var e, m;
|
|
13101
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
13102
|
+
var eMax = (1 << eLen) - 1;
|
|
13103
|
+
var eBias = eMax >> 1;
|
|
13104
|
+
var nBits = -7;
|
|
13105
|
+
var i = isLE ? (nBytes - 1) : 0;
|
|
13106
|
+
var d = isLE ? -1 : 1;
|
|
13107
|
+
var s = buffer[offset + i];
|
|
13108
|
+
|
|
13109
|
+
i += d;
|
|
13110
|
+
|
|
13111
|
+
e = s & ((1 << (-nBits)) - 1);
|
|
13112
|
+
s >>= (-nBits);
|
|
13113
|
+
nBits += eLen;
|
|
13114
|
+
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13115
|
+
|
|
13116
|
+
m = e & ((1 << (-nBits)) - 1);
|
|
13117
|
+
e >>= (-nBits);
|
|
13118
|
+
nBits += mLen;
|
|
13119
|
+
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
13120
|
+
|
|
13121
|
+
if (e === 0) {
|
|
13122
|
+
e = 1 - eBias;
|
|
13123
|
+
} else if (e === eMax) {
|
|
13124
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
13125
|
+
} else {
|
|
13126
|
+
m = m + Math.pow(2, mLen);
|
|
13127
|
+
e = e - eBias;
|
|
13128
|
+
}
|
|
13129
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
13130
|
+
};
|
|
13131
|
+
|
|
13132
|
+
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
13133
|
+
var e, m, c;
|
|
13134
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
13135
|
+
var eMax = (1 << eLen) - 1;
|
|
13136
|
+
var eBias = eMax >> 1;
|
|
13137
|
+
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
|
|
13138
|
+
var i = isLE ? 0 : (nBytes - 1);
|
|
13139
|
+
var d = isLE ? 1 : -1;
|
|
13140
|
+
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
13141
|
+
|
|
13142
|
+
value = Math.abs(value);
|
|
13143
|
+
|
|
13144
|
+
if (isNaN(value) || value === Infinity) {
|
|
13145
|
+
m = isNaN(value) ? 1 : 0;
|
|
13146
|
+
e = eMax;
|
|
13147
|
+
} else {
|
|
13148
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
13149
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
13150
|
+
e--;
|
|
13151
|
+
c *= 2;
|
|
13152
|
+
}
|
|
13153
|
+
if (e + eBias >= 1) {
|
|
13154
|
+
value += rt / c;
|
|
13155
|
+
} else {
|
|
13156
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
13157
|
+
}
|
|
13158
|
+
if (value * c >= 2) {
|
|
13159
|
+
e++;
|
|
13160
|
+
c /= 2;
|
|
13161
|
+
}
|
|
13162
|
+
|
|
13163
|
+
if (e + eBias >= eMax) {
|
|
13164
|
+
m = 0;
|
|
13165
|
+
e = eMax;
|
|
13166
|
+
} else if (e + eBias >= 1) {
|
|
13167
|
+
m = ((value * c) - 1) * Math.pow(2, mLen);
|
|
13168
|
+
e = e + eBias;
|
|
13169
|
+
} else {
|
|
13170
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
13171
|
+
e = 0;
|
|
13172
|
+
}
|
|
13173
|
+
}
|
|
13174
|
+
|
|
13175
|
+
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
13176
|
+
|
|
13177
|
+
e = (e << mLen) | m;
|
|
13178
|
+
eLen += mLen;
|
|
13179
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
13180
|
+
|
|
13181
|
+
buffer[offset + i - d] |= s * 128;
|
|
13182
|
+
};
|
|
13183
|
+
return ieee754;
|
|
13184
|
+
}
|
|
13185
|
+
|
|
13186
|
+
/*!
|
|
13187
|
+
* The buffer module from node.js, for the browser.
|
|
13188
|
+
*
|
|
13189
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
13190
|
+
* @license MIT
|
|
13191
|
+
*/
|
|
13192
|
+
|
|
13193
|
+
var hasRequiredBuffer;
|
|
13194
|
+
|
|
13195
|
+
function requireBuffer () {
|
|
13196
|
+
if (hasRequiredBuffer) return buffer;
|
|
13197
|
+
hasRequiredBuffer = 1;
|
|
13198
|
+
(function (exports$1) {
|
|
13199
|
+
|
|
13200
|
+
const base64 = requireBase64Js();
|
|
13201
|
+
const ieee754 = requireIeee754();
|
|
13202
|
+
const customInspectSymbol =
|
|
13203
|
+
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
13204
|
+
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
13205
|
+
: null;
|
|
13206
|
+
|
|
13207
|
+
exports$1.Buffer = Buffer;
|
|
13208
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
13209
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
13210
|
+
|
|
13211
|
+
const K_MAX_LENGTH = 0x7fffffff;
|
|
13212
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
13213
|
+
|
|
13214
|
+
/**
|
|
13215
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
13216
|
+
* === true Use Uint8Array implementation (fastest)
|
|
13217
|
+
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
13218
|
+
* implementation (most compatible, even IE6)
|
|
13219
|
+
*
|
|
13220
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
13221
|
+
* Opera 11.6+, iOS 4.2+.
|
|
13222
|
+
*
|
|
13223
|
+
* We report that the browser does not support typed arrays if the are not subclassable
|
|
13224
|
+
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
13225
|
+
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
13226
|
+
* for __proto__ and has a buggy typed array implementation.
|
|
13227
|
+
*/
|
|
13228
|
+
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
13229
|
+
|
|
13230
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
13231
|
+
typeof console.error === 'function') {
|
|
13232
|
+
console.error(
|
|
13233
|
+
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
13234
|
+
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
13235
|
+
);
|
|
13236
|
+
}
|
|
13237
|
+
|
|
13238
|
+
function typedArraySupport () {
|
|
13239
|
+
// Can typed array instances can be augmented?
|
|
13240
|
+
try {
|
|
13241
|
+
const arr = new Uint8Array(1);
|
|
13242
|
+
const proto = { foo: function () { return 42 } };
|
|
13243
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
13244
|
+
Object.setPrototypeOf(arr, proto);
|
|
13245
|
+
return arr.foo() === 42
|
|
13246
|
+
} catch (e) {
|
|
13247
|
+
return false
|
|
13248
|
+
}
|
|
13249
|
+
}
|
|
13250
|
+
|
|
13251
|
+
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
13252
|
+
enumerable: true,
|
|
13253
|
+
get: function () {
|
|
13254
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
13255
|
+
return this.buffer
|
|
13256
|
+
}
|
|
13257
|
+
});
|
|
13258
|
+
|
|
13259
|
+
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
13260
|
+
enumerable: true,
|
|
13261
|
+
get: function () {
|
|
13262
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
13263
|
+
return this.byteOffset
|
|
13264
|
+
}
|
|
13265
|
+
});
|
|
13266
|
+
|
|
13267
|
+
function createBuffer (length) {
|
|
13268
|
+
if (length > K_MAX_LENGTH) {
|
|
13269
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
13270
|
+
}
|
|
13271
|
+
// Return an augmented `Uint8Array` instance
|
|
13272
|
+
const buf = new Uint8Array(length);
|
|
13273
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13274
|
+
return buf
|
|
13275
|
+
}
|
|
13276
|
+
|
|
13277
|
+
/**
|
|
13278
|
+
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
13279
|
+
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
13280
|
+
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
13281
|
+
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
13282
|
+
* returns a single octet.
|
|
13283
|
+
*
|
|
13284
|
+
* The `Uint8Array` prototype remains unmodified.
|
|
13285
|
+
*/
|
|
13286
|
+
|
|
13287
|
+
function Buffer (arg, encodingOrOffset, length) {
|
|
13288
|
+
// Common case.
|
|
13289
|
+
if (typeof arg === 'number') {
|
|
13290
|
+
if (typeof encodingOrOffset === 'string') {
|
|
13291
|
+
throw new TypeError(
|
|
13292
|
+
'The "string" argument must be of type string. Received type number'
|
|
13293
|
+
)
|
|
13294
|
+
}
|
|
13295
|
+
return allocUnsafe(arg)
|
|
13296
|
+
}
|
|
13297
|
+
return from(arg, encodingOrOffset, length)
|
|
13298
|
+
}
|
|
13299
|
+
|
|
13300
|
+
Buffer.poolSize = 8192; // not used by this implementation
|
|
13301
|
+
|
|
13302
|
+
function from (value, encodingOrOffset, length) {
|
|
13303
|
+
if (typeof value === 'string') {
|
|
13304
|
+
return fromString(value, encodingOrOffset)
|
|
13305
|
+
}
|
|
13306
|
+
|
|
13307
|
+
if (ArrayBuffer.isView(value)) {
|
|
13308
|
+
return fromArrayView(value)
|
|
13309
|
+
}
|
|
13310
|
+
|
|
13311
|
+
if (value == null) {
|
|
13312
|
+
throw new TypeError(
|
|
13313
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13314
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
13315
|
+
)
|
|
13316
|
+
}
|
|
13317
|
+
|
|
13318
|
+
if (isInstance(value, ArrayBuffer) ||
|
|
13319
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
13320
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13321
|
+
}
|
|
13322
|
+
|
|
13323
|
+
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
13324
|
+
(isInstance(value, SharedArrayBuffer) ||
|
|
13325
|
+
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
13326
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
13327
|
+
}
|
|
13328
|
+
|
|
13329
|
+
if (typeof value === 'number') {
|
|
13330
|
+
throw new TypeError(
|
|
13331
|
+
'The "value" argument must not be of type number. Received type number'
|
|
13332
|
+
)
|
|
13333
|
+
}
|
|
13334
|
+
|
|
13335
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
13336
|
+
if (valueOf != null && valueOf !== value) {
|
|
13337
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
13338
|
+
}
|
|
13339
|
+
|
|
13340
|
+
const b = fromObject(value);
|
|
13341
|
+
if (b) return b
|
|
13342
|
+
|
|
13343
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
13344
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
|
13345
|
+
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
|
13346
|
+
}
|
|
13347
|
+
|
|
13348
|
+
throw new TypeError(
|
|
13349
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
13350
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
13351
|
+
)
|
|
13352
|
+
}
|
|
13353
|
+
|
|
13354
|
+
/**
|
|
13355
|
+
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
13356
|
+
* if value is a number.
|
|
13357
|
+
* Buffer.from(str[, encoding])
|
|
13358
|
+
* Buffer.from(array)
|
|
13359
|
+
* Buffer.from(buffer)
|
|
13360
|
+
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
13361
|
+
**/
|
|
13362
|
+
Buffer.from = function (value, encodingOrOffset, length) {
|
|
13363
|
+
return from(value, encodingOrOffset, length)
|
|
13364
|
+
};
|
|
13365
|
+
|
|
13366
|
+
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
13367
|
+
// https://github.com/feross/buffer/pull/148
|
|
13368
|
+
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
13369
|
+
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
13370
|
+
|
|
13371
|
+
function assertSize (size) {
|
|
13372
|
+
if (typeof size !== 'number') {
|
|
13373
|
+
throw new TypeError('"size" argument must be of type number')
|
|
13374
|
+
} else if (size < 0) {
|
|
13375
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
13376
|
+
}
|
|
13377
|
+
}
|
|
13378
|
+
|
|
13379
|
+
function alloc (size, fill, encoding) {
|
|
13380
|
+
assertSize(size);
|
|
13381
|
+
if (size <= 0) {
|
|
13382
|
+
return createBuffer(size)
|
|
13383
|
+
}
|
|
13384
|
+
if (fill !== undefined) {
|
|
13385
|
+
// Only pay attention to encoding if it's a string. This
|
|
13386
|
+
// prevents accidentally sending in a number that would
|
|
13387
|
+
// be interpreted as a start offset.
|
|
13388
|
+
return typeof encoding === 'string'
|
|
13389
|
+
? createBuffer(size).fill(fill, encoding)
|
|
13390
|
+
: createBuffer(size).fill(fill)
|
|
13391
|
+
}
|
|
13392
|
+
return createBuffer(size)
|
|
13393
|
+
}
|
|
13394
|
+
|
|
13395
|
+
/**
|
|
13396
|
+
* Creates a new filled Buffer instance.
|
|
13397
|
+
* alloc(size[, fill[, encoding]])
|
|
13398
|
+
**/
|
|
13399
|
+
Buffer.alloc = function (size, fill, encoding) {
|
|
13400
|
+
return alloc(size, fill, encoding)
|
|
13401
|
+
};
|
|
13402
|
+
|
|
13403
|
+
function allocUnsafe (size) {
|
|
13404
|
+
assertSize(size);
|
|
13405
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
13406
|
+
}
|
|
13407
|
+
|
|
13408
|
+
/**
|
|
13409
|
+
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13410
|
+
* */
|
|
13411
|
+
Buffer.allocUnsafe = function (size) {
|
|
13412
|
+
return allocUnsafe(size)
|
|
13413
|
+
};
|
|
13414
|
+
/**
|
|
13415
|
+
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
13416
|
+
*/
|
|
13417
|
+
Buffer.allocUnsafeSlow = function (size) {
|
|
13418
|
+
return allocUnsafe(size)
|
|
13419
|
+
};
|
|
13420
|
+
|
|
13421
|
+
function fromString (string, encoding) {
|
|
13422
|
+
if (typeof encoding !== 'string' || encoding === '') {
|
|
13423
|
+
encoding = 'utf8';
|
|
13424
|
+
}
|
|
13425
|
+
|
|
13426
|
+
if (!Buffer.isEncoding(encoding)) {
|
|
13427
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
13428
|
+
}
|
|
13429
|
+
|
|
13430
|
+
const length = byteLength(string, encoding) | 0;
|
|
13431
|
+
let buf = createBuffer(length);
|
|
13432
|
+
|
|
13433
|
+
const actual = buf.write(string, encoding);
|
|
13434
|
+
|
|
13435
|
+
if (actual !== length) {
|
|
13436
|
+
// Writing a hex string, for example, that contains invalid characters will
|
|
13437
|
+
// cause everything after the first invalid character to be ignored. (e.g.
|
|
13438
|
+
// 'abxxcd' will be treated as 'ab')
|
|
13439
|
+
buf = buf.slice(0, actual);
|
|
13440
|
+
}
|
|
13441
|
+
|
|
13442
|
+
return buf
|
|
13443
|
+
}
|
|
13444
|
+
|
|
13445
|
+
function fromArrayLike (array) {
|
|
13446
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
13447
|
+
const buf = createBuffer(length);
|
|
13448
|
+
for (let i = 0; i < length; i += 1) {
|
|
13449
|
+
buf[i] = array[i] & 255;
|
|
13450
|
+
}
|
|
13451
|
+
return buf
|
|
13452
|
+
}
|
|
13453
|
+
|
|
13454
|
+
function fromArrayView (arrayView) {
|
|
13455
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
13456
|
+
const copy = new Uint8Array(arrayView);
|
|
13457
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
13458
|
+
}
|
|
13459
|
+
return fromArrayLike(arrayView)
|
|
13460
|
+
}
|
|
13461
|
+
|
|
13462
|
+
function fromArrayBuffer (array, byteOffset, length) {
|
|
13463
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
13464
|
+
throw new RangeError('"offset" is outside of buffer bounds')
|
|
13465
|
+
}
|
|
13466
|
+
|
|
13467
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
13468
|
+
throw new RangeError('"length" is outside of buffer bounds')
|
|
13469
|
+
}
|
|
13470
|
+
|
|
13471
|
+
let buf;
|
|
13472
|
+
if (byteOffset === undefined && length === undefined) {
|
|
13473
|
+
buf = new Uint8Array(array);
|
|
13474
|
+
} else if (length === undefined) {
|
|
13475
|
+
buf = new Uint8Array(array, byteOffset);
|
|
13476
|
+
} else {
|
|
13477
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
13478
|
+
}
|
|
13479
|
+
|
|
13480
|
+
// Return an augmented `Uint8Array` instance
|
|
13481
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
13482
|
+
|
|
13483
|
+
return buf
|
|
13484
|
+
}
|
|
13485
|
+
|
|
13486
|
+
function fromObject (obj) {
|
|
13487
|
+
if (Buffer.isBuffer(obj)) {
|
|
13488
|
+
const len = checked(obj.length) | 0;
|
|
13489
|
+
const buf = createBuffer(len);
|
|
13490
|
+
|
|
13491
|
+
if (buf.length === 0) {
|
|
13492
|
+
return buf
|
|
13493
|
+
}
|
|
13494
|
+
|
|
13495
|
+
obj.copy(buf, 0, 0, len);
|
|
13496
|
+
return buf
|
|
13497
|
+
}
|
|
13498
|
+
|
|
13499
|
+
if (obj.length !== undefined) {
|
|
13500
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
13501
|
+
return createBuffer(0)
|
|
13502
|
+
}
|
|
13503
|
+
return fromArrayLike(obj)
|
|
13504
|
+
}
|
|
13505
|
+
|
|
13506
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
13507
|
+
return fromArrayLike(obj.data)
|
|
13508
|
+
}
|
|
13509
|
+
}
|
|
13510
|
+
|
|
13511
|
+
function checked (length) {
|
|
13512
|
+
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
13513
|
+
// length is NaN (which is otherwise coerced to zero.)
|
|
13514
|
+
if (length >= K_MAX_LENGTH) {
|
|
13515
|
+
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
13516
|
+
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
13517
|
+
}
|
|
13518
|
+
return length | 0
|
|
13519
|
+
}
|
|
13520
|
+
|
|
13521
|
+
function SlowBuffer (length) {
|
|
13522
|
+
if (+length != length) { // eslint-disable-line eqeqeq
|
|
13523
|
+
length = 0;
|
|
13524
|
+
}
|
|
13525
|
+
return Buffer.alloc(+length)
|
|
13526
|
+
}
|
|
13527
|
+
|
|
13528
|
+
Buffer.isBuffer = function isBuffer (b) {
|
|
13529
|
+
return b != null && b._isBuffer === true &&
|
|
13530
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
13531
|
+
};
|
|
13532
|
+
|
|
13533
|
+
Buffer.compare = function compare (a, b) {
|
|
13534
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
13535
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
13536
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
13537
|
+
throw new TypeError(
|
|
13538
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
13539
|
+
)
|
|
13540
|
+
}
|
|
13541
|
+
|
|
13542
|
+
if (a === b) return 0
|
|
13543
|
+
|
|
13544
|
+
let x = a.length;
|
|
13545
|
+
let y = b.length;
|
|
13546
|
+
|
|
13547
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
13548
|
+
if (a[i] !== b[i]) {
|
|
13549
|
+
x = a[i];
|
|
13550
|
+
y = b[i];
|
|
13551
|
+
break
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
|
|
13555
|
+
if (x < y) return -1
|
|
13556
|
+
if (y < x) return 1
|
|
13557
|
+
return 0
|
|
13558
|
+
};
|
|
13559
|
+
|
|
13560
|
+
Buffer.isEncoding = function isEncoding (encoding) {
|
|
13561
|
+
switch (String(encoding).toLowerCase()) {
|
|
13562
|
+
case 'hex':
|
|
13563
|
+
case 'utf8':
|
|
13564
|
+
case 'utf-8':
|
|
13565
|
+
case 'ascii':
|
|
13566
|
+
case 'latin1':
|
|
13567
|
+
case 'binary':
|
|
13568
|
+
case 'base64':
|
|
13569
|
+
case 'ucs2':
|
|
13570
|
+
case 'ucs-2':
|
|
13571
|
+
case 'utf16le':
|
|
13572
|
+
case 'utf-16le':
|
|
13573
|
+
return true
|
|
13574
|
+
default:
|
|
13575
|
+
return false
|
|
13576
|
+
}
|
|
13577
|
+
};
|
|
13578
|
+
|
|
13579
|
+
Buffer.concat = function concat (list, length) {
|
|
13580
|
+
if (!Array.isArray(list)) {
|
|
13581
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13582
|
+
}
|
|
13583
|
+
|
|
13584
|
+
if (list.length === 0) {
|
|
13585
|
+
return Buffer.alloc(0)
|
|
13586
|
+
}
|
|
13587
|
+
|
|
13588
|
+
let i;
|
|
13589
|
+
if (length === undefined) {
|
|
13590
|
+
length = 0;
|
|
13591
|
+
for (i = 0; i < list.length; ++i) {
|
|
13592
|
+
length += list[i].length;
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
|
|
13596
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
13597
|
+
let pos = 0;
|
|
13598
|
+
for (i = 0; i < list.length; ++i) {
|
|
13599
|
+
let buf = list[i];
|
|
13600
|
+
if (isInstance(buf, Uint8Array)) {
|
|
13601
|
+
if (pos + buf.length > buffer.length) {
|
|
13602
|
+
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
|
|
13603
|
+
buf.copy(buffer, pos);
|
|
13604
|
+
} else {
|
|
13605
|
+
Uint8Array.prototype.set.call(
|
|
13606
|
+
buffer,
|
|
13607
|
+
buf,
|
|
13608
|
+
pos
|
|
13609
|
+
);
|
|
13610
|
+
}
|
|
13611
|
+
} else if (!Buffer.isBuffer(buf)) {
|
|
13612
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
13613
|
+
} else {
|
|
13614
|
+
buf.copy(buffer, pos);
|
|
13615
|
+
}
|
|
13616
|
+
pos += buf.length;
|
|
13617
|
+
}
|
|
13618
|
+
return buffer
|
|
13619
|
+
};
|
|
13620
|
+
|
|
13621
|
+
function byteLength (string, encoding) {
|
|
13622
|
+
if (Buffer.isBuffer(string)) {
|
|
13623
|
+
return string.length
|
|
13624
|
+
}
|
|
13625
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
13626
|
+
return string.byteLength
|
|
13627
|
+
}
|
|
13628
|
+
if (typeof string !== 'string') {
|
|
13629
|
+
throw new TypeError(
|
|
13630
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
13631
|
+
'Received type ' + typeof string
|
|
13632
|
+
)
|
|
13633
|
+
}
|
|
13634
|
+
|
|
13635
|
+
const len = string.length;
|
|
13636
|
+
const mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
13637
|
+
if (!mustMatch && len === 0) return 0
|
|
13638
|
+
|
|
13639
|
+
// Use a for loop to avoid recursion
|
|
13640
|
+
let loweredCase = false;
|
|
13641
|
+
for (;;) {
|
|
13642
|
+
switch (encoding) {
|
|
13643
|
+
case 'ascii':
|
|
13644
|
+
case 'latin1':
|
|
13645
|
+
case 'binary':
|
|
13646
|
+
return len
|
|
13647
|
+
case 'utf8':
|
|
13648
|
+
case 'utf-8':
|
|
13649
|
+
return utf8ToBytes(string).length
|
|
13650
|
+
case 'ucs2':
|
|
13651
|
+
case 'ucs-2':
|
|
13652
|
+
case 'utf16le':
|
|
13653
|
+
case 'utf-16le':
|
|
13654
|
+
return len * 2
|
|
13655
|
+
case 'hex':
|
|
13656
|
+
return len >>> 1
|
|
13657
|
+
case 'base64':
|
|
13658
|
+
return base64ToBytes(string).length
|
|
13659
|
+
default:
|
|
13660
|
+
if (loweredCase) {
|
|
13661
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
13662
|
+
}
|
|
13663
|
+
encoding = ('' + encoding).toLowerCase();
|
|
13664
|
+
loweredCase = true;
|
|
13665
|
+
}
|
|
13666
|
+
}
|
|
13667
|
+
}
|
|
13668
|
+
Buffer.byteLength = byteLength;
|
|
13669
|
+
|
|
13670
|
+
function slowToString (encoding, start, end) {
|
|
13671
|
+
let loweredCase = false;
|
|
13672
|
+
|
|
13673
|
+
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
13674
|
+
// property of a typed array.
|
|
13675
|
+
|
|
13676
|
+
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
13677
|
+
// to their upper/lower bounds if the value passed is out of range.
|
|
13678
|
+
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
13679
|
+
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
13680
|
+
if (start === undefined || start < 0) {
|
|
13681
|
+
start = 0;
|
|
13682
|
+
}
|
|
13683
|
+
// Return early if start > this.length. Done here to prevent potential uint32
|
|
13684
|
+
// coercion fail below.
|
|
13685
|
+
if (start > this.length) {
|
|
13686
|
+
return ''
|
|
13687
|
+
}
|
|
13688
|
+
|
|
13689
|
+
if (end === undefined || end > this.length) {
|
|
13690
|
+
end = this.length;
|
|
13691
|
+
}
|
|
13692
|
+
|
|
13693
|
+
if (end <= 0) {
|
|
13694
|
+
return ''
|
|
13695
|
+
}
|
|
13696
|
+
|
|
13697
|
+
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
13698
|
+
end >>>= 0;
|
|
13699
|
+
start >>>= 0;
|
|
13700
|
+
|
|
13701
|
+
if (end <= start) {
|
|
13702
|
+
return ''
|
|
13703
|
+
}
|
|
13704
|
+
|
|
13705
|
+
if (!encoding) encoding = 'utf8';
|
|
13706
|
+
|
|
13707
|
+
while (true) {
|
|
13708
|
+
switch (encoding) {
|
|
13709
|
+
case 'hex':
|
|
13710
|
+
return hexSlice(this, start, end)
|
|
13711
|
+
|
|
13712
|
+
case 'utf8':
|
|
13713
|
+
case 'utf-8':
|
|
13714
|
+
return utf8Slice(this, start, end)
|
|
13715
|
+
|
|
13716
|
+
case 'ascii':
|
|
13717
|
+
return asciiSlice(this, start, end)
|
|
13718
|
+
|
|
13719
|
+
case 'latin1':
|
|
13720
|
+
case 'binary':
|
|
13721
|
+
return latin1Slice(this, start, end)
|
|
13722
|
+
|
|
13723
|
+
case 'base64':
|
|
13724
|
+
return base64Slice(this, start, end)
|
|
13725
|
+
|
|
13726
|
+
case 'ucs2':
|
|
13727
|
+
case 'ucs-2':
|
|
13728
|
+
case 'utf16le':
|
|
13729
|
+
case 'utf-16le':
|
|
13730
|
+
return utf16leSlice(this, start, end)
|
|
13731
|
+
|
|
13732
|
+
default:
|
|
13733
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
13734
|
+
encoding = (encoding + '').toLowerCase();
|
|
13735
|
+
loweredCase = true;
|
|
13736
|
+
}
|
|
13737
|
+
}
|
|
13738
|
+
}
|
|
13739
|
+
|
|
13740
|
+
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
13741
|
+
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
13742
|
+
// reliably in a browserify context because there could be multiple different
|
|
13743
|
+
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
13744
|
+
// instances that were created from another copy of the `buffer` package.
|
|
13745
|
+
// See: https://github.com/feross/buffer/issues/154
|
|
13746
|
+
Buffer.prototype._isBuffer = true;
|
|
13747
|
+
|
|
13748
|
+
function swap (b, n, m) {
|
|
13749
|
+
const i = b[n];
|
|
13750
|
+
b[n] = b[m];
|
|
13751
|
+
b[m] = i;
|
|
13752
|
+
}
|
|
13753
|
+
|
|
13754
|
+
Buffer.prototype.swap16 = function swap16 () {
|
|
13755
|
+
const len = this.length;
|
|
13756
|
+
if (len % 2 !== 0) {
|
|
13757
|
+
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
13758
|
+
}
|
|
13759
|
+
for (let i = 0; i < len; i += 2) {
|
|
13760
|
+
swap(this, i, i + 1);
|
|
13761
|
+
}
|
|
13762
|
+
return this
|
|
13763
|
+
};
|
|
13764
|
+
|
|
13765
|
+
Buffer.prototype.swap32 = function swap32 () {
|
|
13766
|
+
const len = this.length;
|
|
13767
|
+
if (len % 4 !== 0) {
|
|
13768
|
+
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
13769
|
+
}
|
|
13770
|
+
for (let i = 0; i < len; i += 4) {
|
|
13771
|
+
swap(this, i, i + 3);
|
|
13772
|
+
swap(this, i + 1, i + 2);
|
|
13773
|
+
}
|
|
13774
|
+
return this
|
|
13775
|
+
};
|
|
13776
|
+
|
|
13777
|
+
Buffer.prototype.swap64 = function swap64 () {
|
|
13778
|
+
const len = this.length;
|
|
13779
|
+
if (len % 8 !== 0) {
|
|
13780
|
+
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
13781
|
+
}
|
|
13782
|
+
for (let i = 0; i < len; i += 8) {
|
|
13783
|
+
swap(this, i, i + 7);
|
|
13784
|
+
swap(this, i + 1, i + 6);
|
|
13785
|
+
swap(this, i + 2, i + 5);
|
|
13786
|
+
swap(this, i + 3, i + 4);
|
|
13787
|
+
}
|
|
13788
|
+
return this
|
|
13789
|
+
};
|
|
13790
|
+
|
|
13791
|
+
Buffer.prototype.toString = function toString () {
|
|
13792
|
+
const length = this.length;
|
|
13793
|
+
if (length === 0) return ''
|
|
13794
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
13795
|
+
return slowToString.apply(this, arguments)
|
|
13796
|
+
};
|
|
13797
|
+
|
|
13798
|
+
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
13799
|
+
|
|
13800
|
+
Buffer.prototype.equals = function equals (b) {
|
|
13801
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
13802
|
+
if (this === b) return true
|
|
13803
|
+
return Buffer.compare(this, b) === 0
|
|
13804
|
+
};
|
|
13805
|
+
|
|
13806
|
+
Buffer.prototype.inspect = function inspect () {
|
|
13807
|
+
let str = '';
|
|
13808
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
13809
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
13810
|
+
if (this.length > max) str += ' ... ';
|
|
13811
|
+
return '<Buffer ' + str + '>'
|
|
13812
|
+
};
|
|
13813
|
+
if (customInspectSymbol) {
|
|
13814
|
+
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
13815
|
+
}
|
|
13816
|
+
|
|
13817
|
+
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
13818
|
+
if (isInstance(target, Uint8Array)) {
|
|
13819
|
+
target = Buffer.from(target, target.offset, target.byteLength);
|
|
13820
|
+
}
|
|
13821
|
+
if (!Buffer.isBuffer(target)) {
|
|
13822
|
+
throw new TypeError(
|
|
13823
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
13824
|
+
'Received type ' + (typeof target)
|
|
13825
|
+
)
|
|
13826
|
+
}
|
|
13827
|
+
|
|
13828
|
+
if (start === undefined) {
|
|
13829
|
+
start = 0;
|
|
13830
|
+
}
|
|
13831
|
+
if (end === undefined) {
|
|
13832
|
+
end = target ? target.length : 0;
|
|
13833
|
+
}
|
|
13834
|
+
if (thisStart === undefined) {
|
|
13835
|
+
thisStart = 0;
|
|
13836
|
+
}
|
|
13837
|
+
if (thisEnd === undefined) {
|
|
13838
|
+
thisEnd = this.length;
|
|
13839
|
+
}
|
|
13840
|
+
|
|
13841
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
13842
|
+
throw new RangeError('out of range index')
|
|
13843
|
+
}
|
|
13844
|
+
|
|
13845
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
13846
|
+
return 0
|
|
13847
|
+
}
|
|
13848
|
+
if (thisStart >= thisEnd) {
|
|
13849
|
+
return -1
|
|
13850
|
+
}
|
|
13851
|
+
if (start >= end) {
|
|
13852
|
+
return 1
|
|
13853
|
+
}
|
|
13854
|
+
|
|
13855
|
+
start >>>= 0;
|
|
13856
|
+
end >>>= 0;
|
|
13857
|
+
thisStart >>>= 0;
|
|
13858
|
+
thisEnd >>>= 0;
|
|
13859
|
+
|
|
13860
|
+
if (this === target) return 0
|
|
13861
|
+
|
|
13862
|
+
let x = thisEnd - thisStart;
|
|
13863
|
+
let y = end - start;
|
|
13864
|
+
const len = Math.min(x, y);
|
|
13865
|
+
|
|
13866
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
13867
|
+
const targetCopy = target.slice(start, end);
|
|
13868
|
+
|
|
13869
|
+
for (let i = 0; i < len; ++i) {
|
|
13870
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
13871
|
+
x = thisCopy[i];
|
|
13872
|
+
y = targetCopy[i];
|
|
13873
|
+
break
|
|
13874
|
+
}
|
|
13875
|
+
}
|
|
13876
|
+
|
|
13877
|
+
if (x < y) return -1
|
|
13878
|
+
if (y < x) return 1
|
|
13879
|
+
return 0
|
|
13880
|
+
};
|
|
13881
|
+
|
|
13882
|
+
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
13883
|
+
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
13884
|
+
//
|
|
13885
|
+
// Arguments:
|
|
13886
|
+
// - buffer - a Buffer to search
|
|
13887
|
+
// - val - a string, Buffer, or number
|
|
13888
|
+
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
13889
|
+
// - encoding - an optional encoding, relevant is val is a string
|
|
13890
|
+
// - dir - true for indexOf, false for lastIndexOf
|
|
13891
|
+
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
13892
|
+
// Empty buffer means no match
|
|
13893
|
+
if (buffer.length === 0) return -1
|
|
13894
|
+
|
|
13895
|
+
// Normalize byteOffset
|
|
13896
|
+
if (typeof byteOffset === 'string') {
|
|
13897
|
+
encoding = byteOffset;
|
|
13898
|
+
byteOffset = 0;
|
|
13899
|
+
} else if (byteOffset > 0x7fffffff) {
|
|
13900
|
+
byteOffset = 0x7fffffff;
|
|
13901
|
+
} else if (byteOffset < -2147483648) {
|
|
13902
|
+
byteOffset = -2147483648;
|
|
13903
|
+
}
|
|
13904
|
+
byteOffset = +byteOffset; // Coerce to Number.
|
|
13905
|
+
if (numberIsNaN(byteOffset)) {
|
|
13906
|
+
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
13907
|
+
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
13908
|
+
}
|
|
13909
|
+
|
|
13910
|
+
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
13911
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
13912
|
+
if (byteOffset >= buffer.length) {
|
|
13913
|
+
if (dir) return -1
|
|
13914
|
+
else byteOffset = buffer.length - 1;
|
|
13915
|
+
} else if (byteOffset < 0) {
|
|
13916
|
+
if (dir) byteOffset = 0;
|
|
13917
|
+
else return -1
|
|
13918
|
+
}
|
|
13919
|
+
|
|
13920
|
+
// Normalize val
|
|
13921
|
+
if (typeof val === 'string') {
|
|
13922
|
+
val = Buffer.from(val, encoding);
|
|
13923
|
+
}
|
|
13924
|
+
|
|
13925
|
+
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
13926
|
+
if (Buffer.isBuffer(val)) {
|
|
13927
|
+
// Special case: looking for empty string/buffer always fails
|
|
13928
|
+
if (val.length === 0) {
|
|
13929
|
+
return -1
|
|
13930
|
+
}
|
|
13931
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
13932
|
+
} else if (typeof val === 'number') {
|
|
13933
|
+
val = val & 0xFF; // Search for a byte value [0-255]
|
|
13934
|
+
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
13935
|
+
if (dir) {
|
|
13936
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
13937
|
+
} else {
|
|
13938
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
13939
|
+
}
|
|
13940
|
+
}
|
|
13941
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
13942
|
+
}
|
|
13943
|
+
|
|
13944
|
+
throw new TypeError('val must be string, number or Buffer')
|
|
13945
|
+
}
|
|
13946
|
+
|
|
13947
|
+
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
13948
|
+
let indexSize = 1;
|
|
13949
|
+
let arrLength = arr.length;
|
|
13950
|
+
let valLength = val.length;
|
|
13951
|
+
|
|
13952
|
+
if (encoding !== undefined) {
|
|
13953
|
+
encoding = String(encoding).toLowerCase();
|
|
13954
|
+
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
13955
|
+
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
13956
|
+
if (arr.length < 2 || val.length < 2) {
|
|
13957
|
+
return -1
|
|
13958
|
+
}
|
|
13959
|
+
indexSize = 2;
|
|
13960
|
+
arrLength /= 2;
|
|
13961
|
+
valLength /= 2;
|
|
13962
|
+
byteOffset /= 2;
|
|
13963
|
+
}
|
|
13964
|
+
}
|
|
13965
|
+
|
|
13966
|
+
function read (buf, i) {
|
|
13967
|
+
if (indexSize === 1) {
|
|
13968
|
+
return buf[i]
|
|
13969
|
+
} else {
|
|
13970
|
+
return buf.readUInt16BE(i * indexSize)
|
|
13971
|
+
}
|
|
13972
|
+
}
|
|
13973
|
+
|
|
13974
|
+
let i;
|
|
13975
|
+
if (dir) {
|
|
13976
|
+
let foundIndex = -1;
|
|
13977
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
13978
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
13979
|
+
if (foundIndex === -1) foundIndex = i;
|
|
13980
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
13981
|
+
} else {
|
|
13982
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
13983
|
+
foundIndex = -1;
|
|
13984
|
+
}
|
|
13985
|
+
}
|
|
13986
|
+
} else {
|
|
13987
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
13988
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
13989
|
+
let found = true;
|
|
13990
|
+
for (let j = 0; j < valLength; j++) {
|
|
13991
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
13992
|
+
found = false;
|
|
13993
|
+
break
|
|
13994
|
+
}
|
|
13995
|
+
}
|
|
13996
|
+
if (found) return i
|
|
13997
|
+
}
|
|
13998
|
+
}
|
|
13999
|
+
|
|
14000
|
+
return -1
|
|
14001
|
+
}
|
|
14002
|
+
|
|
14003
|
+
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
14004
|
+
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
14005
|
+
};
|
|
14006
|
+
|
|
14007
|
+
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
14008
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
14009
|
+
};
|
|
14010
|
+
|
|
14011
|
+
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
14012
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
14013
|
+
};
|
|
14014
|
+
|
|
14015
|
+
function hexWrite (buf, string, offset, length) {
|
|
14016
|
+
offset = Number(offset) || 0;
|
|
14017
|
+
const remaining = buf.length - offset;
|
|
14018
|
+
if (!length) {
|
|
14019
|
+
length = remaining;
|
|
14020
|
+
} else {
|
|
14021
|
+
length = Number(length);
|
|
14022
|
+
if (length > remaining) {
|
|
14023
|
+
length = remaining;
|
|
14024
|
+
}
|
|
14025
|
+
}
|
|
14026
|
+
|
|
14027
|
+
const strLen = string.length;
|
|
14028
|
+
|
|
14029
|
+
if (length > strLen / 2) {
|
|
14030
|
+
length = strLen / 2;
|
|
14031
|
+
}
|
|
14032
|
+
let i;
|
|
14033
|
+
for (i = 0; i < length; ++i) {
|
|
14034
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
14035
|
+
if (numberIsNaN(parsed)) return i
|
|
14036
|
+
buf[offset + i] = parsed;
|
|
14037
|
+
}
|
|
14038
|
+
return i
|
|
14039
|
+
}
|
|
14040
|
+
|
|
14041
|
+
function utf8Write (buf, string, offset, length) {
|
|
14042
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
14043
|
+
}
|
|
14044
|
+
|
|
14045
|
+
function asciiWrite (buf, string, offset, length) {
|
|
14046
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
14047
|
+
}
|
|
14048
|
+
|
|
14049
|
+
function base64Write (buf, string, offset, length) {
|
|
14050
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
14051
|
+
}
|
|
14052
|
+
|
|
14053
|
+
function ucs2Write (buf, string, offset, length) {
|
|
14054
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
14055
|
+
}
|
|
14056
|
+
|
|
14057
|
+
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
14058
|
+
// Buffer#write(string)
|
|
14059
|
+
if (offset === undefined) {
|
|
14060
|
+
encoding = 'utf8';
|
|
14061
|
+
length = this.length;
|
|
14062
|
+
offset = 0;
|
|
14063
|
+
// Buffer#write(string, encoding)
|
|
14064
|
+
} else if (length === undefined && typeof offset === 'string') {
|
|
14065
|
+
encoding = offset;
|
|
14066
|
+
length = this.length;
|
|
14067
|
+
offset = 0;
|
|
14068
|
+
// Buffer#write(string, offset[, length][, encoding])
|
|
14069
|
+
} else if (isFinite(offset)) {
|
|
14070
|
+
offset = offset >>> 0;
|
|
14071
|
+
if (isFinite(length)) {
|
|
14072
|
+
length = length >>> 0;
|
|
14073
|
+
if (encoding === undefined) encoding = 'utf8';
|
|
14074
|
+
} else {
|
|
14075
|
+
encoding = length;
|
|
14076
|
+
length = undefined;
|
|
14077
|
+
}
|
|
14078
|
+
} else {
|
|
14079
|
+
throw new Error(
|
|
14080
|
+
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
14081
|
+
)
|
|
14082
|
+
}
|
|
14083
|
+
|
|
14084
|
+
const remaining = this.length - offset;
|
|
14085
|
+
if (length === undefined || length > remaining) length = remaining;
|
|
14086
|
+
|
|
14087
|
+
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
14088
|
+
throw new RangeError('Attempt to write outside buffer bounds')
|
|
14089
|
+
}
|
|
14090
|
+
|
|
14091
|
+
if (!encoding) encoding = 'utf8';
|
|
14092
|
+
|
|
14093
|
+
let loweredCase = false;
|
|
14094
|
+
for (;;) {
|
|
14095
|
+
switch (encoding) {
|
|
14096
|
+
case 'hex':
|
|
14097
|
+
return hexWrite(this, string, offset, length)
|
|
14098
|
+
|
|
14099
|
+
case 'utf8':
|
|
14100
|
+
case 'utf-8':
|
|
14101
|
+
return utf8Write(this, string, offset, length)
|
|
14102
|
+
|
|
14103
|
+
case 'ascii':
|
|
14104
|
+
case 'latin1':
|
|
14105
|
+
case 'binary':
|
|
14106
|
+
return asciiWrite(this, string, offset, length)
|
|
14107
|
+
|
|
14108
|
+
case 'base64':
|
|
14109
|
+
// Warning: maxLength not taken into account in base64Write
|
|
14110
|
+
return base64Write(this, string, offset, length)
|
|
14111
|
+
|
|
14112
|
+
case 'ucs2':
|
|
14113
|
+
case 'ucs-2':
|
|
14114
|
+
case 'utf16le':
|
|
14115
|
+
case 'utf-16le':
|
|
14116
|
+
return ucs2Write(this, string, offset, length)
|
|
14117
|
+
|
|
14118
|
+
default:
|
|
14119
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
14120
|
+
encoding = ('' + encoding).toLowerCase();
|
|
14121
|
+
loweredCase = true;
|
|
14122
|
+
}
|
|
14123
|
+
}
|
|
14124
|
+
};
|
|
14125
|
+
|
|
14126
|
+
Buffer.prototype.toJSON = function toJSON () {
|
|
14127
|
+
return {
|
|
14128
|
+
type: 'Buffer',
|
|
14129
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
14130
|
+
}
|
|
14131
|
+
};
|
|
14132
|
+
|
|
14133
|
+
function base64Slice (buf, start, end) {
|
|
14134
|
+
if (start === 0 && end === buf.length) {
|
|
14135
|
+
return base64.fromByteArray(buf)
|
|
14136
|
+
} else {
|
|
14137
|
+
return base64.fromByteArray(buf.slice(start, end))
|
|
14138
|
+
}
|
|
14139
|
+
}
|
|
14140
|
+
|
|
14141
|
+
function utf8Slice (buf, start, end) {
|
|
14142
|
+
end = Math.min(buf.length, end);
|
|
14143
|
+
const res = [];
|
|
14144
|
+
|
|
14145
|
+
let i = start;
|
|
14146
|
+
while (i < end) {
|
|
14147
|
+
const firstByte = buf[i];
|
|
14148
|
+
let codePoint = null;
|
|
14149
|
+
let bytesPerSequence = (firstByte > 0xEF)
|
|
14150
|
+
? 4
|
|
14151
|
+
: (firstByte > 0xDF)
|
|
14152
|
+
? 3
|
|
14153
|
+
: (firstByte > 0xBF)
|
|
14154
|
+
? 2
|
|
14155
|
+
: 1;
|
|
14156
|
+
|
|
14157
|
+
if (i + bytesPerSequence <= end) {
|
|
14158
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
14159
|
+
|
|
14160
|
+
switch (bytesPerSequence) {
|
|
14161
|
+
case 1:
|
|
14162
|
+
if (firstByte < 0x80) {
|
|
14163
|
+
codePoint = firstByte;
|
|
14164
|
+
}
|
|
14165
|
+
break
|
|
14166
|
+
case 2:
|
|
14167
|
+
secondByte = buf[i + 1];
|
|
14168
|
+
if ((secondByte & 0xC0) === 0x80) {
|
|
14169
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
14170
|
+
if (tempCodePoint > 0x7F) {
|
|
14171
|
+
codePoint = tempCodePoint;
|
|
14172
|
+
}
|
|
14173
|
+
}
|
|
14174
|
+
break
|
|
14175
|
+
case 3:
|
|
14176
|
+
secondByte = buf[i + 1];
|
|
14177
|
+
thirdByte = buf[i + 2];
|
|
14178
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
14179
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
14180
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
14181
|
+
codePoint = tempCodePoint;
|
|
14182
|
+
}
|
|
14183
|
+
}
|
|
14184
|
+
break
|
|
14185
|
+
case 4:
|
|
14186
|
+
secondByte = buf[i + 1];
|
|
14187
|
+
thirdByte = buf[i + 2];
|
|
14188
|
+
fourthByte = buf[i + 3];
|
|
14189
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
14190
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
14191
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
14192
|
+
codePoint = tempCodePoint;
|
|
14193
|
+
}
|
|
14194
|
+
}
|
|
14195
|
+
}
|
|
14196
|
+
}
|
|
14197
|
+
|
|
14198
|
+
if (codePoint === null) {
|
|
14199
|
+
// we did not generate a valid codePoint so insert a
|
|
14200
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
|
14201
|
+
codePoint = 0xFFFD;
|
|
14202
|
+
bytesPerSequence = 1;
|
|
14203
|
+
} else if (codePoint > 0xFFFF) {
|
|
14204
|
+
// encode to utf16 (surrogate pair dance)
|
|
14205
|
+
codePoint -= 0x10000;
|
|
14206
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
14207
|
+
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
14208
|
+
}
|
|
14209
|
+
|
|
14210
|
+
res.push(codePoint);
|
|
14211
|
+
i += bytesPerSequence;
|
|
14212
|
+
}
|
|
14213
|
+
|
|
14214
|
+
return decodeCodePointsArray(res)
|
|
14215
|
+
}
|
|
14216
|
+
|
|
14217
|
+
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
14218
|
+
// the lowest limit is Chrome, with 0x10000 args.
|
|
14219
|
+
// We go 1 magnitude less, for safety
|
|
14220
|
+
const MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
14221
|
+
|
|
14222
|
+
function decodeCodePointsArray (codePoints) {
|
|
14223
|
+
const len = codePoints.length;
|
|
14224
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
14225
|
+
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
14226
|
+
}
|
|
14227
|
+
|
|
14228
|
+
// Decode in chunks to avoid "call stack size exceeded".
|
|
14229
|
+
let res = '';
|
|
14230
|
+
let i = 0;
|
|
14231
|
+
while (i < len) {
|
|
14232
|
+
res += String.fromCharCode.apply(
|
|
14233
|
+
String,
|
|
14234
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
14235
|
+
);
|
|
14236
|
+
}
|
|
14237
|
+
return res
|
|
14238
|
+
}
|
|
14239
|
+
|
|
14240
|
+
function asciiSlice (buf, start, end) {
|
|
14241
|
+
let ret = '';
|
|
14242
|
+
end = Math.min(buf.length, end);
|
|
14243
|
+
|
|
14244
|
+
for (let i = start; i < end; ++i) {
|
|
14245
|
+
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
14246
|
+
}
|
|
14247
|
+
return ret
|
|
14248
|
+
}
|
|
14249
|
+
|
|
14250
|
+
function latin1Slice (buf, start, end) {
|
|
14251
|
+
let ret = '';
|
|
14252
|
+
end = Math.min(buf.length, end);
|
|
14253
|
+
|
|
14254
|
+
for (let i = start; i < end; ++i) {
|
|
14255
|
+
ret += String.fromCharCode(buf[i]);
|
|
14256
|
+
}
|
|
14257
|
+
return ret
|
|
14258
|
+
}
|
|
14259
|
+
|
|
14260
|
+
function hexSlice (buf, start, end) {
|
|
14261
|
+
const len = buf.length;
|
|
14262
|
+
|
|
14263
|
+
if (!start || start < 0) start = 0;
|
|
14264
|
+
if (!end || end < 0 || end > len) end = len;
|
|
14265
|
+
|
|
14266
|
+
let out = '';
|
|
14267
|
+
for (let i = start; i < end; ++i) {
|
|
14268
|
+
out += hexSliceLookupTable[buf[i]];
|
|
14269
|
+
}
|
|
14270
|
+
return out
|
|
14271
|
+
}
|
|
14272
|
+
|
|
14273
|
+
function utf16leSlice (buf, start, end) {
|
|
14274
|
+
const bytes = buf.slice(start, end);
|
|
14275
|
+
let res = '';
|
|
14276
|
+
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
14277
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
14278
|
+
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
14279
|
+
}
|
|
14280
|
+
return res
|
|
14281
|
+
}
|
|
14282
|
+
|
|
14283
|
+
Buffer.prototype.slice = function slice (start, end) {
|
|
14284
|
+
const len = this.length;
|
|
14285
|
+
start = ~~start;
|
|
14286
|
+
end = end === undefined ? len : ~~end;
|
|
14287
|
+
|
|
14288
|
+
if (start < 0) {
|
|
14289
|
+
start += len;
|
|
14290
|
+
if (start < 0) start = 0;
|
|
14291
|
+
} else if (start > len) {
|
|
14292
|
+
start = len;
|
|
14293
|
+
}
|
|
14294
|
+
|
|
14295
|
+
if (end < 0) {
|
|
14296
|
+
end += len;
|
|
14297
|
+
if (end < 0) end = 0;
|
|
14298
|
+
} else if (end > len) {
|
|
14299
|
+
end = len;
|
|
14300
|
+
}
|
|
14301
|
+
|
|
14302
|
+
if (end < start) end = start;
|
|
14303
|
+
|
|
14304
|
+
const newBuf = this.subarray(start, end);
|
|
14305
|
+
// Return an augmented `Uint8Array` instance
|
|
14306
|
+
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
14307
|
+
|
|
14308
|
+
return newBuf
|
|
14309
|
+
};
|
|
14310
|
+
|
|
14311
|
+
/*
|
|
14312
|
+
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
14313
|
+
*/
|
|
14314
|
+
function checkOffset (offset, ext, length) {
|
|
14315
|
+
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
14316
|
+
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
14317
|
+
}
|
|
14318
|
+
|
|
14319
|
+
Buffer.prototype.readUintLE =
|
|
14320
|
+
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
14321
|
+
offset = offset >>> 0;
|
|
14322
|
+
byteLength = byteLength >>> 0;
|
|
14323
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14324
|
+
|
|
14325
|
+
let val = this[offset];
|
|
14326
|
+
let mul = 1;
|
|
14327
|
+
let i = 0;
|
|
14328
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14329
|
+
val += this[offset + i] * mul;
|
|
14330
|
+
}
|
|
14331
|
+
|
|
14332
|
+
return val
|
|
14333
|
+
};
|
|
14334
|
+
|
|
14335
|
+
Buffer.prototype.readUintBE =
|
|
14336
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
14337
|
+
offset = offset >>> 0;
|
|
14338
|
+
byteLength = byteLength >>> 0;
|
|
14339
|
+
if (!noAssert) {
|
|
14340
|
+
checkOffset(offset, byteLength, this.length);
|
|
14341
|
+
}
|
|
14342
|
+
|
|
14343
|
+
let val = this[offset + --byteLength];
|
|
14344
|
+
let mul = 1;
|
|
14345
|
+
while (byteLength > 0 && (mul *= 0x100)) {
|
|
14346
|
+
val += this[offset + --byteLength] * mul;
|
|
14347
|
+
}
|
|
14348
|
+
|
|
14349
|
+
return val
|
|
14350
|
+
};
|
|
14351
|
+
|
|
14352
|
+
Buffer.prototype.readUint8 =
|
|
14353
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
14354
|
+
offset = offset >>> 0;
|
|
14355
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14356
|
+
return this[offset]
|
|
14357
|
+
};
|
|
14358
|
+
|
|
14359
|
+
Buffer.prototype.readUint16LE =
|
|
14360
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
14361
|
+
offset = offset >>> 0;
|
|
14362
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14363
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
14364
|
+
};
|
|
14365
|
+
|
|
14366
|
+
Buffer.prototype.readUint16BE =
|
|
14367
|
+
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
14368
|
+
offset = offset >>> 0;
|
|
14369
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14370
|
+
return (this[offset] << 8) | this[offset + 1]
|
|
14371
|
+
};
|
|
14372
|
+
|
|
14373
|
+
Buffer.prototype.readUint32LE =
|
|
14374
|
+
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
14375
|
+
offset = offset >>> 0;
|
|
14376
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14377
|
+
|
|
14378
|
+
return ((this[offset]) |
|
|
14379
|
+
(this[offset + 1] << 8) |
|
|
14380
|
+
(this[offset + 2] << 16)) +
|
|
14381
|
+
(this[offset + 3] * 0x1000000)
|
|
14382
|
+
};
|
|
14383
|
+
|
|
14384
|
+
Buffer.prototype.readUint32BE =
|
|
14385
|
+
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
14386
|
+
offset = offset >>> 0;
|
|
14387
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14388
|
+
|
|
14389
|
+
return (this[offset] * 0x1000000) +
|
|
14390
|
+
((this[offset + 1] << 16) |
|
|
14391
|
+
(this[offset + 2] << 8) |
|
|
14392
|
+
this[offset + 3])
|
|
14393
|
+
};
|
|
14394
|
+
|
|
14395
|
+
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
|
14396
|
+
offset = offset >>> 0;
|
|
14397
|
+
validateNumber(offset, 'offset');
|
|
14398
|
+
const first = this[offset];
|
|
14399
|
+
const last = this[offset + 7];
|
|
14400
|
+
if (first === undefined || last === undefined) {
|
|
14401
|
+
boundsError(offset, this.length - 8);
|
|
14402
|
+
}
|
|
14403
|
+
|
|
14404
|
+
const lo = first +
|
|
14405
|
+
this[++offset] * 2 ** 8 +
|
|
14406
|
+
this[++offset] * 2 ** 16 +
|
|
14407
|
+
this[++offset] * 2 ** 24;
|
|
14408
|
+
|
|
14409
|
+
const hi = this[++offset] +
|
|
14410
|
+
this[++offset] * 2 ** 8 +
|
|
14411
|
+
this[++offset] * 2 ** 16 +
|
|
14412
|
+
last * 2 ** 24;
|
|
14413
|
+
|
|
14414
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
|
14415
|
+
});
|
|
14416
|
+
|
|
14417
|
+
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
|
14418
|
+
offset = offset >>> 0;
|
|
14419
|
+
validateNumber(offset, 'offset');
|
|
14420
|
+
const first = this[offset];
|
|
14421
|
+
const last = this[offset + 7];
|
|
14422
|
+
if (first === undefined || last === undefined) {
|
|
14423
|
+
boundsError(offset, this.length - 8);
|
|
14424
|
+
}
|
|
14425
|
+
|
|
14426
|
+
const hi = first * 2 ** 24 +
|
|
14427
|
+
this[++offset] * 2 ** 16 +
|
|
14428
|
+
this[++offset] * 2 ** 8 +
|
|
14429
|
+
this[++offset];
|
|
14430
|
+
|
|
14431
|
+
const lo = this[++offset] * 2 ** 24 +
|
|
14432
|
+
this[++offset] * 2 ** 16 +
|
|
14433
|
+
this[++offset] * 2 ** 8 +
|
|
14434
|
+
last;
|
|
14435
|
+
|
|
14436
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
14437
|
+
});
|
|
14438
|
+
|
|
14439
|
+
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
14440
|
+
offset = offset >>> 0;
|
|
14441
|
+
byteLength = byteLength >>> 0;
|
|
14442
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14443
|
+
|
|
14444
|
+
let val = this[offset];
|
|
14445
|
+
let mul = 1;
|
|
14446
|
+
let i = 0;
|
|
14447
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14448
|
+
val += this[offset + i] * mul;
|
|
14449
|
+
}
|
|
14450
|
+
mul *= 0x80;
|
|
14451
|
+
|
|
14452
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14453
|
+
|
|
14454
|
+
return val
|
|
14455
|
+
};
|
|
14456
|
+
|
|
14457
|
+
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
14458
|
+
offset = offset >>> 0;
|
|
14459
|
+
byteLength = byteLength >>> 0;
|
|
14460
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
14461
|
+
|
|
14462
|
+
let i = byteLength;
|
|
14463
|
+
let mul = 1;
|
|
14464
|
+
let val = this[offset + --i];
|
|
14465
|
+
while (i > 0 && (mul *= 0x100)) {
|
|
14466
|
+
val += this[offset + --i] * mul;
|
|
14467
|
+
}
|
|
14468
|
+
mul *= 0x80;
|
|
14469
|
+
|
|
14470
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
14471
|
+
|
|
14472
|
+
return val
|
|
14473
|
+
};
|
|
14474
|
+
|
|
14475
|
+
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
14476
|
+
offset = offset >>> 0;
|
|
14477
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
14478
|
+
if (!(this[offset] & 0x80)) return (this[offset])
|
|
14479
|
+
return ((0xff - this[offset] + 1) * -1)
|
|
14480
|
+
};
|
|
14481
|
+
|
|
14482
|
+
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
14483
|
+
offset = offset >>> 0;
|
|
14484
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14485
|
+
const val = this[offset] | (this[offset + 1] << 8);
|
|
14486
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14487
|
+
};
|
|
14488
|
+
|
|
14489
|
+
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
14490
|
+
offset = offset >>> 0;
|
|
14491
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
14492
|
+
const val = this[offset + 1] | (this[offset] << 8);
|
|
14493
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
14494
|
+
};
|
|
14495
|
+
|
|
14496
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
14497
|
+
offset = offset >>> 0;
|
|
14498
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14499
|
+
|
|
14500
|
+
return (this[offset]) |
|
|
14501
|
+
(this[offset + 1] << 8) |
|
|
14502
|
+
(this[offset + 2] << 16) |
|
|
14503
|
+
(this[offset + 3] << 24)
|
|
14504
|
+
};
|
|
14505
|
+
|
|
14506
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
14507
|
+
offset = offset >>> 0;
|
|
14508
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14509
|
+
|
|
14510
|
+
return (this[offset] << 24) |
|
|
14511
|
+
(this[offset + 1] << 16) |
|
|
14512
|
+
(this[offset + 2] << 8) |
|
|
14513
|
+
(this[offset + 3])
|
|
14514
|
+
};
|
|
14515
|
+
|
|
14516
|
+
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (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 = this[offset + 4] +
|
|
14526
|
+
this[offset + 5] * 2 ** 8 +
|
|
14527
|
+
this[offset + 6] * 2 ** 16 +
|
|
14528
|
+
(last << 24); // Overflow
|
|
14529
|
+
|
|
14530
|
+
return (BigInt(val) << BigInt(32)) +
|
|
14531
|
+
BigInt(first +
|
|
14532
|
+
this[++offset] * 2 ** 8 +
|
|
14533
|
+
this[++offset] * 2 ** 16 +
|
|
14534
|
+
this[++offset] * 2 ** 24)
|
|
14535
|
+
});
|
|
14536
|
+
|
|
14537
|
+
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
|
14538
|
+
offset = offset >>> 0;
|
|
14539
|
+
validateNumber(offset, 'offset');
|
|
14540
|
+
const first = this[offset];
|
|
14541
|
+
const last = this[offset + 7];
|
|
14542
|
+
if (first === undefined || last === undefined) {
|
|
14543
|
+
boundsError(offset, this.length - 8);
|
|
14544
|
+
}
|
|
14545
|
+
|
|
14546
|
+
const val = (first << 24) + // Overflow
|
|
14547
|
+
this[++offset] * 2 ** 16 +
|
|
14548
|
+
this[++offset] * 2 ** 8 +
|
|
14549
|
+
this[++offset];
|
|
14550
|
+
|
|
14551
|
+
return (BigInt(val) << BigInt(32)) +
|
|
14552
|
+
BigInt(this[++offset] * 2 ** 24 +
|
|
14553
|
+
this[++offset] * 2 ** 16 +
|
|
14554
|
+
this[++offset] * 2 ** 8 +
|
|
14555
|
+
last)
|
|
14556
|
+
});
|
|
14557
|
+
|
|
14558
|
+
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
14559
|
+
offset = offset >>> 0;
|
|
14560
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14561
|
+
return ieee754.read(this, offset, true, 23, 4)
|
|
14562
|
+
};
|
|
14563
|
+
|
|
14564
|
+
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
14565
|
+
offset = offset >>> 0;
|
|
14566
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
14567
|
+
return ieee754.read(this, offset, false, 23, 4)
|
|
14568
|
+
};
|
|
14569
|
+
|
|
14570
|
+
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
14571
|
+
offset = offset >>> 0;
|
|
14572
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14573
|
+
return ieee754.read(this, offset, true, 52, 8)
|
|
14574
|
+
};
|
|
14575
|
+
|
|
14576
|
+
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
14577
|
+
offset = offset >>> 0;
|
|
14578
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
14579
|
+
return ieee754.read(this, offset, false, 52, 8)
|
|
14580
|
+
};
|
|
14581
|
+
|
|
14582
|
+
function checkInt (buf, value, offset, ext, max, min) {
|
|
14583
|
+
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
14584
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
14585
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
14586
|
+
}
|
|
14587
|
+
|
|
14588
|
+
Buffer.prototype.writeUintLE =
|
|
14589
|
+
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
14590
|
+
value = +value;
|
|
14591
|
+
offset = offset >>> 0;
|
|
14592
|
+
byteLength = byteLength >>> 0;
|
|
14593
|
+
if (!noAssert) {
|
|
14594
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14595
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14596
|
+
}
|
|
14597
|
+
|
|
14598
|
+
let mul = 1;
|
|
14599
|
+
let i = 0;
|
|
14600
|
+
this[offset] = value & 0xFF;
|
|
14601
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14602
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
14603
|
+
}
|
|
14604
|
+
|
|
14605
|
+
return offset + byteLength
|
|
14606
|
+
};
|
|
14607
|
+
|
|
14608
|
+
Buffer.prototype.writeUintBE =
|
|
14609
|
+
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
14610
|
+
value = +value;
|
|
14611
|
+
offset = offset >>> 0;
|
|
14612
|
+
byteLength = byteLength >>> 0;
|
|
14613
|
+
if (!noAssert) {
|
|
14614
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
14615
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
14616
|
+
}
|
|
14617
|
+
|
|
14618
|
+
let i = byteLength - 1;
|
|
14619
|
+
let mul = 1;
|
|
14620
|
+
this[offset + i] = value & 0xFF;
|
|
14621
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
14622
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
14623
|
+
}
|
|
14624
|
+
|
|
14625
|
+
return offset + byteLength
|
|
14626
|
+
};
|
|
14627
|
+
|
|
14628
|
+
Buffer.prototype.writeUint8 =
|
|
14629
|
+
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
14630
|
+
value = +value;
|
|
14631
|
+
offset = offset >>> 0;
|
|
14632
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
14633
|
+
this[offset] = (value & 0xff);
|
|
14634
|
+
return offset + 1
|
|
14635
|
+
};
|
|
14636
|
+
|
|
14637
|
+
Buffer.prototype.writeUint16LE =
|
|
14638
|
+
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
14639
|
+
value = +value;
|
|
14640
|
+
offset = offset >>> 0;
|
|
14641
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
14642
|
+
this[offset] = (value & 0xff);
|
|
14643
|
+
this[offset + 1] = (value >>> 8);
|
|
14644
|
+
return offset + 2
|
|
14645
|
+
};
|
|
14646
|
+
|
|
14647
|
+
Buffer.prototype.writeUint16BE =
|
|
14648
|
+
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
14649
|
+
value = +value;
|
|
14650
|
+
offset = offset >>> 0;
|
|
14651
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
14652
|
+
this[offset] = (value >>> 8);
|
|
14653
|
+
this[offset + 1] = (value & 0xff);
|
|
14654
|
+
return offset + 2
|
|
14655
|
+
};
|
|
14656
|
+
|
|
14657
|
+
Buffer.prototype.writeUint32LE =
|
|
14658
|
+
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
14659
|
+
value = +value;
|
|
14660
|
+
offset = offset >>> 0;
|
|
14661
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
14662
|
+
this[offset + 3] = (value >>> 24);
|
|
14663
|
+
this[offset + 2] = (value >>> 16);
|
|
14664
|
+
this[offset + 1] = (value >>> 8);
|
|
14665
|
+
this[offset] = (value & 0xff);
|
|
14666
|
+
return offset + 4
|
|
14667
|
+
};
|
|
14668
|
+
|
|
14669
|
+
Buffer.prototype.writeUint32BE =
|
|
14670
|
+
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
14671
|
+
value = +value;
|
|
14672
|
+
offset = offset >>> 0;
|
|
14673
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
14674
|
+
this[offset] = (value >>> 24);
|
|
14675
|
+
this[offset + 1] = (value >>> 16);
|
|
14676
|
+
this[offset + 2] = (value >>> 8);
|
|
14677
|
+
this[offset + 3] = (value & 0xff);
|
|
14678
|
+
return offset + 4
|
|
14679
|
+
};
|
|
14680
|
+
|
|
14681
|
+
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
|
14682
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
14683
|
+
|
|
14684
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
14685
|
+
buf[offset++] = lo;
|
|
14686
|
+
lo = lo >> 8;
|
|
14687
|
+
buf[offset++] = lo;
|
|
14688
|
+
lo = lo >> 8;
|
|
14689
|
+
buf[offset++] = lo;
|
|
14690
|
+
lo = lo >> 8;
|
|
14691
|
+
buf[offset++] = lo;
|
|
14692
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
14693
|
+
buf[offset++] = hi;
|
|
14694
|
+
hi = hi >> 8;
|
|
14695
|
+
buf[offset++] = hi;
|
|
14696
|
+
hi = hi >> 8;
|
|
14697
|
+
buf[offset++] = hi;
|
|
14698
|
+
hi = hi >> 8;
|
|
14699
|
+
buf[offset++] = hi;
|
|
14700
|
+
return offset
|
|
14701
|
+
}
|
|
14702
|
+
|
|
14703
|
+
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
|
14704
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
14705
|
+
|
|
14706
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
14707
|
+
buf[offset + 7] = lo;
|
|
14708
|
+
lo = lo >> 8;
|
|
14709
|
+
buf[offset + 6] = lo;
|
|
14710
|
+
lo = lo >> 8;
|
|
14711
|
+
buf[offset + 5] = lo;
|
|
14712
|
+
lo = lo >> 8;
|
|
14713
|
+
buf[offset + 4] = lo;
|
|
14714
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
14715
|
+
buf[offset + 3] = hi;
|
|
14716
|
+
hi = hi >> 8;
|
|
14717
|
+
buf[offset + 2] = hi;
|
|
14718
|
+
hi = hi >> 8;
|
|
14719
|
+
buf[offset + 1] = hi;
|
|
14720
|
+
hi = hi >> 8;
|
|
14721
|
+
buf[offset] = hi;
|
|
14722
|
+
return offset + 8
|
|
14723
|
+
}
|
|
14724
|
+
|
|
14725
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
14726
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
14727
|
+
});
|
|
14728
|
+
|
|
14729
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
14730
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
14731
|
+
});
|
|
14732
|
+
|
|
14733
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
14734
|
+
value = +value;
|
|
14735
|
+
offset = offset >>> 0;
|
|
14736
|
+
if (!noAssert) {
|
|
14737
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
14738
|
+
|
|
14739
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
14740
|
+
}
|
|
14741
|
+
|
|
14742
|
+
let i = 0;
|
|
14743
|
+
let mul = 1;
|
|
14744
|
+
let sub = 0;
|
|
14745
|
+
this[offset] = value & 0xFF;
|
|
14746
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
14747
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
14748
|
+
sub = 1;
|
|
14749
|
+
}
|
|
14750
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
14751
|
+
}
|
|
14752
|
+
|
|
14753
|
+
return offset + byteLength
|
|
14754
|
+
};
|
|
14755
|
+
|
|
14756
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
14757
|
+
value = +value;
|
|
14758
|
+
offset = offset >>> 0;
|
|
14759
|
+
if (!noAssert) {
|
|
14760
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
14761
|
+
|
|
14762
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
14763
|
+
}
|
|
14764
|
+
|
|
14765
|
+
let i = byteLength - 1;
|
|
14766
|
+
let mul = 1;
|
|
14767
|
+
let sub = 0;
|
|
14768
|
+
this[offset + i] = value & 0xFF;
|
|
14769
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
14770
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
14771
|
+
sub = 1;
|
|
14772
|
+
}
|
|
14773
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
14774
|
+
}
|
|
14775
|
+
|
|
14776
|
+
return offset + byteLength
|
|
14777
|
+
};
|
|
14778
|
+
|
|
14779
|
+
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
14780
|
+
value = +value;
|
|
14781
|
+
offset = offset >>> 0;
|
|
14782
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
|
|
14783
|
+
if (value < 0) value = 0xff + value + 1;
|
|
14784
|
+
this[offset] = (value & 0xff);
|
|
14785
|
+
return offset + 1
|
|
14786
|
+
};
|
|
14787
|
+
|
|
14788
|
+
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
14789
|
+
value = +value;
|
|
14790
|
+
offset = offset >>> 0;
|
|
14791
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
14792
|
+
this[offset] = (value & 0xff);
|
|
14793
|
+
this[offset + 1] = (value >>> 8);
|
|
14794
|
+
return offset + 2
|
|
14795
|
+
};
|
|
14796
|
+
|
|
14797
|
+
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
14798
|
+
value = +value;
|
|
14799
|
+
offset = offset >>> 0;
|
|
14800
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
14801
|
+
this[offset] = (value >>> 8);
|
|
14802
|
+
this[offset + 1] = (value & 0xff);
|
|
14803
|
+
return offset + 2
|
|
14804
|
+
};
|
|
14805
|
+
|
|
14806
|
+
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
14807
|
+
value = +value;
|
|
14808
|
+
offset = offset >>> 0;
|
|
14809
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
14810
|
+
this[offset] = (value & 0xff);
|
|
14811
|
+
this[offset + 1] = (value >>> 8);
|
|
14812
|
+
this[offset + 2] = (value >>> 16);
|
|
14813
|
+
this[offset + 3] = (value >>> 24);
|
|
14814
|
+
return offset + 4
|
|
14815
|
+
};
|
|
14816
|
+
|
|
14817
|
+
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
14818
|
+
value = +value;
|
|
14819
|
+
offset = offset >>> 0;
|
|
14820
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
14821
|
+
if (value < 0) value = 0xffffffff + value + 1;
|
|
14822
|
+
this[offset] = (value >>> 24);
|
|
14823
|
+
this[offset + 1] = (value >>> 16);
|
|
14824
|
+
this[offset + 2] = (value >>> 8);
|
|
14825
|
+
this[offset + 3] = (value & 0xff);
|
|
14826
|
+
return offset + 4
|
|
14827
|
+
};
|
|
14828
|
+
|
|
14829
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
14830
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
14831
|
+
});
|
|
14832
|
+
|
|
14833
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
14834
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
14835
|
+
});
|
|
14836
|
+
|
|
14837
|
+
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
14838
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
14839
|
+
if (offset < 0) throw new RangeError('Index out of range')
|
|
14840
|
+
}
|
|
14841
|
+
|
|
14842
|
+
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
14843
|
+
value = +value;
|
|
14844
|
+
offset = offset >>> 0;
|
|
14845
|
+
if (!noAssert) {
|
|
14846
|
+
checkIEEE754(buf, value, offset, 4);
|
|
14847
|
+
}
|
|
14848
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
14849
|
+
return offset + 4
|
|
14850
|
+
}
|
|
14851
|
+
|
|
14852
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
14853
|
+
return writeFloat(this, value, offset, true, noAssert)
|
|
14854
|
+
};
|
|
14855
|
+
|
|
14856
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
14857
|
+
return writeFloat(this, value, offset, false, noAssert)
|
|
14858
|
+
};
|
|
14859
|
+
|
|
14860
|
+
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
14861
|
+
value = +value;
|
|
14862
|
+
offset = offset >>> 0;
|
|
14863
|
+
if (!noAssert) {
|
|
14864
|
+
checkIEEE754(buf, value, offset, 8);
|
|
14865
|
+
}
|
|
14866
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
14867
|
+
return offset + 8
|
|
14868
|
+
}
|
|
14869
|
+
|
|
14870
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
14871
|
+
return writeDouble(this, value, offset, true, noAssert)
|
|
14872
|
+
};
|
|
14873
|
+
|
|
14874
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
14875
|
+
return writeDouble(this, value, offset, false, noAssert)
|
|
14876
|
+
};
|
|
14877
|
+
|
|
14878
|
+
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
14879
|
+
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
14880
|
+
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
14881
|
+
if (!start) start = 0;
|
|
14882
|
+
if (!end && end !== 0) end = this.length;
|
|
14883
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
14884
|
+
if (!targetStart) targetStart = 0;
|
|
14885
|
+
if (end > 0 && end < start) end = start;
|
|
14886
|
+
|
|
14887
|
+
// Copy 0 bytes; we're done
|
|
14888
|
+
if (end === start) return 0
|
|
14889
|
+
if (target.length === 0 || this.length === 0) return 0
|
|
14890
|
+
|
|
14891
|
+
// Fatal error conditions
|
|
14892
|
+
if (targetStart < 0) {
|
|
14893
|
+
throw new RangeError('targetStart out of bounds')
|
|
14894
|
+
}
|
|
14895
|
+
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
14896
|
+
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
14897
|
+
|
|
14898
|
+
// Are we oob?
|
|
14899
|
+
if (end > this.length) end = this.length;
|
|
14900
|
+
if (target.length - targetStart < end - start) {
|
|
14901
|
+
end = target.length - targetStart + start;
|
|
14902
|
+
}
|
|
14903
|
+
|
|
14904
|
+
const len = end - start;
|
|
14905
|
+
|
|
14906
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
14907
|
+
// Use built-in when available, missing from IE11
|
|
14908
|
+
this.copyWithin(targetStart, start, end);
|
|
14909
|
+
} else {
|
|
14910
|
+
Uint8Array.prototype.set.call(
|
|
14911
|
+
target,
|
|
14912
|
+
this.subarray(start, end),
|
|
14913
|
+
targetStart
|
|
14914
|
+
);
|
|
14915
|
+
}
|
|
14916
|
+
|
|
14917
|
+
return len
|
|
14918
|
+
};
|
|
14919
|
+
|
|
14920
|
+
// Usage:
|
|
14921
|
+
// buffer.fill(number[, offset[, end]])
|
|
14922
|
+
// buffer.fill(buffer[, offset[, end]])
|
|
14923
|
+
// buffer.fill(string[, offset[, end]][, encoding])
|
|
14924
|
+
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
14925
|
+
// Handle string cases:
|
|
14926
|
+
if (typeof val === 'string') {
|
|
14927
|
+
if (typeof start === 'string') {
|
|
14928
|
+
encoding = start;
|
|
14929
|
+
start = 0;
|
|
14930
|
+
end = this.length;
|
|
14931
|
+
} else if (typeof end === 'string') {
|
|
14932
|
+
encoding = end;
|
|
14933
|
+
end = this.length;
|
|
14934
|
+
}
|
|
14935
|
+
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
14936
|
+
throw new TypeError('encoding must be a string')
|
|
14937
|
+
}
|
|
14938
|
+
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
14939
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
14940
|
+
}
|
|
14941
|
+
if (val.length === 1) {
|
|
14942
|
+
const code = val.charCodeAt(0);
|
|
14943
|
+
if ((encoding === 'utf8' && code < 128) ||
|
|
14944
|
+
encoding === 'latin1') {
|
|
14945
|
+
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
14946
|
+
val = code;
|
|
14947
|
+
}
|
|
14948
|
+
}
|
|
14949
|
+
} else if (typeof val === 'number') {
|
|
14950
|
+
val = val & 255;
|
|
14951
|
+
} else if (typeof val === 'boolean') {
|
|
14952
|
+
val = Number(val);
|
|
14953
|
+
}
|
|
14954
|
+
|
|
14955
|
+
// Invalid ranges are not set to a default, so can range check early.
|
|
14956
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
14957
|
+
throw new RangeError('Out of range index')
|
|
14958
|
+
}
|
|
14959
|
+
|
|
14960
|
+
if (end <= start) {
|
|
14961
|
+
return this
|
|
14962
|
+
}
|
|
14963
|
+
|
|
14964
|
+
start = start >>> 0;
|
|
14965
|
+
end = end === undefined ? this.length : end >>> 0;
|
|
14966
|
+
|
|
14967
|
+
if (!val) val = 0;
|
|
14968
|
+
|
|
14969
|
+
let i;
|
|
14970
|
+
if (typeof val === 'number') {
|
|
14971
|
+
for (i = start; i < end; ++i) {
|
|
14972
|
+
this[i] = val;
|
|
14973
|
+
}
|
|
14974
|
+
} else {
|
|
14975
|
+
const bytes = Buffer.isBuffer(val)
|
|
14976
|
+
? val
|
|
14977
|
+
: Buffer.from(val, encoding);
|
|
14978
|
+
const len = bytes.length;
|
|
14979
|
+
if (len === 0) {
|
|
14980
|
+
throw new TypeError('The value "' + val +
|
|
14981
|
+
'" is invalid for argument "value"')
|
|
14982
|
+
}
|
|
14983
|
+
for (i = 0; i < end - start; ++i) {
|
|
14984
|
+
this[i + start] = bytes[i % len];
|
|
14985
|
+
}
|
|
14986
|
+
}
|
|
14987
|
+
|
|
14988
|
+
return this
|
|
14989
|
+
};
|
|
14990
|
+
|
|
14991
|
+
// CUSTOM ERRORS
|
|
14992
|
+
// =============
|
|
14993
|
+
|
|
14994
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
|
14995
|
+
const errors = {};
|
|
14996
|
+
function E (sym, getMessage, Base) {
|
|
14997
|
+
errors[sym] = class NodeError extends Base {
|
|
14998
|
+
constructor () {
|
|
14999
|
+
super();
|
|
15000
|
+
|
|
15001
|
+
Object.defineProperty(this, 'message', {
|
|
15002
|
+
value: getMessage.apply(this, arguments),
|
|
15003
|
+
writable: true,
|
|
15004
|
+
configurable: true
|
|
15005
|
+
});
|
|
15006
|
+
|
|
15007
|
+
// Add the error code to the name to include it in the stack trace.
|
|
15008
|
+
this.name = `${this.name} [${sym}]`;
|
|
15009
|
+
// Access the stack to generate the error message including the error code
|
|
15010
|
+
// from the name.
|
|
15011
|
+
this.stack; // eslint-disable-line no-unused-expressions
|
|
15012
|
+
// Reset the name to the actual name.
|
|
15013
|
+
delete this.name;
|
|
15014
|
+
}
|
|
15015
|
+
|
|
15016
|
+
get code () {
|
|
15017
|
+
return sym
|
|
15018
|
+
}
|
|
15019
|
+
|
|
15020
|
+
set code (value) {
|
|
15021
|
+
Object.defineProperty(this, 'code', {
|
|
15022
|
+
configurable: true,
|
|
15023
|
+
enumerable: true,
|
|
15024
|
+
value,
|
|
15025
|
+
writable: true
|
|
15026
|
+
});
|
|
15027
|
+
}
|
|
15028
|
+
|
|
15029
|
+
toString () {
|
|
15030
|
+
return `${this.name} [${sym}]: ${this.message}`
|
|
15031
|
+
}
|
|
15032
|
+
};
|
|
15033
|
+
}
|
|
15034
|
+
|
|
15035
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
15036
|
+
function (name) {
|
|
15037
|
+
if (name) {
|
|
15038
|
+
return `${name} is outside of buffer bounds`
|
|
15039
|
+
}
|
|
15040
|
+
|
|
15041
|
+
return 'Attempt to access memory outside buffer bounds'
|
|
15042
|
+
}, RangeError);
|
|
15043
|
+
E('ERR_INVALID_ARG_TYPE',
|
|
15044
|
+
function (name, actual) {
|
|
15045
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
15046
|
+
}, TypeError);
|
|
15047
|
+
E('ERR_OUT_OF_RANGE',
|
|
15048
|
+
function (str, range, input) {
|
|
15049
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
15050
|
+
let received = input;
|
|
15051
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
15052
|
+
received = addNumericalSeparator(String(input));
|
|
15053
|
+
} else if (typeof input === 'bigint') {
|
|
15054
|
+
received = String(input);
|
|
15055
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
15056
|
+
received = addNumericalSeparator(received);
|
|
15057
|
+
}
|
|
15058
|
+
received += 'n';
|
|
15059
|
+
}
|
|
15060
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
15061
|
+
return msg
|
|
15062
|
+
}, RangeError);
|
|
15063
|
+
|
|
15064
|
+
function addNumericalSeparator (val) {
|
|
15065
|
+
let res = '';
|
|
15066
|
+
let i = val.length;
|
|
15067
|
+
const start = val[0] === '-' ? 1 : 0;
|
|
15068
|
+
for (; i >= start + 4; i -= 3) {
|
|
15069
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
15070
|
+
}
|
|
15071
|
+
return `${val.slice(0, i)}${res}`
|
|
15072
|
+
}
|
|
15073
|
+
|
|
15074
|
+
// CHECK FUNCTIONS
|
|
15075
|
+
// ===============
|
|
15076
|
+
|
|
15077
|
+
function checkBounds (buf, offset, byteLength) {
|
|
15078
|
+
validateNumber(offset, 'offset');
|
|
15079
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
15080
|
+
boundsError(offset, buf.length - (byteLength + 1));
|
|
15081
|
+
}
|
|
15082
|
+
}
|
|
15083
|
+
|
|
15084
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
15085
|
+
if (value > max || value < min) {
|
|
15086
|
+
const n = typeof min === 'bigint' ? 'n' : '';
|
|
15087
|
+
let range;
|
|
15088
|
+
{
|
|
15089
|
+
if (min === 0 || min === BigInt(0)) {
|
|
15090
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
15091
|
+
} else {
|
|
15092
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
15093
|
+
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
15094
|
+
}
|
|
15095
|
+
}
|
|
15096
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
15097
|
+
}
|
|
15098
|
+
checkBounds(buf, offset, byteLength);
|
|
15099
|
+
}
|
|
15100
|
+
|
|
15101
|
+
function validateNumber (value, name) {
|
|
15102
|
+
if (typeof value !== 'number') {
|
|
15103
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
15104
|
+
}
|
|
15105
|
+
}
|
|
15106
|
+
|
|
15107
|
+
function boundsError (value, length, type) {
|
|
15108
|
+
if (Math.floor(value) !== value) {
|
|
15109
|
+
validateNumber(value, type);
|
|
15110
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
15111
|
+
}
|
|
15112
|
+
|
|
15113
|
+
if (length < 0) {
|
|
15114
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
15115
|
+
}
|
|
15116
|
+
|
|
15117
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
15118
|
+
`>= ${0} and <= ${length}`,
|
|
15119
|
+
value)
|
|
15120
|
+
}
|
|
15121
|
+
|
|
15122
|
+
// HELPER FUNCTIONS
|
|
15123
|
+
// ================
|
|
15124
|
+
|
|
15125
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
15126
|
+
|
|
15127
|
+
function base64clean (str) {
|
|
15128
|
+
// Node takes equal signs as end of the Base64 encoding
|
|
15129
|
+
str = str.split('=')[0];
|
|
15130
|
+
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
15131
|
+
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
15132
|
+
// Node converts strings with length < 2 to ''
|
|
15133
|
+
if (str.length < 2) return ''
|
|
15134
|
+
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
15135
|
+
while (str.length % 4 !== 0) {
|
|
15136
|
+
str = str + '=';
|
|
15137
|
+
}
|
|
15138
|
+
return str
|
|
15139
|
+
}
|
|
15140
|
+
|
|
15141
|
+
function utf8ToBytes (string, units) {
|
|
15142
|
+
units = units || Infinity;
|
|
15143
|
+
let codePoint;
|
|
15144
|
+
const length = string.length;
|
|
15145
|
+
let leadSurrogate = null;
|
|
15146
|
+
const bytes = [];
|
|
15147
|
+
|
|
15148
|
+
for (let i = 0; i < length; ++i) {
|
|
15149
|
+
codePoint = string.charCodeAt(i);
|
|
15150
|
+
|
|
15151
|
+
// is surrogate component
|
|
15152
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
15153
|
+
// last char was a lead
|
|
15154
|
+
if (!leadSurrogate) {
|
|
15155
|
+
// no lead yet
|
|
15156
|
+
if (codePoint > 0xDBFF) {
|
|
15157
|
+
// unexpected trail
|
|
15158
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15159
|
+
continue
|
|
15160
|
+
} else if (i + 1 === length) {
|
|
15161
|
+
// unpaired lead
|
|
15162
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15163
|
+
continue
|
|
15164
|
+
}
|
|
15165
|
+
|
|
15166
|
+
// valid lead
|
|
15167
|
+
leadSurrogate = codePoint;
|
|
15168
|
+
|
|
15169
|
+
continue
|
|
15170
|
+
}
|
|
15171
|
+
|
|
15172
|
+
// 2 leads in a row
|
|
15173
|
+
if (codePoint < 0xDC00) {
|
|
15174
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15175
|
+
leadSurrogate = codePoint;
|
|
15176
|
+
continue
|
|
15177
|
+
}
|
|
15178
|
+
|
|
15179
|
+
// valid surrogate pair
|
|
15180
|
+
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
15181
|
+
} else if (leadSurrogate) {
|
|
15182
|
+
// valid bmp char, but last char was a lead
|
|
15183
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
15184
|
+
}
|
|
15185
|
+
|
|
15186
|
+
leadSurrogate = null;
|
|
15187
|
+
|
|
15188
|
+
// encode utf8
|
|
15189
|
+
if (codePoint < 0x80) {
|
|
15190
|
+
if ((units -= 1) < 0) break
|
|
15191
|
+
bytes.push(codePoint);
|
|
15192
|
+
} else if (codePoint < 0x800) {
|
|
15193
|
+
if ((units -= 2) < 0) break
|
|
15194
|
+
bytes.push(
|
|
15195
|
+
codePoint >> 0x6 | 0xC0,
|
|
15196
|
+
codePoint & 0x3F | 0x80
|
|
15197
|
+
);
|
|
15198
|
+
} else if (codePoint < 0x10000) {
|
|
15199
|
+
if ((units -= 3) < 0) break
|
|
15200
|
+
bytes.push(
|
|
15201
|
+
codePoint >> 0xC | 0xE0,
|
|
15202
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15203
|
+
codePoint & 0x3F | 0x80
|
|
15204
|
+
);
|
|
15205
|
+
} else if (codePoint < 0x110000) {
|
|
15206
|
+
if ((units -= 4) < 0) break
|
|
15207
|
+
bytes.push(
|
|
15208
|
+
codePoint >> 0x12 | 0xF0,
|
|
15209
|
+
codePoint >> 0xC & 0x3F | 0x80,
|
|
15210
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
15211
|
+
codePoint & 0x3F | 0x80
|
|
15212
|
+
);
|
|
15213
|
+
} else {
|
|
15214
|
+
throw new Error('Invalid code point')
|
|
15215
|
+
}
|
|
15216
|
+
}
|
|
15217
|
+
|
|
15218
|
+
return bytes
|
|
15219
|
+
}
|
|
15220
|
+
|
|
15221
|
+
function asciiToBytes (str) {
|
|
15222
|
+
const byteArray = [];
|
|
15223
|
+
for (let i = 0; i < str.length; ++i) {
|
|
15224
|
+
// Node's code seems to be doing this and not & 0x7F..
|
|
15225
|
+
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
15226
|
+
}
|
|
15227
|
+
return byteArray
|
|
15228
|
+
}
|
|
15229
|
+
|
|
15230
|
+
function utf16leToBytes (str, units) {
|
|
15231
|
+
let c, hi, lo;
|
|
15232
|
+
const byteArray = [];
|
|
15233
|
+
for (let i = 0; i < str.length; ++i) {
|
|
15234
|
+
if ((units -= 2) < 0) break
|
|
15235
|
+
|
|
15236
|
+
c = str.charCodeAt(i);
|
|
15237
|
+
hi = c >> 8;
|
|
15238
|
+
lo = c % 256;
|
|
15239
|
+
byteArray.push(lo);
|
|
15240
|
+
byteArray.push(hi);
|
|
15241
|
+
}
|
|
15242
|
+
|
|
15243
|
+
return byteArray
|
|
15244
|
+
}
|
|
15245
|
+
|
|
15246
|
+
function base64ToBytes (str) {
|
|
15247
|
+
return base64.toByteArray(base64clean(str))
|
|
15248
|
+
}
|
|
15249
|
+
|
|
15250
|
+
function blitBuffer (src, dst, offset, length) {
|
|
15251
|
+
let i;
|
|
15252
|
+
for (i = 0; i < length; ++i) {
|
|
15253
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
15254
|
+
dst[i + offset] = src[i];
|
|
15255
|
+
}
|
|
15256
|
+
return i
|
|
15257
|
+
}
|
|
15258
|
+
|
|
15259
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
15260
|
+
// the `instanceof` check but they should be treated as of that type.
|
|
15261
|
+
// See: https://github.com/feross/buffer/issues/166
|
|
15262
|
+
function isInstance (obj, type) {
|
|
15263
|
+
return obj instanceof type ||
|
|
15264
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
15265
|
+
obj.constructor.name === type.name)
|
|
15266
|
+
}
|
|
15267
|
+
function numberIsNaN (obj) {
|
|
15268
|
+
// For IE11 support
|
|
15269
|
+
return obj !== obj // eslint-disable-line no-self-compare
|
|
15270
|
+
}
|
|
15271
|
+
|
|
15272
|
+
// Create lookup table for `toString('hex')`
|
|
15273
|
+
// See: https://github.com/feross/buffer/issues/219
|
|
15274
|
+
const hexSliceLookupTable = (function () {
|
|
15275
|
+
const alphabet = '0123456789abcdef';
|
|
15276
|
+
const table = new Array(256);
|
|
15277
|
+
for (let i = 0; i < 16; ++i) {
|
|
15278
|
+
const i16 = i * 16;
|
|
15279
|
+
for (let j = 0; j < 16; ++j) {
|
|
15280
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
15281
|
+
}
|
|
15282
|
+
}
|
|
15283
|
+
return table
|
|
15284
|
+
})();
|
|
15285
|
+
|
|
15286
|
+
// Return not function with Error if BigInt not supported
|
|
15287
|
+
function defineBigIntMethod (fn) {
|
|
15288
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
15289
|
+
}
|
|
15290
|
+
|
|
15291
|
+
function BufferBigIntNotDefined () {
|
|
15292
|
+
throw new Error('BigInt not supported')
|
|
15293
|
+
}
|
|
15294
|
+
} (buffer));
|
|
15295
|
+
return buffer;
|
|
15296
|
+
}
|
|
15297
|
+
|
|
15298
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
15299
|
+
|
|
15300
|
+
var hasRequiredSafeBuffer;
|
|
15301
|
+
|
|
15302
|
+
function requireSafeBuffer () {
|
|
15303
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
15304
|
+
hasRequiredSafeBuffer = 1;
|
|
15305
|
+
(function (module, exports$1) {
|
|
15306
|
+
/* eslint-disable node/no-deprecated-api */
|
|
15307
|
+
var buffer = requireBuffer();
|
|
15308
|
+
var Buffer = buffer.Buffer;
|
|
15309
|
+
|
|
15310
|
+
// alternative to using Object.keys for old browsers
|
|
15311
|
+
function copyProps (src, dst) {
|
|
15312
|
+
for (var key in src) {
|
|
15313
|
+
dst[key] = src[key];
|
|
15314
|
+
}
|
|
15315
|
+
}
|
|
15316
|
+
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
15317
|
+
module.exports = buffer;
|
|
15318
|
+
} else {
|
|
15319
|
+
// Copy properties from require('buffer')
|
|
15320
|
+
copyProps(buffer, exports$1);
|
|
15321
|
+
exports$1.Buffer = SafeBuffer;
|
|
15322
|
+
}
|
|
15323
|
+
|
|
15324
|
+
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
15325
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
15326
|
+
}
|
|
15327
|
+
|
|
15328
|
+
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
15329
|
+
|
|
15330
|
+
// Copy static methods from Buffer
|
|
15331
|
+
copyProps(Buffer, SafeBuffer);
|
|
15332
|
+
|
|
15333
|
+
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
15334
|
+
if (typeof arg === 'number') {
|
|
15335
|
+
throw new TypeError('Argument must not be a number')
|
|
15336
|
+
}
|
|
15337
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
15338
|
+
};
|
|
15339
|
+
|
|
15340
|
+
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
15341
|
+
if (typeof size !== 'number') {
|
|
15342
|
+
throw new TypeError('Argument must be a number')
|
|
15343
|
+
}
|
|
15344
|
+
var buf = Buffer(size);
|
|
15345
|
+
if (fill !== undefined) {
|
|
15346
|
+
if (typeof encoding === 'string') {
|
|
15347
|
+
buf.fill(fill, encoding);
|
|
15348
|
+
} else {
|
|
15349
|
+
buf.fill(fill);
|
|
15350
|
+
}
|
|
15351
|
+
} else {
|
|
15352
|
+
buf.fill(0);
|
|
15353
|
+
}
|
|
15354
|
+
return buf
|
|
15355
|
+
};
|
|
15356
|
+
|
|
15357
|
+
SafeBuffer.allocUnsafe = function (size) {
|
|
15358
|
+
if (typeof size !== 'number') {
|
|
15359
|
+
throw new TypeError('Argument must be a number')
|
|
15360
|
+
}
|
|
15361
|
+
return Buffer(size)
|
|
15362
|
+
};
|
|
15363
|
+
|
|
15364
|
+
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
15365
|
+
if (typeof size !== 'number') {
|
|
15366
|
+
throw new TypeError('Argument must be a number')
|
|
15367
|
+
}
|
|
15368
|
+
return buffer.SlowBuffer(size)
|
|
15369
|
+
};
|
|
15370
|
+
} (safeBuffer, safeBuffer.exports));
|
|
15371
|
+
return safeBuffer.exports;
|
|
15372
|
+
}
|
|
15373
|
+
|
|
15374
|
+
var src;
|
|
15375
|
+
var hasRequiredSrc;
|
|
15376
|
+
|
|
15377
|
+
function requireSrc () {
|
|
15378
|
+
if (hasRequiredSrc) return src;
|
|
15379
|
+
hasRequiredSrc = 1;
|
|
15380
|
+
// base-x encoding / decoding
|
|
15381
|
+
// Copyright (c) 2018 base-x contributors
|
|
15382
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
15383
|
+
// Distributed under the MIT software license, see the accompanying
|
|
15384
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
15385
|
+
// @ts-ignore
|
|
15386
|
+
var _Buffer = requireSafeBuffer().Buffer;
|
|
15387
|
+
function base (ALPHABET) {
|
|
15388
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
15389
|
+
var BASE_MAP = new Uint8Array(256);
|
|
15390
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
15391
|
+
BASE_MAP[j] = 255;
|
|
15392
|
+
}
|
|
15393
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
15394
|
+
var x = ALPHABET.charAt(i);
|
|
15395
|
+
var xc = x.charCodeAt(0);
|
|
15396
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
15397
|
+
BASE_MAP[xc] = i;
|
|
15398
|
+
}
|
|
15399
|
+
var BASE = ALPHABET.length;
|
|
15400
|
+
var LEADER = ALPHABET.charAt(0);
|
|
15401
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
15402
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
15403
|
+
function encode (source) {
|
|
15404
|
+
if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
|
|
15405
|
+
if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
|
|
15406
|
+
if (source.length === 0) { return '' }
|
|
15407
|
+
// Skip & count leading zeroes.
|
|
15408
|
+
var zeroes = 0;
|
|
15409
|
+
var length = 0;
|
|
15410
|
+
var pbegin = 0;
|
|
15411
|
+
var pend = source.length;
|
|
15412
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
15413
|
+
pbegin++;
|
|
15414
|
+
zeroes++;
|
|
15415
|
+
}
|
|
15416
|
+
// Allocate enough space in big-endian base58 representation.
|
|
15417
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
15418
|
+
var b58 = new Uint8Array(size);
|
|
15419
|
+
// Process the bytes.
|
|
15420
|
+
while (pbegin !== pend) {
|
|
15421
|
+
var carry = source[pbegin];
|
|
15422
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
15423
|
+
var i = 0;
|
|
15424
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
15425
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
15426
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
15427
|
+
carry = (carry / BASE) >>> 0;
|
|
15428
|
+
}
|
|
15429
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15430
|
+
length = i;
|
|
15431
|
+
pbegin++;
|
|
15432
|
+
}
|
|
15433
|
+
// Skip leading zeroes in base58 result.
|
|
15434
|
+
var it2 = size - length;
|
|
15435
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
15436
|
+
it2++;
|
|
15437
|
+
}
|
|
15438
|
+
// Translate the result into a string.
|
|
15439
|
+
var str = LEADER.repeat(zeroes);
|
|
15440
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
15441
|
+
return str
|
|
15442
|
+
}
|
|
15443
|
+
function decodeUnsafe (source) {
|
|
15444
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
15445
|
+
if (source.length === 0) { return _Buffer.alloc(0) }
|
|
15446
|
+
var psz = 0;
|
|
15447
|
+
// Skip and count leading '1's.
|
|
15448
|
+
var zeroes = 0;
|
|
15449
|
+
var length = 0;
|
|
15450
|
+
while (source[psz] === LEADER) {
|
|
15451
|
+
zeroes++;
|
|
15452
|
+
psz++;
|
|
15453
|
+
}
|
|
15454
|
+
// Allocate enough space in big-endian base256 representation.
|
|
15455
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
15456
|
+
var b256 = new Uint8Array(size);
|
|
15457
|
+
// Process the characters.
|
|
15458
|
+
while (psz < source.length) {
|
|
15459
|
+
// Find code of next character
|
|
15460
|
+
var charCode = source.charCodeAt(psz);
|
|
15461
|
+
// Base map can not be indexed using char code
|
|
15462
|
+
if (charCode > 255) { return }
|
|
15463
|
+
// Decode character
|
|
15464
|
+
var carry = BASE_MAP[charCode];
|
|
15465
|
+
// Invalid character
|
|
15466
|
+
if (carry === 255) { return }
|
|
15467
|
+
var i = 0;
|
|
15468
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
15469
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
15470
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
15471
|
+
carry = (carry / 256) >>> 0;
|
|
15472
|
+
}
|
|
15473
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
15474
|
+
length = i;
|
|
15475
|
+
psz++;
|
|
15476
|
+
}
|
|
15477
|
+
// Skip leading zeroes in b256.
|
|
15478
|
+
var it4 = size - length;
|
|
15479
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
15480
|
+
it4++;
|
|
15481
|
+
}
|
|
15482
|
+
var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
|
|
15483
|
+
vch.fill(0x00, 0, zeroes);
|
|
15484
|
+
var j = zeroes;
|
|
15485
|
+
while (it4 !== size) {
|
|
15486
|
+
vch[j++] = b256[it4++];
|
|
15487
|
+
}
|
|
15488
|
+
return vch
|
|
15489
|
+
}
|
|
15490
|
+
function decode (string) {
|
|
15491
|
+
var buffer = decodeUnsafe(string);
|
|
15492
|
+
if (buffer) { return buffer }
|
|
15493
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
15494
|
+
}
|
|
15495
|
+
return {
|
|
15496
|
+
encode: encode,
|
|
15497
|
+
decodeUnsafe: decodeUnsafe,
|
|
15498
|
+
decode: decode
|
|
15499
|
+
}
|
|
15500
|
+
}
|
|
15501
|
+
src = base;
|
|
15502
|
+
return src;
|
|
15503
|
+
}
|
|
15504
|
+
|
|
15505
|
+
var bs58$1;
|
|
15506
|
+
var hasRequiredBs58;
|
|
15507
|
+
|
|
15508
|
+
function requireBs58 () {
|
|
15509
|
+
if (hasRequiredBs58) return bs58$1;
|
|
15510
|
+
hasRequiredBs58 = 1;
|
|
15511
|
+
var basex = requireSrc();
|
|
15512
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
15513
|
+
|
|
15514
|
+
bs58$1 = basex(ALPHABET);
|
|
15515
|
+
return bs58$1;
|
|
15516
|
+
}
|
|
15517
|
+
|
|
15518
|
+
var bs58Exports = requireBs58();
|
|
15519
|
+
var bs58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
|
|
15520
|
+
|
|
15521
|
+
var index = /*#__PURE__*/_mergeNamespaces({
|
|
15522
|
+
__proto__: null,
|
|
15523
|
+
default: bs58
|
|
15524
|
+
}, [bs58Exports]);
|
|
13385
15525
|
|
|
13386
15526
|
/**
|
|
13387
15527
|
* Privy Expo Auth Provider — React Native implementation of AuthProvider.
|
|
@@ -13767,6 +15907,7 @@ exports.onAuthLoadingChanged = onAuthLoadingChanged;
|
|
|
13767
15907
|
exports.onAuthStateChanged = onAuthStateChanged;
|
|
13768
15908
|
exports.reconnectWithNewAuth = reconnectWithNewAuth;
|
|
13769
15909
|
exports.refreshSession = refreshSession;
|
|
15910
|
+
exports.requireBuffer = requireBuffer;
|
|
13770
15911
|
exports.runExpression = runExpression;
|
|
13771
15912
|
exports.runExpressionMany = runExpressionMany;
|
|
13772
15913
|
exports.runQuery = runQuery;
|
|
@@ -13783,4 +15924,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
|
13783
15924
|
exports.signTransaction = signTransaction;
|
|
13784
15925
|
exports.subscribe = subscribe;
|
|
13785
15926
|
exports.useAuth = useAuth;
|
|
13786
|
-
//# sourceMappingURL=index.native-
|
|
15927
|
+
//# sourceMappingURL=index.native-DtxPWD00.js.map
|