@pooflabs/web 0.0.79-rc.1 → 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.
Files changed (72) hide show
  1. package/dist/{index-DwU9hjtr.js → index-BNyxZ82q.js} +365 -23
  2. package/dist/index-BNyxZ82q.js.map +1 -0
  3. package/dist/{index-zS_Y-wbi.js → index-BVi7fTm2.js} +2 -2
  4. package/dist/{index-zS_Y-wbi.js.map → index-BVi7fTm2.js.map} +1 -1
  5. package/dist/{index-CiwYJvf8.esm.js → index-BbtYb8sE.esm.js} +3 -3
  6. package/dist/{index-CiwYJvf8.esm.js.map → index-BbtYb8sE.esm.js.map} +1 -1
  7. package/dist/{index-BHGEc97p.js → index-BhfNMrC0.js} +3 -3
  8. package/dist/{index-BHGEc97p.js.map → index-BhfNMrC0.js.map} +1 -1
  9. package/dist/index-CKIoDkjJ.esm.js +6 -0
  10. package/dist/index-CKIoDkjJ.esm.js.map +1 -0
  11. package/dist/{index-U-xlsKRI.esm.js → index-COIUWugk.esm.js} +2 -2
  12. package/dist/{index-U-xlsKRI.esm.js.map → index-COIUWugk.esm.js.map} +1 -1
  13. package/dist/{index-D9BY44i-.js → index-CSraUgD6.js} +2 -2
  14. package/dist/index-CSraUgD6.js.map +1 -0
  15. package/dist/{index-CsIXFm8d.esm.js → index-Db0NqU8R.esm.js} +365 -23
  16. package/dist/index-Db0NqU8R.esm.js.map +1 -0
  17. package/dist/{index.browser-Cpi4W_1r.js → index.browser-8hyi2LOX.js} +1696 -1366
  18. package/dist/index.browser-8hyi2LOX.js.map +1 -0
  19. package/dist/{index.browser-Dbq5Qf1G.esm.js → index.browser-B4zXnffD.esm.js} +81 -98
  20. package/dist/index.browser-B4zXnffD.esm.js.map +1 -0
  21. package/dist/{index.browser-Df7yN8D5.js → index.browser-BJ_TdUVA.js} +80 -97
  22. package/dist/index.browser-BJ_TdUVA.js.map +1 -0
  23. package/dist/index.browser-BkNaRRVe.js +1222 -0
  24. package/dist/index.browser-BkNaRRVe.js.map +1 -0
  25. package/dist/{index.browser-CMEwqnEe.esm.js → index.browser-BuHl80dp.esm.js} +1696 -1366
  26. package/dist/index.browser-BuHl80dp.esm.js.map +1 -0
  27. package/dist/index.browser-CnbxBj3-.esm.js +1219 -0
  28. package/dist/index.browser-CnbxBj3-.esm.js.map +1 -0
  29. package/dist/index.browser-OvGNsMPu.esm.js +1002 -0
  30. package/dist/index.browser-OvGNsMPu.esm.js.map +1 -0
  31. package/dist/index.browser-vuTr40so.js +1008 -0
  32. package/dist/index.browser-vuTr40so.js.map +1 -0
  33. package/dist/index.esm.js +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/{index.native-DtxPWD00.js → index.native-DUnE51Mx.js} +365 -23
  36. package/dist/index.native-DUnE51Mx.js.map +1 -0
  37. package/dist/{index.native-CEf5PJ_g.esm.js → index.native-DuKhZcus.esm.js} +365 -23
  38. package/dist/index.native-DuKhZcus.esm.js.map +1 -0
  39. package/dist/index.native.esm.js +1 -1
  40. package/dist/index.native.js +1 -1
  41. package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js → phantom-wallet-provider--BJjVUA1.esm.js} +4 -4
  42. package/dist/{phantom-wallet-provider-B0UmUtfB.esm.js.map → phantom-wallet-provider--BJjVUA1.esm.js.map} +1 -1
  43. package/dist/{phantom-wallet-provider-BbyQIlro.js → phantom-wallet-provider-Cg-srwP4.js} +4 -4
  44. package/dist/{phantom-wallet-provider-BbyQIlro.js.map → phantom-wallet-provider-Cg-srwP4.js.map} +1 -1
  45. package/dist/{privy-wallet-provider-DGjYglh7.esm.js → privy-wallet-provider-BLcur3Ue.esm.js} +3 -3
  46. package/dist/{privy-wallet-provider-DGjYglh7.esm.js.map → privy-wallet-provider-BLcur3Ue.esm.js.map} +1 -1
  47. package/dist/{privy-wallet-provider-CoQzq0F4.js → privy-wallet-provider-DpNVyaXa.js} +3 -3
  48. package/dist/{privy-wallet-provider-CoQzq0F4.js.map → privy-wallet-provider-DpNVyaXa.js.map} +1 -1
  49. package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js → solana-mobile-wallet-provider-CFaubssb.esm.js} +4 -4
  50. package/dist/{solana-mobile-wallet-provider-DIyP-Az5.esm.js.map → solana-mobile-wallet-provider-CFaubssb.esm.js.map} +1 -1
  51. package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js → solana-mobile-wallet-provider-zXAk2tfS.js} +4 -4
  52. package/dist/{solana-mobile-wallet-provider-BLoovRsJ.js.map → solana-mobile-wallet-provider-zXAk2tfS.js.map} +1 -1
  53. package/package.json +24 -24
  54. package/dist/index-6pNPzV1t.esm.js +0 -6
  55. package/dist/index-6pNPzV1t.esm.js.map +0 -1
  56. package/dist/index-CsIXFm8d.esm.js.map +0 -1
  57. package/dist/index-D9BY44i-.js.map +0 -1
  58. package/dist/index-DwU9hjtr.js.map +0 -1
  59. package/dist/index.browser-C-_FEr5M.esm.js +0 -1134
  60. package/dist/index.browser-C-_FEr5M.esm.js.map +0 -1
  61. package/dist/index.browser-C9bFQZyQ.esm.js +0 -1373
  62. package/dist/index.browser-C9bFQZyQ.esm.js.map +0 -1
  63. package/dist/index.browser-CMEwqnEe.esm.js.map +0 -1
  64. package/dist/index.browser-Cpi4W_1r.js.map +0 -1
  65. package/dist/index.browser-Dbq5Qf1G.esm.js.map +0 -1
  66. package/dist/index.browser-Df7yN8D5.js.map +0 -1
  67. package/dist/index.browser-DjEZSiqI.js +0 -1137
  68. package/dist/index.browser-DjEZSiqI.js.map +0 -1
  69. package/dist/index.browser-dszs5oe5.js +0 -1376
  70. package/dist/index.browser-dszs5oe5.js.map +0 -1
  71. package/dist/index.native-CEf5PJ_g.esm.js.map +0 -1
  72. 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
