@bounded-sh/client 0.0.118-openapps.0 → 0.0.119

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 (60) hide show
  1. package/dist/auth/providers/email-auth-provider.d.ts +2 -1
  2. package/dist/auth/providers/offchain-auth-provider.d.ts +2 -1
  3. package/dist/auth/providers/transaction-utils.d.ts +5 -3
  4. package/dist/auth/turnkey-signer-bridge.d.ts +16 -0
  5. package/dist/auth/turnkey-wallet-widget.d.ts +4 -0
  6. package/dist/{email-auth-provider-C5bYKzpN.mjs → email-auth-provider-DHq5_wtn.mjs} +7 -2
  7. package/dist/email-auth-provider-DHq5_wtn.mjs.map +1 -0
  8. package/dist/{email-auth-provider-C-SGTRZe.mjs → email-auth-provider-DOI-4lPC.mjs} +7 -2
  9. package/dist/email-auth-provider-DOI-4lPC.mjs.map +1 -0
  10. package/dist/{email-auth-provider-CjbJ8wK1.js → email-auth-provider-DyzhiN9Y.js} +7 -2
  11. package/dist/email-auth-provider-DyzhiN9Y.js.map +1 -0
  12. package/dist/{email-auth-provider-3tuw_aDK.js → email-auth-provider-wOISnCic.js} +7 -2
  13. package/dist/email-auth-provider-wOISnCic.js.map +1 -0
  14. package/dist/{guest-auth-provider-ClCOa69H.js → guest-auth-provider-Br3iM3O3.js} +2 -2
  15. package/dist/{guest-auth-provider-ClCOa69H.js.map → guest-auth-provider-Br3iM3O3.js.map} +1 -1
  16. package/dist/{guest-auth-provider-BwEXKnNK.mjs → guest-auth-provider-DyP5UUg6.mjs} +2 -2
  17. package/dist/{guest-auth-provider-CsM_SuGH.mjs.map → guest-auth-provider-DyP5UUg6.mjs.map} +1 -1
  18. package/dist/{guest-auth-provider-CsM_SuGH.mjs → guest-auth-provider-ZOBNFoeC.mjs} +2 -2
  19. package/dist/{guest-auth-provider-BwEXKnNK.mjs.map → guest-auth-provider-ZOBNFoeC.mjs.map} +1 -1
  20. package/dist/{guest-auth-provider-_jdqZKUo.js → guest-auth-provider-xap-VQBP.js} +2 -2
  21. package/dist/{guest-auth-provider-_jdqZKUo.js.map → guest-auth-provider-xap-VQBP.js.map} +1 -1
  22. package/dist/{index-B2HWEA13.js → index-B4_eKphx.js} +125 -59
  23. package/dist/index-B4_eKphx.js.map +1 -0
  24. package/dist/{index-q9BHoxbM.mjs → index-BaXUWG8Q.mjs} +126 -61
  25. package/dist/index-BaXUWG8Q.mjs.map +1 -0
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +5 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +2 -2
  30. package/dist/{index.native-CMNMw3Pe.js → index.native-B-pjNetI.js} +142 -60
  31. package/dist/index.native-B-pjNetI.js.map +1 -0
  32. package/dist/{index.native-DfDVa7MG.mjs → index.native-B4yI0BqT.mjs} +143 -62
  33. package/dist/index.native-B4yI0BqT.mjs.map +1 -0
  34. package/dist/index.native.js +1 -1
  35. package/dist/index.native.mjs +1 -1
  36. package/dist/{injected-evm-wallet-provider-AXc7Lmzk.mjs → injected-evm-wallet-provider-B4Kr6lnK.mjs} +2 -2
  37. package/dist/{injected-evm-wallet-provider-AXc7Lmzk.mjs.map → injected-evm-wallet-provider-B4Kr6lnK.mjs.map} +1 -1
  38. package/dist/{injected-evm-wallet-provider-qB_GQ9ih.js → injected-evm-wallet-provider-CKAv4Qxh.js} +2 -2
  39. package/dist/{injected-evm-wallet-provider-qB_GQ9ih.js.map → injected-evm-wallet-provider-CKAv4Qxh.js.map} +1 -1
  40. package/dist/{injected-evm-wallet-provider-CUNTCT-a.js → injected-evm-wallet-provider-DQMYqPus.js} +2 -2
  41. package/dist/{injected-evm-wallet-provider-CUNTCT-a.js.map → injected-evm-wallet-provider-DQMYqPus.js.map} +1 -1
  42. package/dist/{injected-evm-wallet-provider-E7eCpvLr.mjs → injected-evm-wallet-provider-Vw-Puwxh.mjs} +2 -2
  43. package/dist/{injected-evm-wallet-provider-E7eCpvLr.mjs.map → injected-evm-wallet-provider-Vw-Puwxh.mjs.map} +1 -1
  44. package/dist/{injected-wallet-provider-BEaDBzcd.js → injected-wallet-provider-B8QTPxf6.js} +14 -5
  45. package/dist/{injected-wallet-provider-BEaDBzcd.js.map → injected-wallet-provider-B8QTPxf6.js.map} +1 -1
  46. package/dist/{injected-wallet-provider-BqYJQDGu.js → injected-wallet-provider-BsTfBAD4.js} +14 -5
  47. package/dist/{injected-wallet-provider-BqYJQDGu.js.map → injected-wallet-provider-BsTfBAD4.js.map} +1 -1
  48. package/dist/{injected-wallet-provider-BoRoxrEl.mjs → injected-wallet-provider-CQxGVYja.mjs} +14 -5
  49. package/dist/{injected-wallet-provider-BoRoxrEl.mjs.map → injected-wallet-provider-CQxGVYja.mjs.map} +1 -1
  50. package/dist/{injected-wallet-provider-gmGZ254w.mjs → injected-wallet-provider-jj9dqm2Z.mjs} +14 -5
  51. package/dist/{injected-wallet-provider-gmGZ254w.mjs.map → injected-wallet-provider-jj9dqm2Z.mjs.map} +1 -1
  52. package/package.json +2 -2
  53. package/dist/email-auth-provider-3tuw_aDK.js.map +0 -1
  54. package/dist/email-auth-provider-C-SGTRZe.mjs.map +0 -1
  55. package/dist/email-auth-provider-C5bYKzpN.mjs.map +0 -1
  56. package/dist/email-auth-provider-CjbJ8wK1.js.map +0 -1
  57. package/dist/index-B2HWEA13.js.map +0 -1
  58. package/dist/index-q9BHoxbM.mjs.map +0 -1
  59. package/dist/index.native-CMNMw3Pe.js.map +0 -1
  60. package/dist/index.native-DfDVa7MG.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -17,8 +17,9 @@ export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from "./au
