@bounded-sh/core 0.0.67 → 0.0.68

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 (23) hide show
  1. package/dist/client/subscribe-query.d.ts +12 -1
  2. package/dist/{index-TyXiW4Uf.mjs → index-C9h-Bnjk.mjs} +50 -11
  3. package/dist/{index-TyXiW4Uf.mjs.map → index-C9h-Bnjk.mjs.map} +1 -1
  4. package/dist/{index-DNZifL5j.js → index-C9w7qQpj.js} +51 -10
  5. package/dist/{index-DNZifL5j.js.map → index-C9w7qQpj.js.map} +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +3 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/{realtime-store-CpbnXM7q.mjs → realtime-store-B_Szs6F3.mjs} +2 -2
  11. package/dist/{realtime-store-CpbnXM7q.mjs.map → realtime-store-B_Szs6F3.mjs.map} +1 -1
  12. package/dist/{realtime-store-CINyAkPw.js → realtime-store-CQiij3zc.js} +2 -2
  13. package/dist/{realtime-store-CINyAkPw.js.map → realtime-store-CQiij3zc.js.map} +1 -1
  14. package/dist/{solana-message-Bycv-L5n.js → solana-message-DibkzgkZ.js} +2 -2
  15. package/dist/{solana-message-Bycv-L5n.js.map → solana-message-DibkzgkZ.js.map} +1 -1
  16. package/dist/{solana-message-DXXwC95Z.mjs → solana-message-ngQQt80s.mjs} +2 -2
  17. package/dist/{solana-message-DXXwC95Z.mjs.map → solana-message-ngQQt80s.mjs.map} +1 -1
  18. package/dist/{solana-operations-ChHG25O0.mjs → solana-operations-B0Q9UOHR.mjs} +2 -2
  19. package/dist/{solana-operations-ChHG25O0.mjs.map → solana-operations-B0Q9UOHR.mjs.map} +1 -1
  20. package/dist/{solana-operations-Dm_4VnlB.js → solana-operations-XjBhPOnu.js} +2 -2
  21. package/dist/{solana-operations-Dm_4VnlB.js.map → solana-operations-XjBhPOnu.js.map} +1 -1
  22. package/dist/types.d.ts +7 -4
  23. package/package.json +2 -2
@@ -45,7 +45,18 @@ type ResolvedIdentity = {
45
45
  bucket: string;
46
46
  token: string | null;
47
47
  };
48
- /** Deterministic key-sorted serialization of query args. */
48
+ /**
49
+ * Deterministic key-sorted serialization of query args, canonicalizing the EXACT
50
+ * JSON wire representation the request serializer sends. Args are first projected
51
+ * through `JSON.parse(JSON.stringify(...))` so `toJSON` runs (a `Date` becomes its
52
+ * ISO string, not `{}`) and functions/`undefined` are dropped exactly as the wire
53
+ * does, then key-sorted with null-prototype objects so an own `__proto__` key
54
+ * round-trips as a property. This makes the dedupe key match what the server
55
+ * actually receives, so two subscriptions can share a poller only when their wire
56
+ * inputs are identical. Cyclic structures and other values the wire cannot
57
+ * serialize (e.g. `BigInt`) are rejected by `JSON.stringify` here, exactly as they
58
+ * would be on the wire.
59
+ */
49
60
  export declare function canonicalizeArgs(args: any): string;
