@pooflabs/web 0.0.88 → 0.0.89-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 (57) hide show
  1. package/dist/auth/providers/mock-poofnet-provider.d.ts +58 -0
  2. package/dist/auth/providers/phantom-wallet-provider.d.ts +5 -0
  3. package/dist/{index-BfsQaxom.esm.js → index-4JUcdcnk.esm.js} +2 -2406
  4. package/dist/index-4JUcdcnk.esm.js.map +1 -0
  5. package/dist/{index-Lm0k5Hwv.js → index-BLiaV7Dz.js} +5302 -2462
  6. package/dist/index-BLiaV7Dz.js.map +1 -0
  7. package/dist/{index-CTtGbOzo.js → index-CXmcQaFm.js} +2 -2406
  8. package/dist/index-CXmcQaFm.js.map +1 -0
  9. package/dist/{index-CJRFnq6O.esm.js → index-Cgaz8U9W.esm.js} +5303 -2461
  10. package/dist/index-Cgaz8U9W.esm.js.map +1 -0
  11. package/dist/{index-MF_M5V0O.esm.js → index-DQhWZskl.esm.js} +2 -2407
  12. package/dist/index-DQhWZskl.esm.js.map +1 -0
  13. package/dist/{index-DBYgqO9f.js → index-QJAj_nTx.js} +13 -2418
  14. package/dist/index-QJAj_nTx.js.map +1 -0
  15. package/dist/{index.browser-BxKN5pIs.js → index.browser-B9NfvmrP.js} +2 -2
  16. package/dist/{index.browser-BxKN5pIs.js.map → index.browser-B9NfvmrP.js.map} +1 -1
  17. package/dist/{index.browser-CMijwVwX.esm.js → index.browser-CG2sQjrd.esm.js} +2 -2
  18. package/dist/{index.browser-CMijwVwX.esm.js.map → index.browser-CG2sQjrd.esm.js.map} +1 -1
  19. package/dist/{index.browser-BCr9Sc8V.js → index.browser-UxB-zDuA.js} +2 -2
  20. package/dist/{index.browser-BCr9Sc8V.js.map → index.browser-UxB-zDuA.js.map} +1 -1
  21. package/dist/{index.browser-CGZvkfTO.esm.js → index.browser-kQdoMu7Y.esm.js} +2 -2
  22. package/dist/{index.browser-CGZvkfTO.esm.js.map → index.browser-kQdoMu7Y.esm.js.map} +1 -1
  23. package/dist/index.esm.js +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{index.native-GyqT8Dn5.esm.js → index.native-CwpIbypp.esm.js} +5488 -2760
  26. package/dist/index.native-CwpIbypp.esm.js.map +1 -0
  27. package/dist/{index.native-FMbSnE7i.js → index.native-Cycwo-3I.js} +5488 -2762
  28. package/dist/index.native-Cycwo-3I.js.map +1 -0
  29. package/dist/index.native.esm.js +1 -1
  30. package/dist/index.native.js +1 -1
  31. package/dist/{phantom-wallet-provider-4_DBhDbx.js → phantom-wallet-provider-BgDhrraw.js} +140 -25
  32. package/dist/phantom-wallet-provider-BgDhrraw.js.map +1 -0
  33. package/dist/{phantom-wallet-provider-BFSfBW0w.esm.js → phantom-wallet-provider-DM-96ILz.esm.js} +136 -21
  34. package/dist/phantom-wallet-provider-DM-96ILz.esm.js.map +1 -0
  35. package/dist/{privy-wallet-provider-Dl0feuCb.esm.js → privy-wallet-provider-C70AIqHI.esm.js} +3 -3
  36. package/dist/{privy-wallet-provider-Dl0feuCb.esm.js.map → privy-wallet-provider-C70AIqHI.esm.js.map} +1 -1
  37. package/dist/{privy-wallet-provider-DRss_Hua.js → privy-wallet-provider-D4IYOUji.js} +3 -3
  38. package/dist/{privy-wallet-provider-DRss_Hua.js.map → privy-wallet-provider-D4IYOUji.js.map} +1 -1
  39. package/dist/{solana-mobile-wallet-provider-CAZs-TkL.js → solana-mobile-wallet-provider-BrjPc7Wd.js} +9 -10
  40. package/dist/{solana-mobile-wallet-provider-CAZs-TkL.js.map → solana-mobile-wallet-provider-BrjPc7Wd.js.map} +1 -1
  41. package/dist/{solana-mobile-wallet-provider-C5mN8Dxh.esm.js → solana-mobile-wallet-provider-CXXw-pKg.esm.js} +3 -4
  42. package/dist/{solana-mobile-wallet-provider-C5mN8Dxh.esm.js.map → solana-mobile-wallet-provider-CXXw-pKg.esm.js.map} +1 -1
  43. package/package.json +3 -2
  44. package/dist/index-BfsQaxom.esm.js.map +0 -1
  45. package/dist/index-CJRFnq6O.esm.js.map +0 -1
  46. package/dist/index-CTtGbOzo.js.map +0 -1
  47. package/dist/index-CvNX4W0l.js +0 -8
  48. package/dist/index-CvNX4W0l.js.map +0 -1
  49. package/dist/index-DBYgqO9f.js.map +0 -1
  50. package/dist/index-DpiO7Cpe.esm.js +0 -6
  51. package/dist/index-DpiO7Cpe.esm.js.map +0 -1
  52. package/dist/index-Lm0k5Hwv.js.map +0 -1
  53. package/dist/index-MF_M5V0O.esm.js.map +0 -1
  54. package/dist/index.native-FMbSnE7i.js.map +0 -1
  55. package/dist/index.native-GyqT8Dn5.esm.js.map +0 -1
  56. package/dist/phantom-wallet-provider-4_DBhDbx.js.map +0 -1
  57. package/dist/phantom-wallet-provider-BFSfBW0w.esm.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { Z as DEFAULT_TEST_ADDRESS, a0 as InsufficientBalanceError, Y as MockAuthProvider, _ as OffchainAuthProvider, $ as PrivyExpoProvider, a1 as ReactNativeSessionManager, a2 as ServerSessionManager, W as WebSessionManager, Q as aggregate, b as buildSetDocumentsTransaction, a3 as clearCache, a4 as closeAllSubscriptions, c as convertRemainingAccounts, P as count, f as createSessionWithPrivy, o as createSessionWithSignature, U as deserializeTransaction, m as genAuthNonce, n as genSolanaMessage, D as get, y as getAuthLoading, C as getAuthProvider, a5 as getCachedData, B as getConfig, v as getCurrentUser, H as getFiles, V as getIdToken, a6 as getMany, g as getPlatform, u as init, z as login, A as logout, x as onAuthLoadingChanged, w as onAuthStateChanged, a7 as reconnectWithNewAuth, a8 as refreshSession, K as runExpression, L as runExpressionMany, I as runQuery, J as runQueryMany, E as set, G as setFile, F as setMany, X as setPlatform, O as signAndSubmitTransaction, M as signMessage, a9 as signSessionCreateMessage, N as signTransaction, R as subscribe, T as useAuth } from './index.native-GyqT8Dn5.esm.js';