17
17
  export { openBoundedWidget } from "./auth/bounded-login-widget";
18
18
  export type { BoundedWidgetOptions } from "./auth/bounded-login-widget";
19
19
  export { ensureSignedIn } from "./auth/ensure-signed-in";
20
- export { get, getMany, docId, set, setMany, setFile, getFiles, search, queryAggregate, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate, type GetOptions, type SearchOptions, type SetOptions, type CountOptions, type AggregateOptions, type AggregateOperation, type AggregateResult, type AggregateSpec, type AggregateRow, type QueryAggregateOptions, } from "@bounded-sh/core";
20
+ export { get, getMany, docId, set, setMany, setFile, getFiles, search, queryAggregate, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, prepareToSign, count, aggregate, type GetOptions, type SearchOptions, type SetOptions, type CountOptions, type AggregateOptions, type AggregateOperation, type AggregateResult, type AggregateSpec, type AggregateRow, type QueryAggregateOptions, } from "@bounded-sh/core";
21
21
  export type { GetOptions as BoundedGetOptions } from "@bounded-sh/core";
22
+ export type { SignerReadiness } from "@bounded-sh/core";
22
23
  export { reconcileSetResult, waitForSetResult } from "@bounded-sh/core";
23
24
  export type { SetResult, SetEntry, SetDocuments, MirrorSync, SolanaFence, ChainTag, SolanaChainTag, CommittedSetResult, ConfirmedSetResult, SolanaConfirmedSetResult, SubmittedSetResult, SolanaSubmittedSetResult, SolanaExpiredNotLandedSetResult, SolanaSignedSetResult, TransactionResult, TransactionReconciliation, ReconcileSetResultOptions, WaitForSetResultOptions, FileUploadResult, FileDeleteResult, } from "@bounded-sh/core";
24
25
  export { subscribe } from "@bounded-sh/core";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-B2HWEA13.js');
3
+ var index = require('./index-B4_eKphx.js');
4
4
  var core = require('@bounded-sh/core');
5
5
  require('react');
6
6
 
@@ -148,6 +148,10 @@ Object.defineProperty(exports, "getMany", {
148
148
  enumerable: true,
149
149
  get: function () { return core.getMany; }
150
150
  });