50
61
  /**
51
62
  * Deterministic key-sorted serialization of a query RESULT for change detection.
@@ -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-DXXwC95Z.mjs');
4046
+ const { genSolanaMessage } = await import('./solana-message-ngQQt80s.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);
@@ -6775,7 +6775,7 @@ async function doReconnectWithNewAuth() {
6775
6775
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
6776
6776
  }
6777
6777
  try {
6778
- const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-CpbnXM7q.mjs');
6778
+ const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-B_Szs6F3.mjs');
6779
6779
  await reconnectRealtimeStoreWithNewAuth();
6780
6780
  }
6781
6781
  catch (error) {
@@ -8717,7 +8717,7 @@ async function setMany(many, options) {
8717
8717
  'Nothing was signed or submitted.');
8718
8718
  }
8719
8719
  const solanaChain = workerChain;
8720
- const { handlePreBuiltTransaction } = await import('./solana-operations-ChHG25O0.mjs');
8720
+ const { handlePreBuiltTransaction } = await import('./solana-operations-B0Q9UOHR.mjs');
8721
8721
  const solanaOutcome = await handlePreBuiltTransaction(curTx, authProvider, options, expectedWritePaths);
8722
8722
  // `shouldSubmitTx: false` signed WITHOUT sending — no signature exists,
8723
8723
  // and there is nothing to mirror, so no synchronization is attempted.
@@ -9615,9 +9615,40 @@ function sortDeep(value) {
9615
9615
  }
9616
9616
  return value;
9617
9617
  }
9618
- /** Deterministic key-sorted serialization of query args. */
9618
+ /**
9619
+ * Key-sorted deep copy that mirrors the JSON wire form byte-for-byte. Unlike
9620
+ * `sortDeep`, it assigns into NULL-PROTOTYPE objects so an own `__proto__` key is
9621
+ * kept as an ordinary JSON property instead of being swallowed by
9622
+ * `Object.prototype`'s `__proto__` setter (which would mutate the prototype and
9623
+ * drop the property, diverging from what `JSON.stringify` actually emits).
9624
+ */
9625
+ function sortDeepWire(value) {
9626
+ if (Array.isArray(value))
9627
+ return value.map(sortDeepWire);
9628
+ if (value && typeof value === 'object') {
9629
+ const out = Object.create(null);
9630
+ for (const k of Object.keys(value).sort())
9631
+ out[k] = sortDeepWire(value[k]);
9632
+ return out;
9633
+ }
9634
+ return value;
9635
+ }
9636
+ /**
9637
+ * Deterministic key-sorted serialization of query args, canonicalizing the EXACT
9638
+ * JSON wire representation the request serializer sends. Args are first projected
9639
+ * through `JSON.parse(JSON.stringify(...))` so `toJSON` runs (a `Date` becomes its
9640
+ * ISO string, not `{}`) and functions/`undefined` are dropped exactly as the wire
9641
+ * does, then key-sorted with null-prototype objects so an own `__proto__` key
9642
+ * round-trips as a property. This makes the dedupe key match what the server
9643
+ * actually receives, so two subscriptions can share a poller only when their wire
9644
+ * inputs are identical. Cyclic structures and other values the wire cannot
9645
+ * serialize (e.g. `BigInt`) are rejected by `JSON.stringify` here, exactly as they
9646
+ * would be on the wire.
9647
+ */
9619
9648
  function canonicalizeArgs(args) {
9620
- return JSON.stringify(sortDeep(args !== null && args !== void 0 ? args : null));
9649
+ var _a;
9650
+ const wire = JSON.parse((_a = JSON.stringify(args !== null && args !== void 0 ? args : null)) !== null && _a !== void 0 ? _a : 'null');
9651
+ return JSON.stringify(sortDeepWire(wire));
9621
9652
  }
9622
9653
  /**
9623
9654
  * Deterministic key-sorted serialization of a query RESULT for change detection.
@@ -10221,7 +10252,7 @@ function toMillis(seconds) {
10221
10252
 
10222
10253
  /** SIWS message creation is async already, so its onchain module can be lazy. */
10223
10254
  async function genSolanaMessage(address, nonce) {
10224
- const implementation = await import('./solana-message-DXXwC95Z.mjs');
10255
+ const implementation = await import('./solana-message-ngQQt80s.mjs');
10225
10256
  return implementation.genSolanaMessage(address, nonce);
10226
10257
  }
10227
10258
 
