@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
@@ -295,6 +295,10 @@ class OffchainAuthProvider {
295
295
  async signTransaction(tx) {
296
296
  return this.wrappedProvider.signTransaction(tx);
297
297
  }
298
+ async prepareToSign() {
299
+ var _a, _b, _c;
300
+ return (_c = (await ((_b = (_a = this.wrappedProvider).prepareToSign) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : 'ready';
301
+ }
298
302
  /**
299
303
  * Sign and submit transaction - not supported in poofnet environment.
300
304
  * See the real providers (PhantomWalletProvider, SolanaKeypairProvider)
@@ -4390,7 +4394,7 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4390
4394
  const requestId = String(ex.request.requestId);
4391
4395
  // Serialize: the approve card is modal, and one warm frame handles one request at a time.
4392
4396
  const run = m.chain.then(() => new Promise((resolve, reject) => {
4393
- var _a;
4397
+ var _a, _b;
4394
4398
  let settled = false;
4395
4399
  let usedFallback = false;
4396
4400
  (_a = ex.assertCurrent) === null || _a === void 0 ? void 0 : _a.call(ex);
@@ -4433,16 +4437,20 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4433
4437
  /* frame gone */
4434
4438
  }
4435
4439
  };
4440
+ const dismiss = () => {
4441
+ if (!ex.silent)
4442
+ hideModal(m);
4443
+ };
4436
4444
  const goFallback = () => {
4437
4445
  if (usedFallback || settled)
4438
4446
  return;
4439
4447
  usedFallback = true;
4440
- hideModal(m);
4448
+ dismiss();
4441
4449
  finish(() => popupFallback().then(resolve, reject));
4442
4450
  };
4443
4451
  m.onBackdrop = () => {
4444
4452
  cancelInFrame();
4445
- hideModal(m);
4453
+ dismiss();
4446
4454
  finish(() => reject(new Error("cancelled")));
4447
4455
  };
4448
4456
  m.onIframeMessage = (d) => {
@@ -4457,17 +4465,18 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4457
4465
  if (d.type === "bounded:turnkey:result" && d.requestId === requestId) {
4458
4466
  const outcome = ex.onResult(d);
4459
4467
  if ("error" in outcome) {
4460
- hideModal(m);
4468
+ dismiss();
4461
4469
  finish(() => reject(new Error(outcome.error)));
4462
4470
  return;
4463
4471
  }
4464
4472
  if (outcome.done) {
4465
- hideModal(m);
4473
+ dismiss();
4466
4474
  finish(() => resolve(outcome.value));
4467
4475
  }
4468
4476
  }
4469
4477
  };
4470
- showModal(m);
4478
+ if (!ex.silent)
4479
+ showModal(m);
4471
4480
  if (m.iframeReady)
4472
4481
  send();
4473
4482
  // If the frame never loads, degrade to the popup (best-effort - a post-load
@@ -4480,10 +4489,10 @@ async function runWidget(url, signerOrigin, ex, popupFallback) {
4480
4489
  ceilingTimer = window.setTimeout(() => {
4481
4490
  if (!settled) {
4482
4491
  cancelInFrame();
4483
- hideModal(m);
4492
+ dismiss();
4484
4493
  finish(() => reject(new Error("Wallet approval timed out.")));
4485
4494
  }
4486
- }, 5 * 60 * 1000);
4495
+ }, (_b = ex.ceilingMs) !== null && _b !== void 0 ? _b : 5 * 60 * 1000);
4487
4496
  }));
4488
4497
  m.chain = run.then(() => undefined, () => undefined);
4489
4498
  return run;
