@pooflabs/web 0.0.85-rc3 → 0.0.87

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 (65) hide show
  1. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +43 -0
  2. package/dist/{index-B5qYY4YM.js → index-B-x9RTF7.js} +2 -2
  3. package/dist/index-B-x9RTF7.js.map +1 -0
  4. package/dist/{index-BaKs3A8s.js → index-BKN0IwAx.js} +3054 -300
  5. package/dist/index-BKN0IwAx.js.map +1 -0
  6. package/dist/{index-C4AnWFs_.esm.js → index-BTwX7FYW.esm.js} +425 -119
  7. package/dist/index-BTwX7FYW.esm.js.map +1 -0
  8. package/dist/{index-BzeiIIwF.js → index-DYBdUxnT.js} +3055 -301
  9. package/dist/index-DYBdUxnT.js.map +1 -0
  10. package/dist/{index-bEXLwE7_.js → index-Dj1tZr6X.js} +426 -118
  11. package/dist/index-Dj1tZr6X.js.map +1 -0
  12. package/dist/{index-dqqR5q7b.esm.js → index-DofM-ue2.esm.js} +3054 -301
  13. package/dist/index-DofM-ue2.esm.js.map +1 -0
  14. package/dist/index-_k6pjuwx.esm.js +6 -0
  15. package/dist/index-_k6pjuwx.esm.js.map +1 -0
  16. package/dist/{index-BE-VWSJT.esm.js → index-x7a-wH2l.esm.js} +3055 -300
  17. package/dist/index-x7a-wH2l.esm.js.map +1 -0
  18. package/dist/{index.browser-D8ttddP4.esm.js → index.browser-Cndx2raY.esm.js} +506 -1876
  19. package/dist/index.browser-Cndx2raY.esm.js.map +1 -0
  20. package/dist/{index.browser-CN6obNQM.js → index.browser-D7-FFk3q.js} +506 -1876
  21. package/dist/index.browser-D7-FFk3q.js.map +1 -0
  22. package/dist/{index.browser-CZIJCtms.js → index.browser-DlA-NKvf.js} +1223 -2565
  23. package/dist/index.browser-DlA-NKvf.js.map +1 -0
  24. package/dist/{index.browser-DQIwLToJ.esm.js → index.browser-nVGFrIHK.esm.js} +1223 -2565
  25. package/dist/index.browser-nVGFrIHK.esm.js.map +1 -0
  26. package/dist/index.esm.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/{index.native-DLziTime.esm.js → index.native-19VsREMJ.esm.js} +43 -62
  29. package/dist/index.native-19VsREMJ.esm.js.map +1 -0
  30. package/dist/{index.native-pG1NTZ0f.js → index.native-D8vj3Lbr.js} +44 -61
  31. package/dist/index.native-D8vj3Lbr.js.map +1 -0
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +1 -1
  34. package/dist/{phantom-wallet-provider-zBp7-uEw.js → phantom-wallet-provider-BlZZa_3s.js} +4 -4
  35. package/dist/{phantom-wallet-provider-zBp7-uEw.js.map → phantom-wallet-provider-BlZZa_3s.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-CP6NXRwG.esm.js → phantom-wallet-provider-Bz3qEFzX.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-CP6NXRwG.esm.js.map → phantom-wallet-provider-Bz3qEFzX.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-CoyW5Gdg.js → privy-wallet-provider-CqCgq7uT.js} +3 -3
  39. package/dist/privy-wallet-provider-CqCgq7uT.js.map +1 -0
  40. package/dist/{privy-wallet-provider-CGYvf3-r.esm.js → privy-wallet-provider-DgNFzioA.esm.js} +3 -3
  41. package/dist/privy-wallet-provider-DgNFzioA.esm.js.map +1 -0
  42. package/dist/{solana-mobile-wallet-provider-B8rHfsPN.esm.js → solana-mobile-wallet-provider-EeQsBTdr.esm.js} +385 -60
  43. package/dist/solana-mobile-wallet-provider-EeQsBTdr.esm.js.map +1 -0
  44. package/dist/{solana-mobile-wallet-provider-CN-D_H4l.js → solana-mobile-wallet-provider-VqIGfdMV.js} +385 -60
  45. package/dist/solana-mobile-wallet-provider-VqIGfdMV.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/index-B5qYY4YM.js.map +0 -1
  48. package/dist/index-BE-VWSJT.esm.js.map +0 -1
  49. package/dist/index-BaKs3A8s.js.map +0 -1
  50. package/dist/index-BzeiIIwF.js.map +0 -1
  51. package/dist/index-C4AnWFs_.esm.js.map +0 -1
  52. package/dist/index-TzHXEf3-.esm.js +0 -6
  53. package/dist/index-TzHXEf3-.esm.js.map +0 -1
  54. package/dist/index-bEXLwE7_.js.map +0 -1
  55. package/dist/index-dqqR5q7b.esm.js.map +0 -1
  56. package/dist/index.browser-CN6obNQM.js.map +0 -1
  57. package/dist/index.browser-CZIJCtms.js.map +0 -1
  58. package/dist/index.browser-D8ttddP4.esm.js.map +0 -1
  59. package/dist/index.browser-DQIwLToJ.esm.js.map +0 -1
  60. package/dist/index.native-DLziTime.esm.js.map +0 -1
  61. package/dist/index.native-pG1NTZ0f.js.map +0 -1
  62. package/dist/privy-wallet-provider-CGYvf3-r.esm.js.map +0 -1
  63. package/dist/privy-wallet-provider-CoyW5Gdg.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-B8rHfsPN.esm.js.map +0 -1
  65. package/dist/solana-mobile-wallet-provider-CN-D_H4l.js.map +0 -1
@@ -22,6 +22,21 @@ function _interopNamespaceDefault(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
 
25
+ function _mergeNamespaces(n, m) {
26
+ m.forEach(function (e) {
27
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
28
+ if (k !== 'default' && !(k in n)) {
29
+ var d = Object.getOwnPropertyDescriptor(e, k);
30
+ Object.defineProperty(n, k, d.get ? d : {
31
+ enumerable: true,
32
+ get: function () { return e[k]; }
33
+ });
34
+ }
35
+ });
36
+ });
37
+ return Object.freeze(n);
38
+ }
39
+
25
40
  var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