151
+ Object.defineProperty(exports, "prepareToSign", {
152
+ enumerable: true,
153
+ get: function () { return core.prepareToSign; }
154
+ });
151
155
  Object.defineProperty(exports, "queryAggregate", {
152
156
  enumerable: true,
153
157
  get: function () { return core.queryAggregate; }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { ar as BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA, aq as BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA, ap as BUILD_REVIEW_CAPABILITY_SCHEMA, ai as BuildsApiError, a6 as ConnectionError, ao as FAILURE_REASONS, ak as NON_TERMINAL_STATES, ac as OffchainAuthProvider, an as PARK_REASONS, ad as PrivyExpoProvider, am as RUN_STATES, al as TERMINAL_STATES, aa as VenueEscrowError, W as WalletConfigError, R as apps, ah as builds, a3 as completeConnection, J as completeLoginFromRedirect, a2 as connect, af as connectBroadcast, ag as connectServiceSession, p as defaultInjectedEvmProvider, f as defaultInjectedProvider, a5 as disconnect, a8 as disputeVenueEscrow, G as ensureSharedWalletLoginReady, N as ensureSignedIn, F as ensureWalletLoginReady, a7 as fundVenueEscrow, x as getAuthLoading, B as getAuthProvider, a4 as getConnections, u as getCurrentUser, _ as getIdToken, K as getLoginReturnError, U as getOrCreateTurnkeyWallet, g as getPlatform, Y as getTurnkeyWalletRecoveryUrl, X as getTurnkeyWalletSessionState, a9 as getVenueEscrow, q as init, z as login, L as loginWithPopup, D as loginWithPrivy, I as loginWithRedirect, E as loginWithWallet, A as logout, aj as mediaAgentTools, w as onAuthLoadingChanged, v as onAuthStateChanged, $ as onramp, a0 as onrampQuote, a1 as onrampStatus, M as openBoundedWidget, V as openTurnkeyKeyExport, H as preloadWalletLogin, ae as requestEip6963Providers, ab as setPlatform, C as signInAnonymously, T as signSolanaMessageViaTurnkey, Z as startTurnkeyEmailLogin, k as supportsWalletSignIn, O as useAuth, Q as useBuildRun, P as useQuery, y as waitForAuthReady } from './index-q9BHoxbM.mjs';
1
+ export { as as BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA, ar as BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA, aq as BUILD_REVIEW_CAPABILITY_SCHEMA, aj as BuildsApiError, a7 as ConnectionError, ap as FAILURE_REASONS, al as NON_TERMINAL_STATES, ad as OffchainAuthProvider, ao as PARK_REASONS, ae as PrivyExpoProvider, an as RUN_STATES, am as TERMINAL_STATES, ab as VenueEscrowError, W as WalletConfigError, T as apps, ai as builds, a4 as completeConnection, K as completeLoginFromRedirect, a3 as connect, ag as connectBroadcast, ah as connectServiceSession, q as defaultInjectedEvmProvider, i as defaultInjectedProvider, a6 as disconnect, a9 as disputeVenueEscrow, H as ensureSharedWalletLoginReady, O as ensureSignedIn, G as ensureWalletLoginReady, a8 as fundVenueEscrow, y as getAuthLoading, C as getAuthProvider, a5 as getConnections, v as getCurrentUser, $ as getIdToken, L as getLoginReturnError, V as getOrCreateTurnkeyWallet, g as getPlatform, Z as getTurnkeyWalletRecoveryUrl, Y as getTurnkeyWalletSessionState, aa as getVenueEscrow, u as init, A as login, M as loginWithPopup, E as loginWithPrivy, J as loginWithRedirect, F as loginWithWallet, B as logout, ak as mediaAgentTools, x as onAuthLoadingChanged, w as onAuthStateChanged, a0 as onramp, a1 as onrampQuote, a2 as onrampStatus, N as openBoundedWidget, X as openTurnkeyKeyExport, I as preloadWalletLogin, af as requestEip6963Providers, ac as setPlatform, D as signInAnonymously, U as signSolanaMessageViaTurnkey, _ as startTurnkeyEmailLogin, l as supportsWalletSignIn, P as useAuth, R as useBuildRun, Q as useQuery, z as waitForAuthReady } from './index-BaXUWG8Q.mjs';
2
2
  export * from '@bounded-sh/core';
3
- export { AppTokenExchangeError, BoundedDeclineError, DECLINE_EVENT_NAME, RATE_LIMIT_EVENT_NAME, ScopedClientReadOnlyError, aggregate, clearAppTokenCache, count, createAppTokenAuthHeaders, createClient, deriveDecline, dispatchDeclineEvent, dispatchRateLimitEvent, docId, exchangeAppToken, get, getConfig, getFiles, getMany, queryAggregate, reconcileSetResult, runExpression, runExpressionMany, runQuery, runQueryMany, search, set, setFile, setMany, signAndSubmitTransaction, signMessage, signTransaction, subscribe, waitForSetResult } from '@bounded-sh/core';
3
+ export { AppTokenExchangeError, BoundedDeclineError, DECLINE_EVENT_NAME, RATE_LIMIT_EVENT_NAME, ScopedClientReadOnlyError, aggregate, clearAppTokenCache, count, createAppTokenAuthHeaders, createClient, deriveDecline, dispatchDeclineEvent, dispatchRateLimitEvent, docId, exchangeAppToken, get, getConfig, getFiles, getMany, prepareToSign, queryAggregate, reconcileSetResult, runExpression, runExpressionMany, runQuery, runQueryMany, search, set, setFile, setMany, signAndSubmitTransaction, signMessage, signTransaction, subscribe, waitForSetResult } from '@bounded-sh/core';
4
4
  import 'react';
5
5
  //# sourceMappingURL=index.mjs.map
@@ -56,7 +56,18 @@ function walletOperationGuard() {
56
56
  throw new Error('wallet_session_changed');
57
57
  };
58
58
  }
59
- function setWalletSessionState(key, state) { }
59
+ // This realm owns one active SDK session and one retained signer frame.
60
+ let activeWalletState;
61
+ function setWalletSessionState(key, state) { activeWalletState = { key, state }; }
62
+ function walletSessionState(key) {
63
+ if ((activeWalletState === null || activeWalletState === void 0 ? void 0 : activeWalletState.key) !== key)
64
+ return { status: 'verification-required' };
65
+ const state = activeWalletState.state;
66
+ if (state.status === 'ready' && (!Number.isFinite(state.expiresAt) || state.expiresAt <= Date.now())) {
67
+ return { status: 'verification-required', reason: 'wallet_session_expired' };
68
+ }
69
+ return state;
70
+ }
60
71
 
61
72
  /**
62
73
  * Platform abstraction layer for React Native compatibility.
@@ -247,6 +258,10 @@ class OffchainAuthProvider {
247
258
  async signTransaction(tx) {
248
259
  return this.wrappedProvider.signTransaction(tx);
249
260
  }
261
+ async prepareToSign() {
262
+ var _a, _b, _c;
263
+ return (_c = (await ((_b = (_a = this.wrappedProvider).prepareToSign) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : 'ready';
264
+ }
250
265
  /**
251
266
  * Sign and submit transaction - not supported in poofnet environment.
252
267
  * See the real providers (PhantomWalletProvider, SolanaKeypairProvider)
@@ -4164,6 +4179,11 @@ function detachWarmSignerIframe(origin) {
4164
4179
  detachIframe(modal);
4165
4180
  return true;
4166
4181
  }
4182
+ /** A removed frame cannot still supply its in-memory signing session. */
4183
+ function hasWarmSignerFrame(context) {
4184
+ var _a;
4185
+ return Boolean(((_a = modal === null || modal === void 0 ? void 0 : modal.iframe) === null || _a === void 0 ? void 0 : _a.isConnected) && modal.iframeContext === context);
4186
+ }
4167
4187
  function detachIframe(m) {
4168
4188
  if (m.iframe) {
4169
4189
  try {
@@ -4205,7 +4225,7 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4205
4225
  const requestId = String(ex.request.requestId);
4206
4226
  // Serialize: the approve card is modal, and one warm frame handles one request at a time.
4207
4227
  const run = m.chain.then(() => new Promise((resolve, reject) => {
4208
- var _a;
4228
+ var _a, _b;
4209
4229
  let settled = false;
4210
4230
  let usedFallback = false;
4211
4231
  (_a = ex.assertCurrent) === null || _a === void 0 ? void 0 : _a.call(ex);
@@ -4248,16 +4268,20 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4248
4268
  /* frame gone */
4249
4269
  }
4250
4270
  };
4271
+ const dismiss = () => {
4272
+ if (!ex.silent)
4273
+ hideModal(m);
4274
+ };
4251
4275
  const goFallback = () => {
4252
4276
  if (usedFallback || settled)
4253
4277
  return;
4254
4278
  usedFallback = true;
4255
- hideModal(m);
4279
+ dismiss();
4256
4280
  finish(() => popupFallback().then(resolve, reject));
4257
4281
  };
4258
4282
  m.onBackdrop = () => {
4259
4283
  cancelInFrame();
4260
- hideModal(m);
4284
+ dismiss();
4261
4285
  finish(() => reject(new Error("cancelled")));
4262
4286
  };
4263
4287
  m.onIframeMessage = (d) => {
@@ -4272,17 +4296,18 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4272
4296
  if (d.type === "bounded:turnkey:result" && d.requestId === requestId) {
4273
4297
  const outcome = ex.onResult(d);
4274
4298
  if ("error" in outcome) {
4275
- hideModal(m);
4299
+ dismiss();
4276
4300
  finish(() => reject(new Error(outcome.error)));
4277
4301
  return;
4278
4302
  }
4279
4303
  if (outcome.done) {
4280
- hideModal(m);
4304
+ dismiss();
4281
4305
  finish(() => resolve(outcome.value));
4282
4306
  }
4283
4307
  }
4284
4308
  };
4285
- showModal(m);
4309
+ if (!ex.silent)
4310
+ showModal(m);
4286
4311
  if (m.iframeReady)
4287
4312
  send();
4288
4313
  // If the frame never loads, degrade to the popup (best-effort - a post-load
@@ -4295,10 +4320,10 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4295
4320
  ceilingTimer = window.setTimeout(() => {
4296
4321
  if (!settled) {
4297
4322
  cancelInFrame();
4298
- hideModal(m);
4323
+ dismiss();
4299
4324
  finish(() => reject(new Error("Wallet approval timed out.")));
4300
4325
  }
4301
- }, 5 * 60 * 1000);
4326
+ }, (_b = ex.ceilingMs) !== null && _b !== void 0 ? _b : 5 * 60 * 1000);
4302
4327
  }));
