@bounded-sh/core 0.0.116 → 0.0.117-sync.0

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 (26) hide show
  1. package/dist/client/operations.d.ts +6 -5
  2. package/dist/{index-CjiaT9AT.js → index-BcJOeks0.js} +48 -41
  3. package/dist/index-BcJOeks0.js.map +1 -0
  4. package/dist/{index-Db4lrwO6.mjs → index-l5JPD7_a.mjs} +48 -41
  5. package/dist/index-l5JPD7_a.mjs.map +1 -0
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/{realtime-store-IPPwUhJc.js → realtime-store-5vXHb5Br.js} +2 -2
  9. package/dist/{realtime-store-IPPwUhJc.js.map → realtime-store-5vXHb5Br.js.map} +1 -1
  10. package/dist/{realtime-store-CNs5zURZ.mjs → realtime-store-CofPUMMC.mjs} +2 -2
  11. package/dist/{realtime-store-CNs5zURZ.mjs.map → realtime-store-CofPUMMC.mjs.map} +1 -1
  12. package/dist/{solana-message-CXuLc7NX.js → solana-message-CaPunjVI.js} +2 -2
  13. package/dist/{solana-message-CXuLc7NX.js.map → solana-message-CaPunjVI.js.map} +1 -1
  14. package/dist/{solana-message-BO6Dtgbv.mjs → solana-message-DXWlEuK5.mjs} +2 -2
  15. package/dist/{solana-message-BO6Dtgbv.mjs.map → solana-message-DXWlEuK5.mjs.map} +1 -1
  16. package/dist/{solana-operations-CghJe0_7.js → solana-operations-BPOTddBI.js} +3 -3
  17. package/dist/{solana-operations-CghJe0_7.js.map → solana-operations-BPOTddBI.js.map} +1 -1
  18. package/dist/{solana-operations-DDt4CzRR.mjs → solana-operations-CuWKt_pG.mjs} +3 -3
  19. package/dist/{solana-operations-DDt4CzRR.mjs.map → solana-operations-CuWKt_pG.mjs.map} +1 -1
  20. package/dist/{solana-v1-operations-BY2DTfbR.js → solana-v1-operations-DTXPM_aZ.js} +3 -3
  21. package/dist/{solana-v1-operations-BY2DTfbR.js.map → solana-v1-operations-DTXPM_aZ.js.map} +1 -1
  22. package/dist/{solana-v1-operations-TH-HUzbT.mjs → solana-v1-operations-MbUM3wgC.mjs} +3 -3
  23. package/dist/{solana-v1-operations-TH-HUzbT.mjs.map → solana-v1-operations-MbUM3wgC.mjs.map} +1 -1
  24. package/package.json +1 -1
  25. package/dist/index-CjiaT9AT.js.map +0 -1
  26. package/dist/index-Db4lrwO6.mjs.map +0 -1