@@ -5065,6 +5074,59 @@ async function clearTurnkeySigningSession(idToken) {
5065
5074
  function hasTurnkeyWallet() {
5066
5075
  return activeTurnkeyAddress() !== null;
5067
5076
  }
5077
+ /** The signer frame could not take the exchange: it never loaded, or a page from before the request existed stays silent. */
5078
+ class SignerFrameUnavailable extends Error {
5079
+ constructor() { super('The Bounded signer frame did not answer.'); }
5080
+ }
5081
+ /** How long a silent session probe may wait for the frame before the write goes on without it. */
5082
+ const SESSION_PROBE_MS = 8000;
5083
+ /**
5084
+ * Make the wallet's 24-hour signing session live BEFORE a transaction exists. Without one the
5085
+ * approve card must first collect an emailed code, which takes longer than a transaction's
5086
+ * blockhash lifetime (about 33 seconds on mainnet in late 2026), so a transaction built before
5087
+ * the code is dead by the time it is signed. A live session is found with nothing shown: the
5088
+ * warm frame answers a silent probe, and it holds the session even where the browser blocks its
5089
+ * storage. Only a lapsed session opens the card, which runs the code ceremony and closes without
5090
+ * signing anything. Resolves `'established'` when that ceremony ran, else `'ready'`.
5091
+ *
5092
+ * Both exchanges run in the warm frame only, since it is the frame that signs next and a popup
5093
+ * keeps its session to itself. Where the frame cannot answer (an embedder that blocks it, or a
5094
+ * signer page from before this request existed), the write goes on the way it always did: the
5095
+ * approve card collects the code itself, and an expired build is built again.
5096
+ */
5097
+ async function ensureTurnkeySigningSession() {
5098
+ if (!hasDOM$3())
5099
+ throw new Error('Turnkey embedded-wallet signing is only available in the browser (trusted wallet UI).');
5100
+ const context = await turnkeySignerPage();
5101
+ context.assertCurrent();
5102
+ if (hasWarmSignerFrame(context.key) && walletSessionState(context.key).status === 'ready')
5103
+ return 'ready';
5104
+ const { url, origin } = context;
5105
+ const authorization = await fetchActionAuthorization('createWallet', context);
5106
+ const frameOnly = () => Promise.reject(new SignerFrameUnavailable());
5107
+ const exchange = (probeOnly) => ({
5108
+ context: context.key, assertCurrent: context.assertCurrent,
5109
+ request: Object.assign({ type: 'bounded:turnkey:session', requestId: `tksession_${Date.now()}_${++requestSeq}`, authorization }, (probeOnly ? { probeOnly: true } : {})),
5110
+ onResult: (d) => d.ok ? { done: true, value: d } : { error: String(d.error || 'The signing session could not be established') },
5111
+ });
5112
+ const probed = await runWidget(url, origin, Object.assign(Object.assign({}, exchange(true)), { silent: true, ceilingMs: SESSION_PROBE_MS }), frameOnly)
5113
+ .catch(() => null);
5114
+ if (!probed)
5115
+ return 'ready';
5116
+ let result = probed;
5117
+ if (result.ready !== true) {
5118
+ try {
5119
+ result = await runWidget(url, origin, exchange(false), frameOnly);
5120
+ }
5121
+ catch (error) {
5122
+ if (error instanceof SignerFrameUnavailable)
5123
+ return 'ready';
5124
+ throw error;
5125
+ }
5126
+ }
5127
+ setWalletSessionState(context.key, { status: 'ready', expiresAt: Number(result.signingSessionExpiresAt) });
5128
+ return result.established === true ? 'established' : 'ready';
5129
+ }
5068
5130
  /**
5069
5131
  * Get-or-create the user's non-custodial Turnkey wallet, resolving with its stable
5070
5132
  * Solana address. Creation never prompts: on first use the signer silently provisions
@@ -5253,10 +5315,9 @@ async function signAndSubmitTransactionWithTurnkey(transaction, feePayer) {
5253
5315
  // has signed silently invalidates their signature - signTransactionWithTurnkey only ADDS the
5254
5316
  // Turnkey signature, it never re-signs the others. So only refresh the blockhash while the
5255
5317
  // transaction is still unsigned; once a real signature is present, preserve the caller's message
5256
- // verbatim and confirm against the blockhash it already carries.
5257
- const hasSignature = transactionHasSignature$1(transaction);
5258
- let confirmBlockhash = blockhash;
5259
- if (!hasSignature) {
5318
+ // verbatim. The confirmation is fenced on the lifetime read above either way: for a pre-signed
5319
+ // transaction that is a superset of the one its signers fenced on, never a shorter wait.
5320
+ if (!transactionHasSignature$1(transaction)) {
5260
5321
  if (isLegacy) {
5261
5322
  const legacy = transaction;
5262
5323
  legacy.recentBlockhash = blockhash;
@@ -5272,19 +5333,17 @@ async function signAndSubmitTransactionWithTurnkey(transaction, feePayer) {
5272
5333
  transaction.message.recentBlockhash = blockhash;
5273
5334
  }
5274
5335
  }
5275
- else {
5276
- confirmBlockhash = (isLegacy
5277
- ? transaction.recentBlockhash
5278
- : transaction.message.recentBlockhash) || blockhash;
5279
- }
5280
5336
  const signed = await signTransactionWithTurnkey(transaction);
5281
5337
  const signature = await connection.sendRawTransaction(signed.serialize(), {
5282
5338
  skipPreflight: false,
5283
5339
  maxRetries: 3,
5284
5340
  });
5285
- const confirmation = await connection.confirmTransaction({ signature, blockhash: confirmBlockhash, lastValidBlockHeight }, 'confirmed');
5286
- if (confirmation.value.err) {
5287
- throw new Error(`Turnkey transaction failed: ${JSON.stringify(confirmation.value.err)}`);
5341
+ const confirmation = await core.confirmSignature(connection, { signature, lastValidBlockHeight });
5342
+ if (!confirmation.landed) {
5343
+ throw new Error(`Turnkey transaction ${signature} was not confirmed: ${confirmation.reason}. Check its status before sending it again.`);
5344
+ }
5345
+ if (confirmation.status.err) {
5346
+ throw new Error(`Turnkey transaction failed: ${JSON.stringify(confirmation.status.err)}`);
5288
5347
  }
5289
5348
  return signature;
5290
5349
  }
@@ -5300,6 +5359,7 @@ async function getTurnkeyWalletRecoveryUrl() {
5300
5359
  var turnkeySignerBridge = /*#__PURE__*/Object.freeze({
5301
5360
  __proto__: null,
5302
5361
  clearTurnkeySigningSession: clearTurnkeySigningSession,
5362
+ ensureTurnkeySigningSession: ensureTurnkeySigningSession,
5303
5363
  getOrCreateTurnkeyWallet: getOrCreateTurnkeyWallet,
5304
5364
  getTurnkeyWalletRecoveryUrl: getTurnkeyWalletRecoveryUrl,
5305
5365
  getTurnkeyWalletSessionState: getTurnkeyWalletSessionState,
@@ -5383,6 +5443,11 @@ const oidcProviderSingleton = {
5383
5443
  throw new Error(OIDC_NO_WALLET);
5384
5444
  return signTransactionV1WithTurnkey(transaction);
5385
5445
  },
5446
+ async prepareToSign() {
5447
+ if (!hasTurnkeyWallet())
5448
+ throw new Error(OIDC_NO_WALLET);
5449
+ return ensureTurnkeySigningSession();
5450
+ },
5386
5451
  supportedTransactionVersions() {
5387
5452
  return hasTurnkeyWallet() ? ['legacy', 0, 1] : ['legacy', 0];
5388
5453
  },
@@ -6496,7 +6561,7 @@ async function getAuthProvider(config, fromStorage = false) {
6496
6561
  // manager as legacy email sessions. Human login should be started
6497
6562
  // with loginWithRedirect(); this provider is kept as the restore and
6498
6563
  // logout surface for those sessions.
6499
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-CjbJ8wK1.js'); })).EmailAuthProvider();
6564
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-DyzhiN9Y.js'); })).EmailAuthProvider();
6500
6565
  break;
6501
6566
  case "phantom": {
6502
6567
  // First-class Solana WALLET LOGIN (the poof/TaroBase-style "connect
@@ -6538,7 +6603,7 @@ async function getAuthProvider(config, fromStorage = false) {
6538
6603
  // (bounded-login-widget.ts), so registration never counts as
6539
6604
  // evidence the user has a wallet.
6540
6605
  await ensureSolanaMobileWalletRegistered(config, configuredNetwork);
6541
- const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6606
+ const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-B8QTPxf6.js'); });
6542
6607
  currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
6543
6608
  break;
6544
6609
  }
@@ -6551,7 +6616,7 @@ async function getAuthProvider(config, fromStorage = false) {
6551
6616
  // Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
6552
6617
  // to point at a specific wallet or set chainId/domain.
6553
6618
  const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
6554
- const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-qB_GQ9ih.js'); });
6619
+ const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-CKAv4Qxh.js'); });
6555
6620
  currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
6556
6621
  break;
6557
6622
  }
@@ -6576,7 +6641,7 @@ async function getAuthProvider(config, fromStorage = false) {
6576
6641
  break;
6577
6642
  case "guest":
6578
6643
  // Anonymous auth: a device-local ed25519 keypair signs the challenge.
6579
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-ClCOa69H.js'); })).GuestAuthProvider();
6644
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-Br3iM3O3.js'); })).GuestAuthProvider();
6580
6645
  break;
6581
6646
  }
6582
6647
  if (!currentAuthProvider) {
@@ -6638,7 +6703,7 @@ async function signInAnonymously() {
6638
6703
  // Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
6639
6704
  // the main bundle for data-only apps. Specifier is a static string literal
6640
6705
  // so bundle-splitting can see it.
6641
- const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-ClCOa69H.js'); })).GuestAuthProvider();
6706
+ const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-Br3iM3O3.js'); })).GuestAuthProvider();
6642
6707
  setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
6643
6708
  // adoptSessionProvider awaits only getConfig() (already resolved here) and then
6644
6709
  // runs every write - provider/method/config/marker/user - in one synchronous
@@ -6809,7 +6874,7 @@ function ensureSharedWalletLoginReady() {
6809
6874
  if (!sharedWalletReady) {
6810
6875
  sharedWalletReady = (async () => {
6811
6876
  await core.getConfig();
6812
- await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6877
+ await Promise.resolve().then(function () { return require('./injected-wallet-provider-B8QTPxf6.js'); });
6813
6878
  })().catch((error) => {
6814
6879
  sharedWalletReady = null;
6815
6880
  throw error;
@@ -6914,7 +6979,7 @@ async function loginWithWallet(options) {
6914
6979
  await ensureSharedWalletLoginReady();
6915
6980
  else
6916
6981
  await ensureWalletLoginReady();
6917
- const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6982
+ const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-B8QTPxf6.js'); });
6918
6983
  // Keep the RAW wallet provider: the offchain wrapper forwards only a fixed
6919
6984
  // set of methods, so cleanup below must speak to the provider that actually
6920
6985
  // holds the config rather than to whatever is wrapping it.
@@ -11577,35 +11642,29 @@ async function getParsedTransactionCompat(connection, signature) {
11577
11642
  }
11578
11643
  }
11579
11644
  /**
11580
- * Polls getSignatureStatuses until the transaction is confirmed, then checks for errors.
11581
- * Throws if the transaction failed on-chain. Returns parsed transaction info on success.
11645
+ * Waits for a broadcast signature by HTTPS status polling, fenced on the blockhash
11646
+ * lifetime it was signed against (core's `confirmSignature`), then checks for an
11647
+ * on-chain error. Throws if the transaction failed on-chain or was not seen before
11648
+ * the fence closed. Returns parsed transaction info on success.
11582
11649
  */
11583
- async function confirmAndCheckTransaction(connection, signature) {
11650
+ async function confirmAndCheckTransaction(connection, signature, lastValidBlockHeight) {
11584
11651
  var _a;
11585
- const maxAttempts = 15;
11586
- for (let i = 0; i < maxAttempts; i++) {
11587
- const { value } = await connection.getSignatureStatuses([signature]);
11588
- const status = value[0];
11589
- if (status) {
11590
- if (status.err) {
11591
- let logMessages;
11592
- try {
11593
- const txInfo = await getParsedTransactionCompat(connection, signature);
11594
- logMessages = (_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.logMessages;
11595
- }
11596
- catch (_b) {
11597
- // Log retrieval is diagnostic only; the on-chain error is the verdict.
11598
- }
11599
- const errorMessage = extractTransactionError(status.err, logMessages);
11600
- throw new Error(`Transaction failed: ${errorMessage}`);
11601
- }
11602
- if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized') {
11603
- return await getParsedTransactionCompat(connection, signature);
11604
- }
11652
+ const confirmation = await core.confirmSignature(connection, { signature, lastValidBlockHeight });
11653
+ if (!confirmation.landed) {
11654
+ throw new Error(`Transaction ${signature} was not confirmed: ${confirmation.reason}. Check its status before sending it again.`);
11655
+ }
11656
+ if (confirmation.status.err) {
11657
+ let logMessages;
11658
+ try {
11659
+ const txInfo = await getParsedTransactionCompat(connection, signature);
11660
+ logMessages = (_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.logMessages;
11605
11661
  }
11606
- await new Promise(resolve => setTimeout(resolve, 1000));
11662
+ catch (_b) {
11663
+ // Log retrieval is diagnostic only; the on-chain error is the verdict.
11664
+ }
11665
+ throw new Error(`Transaction failed: ${extractTransactionError(confirmation.status.err, logMessages)}`);
11607
11666
  }
11608
- throw new Error('Transaction confirmation timeout');
11667
+ return getParsedTransactionCompat(connection, signature);
11609
11668
  }
11610
11669
 
11611
11670
  /**
@@ -11775,24 +11834,30 @@ class PrivyExpoProvider {
11775
11834
  // included), so refreshing the blockhash after any signer (sponsor / co-signer)
11776
11835
  // has signed silently invalidates their signature. Only refresh while the
11777
11836
  // transaction is still unsigned; once a real signature is present, submit the
11778
- // caller's transaction verbatim.
11837
+ // caller's transaction verbatim. Either way the confirmation is fenced on a
11838
+ // lifetime read now: for a pre-signed transaction that is a superset of the
11839
+ // one its signers fenced on, never a shorter wait.
11840
+ let lastValidBlockHeight;
11779
11841
  if (!transactionHasSignature(transaction)) {
11842
+ const { blockhash, lastValidBlockHeight: freshLastValid } = await connection.getLatestBlockhash('confirmed');
11843
+ lastValidBlockHeight = freshLastValid;
11780
11844
  const isLegacyTx = 'recentBlockhash' in transaction &&
11781
11845
  !('message' in transaction && 'staticAccountKeys' in transaction.message);
11782
11846
  if (isLegacyTx) {
11783
11847
  const legacyTx = transaction;
11784
- const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
11785
11848
  legacyTx.recentBlockhash = blockhash;
11786
11849
  legacyTx.lastValidBlockHeight = lastValidBlockHeight;
11787
11850
  legacyTx.feePayer = feePayer || new PublicKey(wallet.address);
11788
11851
  }
11789
11852
  else {
11790
11853
  const versionedTx = transaction;
11791
- const { blockhash } = await connection.getLatestBlockhash('confirmed');
11792
11854
  versionedTx.message.recentBlockhash = blockhash;
11793
11855
  }
11794
11856
  }
11795
- const { signature } = await this.signAndSubmitInternal(transaction, wallet, connection);
11857
+ else {
11858
+ ({ lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed'));
11859
+ }
11860
+ const { signature } = await this.signAndSubmitInternal(transaction, wallet, connection, lastValidBlockHeight);
11796
11861
  return signature;
11797
11862
  }
11798
11863
  async restoreSession(beforeCommit) {
@@ -11863,11 +11928,11 @@ class PrivyExpoProvider {
11863
11928
  `Sign in again before ${action}.`);
11864
11929
  }
11865
11930
  }
11866
- async signAndSubmitInternal(transaction, wallet, connection) {
11931
+ async signAndSubmitInternal(transaction, wallet, connection, lastValidBlockHeight) {
11867
11932
  // Use Privy's combined sign+send
11868
11933
  const result = await wallet.signAndSendTransaction(transaction, connection);
11869
11934
  const signature = result.signature;
11870
- const txInfo = await confirmAndCheckTransaction(connection, signature);
11935
+ const txInfo = await confirmAndCheckTransaction(connection, signature, lastValidBlockHeight);
11871
11936
  return { signature, txInfo };
11872
11937
  }
11873
11938
  // The constructor rpcUrl wins, then init()'s rpcUrl, then the platform RPC
@@ -12323,6 +12388,7 @@ exports.disconnect = disconnect;
12323
12388
  exports.disputeVenueEscrow = disputeVenueEscrow;
12324
12389
  exports.ensureSharedWalletLoginReady = ensureSharedWalletLoginReady;
12325
12390
  exports.ensureSignedIn = ensureSignedIn;
12391
+ exports.ensureTurnkeySigningSession = ensureTurnkeySigningSession;
12326
12392
  exports.ensureWalletLoginReady = ensureWalletLoginReady;
12327
12393
  exports.firstStandardWalletProvider = firstStandardWalletProvider;
12328
12394
  exports.fundVenueEscrow = fundVenueEscrow;
@@ -12374,4 +12440,4 @@ exports.useAuth = useAuth;
12374
12440
  exports.useBuildRun = useBuildRun;
12375
12441
  exports.useQuery = useQuery;
12376
12442
  exports.waitForAuthReady = waitForAuthReady;
12377
- //# sourceMappingURL=index-B2HWEA13.js.map
12443
+ //# sourceMappingURL=index-B4_eKphx.js.map