@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.
@@ -4045,7 +4045,7 @@ class ServerSessionManager {
4045
4045
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4046
4046
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4047
4047
  const nonce = await genAuthNonce(sessionConfig);
4048
- const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-DnV4FQ__.js'); });
4048
+ const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-BecAT47y.js'); });
4049
4049
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4050
4050
  /* sign the message */
4051
4051
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -5406,6 +5406,35 @@ async function getWsAuthToken(isServer) {
5406
5406
  throw rememberAmbientAuthFailure(normalizeAuthExpiredError(error, 'Authentication expired and refresh failed'));
5407
5407
  }
5408
5408
  }
5409
+ /**
5410
+ * The server refused the token sent on the auth frame: its error frame arrives
5411
+ * while the auth ack is still pending, just before the 1008 close. Local expiry
5412
+ * had vouched for that exact token (unexpired but invalid - e.g. a rotated
5413
+ * issuer key), so re-sending it would only be refused again. Force a genuinely
5414
+ * new one: a definitive issuer rejection clears the session inside the shared
5415
+ * helper (firing notifySessionCleared, which signs the UI out), a successful
5416
+ * refresh commits a new token - and the ordinary reconnect loop picks up either
5417
+ * outcome on its own. Fresh token: authenticates. No token: connects
5418
+ * anonymously and public reads replay instead of erroring forever.
5419
+ */
5420
+ async function recoverFromServerAuthRejection(connection) {
5421
+ const rejected = connection.pendingAuthToken;
5422
+ if (!rejected)
5423
+ return;
5424
+ // One forced refresh per distinct rejected token value: a transiently
5425
+ // unreachable issuer must not turn the reconnect loop into a refresh storm.
5426
+ if (connection.serverRejectedAuthToken === rejected)
5427
+ return;
5428
+ connection.serverRejectedAuthToken = rejected;
5429
+ try {
5430
+ await getFreshAuthToken(connection.isServer, { force: true });
5431
+ }
5432
+ catch (_a) {
5433
+ // Every failure mode is already handled inside the helper: a dead
5434
+ // session was cleared (auth listeners notified), a transient refresh
5435
+ // failure keeps the session and the latch above stops the storm.
5436
+ }
5437
+ }
5409
5438
  async function getConnectionAuthToken(isServer, authTokenProvider, anonymous) {
5410
5439
  // A read-only scoped instance connects anonymously: no auth frame, and it
5411
5440
  // must never read (or refresh) the ambient global session - that session
@@ -5729,6 +5758,8 @@ async function getOrCreateConnectionOnce(appId, isServer, routePath, authTokenPr
5729
5758
  authFailure: null,
5730
5759
  source,
5731
5760
  anonymous,
5761
+ isServer,
5762
+ serverRejectedAuthToken: null,
5732
5763
  };
5733
5764
  connections.set(connKey, connection);
5734
5765
  // URL provider for reconnection with fresh tokens
@@ -5994,6 +6025,16 @@ function handleServerMessage(connection, message) {
5994
6025
  }
5995
6026
  case 'error': {
5996
6027
  console.error('[WS v2] Server error:', message.code, message.message);
6028
+ // The auth frame was just refused: while the auth ack is pending the
6029
+ // server sends no other error frame, and this one is immediately
6030
+ // followed by its 1008 close. Kick the forced-refresh recovery - the
6031
+ // ordinary reconnect loop then re-auths with a fresh token or, once a
6032
+ // definitively dead session is cleared, connects anonymously so
6033
+ // public reads still replay. Ambient connections only: wallet-scoped
6034
+ // connections refresh through their own provider.
6035
+ if (connection.isAuthenticating && connection.pendingAuthToken && !connection.authTokenProvider && !connection.anonymous) {
6036
+ void recoverFromServerAuthRejection(connection);
6037
+ }
5997
6038
  // Build an Error that ALSO carries the stable `code` as a structured
5998
6039
  // field (not just string-interpolated into the message) so callers can
5999
6040
  // branch on it — e.g. `catch (e) { if (e.code === 'invariant_violation') }`
@@ -6777,7 +6818,7 @@ async function doReconnectWithNewAuth() {
6777
6818
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
6778
6819
  }
6779
6820
  try {
6780
- const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-CkgpUOrE.js'); });
6821
+ const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-DfeKV55-.js'); });
6781
6822
  await reconnectRealtimeStoreWithNewAuth();
6782
6823
  }
6783
6824
  catch (error) {
@@ -8220,7 +8261,7 @@ async function setMany(many, options) {
8220
8261
  'Nothing was signed or submitted.');
8221
8262
  }
8222
8263
  const solanaChain = workerChain;
8223
- const { handlePreBuiltTransaction } = await Promise.resolve().then(function () { return require('./solana-operations-DPul1dWo.js'); });
8264
+ const { handlePreBuiltTransaction } = await Promise.resolve().then(function () { return require('./solana-operations-uN89eqO2.js'); });
8224
8265
  const solanaOutcome = await handlePreBuiltTransaction(curTx, authProvider, options, expectedWritePaths);
8225
8266
  // `shouldSubmitTx: false` signed WITHOUT sending — no signature exists,
8226
8267
  // and there is nothing to mirror, so no synchronization is attempted.
@@ -9661,7 +9702,7 @@ function toMillis(seconds) {
9661
9702
 
9662
9703
  /** SIWS message creation is async already, so its onchain module can be lazy. */
9663
9704
  async function genSolanaMessage(address, nonce) {
9664
- const implementation = await Promise.resolve().then(function () { return require('./solana-message-DnV4FQ__.js'); });
9705
+ const implementation = await Promise.resolve().then(function () { return require('./solana-message-BecAT47y.js'); });
9665
9706
  return implementation.genSolanaMessage(address, nonce);
9666
9707
  }
9667
9708
 
@@ -10222,4 +10263,4 @@ exports.toMillis = toMillis;
10222
10263
  exports.toSeconds = toSeconds;
10223
10264
  exports.waitForSetResult = waitForSetResult;
10224
10265
  exports.withEffects = withEffects;
10225
- //# sourceMappingURL=index-DlJKTmRv.js.map
10266
+ //# sourceMappingURL=index-CqTl6vHg.js.map