@pooflabs/web 0.0.86 → 0.0.88

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-DK28JaJm.esm.js → index-BfsQaxom.esm.js} +3054 -301
  3. package/dist/index-BfsQaxom.esm.js.map +1 -0
  4. package/dist/{index-BQUfNEiY.esm.js → index-CJRFnq6O.esm.js} +476 -103
  5. package/dist/index-CJRFnq6O.esm.js.map +1 -0
  6. package/dist/{index-BHkED2YI.js → index-CTtGbOzo.js} +3054 -300
  7. package/dist/index-CTtGbOzo.js.map +1 -0
  8. package/dist/{index-D-Wbwevj.js → index-CvNX4W0l.js} +2 -2
  9. package/dist/index-CvNX4W0l.js.map +1 -0
  10. package/dist/{index-DUn32Hkh.js → index-DBYgqO9f.js} +3055 -301
  11. package/dist/index-DBYgqO9f.js.map +1 -0
  12. package/dist/index-DpiO7Cpe.esm.js +6 -0
  13. package/dist/index-DpiO7Cpe.esm.js.map +1 -0
  14. package/dist/{index-hEc5_KoM.js → index-Lm0k5Hwv.js} +477 -102
  15. package/dist/index-Lm0k5Hwv.js.map +1 -0
  16. package/dist/{index-Cfp30Jm_.esm.js → index-MF_M5V0O.esm.js} +3055 -300
  17. package/dist/index-MF_M5V0O.esm.js.map +1 -0
  18. package/dist/{index.browser-CbawPvh6.js → index.browser-BCr9Sc8V.js} +506 -1876
  19. package/dist/index.browser-BCr9Sc8V.js.map +1 -0
  20. package/dist/{index.browser-DD8pg_L2.js → index.browser-BxKN5pIs.js} +1223 -2565
  21. package/dist/index.browser-BxKN5pIs.js.map +1 -0
  22. package/dist/{index.browser-DQqKPfDA.esm.js → index.browser-CGZvkfTO.esm.js} +506 -1876
  23. package/dist/index.browser-CGZvkfTO.esm.js.map +1 -0
  24. package/dist/{index.browser-C9gHoUen.esm.js → index.browser-CMijwVwX.esm.js} +1223 -2565
  25. package/dist/index.browser-CMijwVwX.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-7hiNiSyC.js → index.native-FMbSnE7i.js} +44 -61
  29. package/dist/index.native-FMbSnE7i.js.map +1 -0
  30. package/dist/{index.native-BItnSD47.esm.js → index.native-GyqT8Dn5.esm.js} +43 -62
  31. package/dist/index.native-GyqT8Dn5.esm.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-CjvLq_2_.js → phantom-wallet-provider-4_DBhDbx.js} +4 -4
  35. package/dist/{phantom-wallet-provider-CjvLq_2_.js.map → phantom-wallet-provider-4_DBhDbx.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-DE3vit2Z.esm.js → phantom-wallet-provider-BFSfBW0w.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-DE3vit2Z.esm.js.map → phantom-wallet-provider-BFSfBW0w.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-DFZaQPss.js → privy-wallet-provider-DRss_Hua.js} +3 -3
  39. package/dist/privy-wallet-provider-DRss_Hua.js.map +1 -0
  40. package/dist/{privy-wallet-provider-ip2pqo_U.esm.js → privy-wallet-provider-Dl0feuCb.esm.js} +3 -3
  41. package/dist/privy-wallet-provider-Dl0feuCb.esm.js.map +1 -0
  42. package/dist/{solana-mobile-wallet-provider-D7BbSpez.esm.js → solana-mobile-wallet-provider-C5mN8Dxh.esm.js} +437 -45
  43. package/dist/solana-mobile-wallet-provider-C5mN8Dxh.esm.js.map +1 -0
  44. package/dist/{solana-mobile-wallet-provider-DwER68Rz.js → solana-mobile-wallet-provider-CAZs-TkL.js} +437 -45
  45. package/dist/solana-mobile-wallet-provider-CAZs-TkL.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/index-BHkED2YI.js.map +0 -1
  48. package/dist/index-BQUfNEiY.esm.js.map +0 -1
  49. package/dist/index-Cfp30Jm_.esm.js.map +0 -1
  50. package/dist/index-D-Wbwevj.js.map +0 -1
  51. package/dist/index-DK28JaJm.esm.js.map +0 -1
  52. package/dist/index-DKyWaxCB.esm.js +0 -6
  53. package/dist/index-DKyWaxCB.esm.js.map +0 -1
  54. package/dist/index-DUn32Hkh.js.map +0 -1
  55. package/dist/index-hEc5_KoM.js.map +0 -1
  56. package/dist/index.browser-C9gHoUen.esm.js.map +0 -1
  57. package/dist/index.browser-CbawPvh6.js.map +0 -1
  58. package/dist/index.browser-DD8pg_L2.js.map +0 -1
  59. package/dist/index.browser-DQqKPfDA.esm.js.map +0 -1
  60. package/dist/index.native-7hiNiSyC.js.map +0 -1
  61. package/dist/index.native-BItnSD47.esm.js.map +0 -1
  62. package/dist/privy-wallet-provider-DFZaQPss.js.map +0 -1
  63. package/dist/privy-wallet-provider-ip2pqo_U.esm.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-D7BbSpez.esm.js.map +0 -1
  65. package/dist/solana-mobile-wallet-provider-DwER68Rz.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-BHkED2YI.js'); })