- 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;
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
- __proto__: null,
6620
- WebSessionManager: WebSessionManager
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
- const { value: table } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
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
- __proto__: null,
9559
- ServerSessionManager: ServerSessionManager
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 globalAxios(requestConfig);
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
- connection.consecutiveAuthFailures = 0;
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
@@ -15342,7 +15684,7 @@ async function loadDependencies() {
15342
15684
  const [reactModule, reactDomModule, phantomModule] = await Promise.all([
15343
15685
  import('react'),
15344
15686
  import('react-dom/client'),
15345
- Promise.resolve().then(function () { return require('./index-zS_Y-wbi.js'); })
15687
+ Promise.resolve().then(function () { return require('./index-BVi7fTm2.js'); })
15346
15688
  ]);
15347
15689
  // Extract default export from ESM module namespace
15348
15690
  // Dynamic import() returns { default: Module, ...exports }, not the module directly
@@ -20817,7 +21159,7 @@ async function loadMwaProtocol() {
20817
21159
  return mwaProtocolLoadPromise;
20818
21160
  mwaProtocolLoadPromise = (async () => {
20819
21161
  try {
20820
- mwaProtocolModule = await Promise.resolve().then(function () { return require('./index.browser-Df7yN8D5.js'); });
21162
+ mwaProtocolModule = await Promise.resolve().then(function () { return require('./index.browser-BJ_TdUVA.js'); });
20821
21163
  }
20822
21164
  catch (e) {
20823
21165
  console.warn('[SolanaMobileWallet] @solana-mobile/mobile-wallet-adapter-protocol-web3js not installed. Install it to enable Seeker wallet support.');
@@ -20839,7 +21181,7 @@ async function registerMobileWalletAdapter(config) {
20839
21181
  if (typeof window === 'undefined')
20840
21182
  return;
20841
21183
  try {
20842
- const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-Cpi4W_1r.js'); });
21184
+ const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-8hyi2LOX.js'); });
20843
21185
  const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
20844
21186
  if (!registerMwa) {
20845
21187
  console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
@@ -21804,4 +22146,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
21804
22146
  exports.signTransaction = signTransaction;
21805
22147
  exports.subscribe = subscribe;
21806
22148
  exports.useAuth = useAuth;
21807
- //# sourceMappingURL=index-DwU9hjtr.js.map
22149
+ //# sourceMappingURL=index-BNyxZ82q.js.map