4303
4328
  m.chain = run.then(() => undefined, () => undefined);
4304
4329
  return run;
@@ -4800,6 +4825,59 @@ async function clearTurnkeySigningSession(idToken) {
4800
4825
  function hasTurnkeyWallet() {
4801
4826
  return activeTurnkeyAddress() !== null;
4802
4827
  }
4828
+ /** The signer frame could not take the exchange: it never loaded, or a page from before the request existed stays silent. */
4829
+ class SignerFrameUnavailable extends Error {
4830
+ constructor() { super('The Bounded signer frame did not answer.'); }
4831
+ }
4832
+ /** How long a silent session probe may wait for the frame before the write goes on without it. */
4833
+ const SESSION_PROBE_MS = 8000;
4834
+ /**
4835
+ * Make the wallet's 24-hour signing session live BEFORE a transaction exists. Without one the
4836
+ * approve card must first collect an emailed code, which takes longer than a transaction's
4837
+ * blockhash lifetime (about 33 seconds on mainnet in late 2026), so a transaction built before
4838
+ * the code is dead by the time it is signed. A live session is found with nothing shown: the
4839
+ * warm frame answers a silent probe, and it holds the session even where the browser blocks its
4840
+ * storage. Only a lapsed session opens the card, which runs the code ceremony and closes without
4841
+ * signing anything. Resolves `'established'` when that ceremony ran, else `'ready'`.
4842
+ *
4843
+ * Both exchanges run in the warm frame only, since it is the frame that signs next and a popup
4844
+ * keeps its session to itself. Where the frame cannot answer (an embedder that blocks it, or a
4845
+ * signer page from before this request existed), the write goes on the way it always did: the
4846
+ * approve card collects the code itself, and an expired build is built again.
4847
+ */
4848
+ async function ensureTurnkeySigningSession() {
4849
+ if (!hasDOM$2())
4850
+ throw new Error('Turnkey embedded-wallet signing is only available in the browser (trusted wallet UI).');
4851
+ const context = await turnkeySignerPage();
4852
+ context.assertCurrent();
4853
+ if (hasWarmSignerFrame(context.key) && walletSessionState(context.key).status === 'ready')
4854
+ return 'ready';
4855
+ const { url, origin } = context;
4856
+ const authorization = await fetchActionAuthorization('createWallet', context);
4857
+ const frameOnly = () => Promise.reject(new SignerFrameUnavailable());
4858
+ const exchange = (probeOnly) => ({
4859
+ context: context.key, assertCurrent: context.assertCurrent,
4860
+ request: Object.assign({ type: 'bounded:turnkey:session', requestId: `tksession_${Date.now()}_${++requestSeq}`, authorization }, (probeOnly ? { probeOnly: true } : {})),
4861
+ onResult: (d) => d.ok ? { done: true, value: d } : { error: String(d.error || 'The signing session could not be established') },
4862
+ });
4863
+ const probed = await runWidget(url, origin, Object.assign(Object.assign({}, exchange(true)), { silent: true, ceilingMs: SESSION_PROBE_MS }), frameOnly)
4864
+ .catch(() => null);
4865
+ if (!probed)
4866
+ return 'ready';
4867
+ let result = probed;
4868
+ if (result.ready !== true) {
4869
+ try {
4870
+ result = await runWidget(url, origin, exchange(false), frameOnly);
4871
+ }
4872
+ catch (error) {
4873
+ if (error instanceof SignerFrameUnavailable)
4874
+ return 'ready';
4875
+ throw error;
4876
+ }
4877
+ }
4878
+ setWalletSessionState(context.key, { status: 'ready', expiresAt: Number(result.signingSessionExpiresAt) });
4879
+ return result.established === true ? 'established' : 'ready';
4880
+ }
4803
4881
  /**
4804
4882
  * Open the Bounded Turnkey approval card and sign `message` (raw bytes) with the
4805
4883
  * user's Turnkey wallet, resolving with the ed25519 signature and wallet address.
@@ -4836,7 +4914,7 @@ async function signSolanaMessageViaTurnkey(message) {
4836
4914
  // A top-level popup keeps its signing session in the signer origin's own storage, which the
4837
4915
  // warm in-app frame (a partitioned context) cannot see, so it says nothing about that frame.
4838
4916
  if (transport !== 'popup')
4839
- setWalletSessionState(context.key, { expiresAt: Number(d.signingSessionExpiresAt) });
4917
+ setWalletSessionState(context.key, { status: 'ready', expiresAt: Number(d.signingSessionExpiresAt) });
4840
4918
  return { done: true, value: { signature: fromHex(d.signatureHex), address: d.address, subOrgId: String(d.subOrgId || '') } };
4841
4919
  }
4842
4920
  // The hosted signer refuses a cross-app signature inside a frame. Never retry it from here:
@@ -4916,10 +4994,9 @@ async function signAndSubmitTransactionWithTurnkey(transaction, feePayer) {
4916
4994
  // has signed silently invalidates their signature - signTransactionWithTurnkey only ADDS the
4917
4995
  // Turnkey signature, it never re-signs the others. So only refresh the blockhash while the
4918
4996
  // transaction is still unsigned; once a real signature is present, preserve the caller's message
4919
- // verbatim and confirm against the blockhash it already carries.
4920
- const hasSignature = transactionHasSignature$1(transaction);
4921
- let confirmBlockhash = blockhash;
4922
- if (!hasSignature) {
4997
+ // verbatim. The confirmation is fenced on the lifetime read above either way: for a pre-signed
4998
+ // transaction that is a superset of the one its signers fenced on, never a shorter wait.
4999
+ if (!transactionHasSignature$1(transaction)) {
4923
5000
  if (isLegacy) {
4924
5001
  const legacy = transaction;
4925
5002
  legacy.recentBlockhash = blockhash;
@@ -4935,19 +5012,17 @@ async function signAndSubmitTransactionWithTurnkey(transaction, feePayer) {
4935
5012
  transaction.message.recentBlockhash = blockhash;
4936
5013
  }
4937
5014
  }
4938
- else {
4939
- confirmBlockhash = (isLegacy
4940
- ? transaction.recentBlockhash
4941
- : transaction.message.recentBlockhash) || blockhash;
4942
- }
4943
5015
  const signed = await signTransactionWithTurnkey(transaction);
4944
5016
  const signature = await connection.sendRawTransaction(signed.serialize(), {
4945
5017
  skipPreflight: false,
4946
5018
  maxRetries: 3,
4947
5019
  });
4948
- const confirmation = await connection.confirmTransaction({ signature, blockhash: confirmBlockhash, lastValidBlockHeight }, 'confirmed');
4949
- if (confirmation.value.err) {
4950
- throw new Error(`Turnkey transaction failed: ${JSON.stringify(confirmation.value.err)}`);
5020
+ const confirmation = await core.confirmSignature(connection, { signature, lastValidBlockHeight });
5021
+ if (!confirmation.landed) {
5022
+ throw new Error(`Turnkey transaction ${signature} was not confirmed: ${confirmation.reason}. Check its status before sending it again.`);
5023
+ }
5024
+ if (confirmation.status.err) {
5025
+ throw new Error(`Turnkey transaction failed: ${JSON.stringify(confirmation.status.err)}`);
4951
5026
  }
4952
5027
  return signature;
4953
5028
  }
@@ -4955,6 +5030,7 @@ async function signAndSubmitTransactionWithTurnkey(transaction, feePayer) {
4955
5030
  var turnkeySignerBridge = /*#__PURE__*/Object.freeze({
4956
5031
  __proto__: null,
4957
5032
  clearTurnkeySigningSession: clearTurnkeySigningSession,
5033
+ ensureTurnkeySigningSession: ensureTurnkeySigningSession,
4958
5034
  hasTurnkeyWallet: hasTurnkeyWallet,
4959
5035
  signAndSubmitTransactionWithTurnkey: signAndSubmitTransactionWithTurnkey,
4960
5036
  signMessageWithTurnkey: signMessageWithTurnkey,
@@ -5034,6 +5110,11 @@ const oidcProviderSingleton = {
5034
5110
  throw new Error(OIDC_NO_WALLET);
5035
5111
  return signTransactionV1WithTurnkey(transaction);
5036
5112
  },
5113
+ async prepareToSign() {
5114
+ if (!hasTurnkeyWallet())
5115
+ throw new Error(OIDC_NO_WALLET);
5116
+ return ensureTurnkeySigningSession();
5117
+ },
5037
5118
  supportedTransactionVersions() {
5038
5119
  return hasTurnkeyWallet() ? ['legacy', 0, 1] : ['legacy', 0];
5039
5120
  },
@@ -6089,7 +6170,7 @@ async function getAuthProvider(config, fromStorage = false) {
6089
6170
  // manager as legacy email sessions. Human login should be started
6090
6171
  // with loginWithRedirect(); this provider is kept as the restore and
6091
6172
  // logout surface for those sessions.
6092
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-3tuw_aDK.js'); })).EmailAuthProvider();
6173
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-wOISnCic.js'); })).EmailAuthProvider();
6093
6174
  break;
6094
6175
  case "phantom": {
6095
6176
  // First-class Solana WALLET LOGIN (the poof/TaroBase-style "connect
@@ -6131,7 +6212,7 @@ async function getAuthProvider(config, fromStorage = false) {
6131
6212
  // (bounded-login-widget.ts), so registration never counts as
6132
6213
  // evidence the user has a wallet.
6133
6214
  await ensureSolanaMobileWalletRegistered(config, configuredNetwork);
6134
- const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BqYJQDGu.js'); });
6215
+ const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BsTfBAD4.js'); });
6135
6216
  currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
6136
6217
  break;
6137
6218
  }
@@ -6144,7 +6225,7 @@ async function getAuthProvider(config, fromStorage = false) {
6144
6225
  // Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
6145
6226
  // to point at a specific wallet or set chainId/domain.
6146
6227
  const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
6147
- const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-CUNTCT-a.js'); });
6228
+ const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-DQMYqPus.js'); });
6148
6229
  currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
6149
6230
  break;
6150
6231
  }
@@ -6169,7 +6250,7 @@ async function getAuthProvider(config, fromStorage = false) {
6169
6250
  break;
6170
6251
  case "guest":
6171
6252
  // Anonymous auth: a device-local ed25519 keypair signs the challenge.
6172
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-_jdqZKUo.js'); })).GuestAuthProvider();
6253
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-xap-VQBP.js'); })).GuestAuthProvider();
6173
6254
  break;
6174
6255
  }
6175
6256
  if (!currentAuthProvider) {
@@ -6231,7 +6312,7 @@ async function signInAnonymously() {
6231
6312
  // Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
6232
6313
  // the main bundle for data-only apps. Specifier is a static string literal
6233
6314
  // so bundle-splitting can see it.
6234
- const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-_jdqZKUo.js'); })).GuestAuthProvider();
6315
+ const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-xap-VQBP.js'); })).GuestAuthProvider();
6235
6316
  setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
6236
6317
  // adoptSessionProvider awaits only getConfig() (already resolved here) and then
6237
6318
  // runs every write - provider/method/config/marker/user - in one synchronous
@@ -6402,7 +6483,7 @@ function ensureSharedWalletLoginReady() {
6402
6483
  if (!sharedWalletReady) {
6403
6484
  sharedWalletReady = (async () => {
6404
6485
  await core.getConfig();
6405
- await Promise.resolve().then(function () { return require('./injected-wallet-provider-BqYJQDGu.js'); });
6486
+ await Promise.resolve().then(function () { return require('./injected-wallet-provider-BsTfBAD4.js'); });
6406
6487
  })().catch((error) => {
6407
6488
  sharedWalletReady = null;
6408
6489
  throw error;
@@ -8582,35 +8663,29 @@ async function getParsedTransactionCompat(connection, signature) {
8582
8663
  }
8583
8664
  }
8584
8665
  /**
8585
- * Polls getSignatureStatuses until the transaction is confirmed, then checks for errors.
8586
- * Throws if the transaction failed on-chain. Returns parsed transaction info on success.
8666
+ * Waits for a broadcast signature by HTTPS status polling, fenced on the blockhash
8667
+ * lifetime it was signed against (core's `confirmSignature`), then checks for an
8668
+ * on-chain error. Throws if the transaction failed on-chain or was not seen before
8669
+ * the fence closed. Returns parsed transaction info on success.
8587
8670
  */
8588
- async function confirmAndCheckTransaction(connection, signature) {
8671
+ async function confirmAndCheckTransaction(connection, signature, lastValidBlockHeight) {
8589
8672
  var _a;
8590
- const maxAttempts = 15;
8591
- for (let i = 0; i < maxAttempts; i++) {
8592
- const { value } = await connection.getSignatureStatuses([signature]);
8593
- const status = value[0];
8594
- if (status) {
8595
- if (status.err) {
8596
- let logMessages;
8597
- try {
8598
- const txInfo = await getParsedTransactionCompat(connection, signature);
8599
- logMessages = (_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.logMessages;
8600
- }
8601
- catch (_b) {
8602
- // Log retrieval is diagnostic only; the on-chain error is the verdict.
8603
- }
8604
- const errorMessage = extractTransactionError(status.err, logMessages);
8605
- throw new Error(`Transaction failed: ${errorMessage}`);
8606
- }
8607
- if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized') {
8608
- return await getParsedTransactionCompat(connection, signature);
8609
- }
8673
+ const confirmation = await core.confirmSignature(connection, { signature, lastValidBlockHeight });
8674
+ if (!confirmation.landed) {
8675
+ throw new Error(`Transaction ${signature} was not confirmed: ${confirmation.reason}. Check its status before sending it again.`);
8676
+ }
8677
+ if (confirmation.status.err) {
8678
+ let logMessages;
8679
+ try {
8680
+ const txInfo = await getParsedTransactionCompat(connection, signature);
8681
+ logMessages = (_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.logMessages;
8610
8682
  }
8611
- await new Promise(resolve => setTimeout(resolve, 1000));
8683
+ catch (_b) {
8684
+ // Log retrieval is diagnostic only; the on-chain error is the verdict.
8685
+ }
8686
+ throw new Error(`Transaction failed: ${extractTransactionError(confirmation.status.err, logMessages)}`);
8612
8687
  }
8613
- throw new Error('Transaction confirmation timeout');
8688
+ return getParsedTransactionCompat(connection, signature);
8614
8689
  }
8615
8690
 
8616
8691
  /**
@@ -8780,24 +8855,30 @@ class PrivyExpoProvider {
8780
8855
  // included), so refreshing the blockhash after any signer (sponsor / co-signer)
8781
8856
  // has signed silently invalidates their signature. Only refresh while the
8782
8857
  // transaction is still unsigned; once a real signature is present, submit the
8783
- // caller's transaction verbatim.
8858
+ // caller's transaction verbatim. Either way the confirmation is fenced on a
8859
+ // lifetime read now: for a pre-signed transaction that is a superset of the
8860
+ // one its signers fenced on, never a shorter wait.
8861
+ let lastValidBlockHeight;
8784
8862
  if (!transactionHasSignature(transaction)) {
8863
+ const { blockhash, lastValidBlockHeight: freshLastValid } = await connection.getLatestBlockhash('confirmed');
8864
+ lastValidBlockHeight = freshLastValid;
8785
8865
  const isLegacyTx = 'recentBlockhash' in transaction &&
8786
8866
  !('message' in transaction && 'staticAccountKeys' in transaction.message);
8787
8867
  if (isLegacyTx) {
8788
8868
  const legacyTx = transaction;
8789
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
8790
8869
  legacyTx.recentBlockhash = blockhash;
8791
8870
  legacyTx.lastValidBlockHeight = lastValidBlockHeight;
8792
8871
  legacyTx.feePayer = feePayer || new PublicKey(wallet.address);
8793
8872
  }
8794
8873
  else {
8795
8874
  const versionedTx = transaction;
8796
- const { blockhash } = await connection.getLatestBlockhash('confirmed');
8797
8875
  versionedTx.message.recentBlockhash = blockhash;
8798
8876
  }
8799
8877
  }
8800
- const { signature } = await this.signAndSubmitInternal(transaction, wallet, connection);
8878
+ else {
8879
+ ({ lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed'));
8880
+ }
8881
+ const { signature } = await this.signAndSubmitInternal(transaction, wallet, connection, lastValidBlockHeight);
8801
8882
  return signature;
8802
8883
  }
8803
8884
  async restoreSession(beforeCommit) {
@@ -8868,11 +8949,11 @@ class PrivyExpoProvider {
8868
8949
  `Sign in again before ${action}.`);
8869
8950
  }
8870
8951
  }
8871
- async signAndSubmitInternal(transaction, wallet, connection) {
8952
+ async signAndSubmitInternal(transaction, wallet, connection, lastValidBlockHeight) {
8872
8953
  // Use Privy's combined sign+send
8873
8954
  const result = await wallet.signAndSendTransaction(transaction, connection);
8874
8955
  const signature = result.signature;
8875
- const txInfo = await confirmAndCheckTransaction(connection, signature);
8956
+ const txInfo = await confirmAndCheckTransaction(connection, signature, lastValidBlockHeight);
8876
8957
  return { signature, txInfo };
8877
8958
  }
8878
8959
  // The constructor rpcUrl wins, then init()'s rpcUrl, then the platform RPC
@@ -8925,6 +9006,7 @@ exports.bufferExports = bufferExports;
8925
9006
  exports.builds = builds;
8926
9007
  exports.completeLoginFromRedirect = completeLoginFromRedirect;
8927
9008
  exports.confirmAndCheckTransaction = confirmAndCheckTransaction;
9009
+ exports.ensureTurnkeySigningSession = ensureTurnkeySigningSession;
8928
9010
  exports.getAuthLoading = getAuthLoading;
8929
9011
  exports.getAuthProvider = getAuthProvider;
8930
9012
  exports.getCurrentUser = getCurrentUser;
@@ -8966,4 +9048,4 @@ exports.useBuildRun = useBuildRun;
8966
9048
  exports.useQuery = useQuery;
8967
9049
  exports.waitForAuthReady = waitForAuthReady;
8968
9050
  exports.walletStandardFeatureName = walletStandardFeatureName;
8969
- //# sourceMappingURL=index.native-CMNMw3Pe.js.map
9051
+ //# sourceMappingURL=index.native-B-pjNetI.js.map