@pooflabs/web 0.0.79 → 0.0.80
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-DwU9hjtr.js → index-BNyxZ82q.js} +365 -23
- package/dist/index-BNyxZ82q.js.map +1 -0
- package/dist/{index-zS_Y-wbi.js → index-BVi7fTm2.js} +2 -2
- package/dist/{index-zS_Y-wbi.js.map → index-BVi7fTm2.js.map} +1 -1
- package/dist/{index-CiwYJvf8.esm.js → index-BbtYb8sE.esm.js} +3 -3
- package/dist/{index-CiwYJvf8.esm.js.map → index-BbtYb8sE.esm.js.map} +1 -1
- package/dist/{index-BHGEc97p.js → index-BhfNMrC0.js} +3 -3
- package/dist/{index-BHGEc97p.js.map → index-BhfNMrC0.js.map} +1 -1
- package/dist/index-CKIoDkjJ.esm.js +6 -0
- package/dist/index-CKIoDkjJ.esm.js.map +1 -0
- package/dist/{index-U-xlsKRI.esm.js → index-COIUWugk.esm.js} +2 -2
- package/dist/{index-U-xlsKRI.esm.js.map → index-COIUWugk.esm.js.map} +1 -1
- package/dist/{index-D9BY44i-.js → index-CSraUgD6.js} +2 -2
- package/dist/index-CSraUgD6.js.map +1 -0
- package/dist/{index-CsIXFm8d.esm.js → index-Db0NqU8R.esm.js} +365 -23
- package/dist/index-Db0NqU8R.esm.js.map +1 -0
- package/dist/{index.browser-Cpi4W_1r.js → index.browser-8hyi2LOX.js} +1696 -1366
- package/dist/index.browser-8hyi2LOX.js.map +1 -0
- package/dist/{index.browser-Dbq5Qf1G.esm.js → index.browser-B4zXnffD.esm.js} +81 -98
- package/dist/index.browser-B4zXnffD.esm.js.map +1 -0
- package/dist/{index.browser-Df7yN8D5.js → index.browser-BJ_TdUVA.js} +80 -97
- package/dist/index.browser-BJ_TdUVA.js.map +1 -0
- package/dist/index.browser-BkNaRRVe.js +1222 -0
- package/dist/index.browser-BkNaRRVe.js.map +1 -0
- package/dist/{index.browser-CMEwqnEe.esm.js → index.browser-BuHl80dp.esm.js} +1696 -1366
- package/dist/index.browser-BuHl80dp.esm.js.map +1 -0
- package/dist/index.browser-CnbxBj3-.esm.js +1219 -0
- package/dist/index.browser-CnbxBj3-.esm.js.map +1 -0
- package/dist/index.browser-OvGNsMPu.esm.js +1002 -0
- package/dist/index.browser-OvGNsMPu.esm.js.map +1 -0
- package/dist/index.browser-vuTr40so.js +1008 -0
- package/dist/index.browser-vuTr40so.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index.native-DtxPWD00.js → index.native-DUnE51Mx.js} +365 -23
- package/dist/index.native-DUnE51Mx.js.map +1 -0
- package/dist/{index.native-CEf5PJ_g.esm.js → index.native-DuKhZcus.esm.js} +365 -23
- package/dist/index.native-DuKhZcus.esm.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js → phantom-wallet-provider--BJjVUA1.esm.js} +4 -4
- package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js.map → phantom-wallet-provider--BJjVUA1.esm.js.map} +1 -1
- package/dist/{phantom-wallet-provider-BbyQIlro.js → phantom-wallet-provider-Cg-srwP4.js} +4 -4
- package/dist/{phantom-wallet-provider-BbyQIlro.js.map → phantom-wallet-provider-Cg-srwP4.js.map} +1 -1
- package/dist/{privy-wallet-provider-DGjYglh7.esm.js → privy-wallet-provider-BLcur3Ue.esm.js} +3 -3
- package/dist/{privy-wallet-provider-DGjYglh7.esm.js.map → privy-wallet-provider-BLcur3Ue.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-CoQzq0F4.js → privy-wallet-provider-DpNVyaXa.js} +3 -3
- package/dist/{privy-wallet-provider-CoQzq0F4.js.map → privy-wallet-provider-DpNVyaXa.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js → solana-mobile-wallet-provider-CFaubssb.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js.map → solana-mobile-wallet-provider-CFaubssb.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js → solana-mobile-wallet-provider-zXAk2tfS.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js.map → solana-mobile-wallet-provider-zXAk2tfS.js.map} +1 -1
- package/package.json +24 -24
- package/dist/index-6pNPzV1t.esm.js +0 -6
- package/dist/index-6pNPzV1t.esm.js.map +0 -1
- package/dist/index-CsIXFm8d.esm.js.map +0 -1
- package/dist/index-D9BY44i-.js.map +0 -1
- package/dist/index-DwU9hjtr.js.map +0 -1
- package/dist/index.browser-C-_FEr5M.esm.js +0 -1134
- package/dist/index.browser-C-_FEr5M.esm.js.map +0 -1
- package/dist/index.browser-C9bFQZyQ.esm.js +0 -1373
- package/dist/index.browser-C9bFQZyQ.esm.js.map +0 -1
- package/dist/index.browser-CMEwqnEe.esm.js.map +0 -1
- package/dist/index.browser-Cpi4W_1r.js.map +0 -1
- package/dist/index.browser-Dbq5Qf1G.esm.js.map +0 -1
- package/dist/index.browser-Df7yN8D5.js.map +0 -1
- package/dist/index.browser-DjEZSiqI.js +0 -1137
- package/dist/index.browser-DjEZSiqI.js.map +0 -1
- package/dist/index.browser-dszs5oe5.js +0 -1376
- package/dist/index.browser-dszs5oe5.js.map +0 -1
- package/dist/index.native-CEf5PJ_g.esm.js.map +0 -1
- package/dist/index.native-DtxPWD00.js.map +0 -1
|
@@ -6415,6 +6415,261 @@ var ReconnectingWebSocket = /** @class */ (function () {
|
|
|
6415
6415
|
return ReconnectingWebSocket;
|
|
6416
6416
|
}());
|
|
6417
6417
|
|
|
6418
|
+
function getDefaultExportFromCjs (x) {
|
|
6419
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6420
|
+
}
|
|
6421
|
+
|
|
6422
|
+
var isRetryAllowed$1;
|
|
6423
|
+
var hasRequiredIsRetryAllowed;
|
|
6424
|
+
|
|
6425
|
+
function requireIsRetryAllowed () {
|
|
6426
|
+
if (hasRequiredIsRetryAllowed) return isRetryAllowed$1;
|
|
6427
|
+
hasRequiredIsRetryAllowed = 1;
|
|
6428
|
+
|
|
6429
|
+
const denyList = new Set([
|
|
6430
|
+
'ENOTFOUND',
|
|
6431
|
+
'ENETUNREACH',
|
|
6432
|
+
|
|
6433
|
+
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
|
|
6434
|
+
'UNABLE_TO_GET_ISSUER_CERT',
|
|
6435
|
+
'UNABLE_TO_GET_CRL',
|
|
6436
|
+
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
|
6437
|
+
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
|
|
6438
|
+
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
|
|
6439
|
+
'CERT_SIGNATURE_FAILURE',
|
|
6440
|
+
'CRL_SIGNATURE_FAILURE',
|
|
6441
|
+
'CERT_NOT_YET_VALID',
|
|
6442
|
+
'CERT_HAS_EXPIRED',
|
|
6443
|
+
'CRL_NOT_YET_VALID',
|
|
6444
|
+
'CRL_HAS_EXPIRED',
|
|
6445
|
+
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
|
|
6446
|
+
'ERROR_IN_CERT_NOT_AFTER_FIELD',
|
|
6447
|
+
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
|
|
6448
|
+
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
|
|
6449
|
+
'OUT_OF_MEM',
|
|
6450
|
+
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
6451
|
+
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
6452
|
+
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
6453
|
+
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
6454
|
+
'CERT_CHAIN_TOO_LONG',
|
|
6455
|
+
'CERT_REVOKED',
|
|
6456
|
+
'INVALID_CA',
|
|
6457
|
+
'PATH_LENGTH_EXCEEDED',
|
|
6458
|
+
'INVALID_PURPOSE',
|
|
6459
|
+
'CERT_UNTRUSTED',
|
|
6460
|
+
'CERT_REJECTED',
|
|
6461
|
+
'HOSTNAME_MISMATCH'
|
|
6462
|
+
]);
|
|
6463
|
+
|
|
6464
|
+
// TODO: Use `error?.code` when targeting Node.js 14
|
|
6465
|
+
isRetryAllowed$1 = error => !denyList.has(error && error.code);
|
|
6466
|
+
return isRetryAllowed$1;
|
|
6467
|
+
}
|
|
6468
|
+
|
|
6469
|
+
var isRetryAllowedExports = requireIsRetryAllowed();
|
|
6470
|
+
var isRetryAllowed = /*@__PURE__*/getDefaultExportFromCjs(isRetryAllowedExports);
|
|
6471
|
+
|
|
6472
|
+
const namespace = 'axios-retry';
|
|
6473
|
+
function isNetworkError(error) {
|
|
6474
|
+
const CODE_EXCLUDE_LIST = ['ERR_CANCELED', 'ECONNABORTED'];
|
|
6475
|
+
if (error.response) {
|
|
6476
|
+
return false;
|
|
6477
|
+
}
|
|
6478
|
+
if (!error.code) {
|
|
6479
|
+
return false;
|
|
6480
|
+
}
|
|
6481
|
+
// Prevents retrying timed out & cancelled requests
|
|
6482
|
+
if (CODE_EXCLUDE_LIST.includes(error.code)) {
|
|
6483
|
+
return false;
|
|
6484
|
+
}
|
|
6485
|
+
// Prevents retrying unsafe errors
|
|
6486
|
+
return isRetryAllowed(error);
|
|
6487
|
+
}
|
|
6488
|
+
const SAFE_HTTP_METHODS = ['get', 'head', 'options'];
|
|
6489
|
+
const IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
|
|
6490
|
+
function isRetryableError(error) {
|
|
6491
|
+
return (error.code !== 'ECONNABORTED' &&
|
|
6492
|
+
(!error.response ||
|
|
6493
|
+
error.response.status === 429 ||
|
|
6494
|
+
(error.response.status >= 500 && error.response.status <= 599)));
|
|
6495
|
+
}
|
|
6496
|
+
function isSafeRequestError(error) {
|
|
6497
|
+
if (!error.config?.method) {
|
|
6498
|
+
// Cannot determine if the request can be retried
|
|
6499
|
+
return false;
|
|
6500
|
+
}
|
|
6501
|
+
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6502
|
+
}
|
|
6503
|
+
function isIdempotentRequestError(error) {
|
|
6504
|
+
if (!error.config?.method) {
|
|
6505
|
+
// Cannot determine if the request can be retried
|
|
6506
|
+
return false;
|
|
6507
|
+
}
|
|
6508
|
+
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6509
|
+
}
|
|
6510
|
+
function isNetworkOrIdempotentRequestError(error) {
|
|
6511
|
+
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
6512
|
+
}
|
|
6513
|
+
function retryAfter(error = undefined) {
|
|
6514
|
+
const retryAfterHeader = error?.response?.headers['retry-after'];
|
|
6515
|
+
if (!retryAfterHeader) {
|
|
6516
|
+
return 0;
|
|
6517
|
+
}
|
|
6518
|
+
// if the retry after header is a number, convert it to milliseconds
|
|
6519
|
+
let retryAfterMs = (Number(retryAfterHeader) || 0) * 1000;
|
|
6520
|
+
// If the retry after header is a date, get the number of milliseconds until that date
|
|
6521
|
+
if (retryAfterMs === 0) {
|
|
6522
|
+
retryAfterMs = (new Date(retryAfterHeader).valueOf() || 0) - Date.now();
|
|
6523
|
+
}
|
|
6524
|
+
return Math.max(0, retryAfterMs);
|
|
6525
|
+
}
|
|
6526
|
+
function noDelay(_retryNumber = 0, error = undefined) {
|
|
6527
|
+
return Math.max(0, retryAfter(error));
|
|
6528
|
+
}
|
|
6529
|
+
function exponentialDelay(retryNumber = 0, error = undefined, delayFactor = 100) {
|
|
6530
|
+
const calculatedDelay = 2 ** retryNumber * delayFactor;
|
|
6531
|
+
const delay = Math.max(calculatedDelay, retryAfter(error));
|
|
6532
|
+
const randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay
|
|
6533
|
+
return delay + randomSum;
|
|
6534
|
+
}
|
|
6535
|
+
/**
|
|
6536
|
+
* Linear delay
|
|
6537
|
+
* @param {number | undefined} delayFactor - delay factor in milliseconds (default: 100)
|
|
6538
|
+
* @returns {function} (retryNumber: number, error: AxiosError | undefined) => number
|
|
6539
|
+
*/
|
|
6540
|
+
function linearDelay(delayFactor = 100) {
|
|
6541
|
+
return (retryNumber = 0, error = undefined) => {
|
|
6542
|
+
const delay = retryNumber * delayFactor;
|
|
6543
|
+
return Math.max(delay, retryAfter(error));
|
|
6544
|
+
};
|
|
6545
|
+
}
|
|
6546
|
+
const DEFAULT_OPTIONS = {
|
|
6547
|
+
retries: 3,
|
|
6548
|
+
retryCondition: isNetworkOrIdempotentRequestError,
|
|
6549
|
+
retryDelay: noDelay,
|
|
6550
|
+
shouldResetTimeout: false,
|
|
6551
|
+
onRetry: () => { },
|
|
6552
|
+
onMaxRetryTimesExceeded: () => { },
|
|
6553
|
+
validateResponse: null
|
|
6554
|
+
};
|
|
6555
|
+
function getRequestOptions(config, defaultOptions) {
|
|
6556
|
+
return { ...DEFAULT_OPTIONS, ...defaultOptions, ...config[namespace] };
|
|
6557
|
+
}
|
|
6558
|
+
function setCurrentState(config, defaultOptions, resetLastRequestTime = false) {
|
|
6559
|
+
const currentState = getRequestOptions(config, defaultOptions || {});
|
|
6560
|
+
currentState.retryCount = currentState.retryCount || 0;
|
|
6561
|
+
if (!currentState.lastRequestTime || resetLastRequestTime) {
|
|
6562
|
+
currentState.lastRequestTime = Date.now();
|
|
6563
|
+
}
|
|
6564
|
+
config[namespace] = currentState;
|
|
6565
|
+
return currentState;
|
|
6566
|
+
}
|
|
6567
|
+
function fixConfig(axiosInstance, config) {
|
|
6568
|
+
// @ts-ignore
|
|
6569
|
+
if (axiosInstance.defaults.agent === config.agent) {
|
|
6570
|
+
// @ts-ignore
|
|
6571
|
+
delete config.agent;
|
|
6572
|
+
}
|
|
6573
|
+
if (axiosInstance.defaults.httpAgent === config.httpAgent) {
|
|
6574
|
+
delete config.httpAgent;
|
|
6575
|
+
}
|
|
6576
|
+
if (axiosInstance.defaults.httpsAgent === config.httpsAgent) {
|
|
6577
|
+
delete config.httpsAgent;
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6580
|
+
async function shouldRetry(currentState, error) {
|
|
6581
|
+
const { retries, retryCondition } = currentState;
|
|
6582
|
+
const shouldRetryOrPromise = (currentState.retryCount || 0) < retries && retryCondition(error);
|
|
6583
|
+
// This could be a promise
|
|
6584
|
+
if (typeof shouldRetryOrPromise === 'object') {
|
|
6585
|
+
try {
|
|
6586
|
+
const shouldRetryPromiseResult = await shouldRetryOrPromise;
|
|
6587
|
+
// keep return true unless shouldRetryPromiseResult return false for compatibility
|
|
6588
|
+
return shouldRetryPromiseResult !== false;
|
|
6589
|
+
}
|
|
6590
|
+
catch (_err) {
|
|
6591
|
+
return false;
|
|
6592
|
+
}
|
|
6593
|
+
}
|
|
6594
|
+
return shouldRetryOrPromise;
|
|
6595
|
+
}
|
|
6596
|
+
async function handleRetry(axiosInstance, currentState, error, config) {
|
|
6597
|
+
currentState.retryCount += 1;
|
|
6598
|
+
const { retryDelay, shouldResetTimeout, onRetry } = currentState;
|
|
6599
|
+
const delay = retryDelay(currentState.retryCount, error);
|
|
6600
|
+
// Axios fails merging this configuration to the default configuration because it has an issue
|
|
6601
|
+
// with circular structures: https://github.com/mzabriskie/axios/issues/370
|
|
6602
|
+
fixConfig(axiosInstance, config);
|
|
6603
|
+
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
6604
|
+
const lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
6605
|
+
const timeout = config.timeout - lastRequestDuration - delay;
|
|
6606
|
+
if (timeout <= 0) {
|
|
6607
|
+
return Promise.reject(error);
|
|
6608
|
+
}
|
|
6609
|
+
config.timeout = timeout;
|
|
6610
|
+
}
|
|
6611
|
+
config.transformRequest = [(data) => data];
|
|
6612
|
+
await onRetry(currentState.retryCount, error, config);
|
|
6613
|
+
if (config.signal?.aborted) {
|
|
6614
|
+
return Promise.resolve(axiosInstance(config));
|
|
6615
|
+
}
|
|
6616
|
+
return new Promise((resolve) => {
|
|
6617
|
+
const abortListener = () => {
|
|
6618
|
+
clearTimeout(timeout);
|
|
6619
|
+
resolve(axiosInstance(config));
|
|
6620
|
+
};
|
|
6621
|
+
const timeout = setTimeout(() => {
|
|
6622
|
+
resolve(axiosInstance(config));
|
|
6623
|
+
if (config.signal?.removeEventListener) {
|
|
6624
|
+
config.signal.removeEventListener('abort', abortListener);
|
|
6625
|
+
}
|
|
6626
|
+
}, delay);
|
|
6627
|
+
if (config.signal?.addEventListener) {
|
|
6628
|
+
config.signal.addEventListener('abort', abortListener, { once: true });
|
|
6629
|
+
}
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6632
|
+
async function handleMaxRetryTimesExceeded(currentState, error) {
|
|
6633
|
+
if (currentState.retryCount >= currentState.retries)
|
|
6634
|
+
await currentState.onMaxRetryTimesExceeded(error, currentState.retryCount);
|
|
6635
|
+
}
|
|
6636
|
+
const axiosRetry = (axiosInstance, defaultOptions) => {
|
|
6637
|
+
const requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
|
|
6638
|
+
setCurrentState(config, defaultOptions, true);
|
|
6639
|
+
if (config[namespace]?.validateResponse) {
|
|
6640
|
+
// by setting this, all HTTP responses will be go through the error interceptor first
|
|
6641
|
+
config.validateStatus = () => false;
|
|
6642
|
+
}
|
|
6643
|
+
return config;
|
|
6644
|
+
});
|
|
6645
|
+
const responseInterceptorId = axiosInstance.interceptors.response.use(null, async (error) => {
|
|
6646
|
+
const { config } = error;
|
|
6647
|
+
// If we have no information to retry the request
|
|
6648
|
+
if (!config) {
|
|
6649
|
+
return Promise.reject(error);
|
|
6650
|
+
}
|
|
6651
|
+
const currentState = setCurrentState(config, defaultOptions);
|
|
6652
|
+
if (error.response && currentState.validateResponse?.(error.response)) {
|
|
6653
|
+
// no issue with response
|
|
6654
|
+
return error.response;
|
|
6655
|
+
}
|
|
6656
|
+
if (await shouldRetry(currentState, error)) {
|
|
6657
|
+
return handleRetry(axiosInstance, currentState, error, config);
|
|
6658
|
+
}
|
|
6659
|
+
await handleMaxRetryTimesExceeded(currentState, error);
|
|
6660
|
+
return Promise.reject(error);
|
|
6661
|
+
});
|
|
6662
|
+
return { requestInterceptorId, responseInterceptorId };
|
|
6663
|
+
};
|
|
6664
|
+
// Compatibility with CommonJS
|
|
6665
|
+
axiosRetry.isNetworkError = isNetworkError;
|
|
6666
|
+
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
6667
|
+
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
6668
|
+
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
6669
|
+
axiosRetry.exponentialDelay = exponentialDelay;
|
|
6670
|
+
axiosRetry.linearDelay = linearDelay;
|
|
6671
|
+
axiosRetry.isRetryableError = isRetryableError;
|
|
6672
|
+
|
|
6418
6673
|
let axiosClient;
|
|
6419
6674
|
async function getAxiosAuthClient() {
|
|
6420
6675
|
if (!axiosClient) {
|
|
@@ -6424,6 +6679,7 @@ async function getAxiosAuthClient() {
|
|
|
6424
6679
|
headers: {
|
|
6425
6680
|
'Content-Type': 'application/json',
|
|
6426
6681
|
},
|
|
6682
|
+
timeout: 30000, // 30s timeout, matching makeApiRequest
|
|
6427
6683
|
});
|
|
6428
6684
|
}
|
|
6429
6685
|
return axiosClient;
|
|
@@ -6470,15 +6726,41 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
|
|
|
6470
6726
|
});
|
|
6471
6727
|
return response.data;
|
|
6472
6728
|
}
|
|
6729
|
+
// Deduplicate concurrent refreshSession calls to prevent multiple code paths
|
|
6730
|
+
// (WebSocket reconnection, periodic refresh, API 401 retry) from all hitting
|
|
6731
|
+
// /session/refresh simultaneously.
|
|
6732
|
+
// Note: module-level state is shared across requests in SSR/Node — acceptable
|
|
6733
|
+
// since there is only one active session per server instance (same pattern as
|
|
6734
|
+
// refreshInFlight in api.ts).
|
|
6735
|
+
let refreshInFlight$1 = null;
|
|
6736
|
+
let refreshInFlightToken = null;
|
|
6473
6737
|
async function refreshSession(refreshToken) {
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6738
|
+
if (refreshInFlight$1 && refreshInFlightToken === refreshToken) {
|
|
6739
|
+
return refreshInFlight$1;
|
|
6740
|
+
}
|
|
6741
|
+
refreshInFlightToken = refreshToken;
|
|
6742
|
+
let currentFlight;
|
|
6743
|
+
currentFlight = refreshInFlight$1 = (async () => {
|
|
6744
|
+
try {
|
|
6745
|
+
const client = await getAxiosAuthClient();
|
|
6746
|
+
const config = await getConfig();
|
|
6747
|
+
const appId = config.appId;
|
|
6748
|
+
const response = await client.post('/session/refresh', {
|
|
6749
|
+
refreshToken,
|
|
6750
|
+
appId
|
|
6751
|
+
});
|
|
6752
|
+
return response.data;
|
|
6753
|
+
}
|
|
6754
|
+
finally {
|
|
6755
|
+
// Only clear if we're still the active in-flight request.
|
|
6756
|
+
// A second call with a different token may have replaced us.
|
|
6757
|
+
if (refreshInFlight$1 === currentFlight) {
|
|
6758
|
+
refreshInFlight$1 = null;
|
|
6759
|
+
refreshInFlightToken = null;
|
|
6760
|
+
}
|
|
6761
|
+
}
|
|
6762
|
+
})();
|
|
6763
|
+
return refreshInFlight$1;
|
|
6482
6764
|
}
|
|
6483
6765
|
async function signSessionCreateMessage(_signMessageFunction) {
|
|
6484
6766
|
}
|
|
@@ -6616,14 +6898,10 @@ class WebSessionManager {
|
|
|
6616
6898
|
WebSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
|
|
6617
6899
|
|
|
6618
6900
|
var webSessionManager = /*#__PURE__*/Object.freeze({
|
|
6619
|
-
|
|
6620
|
-
|
|
6901
|
+
__proto__: null,
|
|
6902
|
+
WebSessionManager: WebSessionManager
|
|
6621
6903
|
});
|
|
6622
6904
|
|
|
6623
|
-
function getDefaultExportFromCjs (x) {
|
|
6624
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6625
|
-
}
|
|
6626
|
-
|
|
6627
6905
|
var buffer$1 = {};
|
|
6628
6906
|
|
|
6629
6907
|
var base64Js$1 = {};
|
|
@@ -9420,7 +9698,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
9420
9698
|
}
|
|
9421
9699
|
}
|
|
9422
9700
|
else if (lutKey != null) {
|
|
9423
|
-
|
|
9701
|
+
// The LUT may have just been created server-side and the client's RPC node
|
|
9702
|
+
// may not have indexed it yet (load-balancer split). Retry with exponential
|
|
9703
|
+
// back-off; first retry at 100 ms almost always resolves it.
|
|
9704
|
+
let table = null;
|
|
9705
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
9706
|
+
const { value } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
|
|
9707
|
+
if (value) {
|
|
9708
|
+
table = value;
|
|
9709
|
+
break;
|
|
9710
|
+
}
|
|
9711
|
+
if (attempt < 4)
|
|
9712
|
+
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
9713
|
+
}
|
|
9424
9714
|
if (!table)
|
|
9425
9715
|
throw new Error('LUT not found after creation/extend');
|
|
9426
9716
|
lookupTables.push(table);
|
|
@@ -9555,8 +9845,8 @@ class ServerSessionManager {
|
|
|
9555
9845
|
ServerSessionManager.instance = new ServerSessionManager();
|
|
9556
9846
|
|
|
9557
9847
|
var serverSessionManager = /*#__PURE__*/Object.freeze({
|
|
9558
|
-
|
|
9559
|
-
|
|
9848
|
+
__proto__: null,
|
|
9849
|
+
ServerSessionManager: ServerSessionManager
|
|
9560
9850
|
});
|
|
9561
9851
|
|
|
9562
9852
|
/**
|
|
@@ -9655,6 +9945,23 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
|
|
|
9655
9945
|
await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
|
|
9656
9946
|
}
|
|
9657
9947
|
|
|
9948
|
+
const apiClient = globalAxios.create();
|
|
9949
|
+
axiosRetry(apiClient, {
|
|
9950
|
+
retries: 2,
|
|
9951
|
+
retryCondition: (error) => {
|
|
9952
|
+
var _a, _b;
|
|
9953
|
+
// Only retry GET requests on network errors (ECONNRESET, ETIMEDOUT, etc.)
|
|
9954
|
+
// Writes (POST/PUT) are not retried — the server may have processed
|
|
9955
|
+
// the request before the connection was reset.
|
|
9956
|
+
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';
|
|
9957
|
+
},
|
|
9958
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
9959
|
+
shouldResetTimeout: true,
|
|
9960
|
+
onRetry: (retryCount, error, requestConfig) => {
|
|
9961
|
+
var _a;
|
|
9962
|
+
console.warn(`[tarobase-sdk] retry ${retryCount} for ${(_a = requestConfig.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${requestConfig.url} — ${error.code || error.message}`);
|
|
9963
|
+
},
|
|
9964
|
+
});
|
|
9658
9965
|
const refreshInFlight = new Map();
|
|
9659
9966
|
async function refreshAuthSessionOnce(appId, isServer) {
|
|
9660
9967
|
const key = `${isServer ? "server" : "web"}:${appId}`;
|
|
@@ -9701,6 +10008,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
9701
10008
|
ServerSessionManager.instance.clearSession();
|
|
9702
10009
|
};
|
|
9703
10010
|
async function executeRequest() {
|
|
10011
|
+
var _a;
|
|
9704
10012
|
// When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
|
|
9705
10013
|
// Otherwise use the global createAuthHeader (default path).
|
|
9706
10014
|
const authHeader = (_overrides === null || _overrides === void 0 ? void 0 : _overrides._getAuthHeaders)
|
|
@@ -9722,11 +10030,12 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
9722
10030
|
method,
|
|
9723
10031
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
9724
10032
|
headers,
|
|
10033
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : 30000,
|
|
9725
10034
|
};
|
|
9726
10035
|
if (method !== "GET" && method !== "get") {
|
|
9727
10036
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
9728
10037
|
}
|
|
9729
|
-
const response = await
|
|
10038
|
+
const response = await apiClient(requestConfig);
|
|
9730
10039
|
return { data: response.data, status: response.status, headers: response.headers };
|
|
9731
10040
|
}
|
|
9732
10041
|
try {
|
|
@@ -10662,6 +10971,7 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10662
10971
|
// This replaces the old single setTimeout approach which was unreliable for long
|
|
10663
10972
|
// delays (browsers throttle/suspend timers in background tabs).
|
|
10664
10973
|
connection.tokenRefreshTimer = setInterval(async () => {
|
|
10974
|
+
var _a, _b;
|
|
10665
10975
|
try {
|
|
10666
10976
|
const currentToken = await getIdToken$1(isServer);
|
|
10667
10977
|
if (!currentToken)
|
|
@@ -10692,6 +11002,17 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10692
11002
|
}
|
|
10693
11003
|
}
|
|
10694
11004
|
catch (refreshError) {
|
|
11005
|
+
// If the refresh token itself is invalid (401/403), stop retrying —
|
|
11006
|
+
// the token won't magically become valid next interval, and continuing
|
|
11007
|
+
// to hammer /session/refresh causes 429 rate-limit storms.
|
|
11008
|
+
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) {
|
|
11009
|
+
console.warn('[WS v2] Refresh token rejected (401/403), stopping periodic refresh');
|
|
11010
|
+
if (connection.tokenRefreshTimer) {
|
|
11011
|
+
clearInterval(connection.tokenRefreshTimer);
|
|
11012
|
+
connection.tokenRefreshTimer = null;
|
|
11013
|
+
}
|
|
11014
|
+
return;
|
|
11015
|
+
}
|
|
10695
11016
|
console.warn('[WS v2] Proactive token refresh failed, will retry next interval:', refreshError);
|
|
10696
11017
|
}
|
|
10697
11018
|
}
|
|
@@ -10702,6 +11023,7 @@ function scheduleTokenRefresh(connection, isServer) {
|
|
|
10702
11023
|
}, TOKEN_CHECK_INTERVAL);
|
|
10703
11024
|
}
|
|
10704
11025
|
async function getFreshAuthToken(isServer) {
|
|
11026
|
+
var _a, _b;
|
|
10705
11027
|
const currentToken = await getIdToken$1(isServer);
|
|
10706
11028
|
if (!currentToken) {
|
|
10707
11029
|
return null;
|
|
@@ -10724,6 +11046,17 @@ async function getFreshAuthToken(isServer) {
|
|
|
10724
11046
|
}
|
|
10725
11047
|
catch (error) {
|
|
10726
11048
|
console.error('[WS v2] Error refreshing token:', error);
|
|
11049
|
+
// If the refresh token is permanently invalid (401/403), clear the stale
|
|
11050
|
+
// session from storage so future attempts don't keep retrying with it.
|
|
11051
|
+
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)) {
|
|
11052
|
+
try {
|
|
11053
|
+
const { WebSessionManager } = await Promise.resolve().then(function () { return webSessionManager; });
|
|
11054
|
+
WebSessionManager.clearSession();
|
|
11055
|
+
}
|
|
11056
|
+
catch (clearError) {
|
|
11057
|
+
console.warn('[WS v2] Failed to clear stale session:', clearError);
|
|
11058
|
+
}
|
|
11059
|
+
}
|
|
10727
11060
|
}
|
|
10728
11061
|
// Return null instead of the expired token to prevent infinite 401 reconnect storms.
|
|
10729
11062
|
// The server accepts unauthenticated connections; auth-required subscriptions will
|
|
@@ -10844,7 +11177,16 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10844
11177
|
ws.addEventListener('open', () => {
|
|
10845
11178
|
connection.isConnecting = false;
|
|
10846
11179
|
connection.isConnected = true;
|
|
10847
|
-
|
|
11180
|
+
// NOTE: Do NOT reset consecutiveAuthFailures here. It is reset when a
|
|
11181
|
+
// fresh auth token is actually obtained (in urlProvider, line ~389) or on
|
|
11182
|
+
// an explicit auth change (reconnectWithNewAuthV2, line ~854). Resetting
|
|
11183
|
+
// on every 'open' event created an infinite loop: auth fails 5x → connect
|
|
11184
|
+
// without auth → open resets counter → disconnect → auth fails 5x again →
|
|
11185
|
+
// repeat forever, hammering /session/refresh and causing 429s.
|
|
11186
|
+
//
|
|
11187
|
+
// An elevated counter is safe for anonymous/guest sessions: when there's no
|
|
11188
|
+
// token at all (getIdToken returns null), the counter is never checked —
|
|
11189
|
+
// urlProvider skips straight to unauthenticated connection.
|
|
10848
11190
|
// Schedule periodic token freshness checks
|
|
10849
11191
|
scheduleTokenRefresh(connection, isServer);
|
|
10850
11192
|
// Re-subscribe to all existing subscriptions after reconnect
|
|
@@ -12506,15 +12848,15 @@ function clearIncompatibleSession() {
|
|
|
12506
12848
|
// Lazy loaders for web-only providers.
|
|
12507
12849
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
12508
12850
|
async function loadPrivyWalletProvider() {
|
|
12509
|
-
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-
|
|
12851
|
+
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-DpNVyaXa.js'); });
|
|
12510
12852
|
return mod.PrivyWalletProvider;
|
|
12511
12853
|
}
|
|
12512
12854
|
async function loadPhantomWalletProvider() {
|
|
12513
|
-
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-
|
|
12855
|
+
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-Cg-srwP4.js'); });
|
|
12514
12856
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
12515
12857
|
}
|
|
12516
12858
|
async function loadSolanaMobileWalletProvider() {
|
|
12517
|
-
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-
|
|
12859
|
+
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-zXAk2tfS.js'); });
|
|
12518
12860
|
return mod.SolanaMobileWalletProvider;
|
|
12519
12861
|
}
|
|
12520
12862
|
async function hotSwapToPrivyProvider(config) {
|
|
@@ -15924,4 +16266,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
|
15924
16266
|
exports.signTransaction = signTransaction;
|
|
15925
16267
|
exports.subscribe = subscribe;
|
|
15926
16268
|
exports.useAuth = useAuth;
|
|
15927
|
-
//# sourceMappingURL=index.native-
|
|
16269
|
+
//# sourceMappingURL=index.native-DUnE51Mx.js.map
|