@bounded-sh/core 0.0.69 → 0.0.70

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.
@@ -4043,7 +4043,7 @@ class ServerSessionManager {
4043
4043
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4044
4044
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4045
4045
  const nonce = await genAuthNonce(sessionConfig);
4046
- const { genSolanaMessage } = await import('./solana-message-AXfv2U1S.mjs');
4046
+ const { genSolanaMessage } = await import('./solana-message-BFqre_Oi.mjs');
4047
4047
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4048
4048
  /* sign the message */
4049
4049
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -5404,6 +5404,35 @@ async function getWsAuthToken(isServer) {
5404
5404
  throw rememberAmbientAuthFailure(normalizeAuthExpiredError(error, 'Authentication expired and refresh failed'));
5405
5405
  }
5406
5406
  }
5407
+ /**
5408
+ * The server refused the token sent on the auth frame: its error frame arrives
5409
+ * while the auth ack is still pending, just before the 1008 close. Local expiry
5410
+ * had vouched for that exact token (unexpired but invalid - e.g. a rotated
5411
+ * issuer key), so re-sending it would only be refused again. Force a genuinely
5412
+ * new one: a definitive issuer rejection clears the session inside the shared
5413
+ * helper (firing notifySessionCleared, which signs the UI out), a successful
5414
+ * refresh commits a new token - and the ordinary reconnect loop picks up either
5415
+ * outcome on its own. Fresh token: authenticates. No token: connects
5416
+ * anonymously and public reads replay instead of erroring forever.
5417
+ */
5418
+ async function recoverFromServerAuthRejection(connection) {
5419
+ const rejected = connection.pendingAuthToken;
5420
+ if (!rejected)
5421
+ return;
5422
+ // One forced refresh per distinct rejected token value: a transiently
5423
+ // unreachable issuer must not turn the reconnect loop into a refresh storm.
5424
+ if (connection.serverRejectedAuthToken === rejected)
5425
+ return;
5426
+ connection.serverRejectedAuthToken = rejected;
5427
+ try {
5428
+ await getFreshAuthToken(connection.isServer, { force: true });
5429
+ }
5430
+ catch (_a) {
5431
+ // Every failure mode is already handled inside the helper: a dead
5432
+ // session was cleared (auth listeners notified), a transient refresh
5433
+ // failure keeps the session and the latch above stops the storm.
5434
+ }
5435
+ }
5407
5436
  async function getConnectionAuthToken(isServer, authTokenProvider, anonymous) {
5408
5437
  // A read-only scoped instance connects anonymously: no auth frame, and it
5409
5438
  // must never read (or refresh) the ambient global session - that session
@@ -5727,6 +5756,8 @@ async function getOrCreateConnectionOnce(appId, isServer, routePath, authTokenPr
5727
5756
  authFailure: null,
5728
5757
  source,
5729
5758
  anonymous,
5759
+ isServer,
5760
+ serverRejectedAuthToken: null,
5730
5761
  };
5731
5762
  connections.set(connKey, connection);
5732
5763
  // URL provider for reconnection with fresh tokens
@@ -5992,6 +6023,16 @@ function handleServerMessage(connection, message) {
5992
6023
  }
5993
6024
  case 'error': {
5994
6025
  console.error('[WS v2] Server error:', message.code, message.message);
6026
+ // The auth frame was just refused: while the auth ack is pending the
6027
+ // server sends no other error frame, and this one is immediately
6028
+ // followed by its 1008 close. Kick the forced-refresh recovery - the
6029
+ // ordinary reconnect loop then re-auths with a fresh token or, once a
6030
+ // definitively dead session is cleared, connects anonymously so
6031
+ // public reads still replay. Ambient connections only: wallet-scoped
6032
+ // connections refresh through their own provider.
6033
+ if (connection.isAuthenticating && connection.pendingAuthToken && !connection.authTokenProvider && !connection.anonymous) {
6034
+ void recoverFromServerAuthRejection(connection);
6035
+ }
5995
6036
  // Build an Error that ALSO carries the stable `code` as a structured
5996
6037
  // field (not just string-interpolated into the message) so callers can
5997
6038
  // branch on it — e.g. `catch (e) { if (e.code === 'invariant_violation') }`
@@ -6775,7 +6816,7 @@ async function doReconnectWithNewAuth() {
6775
6816
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
6776
6817
  }
6777
6818
  try {
6778
- const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-i8pxSuZE.mjs');
6819
+ const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-ByP5wYsa.mjs');
6779
6820
  await reconnectRealtimeStoreWithNewAuth();
6780
6821
  }
6781
6822
  catch (error) {
@@ -8218,7 +8259,7 @@ async function setMany(many, options) {
8218
8259
  'Nothing was signed or submitted.');
8219
8260
  }
8220
8261
  const solanaChain = workerChain;
8221
- const { handlePreBuiltTransaction } = await import('./solana-operations-Bte92rmq.mjs');
8262
+ const { handlePreBuiltTransaction } = await import('./solana-operations-ByMDnjog.mjs');
8222
8263
  const solanaOutcome = await handlePreBuiltTransaction(curTx, authProvider, options, expectedWritePaths);
8223
8264
  // `shouldSubmitTx: false` signed WITHOUT sending — no signature exists,
8224
8265
  // and there is nothing to mirror, so no synchronization is attempted.
@@ -9659,7 +9700,7 @@ function toMillis(seconds) {
9659
9700
 
9660
9701
  /** SIWS message creation is async already, so its onchain module can be lazy. */
9661
9702
  async function genSolanaMessage(address, nonce) {
9662
- const implementation = await import('./solana-message-AXfv2U1S.mjs');
9703
+ const implementation = await import('./solana-message-BFqre_Oi.mjs');
9663
9704
  return implementation.genSolanaMessage(address, nonce);
9664
9705
  }
9665
9706
 
@@ -10135,4 +10176,4 @@ function defineLiveModule(mod) {
10135
10176
  }
10136
10177
 
10137
10178
  export { getSessionGeneration as $, closeAllSubscriptions as A, clearCache as B, getCachedData as C, reconnectWithNewAuth as D, createClient as E, subscribeQuery as F, closeAllQuerySubscriptions as G, canonicalizeArgs as H, InsufficientBalanceError as I, canonicalizeResult as J, DEFAULT_QUERY_POLL_INTERVAL_MS as K, BoundedDeclineError as L, MIN_QUERY_POLL_INTERVAL_MS as M, deriveDecline as N, dispatchDeclineEvent as O, DECLINE_EVENT_NAME as P, dispatchRateLimitEvent as Q, RATE_LIMIT_EVENT_NAME as R, ScopedClientReadOnlyError as S, hasActiveConnection as T, increment as U, serverTimestamp as V, now as W, toSeconds as X, toMillis as Y, getIdToken as Z, deriveUserIdentityFromIdToken as _, getWebhookKeysUrl as a, WebSessionManager as a0, ReactNativeSessionManager as a1, getActiveSessionManager as a2, onSessionCleared as a3, SessionEnvironmentError as a4, UNSUPPORTED_ENVIRONMENT_CODE as a5, AUTH_CHANGED_CODE as a6, AUTH_EXPIRED_CODE as a7, isAuthExpiredError as a8, getFreshAuthToken as a9, ServerSessionManager as aa, createSessionWithSignature as ab, refreshSession as ac, revokeSession as ad, signSessionCreateMessage as ae, genAuthNonce as af, genSolanaMessage as ag, genSiweMessage as ah, normalizeEvmAddress as ai, toLowerEvmAddress as aj, functions as ak, invoke as al, FunctionInvokeError as am, live as an, intent as ao, status as ap, subscribeView as aq, LiveIntentError as ar, withEffects as as, isEffectResult as at, defineLiveModule as au, EFFECT_INTENT_ADDRESS as av, bufferExports as b, getConfiguredAppId as c, get as d, getMany as e, docId as f, getConfig as g, setMany as h, init as i, setFile as j, getFiles as k, search as l, runQueryMany as m, runExpression as n, runExpressionMany as o, signMessage as p, queryAggregate as q, runQuery as r, set as s, signTransaction as t, signAndSubmitTransaction as u, count as v, aggregate as w, reconcileSetResult as x, waitForSetResult as y, subscribe as z };
10138
- //# sourceMappingURL=index-B3aNfGi6.mjs.map
10179
+ //# sourceMappingURL=index-Csf_2uZF.mjs.map