@pooflabs/web 0.0.84 → 0.0.85-rc2

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 (67) hide show
  1. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +47 -20
  2. package/dist/{index-BM6hgCdH.js → index-B1_Q49qQ.js} +2 -2
  3. package/dist/{index-BM6hgCdH.js.map → index-B1_Q49qQ.js.map} +1 -1
  4. package/dist/{index-CH2G5Y9i.esm.js → index-B7tJ8TAn.esm.js} +2 -2
  5. package/dist/{index-CH2G5Y9i.esm.js.map → index-B7tJ8TAn.esm.js.map} +1 -1
  6. package/dist/{index-BPlF6-PQ.js → index-BeFR3-cf.js} +522 -289
  7. package/dist/{index-BPlF6-PQ.js.map → index-BeFR3-cf.js.map} +1 -1
  8. package/dist/index-DbJCCvVN.esm.js +6 -0
  9. package/dist/index-DbJCCvVN.esm.js.map +1 -0
  10. package/dist/{index-CSeN3jbG.js → index-DflG_JAB.js} +3 -3
  11. package/dist/{index-CSeN3jbG.js.map → index-DflG_JAB.js.map} +1 -1
  12. package/dist/{index-Bp4b5LXs.js → index-DyRIXw-l.js} +2 -2
  13. package/dist/index-DyRIXw-l.js.map +1 -0
  14. package/dist/{index-XHbmzFFO.esm.js → index-QukWgaIi.esm.js} +523 -290
  15. package/dist/{index-XHbmzFFO.esm.js.map → index-QukWgaIi.esm.js.map} +1 -1
  16. package/dist/{index-ep10Sw82.esm.js → index-agGmWBn4.esm.js} +3 -3
  17. package/dist/{index-ep10Sw82.esm.js.map → index-agGmWBn4.esm.js.map} +1 -1
  18. package/dist/{index.browser-C1QL04xM.js → index.browser-BJmFjY2f.js} +1006 -15
  19. package/dist/index.browser-BJmFjY2f.js.map +1 -0
  20. package/dist/index.browser-DZtZWdul.js +4994 -0
  21. package/dist/index.browser-DZtZWdul.js.map +1 -0
  22. package/dist/index.browser-lHP9glAW.esm.js +6060 -0
  23. package/dist/index.browser-lHP9glAW.esm.js.map +1 -0
  24. package/dist/{index.browser-Cgj7Hs6n.esm.js → index.browser-p-pgsxxW.esm.js} +836 -916
  25. package/dist/index.browser-p-pgsxxW.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-BmtuyGXs.js → index.native-ANhb4jEB.js} +4 -4
  29. package/dist/{index.native-BmtuyGXs.js.map → index.native-ANhb4jEB.js.map} +1 -1
  30. package/dist/{index.native-X01vlukI.esm.js → index.native-a3mhu9HP.esm.js} +4 -4
  31. package/dist/{index.native-X01vlukI.esm.js.map → index.native-a3mhu9HP.esm.js.map} +1 -1
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +1 -1
  34. package/dist/{phantom-wallet-provider-C_LPU6Ns.js → phantom-wallet-provider-BOdn0D1Q.js} +4 -4
  35. package/dist/{phantom-wallet-provider-C_LPU6Ns.js.map → phantom-wallet-provider-BOdn0D1Q.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-DRvhBbbR.esm.js → phantom-wallet-provider-Dsza6TBv.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-DRvhBbbR.esm.js.map → phantom-wallet-provider-Dsza6TBv.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-DQM8xO38.js → privy-wallet-provider-BlPh3Gn_.js} +3 -3
  39. package/dist/{privy-wallet-provider-DQM8xO38.js.map → privy-wallet-provider-BlPh3Gn_.js.map} +1 -1
  40. package/dist/{privy-wallet-provider-ZGu8q5T5.esm.js → privy-wallet-provider-bwwhkFjL.esm.js} +3 -3
  41. package/dist/{privy-wallet-provider-ZGu8q5T5.esm.js.map → privy-wallet-provider-bwwhkFjL.esm.js.map} +1 -1
  42. package/dist/solana-mobile-wallet-provider-S8yWHG6i.js +841 -0
  43. package/dist/solana-mobile-wallet-provider-S8yWHG6i.js.map +1 -0
  44. package/dist/solana-mobile-wallet-provider-fzLIgJBf.esm.js +820 -0
  45. package/dist/solana-mobile-wallet-provider-fzLIgJBf.esm.js.map +1 -0
  46. package/package.json +2 -1
  47. package/dist/index-Bp4b5LXs.js.map +0 -1
  48. package/dist/index-C80kRxWk.esm.js +0 -6
  49. package/dist/index-C80kRxWk.esm.js.map +0 -1
  50. package/dist/index.browser-BvNsUWjt.js +0 -105
  51. package/dist/index.browser-BvNsUWjt.js.map +0 -1
  52. package/dist/index.browser-BwIqqM4U.js +0 -1099
  53. package/dist/index.browser-BwIqqM4U.js.map +0 -1
  54. package/dist/index.browser-C1QL04xM.js.map +0 -1
  55. package/dist/index.browser-Cgj7Hs6n.esm.js.map +0 -1
  56. package/dist/index.browser-CifFI7Ju.esm.js +0 -1096
  57. package/dist/index.browser-CifFI7Ju.esm.js.map +0 -1
  58. package/dist/index.browser-D8VWPXTZ.esm.js +0 -102
  59. package/dist/index.browser-D8VWPXTZ.esm.js.map +0 -1
  60. package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
  61. package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
  62. package/dist/index.browser-vuTr40so.js +0 -1008
  63. package/dist/index.browser-vuTr40so.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-6gNw2_bX.js +0 -608
  65. package/dist/solana-mobile-wallet-provider-6gNw2_bX.js.map +0 -1
  66. package/dist/solana-mobile-wallet-provider-B65A7abd.esm.js +0 -587
  67. package/dist/solana-mobile-wallet-provider-B65A7abd.esm.js.map +0 -1