@@ -4305,7 +4305,7 @@ class ServerSessionManager {
4305
4305
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4306
4306
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4307
4307
  const nonce = await genAuthNonce(sessionConfig);
4308
- const { genSolanaMessage } = await import('./solana-message-BO6Dtgbv.mjs');
4308
+ const { genSolanaMessage } = await import('./solana-message-DXWlEuK5.mjs');
4309
4309
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4310
4310
  /* sign the message */
4311
4311
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -5051,6 +5051,7 @@ class BoundedDeclineError extends Error {
5051
5051
 
5052
5052
  const apiClient = axios.create();
5053
5053
  const TRANSIENT_GET_STATUSES = new Set([500, 502, 503, 504]);
5054
+ const TRANSIENT_SYNC_STATUSES = new Set([502, 503, 504]);
5054
5055
  const RATE_LIMIT_RETRY_BASE_DELAY_MS = 100;
5055
5056
  /** The window event emitted when the API responds with HTTP 429. */
5056
5057
  const RATE_LIMIT_EVENT_NAME = 'bounded:ratelimit';
@@ -5099,7 +5100,7 @@ function getRateLimitAttempt(error) {
5099
5100
  axiosRetry(apiClient, {
5100
5101
  retries: 2,
5101
5102
  retryCondition: (error) => {
5102
- var _a, _b, _c, _d, _e, _f, _g, _h;
5103
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
5103
5104
  // A caller cancellation is final. In particular, never turn a route
5104
5105
  // unmount into a fresh GET after its AbortSignal has fired.
5105
5106
  const canceled = axios.isCancel(error)
@@ -5115,15 +5116,27 @@ axiosRetry(apiClient, {
5115
5116
  // safe for every method, including POST requests to the queries API.
5116
5117
  if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) === 429)
5117
5118
  return true;
5118
- // Only retry idempotent GETs. Network failures and the small set of
5119
- // conventional transient gateway/runtime statuses get two bounded
5120
- // retries; auth, policy, invariant, and other terminal responses stay final.
5121
- // Writes are never retried because the server may already have applied
5122
- // them before the response was lost.
5123
- if (((_f = (_e = error.config) === null || _e === void 0 ? void 0 : _e.method) === null || _f === void 0 ? void 0 : _f.toLowerCase()) !== 'get')
5119
+ // Sync only indexes existing chain state, so repeating it cannot submit
5120
+ // a second transaction. Keep its retries in this same bounded transport
5121
+ // loop instead of multiplying them with another SDK retry loop.
5122
+ const method = (_f = (_e = error.config) === null || _e === void 0 ? void 0 : _e.method) === null || _f === void 0 ? void 0 : _f.toLowerCase();
5123
+ let isSync = false;
5124
+ if (method === 'put') {
5125
+ try {
5126
+ isSync = new URL(String((_g = error.config) === null || _g === void 0 ? void 0 : _g.url)).pathname === '/items/sync';
5127
+ }
5128
+ catch ( /* An unrecognized URL is never safe to retry. */_m) { /* An unrecognized URL is never safe to retry. */ }
5129
+ }
5130
+ if (isSync) {
5131
+ return axiosRetry.isNetworkError(error)
5132
+ || TRANSIENT_SYNC_STATUSES.has((_j = (_h = error.response) === null || _h === void 0 ? void 0 : _h.status) !== null && _j !== void 0 ? _j : 0);
5133
+ }
5134
+ // Ordinary writes are never retried: a lost response may follow commit.
5135
+ // GET network and selected gateway/runtime failures are safe to repeat.
5136
+ if (method !== 'get')
5124
5137
  return false;
5125
5138
  return axiosRetry.isNetworkError(error)
5126
- || TRANSIENT_GET_STATUSES.has((_h = (_g = error.response) === null || _g === void 0 ? void 0 : _g.status) !== null && _h !== void 0 ? _h : 0);
5139
+ || TRANSIENT_GET_STATUSES.has((_l = (_k = error.response) === null || _k === void 0 ? void 0 : _k.status) !== null && _l !== void 0 ? _l : 0);
5127
5140
  },
5128
5141
  retryDelay: (retryCount, error) => {
5129
5142
  var _a;
@@ -7664,7 +7677,7 @@ async function doReconnectWithNewAuth() {
7664
7677
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
7665
7678
  }
7666
7679
  try {
7667
- const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-CNs5zURZ.mjs');
7680
+ const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-CofPUMMC.mjs');
7668
7681
  await reconnectRealtimeStoreWithNewAuth();
7669
7682
  }
7670
7683
  catch (error) {
@@ -8850,12 +8863,6 @@ async function runExpressionMany(many) {
8850
8863
  }
8851
8864
  }
8852
8865
  /* ===================== WRITE RECEIPT HELPERS (W4) ======================== */
8853
- /**
8854
- * Settle delay before the best-effort mirror read on an on-chain write. It is
8855
- * an optimization, not a correctness guarantee: the receipt is captured first
8856
- * and returned regardless of what the mirror read reports.
8857
- */
8858
- const MIRROR_SYNC_SETTLE_MS = 1500;
8859
8866
  const SOLANA_CHAIN_TAGS = new Set(['solana_devnet', 'solana_mainnet']);
8860
8867
  /**
8861
8868
  * Read the execution-lane tag the WORKER reported. The SDK never infers it: a
@@ -8930,16 +8937,14 @@ function validatePathKeyedDocuments(paths, source) {
8930
8937
  return { observed: true, documents };
8931
8938
  }
8932
8939
  /**
8933
- * Best-effort mirror read. A confirmed transaction must NEVER be lost to a
8940
+ * Best-effort chain synchronization. A confirmed transaction must NEVER be lost to a
8934
8941
  * synchronization failure, so this reports its outcome in `mirrorSync` and
8935
- * never rejects. It reads the CONCRETE destination paths, so a collection
8936
- * insert with a generated id syncs the path that actually exists.
8942
+ * never rejects. The signature lets the server index the exact transaction,
8943
+ * including hook-mutated documents beyond the requested destination paths.
8937
8944
  */
8938
- async function attemptMirrorSync(paths, options, settleMs = MIRROR_SYNC_SETTLE_MS) {
8945
+ async function attemptMirrorSync(paths, options, transactionSignature) {
8939
8946
  try {
8940
- if (settleMs > 0)
8941
- await new Promise(resolve => setTimeout(resolve, settleMs));
8942
- const synced = await syncItems(paths, options);
8947
+ const synced = await syncItems(paths, options, transactionSignature);
8943
8948
  // The sync endpoint answers `{ data: <path-keyed map>, status }`; a document
8944
8949
  // path always contains a `/`, so a top-level `data` key is never one.
8945
8950
  const map = (synced && typeof synced === 'object' && !Array.isArray(synced) && 'data' in synced)
@@ -9164,7 +9169,7 @@ async function setMany(many, options) {
9164
9169
  if (typeof curTx.serializedTransaction !== 'string' || typeof curTx.poofnetIntentId !== 'string') {
9165
9170
  throw new Error('Unsupported 202 transaction shape: a poofnet write needs serializedTransaction and poofnetIntentId');
9166
9171
  }
9167
- const { signPoofnetTransaction, buildExpectedWriteIntent } = await import('./solana-operations-DDt4CzRR.mjs');
9172
+ const { signPoofnetTransaction, buildExpectedWriteIntent } = await import('./solana-operations-CuWKt_pG.mjs');
9168
9173
  const signedTransaction = await signPoofnetTransaction(curTx.serializedTransaction, authProvider, options, buildExpectedWriteIntent(documents));
9169
9174
  // Signing-only, exactly as on a real chain: signed and NOT committed.
9170
9175
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
@@ -9202,7 +9207,7 @@ async function setMany(many, options) {
9202
9207
  'Nothing was signed or submitted.');
9203
9208
  }
9204
9209
  const solanaChain = workerChain;
9205
- const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await import('./solana-operations-DDt4CzRR.mjs');
9210
+ const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await import('./solana-operations-CuWKt_pG.mjs');
9206
9211
  // OA-0001: derive the expected intent from OUR OWN request (the one
9207
9212
  // ground truth a tampered builder response cannot change) so the
9208
9213
  // validator can reject any transaction whose operation semantics
@@ -9243,7 +9248,7 @@ async function setMany(many, options) {
9243
9248
  // best-effort enrichment reported in `mirrorSync`, never a rejection.
9244
9249
  const mirrorSync = grantLane
9245
9250
  ? { observed: false, reason: 'not attempted: a venue grant authorizes only the write' }
9246
- : await attemptMirrorSync(requestedPaths, options);
9251
+ : await attemptMirrorSync(requestedPaths, Object.assign(Object.assign({}, options), { _overrides: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options._overrides), { _config: config }) }), solanaOutcome.transactionSignature);
9247
9252
  return {
9248
9253
  status: 'confirmed', appId, requestedDocuments, chain: solanaChain,
9249
9254
  transactionId: solanaOutcome.transactionSignature,
@@ -9515,14 +9520,18 @@ async function signAndSubmitTransaction(transaction, feePayer) {
9515
9520
  }
9516
9521
  return config.authProvider.signAndSubmitTransaction(transaction, feePayer);
9517
9522
  }
9518
- async function syncItems(paths, options) {
9519
- try {
9520
- const response = await makeApiRequest('PUT', 'items/sync', { paths }, options === null || options === void 0 ? void 0 : options._overrides);
9521
- return response.data;
9522
- }
9523
- catch (error) {
9524
- throw error;
9523
+ /** Refresh concrete paths, or index a confirmed transaction and read its requested paths. */
9524
+ async function syncItems(paths, options, transactionSignature) {
9525
+ var _a, _b;
9526
+ const response = await makeApiRequest('PUT', 'items/sync', Object.assign({ paths }, (transactionSignature !== undefined ? { transactionSignature } : {})), options === null || options === void 0 ? void 0 : options._overrides);
9527
+ if (transactionSignature !== undefined && (response.status !== 200
9528
+ || ((_a = response.data) === null || _a === void 0 ? void 0 : _a.synchronized) !== true
9529
+ || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.transactionSignature) !== transactionSignature)) {
9530
+ // An older server's local-read stub can return 200 with stale documents.
9531
+ // Only the matching server acknowledgment proves this transaction was indexed.
9532
+ throw new Error('the synchronization response did not acknowledge the confirmed transaction');
9525
9533
  }
9534
+ return response.data;
9526
9535
  }
9527
9536
 
9528
9537
  var operations = /*#__PURE__*/Object.freeze({
@@ -9555,8 +9564,6 @@ var operations = /*#__PURE__*/Object.freeze({
9555
9564
  const DEFAULT_TIMEOUT_MS = 60000;
9556
9565
  const DEFAULT_MAX_ATTEMPTS$1 = 20;
9557
9566
  const DEFAULT_POLL_INTERVAL_MS = 3000;
9558
- /** Mirror read after a late confirmation. No settle delay: the tx already landed. */
9559
- const RECONCILE_MIRROR_SETTLE_MS = 0;
9560
9567
  function errorText(error) {
9561
9568
  const message = error === null || error === void 0 ? void 0 : error.message;
9562
9569
  return typeof message === 'string' && message.length > 0 ? message : String(error);
@@ -9605,12 +9612,12 @@ function assertReceiptMatchesContext(receipt, config) {
9605
9612
  function stillSubmitted(receipt, reason) {
9606
9613
  return Object.assign(Object.assign({}, receipt), { confirmation: Object.assign(Object.assign({}, receipt.confirmation), { reason }) });
9607
9614
  }
9608
- async function mirrorFor(receipt, options) {
9615
+ async function mirrorFor(receipt, config, options) {
9609
9616
  const paths = receipt.requestedDocuments.map(entry => entry.path);
9610
9617
  if (paths.length === 0)
9611
9618
  return { observed: false, reason: 'the receipt carried no requested paths' };
9612
- const setOptions = (options === null || options === void 0 ? void 0 : options._overrides) ? { _overrides: options._overrides } : undefined;
9613
- return attemptMirrorSync(paths, setOptions, RECONCILE_MIRROR_SETTLE_MS);
9619
+ const setOptions = { _overrides: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options._overrides), { _config: config }) };
9620
+ return attemptMirrorSync(paths, setOptions, receipt.transactionId);
9614
9621
  }
9615
9622
  async function resolveSolanaRpc(config, options) {
9616
9623
  var _a, _b;
@@ -9692,7 +9699,7 @@ async function reconcileSolana(receipt, config, options) {
9692
9699
  signedTransaction: receipt.signedTransaction,
9693
9700
  fence: receipt.fence,
9694
9701
  confirmationContextSlot: typeof statusValue.slot === 'number' ? statusValue.slot : (contextSlot !== null && contextSlot !== void 0 ? contextSlot : 0),
9695
- mirrorSync: await mirrorFor(receipt, options),
9702
+ mirrorSync: await mirrorFor(receipt, config, options),
9696
9703
  };
9697
9704
  return confirmed;
9698
9705
  }
@@ -11046,7 +11053,7 @@ function toMillis(seconds) {
11046
11053
 
11047
11054
  /** SIWS message creation is async already, so its onchain module can be lazy. */
11048
11055
  async function genSolanaMessage(address, nonce) {
11049
- const implementation = await import('./solana-message-BO6Dtgbv.mjs');
11056
+ const implementation = await import('./solana-message-DXWlEuK5.mjs');
11050
11057
  return implementation.genSolanaMessage(address, nonce);
11051
11058
  }
11052
11059
 
@@ -11596,4 +11603,4 @@ function defineLiveModule(mod) {
11596
11603
  }
11597
11604
 
11598
11605
  export { RATE_LIMIT_EVENT_NAME as $, isWriteNotApplied as A, writeNotAppliedPhase as B, subscribe as C, closeAllSubscriptions as D, clearCache as E, getCachedData as F, reconnectWithNewAuth as G, createClient as H, InsufficientBalanceError as I, exchangeAppToken as J, clearAppTokenCache as K, createAppTokenAuthHeaders as L, AppTokenExchangeError as M, setWithVenueGrant as N, resolveVenueRpcUrl as O, subscribeQuery as P, closeAllQuerySubscriptions as Q, canonicalizeArgs as R, ScopedClientReadOnlyError as S, canonicalizeResult as T, DEFAULT_QUERY_POLL_INTERVAL_MS as U, MIN_QUERY_POLL_INTERVAL_MS as V, BoundedDeclineError as W, deriveDecline as X, dispatchDeclineEvent as Y, DECLINE_EVENT_NAME as Z, dispatchRateLimitEvent as _, getWebhookKeysUrl as a, hasActiveConnection as a0, increment as a1, serverTimestamp as a2, now as a3, toSeconds as a4, toMillis as a5, getIdToken as a6, deriveUserIdentityFromIdToken as a7, getSessionGeneration as a8, WebSessionManager as a9, normalizeEvmAddress as aA, toLowerEvmAddress as aB, functions as aC, invoke as aD, FunctionInvokeError as aE, live as aF, intent as aG, status as aH, subscribeView as aI, LiveIntentError as aJ, withEffects as aK, isEffectResult as aL, defineLiveModule as aM, EFFECT_INTENT_ADDRESS as aN, ReactNativeSessionManager as aa, getActiveSessionManager as ab, onSessionCleared as ac, announceSessionChange as ad, onSessionChange as ae, SESSION_SIGNAL_CHANNEL as af, SessionEnvironmentError as ag, UNSUPPORTED_ENVIRONMENT_CODE as ah, AUTH_CHANGED_CODE as ai, AUTH_EXPIRED_CODE as aj, isAuthExpiredError as ak, getFreshAuthToken as al, ServerSessionManager as am, createSessionWithSignature as an, refreshSession as ao, revokeSession as ap, signSessionCreateMessage as aq, genAuthNonce as ar, genSolanaMessage as as, createSolanaSignInRequest as at, createSolanaSignInMessageText as au, genSolanaSignInRequest as av, genSolanaSignInMessage as aw, browserSignInDomain as ax, SOLANA_SIGN_IN_STATEMENT as ay, genSiweMessage 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, markWriteNotApplied as m, runQueryMany as n, runExpression as o, runExpressionMany as p, queryAggregate as q, runQuery as r, set as s, signMessage as t, signTransaction as u, signAndSubmitTransaction as v, count as w, aggregate as x, reconcileSetResult as y, waitForSetResult as z };
11599
- //# sourceMappingURL=index-Db4lrwO6.mjs.map
11606
+ //# sourceMappingURL=index-l5JPD7_a.mjs.map