@pooflabs/web 0.0.76 → 0.0.78

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 (66) hide show
  1. package/README.md +32 -0
  2. package/dist/{index-COMIXUxl.js → index-CKaaE12K.js} +2 -2
  3. package/dist/{index-COMIXUxl.js.map → index-CKaaE12K.js.map} +1 -1
  4. package/dist/{index-Dsh0H37n.esm.js → index-Cmu0PVJD.esm.js} +2 -2
  5. package/dist/{index-Dsh0H37n.esm.js.map → index-Cmu0PVJD.esm.js.map} +1 -1
  6. package/dist/{index-BrlvWT1Q.js → index-Cp727oEW.js} +450 -23
  7. package/dist/index-Cp727oEW.js.map +1 -0
  8. package/dist/{index-C5Cnn7Hq.esm.js → index-CwGoYY0Y.esm.js} +450 -24
  9. package/dist/index-CwGoYY0Y.esm.js.map +1 -0
  10. package/dist/{index-BilNgDSc.js → index-DE7k2G22.js} +2 -2
  11. package/dist/{index-BilNgDSc.js.map → index-DE7k2G22.js.map} +1 -1
  12. package/dist/{index-DeVykeX4.esm.js → index-OAJ0rndN.esm.js} +2 -2
  13. package/dist/{index-DeVykeX4.esm.js.map → index-OAJ0rndN.esm.js.map} +1 -1
  14. package/dist/{index.browser-CMO2pjaF.js → index.browser-AZQ5TnZ4.js} +3 -3
  15. package/dist/{index.browser-CMO2pjaF.js.map → index.browser-AZQ5TnZ4.js.map} +1 -1
  16. package/dist/{index.browser-CSTWylhG.esm.js → index.browser-B4een3Gz.esm.js} +3 -3
  17. package/dist/{index.browser-CSTWylhG.esm.js.map → index.browser-B4een3Gz.esm.js.map} +1 -1
  18. package/dist/index.browser-BMtEulGJ.js +122 -0
  19. package/dist/index.browser-BMtEulGJ.js.map +1 -0
  20. package/dist/{index.browser-DZjyUgtx.esm.js → index.browser-C-_FEr5M.esm.js} +449 -479
  21. package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
  22. package/dist/index.browser-DFeGGyO7.esm.js +1250 -0
  23. package/dist/index.browser-DFeGGyO7.esm.js.map +1 -0
  24. package/dist/{index.browser-BOJRGZWX.js → index.browser-DjEZSiqI.js} +449 -479
  25. package/dist/index.browser-DjEZSiqI.js.map +1 -0
  26. package/dist/index.browser-QPkAiPQp.js +1253 -0
  27. package/dist/index.browser-QPkAiPQp.js.map +1 -0
  28. package/dist/index.browser-x87QUr4N.esm.js +119 -0
  29. package/dist/index.browser-x87QUr4N.esm.js.map +1 -0
  30. package/dist/index.esm.js +1 -1
  31. package/dist/index.js +2 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/{index.native-H-fEcP_L.esm.js → index.native-CjEJXA9y.esm.js} +450 -24
  34. package/dist/index.native-CjEJXA9y.esm.js.map +1 -0
  35. package/dist/{index.native-CkUXrvPQ.js → index.native-D7IrIMX1.js} +450 -23
  36. package/dist/index.native-D7IrIMX1.js.map +1 -0
  37. package/dist/index.native.esm.js +1 -1
  38. package/dist/index.native.js +2 -1
  39. package/dist/index.native.js.map +1 -1
  40. package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js → phantom-wallet-provider-B1TleWsy.esm.js} +3 -3
  41. package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js.map → phantom-wallet-provider-B1TleWsy.esm.js.map} +1 -1
  42. package/dist/{phantom-wallet-provider-DrNrxSUL.js → phantom-wallet-provider-DwmdHVd-.js} +3 -3
  43. package/dist/{phantom-wallet-provider-DrNrxSUL.js.map → phantom-wallet-provider-DwmdHVd-.js.map} +1 -1
  44. package/dist/{privy-wallet-provider-BtLH1dpY.esm.js → privy-wallet-provider-CZgiUwUN.esm.js} +3 -3
  45. package/dist/{privy-wallet-provider-BtLH1dpY.esm.js.map → privy-wallet-provider-CZgiUwUN.esm.js.map} +1 -1
  46. package/dist/{privy-wallet-provider-CrRfcONv.js → privy-wallet-provider-Cf6WgpK1.js} +3 -3
  47. package/dist/{privy-wallet-provider-CrRfcONv.js.map → privy-wallet-provider-Cf6WgpK1.js.map} +1 -1
  48. package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js → solana-mobile-wallet-provider-C9j8O3mD.esm.js} +3 -3
  49. package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js.map → solana-mobile-wallet-provider-C9j8O3mD.esm.js.map} +1 -1
  50. package/dist/{solana-mobile-wallet-provider-QcGazewW.js → solana-mobile-wallet-provider-DZmpeNIS.js} +3 -3
  51. package/dist/{solana-mobile-wallet-provider-QcGazewW.js.map → solana-mobile-wallet-provider-DZmpeNIS.js.map} +1 -1
  52. package/package.json +2 -2
  53. package/dist/index-BrlvWT1Q.js.map +0 -1
  54. package/dist/index-C5Cnn7Hq.esm.js.map +0 -1
  55. package/dist/index.browser--rDwfvXH.esm.js +0 -307
  56. package/dist/index.browser--rDwfvXH.esm.js.map +0 -1
  57. package/dist/index.browser-BOJRGZWX.js.map +0 -1
  58. package/dist/index.browser-CLZv9v_y.js +0 -310
  59. package/dist/index.browser-CLZv9v_y.js.map +0 -1
  60. package/dist/index.browser-DQKnuR3q.esm.js +0 -1468
  61. package/dist/index.browser-DQKnuR3q.esm.js.map +0 -1
  62. package/dist/index.browser-DZjyUgtx.esm.js.map +0 -1
  63. package/dist/index.browser-DqO3G-HJ.js +0 -1471
  64. package/dist/index.browser-DqO3G-HJ.js.map +0 -1
  65. package/dist/index.native-CkUXrvPQ.js.map +0 -1
  66. package/dist/index.native-H-fEcP_L.esm.js.map +0 -1