15704
+ Promise.resolve().then(function () { return require('./index-CTtGbOzo.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;
20364
+
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
+ }
20393
20374
 
20394
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
20395
- var base58 = basex(ALPHABET);
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.
@@ -21413,13 +21402,13 @@ async function withMwaAssociationRetry(fn) {
21413
21402
  * next tap is a new activation (a real retry). A timer-based retry would
21414
21403
  * just hit the same Chrome block. Cap at 3 attempts before giving up.
21415
21404
  */
21416
- async function awaitSignInGestureAndSign(theme, signFn) {
21405
+ async function awaitSignInGestureAndSign(theme, signFn, noResultError = 'MWA returned no signature') {
21417
21406
  if (typeof document === 'undefined' || typeof window === 'undefined') {
21418
21407
  // SSR / non-browser: skip the gesture, just call (the activation
21419
21408
  // model doesn't apply outside the browser).
21420
21409
  const results = await signFn();
21421
21410
  if (!results || results.length === 0)
21422
- throw new Error('MWA returned no signature');
21411
+ throw new Error(noResultError);
21423
21412
  return results[0];
21424
21413
  }
21425
21414
  return new Promise((resolve, reject) => {
@@ -21611,7 +21600,7 @@ async function awaitSignInGestureAndSign(theme, signFn) {
21611
21600
  // launchAssociation(). Do not `await` before calling.
21612
21601
  signFn().then((results) => {
21613
21602
  if (!results || results.length === 0) {
21614
- finishReject(new Error('MWA returned no signature'));
21603
+ finishReject(new Error(noResultError));
21615
21604
  return;
21616
21605
  }
21617
21606
  finishResolve(results[0]);
@@ -21639,6 +21628,31 @@ async function awaitSignInGestureAndSign(theme, signFn) {
21639
21628
  });
21640
21629
  });
21641
21630
  }
21631
+ /**
21632
+ * Sign through the gesture modal ONLY when transient user activation has
21633
+ * already decayed. Fast transactions still hold the activation from the
21634
+ * user's tap, so the `solana-wallet:` navigation succeeds directly with no
21635
+ * modal (preserves prior UX — no extra tap). Slow transactions — e.g. a swap
21636
+ * whose server-side build exceeds Chrome's ~5s activation window — have lost
21637
+ * it, so we fall back to awaitSignInGestureAndSign to mint a fresh activation
21638
+ * via a "Sign in" tap. Returns the first result (same shape as the bare
21639
+ * wallet-standard feature call and as awaitSignInGestureAndSign).
21640
+ */
21641
+ async function signWithFreshActivation(theme, signFn, noResultError = 'MWA returned no signature') {
21642
+ var _a;
21643
+ const activationLive = typeof navigator !== 'undefined' &&
21644
+ ((_a = navigator.userActivation) === null || _a === void 0 ? void 0 : _a.isActive) === true;
21645
+ if (activationLive) {
21646
+ // Live gesture: invoke synchronously (no await before signFn) so the
21647
+ // activation propagates to the protocol's location.assign navigation.
21648
+ const results = await signFn();
21649
+ if (!results || results.length === 0)
21650
+ throw new Error(noResultError);
21651
+ return results[0];
21652
+ }
21653
+ // Activation gone: surface the modal so the user's tap mints a fresh one.
21654
+ return awaitSignInGestureAndSign(theme, signFn, noResultError);
21655
+ }
21642
21656
  /**
21643
21657
  * Normalize a chain string to a wallet-standard Solana chain identifier.
21644
21658
  *
@@ -21780,7 +21794,7 @@ async function registerMobileWalletAdapter(config) {
21780
21794
  if (typeof window === 'undefined')
21781
21795
  return;
21782
21796
  try {
21783
- const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-DD8pg_L2.js'); });
21797
+ const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-BxKN5pIs.js'); });
21784
21798
  const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
21785
21799
  if (!registerMwa) {
21786
21800
  console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
@@ -21847,19 +21861,66 @@ class SolanaMobileWalletProvider {
21847
21861
  constructor(networkUrl = null, config = {}) {
21848
21862
  /** LocalSolanaMobileWalletAdapterWallet, lazy-constructed in ensureWallet(). */
21849
21863
  this.wallet = null;
21864
+ /**
21865
+ * Cached MWA auth_token returned by `wallet.authorize()`. Reused by
21866
+ * subsequent native transact() calls (signMessage / signTransaction)
21867
+ * so the user doesn't get the wallet-pick popup on every operation.
21868
+ * Persisted to platform storage and hydrated by the constructor on
21869
+ * native; cleared by logout() and on `ERROR_REAUTHORIZE`.
21870
+ */
21871
+ this.nativeAuthToken = null;
21872
+ /** Cached public key string for the connected MWA wallet (native). */
21873
+ this.nativeAddress = null;
21850
21874
  this.networkUrl = networkUrl;
21851
21875
  this.config = config;
21852
- if (typeof window === 'undefined') {
21876
+ // Allow construction in true React Native environments: getPlatform().hasDOM
21877
+ // is false there even though `typeof window === 'object'` (RN exposes a
21878
+ // partial window global). Web/PWA paths still keep their original guard:
21879
+ // they need real window+document for wallet-standard-mobile's deep-link
21880
+ // mechanism, so missing-window in those builds remains a fail-fast.
21881
+ const hasDOM = getPlatform().hasDOM;
21882
+ if (!hasDOM && typeof window === 'undefined') {
21883
+ throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser or React Native environment');
21884
+ }
21885
+ if (hasDOM && typeof window === 'undefined') {
21853
21886
  throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser environment');
21854
21887
  }
21855
21888
  if (SolanaMobileWalletProvider.instance) {
21856
21889
  return SolanaMobileWalletProvider.instance;
21857
21890
  }
21891
+ // `appIdentity.uri` is what Phantom Android (and other MWA wallets)
21892
+ // display in their approval modal. On web/PWA this is the page
21893
+ // origin; on native there's no `window.location`, so fall back to
21894
+ // a stable identifier the user can recognize. Apps can override
21895
+ // entirely via `config.appIdentity.uri`.
21896
+ const fallbackUri = hasDOM
21897
+ ? getPlatform().getLocationOrigin()
21898
+ : 'tarobase://app';
21858
21899
  this.appIdentity = config.appIdentity || {
21859
21900
  name: 'TaroBase App',
21860
- uri: getPlatform().getLocationOrigin(),
21901
+ uri: fallbackUri,
21861
21902
  };
21862
21903
  this.cluster = config.cluster || 'mainnet-beta';
21904
+ // Hydrate cached MWA auth_token from storage on native so we can
21905
+ // skip the wallet-pick popup after a cold-start when the underlying
21906
+ // wallet authorization is still valid. Sync storage call per the
21907
+ // PlatformAdapter contract; safe to swallow read errors (a fresh
21908
+ // login() just re-authorizes).
21909
+ if (!hasDOM) {
21910
+ try {
21911
+ const raw = getPlatform().storage.getItem(MWA_AUTH_TOKEN_STORAGE_KEY);
21912
+ if (raw) {
21913
+ const parsed = JSON.parse(raw);
21914
+ if (typeof parsed.token === 'string' && typeof parsed.address === 'string') {
21915
+ this.nativeAuthToken = parsed.token;
21916
+ this.nativeAddress = parsed.address;
21917
+ }
21918
+ }
21919
+ }
21920
+ catch (_a) {
21921
+ // Corrupt or unreadable cache — ignore. login() will re-auth.
21922
+ }
21923
+ }
21863
21924
  SolanaMobileWalletProvider.instance = this;
21864
21925
  }
21865
21926
  static getInstance(networkUrl, config) {
@@ -21872,7 +21933,7 @@ class SolanaMobileWalletProvider {
21872
21933
  async ensureWallet() {
21873
21934
  if (this.wallet)
21874
21935
  return this.wallet;
21875
- const mod = await Promise.resolve().then(function () { return require('./index.browser-DD8pg_L2.js'); });
21936
+ const mod = await Promise.resolve().then(function () { return require('./index.browser-BxKN5pIs.js'); });
21876
21937
  const chain = mapChainToWalletStandard(this.cluster);
21877
21938
  this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
21878
21939
  appIdentity: this.appIdentity,
@@ -21922,6 +21983,134 @@ class SolanaMobileWalletProvider {
21922
21983
  getChain() {
21923
21984
  return mapChainToWalletStandard(this.cluster);
21924
21985
  }
21986
+ /**
21987
+ * Dynamically import and unwrap `transact` from the MWA web3js
21988
+ * package. The package is externalized in rollup.config.js so this
21989
+ * resolves to `lib/cjs/index.native.js` (TurboModule-backed) on
21990
+ * Metro and `lib/esm/index.browser.js` (WebSocket) on webpack/vite
21991
+ * per their respective platform conditions. Handles Metro's CJS-to-
21992
+ * ESM interop variance (`mod.transact` vs `mod.default?.transact`).
21993
+ */
21994
+ async loadTransact() {
21995
+ var _a;
21996
+ const mod = await import('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
21997
+ const t = mod.transact || ((_a = mod.default) === null || _a === void 0 ? void 0 : _a.transact);
21998
+ if (typeof t !== 'function') {
21999
+ throw new Error('MWA transact API not available on this platform');
22000
+ }
22001
+ return t;
22002
+ }
22003
+ /**
22004
+ * Cache and persist a fresh MWA auth_token + address. Called from
22005
+ * `_loginNative` after a successful authorize. Storage failures are
22006
+ * non-fatal (next cold-start re-auths).
22007
+ */
22008
+ persistNativeAuth(token, address) {
22009
+ this.nativeAuthToken = token;
22010
+ this.nativeAddress = address;
22011
+ try {
22012
+ getPlatform().storage.setItem(MWA_AUTH_TOKEN_STORAGE_KEY, JSON.stringify({ token, address }));
22013
+ }
22014
+ catch (_a) {
22015
+ // non-fatal — token still in-memory for this process
22016
+ }
22017
+ }
22018
+ /** Clear cached + persisted native auth state. */
22019
+ clearNativeAuth() {
22020
+ this.nativeAuthToken = null;
22021
+ this.nativeAddress = null;
22022
+ try {
22023
+ getPlatform().storage.removeItem(MWA_AUTH_TOKEN_STORAGE_KEY);
22024
+ }
22025
+ catch (_a) {
22026
+ // ignore
22027
+ }
22028
+ }
22029
+ /**
22030
+ * Classify an MWA-native error as a user cancellation. User-cancel
22031
+ * shouldn't surface as a red console.error; callers can swallow or
22032
+ * show a softer message. MWA spec codes plus the same substring
22033
+ * checks the web path uses to catch wallet-specific phrasing.
22034
+ */
22035
+ isNativeUserCancel(err) {
22036
+ var _a;
22037
+ if (!err)
22038
+ return false;
22039
+ const code = err.code;
22040
+ if (code === 'ERROR_NOT_SIGNED')
22041
+ return true;
22042
+ const msg = String((_a = err.message) !== null && _a !== void 0 ? _a : '').toLowerCase();
22043
+ return /user (rejected|denied|cancelled|canceled|declined)/.test(msg);
22044
+ }
22045
+ /**
22046
+ * Native MWA login via @solana-mobile/mobile-wallet-adapter-protocol-web3js.
22047
+ * Used in true React Native (Expo) environments where wallet-standard-mobile's
22048
+ * web universal-link path doesn't apply. Does authorize + signMessage in a
22049
+ * single transact() roundtrip — intent-based MWA doesn't need the two-popup
22050
+ * dance the web path uses (no Chrome activation-loss concern). Persists the
22051
+ * resulting auth_token so cold-start can reauthorize without a fresh popup.
22052
+ */
22053
+ async _loginNative() {
22054
+ const transact = await this.loadTransact();
22055
+ const existingSession = await WebSessionManager.getSession();
22056
+ const nonce = await genAuthNonce();
22057
+ const result = await transact(async (wallet) => {
22058
+ const auth = await wallet.authorize({
22059
+ chain: this.getChain(),
22060
+ identity: this.appIdentity,
22061
+ });
22062
+ if (!auth.accounts || auth.accounts.length === 0) {
22063
+ throw new Error('MWA returned no accounts');
22064
+ }
22065
+ const account = auth.accounts[0];
22066
+ // account.address is base64-encoded per MWA spec; convert to
22067
+ // the base58 form Tarobase + the rest of the SDK use.
22068
+ const base58Addr = new web3_js.PublicKey(bufferExports.Buffer.from(account.address, 'base64')).toBase58();
22069
+ // Reuse session if already valid for this address — skip the
22070
+ // signMessages roundtrip entirely.
22071
+ if (existingSession && existingSession.address === base58Addr) {
22072
+ return {
22073
+ base58Addr,
22074
+ authToken: auth.auth_token,
22075
+ signatureBase64: null,
22076
+ };
22077
+ }
22078
+ const messageText = await genSolanaMessage(base58Addr, nonce);
22079
+ const messageBytes = getPlatform().textEncode(messageText);
22080
+ const signatures = await wallet.signMessages({
22081
+ addresses: [account.address],
22082
+ payloads: [messageBytes],
22083
+ });
22084
+ if (!signatures || signatures.length === 0) {
22085
+ throw new Error('MWA returned no signature');
22086
+ }
22087
+ // Per spec, signMessages returns Uint8Array[] of signatures
22088
+ // (one per payload), not message+signature concatenations.
22089
+ const signatureBase64 = bufferExports.Buffer.from(signatures[0]).toString('base64');
22090
+ return {
22091
+ base58Addr,
22092
+ authToken: auth.auth_token,
22093
+ signatureBase64,
22094
+ messageText,
22095
+ };
22096
+ });
22097
+ this.persistNativeAuth(result.authToken, result.base58Addr);
22098
+ // Existing valid session — short-circuit before re-creating server-side.
22099
+ if (existingSession && existingSession.address === result.base58Addr) {
22100
+ const user = { provider: this, address: result.base58Addr };
22101
+ setCurrentUser(user);
22102
+ return user;
22103
+ }
22104
+ // Create Tarobase session on the server.
22105
+ if (!result.signatureBase64 || !result.messageText) {
22106
+ throw new Error('MWA login completed without signature');
22107
+ }
22108
+ const createSessionResult = await createSessionWithSignature(result.base58Addr, result.messageText, result.signatureBase64);
22109
+ await WebSessionManager.storeSession(result.base58Addr, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
22110
+ const user = { provider: this, address: result.base58Addr };
22111
+ setCurrentUser(user);
22112
+ return user;
22113
+ }
21925
22114
  async login() {
21926
22115
  var _a, _b, _c, _d, _e;
21927
22116
  setAuthLoading(true);
@@ -21932,6 +22121,13 @@ class SolanaMobileWalletProvider {
21932
22121
  const prevAuthMethod = readAuthMethod();
21933
22122
  writeAuthMethod(MWA_AUTH_METHOD);
21934
22123
  try {
22124
+ // True React Native: skip the wallet-standard-mobile path (which
22125
+ // requires window.isSecureContext and a real DOM) and use the raw
22126
+ // MWA protocol via Android intents.
22127
+ if (!getPlatform().hasDOM) {
22128
+ const user = await this._loginNative();
22129
+ return user;
22130
+ }
21935
22131
  const wallet = await this.ensureWallet();
21936
22132
  // Quick-check: wallet may already have authorization (e.g. from a
21937
22133
  // previous in-page login) and a matching Tarobase session — skip
@@ -22033,6 +22229,29 @@ class SolanaMobileWalletProvider {
22033
22229
  return null;
22034
22230
  }
22035
22231
  async logout() {
22232
+ if (!getPlatform().hasDOM) {
22233
+ // Native path: deauthorize the cached MWA auth_token if we have
22234
+ // one (failures non-fatal — the wallet app may have been
22235
+ // uninstalled or the token already revoked), then clear local
22236
+ // and persisted state.
22237
+ const token = this.nativeAuthToken;
22238
+ if (token) {
22239
+ try {
22240
+ const transact = await this.loadTransact();
22241
+ await transact(async (wallet) => {
22242
+ await wallet.deauthorize({ auth_token: token });
22243
+ });
22244
+ }
22245
+ catch (error) {
22246
+ console.warn('[SolanaMobileWallet] Native deauthorize error:', error);
22247
+ }
22248
+ }
22249
+ this.clearNativeAuth();
22250
+ WebSessionManager.clearSession();
22251
+ writeAuthMethod(null);
22252
+ setCurrentUser(null);
22253
+ return;
22254
+ }
22036
22255
  try {
22037
22256
  const wallet = await this.ensureWallet();
22038
22257
  const disconnectFeat = getDisconnectFeature(wallet);
@@ -22052,7 +22271,42 @@ class SolanaMobileWalletProvider {
22052
22271
  setCurrentUser(null);
22053
22272
  }
22054
22273
  async signMessage(message) {
22055
- var _a, _b;
22274
+ var _a, _b, _c;
22275
+ // Native: reauthorize with cached auth_token, then signMessages inside
22276
+ // the same transact() session. No wallet-pick popup if the auth_token
22277
+ // is still valid for the user's wallet.
22278
+ if (!getPlatform().hasDOM) {
22279
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22280
+ throw new Error('Wallet not connected. Call login() first.');
22281
+ }
22282
+ const transact = await this.loadTransact();
22283
+ const messageBytes = getPlatform().textEncode(message);
22284
+ const addressBase64 = new web3_js.PublicKey(this.nativeAddress).toBuffer().toString('base64');
22285
+ const authToken = this.nativeAuthToken;
22286
+ try {
22287
+ const signature = await transact(async (wallet) => {
22288
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22289
+ const sigs = await wallet.signMessages({
22290
+ addresses: [addressBase64],
22291
+ payloads: [messageBytes],
22292
+ });
22293
+ if (!sigs || sigs.length === 0)
22294
+ throw new Error('MWA returned no signature');
22295
+ return sigs[0];
22296
+ });
22297
+ return bufferExports.Buffer.from(signature).toString('base64');
22298
+ }
22299
+ catch (error) {
22300
+ if (this.isNativeUserCancel(error)) {
22301
+ throw new Error('User declined to sign');
22302
+ }
22303
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22304
+ await this.logout();
22305
+ throw new Error('Wallet connection lost. Please reconnect.');
22306
+ }
22307
+ throw new Error(`Failed to sign message: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22308
+ }
22309
+ }
22056
22310
  const account = await this.ensureAuthorized();
22057
22311
  const wallet = await this.ensureWallet();
22058
22312
  try {
@@ -22066,7 +22320,7 @@ class SolanaMobileWalletProvider {
22066
22320
  return bufferExports.Buffer.from(sigBytes).toString('base64');
22067
22321
  }
22068
22322
  catch (error) {
22069
- 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')) ||
22323
+ 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')) ||
22070
22324
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22071
22325
  await this.logout();
22072
22326
  throw new Error('Wallet connection lost. Please reconnect.');
@@ -22075,7 +22329,58 @@ class SolanaMobileWalletProvider {
22075
22329
  }
22076
22330
  }
22077
22331
  async signTransaction(transaction) {
22078
- var _a, _b;
22332
+ var _a, _b, _c;
22333
+ // Native: fill blockhash/feePayer if missing, then signTransactions
22334
+ // inside a transact() session keyed by the cached auth_token.
22335
+ if (!getPlatform().hasDOM) {
22336
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22337
+ throw new Error('Wallet not connected. Call login() first.');
22338
+ }
22339
+ const connectedPubkey = new web3_js.PublicKey(this.nativeAddress);
22340
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
22341
+ if (isLegacyTransaction) {
22342
+ const legacyTx = transaction;
22343
+ if (!legacyTx.recentBlockhash) {
22344
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
22345
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
22346
+ legacyTx.recentBlockhash = blockhash;
22347
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
22348
+ }
22349
+ if (!legacyTx.feePayer) {
22350
+ legacyTx.feePayer = connectedPubkey;
22351
+ }
22352
+ }
22353
+ else {
22354
+ const versionedTx = transaction;
22355
+ if (!versionedTx.message.recentBlockhash) {
22356
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
22357
+ const { blockhash } = await conn.getLatestBlockhash('confirmed');
22358
+ versionedTx.message.recentBlockhash = blockhash;
22359
+ }
22360
+ }
22361
+ const transact = await this.loadTransact();
22362
+ const authToken = this.nativeAuthToken;
22363
+ try {
22364
+ const signed = await transact(async (wallet) => {
22365
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22366
+ const results = await wallet.signTransactions({ transactions: [transaction] });
22367
+ if (!results || results.length === 0)
22368
+ throw new Error('MWA returned no signed transaction');
22369
+ return results[0];
22370
+ });
22371
+ return signed;
22372
+ }
22373
+ catch (error) {
22374
+ if (this.isNativeUserCancel(error)) {
22375
+ throw new Error('User declined to sign');
22376
+ }
22377
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22378
+ await this.logout();
22379
+ throw new Error('Wallet connection lost. Please reconnect.');
22380
+ }
22381
+ throw new Error(`Failed to sign transaction: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22382
+ }
22383
+ }
22079
22384
  const account = await this.ensureAuthorized();
22080
22385
  const connectedPubkey = new web3_js.PublicKey(account.publicKey);
22081
22386
  const wallet = await this.ensureWallet();
@@ -22106,15 +22411,14 @@ class SolanaMobileWalletProvider {
22106
22411
  try {
22107
22412
  const signTxFeat = getSignTransactionFeature(wallet);
22108
22413
  const wireBytes = txToWireBytes(transaction);
22109
- const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
22110
- if (!results || results.length === 0) {
22111
- throw new Error('MWA returned no signed transaction');
22112
- }
22113
- const { signedTransaction: signedBytes } = results[0];
22414
+ // signTransaction navigates to `solana-wallet:`; only show the
22415
+ // gesture modal if the tap activation has decayed (see runTransaction).
22416
+ const signResult = await signWithFreshActivation(this.config.theme, () => signTxFeat.signTransaction({ account, transaction: wireBytes, chain }), 'MWA returned no signed transaction');
22417
+ const { signedTransaction: signedBytes } = signResult;
22114
22418
  return txFromWireBytes(new Uint8Array(signedBytes));
22115
22419
  }
22116
22420
  catch (error) {
22117
- 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')) ||
22421
+ 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')) ||
22118
22422
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22119
22423
  await this.logout();
22120
22424
  throw new Error('Wallet connection lost. Please reconnect.');
@@ -22123,7 +22427,70 @@ class SolanaMobileWalletProvider {
22123
22427
  }
22124
22428
  }
22125
22429
  async signAndSubmitTransaction(transaction, feePayer) {
22126
- var _a, _b, _c, _d, _e, _f;
22430
+ var _a, _b, _c, _d, _e, _f, _g;
22431
+ // Native: signAndSendTransactions inside a transact() session.
22432
+ // The wallet submits to its own RPC; we then await confirmation on
22433
+ // ours. Surfnet (custom RPC) needs manual submission because the
22434
+ // wallet won't route there — we fall back to sign-only + manual send.
22435
+ if (!getPlatform().hasDOM) {
22436
+ if (!this.nativeAuthToken || !this.nativeAddress) {
22437
+ throw new Error('Wallet not connected. Call login() first.');
22438
+ }
22439
+ const connectedPubkey = new web3_js.PublicKey(this.nativeAddress);
22440
+ const rpcUrl = this.getRpcUrl();
22441
+ const connection = new web3_js.Connection(rpcUrl, 'confirmed');
22442
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
22443
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
22444
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
22445
+ if (isLegacyTransaction) {
22446
+ const legacyTx = transaction;
22447
+ legacyTx.recentBlockhash = blockhash;
22448
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
22449
+ if (!legacyTx.feePayer)
22450
+ legacyTx.feePayer = feePayer !== null && feePayer !== void 0 ? feePayer : connectedPubkey;
22451
+ }
22452
+ else {
22453
+ const versionedTx = transaction;
22454
+ versionedTx.message.recentBlockhash = blockhash;
22455
+ }
22456
+ const transact = await this.loadTransact();
22457
+ const authToken = this.nativeAuthToken;
22458
+ try {
22459
+ if (isSurfnet) {
22460
+ // Surfnet: sign only, submit manually to Surfnet RPC
22461
+ // (the wallet would route signAndSend to its own RPC).
22462
+ const signed = await transact(async (wallet) => {
22463
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22464
+ const results = await wallet.signTransactions({ transactions: [transaction] });
22465
+ if (!results || results.length === 0)
22466
+ throw new Error('MWA returned no signed transaction');
22467
+ return results[0];
22468
+ });
22469
+ const sig = await connection.sendRawTransaction(signed.serialize(), { preflightCommitment: 'confirmed' });
22470
+ await confirmAndCheckTransaction(connection, sig);
22471
+ return sig;
22472
+ }
22473
+ const sig = await transact(async (wallet) => {
22474
+ await wallet.reauthorize({ auth_token: authToken, identity: this.appIdentity });
22475
+ const results = await wallet.signAndSendTransactions({ transactions: [transaction] });
22476
+ if (!results || results.length === 0)
22477
+ throw new Error('MWA returned no signature');
22478
+ return results[0];
22479
+ });
22480
+ await confirmAndCheckTransaction(connection, sig);
22481
+ return sig;
22482
+ }
22483
+ catch (error) {
22484
+ if (this.isNativeUserCancel(error)) {
22485
+ throw new Error('User declined to sign');
22486
+ }
22487
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED' || (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_REAUTHORIZE') {
22488
+ await this.logout();
22489
+ throw new Error('Wallet connection lost. Please reconnect.');
22490
+ }
22491
+ throw new Error(`Failed to sign+submit transaction: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
22492
+ }
22493
+ }
22127
22494
  const account = await this.ensureAuthorized();
22128
22495
  const connectedPubkey = new web3_js.PublicKey(account.publicKey);
22129
22496
  const wallet = await this.ensureWallet();
@@ -22153,11 +22520,9 @@ class SolanaMobileWalletProvider {
22153
22520
  // because the wallet would submit to its own RPC.
22154
22521
  const signTxFeat = getSignTransactionFeature(wallet);
22155
22522
  const wireBytes = txToWireBytes(transaction);
22156
- const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
22157
- if (!results || results.length === 0) {
22158
- throw new Error('MWA returned no signed transaction');
22159
- }
22160
- const { signedTransaction: signedBytes } = results[0];
22523
+ // Gesture modal only if activation decayed (see runTransaction).
22524
+ const signResult = await signWithFreshActivation(this.config.theme, () => signTxFeat.signTransaction({ account, transaction: wireBytes, chain }), 'MWA returned no signed transaction');
22525
+ const { signedTransaction: signedBytes } = signResult;
22161
22526
  const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
22162
22527
  const signature = await connection.sendRawTransaction(signedTx.serialize(), {
22163
22528
  preflightCommitment: 'confirmed',
@@ -22173,33 +22538,31 @@ class SolanaMobileWalletProvider {
22173
22538
  return signature;
22174
22539
  }
22175
22540
  // Non-Surfnet: wallet signs and submits to its own RPC.
22541
+ // Gesture modal only if activation decayed (see runTransaction).
22176
22542
  const signSendFeat = getSignAndSendTransactionFeature(wallet);
22177
22543
  const wireBytes = txToWireBytes(transaction);
22178
- const results = await signSendFeat.signAndSendTransaction({
22544
+ const sendResult = await signWithFreshActivation(this.config.theme, () => signSendFeat.signAndSendTransaction({
22179
22545
  account,
22180
22546
  transaction: wireBytes,
22181
22547
  chain,
22182
22548
  options: { commitment: 'confirmed' },
22183
- });
22184
- if (!results || results.length === 0) {
22185
- throw new Error('MWA returned no signature');
22186
- }
22187
- const { signature: sigBytes } = results[0];
22549
+ }));
22550
+ const { signature: sigBytes } = sendResult;
22188
22551
  const signature = base58.encode(sigBytes);
22189
22552
  await confirmAndCheckTransaction(connection, signature);
22190
22553
  return signature;
22191
22554
  }
22192
22555
  catch (error) {
22193
- 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')) ||
22556
+ 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')) ||
22194
22557
  (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
22195
22558
  await this.logout();
22196
22559
  throw new Error('Wallet connection lost. Please reconnect.');
22197
22560
  }
22198
22561
  const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
22199
- ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user rejected')) ||
22200
- ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user denied')) ||
22201
- ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user cancelled')) ||
22202
- ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user canceled'));
22562
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user rejected')) ||
22563
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user denied')) ||
22564
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user cancelled')) ||
22565
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user canceled'));
22203
22566
  if (!isUserRejection) {
22204
22567
  console.error('[SolanaMobileWallet] Transaction failed:', error);
22205
22568
  }
@@ -22264,11 +22627,13 @@ class SolanaMobileWalletProvider {
22264
22627
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
22265
22628
  const signTxFeat = getSignTransactionFeature(wallet);
22266
22629
  const wireBytes = txToWireBytes(tx);
22267
- const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
22268
- if (!results || results.length === 0) {
22630
+ // signTransaction also navigates to `solana-wallet:`; only
22631
+ // surface the gesture modal if the tap activation has decayed.
22632
+ const signOnlyResult = await signWithFreshActivation(this.config.theme, () => signTxFeat.signTransaction({ account, transaction: wireBytes, chain }), 'MWA returned no signed transaction');
22633
+ if (!signOnlyResult) {
22269
22634
  throw new Error('MWA returned no signed transaction');
22270
22635
  }
22271
- const { signedTransaction: signedBytes } = results[0];
22636
+ const { signedTransaction: signedBytes } = signOnlyResult;
22272
22637
  const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
22273
22638
  return {
22274
22639
  signedTransaction: signedTx,
@@ -22281,11 +22646,13 @@ class SolanaMobileWalletProvider {
22281
22646
  // Surfnet: sign locally via wallet-standard, submit manually.
22282
22647
  const signTxFeat = getSignTransactionFeature(wallet);
22283
22648
  const wireBytes = txToWireBytes(tx);
22284
- const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
22285
- if (!results || results.length === 0) {
22649
+ // signTransaction also navigates to `solana-wallet:`; only
22650
+ // surface the gesture modal if the tap activation has decayed.
22651
+ const surfnetResult = await signWithFreshActivation(this.config.theme, () => signTxFeat.signTransaction({ account, transaction: wireBytes, chain }), 'MWA returned no signed transaction');
22652
+ if (!surfnetResult) {
22286
22653
  throw new Error('MWA returned no signed transaction');
22287
22654
  }
22288
- const { signedTransaction: signedBytes } = results[0];
22655
+ const { signedTransaction: signedBytes } = surfnetResult;
22289
22656
  const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
22290
22657
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
22291
22658
  const signature = await connection.sendRawTransaction(signedTx.serialize(), {
@@ -22311,18 +22678,24 @@ class SolanaMobileWalletProvider {
22311
22678
  };
22312
22679
  }
22313
22680
  // Non-Surfnet: wallet signs and submits to its own RPC.
22681
+ // signAndSendTransaction dispatches a `solana-wallet:` navigation
22682
+ // that Chrome blocks without transient user activation. Fast txs
22683
+ // still hold the tap activation and navigate directly; slow ones
22684
+ // (e.g. a swap whose server build exceeds Chrome's ~5s window)
22685
+ // have lost it, so signWithFreshActivation shows the "Sign in"
22686
+ // modal to mint a fresh activation — no modal when not needed.
22314
22687
  const signSendFeat = getSignAndSendTransactionFeature(wallet);
22315
22688
  const wireBytes = txToWireBytes(tx);
22316
- const results = await signSendFeat.signAndSendTransaction({
22689
+ const sendResult = await signWithFreshActivation(this.config.theme, () => signSendFeat.signAndSendTransaction({
22317
22690
  account,
22318
22691
  transaction: wireBytes,
22319
22692
  chain,
22320
22693
  options: { commitment: 'confirmed' },
22321
- });
22322
- if (!results || results.length === 0) {
22694
+ }));
22695
+ if (!sendResult) {
22323
22696
  throw new Error('MWA returned no signature');
22324
22697
  }
22325
- const { signature: sigBytes } = results[0];
22698
+ const { signature: sigBytes } = sendResult;
22326
22699
  const signature = base58.encode(sigBytes);
22327
22700
  const txInfo = await confirmAndCheckTransaction(connection, signature);
22328
22701
  return {
@@ -22766,6 +23139,7 @@ exports.bufferExports = bufferExports;
22766
23139
  exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
22767
23140
  exports.clearCache = clearCache;
22768
23141
  exports.closeAllSubscriptions = closeAllSubscriptions;
23142
+ exports.commonjsRequire = commonjsRequire;
22769
23143
  exports.convertRemainingAccounts = convertRemainingAccounts;
22770
23144
  exports.count = count;
22771
23145
  exports.createSessionWithPrivy = createSessionWithPrivy;
@@ -22793,6 +23167,7 @@ exports.onAuthStateChanged = onAuthStateChanged;
22793
23167
  exports.reconnectWithNewAuth = reconnectWithNewAuth;
22794
23168
  exports.refreshSession = refreshSession;
22795
23169
  exports.registerMobileWalletAdapter = registerMobileWalletAdapter;
23170
+ exports.require$$0 = require$$0;
22796
23171
  exports.runExpression = runExpression;
22797
23172
  exports.runExpressionMany = runExpressionMany;
22798
23173
  exports.runQuery = runQuery;
@@ -22807,4 +23182,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
22807
23182
  exports.signTransaction = signTransaction;
22808
23183
  exports.subscribe = subscribe;
22809
23184
  exports.useAuth = useAuth;
22810
- //# sourceMappingURL=index-hEc5_KoM.js.map
23185
+ //# sourceMappingURL=index-Lm0k5Hwv.js.map