1
+ export { X as DEFAULT_TEST_ADDRESS, _ as InsufficientBalanceError, V as MockAuthProvider, Y as OffchainAuthProvider, Z as PrivyExpoProvider, $ as ReactNativeSessionManager, a0 as ServerSessionManager, W as WebSessionManager, O as aggregate, b as buildSetDocumentsTransaction, a1 as clearCache, a2 as closeAllSubscriptions, c as convertRemainingAccounts, N as count, f as createSessionWithPrivy, p as createSessionWithSignature, R as deserializeTransaction, n as genAuthNonce, o as genSolanaMessage, B as get, w as getAuthLoading, A as getAuthProvider, a3 as getCachedData, z as getConfig, t as getCurrentUser, F as getFiles, T as getIdToken, a4 as getMany, g as getPlatform, r as init, x as login, y as logout, v as onAuthLoadingChanged, u as onAuthStateChanged, a5 as reconnectWithNewAuth, a6 as refreshSession, I as runExpression, J as runExpressionMany, G as runQuery, H as runQueryMany, C as set, E as setFile, D as setMany, U as setPlatform, M as signAndSubmitTransaction, K as signMessage, a7 as signSessionCreateMessage, L as signTransaction, P as subscribe, Q as useAuth } from './index.native-CwpIbypp.esm.js';
2
2
  import 'axios';
3
3
  import '@solana/web3.js';
4
4
  import '@coral-xyz/anchor';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index_native = require('./index.native-FMbSnE7i.js');
3
+ var index_native = require('./index.native-Cycwo-3I.js');
4
4
  require('axios');
5
5
  require('@solana/web3.js');
6
6
  require('@coral-xyz/anchor');
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CvNX4W0l.js');
4
- var index_native = require('./index.native-FMbSnE7i.js');
3
+ var index_native = require('./index.native-Cycwo-3I.js');
5
4
  var web3_js = require('@solana/web3.js');