@@ -6400,6 +6400,261 @@ var ReconnectingWebSocket = /** @class */ (function () {
6400
6400
  return ReconnectingWebSocket;
6401
6401
  }());
6402
6402
 
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
+
6403
6658
  let axiosClient;
6404
6659
  async function getAxiosAuthClient() {
6405
6660
  if (!axiosClient) {
@@ -6409,6 +6664,7 @@ async function getAxiosAuthClient() {
6409
6664
  headers: {
6410
6665
  'Content-Type': 'application/json',
6411
6666
  },
6667
+ timeout: 30000, // 30s timeout, matching makeApiRequest
6412
6668
  });
6413
6669
  }
6414
6670
  return axiosClient;
@@ -6455,15 +6711,41 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
6455
6711
  });
6456
6712
  return response.data;
6457
6713
  }
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;
6458
6722
  async function refreshSession(refreshToken) {
6459
- const client = await getAxiosAuthClient();
6460
- const config = await getConfig();
6461
- const appId = config.appId;
6462
- const response = await client.post('/session/refresh', {
6463
- refreshToken,
6464
- appId
6465
- });
6466
- return response.data;
6723
+ if (refreshInFlight$1 && refreshInFlightToken === refreshToken) {
6724
+ return refreshInFlight$1;
6725
+ }
6726
+ refreshInFlightToken = refreshToken;
6727
+ let currentFlight;
6728
+ currentFlight = refreshInFlight$1 = (async () => {
6729
+ try {
6730
+ const client = await getAxiosAuthClient();
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;
6467
6749
  }
6468
6750
  async function signSessionCreateMessage(_signMessageFunction) {
6469
6751
  }
@@ -6601,14 +6883,10 @@ class WebSessionManager {
6601
6883
  WebSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
6602
6884
 
6603
6885
  var webSessionManager = /*#__PURE__*/Object.freeze({
6604
- __proto__: null,
6605
- WebSessionManager: WebSessionManager
6886
+ __proto__: null,
6887
+ WebSessionManager: WebSessionManager
6606
6888
  });
6607
6889
 
6608
- function getDefaultExportFromCjs (x) {
6609
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6610
- }
6611
-
6612
6890
  var buffer = {};
6613
6891
 
6614
6892
  var base64Js = {};
@@ -9405,7 +9683,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
9405
9683
  }
9406
9684
  }
9407
9685
  else if (lutKey != null) {
9408
- const { value: table } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
9686
+ // The LUT may have just been created server-side and the client's RPC node
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
+ }
9409
9699
  if (!table)
9410
9700
  throw new Error('LUT not found after creation/extend');
9411
9701
  lookupTables.push(table);
@@ -9540,8 +9830,8 @@ class ServerSessionManager {
9540
9830
  ServerSessionManager.instance = new ServerSessionManager();
9541
9831
 
9542
9832
  var serverSessionManager = /*#__PURE__*/Object.freeze({
9543
- __proto__: null,
9544
- ServerSessionManager: ServerSessionManager
9833
+ __proto__: null,
9834
+ ServerSessionManager: ServerSessionManager
9545
9835
  });
9546
9836
 
9547
9837
  /**
@@ -9640,6 +9930,23 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
9640
9930
  await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
9641
9931
  }
9642
9932
 
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
+ });
9643
9950
  const refreshInFlight = new Map();
9644
9951
  async function refreshAuthSessionOnce(appId, isServer) {
9645
9952
  const key = `${isServer ? "server" : "web"}:${appId}`;
@@ -9686,6 +9993,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
9686
9993
  ServerSessionManager.instance.clearSession();
9687
9994
  };
9688
9995
  async function executeRequest() {
9996
+ var _a;
9689
9997
  // When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
9690
9998
  // Otherwise use the global createAuthHeader (default path).
9691
9999
  const authHeader = (_overrides === null || _overrides === void 0 ? void 0 : _overrides._getAuthHeaders)
@@ -9707,11 +10015,12 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
9707
10015
  method,
9708
10016
  url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
9709
10017
  headers,
10018
+ timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : 30000,
9710
10019
  };
9711
10020
  if (method !== "GET" && method !== "get") {
9712
10021
  requestConfig.data = data ? JSON.stringify(data) : {};
9713
10022
  }
9714
- const response = await globalAxios(requestConfig);
10023
+ const response = await apiClient(requestConfig);
9715
10024
  return { data: response.data, status: response.status, headers: response.headers };
9716
10025
  }
9717
10026
  try {
@@ -10122,6 +10431,90 @@ function cleanupExpiredCache() {
10122
10431
  });
10123
10432
  lastCacheCleanup = now;
10124
10433
  }
10434
+ async function getMany(paths, opts = {}) {
10435
+ if (paths.length === 0) {
10436
+ return [];
10437
+ }
10438
+ if (paths.length > 30) {
10439
+ throw new Error('Cannot fetch more than 30 documents at once');
10440
+ }
10441
+ const normalizedPaths = [];
10442
+ for (const path of paths) {
10443
+ let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
10444
+ if (normalizedPath.endsWith("*") && normalizedPath.length > 1) {
10445
+ normalizedPath = normalizedPath.slice(0, -1);
10446
+ }
10447
+ if (!normalizedPath || normalizedPath.length === 0) {
10448
+ throw new Error(`Invalid path provided: ${path}`);
10449
+ }
10450
+ const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
10451
+ if (!pathIsDocument) {
10452
+ throw new Error(`Path must point to a document (even number of segments): ${path}`);
10453
+ }
10454
+ normalizedPaths.push(normalizedPath);
10455
+ }
10456
+ const now = Date.now();
10457
+ const results = new Array(paths.length);
10458
+ const uncachedIndices = [];
10459
+ const uncachedPaths = [];
10460
+ for (let i = 0; i < normalizedPaths.length; i++) {
10461
+ const normalizedPath = normalizedPaths[i];
10462
+ const cacheKey = `${normalizedPath}:`;
10463
+ if (!opts.bypassCache && getCache[cacheKey] && now < getCache[cacheKey].expiresAt) {
10464
+ results[i] = { path: normalizedPath, data: getCache[cacheKey].data };
10465
+ }
10466
+ else {
10467
+ uncachedIndices.push(i);
10468
+ uncachedPaths.push(normalizedPath);
10469
+ }
10470
+ }
10471
+ if (uncachedPaths.length > 0) {
10472
+ try {
10473
+ const response = await makeApiRequest('POST', 'items/batch', { paths: uncachedPaths }, opts._overrides);
10474
+ const serverResults = response.data.results;
10475
+ const serverResultsMap = new Map();
10476
+ for (const result of serverResults) {
10477
+ serverResultsMap.set(result.path, result);
10478
+ }
10479
+ for (let i = 0; i < uncachedIndices.length; i++) {
10480
+ const originalIndex = uncachedIndices[i];
10481
+ const normalizedPath = uncachedPaths[i];
10482
+ const serverResult = serverResultsMap.get(normalizedPath);
10483
+ if (serverResult) {
10484
+ results[originalIndex] = serverResult;
10485
+ if (!serverResult.error && !opts.bypassCache) {
10486
+ const cacheKey = `${normalizedPath}:`;
10487
+ getCache[cacheKey] = {
10488
+ data: serverResult.data,
10489
+ expiresAt: now + GET_CACHE_TTL
10490
+ };
10491
+ }
10492
+ }
10493
+ else {
10494
+ results[originalIndex] = {
10495
+ path: normalizedPath,
10496
+ data: null,
10497
+ error: { code: 'NOT_FOUND', message: `No result returned for path ${normalizedPath}` }
10498
+ };
10499
+ }
10500
+ }
10501
+ if (now - lastCacheCleanup > 5000) {
10502
+ cleanupExpiredCache();
10503
+ lastCacheCleanup = now;
10504
+ }
10505
+ }
10506
+ catch (error) {
10507
+ for (const originalIndex of uncachedIndices) {
10508
+ results[originalIndex] = {
10509
+ path: normalizedPaths[originalIndex],
10510
+ data: null,
10511
+ error: { code: 'NOT_FOUND', message: error instanceof Error ? error.message : 'Unknown error' }
10512
+ };
10513
+ }
10514
+ }
10515
+ }
10516
+ return results;
10517
+ }
10125
10518
  async function runQuery(absolutePath, queryName, queryArgs, opts) {
10126
10519
  const result = await runQueryMany([{ absolutePath, queryName, queryArgs }], opts);
10127
10520
  return result[0];
@@ -10563,6 +10956,7 @@ function scheduleTokenRefresh(connection, isServer) {
10563
10956
  // This replaces the old single setTimeout approach which was unreliable for long
10564
10957
  // delays (browsers throttle/suspend timers in background tabs).
10565
10958
  connection.tokenRefreshTimer = setInterval(async () => {
10959
+ var _a, _b;
10566
10960
  try {
10567
10961
  const currentToken = await getIdToken$1(isServer);
10568
10962
  if (!currentToken)
@@ -10593,6 +10987,17 @@ function scheduleTokenRefresh(connection, isServer) {
10593
10987
  }
10594
10988
  }
10595
10989
  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
+ }
10596
11001
  console.warn('[WS v2] Proactive token refresh failed, will retry next interval:', refreshError);
10597
11002
  }
10598
11003
  }
@@ -10603,6 +11008,7 @@ function scheduleTokenRefresh(connection, isServer) {
10603
11008
  }, TOKEN_CHECK_INTERVAL);
10604
11009
  }
10605
11010
  async function getFreshAuthToken(isServer) {
11011
+ var _a, _b;
10606
11012
  const currentToken = await getIdToken$1(isServer);
10607
11013
  if (!currentToken) {
10608
11014
  return null;
@@ -10625,6 +11031,17 @@ async function getFreshAuthToken(isServer) {
10625
11031
  }
10626
11032
  catch (error) {
10627
11033
  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
+ }
10628
11045
  }
10629
11046
  // Return null instead of the expired token to prevent infinite 401 reconnect storms.
10630
11047
  // The server accepts unauthenticated connections; auth-required subscriptions will
@@ -10745,7 +11162,16 @@ async function getOrCreateConnection(appId, isServer) {
10745
11162
  ws.addEventListener('open', () => {
10746
11163
  connection.isConnecting = false;
10747
11164
  connection.isConnected = true;
10748
- connection.consecutiveAuthFailures = 0;
11165
+ // NOTE: Do NOT reset consecutiveAuthFailures here. It is reset when a
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.
10749
11175
  // Schedule periodic token freshness checks
10750
11176
  scheduleTokenRefresh(connection, isServer);
10751
11177
  // Re-subscribe to all existing subscriptions after reconnect
@@ -12407,15 +12833,15 @@ function clearIncompatibleSession() {
12407
12833
  // Lazy loaders for web-only providers.
12408
12834
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
12409
12835
  async function loadPrivyWalletProvider() {
12410
- const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-CrRfcONv.js'); });
12836
+ const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-Cf6WgpK1.js'); });
12411
12837
  return mod.PrivyWalletProvider;
12412
12838
  }
12413
12839
  async function loadPhantomWalletProvider() {
12414
- const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-DrNrxSUL.js'); });
12840
+ const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-DwmdHVd-.js'); });
12415
12841
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
12416
12842
  }
12417
12843
  async function loadSolanaMobileWalletProvider() {
12418
- const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-QcGazewW.js'); });
12844
+ const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-DZmpeNIS.js'); });
12419
12845
  return mod.SolanaMobileWalletProvider;
12420
12846
  }
12421
12847
  async function hotSwapToPrivyProvider(config) {
@@ -13331,6 +13757,7 @@ exports.getCurrentUser = getCurrentUser;
13331
13757
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs$1;
13332
13758
  exports.getFiles = getFiles;
13333
13759
  exports.getIdToken = getIdToken;
13760
+ exports.getMany = getMany;
13334
13761
  exports.getPlatform = getPlatform;
13335
13762
  exports.index = index;
13336
13763
  exports.init = init;
@@ -13356,4 +13783,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
13356
13783
  exports.signTransaction = signTransaction;
13357
13784
  exports.subscribe = subscribe;
13358
13785
  exports.useAuth = useAuth;
13359
- //# sourceMappingURL=index.native-CkUXrvPQ.js.map
13786
+ //# sourceMappingURL=index.native-D7IrIMX1.js.map