@pooflabs/web 0.0.85-rc1 → 0.0.85-rc3

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 (51) hide show
  1. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +5 -0
  2. package/dist/{index-DlyeWzMk.js → index-B5qYY4YM.js} +2 -2
  3. package/dist/index-B5qYY4YM.js.map +1 -0
  4. package/dist/{index-Buu8v-Oe.esm.js → index-BE-VWSJT.esm.js} +2 -2
  5. package/dist/{index-Buu8v-Oe.esm.js.map → index-BE-VWSJT.esm.js.map} +1 -1
  6. package/dist/{index-BoWQVxMI.js → index-BaKs3A8s.js} +2 -2
  7. package/dist/{index-BoWQVxMI.js.map → index-BaKs3A8s.js.map} +1 -1
  8. package/dist/{index-C2p1Cldz.js → index-BzeiIIwF.js} +3 -3
  9. package/dist/{index-C2p1Cldz.js.map → index-BzeiIIwF.js.map} +1 -1
  10. package/dist/{index-ZKzq5QT_.esm.js → index-C4AnWFs_.esm.js} +421 -13
  11. package/dist/{index-ZKzq5QT_.esm.js.map → index-C4AnWFs_.esm.js.map} +1 -1
  12. package/dist/index-TzHXEf3-.esm.js +6 -0
  13. package/dist/index-TzHXEf3-.esm.js.map +1 -0
  14. package/dist/{index-R7cvXys2.js → index-bEXLwE7_.js} +421 -13
  15. package/dist/{index-R7cvXys2.js.map → index-bEXLwE7_.js.map} +1 -1
  16. package/dist/{index-4TKz3Mn_.esm.js → index-dqqR5q7b.esm.js} +3 -3
  17. package/dist/{index-4TKz3Mn_.esm.js.map → index-dqqR5q7b.esm.js.map} +1 -1
  18. package/dist/{index.browser-BQSN-6X2.js → index.browser-CN6obNQM.js} +2 -118
  19. package/dist/{index.browser-BQSN-6X2.js.map → index.browser-CN6obNQM.js.map} +1 -1
  20. package/dist/{index.browser-DZCNegue.js → index.browser-CZIJCtms.js} +2 -2
  21. package/dist/{index.browser-DZCNegue.js.map → index.browser-CZIJCtms.js.map} +1 -1
  22. package/dist/{index.browser-tPepE5fo.esm.js → index.browser-D8ttddP4.esm.js} +3 -117
  23. package/dist/{index.browser-tPepE5fo.esm.js.map → index.browser-D8ttddP4.esm.js.map} +1 -1
  24. package/dist/{index.browser-zfGYm0ST.esm.js → index.browser-DQIwLToJ.esm.js} +2 -2
  25. package/dist/{index.browser-zfGYm0ST.esm.js.map → index.browser-DQIwLToJ.esm.js.map} +1 -1
  26. package/dist/index.esm.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/{index.native-BPQqeP6_.esm.js → index.native-DLziTime.esm.js} +4 -4
  29. package/dist/{index.native-BPQqeP6_.esm.js.map → index.native-DLziTime.esm.js.map} +1 -1
  30. package/dist/{index.native-BGaUOX9f.js → index.native-pG1NTZ0f.js} +4 -4
  31. package/dist/{index.native-BGaUOX9f.js.map → index.native-pG1NTZ0f.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-DheGhOp4.esm.js → phantom-wallet-provider-CP6NXRwG.esm.js} +4 -4
  35. package/dist/{phantom-wallet-provider-DheGhOp4.esm.js.map → phantom-wallet-provider-CP6NXRwG.esm.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-MFcwrRpJ.js → phantom-wallet-provider-zBp7-uEw.js} +4 -4
  37. package/dist/{phantom-wallet-provider-MFcwrRpJ.js.map → phantom-wallet-provider-zBp7-uEw.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-D15Au3j8.esm.js → privy-wallet-provider-CGYvf3-r.esm.js} +3 -3
  39. package/dist/{privy-wallet-provider-D15Au3j8.esm.js.map → privy-wallet-provider-CGYvf3-r.esm.js.map} +1 -1
  40. package/dist/{privy-wallet-provider-CFw6o7O5.js → privy-wallet-provider-CoyW5Gdg.js} +3 -3
  41. package/dist/{privy-wallet-provider-CFw6o7O5.js.map → privy-wallet-provider-CoyW5Gdg.js.map} +1 -1
  42. package/dist/{solana-mobile-wallet-provider-ChHh-U_p.esm.js → solana-mobile-wallet-provider-B8rHfsPN.esm.js} +414 -9
  43. package/dist/solana-mobile-wallet-provider-B8rHfsPN.esm.js.map +1 -0
  44. package/dist/{solana-mobile-wallet-provider-BM9wdF0m.js → solana-mobile-wallet-provider-CN-D_H4l.js} +414 -9
  45. package/dist/solana-mobile-wallet-provider-CN-D_H4l.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/index-COF6zNCs.esm.js +0 -6
  48. package/dist/index-COF6zNCs.esm.js.map +0 -1
  49. package/dist/index-DlyeWzMk.js.map +0 -1
  50. package/dist/solana-mobile-wallet-provider-BM9wdF0m.js.map +0 -1
  51. package/dist/solana-mobile-wallet-provider-ChHh-U_p.esm.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-DlyeWzMk.js');