6
5
  var anchor = require('@coral-xyz/anchor');
7
6
  require('axios');
@@ -53,6 +52,27 @@ function shouldBreakOutOfIframe(provider) {
53
52
  // exactly the iframe-without-provider case we need to escape.
54
53
  return provider === 'deeplink' && isInIframe();
55
54
  }
55
+ // In a cross-origin iframe (e.g. the poof.new build-page preview) on mobile,
56
+ // Mobile Wallet Adapter can't run: its localhost association handshake needs
57
+ // Chrome's Local Network Access, which is denied to cross-origin sub-frames.
58
+ // So open the app's own URL TOP-LEVEL (a new tab / Custom Tab), where MWA works
59
+ // natively; the connect happens there and the session — written to same-origin
60
+ // storage — reflects back into this iframe (awaitTopLevelConnect picks it up).
61
+ // Must be called synchronously inside a user-gesture handler so window.open
62
+ // isn't popup-blocked. Returns true if the tab was opened.
63
+ function openTopLevelForConnect() {
64
+ if (typeof window === 'undefined' || !isInIframe())
65
+ return false;
66
+ try {
67
+ const url = new URL(window.location.href);
68
+ url.searchParams.set('poofConnect', '1');
69
+ const w = window.open(url.toString(), '_blank');
70
+ return !!w;
71
+ }
72
+ catch (_a) {
73
+ return false;
74
+ }
75
+ }
56
76
  // Dynamically import React and Phantom SDK - only when needed
57
77
  let React;
58
78
  let ReactDOM;