26
41
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React$2);
27
42
 
@@ -6770,28 +6785,6 @@ class WebSessionManager {
6770
6785
  static async storeSession(address, accessToken, idToken, refreshToken) {
6771
6786
  if (typeof window === "undefined")
6772
6787
  return;
6773
- // JWT-wallet binding: refuse to store a session whose idToken is bound
6774
- // to a different wallet than `address`. Prevents races that would otherwise
6775
- // leave localStorage with mismatched address/token state.
6776
- try {
6777
- const payloadB64 = idToken.split(".")[1];
6778
- if (payloadB64) {
6779
- const payload = JSON.parse(this.decodeBase64Url(payloadB64));
6780
- const tokenWallet = payload["custom:walletAddress"];
6781
- if (tokenWallet && tokenWallet !== address) {
6782
- throw new Error(`[WebSessionManager] Refusing to store session: address (${address}) does not match idToken custom:walletAddress (${tokenWallet})`);
6783
- }
6784
- if (!tokenWallet) {
6785
- console.warn("[WebSessionManager] storeSession: idToken has no custom:walletAddress claim — writing without validation");
6786
- }
6787
- }
6788
- }
6789
- catch (err) {
6790
- if (typeof (err === null || err === void 0 ? void 0 : err.message) === "string" && err.message.includes("Refusing to store session")) {
6791
- throw err;
6792
- }
6793
- console.warn("[WebSessionManager] storeSession: failed to decode idToken for validation:", err);
6794
- }
6795
6788
  const config = await getConfig();
6796
6789
  const currentAppId = config.appId;
6797
6790
  localStorage.setItem(this.TAROBASE_SESSION_STORAGE_KEY, JSON.stringify({
@@ -9490,11 +9483,11 @@ function requireSrc$1 () {
9490
9483
  }
9491
9484
 
9492
9485
  var bs58$1;
9493
- var hasRequiredBs58;
9486
+ var hasRequiredBs58$1;
9494
9487
 
9495
- function requireBs58 () {
9496
- if (hasRequiredBs58) return bs58$1;
9497
- hasRequiredBs58 = 1;
9488
+ function requireBs58$1 () {
9489
+ if (hasRequiredBs58$1) return bs58$1;
9490
+ hasRequiredBs58$1 = 1;
9498
9491
  var basex = requireSrc$1();
9499
9492
  var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
9500
9493
 
@@ -9502,8 +9495,8 @@ function requireBs58 () {
9502
9495
  return bs58$1;
9503
9496
  }
9504
9497
 
9505
- var bs58Exports = requireBs58();
9506
- var bs58 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
9498
+ var bs58Exports$1 = requireBs58$1();
9499
+ var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports$1);
9507
9500
 
9508
9501
  // ─────────────────────────────────────────────────────────────
9509
9502
  // Local implementation of getSimulationComputeUnits
@@ -9765,7 +9758,7 @@ function loadKeypairFromEnv() {
9765
9758
  try {
9766
9759
  const secretKey = secret.trim().startsWith("[")
9767
9760
  ? Uint8Array.from(JSON.parse(secret))
9768
- : bs58.decode(secret.trim());
9761
+ : bs58$2.decode(secret.trim());
9769
9762
  return web3_js.Keypair.fromSecretKey(secretKey);
9770
9763
  }
9771
9764
  catch (err) {
@@ -11710,28 +11703,6 @@ class ReactNativeSessionManager {
11710
11703
  /* STORE */
11711
11704
  /* ------------------------------------------------------------------ */
11712
11705
  static async storeSession(address, accessToken, idToken, refreshToken) {
11713
- // JWT-wallet binding: refuse to store a session whose idToken is bound
11714
- // to a different wallet than `address`. Prevents races that would otherwise
11715
- // leave storage with mismatched address/token state.
11716
- try {
11717
- const payloadB64 = idToken.split(".")[1];
11718
- if (payloadB64) {
11719
- const payload = JSON.parse(this.decodeBase64Url(payloadB64));
11720
- const tokenWallet = payload["custom:walletAddress"];
11721
- if (tokenWallet && tokenWallet !== address) {
11722
- throw new Error(`[ReactNativeSessionManager] Refusing to store session: address (${address}) does not match idToken custom:walletAddress (${tokenWallet})`);
11723
- }
11724
- if (!tokenWallet) {
11725
- console.warn("[ReactNativeSessionManager] storeSession: idToken has no custom:walletAddress claim — writing without validation");
11726
- }
11727
- }
11728
- }
11729
- catch (err) {
11730
- if (typeof (err === null || err === void 0 ? void 0 : err.message) === "string" && err.message.includes("Refusing to store session")) {
11731
- throw err;
11732
- }
11733
- console.warn("[ReactNativeSessionManager] storeSession: failed to decode idToken for validation:", err);
11734
- }
11735
11706
  const config = await getConfig();
11736
11707
  const currentAppId = config.appId;
11737
11708
  this.getStorage().setItem(this.TAROBASE_SESSION_STORAGE_KEY, JSON.stringify({
@@ -15730,7 +15701,7 @@ async function loadDependencies() {
15730
15701
  const [reactModule, reactDomModule, phantomModule] = await Promise.all([
15731
15702
  import('react'),
15732
15703
  import('react-dom/client'),
15733
- Promise.resolve().then(function () { return require('./index-BaKs3A8s.js'); })
15704
+ Promise.resolve().then(function () { return require('./index-BKN0IwAx.js'); })
15734
15705
  ]);
15735
15706
  // Extract default export from ESM module namespace
15736
15707
  // Dynamic import() returns { default: Module, ...exports }, not the module directly
@@ -20388,16 +20359,26 @@ function requireSrc () {
20388
20359
  return src;
20389
20360
  }
20390
20361
 
20391
- var srcExports = requireSrc();
20392
- var basex = /*@__PURE__*/getDefaultExportFromCjs$1(srcExports);
20362
+ var bs58;
20363
+ var hasRequiredBs58;
20393
20364
 
20394
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
20395
- var base58 = basex(ALPHABET);
20365
+ function requireBs58 () {
20366
+ if (hasRequiredBs58) return bs58;
20367
+ hasRequiredBs58 = 1;
20368
+ var basex = requireSrc();
20369
+ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
20370
+
20371
+ bs58 = basex(ALPHABET);
20372
+ return bs58;
20373
+ }
20374
+
20375
+ var bs58Exports = requireBs58();
20376
+ var base58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
20396
20377
 
20397
- var index = /*#__PURE__*/Object.freeze({
20378
+ var index = /*#__PURE__*/_mergeNamespaces({
20398
20379
  __proto__: null,
20399
20380
  default: base58
20400
- });
20381
+ }, [bs58Exports]);
20401
20382
 
20402
20383
  const SURFNET_RPC_URL$1 = "https://surfpool.fly.dev";
20403
20384
  let React;
@@ -21286,6 +21267,14 @@ var privyWalletProvider = /*#__PURE__*/Object.freeze({
21286
21267
  PrivyWalletProvider: PrivyWalletProvider
21287
21268
  });
21288
21269
 
21270
+ /**
21271
+ * Storage key for persisting the MWA auth_token across cold starts.
21272
+ * Holds JSON `{ token: string, address: string }`. Cleared by
21273
+ * `logout()`. Hydrated by the constructor on native so cold-start
21274
+ * doesn't force the user back into Phantom's approval flow when the
21275
+ * underlying wallet authorization is still valid.
21276
+ */
21277
+ const MWA_AUTH_TOKEN_STORAGE_KEY = 'tarobase_mwa_auth_token';
21289
21278
  /**
21290
21279
  * Detects whether the current environment is a mobile browser capable of
21291
21280
  * Mobile Wallet Adapter (MWA) communication.
@@ -21357,20 +21346,11 @@ function isMwaAssociationRetryable(e) {
21357
21346
  * so a second attempt skips the consent sheet, jumps straight to
21358
21347
  * Verify/Approve, and completes inside the timeout.
21359
21348
  */
21360
- async function withMwaAssociationRetry(label, fn) {
21361
- const t0 = Date.now();
21362
- console.log(`[MWA-DEBUG] ${label} attempt=1 start`);
21349
+ async function withMwaAssociationRetry(fn) {
21363
21350
  try {
21364
- const result = await fn();
21365
- console.log(`[MWA-DEBUG] ${label} attempt=1 ok (${Date.now() - t0}ms)`);
21366
- return result;
21351
+ return await fn();
21367
21352
  }
21368
21353
  catch (e) {
21369
- const info = findMwaError(e);
21370
- console.log(`[MWA-DEBUG] ${label} attempt=1 err (${Date.now() - t0}ms)`, {
21371
- outer: { name: e === null || e === void 0 ? void 0 : e.name, message: e === null || e === void 0 ? void 0 : e.message },
21372
- mwa: info,
21373
- });
21374
21354
  const retryable = isMwaAssociationRetryable(e);
21375
21355
  if (!retryable)
21376
21356
  throw e;
@@ -21379,21 +21359,11 @@ async function withMwaAssociationRetry(label, fn) {
21379
21359
  // so visibility-based waits fire too early. Use a fixed delay long
21380
21360
  // enough for Seeker to dismiss its sheet and the OS to release intent
21381
21361
  // state. 2.5s is empirically safe; tune from device traces if needed.
21382
- console.log(`[MWA-DEBUG] ${label} retryable (${retryable.code}); waiting 2500ms before retry`);
21383
21362
  await new Promise(r => setTimeout(r, 2500));
21384
- const t1 = Date.now();
21385
- console.log(`[MWA-DEBUG] ${label} attempt=2 start`);
21386
21363
  try {
21387
- const result = await fn();
21388
- console.log(`[MWA-DEBUG] ${label} attempt=2 ok (${Date.now() - t1}ms)`);
21389
- return result;
21364
+ return await fn();
21390
21365
  }
21391
21366
  catch (e2) {
21392
- const info2 = findMwaError(e2);
21393
- console.log(`[MWA-DEBUG] ${label} attempt=2 err (${Date.now() - t1}ms)`, {
21394
- outer: { name: e2 === null || e2 === void 0 ? void 0 : e2.name, message: e2 === null || e2 === void 0 ? void 0 : e2.message },
21395
- mwa: info2,
21396
- });
21397
21367
  // Only mask the error with the clean Seeker message when the
21398
21368
  // second failure is also an association-flavored error. If it's
21399
21369
  // a user cancel, wallet rejection, or unknown error, rethrow
@@ -21432,7 +21402,7 @@ async function withMwaAssociationRetry(label, fn) {
21432
21402
  * next tap is a new activation (a real retry). A timer-based retry would
21433
21403
  * just hit the same Chrome block. Cap at 3 attempts before giving up.
21434
21404
  */
21435
- async function awaitSignInGestureAndSign(label, theme, signFn) {
21405
+ async function awaitSignInGestureAndSign(theme, signFn) {
21436
21406
  if (typeof document === 'undefined' || typeof window === 'undefined') {
21437
21407
  // SSR / non-browser: skip the gesture, just call (the activation
21438
21408
  // model doesn't apply outside the browser).
@@ -21599,18 +21569,15 @@ async function awaitSignInGestureAndSign(label, theme, signFn) {
21599
21569
  finishReject(new Error('User cancelled wallet sign in'));
21600
21570
  };
21601
21571
  closeBtn.addEventListener('click', () => {
21602
- console.log(`[MWA-DEBUG] ${label} gesture: close clicked`);
21603
21572
  handleCancel();
21604
21573
  });
21605
21574
  overlay.addEventListener('click', (e) => {
21606
21575
  if (e.target === overlay) {
21607
- console.log(`[MWA-DEBUG] ${label} gesture: overlay clicked (cancel)`);
21608
21576
  handleCancel();
21609
21577
  }
21610
21578
  });
21611
21579
  const onKeydown = (e) => {
21612
21580
  if (e.key === 'Escape') {
21613
- console.log(`[MWA-DEBUG] ${label} gesture: Escape pressed (cancel)`);
21614
21581
  handleCancel();
21615
21582
  }
21616
21583
  };
@@ -21620,7 +21587,6 @@ async function awaitSignInGestureAndSign(label, theme, signFn) {
21620
21587
  return;
21621
21588
  attemptCount++;
21622
21589
  const attempt = attemptCount;
21623
- console.log(`[MWA-DEBUG] ${label} gesture: button click attempt=${attempt}`);
21624
21590
  // Disable to prevent double-clicks while the wallet popup is up.
21625
21591
  button.disabled = true;
21626
21592
  setButtonDisabledStyle();
@@ -21632,29 +21598,17 @@ async function awaitSignInGestureAndSign(label, theme, signFn) {
21632
21598
  // so Chrome's transient user activation propagates to the
21633
21599
  // protocol's window.location.assign(associationUrl) inside
21634
21600
  // launchAssociation(). Do not `await` before calling.
21635
- const t0 = Date.now();
21636
- console.log(`[MWA-DEBUG] ${label} gesture: signMessage start (attempt=${attempt})`);
21637
21601
  signFn().then((results) => {
21638
- const elapsed = Date.now() - t0;
21639
21602
  if (!results || results.length === 0) {
21640
- console.log(`[MWA-DEBUG] ${label} gesture: signMessage returned empty (attempt=${attempt}, ${elapsed}ms)`);
21641
21603
  finishReject(new Error('MWA returned no signature'));
21642
21604
  return;
21643
21605
  }
21644
- console.log(`[MWA-DEBUG] ${label} gesture: signMessage ok (attempt=${attempt}, ${elapsed}ms)`);
21645
21606
  finishResolve(results[0]);
21646
21607
  }).catch((err) => {
21647
- const elapsed = Date.now() - t0;
21648
- const info = findMwaError(err);
21649
- console.log(`[MWA-DEBUG] ${label} gesture: signMessage err (attempt=${attempt}, ${elapsed}ms)`, {
21650
- outer: { name: err === null || err === void 0 ? void 0 : err.name, message: err === null || err === void 0 ? void 0 : err.message },
21651
- mwa: info,
21652
- });
21653
21608
  const retryable = isMwaAssociationRetryable(err);
21654
21609
  if (retryable && attempt < MAX_ATTEMPTS) {
21655
21610
  // Re-enable the button so the user's next tap provides a
21656
21611
  // fresh user activation. Show inline error text.
21657
- console.log(`[MWA-DEBUG] ${label} gesture: retryable (${retryable.code}); awaiting user tap to retry (attempt ${attempt}/${MAX_ATTEMPTS})`);
21658
21612
  button.disabled = false;
21659
21613
  setButtonEnabledStyle();
21660
21614
  button.textContent = originalText;
@@ -21664,7 +21618,6 @@ async function awaitSignInGestureAndSign(label, theme, signFn) {
21664
21618
  }
21665
21619
  if (retryable) {
21666
21620
  // Hit the attempt cap with a still-retryable failure.
21667
- console.log(`[MWA-DEBUG] ${label} gesture: retryable but attempt cap reached (${attempt})`);
21668
21621
  finishReject(new Error("Couldn't connect to your Seeker wallet. Please try again."));
21669
21622
  return;
21670
21623
  }
@@ -21673,7 +21626,6 @@ async function awaitSignInGestureAndSign(label, theme, signFn) {
21673
21626
  finishReject(err);
21674
21627
  });
21675
21628
  });
21676
- console.log(`[MWA-DEBUG] ${label} gesture: modal shown`);
21677
21629
  });
21678
21630
  }
21679
21631
  /**
@@ -21817,7 +21769,7 @@ async function registerMobileWalletAdapter(config) {
21817
21769
  if (typeof window === 'undefined')
21818
21770
  return;
21819
21771
  try {
21820
- const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-CZIJCtms.js'); });
21772
+ const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-DlA-NKvf.js'); });
21821
21773
  const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
21822
21774
  if (!registerMwa) {
21823
21775
  console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
@@ -21844,7 +21796,7 @@ async function registerMobileWalletAdapter(config) {
21844
21796
  // SolanaMobileWalletProvider.ensureWallet() for why. Consumers that
21845
21797
  // want their own UX can pass config.onWalletNotFound.
21846
21798
  options.onWalletNotFound = (_b = config === null || config === void 0 ? void 0 : config.onWalletNotFound) !== null && _b !== void 0 ? _b : (async () => {
21847
- console.warn('[MWA-DEBUG] registerMobileWalletAdapter onWalletNotFound (suppressed)');
21799
+ // intentional no-op
21848
21800
  });
21849
21801
  registerMwa(options);
21850
21802
  }
@@ -21884,19 +21836,66 @@ class SolanaMobileWalletProvider {
21884
21836
  constructor(networkUrl = null, config = {}) {
21885
21837
  /** LocalSolanaMobileWalletAdapterWallet, lazy-constructed in ensureWallet(). */
21886
21838
  this.wallet = null;
21839
+ /**
21840
+ * Cached MWA auth_token returned by `wallet.authorize()`. Reused by
21841
+ * subsequent native transact() calls (signMessage / signTransaction)
21842
+ * so the user doesn't get the wallet-pick popup on every operation.
21843
+ * Persisted to platform storage and hydrated by the constructor on
21844
+ * native; cleared by logout() and on `ERROR_REAUTHORIZE`.
21845
+ */
21846
+ this.nativeAuthToken = null;
21847
+ /** Cached public key string for the connected MWA wallet (native). */
21848
+ this.nativeAddress = null;
21887
21849
  this.networkUrl = networkUrl;
21888
21850
  this.config = config;
21889
- if (typeof window === 'undefined') {
21851
+ // Allow construction in true React Native environments: getPlatform().hasDOM
21852
+ // is false there even though `typeof window === 'object'` (RN exposes a
21853
+ // partial window global). Web/PWA paths still keep their original guard:
21854
+ // they need real window+document for wallet-standard-mobile's deep-link
21855
+ // mechanism, so missing-window in those builds remains a fail-fast.
21856
+ const hasDOM = getPlatform().hasDOM;
21857
+ if (!hasDOM && typeof window === 'undefined') {
21858
+ throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser or React Native environment');
21859
+ }
21860
+ if (hasDOM && typeof window === 'undefined') {
21890
21861
  throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser environment');
21891
21862
  }
21892
21863
  if (SolanaMobileWalletProvider.instance) {
21893
21864
  return SolanaMobileWalletProvider.instance;
21894
21865
  }
21866
+ // `appIdentity.uri` is what Phantom Android (and other MWA wallets)
21867
+ // display in their approval modal. On web/PWA this is the page
21868
+ // origin; on native there's no `window.location`, so fall back to
21869
+ // a stable identifier the user can recognize. Apps can override
21870
+ // entirely via `config.appIdentity.uri`.
21871
+ const fallbackUri = hasDOM
21872
+ ? getPlatform().getLocationOrigin()
21873
+ : 'tarobase://app';
21895
21874
  this.appIdentity = config.appIdentity || {
21896
21875
  name: 'TaroBase App',
21897
- uri: getPlatform().getLocationOrigin(),
21876
+ uri: fallbackUri,
21898
21877
  };
21899
21878
  this.cluster = config.cluster || 'mainnet-beta';
21879
+ // Hydrate cached MWA auth_token from storage on native so we can
21880
+ // skip the wallet-pick popup after a cold-start when the underlying
21881
+ // wallet authorization is still valid. Sync storage call per the
21882
+ // PlatformAdapter contract; safe to swallow read errors (a fresh
21883
+ // login() just re-authorizes).
21884
+ if (!hasDOM) {
21885
+ try {
21886
+ const raw = getPlatform().storage.getItem(MWA_AUTH_TOKEN_STORAGE_KEY);
21887
+ if (raw) {
21888
+ const parsed = JSON.parse(raw);
21889
+ if (typeof parsed.token === 'string' && typeof parsed.address === 'string') {
21890
+ this.nativeAuthToken = parsed.token;
21891
+ this.nativeAddress = parsed.address;
21892
+ }
21893
+ }
21894
+ }
21895
+ catch (_a) {
21896
+ // Corrupt or unreadable cache — ignore. login() will re-auth.
21897
+ }
21898
+ }
21900
21899
  SolanaMobileWalletProvider.instance = this;
21901
21900
  }
21902
21901
  static getInstance(networkUrl, config) {
@@ -21909,7 +21908,7 @@ class SolanaMobileWalletProvider {
21909
21908
  async ensureWallet() {
21910
21909
  if (this.wallet)
21911
21910
  return this.wallet;
21912
- const mod = await Promise.resolve().then(function () { return require('./index.browser-CZIJCtms.js'); });
21911
+ const mod = await Promise.resolve().then(function () { return require('./index.browser-DlA-NKvf.js'); });
21913
21912
  const chain = mapChainToWalletStandard(this.cluster);
21914
21913
  this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
21915
21914
  appIdentity: this.appIdentity,
@@ -21923,7 +21922,7 @@ class SolanaMobileWalletProvider {
21923
21922
  // login()'s withMwaAssociationRetry handles this case; on second
21924
21923
  // failure it surfaces a clean error message to the host app.
21925
21924
  onWalletNotFound: async () => {
21926
- console.warn('[MWA-DEBUG] ensureWallet onWalletNotFound (suppressed)');
21925
+ // intentional no-op
21927
21926
  },
21928
21927
  });
21929
21928
  return this.wallet;
@@ -21959,6 +21958,134 @@ class SolanaMobileWalletProvider {
21959
21958
  getChain() {
21960
21959
  return mapChainToWalletStandard(this.cluster);
21961
21960
  }
21961
+ /**
21962
+ * Dynamically import and unwrap `transact` from the MWA web3js
21963
+ * package. The package is externalized in rollup.config.js so this
21964
+ * resolves to `lib/cjs/index.native.js` (TurboModule-backed) on
21965
+ * Metro and `lib/esm/index.browser.js` (WebSocket) on webpack/vite
21966
+ * per their respective platform conditions. Handles Metro's CJS-to-
21967
+ * ESM interop variance (`mod.transact` vs `mod.default?.transact`).
21968
+ */
21969
+ async loadTransact() {
21970
+ var _a;
21971
+ const mod = await import('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
21972
+ const t = mod.transact || ((_a = mod.default) === null || _a === void 0 ? void 0 : _a.transact);
21973
+ if (typeof t !== 'function') {
21974
+ throw new Error('MWA transact API not available on this platform');
21975
+ }
21976
+ return t;
21977
+ }
21978
+ /**
21979
+ * Cache and persist a fresh MWA auth_token + address. Called from
21980
+ * `_loginNative` after a successful authorize. Storage failures are
21981
+ * non-fatal (next cold-start re-auths).
21982
+ */
21983
+ persistNativeAuth(token, address) {
21984
+ this.nativeAuthToken = token;
21985
+ this.nativeAddress = address;
21986
+ try {
21987
+ getPlatform().storage.setItem(MWA_AUTH_TOKEN_STORAGE_KEY, JSON.stringify({ token, address }));
21988
+ }
21989
+ catch (_a) {
21990
+ // non-fatal — token still in-memory for this process
21991
+ }
21992
+ }
21993
+ /** Clear cached + persisted native auth state. */
21994
+ clearNativeAuth() {
21995
+ this.nativeAuthToken = null;
21996
+ this.nativeAddress = null;
21997
+ try {
21998
+ getPlatform().storage.removeItem(MWA_AUTH_TOKEN_STORAGE_KEY);
21999
+ }
22000
+ catch (_a) {
22001
+ // ignore
22002
+ }
22003
+ }
22004
+ /**
22005
+ * Classify an MWA-native error as a user cancellation. User-cancel
22006
+ * shouldn't surface as a red console.error; callers can swallow or
22007
+ * show a softer message. MWA spec codes plus the same substring
22008
+ * checks the web path uses to catch wallet-specific phrasing.
22009
+ */
22010
+ isNativeUserCancel(err) {
22011
+ var _a;
22012
+ if (!err)
22013
+ return false;
22014
+ const code = err.code;
22015
+ if (code === 'ERROR_NOT_SIGNED')
22016
+ return true;
22017
+ const msg = String((_a = err.message) !== null && _a !== void 0 ? _a : '').toLowerCase();
22018
+ return /user (rejected|denied|cancelled|canceled|declined)/.test(msg);
22019
+ }
22020
+ /**
22021
+ * Native MWA login via @solana-mobile/mobile-wallet-adapter-protocol-web3js.
22022
+ * Used in true React Native (Expo) environments where wallet-standard-mobile's
22023
+ * web universal-link path doesn't apply. Does authorize + signMessage in a
22024
+ * single transact() roundtrip — intent-based MWA doesn't need the two-popup
22025
+ * dance the web path uses (no Chrome activation-loss concern). Persists the
22026
+ * resulting auth_token so cold-start can reauthorize without a fresh popup.
22027
+ */
22028
+ async _loginNative() {
22029
+ const transact = await this.loadTransact();
22030
+ const existingSession = await WebSessionManager.getSession();
22031
+ const nonce = await genAuthNonce();
22032
+ const result = await transact(async (wallet) => {
22033
+ const auth = await wallet.authorize({
22034
+ chain: this.getChain(),
22035
+ identity: this.appIdentity,
22036
+ });
22037
+ if (!auth.accounts || auth.accounts.length === 0) {
22038
+ throw new Error('MWA returned no accounts');
22039
+ }
22040
+ const account = auth.accounts[0];
22041
+ // account.address is base64-encoded per MWA spec; convert to
22042
+ // the base58 form Tarobase + the rest of the SDK use.
22043
+ const base58Addr = new web3_js.PublicKey(bufferExports.Buffer.from(account.address, 'base64')).toBase58();
22044
+ // Reuse session if already valid for this address — skip the
22045
+ // signMessages roundtrip entirely.
22046
+ if (existingSession && existingSession.address === base58Addr) {
22047
+ return {
22048
+ base58Addr,
22049
+ authToken: auth.auth_token,
22050
+ signatureBase64: null,
22051
+ };
22052
+ }
22053
+ const messageText = await genSolanaMessage(base58Addr, nonce);
22054
+ const messageBytes = getPlatform().textEncode(messageText);
22055
+ const signatures = await wallet.signMessages({
22056
+ addresses: [account.address],
22057
+ payloads: [messageBytes],
22058
+ });
22059
+ if (!signatures || signatures.length === 0) {
22060
+ throw new Error('MWA returned no signature');
22061
+ }
22062
+ // Per spec, signMessages returns Uint8Array[] of signatures
22063
+ // (one per payload), not message+signature concatenations.
22064
+ const signatureBase64 = bufferExports.Buffer.from(signatures[0]).toString('base64');
22065
+ return {
22066
+ base58Addr,
22067
+ authToken: auth.auth_token,
22068
+ signatureBase64,
22069
+ messageText,
22070
+ };
22071
+ });
22072
+ this.persistNativeAuth(result.authToken, result.base58Addr);
22073
+ // Existing valid session — short-circuit before re-creating server-side.
22074
+ if (existingSession && existingSession.address === result.base58Addr) {
22075
+ const user = { provider: this, address: result.base58Addr };
22076
+ setCurrentUser(user);
22077
+ return user;
22078
+ }
22079
+ // Create Tarobase session on the server.
22080
+ if (!result.signatureBase64 || !result.messageText) {
22081
+ throw new Error('MWA login completed without signature');
22082
+ }
22083
+ const createSessionResult = await createSessionWithSignature(result.base58Addr, result.messageText, result.signatureBase64);
22084
+ await WebSessionManager.storeSession(result.base58Addr, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
22085
+ const user = { provider: this, address: result.base58Addr };
22086
+ setCurrentUser(user);
22087
+ return user;
22088
+ }
21962
22089
  async login() {
21963
22090
  var _a, _b, _c, _d, _e;
21964
22091
  setAuthLoading(true);
@@ -21969,6 +22096,13 @@ class SolanaMobileWalletProvider {
21969
22096
  const prevAuthMethod = readAuthMethod();
21970
22097
  writeAuthMethod(MWA_AUTH_METHOD);
21971
22098
  try {
22099
+ // True React Native: skip the wallet-standard-mobile path (which
22100
+ // requires window.isSecureContext and a real DOM) and use the raw
22101
+ // MWA protocol via Android intents.
22102
+ if (!getPlatform().hasDOM) {
22103
+ const user = await this._loginNative();
22104
+ return user;
22105
+ }
21972
22106
  const wallet = await this.ensureWallet();
21973
22107
  // Quick-check: wallet may already have authorization (e.g. from a
21974
22108
  // previous in-page login) and a matching Tarobase session — skip
@@ -21997,7 +22131,7 @@ class SolanaMobileWalletProvider {
21997
22131
  // consent on the second pass and completes quickly. See
21998
22132
  // withMwaAssociationRetry for details.
21999
22133
  const connectFeat = getConnectFeature(wallet);
22000
- const { accounts } = await withMwaAssociationRetry('login:connect', () => connectFeat.connect());
22134
+ const { accounts } = await withMwaAssociationRetry(() => connectFeat.connect());
22001
22135
  if (!accounts || accounts.length === 0) {
22002
22136
  throw new Error('MWA returned no accounts');
22003
22137
  }
@@ -22030,7 +22164,7 @@ class SolanaMobileWalletProvider {
22030
22164
  const messageText = await genSolanaMessage(base58Addr, nonce);
22031
22165
  const messageBytes = getPlatform().textEncode(messageText);
22032
22166
  const signMessageFeat = getSignMessageFeature(wallet);
22033
- const signResult = await awaitSignInGestureAndSign('login:signMessage', this.config.theme, () => signMessageFeat.signMessage({ account, message: messageBytes }));
22167
+ const signResult = await awaitSignInGestureAndSign(this.config.theme, () => signMessageFeat.signMessage({ account, message: messageBytes }));
22034
22168
  if (!signResult) {
22035
22169
  throw new Error('MWA returned no signature');
22036
22170
  }
@@ -22070,6 +22204,29 @@ class SolanaMobileWalletProvider {
22070
22204
  return null;
22071
22205
  }
22072
22206
  async logout() {
22207
+ if (!getPlatform().hasDOM) {
22208
+ // Native path: deauthorize the cached MWA auth_token if we have
22209
+ // one (failures non-fatal — the wallet app may have been
22210
+ // uninstalled or the token already revoked), then clear local
22211
+ // and persisted state.
22212
+ const token = this.nativeAuthToken;
22213
+ if (token) {
22214
+ try {
22215
+ const transact = await this.loadTransact();
22216
+ await transact(async (wallet) => {
22217
+ await wallet.deauthorize({ auth_token: token });
22218
+ });
22219
+ }
22220
+ catch (error) {
22221
+ console.warn('[SolanaMobileWallet] Native deauthorize error:', error);
22222
+ }
22223
+ }
22224
+ this.clearNativeAuth();
22225
+ WebSessionManager.clearSession();
22226
+ writeAuthMethod(null);
22227
+ setCurrentUser(null);
22228
+ return;
22229
+ }
22073
22230
  try {
22074
22231
  const wallet = await this.ensureWallet();
22075
22232
  const disconnectFeat = getDisconnectFeature(wallet);
@@ -22089,7 +22246,42 @@ class SolanaMobileWalletProvider {
22089
22246
  setCurrentUser(null);
22090
22247
  }
22091
22248
  async signMessage(message) {
22092
- var _a, _b;
22249
+ var _a, _b, _c;
22250
+ // Native: reauthorize with cached auth_token, then signMessages inside
22251
+ // the same transact() session. No wallet-pick popup if the auth_token
22252
+ // is still valid for the user's wallet.
22253
+ if (!getPlatform().hasDOM) {
22254
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22255
+ throw new Error('Wallet not connected. Call login() first.');
22256
+ }
22257
+ const transact = await this.loadTransact();
22258
+ const messageBytes = getPlatform().textEncode(message);
22259
+ const addressBase64 = new web3_js.PublicKey(this.nativeAddress).toBuffer().toString('base64');
22260
+ const authToken = this.nativeAuthToken;
22261
+ try {
22262
+ const signature = await transact(async (wallet) => {
22263
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22264
+ const sigs = await wallet.signMessages({
22265
+ addresses: [addressBase64],
22266
+ payloads: [messageBytes],
22267
+ });
22268
+ if (!sigs || sigs.length === 0)
22269
+ throw new Error('MWA returned no signature');
22270
+ return sigs[0];
22271
+ });
22272
+ return bufferExports.Buffer.from(signature).toString('base64');
22273
+ }
22274
+ catch (error) {
22275
+ if (this.isNativeUserCancel(error)) {
22276
+ throw new Error('User declined to sign');
22277
+ }
22278
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22279
+ await this.logout();
22280
+ throw new Error('Wallet connection lost. Please reconnect.');
22281
+ }
22282
+ throw new Error(`Failed to sign message: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22283
+ }
22284
+ }
22093
22285
  const account = await this.ensureAuthorized();
22094
22286
  const wallet = await this.ensureWallet();
22095
22287
  try {
@@ -22103,7 +22295,7 @@ class SolanaMobileWalletProvider {
22103
22295
  return bufferExports.Buffer.from(sigBytes).toString('base64');
22104
22296
  }
22105
22297
  catch (error) {
22106
- if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
22298
+ if (((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not connected')) || ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not authorized')) ||
22107
22299
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22108
22300
  await this.logout();
22109
22301
  throw new Error('Wallet connection lost. Please reconnect.');
@@ -22112,7 +22304,58 @@ class SolanaMobileWalletProvider {
22112
22304
  }
22113
22305
  }
22114
22306
  async signTransaction(transaction) {
22115
- var _a, _b;
22307
+ var _a, _b, _c;
22308
+ // Native: fill blockhash/feePayer if missing, then signTransactions
22309
+ // inside a transact() session keyed by the cached auth_token.
22310
+ if (!getPlatform().hasDOM) {
22311
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22312
+ throw new Error('Wallet not connected. Call login() first.');
22313
+ }
22314
+ const connectedPubkey = new web3_js.PublicKey(this.nativeAddress);
22315
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
22316
+ if (isLegacyTransaction) {
22317
+ const legacyTx = transaction;
22318
+ if (!legacyTx.recentBlockhash) {
22319
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
22320
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
22321
+ legacyTx.recentBlockhash = blockhash;
22322
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
22323
+ }
22324
+ if (!legacyTx.feePayer) {
22325
+ legacyTx.feePayer = connectedPubkey;
22326
+ }
22327
+ }
22328
+ else {
22329
+ const versionedTx = transaction;
22330
+ if (!versionedTx.message.recentBlockhash) {
22331
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
22332
+ const { blockhash } = await conn.getLatestBlockhash('confirmed');
22333
+ versionedTx.message.recentBlockhash = blockhash;
22334
+ }
22335
+ }
22336
+ const transact = await this.loadTransact();
22337
+ const authToken = this.nativeAuthToken;
22338
+ try {
22339
+ const signed = await transact(async (wallet) => {
22340
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22341
+ const results = await wallet.signTransactions({ transactions: [transaction] });
22342
+ if (!results || results.length === 0)
22343
+ throw new Error('MWA returned no signed transaction');
22344
+ return results[0];
22345
+ });
22346
+ return signed;
22347
+ }
22348
+ catch (error) {
22349
+ if (this.isNativeUserCancel(error)) {
22350
+ throw new Error('User declined to sign');
22351
+ }
22352
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22353
+ await this.logout();
22354
+ throw new Error('Wallet connection lost. Please reconnect.');
22355
+ }
22356
+ throw new Error(`Failed to sign transaction: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22357
+ }
22358
+ }
22116
22359
  const account = await this.ensureAuthorized();
22117
22360
  const connectedPubkey = new web3_js.PublicKey(account.publicKey);
22118
22361
  const wallet = await this.ensureWallet();
@@ -22151,7 +22394,7 @@ class SolanaMobileWalletProvider {
22151
22394
  return txFromWireBytes(new Uint8Array(signedBytes));
22152
22395
  }
22153
22396
  catch (error) {
22154
- if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
22397
+ if (((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not connected')) || ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not authorized')) ||
22155
22398
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22156
22399
  await this.logout();
22157
22400
  throw new Error('Wallet connection lost. Please reconnect.');
@@ -22160,7 +22403,70 @@ class SolanaMobileWalletProvider {
22160
22403
  }
22161
22404
  }
22162
22405
  async signAndSubmitTransaction(transaction, feePayer) {
22163
- var _a, _b, _c, _d, _e, _f;
22406
+ var _a, _b, _c, _d, _e, _f, _g;
22407
+ // Native: signAndSendTransactions inside a transact() session.
22408
+ // The wallet submits to its own RPC; we then await confirmation on
22409
+ // ours. Surfnet (custom RPC) needs manual submission because the
22410
+ // wallet won't route there — we fall back to sign-only + manual send.
22411
+ if (!getPlatform().hasDOM) {
22412
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22413
+ throw new Error('Wallet not connected. Call login() first.');
22414
+ }
22415
+ const connectedPubkey = new web3_js.PublicKey(this.nativeAddress);
22416
+ const rpcUrl = this.getRpcUrl();
22417
+ const connection = new web3_js.Connection(rpcUrl, 'confirmed');
22418
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
22419
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
22420
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
22421
+ if (isLegacyTransaction) {
22422
+ const legacyTx = transaction;
22423
+ legacyTx.recentBlockhash = blockhash;
22424
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
22425
+ if (!legacyTx.feePayer)
22426
+ legacyTx.feePayer = feePayer !== null && feePayer !== void 0 ? feePayer : connectedPubkey;
22427
+ }
22428
+ else {
22429
+ const versionedTx = transaction;
22430
+ versionedTx.message.recentBlockhash = blockhash;
22431
+ }
22432
+ const transact = await this.loadTransact();
22433
+ const authToken = this.nativeAuthToken;
22434
+ try {
22435
+ if (isSurfnet) {
22436
+ // Surfnet: sign only, submit manually to Surfnet RPC
22437
+ // (the wallet would route signAndSend to its own RPC).
22438
+ const signed = await transact(async (wallet) => {
22439
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22440
+ const results = await wallet.signTransactions({ transactions: [transaction] });
22441
+ if (!results || results.length === 0)
22442
+ throw new Error('MWA returned no signed transaction');
22443
+ return results[0];
22444
+ });
22445
+ const sig = await connection.sendRawTransaction(signed.serialize(), { preflightCommitment: 'confirmed' });
22446
+ await confirmAndCheckTransaction(connection, sig);
22447
+ return sig;
22448
+ }
22449
+ const sig = await transact(async (wallet) => {
22450
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22451
+ const results = await wallet.signAndSendTransactions({ transactions: [transaction] });
22452
+ if (!results || results.length === 0)
22453
+ throw new Error('MWA returned no signature');
22454
+ return results[0];
22455
+ });
22456
+ await confirmAndCheckTransaction(connection, sig);
22457
+ return sig;
22458
+ }
22459
+ catch (error) {
22460
+ if (this.isNativeUserCancel(error)) {
22461
+ throw new Error('User declined to sign');
22462
+ }
22463
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22464
+ await this.logout();
22465
+ throw new Error('Wallet connection lost. Please reconnect.');
22466
+ }
22467
+ throw new Error(`Failed to sign+submit transaction: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22468
+ }
22469
+ }
22164
22470
  const account = await this.ensureAuthorized();
22165
22471
  const connectedPubkey = new web3_js.PublicKey(account.publicKey);
22166
22472
  const wallet = await this.ensureWallet();
@@ -22227,16 +22533,16 @@ class SolanaMobileWalletProvider {
22227
22533
  return signature;
22228
22534
  }
22229
22535
  catch (error) {
22230
- if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
22536
+ if (((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not connected')) || ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not authorized')) ||
22231
22537
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22232
22538
  await this.logout();
22233
22539
  throw new Error('Wallet connection lost. Please reconnect.');
22234
22540
  }
22235
22541
  const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
22236
- ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user rejected')) ||
22237
- ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user denied')) ||
22238
- ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user cancelled')) ||
22239
- ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user canceled'));
22542
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user rejected')) ||
22543
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user denied')) ||
22544
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user cancelled')) ||
22545
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user canceled'));
22240
22546
  if (!isUserRejection) {
22241
22547
  console.error('[SolanaMobileWallet] Transaction failed:', error);
22242
22548
  }
@@ -22803,6 +23109,7 @@ exports.bufferExports = bufferExports;
22803
23109
  exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
22804
23110
  exports.clearCache = clearCache;
22805
23111
  exports.closeAllSubscriptions = closeAllSubscriptions;
23112
+ exports.commonjsRequire = commonjsRequire;
22806
23113
  exports.convertRemainingAccounts = convertRemainingAccounts;
22807
23114
  exports.count = count;
22808
23115
  exports.createSessionWithPrivy = createSessionWithPrivy;
@@ -22830,6 +23137,7 @@ exports.onAuthStateChanged = onAuthStateChanged;
22830
23137
  exports.reconnectWithNewAuth = reconnectWithNewAuth;
22831
23138
  exports.refreshSession = refreshSession;
22832
23139
  exports.registerMobileWalletAdapter = registerMobileWalletAdapter;
23140
+ exports.require$$0 = require$$0;
22833
23141
  exports.runExpression = runExpression;
22834
23142
  exports.runExpressionMany = runExpressionMany;
22835
23143
  exports.runQuery = runQuery;
@@ -22844,4 +23152,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
22844
23152
  exports.signTransaction = signTransaction;
22845
23153
  exports.subscribe = subscribe;
22846
23154
  exports.useAuth = useAuth;
22847
- //# sourceMappingURL=index-bEXLwE7_.js.map
23155
+ //# sourceMappingURL=index-Dj1tZr6X.js.map