@@ -0,0 +1,841 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-DyRIXw-l.js');
4
+ var index_native = require('./index.native-ANhb4jEB.js');
5
+ var web3_js = require('@solana/web3.js');
6
+ var anchor = require('@coral-xyz/anchor');
7
+ require('axios');
8
+ require('react');
9
+
10
+ function _interopNamespaceDefault(e) {
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
28
+
29
+ const ED25519_SIGNATURE_LENGTH = 64;
30
+ const STORED_AUTH_METHOD_KEY = 'tarobase_last_auth_method';
31
+ const MWA_AUTH_METHOD = 'mobile-wallet-adapter';
32
+ function findMwaError(e, maxDepth = 5) {
33
+ var _a;
34
+ let cur = e;
35
+ let depth = 0;
36
+ while (cur && depth < maxDepth) {
37
+ if ((cur === null || cur === void 0 ? void 0 : cur.name) === 'SolanaMobileWalletAdapterError' && typeof (cur === null || cur === void 0 ? void 0 : cur.code) === 'string') {
38
+ return { code: cur.code, message: String((_a = cur.message) !== null && _a !== void 0 ? _a : '') };
39
+ }
40
+ cur = cur === null || cur === void 0 ? void 0 : cur.cause;
41
+ depth++;
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * Returns the matched MwaErrorInfo when the error is from an association
47
+ * failure that an automatic retry can recover from (i.e. the wallet exists
48
+ * on-device but the dApp's protocol session didn't complete in time). Returns
49
+ * null for non-retryable errors (user cancel, unknown wallet errors, etc.).
50
+ *
51
+ * Specifically:
52
+ * - ERROR_WALLET_NOT_FOUND: thrown from the protocol's startScenario when
53
+ * it gave up waiting for a wallet to respond. On Seeker this races the
54
+ * first-time-consent UI on the very first authorize.
55
+ * - ERROR_SESSION_TIMEOUT: similar — the protocol's session-establishment
56
+ * timer expired.
57
+ * - ERROR_ASSOCIATION_CANCELLED: shared by user-cancel ("Wallet connection
58
+ * cancelled by user") AND the 30s wallet-standard WALLET_ASSOCIATION_TIMEOUT
59
+ * ("Wallet connection timed out"). Discriminate by message — never retry
60
+ * a user cancel.
61
+ */
62
+ function isMwaAssociationRetryable(e) {
63
+ const info = findMwaError(e);
64
+ if (!info)
65
+ return null;
66
+ if (info.code === 'ERROR_WALLET_NOT_FOUND')
67
+ return info;
68
+ if (info.code === 'ERROR_SESSION_TIMEOUT')
69
+ return info;
70
+ if (info.code === 'ERROR_ASSOCIATION_CANCELLED' && /timed out/i.test(info.message))
71
+ return info;
72
+ return null;
73
+ }
74
+ /**
75
+ * Single-retry wrapper for MWA association failures. Used ONLY for login's
76
+ * `standard:connect` and `solana:signMessage` calls — never for
77
+ * `signAndSendTransaction`/`runTransaction` because retry on a path that
78
+ * may have already submitted a tx can double-send.
79
+ *
80
+ * The retry exists for one specific scenario: on first-time MWA usage from a
81
+ * given origin on Seeker, the protocol's session-establishment timer races
82
+ * Seeker's first-time consent UI. The user reads the consent sheet, taps
83
+ * Connect — but by then the protocol has given up and thrown
84
+ * ERROR_WALLET_NOT_FOUND. The consent itself IS persisted on Seeker though,
85
+ * so a second attempt skips the consent sheet, jumps straight to
86
+ * Verify/Approve, and completes inside the timeout.
87
+ */
88
+ async function withMwaAssociationRetry(label, fn) {
89
+ const t0 = Date.now();
90
+ console.log(`[MWA-DEBUG] ${label} attempt=1 start`);
91
+ try {
92
+ const result = await fn();
93
+ console.log(`[MWA-DEBUG] ${label} attempt=1 ok (${Date.now() - t0}ms)`);
94
+ return result;
95
+ }
96
+ catch (e) {
97
+ const info = findMwaError(e);
98
+ console.log(`[MWA-DEBUG] ${label} attempt=1 err (${Date.now() - t0}ms)`, {
99
+ outer: { name: e === null || e === void 0 ? void 0 : e.name, message: e === null || e === void 0 ? void 0 : e.message },
100
+ mwa: info,
101
+ });
102
+ const retryable = isMwaAssociationRetryable(e);
103
+ if (!retryable)
104
+ throw e;
105
+ // Seeker's consent sheet is a bottom-sheet overlay — Chrome doesn't
106
+ // reliably flip document.visibilityState to 'hidden' while it's open,
107
+ // so visibility-based waits fire too early. Use a fixed delay long
108
+ // enough for Seeker to dismiss its sheet and the OS to release intent
109
+ // state. 2.5s is empirically safe; tune from device traces if needed.
110
+ console.log(`[MWA-DEBUG] ${label} retryable (${retryable.code}); waiting 2500ms before retry`);
111
+ await new Promise(r => setTimeout(r, 2500));
112
+ const t1 = Date.now();
113
+ console.log(`[MWA-DEBUG] ${label} attempt=2 start`);
114
+ try {
115
+ const result = await fn();
116
+ console.log(`[MWA-DEBUG] ${label} attempt=2 ok (${Date.now() - t1}ms)`);
117
+ return result;
118
+ }
119
+ catch (e2) {
120
+ const info2 = findMwaError(e2);
121
+ console.log(`[MWA-DEBUG] ${label} attempt=2 err (${Date.now() - t1}ms)`, {
122
+ outer: { name: e2 === null || e2 === void 0 ? void 0 : e2.name, message: e2 === null || e2 === void 0 ? void 0 : e2.message },
123
+ mwa: info2,
124
+ });
125
+ // Only mask the error with the clean Seeker message when the
126
+ // second failure is also an association-flavored error. If it's
127
+ // a user cancel, wallet rejection, or unknown error, rethrow
128
+ // the original so the host app surfaces the real cause.
129
+ if (isMwaAssociationRetryable(e2)) {
130
+ throw new Error("Couldn't connect to your Seeker wallet. Please try again.");
131
+ }
132
+ throw e2;
133
+ }
134
+ }
135
+ }
136
+ /**
137
+ * Normalize a chain string to a wallet-standard Solana chain identifier.
138
+ *
139
+ * Handles three input shapes that all show up in practice:
140
+ * - Bare cluster name from `SolanaMobileWalletConfig.cluster` (e.g. 'devnet').
141
+ * - Prefixed `solana:cluster` (e.g. 'solana:devnet').
142
+ * - Double-prefixed `solana:solana:cluster` (constructor used to wrap cluster
143
+ * with `solana:` blindly; if a caller already passed a prefixed string the
144
+ * result was `solana:solana:devnet`).
145
+ *
146
+ * Wallet-standard Solana chains are exactly:
147
+ * 'solana:mainnet' | 'solana:devnet' | 'solana:testnet' | 'solana:localnet'
148
+ * — `mainnet-beta` is NOT a valid wallet-standard identifier and must be
149
+ * normalized to `solana:mainnet`.
150
+ */
151
+ function mapChainToWalletStandard(input) {
152
+ if (!input)
153
+ return 'solana:mainnet';
154
+ let s = String(input).toLowerCase();
155
+ while (s.startsWith('solana:'))
156
+ s = s.slice('solana:'.length);
157
+ if (s === 'mainnet-beta' || s === 'mainnet')
158
+ return 'solana:mainnet';
159
+ if (s === 'devnet')
160
+ return 'solana:devnet';
161
+ if (s === 'testnet')
162
+ return 'solana:testnet';
163
+ if (s === 'localnet')
164
+ return 'solana:localnet';
165
+ return 'solana:mainnet';
166
+ }
167
+ /**
168
+ * Serialize a Transaction/VersionedTransaction to a Uint8Array wire payload
169
+ * that the wallet-standard `solana:signTransaction` /
170
+ * `solana:signAndSendTransaction` features expect.
171
+ *
172
+ * Legacy transactions must serialize with `requireAllSignatures: false` and
173
+ * `verifySignatures: false` — the wallet hasn't signed yet, and the default
174
+ * `serialize()` would throw "Signature verification failed". Versioned
175
+ * transactions use the default `serialize()` which already permits unsigned
176
+ * payloads. Mirrors the helper at
177
+ * `@solana-mobile/mobile-wallet-adapter-protocol-web3js/lib/esm/index.browser.js:13-18`.
178
+ */
179
+ function txToWireBytes(tx) {
180
+ if ('version' in tx)
181
+ return tx.serialize();
182
+ return tx.serialize({ requireAllSignatures: false, verifySignatures: false });
183
+ }
184
+ /**
185
+ * Deserialize a wire-format transaction returned by the wallet
186
+ * `solana:signTransaction` feature. Mirrors the helper at
187
+ * `@solana-mobile/mobile-wallet-adapter-protocol-web3js/lib/esm/index.browser.js:19-23`
188
+ * so legacy and versioned bytes both round-trip correctly.
189
+ */
190
+ function txFromWireBytes(byteArray) {
191
+ const messageOffset = byteArray[0] * ED25519_SIGNATURE_LENGTH + 1;
192
+ const messageVersion = web3_js.VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length));
193
+ if (messageVersion === 'legacy') {
194
+ return web3_js.Transaction.from(byteArray);
195
+ }
196
+ return web3_js.VersionedTransaction.deserialize(byteArray);
197
+ }
198
+ /**
199
+ * Per-method runtime narrowing of wallet-standard features. The wallet's
200
+ * `.features` type is a union (`signAndSendTransaction` | `signTransaction`),
201
+ * and after authorization the wallet may also narrow `#optionalFeatures`
202
+ * based on actual wallet capabilities. Narrow at the call site so a method
203
+ * that needs only `signMessage` doesn't fail when a wallet lacks
204
+ * `signTransaction`.
205
+ */
206
+ function getSignMessageFeature(wallet) {
207
+ const f = wallet.features;
208
+ const feat = f['solana:signMessage'];
209
+ if (!feat || typeof feat.signMessage !== 'function') {
210
+ throw new Error('Wallet does not support solana:signMessage');
211
+ }
212
+ return feat;
213
+ }
214
+ function getSignTransactionFeature(wallet) {
215
+ const f = wallet.features;
216
+ const feat = f['solana:signTransaction'];
217
+ if (!feat || typeof feat.signTransaction !== 'function') {
218
+ throw new Error('Wallet does not support solana:signTransaction');
219
+ }
220
+ return feat;
221
+ }
222
+ function getSignAndSendTransactionFeature(wallet) {
223
+ const f = wallet.features;
224
+ const feat = f['solana:signAndSendTransaction'];
225
+ if (!feat || typeof feat.signAndSendTransaction !== 'function') {
226
+ throw new Error('Wallet does not support solana:signAndSendTransaction');
227
+ }
228
+ return feat;
229
+ }
230
+ function getConnectFeature(wallet) {
231
+ const f = wallet.features;
232
+ const feat = f['standard:connect'];
233
+ if (!feat || typeof feat.connect !== 'function') {
234
+ throw new Error('Wallet does not support standard:connect');
235
+ }
236
+ return feat;
237
+ }
238
+ function getDisconnectFeature(wallet) {
239
+ const f = wallet.features;
240
+ const feat = f['standard:disconnect'];
241
+ return feat && typeof feat.disconnect === 'function' ? feat : null;
242
+ }
243
+ function writeAuthMethod(method) {
244
+ try {
245
+ if (method === null) {
246
+ index_native.getPlatform().storage.removeItem(STORED_AUTH_METHOD_KEY);
247
+ }
248
+ else {
249
+ index_native.getPlatform().storage.setItem(STORED_AUTH_METHOD_KEY, method);
250
+ }
251
+ }
252
+ catch (_a) {
253
+ // storage may be unavailable
254
+ }
255
+ }
256
+ function readAuthMethod() {
257
+ try {
258
+ return index_native.getPlatform().storage.getItem(STORED_AUTH_METHOD_KEY);
259
+ }
260
+ catch (_a) {
261
+ return null;
262
+ }
263
+ }
264
+ /**
265
+ * SolanaMobileWalletProvider implements the AuthProvider interface using
266
+ * Solana Mobile's wallet-standard wrapper (`LocalSolanaMobileWalletAdapterWallet`).
267
+ *
268
+ * Why wallet-standard and not the raw MWA protocol: as of
269
+ * `@solana-mobile/wallet-standard-mobile@0.5.0+`, the wallet's internal
270
+ * `#transact` calls `checkLocalNetworkAccessPermission()` before opening the
271
+ * localhost WebSocket. That helper renders a three-stage UX flow Solana
272
+ * Mobile designed specifically to defuse Chrome's Local Network Access
273
+ * permission dialog (which renders with disabled buttons on Android Chrome,
274
+ * the source of the long-running Seeker MWA bug):
275
+ *
276
+ * 1. "Allow connections to your wallet" informational modal.
277
+ * 2. Chrome's permission prompt (interactive because it's spawned as a
278
+ * fresh user gesture from step 1).
279
+ * 3. "Ready to connect!" success modal.
280
+ *
281
+ * `checkLocalNetworkAccessPermission` is internal to the library — it's not
282
+ * exported. The only way to invoke it is to go through the wallet's
283
+ * `standard:connect` / `solana:sign*` features, which is what this provider
284
+ * does.
285
+ *
286
+ * Notes on UX: login uses two wallet popups in succession — `standard:connect`
287
+ * (authorize) and `solana:signMessage` (sign the Tarobase nonce). The
288
+ * previous implementation combined both inside a single `transact` callback;
289
+ * splitting them is the cost of going through wallet-standard, and is
290
+ * acceptable given the alternative was broken on Seeker.
291
+ */
292
+ class SolanaMobileWalletProvider {
293
+ constructor(networkUrl = null, config = {}) {
294
+ /** LocalSolanaMobileWalletAdapterWallet, lazy-constructed in ensureWallet(). */
295
+ this.wallet = null;
296
+ this.networkUrl = networkUrl;
297
+ this.config = config;
298
+ if (typeof window === 'undefined') {
299
+ throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser environment');
300
+ }
301
+ if (SolanaMobileWalletProvider.instance) {
302
+ return SolanaMobileWalletProvider.instance;
303
+ }
304
+ this.appIdentity = config.appIdentity || {
305
+ name: 'TaroBase App',
306
+ uri: index_native.getPlatform().getLocationOrigin(),
307
+ };
308
+ this.cluster = config.cluster || 'mainnet-beta';
309
+ SolanaMobileWalletProvider.instance = this;
310
+ }
311
+ static getInstance(networkUrl, config) {
312
+ if (!SolanaMobileWalletProvider.instance) {
313
+ new SolanaMobileWalletProvider(networkUrl, config);
314
+ }
315
+ return SolanaMobileWalletProvider.instance;
316
+ }
317
+ /** Lazy-construct LocalSolanaMobileWalletAdapterWallet on first need. */
318
+ async ensureWallet() {
319
+ if (this.wallet)
320
+ return this.wallet;
321
+ const mod = await Promise.resolve().then(function () { return require('./index.browser-DZtZWdul.js'); });
322
+ const chain = mapChainToWalletStandard(this.cluster);
323
+ this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
324
+ appIdentity: this.appIdentity,
325
+ authorizationCache: mod.createDefaultAuthorizationCache(),
326
+ chains: [chain],
327
+ chainSelector: mod.createDefaultChainSelector(),
328
+ // Suppress the default "We can't find a wallet" modal — that
329
+ // modal is misleading when ERROR_WALLET_NOT_FOUND fires during
330
+ // a first-time-consent race on Seeker (the wallet IS installed,
331
+ // the protocol just gave up before the user finished consenting).
332
+ // login()'s withMwaAssociationRetry handles this case; on second
333
+ // failure it surfaces a clean error message to the host app.
334
+ onWalletNotFound: async () => {
335
+ console.warn('[MWA-DEBUG] ensureWallet onWalletNotFound (suppressed)');
336
+ },
337
+ });
338
+ return this.wallet;
339
+ }
340
+ /**
341
+ * Ensure the wallet has an active authorization. After a Tarobase session
342
+ * is restored from storage on cold-start, `wallet.accounts` is empty until
343
+ * we silently reconnect from the AuthorizationCache. If the cache is also
344
+ * empty, fall back to interactive `login()` (which surfaces the three-stage
345
+ * Solana Mobile LNA flow + wallet popups).
346
+ *
347
+ * Returns the wallet-standard `WalletAccount` to use for sign operations.
348
+ */
349
+ async ensureAuthorized() {
350
+ const wallet = await this.ensureWallet();
351
+ if (wallet.accounts.length === 0) {
352
+ try {
353
+ const connectFeat = getConnectFeature(wallet);
354
+ await connectFeat.connect({ silent: true });
355
+ }
356
+ catch (e) {
357
+ console.warn('[SolanaMobileWallet] silent connect failed:', e === null || e === void 0 ? void 0 : e.message);
358
+ }
359
+ }
360
+ if (wallet.accounts.length === 0) {
361
+ const user = await this.login();
362
+ if (!user)
363
+ throw new Error('MWA not connected');
364
+ }
365
+ return wallet.accounts[0];
366
+ }
367
+ /** Returns the active wallet-standard chain identifier (e.g. 'solana:mainnet'). */
368
+ getChain() {
369
+ return mapChainToWalletStandard(this.cluster);
370
+ }
371
+ async login() {
372
+ var _a, _b, _c, _d, _e;
373
+ index_native.setAuthLoading(true);
374
+ // Mark the auth method early so a concurrent Phantom auto-create-session
375
+ // effect (see phantom-wallet-provider) sees 'mobile-wallet-adapter'
376
+ // during our slow connect/sign roundtrip and backs off. Capture the
377
+ // previous value so we can restore it if login fails.
378
+ const prevAuthMethod = readAuthMethod();
379
+ writeAuthMethod(MWA_AUTH_METHOD);
380
+ try {
381
+ const wallet = await this.ensureWallet();
382
+ // Quick-check: wallet may already have authorization (e.g. from a
383
+ // previous in-page login) and a matching Tarobase session — skip
384
+ // popups in that case.
385
+ if (wallet.accounts.length > 0) {
386
+ const accountPubkey = new web3_js.PublicKey(wallet.accounts[0].publicKey);
387
+ const base58Addr = accountPubkey.toBase58();
388
+ const existingSession = await index_native.WebSessionManager.getSession();
389
+ if (existingSession && existingSession.address === base58Addr) {
390
+ const user = { provider: this, address: base58Addr };
391
+ index_native.setCurrentUser(user);
392
+ return user;
393
+ }
394
+ }
395
+ // Pre-fetch nonce while the wallet popup is not yet open.
396
+ const nonce = await index_native.genAuthNonce();
397
+ // Wallet popup #1: standard:connect performs MWA authorize. This
398
+ // is where wallet-standard's checkLocalNetworkAccessPermission()
399
+ // fires the three-stage LNA UX (info modal → permission prompt →
400
+ // success modal) before opening the localhost WebSocket.
401
+ //
402
+ // Wrap with single-retry: on a Seeker origin's first MWA usage,
403
+ // the protocol's session-establishment timer often races Seeker's
404
+ // first-time consent UI and throws ERROR_WALLET_NOT_FOUND before
405
+ // the user finishes tapping. The retry hits Seeker's cached
406
+ // consent on the second pass and completes quickly. See
407
+ // withMwaAssociationRetry for details.
408
+ const connectFeat = getConnectFeature(wallet);
409
+ const { accounts } = await withMwaAssociationRetry('login:connect', () => connectFeat.connect());
410
+ if (!accounts || accounts.length === 0) {
411
+ throw new Error('MWA returned no accounts');
412
+ }
413
+ const account = accounts[0];
414
+ const accountPubkey = new web3_js.PublicKey(account.publicKey);
415
+ const base58Addr = accountPubkey.toBase58();
416
+ // If we happen to already have a matching Tarobase session, reuse it.
417
+ const existingSession = await index_native.WebSessionManager.getSession();
418
+ if (existingSession && existingSession.address === base58Addr) {
419
+ const user = { provider: this, address: base58Addr };
420
+ index_native.setCurrentUser(user);
421
+ return user;
422
+ }
423
+ // Wallet popup #2: sign the Tarobase nonce message. Wrap with the
424
+ // same retry for defense in depth — by now Seeker has cached the
425
+ // consent so this rarely hits the retry path, but if the
426
+ // protocol's session timer fires here too we recover transparently.
427
+ const messageText = await index_native.genSolanaMessage(base58Addr, nonce);
428
+ const messageBytes = index_native.getPlatform().textEncode(messageText);
429
+ const signMessageFeat = getSignMessageFeature(wallet);
430
+ const signResults = await withMwaAssociationRetry('login:signMessage', () => signMessageFeat.signMessage({ account, message: messageBytes }));
431
+ if (!signResults || signResults.length === 0) {
432
+ throw new Error('MWA returned no signature');
433
+ }
434
+ const { signature: sigBytes } = signResults[0];
435
+ const signatureBase64 = index.bufferExports.Buffer.from(sigBytes).toString('base64');
436
+ // Create Tarobase session on the server.
437
+ const createSessionResult = await index_native.createSessionWithSignature(base58Addr, messageText, signatureBase64);
438
+ await index_native.WebSessionManager.storeSession(base58Addr, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
439
+ // Auth-method marker is already 'mobile-wallet-adapter' from above.
440
+ const user = { provider: this, address: base58Addr };
441
+ index_native.setCurrentUser(user);
442
+ return user;
443
+ }
444
+ catch (error) {
445
+ // Restore the previous auth-method marker since this login attempt failed.
446
+ writeAuthMethod(prevAuthMethod);
447
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
448
+ ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('user rejected')) ||
449
+ ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('user denied')) ||
450
+ ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user cancelled')) ||
451
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user canceled')) ||
452
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user declined'));
453
+ if (!isUserRejection) {
454
+ console.error('[SolanaMobileWallet] Login failed:', error);
455
+ }
456
+ throw error;
457
+ }
458
+ finally {
459
+ index_native.setAuthLoading(false);
460
+ }
461
+ }
462
+ async restoreSession() {
463
+ const session = await index_native.WebSessionManager.getSession();
464
+ if (session) {
465
+ return { provider: this, address: session.address };
466
+ }
467
+ return null;
468
+ }
469
+ async logout() {
470
+ try {
471
+ const wallet = await this.ensureWallet();
472
+ const disconnectFeat = getDisconnectFeature(wallet);
473
+ if (disconnectFeat) {
474
+ // Disconnect clears the AuthorizationCache and resets
475
+ // wallet.#authorization internally (no LNA dialog).
476
+ await disconnectFeat.disconnect();
477
+ }
478
+ }
479
+ catch (error) {
480
+ console.error('[SolanaMobileWallet] Disconnect error:', error);
481
+ }
482
+ index_native.WebSessionManager.clearSession();
483
+ // Clear the auth-method marker so Phantom auto-create is unblocked
484
+ // for any subsequent fresh login on this device.
485
+ writeAuthMethod(null);
486
+ index_native.setCurrentUser(null);
487
+ }
488
+ async signMessage(message) {
489
+ var _a, _b;
490
+ const account = await this.ensureAuthorized();
491
+ const wallet = await this.ensureWallet();
492
+ try {
493
+ const signMessageFeat = getSignMessageFeature(wallet);
494
+ const messageBytes = index_native.getPlatform().textEncode(message);
495
+ const results = await signMessageFeat.signMessage({ account, message: messageBytes });
496
+ if (!results || results.length === 0) {
497
+ throw new Error('MWA returned no signature');
498
+ }
499
+ const { signature: sigBytes } = results[0];
500
+ return index.bufferExports.Buffer.from(sigBytes).toString('base64');
501
+ }
502
+ catch (error) {
503
+ 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')) ||
504
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
505
+ await this.logout();
506
+ throw new Error('Wallet connection lost. Please reconnect.');
507
+ }
508
+ throw new Error(`Failed to sign message: ${error.message}`);
509
+ }
510
+ }
511
+ async signTransaction(transaction) {
512
+ var _a, _b;
513
+ const account = await this.ensureAuthorized();
514
+ const connectedPubkey = new web3_js.PublicKey(account.publicKey);
515
+ const wallet = await this.ensureWallet();
516
+ const chain = this.getChain();
517
+ // Preserve existing prep: fill missing blockhash / fee payer so call
518
+ // sites that build a tx without these fields don't regress.
519
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
520
+ if (isLegacyTransaction) {
521
+ const legacyTx = transaction;
522
+ if (!legacyTx.recentBlockhash) {
523
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
524
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
525
+ legacyTx.recentBlockhash = blockhash;
526
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
527
+ }
528
+ if (!legacyTx.feePayer) {
529
+ legacyTx.feePayer = connectedPubkey;
530
+ }
531
+ }
532
+ else {
533
+ const versionedTx = transaction;
534
+ if (!versionedTx.message.recentBlockhash) {
535
+ const conn = new web3_js.Connection(this.getRpcUrl(), 'confirmed');
536
+ const { blockhash } = await conn.getLatestBlockhash('confirmed');
537
+ versionedTx.message.recentBlockhash = blockhash;
538
+ }
539
+ }
540
+ try {
541
+ const signTxFeat = getSignTransactionFeature(wallet);
542
+ const wireBytes = txToWireBytes(transaction);
543
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
544
+ if (!results || results.length === 0) {
545
+ throw new Error('MWA returned no signed transaction');
546
+ }
547
+ const { signedTransaction: signedBytes } = results[0];
548
+ return txFromWireBytes(new Uint8Array(signedBytes));
549
+ }
550
+ catch (error) {
551
+ 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')) ||
552
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
553
+ await this.logout();
554
+ throw new Error('Wallet connection lost. Please reconnect.');
555
+ }
556
+ throw new Error(`Failed to sign transaction: ${error.message}`);
557
+ }
558
+ }
559
+ async signAndSubmitTransaction(transaction, feePayer) {
560
+ var _a, _b, _c, _d, _e, _f;
561
+ const account = await this.ensureAuthorized();
562
+ const connectedPubkey = new web3_js.PublicKey(account.publicKey);
563
+ const wallet = await this.ensureWallet();
564
+ const chain = this.getChain();
565
+ const rpcUrl = this.getRpcUrl();
566
+ const connection = new web3_js.Connection(rpcUrl, 'confirmed');
567
+ const isSurfnet = rpcUrl === index_native.SURFNET_RPC_URL;
568
+ try {
569
+ // Preserve existing prep: refresh blockhash and set fee payer.
570
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
571
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
572
+ if (isLegacyTransaction) {
573
+ const legacyTx = transaction;
574
+ legacyTx.recentBlockhash = blockhash;
575
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
576
+ if (!legacyTx.feePayer) {
577
+ legacyTx.feePayer = feePayer !== null && feePayer !== void 0 ? feePayer : connectedPubkey;
578
+ }
579
+ }
580
+ else {
581
+ const versionedTx = transaction;
582
+ versionedTx.message.recentBlockhash = blockhash;
583
+ }
584
+ if (isSurfnet) {
585
+ // Surfnet: sign locally via wallet-standard, submit manually
586
+ // to the Surfnet RPC. Don't route through signAndSendTransaction
587
+ // because the wallet would submit to its own RPC.
588
+ const signTxFeat = getSignTransactionFeature(wallet);
589
+ const wireBytes = txToWireBytes(transaction);
590
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
591
+ if (!results || results.length === 0) {
592
+ throw new Error('MWA returned no signed transaction');
593
+ }
594
+ const { signedTransaction: signedBytes } = results[0];
595
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
596
+ const signature = await connection.sendRawTransaction(signedTx.serialize(), {
597
+ preflightCommitment: 'confirmed',
598
+ });
599
+ const confirmation = await connection.confirmTransaction({
600
+ signature,
601
+ blockhash,
602
+ lastValidBlockHeight,
603
+ }, 'confirmed');
604
+ if (confirmation.value.err) {
605
+ throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
606
+ }
607
+ return signature;
608
+ }
609
+ // Non-Surfnet: wallet signs and submits to its own RPC.
610
+ const signSendFeat = getSignAndSendTransactionFeature(wallet);
611
+ const wireBytes = txToWireBytes(transaction);
612
+ const results = await signSendFeat.signAndSendTransaction({
613
+ account,
614
+ transaction: wireBytes,
615
+ chain,
616
+ options: { commitment: 'confirmed' },
617
+ });
618
+ if (!results || results.length === 0) {
619
+ throw new Error('MWA returned no signature');
620
+ }
621
+ const { signature: sigBytes } = results[0];
622
+ const signature = index_native.base58.encode(sigBytes);
623
+ await index_native.confirmAndCheckTransaction(connection, signature);
624
+ return signature;
625
+ }
626
+ catch (error) {
627
+ 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')) ||
628
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
629
+ await this.logout();
630
+ throw new Error('Wallet connection lost. Please reconnect.');
631
+ }
632
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
633
+ ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user rejected')) ||
634
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user denied')) ||
635
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user cancelled')) ||
636
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user canceled'));
637
+ if (!isUserRejection) {
638
+ console.error('[SolanaMobileWallet] Transaction failed:', error);
639
+ }
640
+ throw new Error(`Failed to execute transaction: ${error.message}`);
641
+ }
642
+ }
643
+ async runTransaction(_evmTransactionData, solTransactionData, options) {
644
+ var _a, _b, _c, _d, _e, _f, _g, _h;
645
+ if (!solTransactionData) {
646
+ throw new Error('Solana transaction data is required for mobile wallet');
647
+ }
648
+ const account = await this.ensureAuthorized();
649
+ const connectedPubkey = new web3_js.PublicKey(account.publicKey);
650
+ const wallet = await this.ensureWallet();
651
+ const chain = this.getChain();
652
+ const rpcUrl = this.getRpcUrl(solTransactionData.network);
653
+ const connection = new web3_js.Connection(rpcUrl, 'confirmed');
654
+ const isSurfnet = rpcUrl === index_native.SURFNET_RPC_URL;
655
+ try {
656
+ const remainingAccounts = index_native.convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
657
+ let app_id = solTransactionData.appId;
658
+ if (typeof window !== 'undefined' && window.CUSTOM_TAROBASE_APP_ID_HEADER) {
659
+ app_id = window.CUSTOM_TAROBASE_APP_ID_HEADER;
660
+ }
661
+ if (!app_id) {
662
+ throw new Error('App ID is required');
663
+ }
664
+ // Mock wallet adapter for Anchor — only publicKey is read during build.
665
+ const mockWalletAdapter = {
666
+ publicKey: connectedPubkey,
667
+ signTransaction: async (tx) => tx,
668
+ signAllTransactions: async (txs) => txs,
669
+ };
670
+ const anchorProvider = new anchor__namespace.AnchorProvider(connection, mockWalletAdapter, anchor__namespace.AnchorProvider.defaultOptions());
671
+ const finalDeduped = [];
672
+ for (const acc of remainingAccounts) {
673
+ const existing = finalDeduped.find((d) => d.pubkey.equals(acc.pubkey));
674
+ if (existing) {
675
+ existing.isSigner = existing.isSigner || acc.isSigner;
676
+ existing.isWritable = existing.isWritable || acc.isWritable;
677
+ }
678
+ else {
679
+ finalDeduped.push(acc);
680
+ }
681
+ }
682
+ let tx;
683
+ if (solTransactionData.signedTransaction) {
684
+ // Server has co-signed a CPI attestation. Do NOT mutate its
685
+ // blockhash — that would invalidate the server's signature.
686
+ tx = web3_js.VersionedTransaction.deserialize(index.bufferExports.Buffer.from(solTransactionData.signedTransaction, 'base64'));
687
+ }
688
+ else {
689
+ const result = await index_native.buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, connectedPubkey, {
690
+ app_id,
691
+ documents: solTransactionData.txArgs[0].setDocumentData,
692
+ delete_paths: solTransactionData.txArgs[0].deletePaths,
693
+ txData: solTransactionData.txArgs[0].txData
694
+ }, finalDeduped, solTransactionData.lutKey, solTransactionData.preInstructions, false, solTransactionData.additionalLutAddresses);
695
+ tx = result.tx;
696
+ }
697
+ // Sign-only branch — sign the tx but don't submit.
698
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
699
+ const signTxFeat = getSignTransactionFeature(wallet);
700
+ const wireBytes = txToWireBytes(tx);
701
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
702
+ if (!results || results.length === 0) {
703
+ throw new Error('MWA returned no signed transaction');
704
+ }
705
+ const { signedTransaction: signedBytes } = results[0];
706
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
707
+ return {
708
+ signedTransaction: signedTx,
709
+ blockNumber: 0,
710
+ gasUsed: '0',
711
+ data: ''
712
+ };
713
+ }
714
+ if (isSurfnet) {
715
+ // Surfnet: sign locally via wallet-standard, submit manually.
716
+ const signTxFeat = getSignTransactionFeature(wallet);
717
+ const wireBytes = txToWireBytes(tx);
718
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
719
+ if (!results || results.length === 0) {
720
+ throw new Error('MWA returned no signed transaction');
721
+ }
722
+ const { signedTransaction: signedBytes } = results[0];
723
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
724
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
725
+ const signature = await connection.sendRawTransaction(signedTx.serialize(), {
726
+ preflightCommitment: 'confirmed',
727
+ });
728
+ const confirmation = await connection.confirmTransaction({
729
+ signature,
730
+ blockhash,
731
+ lastValidBlockHeight,
732
+ }, 'confirmed');
733
+ if (confirmation.value.err) {
734
+ throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
735
+ }
736
+ const txInfo = await connection.getParsedTransaction(signature, {
737
+ maxSupportedTransactionVersion: 0,
738
+ commitment: 'confirmed',
739
+ });
740
+ return {
741
+ transactionSignature: signature,
742
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
743
+ gasUsed: ((_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.fee.toString()) || '0',
744
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
745
+ };
746
+ }
747
+ // Non-Surfnet: wallet signs and submits to its own RPC.
748
+ const signSendFeat = getSignAndSendTransactionFeature(wallet);
749
+ const wireBytes = txToWireBytes(tx);
750
+ const results = await signSendFeat.signAndSendTransaction({
751
+ account,
752
+ transaction: wireBytes,
753
+ chain,
754
+ options: { commitment: 'confirmed' },
755
+ });
756
+ if (!results || results.length === 0) {
757
+ throw new Error('MWA returned no signature');
758
+ }
759
+ const { signature: sigBytes } = results[0];
760
+ const signature = index_native.base58.encode(sigBytes);
761
+ const txInfo = await index_native.confirmAndCheckTransaction(connection, signature);
762
+ return {
763
+ transactionSignature: signature,
764
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
765
+ gasUsed: ((_b = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _b === void 0 ? void 0 : _b.fee.toString()) || '0',
766
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
767
+ };
768
+ }
769
+ catch (error) {
770
+ if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('not authorized')) ||
771
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
772
+ await this.logout();
773
+ throw new Error('Wallet connection lost. Please reconnect.');
774
+ }
775
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
776
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
777
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
778
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
779
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
780
+ if (!isUserRejection) {
781
+ console.error('[SolanaMobileWallet] Transaction failed:', error);
782
+ }
783
+ throw new Error(`Failed to execute transaction: ${error.message}`);
784
+ }
785
+ }
786
+ async getNativeMethods() {
787
+ var _a, _b, _c;
788
+ // Synchronous-ish state read; tolerate the wallet being unauthorized
789
+ // (return nulls). Don't trigger ensureAuthorized() here — callers that
790
+ // need the wallet active should sign through one of the sign methods.
791
+ const wallet = this.wallet;
792
+ if (!wallet) {
793
+ return {
794
+ authToken: null,
795
+ walletUriBase: null,
796
+ publicKey: null,
797
+ base64Address: null,
798
+ wallet: null,
799
+ currentAuthorization: null,
800
+ };
801
+ }
802
+ const acct = (_a = wallet.accounts) === null || _a === void 0 ? void 0 : _a[0];
803
+ const auth = wallet.currentAuthorization;
804
+ let publicKey = null;
805
+ let base64Address = null;
806
+ if (acct) {
807
+ publicKey = new web3_js.PublicKey(acct.publicKey);
808
+ base64Address = btoa(String.fromCharCode(...acct.publicKey));
809
+ }
810
+ return {
811
+ authToken: (_b = auth === null || auth === void 0 ? void 0 : auth.auth_token) !== null && _b !== void 0 ? _b : null,
812
+ walletUriBase: (_c = auth === null || auth === void 0 ? void 0 : auth.wallet_uri_base) !== null && _c !== void 0 ? _c : null,
813
+ publicKey,
814
+ base64Address,
815
+ wallet,
816
+ currentAuthorization: auth !== null && auth !== void 0 ? auth : null,
817
+ };
818
+ }
819
+ /* ----------------------------------------------------------- *
820
+ * Private Helpers
821
+ * ----------------------------------------------------------- */
822
+ getRpcUrl(network) {
823
+ if (this.networkUrl) {
824
+ return this.networkUrl;
825
+ }
826
+ if (network === 'solana_devnet') {
827
+ return index_native.SOLANA_DEVNET_RPC_URL;
828
+ }
829
+ else if (network === 'solana_mainnet') {
830
+ return index_native.SOLANA_MAINNET_RPC_URL;
831
+ }
832
+ else if (network === 'surfnet') {
833
+ return index_native.SURFNET_RPC_URL;
834
+ }
835
+ return index_native.SOLANA_MAINNET_RPC_URL;
836
+ }
837
+ }
838
+ SolanaMobileWalletProvider.instance = null;
839
+
840
+ exports.SolanaMobileWalletProvider = SolanaMobileWalletProvider;
841
+ //# sourceMappingURL=solana-mobile-wallet-provider-S8yWHG6i.js.map