4
- var index_native = require('./index.native-BGaUOX9f.js');
3
+ var index = require('./index-B5qYY4YM.js');
4
+ var index_native = require('./index.native-pG1NTZ0f.js');
5
5
  var web3_js = require('@solana/web3.js');
6
6
  var anchor = require('@coral-xyz/anchor');
7
7
  require('axios');
@@ -29,6 +29,381 @@ var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
29
29
  const ED25519_SIGNATURE_LENGTH = 64;
30
30
  const STORED_AUTH_METHOD_KEY = 'tarobase_last_auth_method';
31
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
+ * User-gesture-mediated wallet-standard sign helper.
138
+ *
139
+ * Why this exists: login flows that go through wallet-standard call two
140
+ * separate transacts (standard:connect, then solana:signMessage). Each
141
+ * transact dispatches its own `solana-wallet:` Android intent navigation
142
+ * via `window.location.assign(associationUrl)` (see
143
+ * @solana-mobile/mobile-wallet-adapter-protocol/lib/cjs/index.browser.js
144
+ * `launchAssociation()` at line 459). Chrome requires **transient user
145
+ * activation** for each custom-scheme navigation. The first transact
146
+ * consumes the activation from the user's "Continue to Allow" tap on the
147
+ * LNA modal; by the time the second transact (signMessage) runs as a JS
148
+ * continuation, the activation has decayed, Chrome blocks the navigation,
149
+ * no `blur` event fires, the protocol's `getDetectionPromise` (3000ms
150
+ * timeout, line 433) rejects, and we get `ERROR_WALLET_NOT_FOUND`.
151
+ *
152
+ * Fix: show a Tarobase-controlled modal between the two transacts. When the
153
+ * user taps the modal's "Sign in" button, that tap IS a fresh user
154
+ * activation. We invoke the sign function directly inside the click handler
155
+ * — no `await` between the tap and the call — so the activation propagates
156
+ * to the protocol's `location.assign`.
157
+ *
158
+ * Failure recovery is also user-gesture driven: if the sign function fails
159
+ * with a retryable association error, we re-enable the button so the user's
160
+ * next tap is a new activation (a real retry). A timer-based retry would
161
+ * just hit the same Chrome block. Cap at 3 attempts before giving up.
162
+ */
163
+ async function awaitSignInGestureAndSign(label, theme, signFn) {
164
+ if (typeof document === 'undefined' || typeof window === 'undefined') {
165
+ // SSR / non-browser: skip the gesture, just call (the activation
166
+ // model doesn't apply outside the browser).
167
+ const results = await signFn();
168
+ if (!results || results.length === 0)
169
+ throw new Error('MWA returned no signature');
170
+ return results[0];
171
+ }
172
+ return new Promise((resolve, reject) => {
173
+ const isDark = theme === 'dark'
174
+ || (theme == null
175
+ && typeof window.matchMedia === 'function'
176
+ && window.matchMedia('(prefers-color-scheme: dark)').matches);
177
+ // Palette
178
+ const overlayBg = 'rgba(0, 0, 0, 0.62)';
179
+ const cardBg = isDark ? '#1a1a1f' : '#ffffff';
180
+ const titleColor = isDark ? '#ffffff' : '#0a0a0a';
181
+ const subtitleColor = isDark ? '#a1a1aa' : '#52525b';
182
+ const btnBg = isDark ? '#ffffff' : '#0a0a0a';
183
+ const btnText = isDark ? '#0a0a0a' : '#ffffff';
184
+ const btnDisabledBg = isDark ? '#3f3f46' : '#d4d4d8';
185
+ const btnDisabledText = isDark ? '#71717a' : '#71717a';
186
+ const errorColor = isDark ? '#fca5a5' : '#dc2626';
187
+ const closeColor = isDark ? '#71717a' : '#a1a1aa';
188
+ const fontStack = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
189
+ const overlay = document.createElement('div');
190
+ overlay.setAttribute('data-tarobase-mwa-gesture', 'true');
191
+ overlay.style.cssText = [
192
+ 'position: fixed',
193
+ 'inset: 0',
194
+ 'z-index: 2147483646',
195
+ `background: ${overlayBg}`,
196
+ 'display: flex',
197
+ 'align-items: center',
198
+ 'justify-content: center',
199
+ 'padding: 20px',
200
+ 'box-sizing: border-box',
201
+ `font-family: ${fontStack}`,
202
+ ].join('; ');
203
+ const card = document.createElement('div');
204
+ card.style.cssText = [
205
+ `background: ${cardBg}`,
206
+ 'border-radius: 20px',
207
+ 'padding: 28px 24px 24px',
208
+ 'max-width: 340px',
209
+ 'width: 100%',
210
+ 'box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28)',
211
+ 'position: relative',
212
+ 'box-sizing: border-box',
213
+ ].join('; ');
214
+ const closeBtn = document.createElement('button');
215
+ closeBtn.setAttribute('aria-label', 'Close');
216
+ closeBtn.innerHTML = '&times;';
217
+ closeBtn.style.cssText = [
218
+ 'position: absolute',
219
+ 'top: 12px',
220
+ 'right: 12px',
221
+ 'background: transparent',
222
+ 'border: none',
223
+ `color: ${closeColor}`,
224
+ 'font-size: 24px',
225
+ 'line-height: 1',
226
+ 'cursor: pointer',
227
+ 'padding: 6px 10px',
228
+ 'border-radius: 8px',
229
+ ].join('; ');
230
+ const title = document.createElement('div');
231
+ title.textContent = 'Almost there';
232
+ title.style.cssText = [
233
+ `color: ${titleColor}`,
234
+ 'font-size: 20px',
235
+ 'font-weight: 600',
236
+ 'margin-bottom: 6px',
237
+ 'text-align: center',
238
+ ].join('; ');
239
+ const subtitle = document.createElement('div');
240
+ subtitle.textContent = 'Tap to sign in with your wallet';
241
+ subtitle.style.cssText = [
242
+ `color: ${subtitleColor}`,
243
+ 'font-size: 14px',
244
+ 'line-height: 1.4',
245
+ 'margin-bottom: 22px',
246
+ 'text-align: center',
247
+ ].join('; ');
248
+ const errorRow = document.createElement('div');
249
+ errorRow.style.cssText = [
250
+ `color: ${errorColor}`,
251
+ 'font-size: 13px',
252
+ 'line-height: 1.4',
253
+ 'margin-bottom: 14px',
254
+ 'text-align: center',
255
+ 'min-height: 0',
256
+ 'transition: min-height 100ms ease',
257
+ ].join('; ');
258
+ const button = document.createElement('button');
259
+ button.textContent = 'Sign in';
260
+ const setButtonEnabledStyle = () => {
261
+ button.style.cssText = [
262
+ `background: ${btnBg}`,
263
+ `color: ${btnText}`,
264
+ 'border: none',
265
+ 'border-radius: 14px',
266
+ 'padding: 14px 20px',
267
+ 'font-size: 16px',
268
+ 'font-weight: 600',
269
+ 'width: 100%',
270
+ 'cursor: pointer',
271
+ '-webkit-tap-highlight-color: transparent',
272
+ 'box-sizing: border-box',
273
+ `font-family: ${fontStack}`,
274
+ ].join('; ');
275
+ };
276
+ const setButtonDisabledStyle = () => {
277
+ button.style.cssText = [
278
+ `background: ${btnDisabledBg}`,
279
+ `color: ${btnDisabledText}`,
280
+ 'border: none',
281
+ 'border-radius: 14px',
282
+ 'padding: 14px 20px',
283
+ 'font-size: 16px',
284
+ 'font-weight: 600',
285
+ 'width: 100%',
286
+ 'cursor: default',
287
+ '-webkit-tap-highlight-color: transparent',
288
+ 'box-sizing: border-box',
289
+ `font-family: ${fontStack}`,
290
+ ].join('; ');
291
+ };
292
+ setButtonEnabledStyle();
293
+ card.appendChild(closeBtn);
294
+ card.appendChild(title);
295
+ card.appendChild(subtitle);
296
+ card.appendChild(errorRow);
297
+ card.appendChild(button);
298
+ overlay.appendChild(card);
299
+ document.body.appendChild(overlay);
300
+ let settled = false;
301
+ let attemptCount = 0;
302
+ const MAX_ATTEMPTS = 3;
303
+ const cleanup = () => {
304
+ try {
305
+ overlay.remove();
306
+ }
307
+ catch ( /* ignore */_a) { /* ignore */ }
308
+ document.removeEventListener('keydown', onKeydown);
309
+ };
310
+ const finishResolve = (value) => {
311
+ if (settled)
312
+ return;
313
+ settled = true;
314
+ cleanup();
315
+ resolve(value);
316
+ };
317
+ const finishReject = (err) => {
318
+ if (settled)
319
+ return;
320
+ settled = true;
321
+ cleanup();
322
+ reject(err);
323
+ };
324
+ const handleCancel = () => {
325
+ // Phrasing matches login()'s isUserRejection substring check so
326
+ // the existing catch suppresses error-log noise.
327
+ finishReject(new Error('User cancelled wallet sign in'));
328
+ };
329
+ closeBtn.addEventListener('click', () => {
330
+ console.log(`[MWA-DEBUG] ${label} gesture: close clicked`);
331
+ handleCancel();
332
+ });
333
+ overlay.addEventListener('click', (e) => {
334
+ if (e.target === overlay) {
335
+ console.log(`[MWA-DEBUG] ${label} gesture: overlay clicked (cancel)`);
336
+ handleCancel();
337
+ }
338
+ });
339
+ const onKeydown = (e) => {
340
+ if (e.key === 'Escape') {
341
+ console.log(`[MWA-DEBUG] ${label} gesture: Escape pressed (cancel)`);
342
+ handleCancel();
343
+ }
344
+ };
345
+ document.addEventListener('keydown', onKeydown);
346
+ button.addEventListener('click', () => {
347
+ if (settled)
348
+ return;
349
+ attemptCount++;
350
+ const attempt = attemptCount;
351
+ console.log(`[MWA-DEBUG] ${label} gesture: button click attempt=${attempt}`);
352
+ // Disable to prevent double-clicks while the wallet popup is up.
353
+ button.disabled = true;
354
+ setButtonDisabledStyle();
355
+ const originalText = 'Sign in';
356
+ button.textContent = 'Signing in…';
357
+ errorRow.textContent = '';
358
+ errorRow.style.minHeight = '0';
359
+ // CRITICAL: invoke signFn() synchronously inside the click handler
360
+ // so Chrome's transient user activation propagates to the
361
+ // protocol's window.location.assign(associationUrl) inside
362
+ // launchAssociation(). Do not `await` before calling.
363
+ const t0 = Date.now();
364
+ console.log(`[MWA-DEBUG] ${label} gesture: signMessage start (attempt=${attempt})`);
365
+ signFn().then((results) => {
366
+ const elapsed = Date.now() - t0;
367
+ if (!results || results.length === 0) {
368
+ console.log(`[MWA-DEBUG] ${label} gesture: signMessage returned empty (attempt=${attempt}, ${elapsed}ms)`);
369
+ finishReject(new Error('MWA returned no signature'));
370
+ return;
371
+ }
372
+ console.log(`[MWA-DEBUG] ${label} gesture: signMessage ok (attempt=${attempt}, ${elapsed}ms)`);
373
+ finishResolve(results[0]);
374
+ }).catch((err) => {
375
+ const elapsed = Date.now() - t0;
376
+ const info = findMwaError(err);
377
+ console.log(`[MWA-DEBUG] ${label} gesture: signMessage err (attempt=${attempt}, ${elapsed}ms)`, {
378
+ outer: { name: err === null || err === void 0 ? void 0 : err.name, message: err === null || err === void 0 ? void 0 : err.message },
379
+ mwa: info,
380
+ });
381
+ const retryable = isMwaAssociationRetryable(err);
382
+ if (retryable && attempt < MAX_ATTEMPTS) {
383
+ // Re-enable the button so the user's next tap provides a
384
+ // fresh user activation. Show inline error text.
385
+ console.log(`[MWA-DEBUG] ${label} gesture: retryable (${retryable.code}); awaiting user tap to retry (attempt ${attempt}/${MAX_ATTEMPTS})`);
386
+ button.disabled = false;
387
+ setButtonEnabledStyle();
388
+ button.textContent = originalText;
389
+ errorRow.textContent = "Couldn't connect — tap to try again";
390
+ errorRow.style.minHeight = '20px';
391
+ return;
392
+ }
393
+ if (retryable) {
394
+ // Hit the attempt cap with a still-retryable failure.
395
+ console.log(`[MWA-DEBUG] ${label} gesture: retryable but attempt cap reached (${attempt})`);
396
+ finishReject(new Error("Couldn't connect to your Seeker wallet. Please try again."));
397
+ return;
398
+ }
399
+ // Non-retryable error (user cancel inside Seeker, wallet
400
+ // rejected sign, unknown error, etc.) — surface as-is.
401
+ finishReject(err);
402
+ });
403
+ });
404
+ console.log(`[MWA-DEBUG] ${label} gesture: modal shown`);
405
+ });
406
+ }
32
407
  /**
33
408
  * Normalize a chain string to a wallet-standard Solana chain identifier.
34
409
  *
@@ -214,14 +589,22 @@ class SolanaMobileWalletProvider {
214
589
  async ensureWallet() {
215
590
  if (this.wallet)
216
591
  return this.wallet;
217
- const mod = await Promise.resolve().then(function () { return require('./index.browser-BQSN-6X2.js'); });
592
+ const mod = await Promise.resolve().then(function () { return require('./index.browser-CN6obNQM.js'); });
218
593
  const chain = mapChainToWalletStandard(this.cluster);
219
594
  this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
220
595
  appIdentity: this.appIdentity,
221
596
  authorizationCache: mod.createDefaultAuthorizationCache(),
222
597
  chains: [chain],
223
598
  chainSelector: mod.createDefaultChainSelector(),
224
- onWalletNotFound: mod.createDefaultWalletNotFoundHandler(),
599
+ // Suppress the default "We can't find a wallet" modal — that
600
+ // modal is misleading when ERROR_WALLET_NOT_FOUND fires during
601
+ // a first-time-consent race on Seeker (the wallet IS installed,
602
+ // the protocol just gave up before the user finished consenting).
603
+ // login()'s withMwaAssociationRetry handles this case; on second
604
+ // failure it surfaces a clean error message to the host app.
605
+ onWalletNotFound: async () => {
606
+ console.warn('[MWA-DEBUG] ensureWallet onWalletNotFound (suppressed)');
607
+ },
225
608
  });
226
609
  return this.wallet;
227
610
  }
@@ -286,8 +669,15 @@ class SolanaMobileWalletProvider {
286
669
  // is where wallet-standard's checkLocalNetworkAccessPermission()
287
670
  // fires the three-stage LNA UX (info modal → permission prompt →
288
671
  // success modal) before opening the localhost WebSocket.
672
+ //
673
+ // Wrap with single-retry: on a Seeker origin's first MWA usage,
674
+ // the protocol's session-establishment timer often races Seeker's
675
+ // first-time consent UI and throws ERROR_WALLET_NOT_FOUND before
676
+ // the user finishes tapping. The retry hits Seeker's cached
677
+ // consent on the second pass and completes quickly. See
678
+ // withMwaAssociationRetry for details.
289
679
  const connectFeat = getConnectFeature(wallet);
290
- const { accounts } = await connectFeat.connect();
680
+ const { accounts } = await withMwaAssociationRetry('login:connect', () => connectFeat.connect());
291
681
  if (!accounts || accounts.length === 0) {
292
682
  throw new Error('MWA returned no accounts');
293
683
  }
@@ -302,14 +692,29 @@ class SolanaMobileWalletProvider {
302
692
  return user;
303
693
  }
304
694
  // Wallet popup #2: sign the Tarobase nonce message.
695
+ //
696
+ // We cannot call signMessageFeat.signMessage() directly here:
697
+ // it would run as a JS continuation from the connect() resolve,
698
+ // with no fresh Chrome transient user activation. The wallet-
699
+ // standard sign path internally dispatches a new solana-wallet:
700
+ // Android intent via window.location.assign() (see
701
+ // @solana-mobile/mobile-wallet-adapter-protocol launchAssociation
702
+ // at lib/cjs/index.browser.js:459). Chrome blocks the assign
703
+ // without activation, the blur event never fires, and the
704
+ // protocol's 3-second getDetectionPromise rejects with
705
+ // ERROR_WALLET_NOT_FOUND.
706
+ //
707
+ // Insert a Tarobase modal: the user's tap on "Sign in" provides a
708
+ // fresh activation, and signMessage is invoked synchronously
709
+ // inside the click handler so the activation propagates.
305
710
  const messageText = await index_native.genSolanaMessage(base58Addr, nonce);
306
711
  const messageBytes = index_native.getPlatform().textEncode(messageText);
307
712
  const signMessageFeat = getSignMessageFeature(wallet);
308
- const signResults = await signMessageFeat.signMessage({ account, message: messageBytes });
309
- if (!signResults || signResults.length === 0) {
713
+ const signResult = await awaitSignInGestureAndSign('login:signMessage', this.config.theme, () => signMessageFeat.signMessage({ account, message: messageBytes }));
714
+ if (!signResult) {
310
715
  throw new Error('MWA returned no signature');
311
716
  }
312
- const { signature: sigBytes } = signResults[0];
717
+ const { signature: sigBytes } = signResult;
313
718
  const signatureBase64 = index.bufferExports.Buffer.from(sigBytes).toString('base64');
314
719
  // Create Tarobase session on the server.
315
720
  const createSessionResult = await index_native.createSessionWithSignature(base58Addr, messageText, signatureBase64);
@@ -716,4 +1121,4 @@ class SolanaMobileWalletProvider {
716
1121
  SolanaMobileWalletProvider.instance = null;
717
1122
 
718
1123
  exports.SolanaMobileWalletProvider = SolanaMobileWalletProvider;
719
- //# sourceMappingURL=solana-mobile-wallet-provider-BM9wdF0m.js.map
1124
+ //# sourceMappingURL=solana-mobile-wallet-provider-CN-D_H4l.js.map