@@ -73,7 +93,7 @@ async function loadDependencies() {
73
93
  const [reactModule, reactDomModule, phantomModule] = await Promise.all([
74
94
  import('react'),
75
95
  import('react-dom/client'),
76
- Promise.resolve().then(function () { return require('./index-DBYgqO9f.js'); })
96
+ Promise.resolve().then(function () { return require('./index-QJAj_nTx.js'); })
77
97
  ]);
78
98
  // Extract default export from ESM module namespace
79
99
  // Dynamic import() returns { default: Module, ...exports }, not the module directly
@@ -103,6 +123,8 @@ class PhantomWalletProvider {
103
123
  this.onSwitchToPrivy = null;
104
124
  /** Callback to swap to a Mobile Wallet Adapter provider when the user clicks "Connect Mobile Wallet" */
105
125
  this.onSwitchToMWA = null;
126
+ /** Callback to swap to the simulated Poofnet provider when the user clicks "Connect with Poofnet wallet" */
127
+ this.onSwitchToPoofnet = null;
106
128
  this.networkUrl = networkUrl;
107
129
  this.config = config;
108
130
  if (typeof window === 'undefined') {
@@ -315,7 +337,7 @@ class PhantomWalletProvider {
315
337
  const signResult = await solana.signMessage(messageText);
316
338
  // Convert Uint8Array signature to base64 string
317
339
  const signatureBytes = signResult.signature;
318
- const signature = index.bufferExports.Buffer.from(signatureBytes).toString('base64');
340
+ const signature = index_native.bufferExports.Buffer.from(signatureBytes).toString('base64');
319
341
  const createSessionResult = await index_native.createSessionWithSignature(publicKey, messageText, signature);
320
342
  // Pre-write guard: MWA may have started a login while we were
321
343
  // in flight. If MWA owns the auth method now, abort before we
@@ -422,7 +444,7 @@ class PhantomWalletProvider {
422
444
  const signResult = await solana.signMessage(messageText);
423
445
  // Convert Uint8Array signature to base64 string
424
446
  const signatureBytes = signResult.signature;
425
- const signature = index.bufferExports.Buffer.from(signatureBytes).toString('base64');
447
+ const signature = index_native.bufferExports.Buffer.from(signatureBytes).toString('base64');
426
448
  const createSessionResult = await index_native.createSessionWithSignature(publicKey, messageText, signature);
427
449
  await index_native.WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
428
450
  // Mark auth method so clearIncompatibleSession() doesn't wipe this session
@@ -456,26 +478,19 @@ class PhantomWalletProvider {
456
478
  const handleWalletClick = async (options) => {
457
479
  walletClickedRef.current = true;
458
480
  setShowWalletModal(false);
459
- // If we're in an iframe and the user chose deeplink, Phantom's SDK
460
- // will navigate *this* iframe to phantom.app/ul/browse/..., which
461
- // Android App Links won't intercept and phantom.app won't let be
462
- // framed. Escape to top-level first so the wallet browser can
463
- // inject its provider and the normal injected flow takes over
464
- // on the user's next connect tap.
481
+ // Cross-origin preview iframe + deeplink: the old approach navigated
482
+ // the top frame to this URL, but in a TWA that lands out-of-scope and
483
+ // shows a chrome-error ("bad page"). Instead, open the app TOP-LEVEL
484
+ // in a new tab where the wallet connect works natively; the session
485
+ // reflects back into this iframe (see openTopLevelForConnect /
486
+ // awaitTopLevelConnect).
465
487
  if (shouldBreakOutOfIframe(options === null || options === void 0 ? void 0 : options.provider)) {
466
- try {
467
- // Same-site navigation (*.poof.new → *.poof.new) plus the
468
- // iframe's allow-top-navigation-by-user-activation sandbox
469
- // token make this go through.
470
- window.top.location.href = window.location.href;
488
+ if (openTopLevelForConnect()) {
489
+ that.awaitTopLevelConnect();
471
490
  return;
472
491
  }
473
- catch (_a) {
474
- // Top-nav blocked (no sandbox grant, cross-origin top, etc.).
475
- // Fall through to the normal deeplink path — at least the
476
- // user gets the original broken-ish behavior instead of a
477
- // silently-dead button.
478
- }
492
+ // Popup blocked — fall through to the original deeplink path
493
+ // (better a broken-ish button than a silently-dead one).
479
494
  }
480
495
  try {
481
496
  if (options === null || options === void 0 ? void 0 : options.walletId) {
@@ -521,6 +536,14 @@ class PhantomWalletProvider {
521
536
  that.loginInProgress = false;
522
537
  walletClickedRef.current = true;
523
538
  setShowWalletModal(false);
539
+ // Cross-origin preview iframe (e.g. poof.new build page) on mobile:
540
+ // MWA can't run here (Chrome denies Local Network Access to sub-frames,
541
+ // and its localhost handshake fails). Open the app top-level for the
542
+ // connect; the session reflects back into this iframe.
543
+ if (isInIframe() && openTopLevelForConnect()) {
544
+ that.awaitTopLevelConnect();
545
+ return;
546
+ }
524
547
  if (that.onSwitchToMWA) {
525
548
  try {
526
549
  const mwaProvider = await that.onSwitchToMWA();
@@ -542,6 +565,33 @@ class PhantomWalletProvider {
542
565
  }
543
566
  }
544
567
  };
568
+ const handlePoofnetClick = async () => {
569
+ that.loginInProgress = false;
570
+ walletClickedRef.current = true;
571
+ setShowWalletModal(false);
572
+ // Simulated Poofnet wallet (offchain/preview only): hot-swap to the
573
+ // mock provider and connect instantly — no real wallet round-trip.
574
+ if (that.onSwitchToPoofnet) {
575
+ try {
576
+ const poofnetProvider = await that.onSwitchToPoofnet();
577
+ const user = await poofnetProvider.login();
578
+ if (that.pendingLogin && user) {
579
+ that.pendingLogin.resolve(user);
580
+ that.pendingLogin = null;
581
+ }
582
+ else if (that.pendingLogin) {
583
+ that.pendingLogin.reject(new Error('User cancelled login'));
584
+ that.pendingLogin = null;
585
+ }
586
+ }
587
+ catch (error) {
588
+ if (that.pendingLogin) {
589
+ that.pendingLogin.reject(error);
590
+ that.pendingLogin = null;
591
+ }
592
+ }
593
+ }
594
+ };
545
595
  const handleCloseModal = () => {
546
596
  setShowWalletModal(false);
547
597
  if (that.loginInProgress && that.pendingLogin && !(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected)) {
@@ -716,6 +766,23 @@ class PhantomWalletProvider {
716
766
  stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
717
767
  })), 'Connect Mobile Wallet'));
718
768
  }
769
+ // Poofnet simulated-wallet button — shown only when the offchain mock
770
+ // option is enabled (onSwitchToPoofnet is set for offchain + showPoofnetWallet).
771
+ if (that.onSwitchToPoofnet) {
772
+ walletButtons.push(React.createElement('button', {
773
+ key: 'poofnet-wallet',
774
+ style: buttonStyle('poofnet-wallet'),
775
+ onClick: handlePoofnetClick,
776
+ onMouseEnter: () => setHoveredBtn('poofnet-wallet'),
777
+ onMouseLeave: () => setHoveredBtn(null),
778
+ }, React.createElement('span', {
779
+ style: {
780
+ width: '18px', height: '18px', borderRadius: '50%',
781
+ background: 'linear-gradient(135deg,#9945FF,#14F195)',
782
+ flexShrink: '0', display: 'inline-block',
783
+ },
784
+ }), 'Connect with Poofnet wallet'));
785
+ }
719
786
  // Email button — only when Privy fallback is enabled
720
787
  if (that.config.enablePrivyFallback) {
721
788
  walletButtons.push(React.createElement('button', {
@@ -1033,6 +1100,54 @@ class PhantomWalletProvider {
1033
1100
  }
1034
1101
  return null;
1035
1102
  }
1103
+ // When connect is delegated to a top-level tab (openTopLevelForConnect — used
1104
+ // for the cross-origin preview iframe on mobile, where MWA can't run), the
1105
+ // actual connect happens in that tab and writes the session to same-origin
1106
+ // storage. This watches for that session to appear and resolves the in-flight
1107
+ // login() with it. It listens for `storage` events and visibility regain (the
1108
+ // user returning from the tab), with a polling fallback and a hard timeout.
1109
+ awaitTopLevelConnect() {
1110
+ if (typeof window === 'undefined')
1111
+ return;
1112
+ let done = false;
1113
+ const cleanup = () => {
1114
+ clearInterval(poll);
1115
+ clearTimeout(timeout);
1116
+ window.removeEventListener('storage', onChange);
1117
+ document.removeEventListener('visibilitychange', onVisible);
1118
+ };
1119
+ const tryResolve = async () => {
1120
+ if (done)
1121
+ return;
1122
+ try {
1123
+ const user = await this.restoreSession();
1124
+ if (user && this.pendingLogin) {
1125
+ done = true;
1126
+ cleanup();
1127
+ this.pendingLogin.resolve(user);
1128
+ this.pendingLogin = null;
1129
+ this.loginInProgress = false;
1130
+ }
1131
+ }
1132
+ catch (_a) {
1133
+ // not ready yet — keep waiting
1134
+ }
1135
+ };
1136
+ const onChange = () => { void tryResolve(); };
1137
+ const onVisible = () => { if (document.visibilityState === 'visible')
1138
+ void tryResolve(); };
1139
+ const poll = setInterval(() => { void tryResolve(); }, 1500);
1140
+ const timeout = setTimeout(() => {
1141
+ cleanup();
1142
+ if (!done && this.pendingLogin) {
1143
+ this.pendingLogin.reject(new Error('Wallet connection timed out'));
1144
+ this.pendingLogin = null;
1145
+ this.loginInProgress = false;
1146
+ }
1147
+ }, 180000);
1148
+ window.addEventListener('storage', onChange);
1149
+ document.addEventListener('visibilitychange', onVisible);
1150
+ }
1036
1151
  async address() {
1037
1152
  var _a, _b, _c, _d;
1038
1153
  await this.ensureReady();
@@ -1121,7 +1236,7 @@ class PhantomWalletProvider {
1121
1236
  // building from components.
1122
1237
  let tx;
1123
1238
  if (solTransactionData.signedTransaction) {
1124
- tx = web3_js.VersionedTransaction.deserialize(index.bufferExports.Buffer.from(solTransactionData.signedTransaction, 'base64'));
1239
+ tx = web3_js.VersionedTransaction.deserialize(index_native.bufferExports.Buffer.from(solTransactionData.signedTransaction, 'base64'));
1125
1240
  }
1126
1241
  else {
1127
1242
  const result = await index_native.buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, publicKey, {
@@ -1392,7 +1507,7 @@ class PhantomWalletProvider {
1392
1507
  try {
1393
1508
  // signMessage returns { signature: Uint8Array, publicKey: string }
1394
1509
  const result = await this.phantomMethods.solana.signMessage(message);
1395
- return index.bufferExports.Buffer.from(result.signature).toString('base64');
1510
+ return index_native.bufferExports.Buffer.from(result.signature).toString('base64');
1396
1511
  }
1397
1512
  catch (error) {
1398
1513
  // Check if this is a connection error - if so, log out
@@ -1488,4 +1603,4 @@ class PhantomWalletProvider {
1488
1603
  PhantomWalletProvider.instance = null;
1489
1604
 
1490
1605
  exports.PhantomWalletProvider = PhantomWalletProvider;
1491
- //# sourceMappingURL=phantom-wallet-provider-4_DBhDbx.js.map
1606
+ //# sourceMappingURL=phantom-wallet-provider-BgDhrraw.js.map