@@ -10291,7 +10322,14 @@ async function invoke(name, args = {}, opts = {}) {
10291
10322
  const controller = new AbortController();
10292
10323
  const timeoutMs = (_e = opts.timeoutMs) !== null && _e !== void 0 ? _e : 60000;
10293
10324
  const timer = setTimeout(() => controller.abort(), timeoutMs);
10325
+ // `fetch` resolves as soon as the response HEADERS arrive, not when the body
10326
+ // has been received, so the abort timer must stay armed across `res.text()`
10327
+ // too. Clearing it in a `finally` that covers both the fetch AND the body read
10328
+ // means a dispatcher/network that returns headers then stalls (or drip-feeds)
10329
+ // the body is torn down at `timeoutMs` instead of leaving `invoke` pending
10330
+ // forever and accumulating open connections (DS3-0432).
10294
10331
  let res;
10332
+ let text;
10295
10333
  try {
10296
10334
  res = await fetch(`${base}/invoke`, {
10297
10335
  method: 'POST',
@@ -10299,17 +10337,18 @@ async function invoke(name, args = {}, opts = {}) {
10299
10337
  body: JSON.stringify({ appId: config.appId, functionName: name, args }),
10300
10338
  signal: controller.signal,
10301
10339
  });
10340
+ text = await res.text();
10302
10341
  }
10303
10342
  catch (err) {
10304
- clearTimeout(timer);
10305
10343
  if ((err === null || err === void 0 ? void 0 : err.name) === 'AbortError') {
10306
10344
  throw new FunctionInvokeError(`Function "${name}" invocation timed out after ${timeoutMs}ms`);
10307
10345
  }
10308
10346
  throw new FunctionInvokeError(`Failed to reach the functions dispatcher: ${(_f = err === null || err === void 0 ? void 0 : err.message) !== null && _f !== void 0 ? _f : String(err)}`);
10309
10347
  }
10310
- clearTimeout(timer);
10348
+ finally {
10349
+ clearTimeout(timer);
10350
+ }
10311
10351
  let body = null;
10312
- const text = await res.text();
10313
10352
  if (text) {
10314
10353
  try {
10315
10354
  body = JSON.parse(text);
@@ -10688,5 +10727,5 @@ function defineLiveModule(mod) {
10688
10727
  return mod;
10689
10728
  }
10690
10729
 
10691
- export { WebSessionManager 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, ReactNativeSessionManager as a0, getActiveSessionManager as a1, onSessionCleared as a2, SessionEnvironmentError as a3, UNSUPPORTED_ENVIRONMENT_CODE as a4, AUTH_CHANGED_CODE as a5, AUTH_EXPIRED_CODE as a6, isAuthExpiredError as a7, ServerSessionManager as a8, createSessionWithSignature as a9, refreshSession as aa, revokeSession as ab, signSessionCreateMessage as ac, genAuthNonce as ad, genSolanaMessage as ae, genSiweMessage as af, normalizeEvmAddress as ag, toLowerEvmAddress as ah, assertCanonicalBoundedRuntimeWriteCalldata as ai, assertEvmTransactionMatchesWrite as aj, BOUNDED_RUNTIME_SET_DOCUMENTS_SELECTOR as ak, BOUNDED_RUNTIME_SET_DOCUMENTS_ATTESTED_SELECTOR as al, functions as am, invoke as an, FunctionInvokeError as ao, live as ap, intent as aq, status as ar, subscribeView as as, LiveIntentError as at, withEffects as au, isEffectResult as av, defineLiveModule as aw, EFFECT_INTENT_ADDRESS as ax, 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 };
10692
- //# sourceMappingURL=index-TyXiW4Uf.mjs.map
10730
+ 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, assertCanonicalBoundedRuntimeWriteCalldata as ak, assertEvmTransactionMatchesWrite as al, BOUNDED_RUNTIME_SET_DOCUMENTS_SELECTOR as am, BOUNDED_RUNTIME_SET_DOCUMENTS_ATTESTED_SELECTOR as an, functions as ao, invoke as ap, FunctionInvokeError as aq, live as ar, intent as as, status as at, subscribeView as au, LiveIntentError as av, withEffects as aw, isEffectResult as ax, defineLiveModule as ay, EFFECT_INTENT_ADDRESS as az, 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 };
10731
+ //# sourceMappingURL=index-C9h-Bnjk.mjs.map