@pooflabs/web 0.0.89-rc2 → 0.0.89-rc4

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 (55) hide show
  1. package/dist/auth/hooks/usePoofnetWallet.d.ts +28 -0
  2. package/dist/auth/providers/mock-poofnet-provider.d.ts +10 -25
  3. package/dist/{index-DQhWZskl.esm.js → index-Bop7HFA-.esm.js} +2 -2
  4. package/dist/{index-4JUcdcnk.esm.js.map → index-Bop7HFA-.esm.js.map} +1 -1
  5. package/dist/{index-CXmcQaFm.js → index-CEADZ0na.js} +2 -2
  6. package/dist/{index-CXmcQaFm.js.map → index-CEADZ0na.js.map} +1 -1
  7. package/dist/{index-Cgaz8U9W.esm.js → index-DGOP9-5L.esm.js} +132 -87
  8. package/dist/index-DGOP9-5L.esm.js.map +1 -0
  9. package/dist/{index-BLiaV7Dz.js → index-DHI02_l_.js} +132 -86
  10. package/dist/index-DHI02_l_.js.map +1 -0
  11. package/dist/{index-QJAj_nTx.js → index-DS3Ftep_.js} +2 -2
  12. package/dist/{index-QJAj_nTx.js.map → index-DS3Ftep_.js.map} +1 -1
  13. package/dist/{index-4JUcdcnk.esm.js → index-DZhOa-_D.esm.js} +2 -2
  14. package/dist/{index-DQhWZskl.esm.js.map → index-DZhOa-_D.esm.js.map} +1 -1
  15. package/dist/{index.browser-kQdoMu7Y.esm.js → index.browser-0dewreQm.esm.js} +2 -2
  16. package/dist/{index.browser-kQdoMu7Y.esm.js.map → index.browser-0dewreQm.esm.js.map} +1 -1
  17. package/dist/{index.browser-CG2sQjrd.esm.js → index.browser-B-pUCZgP.esm.js} +2 -2
  18. package/dist/{index.browser-CG2sQjrd.esm.js.map → index.browser-B-pUCZgP.esm.js.map} +1 -1
  19. package/dist/{index.browser-B9NfvmrP.js → index.browser-C9AVHEa4.js} +2 -2
  20. package/dist/{index.browser-B9NfvmrP.js.map → index.browser-C9AVHEa4.js.map} +1 -1
  21. package/dist/{index.browser-UxB-zDuA.js → index.browser-rhFUHjM1.js} +2 -2
  22. package/dist/{index.browser-UxB-zDuA.js.map → index.browser-rhFUHjM1.js.map} +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.esm.js +1 -1
  25. package/dist/index.js +2 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/{index.native-CwpIbypp.esm.js → index.native-CXtxnE1X.esm.js} +114 -85
  28. package/dist/index.native-CXtxnE1X.esm.js.map +1 -0
  29. package/dist/{index.native-Cycwo-3I.js → index.native-DzDWIHgW.js} +114 -84
  30. package/dist/index.native-DzDWIHgW.js.map +1 -0
  31. package/dist/index.native.d.ts +2 -0
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +2 -1
  34. package/dist/index.native.js.map +1 -1
  35. package/dist/{phantom-wallet-provider-DM-96ILz.esm.js → phantom-wallet-provider-SmsVVBCI.esm.js} +16 -3
  36. package/dist/phantom-wallet-provider-SmsVVBCI.esm.js.map +1 -0
  37. package/dist/{phantom-wallet-provider-BgDhrraw.js → phantom-wallet-provider-mA4Yaf-t.js} +16 -3
  38. package/dist/phantom-wallet-provider-mA4Yaf-t.js.map +1 -0
  39. package/dist/{privy-wallet-provider-C70AIqHI.esm.js → privy-wallet-provider-BNPm2WEZ.esm.js} +3 -3
  40. package/dist/{privy-wallet-provider-C70AIqHI.esm.js.map → privy-wallet-provider-BNPm2WEZ.esm.js.map} +1 -1
  41. package/dist/{privy-wallet-provider-D4IYOUji.js → privy-wallet-provider-CHMc_YjB.js} +3 -3
  42. package/dist/{privy-wallet-provider-D4IYOUji.js.map → privy-wallet-provider-CHMc_YjB.js.map} +1 -1
  43. package/dist/{solana-mobile-wallet-provider-CXXw-pKg.esm.js → solana-mobile-wallet-provider-BMGBQI3W.esm.js} +8 -5
  44. package/dist/solana-mobile-wallet-provider-BMGBQI3W.esm.js.map +1 -0
  45. package/dist/{solana-mobile-wallet-provider-BrjPc7Wd.js → solana-mobile-wallet-provider-DmBKAypM.js} +8 -5
  46. package/dist/solana-mobile-wallet-provider-DmBKAypM.js.map +1 -0
  47. package/package.json +1 -1
  48. package/dist/index-BLiaV7Dz.js.map +0 -1
  49. package/dist/index-Cgaz8U9W.esm.js.map +0 -1
  50. package/dist/index.native-CwpIbypp.esm.js.map +0 -1
  51. package/dist/index.native-Cycwo-3I.js.map +0 -1
  52. package/dist/phantom-wallet-provider-BgDhrraw.js.map +0 -1
  53. package/dist/phantom-wallet-provider-DM-96ILz.esm.js.map +0 -1
  54. package/dist/solana-mobile-wallet-provider-BrjPc7Wd.js.map +0 -1
  55. package/dist/solana-mobile-wallet-provider-CXXw-pKg.esm.js.map +0 -1
@@ -16895,13 +16895,19 @@ const AUTH_METHOD = 'poofnet-mock';
16895
16895
  * wrapped by OffchainAuthProvider so transaction mocking is unchanged. Mainnet
16896
16896
  * never touches this class.
16897
16897
  */
16898
+ /**
16899
+ * The active MockPoofnetProvider instance while mock-connected. Exposed so the
16900
+ * usePoofnetWallet() hook (and thus the app's own wallet UI, e.g. WalletButton)
16901
+ * can list/switch/generate mock wallets. Null when not mock-connected.
16902
+ */
16903
+ let activeMockPoofnetInstance = null;
16904
+ function getActiveMockPoofnetProvider() {
16905
+ return activeMockPoofnetInstance;
16906
+ }
16898
16907
  class MockPoofnetProvider {
16899
16908
  constructor() {
16900
16909
  /** The keypair for the currently-connected mock wallet (re-derived on login/switch/restore). */
16901
16910
  this.activeKeypair = null;
16902
- /** Floating wallet widget root (web only). */
16903
- this.widgetEl = null;
16904
- this.widgetExpanded = false;
16905
16911
  }
16906
16912
  // ============ Identity / derivation ============
16907
16913
  getDeviceId() {
@@ -17000,21 +17006,24 @@ class MockPoofnetProvider {
17000
17006
  }
17001
17007
  const index = Math.min(meta.activeIndex, meta.count - 1);
17002
17008
  this.activeKeypair = await this.deriveKeypair(appId, index);
17009
+ // Set the singleton BEFORE mintSession — mintSession calls setCurrentUser,
17010
+ // which fires onAuthStateChanged → usePoofnetWallet.refresh(); that refresh
17011
+ // must see this instance (else isMock is false until a reload).
17012
+ activeMockPoofnetInstance = this;
17003
17013
  const user = await this.mintSession(this.activeKeypair);
17004
- this.showWalletWidget(appId).catch(() => { });
17005
17014
  return user;
17006
17015
  }
17007
17016
  async restoreSession() {
17008
17017
  const session = await WebSessionManager.getSession();
17009
17018
  if (!session)
17010
17019
  return null;
17011
- // Re-derive the active keypair so signMessage works after a reload, and
17012
- // re-show the widget. Best-effort — the session itself is authoritative.
17020
+ // Re-derive the active keypair so signMessage works after a reload.
17021
+ // Best-effort — the session itself is authoritative.
17013
17022
  try {
17014
17023
  const appId = await this.getAppId();
17015
17024
  const meta = this.getWalletMeta(appId);
17016
17025
  this.activeKeypair = await this.deriveKeypair(appId, Math.min(meta.activeIndex, Math.max(0, meta.count - 1)));
17017
- this.showWalletWidget(appId).catch(() => { });
17026
+ activeMockPoofnetInstance = this;
17018
17027
  }
17019
17028
  catch ( /* noop */_a) { /* noop */ }
17020
17029
  return { provider: this, address: session.address };
@@ -17023,7 +17032,7 @@ class MockPoofnetProvider {
17023
17032
  WebSessionManager.clearSession();
17024
17033
  setCurrentUser(null);
17025
17034
  this.activeKeypair = null;
17026
- this.removeWalletWidget();
17035
+ activeMockPoofnetInstance = null;
17027
17036
  }
17028
17037
  // ============ Multi-wallet management ============
17029
17038
  /** Switch to (and connect as) an existing mock wallet by index. */
@@ -17037,8 +17046,10 @@ class MockPoofnetProvider {
17037
17046
  // Drop the old session, mint a fresh one for the selected wallet.
17038
17047
  WebSessionManager.clearSession();
17039
17048
  this.activeKeypair = await this.deriveKeypair(appId, index);
17049
+ // Set the singleton before mintSession (see login) so the refresh that
17050
+ // mintSession's setCurrentUser triggers observes the active instance.
17051
+ activeMockPoofnetInstance = this;
17040
17052
  const user = await this.mintSession(this.activeKeypair);
17041
- this.showWalletWidget(appId).catch(() => { });
17042
17053
  return user;
17043
17054
  }
17044
17055
  /** Generate a brand-new mock wallet (next index) and connect as it. */
@@ -17047,6 +17058,18 @@ class MockPoofnetProvider {
17047
17058
  const meta = this.getWalletMeta(appId);
17048
17059
  return this.switchWallet(meta.count);
17049
17060
  }
17061
+ /** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
17062
+ async getWalletState() {
17063
+ const appId = await this.getAppId();
17064
+ const meta = this.getWalletMeta(appId);
17065
+ const count = Math.max(1, meta.count);
17066
+ const wallets = [];
17067
+ for (let i = 0; i < count; i++) {
17068
+ const kp = await this.deriveKeypair(appId, i);
17069
+ wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17070
+ }
17071
+ return { wallets, activeIndex: Math.min(meta.activeIndex, count - 1) };
17072
+ }
17050
17073
  // ============ AuthProvider interface (offchain-wrapped, mostly inert) ============
17051
17074
  async signMessage(message) {
17052
17075
  if (!this.activeKeypair)
@@ -17079,73 +17102,6 @@ class MockPoofnetProvider {
17079
17102
  async getNativeMethods() {
17080
17103
  return {};
17081
17104
  }
17082
- // ============ Floating wallet widget (web only) ============
17083
- async showWalletWidget(appId) {
17084
- if (!getPlatform().hasDOM || typeof document === 'undefined')
17085
- return;
17086
- const meta = this.getWalletMeta(appId);
17087
- // Derive addresses for every wallet so the dropdown can show them.
17088
- const wallets = [];
17089
- for (let i = 0; i < meta.count; i++) {
17090
- const kp = await this.deriveKeypair(appId, i);
17091
- wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17092
- }
17093
- const active = wallets[Math.min(meta.activeIndex, wallets.length - 1)] || wallets[0];
17094
- if (!active)
17095
- return;
17096
- if (!this.widgetEl) {
17097
- this.widgetEl = document.createElement('div');
17098
- this.widgetEl.id = 'poofnet-wallet-widget';
17099
- document.body.appendChild(this.widgetEl);
17100
- }
17101
- const short = (a) => `${a.slice(0, 4)}…${a.slice(-4)}`;
17102
- const rows = wallets.map((w) => `
17103
- <button data-poofnet-switch="${w.index}" style="display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;padding:8px 10px;background:${w.index === active.index ? 'rgba(153,69,255,0.18)' : 'transparent'};border:none;border-radius:8px;color:#fff;font-size:13px;cursor:pointer;text-align:left;">
17104
- <span style="display:flex;flex-direction:column;"><span style="font-weight:600;">${w.label}</span><span style="opacity:0.55;font-size:11px;font-family:monospace;">${short(w.address)}</span></span>
17105
- ${w.index === active.index ? '<span style="color:#9945FF;">●</span>' : ''}
17106
- </button>`).join('');
17107
- this.widgetEl.innerHTML = `
17108
- <div style="position:fixed;bottom:16px;right:16px;z-index:2147483600;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
17109
- ${this.widgetExpanded ? `
17110
- <div style="margin-bottom:8px;width:240px;background:#161618;border:1px solid #2a2a2e;border-radius:12px;padding:8px;box-shadow:0 8px 32px rgba(0,0,0,0.5);">
17111
- <div style="padding:6px 10px 8px;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;color:#9945FF;font-weight:700;">Poofnet · Simulated</div>
17112
- <div style="max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:2px;">${rows}</div>
17113
- <button data-poofnet-generate="1" style="margin-top:6px;width:100%;padding:8px 10px;background:rgba(153,69,255,0.12);border:1px dashed #9945FF;border-radius:8px;color:#c8a4ff;font-size:13px;font-weight:600;cursor:pointer;">+ Generate new wallet</button>
17114
- </div>` : ''}
17115
- <button data-poofnet-toggle="1" style="display:flex;align-items:center;gap:8px;padding:8px 12px;background:#161618;border:1px solid #2a2a2e;border-radius:999px;color:#fff;font-size:13px;cursor:pointer;box-shadow:0 4px 16px rgba(0,0,0,0.4);">
17116
- <span style="width:8px;height:8px;border-radius:50%;background:#9945FF;box-shadow:0 0 8px #9945FF;"></span>
17117
- <span style="font-weight:600;">${active.label}</span>
17118
- <span style="opacity:0.55;font-family:monospace;font-size:12px;">${short(active.address)}</span>
17119
- <span style="opacity:0.5;transform:rotate(${this.widgetExpanded ? '180deg' : '0deg'});">▾</span>
17120
- </button>
17121
- </div>`;
17122
- // Wire handlers (re-bound each render).
17123
- const toggle = this.widgetEl.querySelector('[data-poofnet-toggle]');
17124
- if (toggle)
17125
- toggle.onclick = () => { this.widgetExpanded = !this.widgetExpanded; this.showWalletWidget(appId).catch(() => { }); };
17126
- this.widgetEl.querySelectorAll('[data-poofnet-switch]').forEach((btn) => {
17127
- btn.onclick = async () => {
17128
- const idx = parseInt(btn.getAttribute('data-poofnet-switch'), 10);
17129
- this.widgetExpanded = false;
17130
- if (idx !== active.index)
17131
- await this.switchWallet(idx);
17132
- else
17133
- this.showWalletWidget(appId).catch(() => { });
17134
- };
17135
- });
17136
- const gen = this.widgetEl.querySelector('[data-poofnet-generate]');
17137
- if (gen)
17138
- gen.onclick = async () => { this.widgetExpanded = false; await this.generateWallet(); };
17139
- }
17140
- removeWalletWidget() {
17141
- try {
17142
- if (this.widgetEl && this.widgetEl.parentNode)
17143
- this.widgetEl.parentNode.removeChild(this.widgetEl);
17144
- }
17145
- catch ( /* noop */_a) { /* noop */ }
17146
- this.widgetEl = null;
17147
- this.widgetExpanded = false;
17148
- }
17149
17105
  }
17150
17106
 
17151
17107
  /**
@@ -17909,15 +17865,15 @@ function clearIncompatibleSession() {
17909
17865
  // Lazy loaders for web-only providers.
17910
17866
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
17911
17867
  async function loadPrivyWalletProvider() {
17912
- const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-D4IYOUji.js'); });
17868
+ const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-CHMc_YjB.js'); });
17913
17869
  return mod.PrivyWalletProvider;
17914
17870
  }
17915
17871
  async function loadPhantomWalletProvider() {
17916
- const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-BgDhrraw.js'); });
17872
+ const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-mA4Yaf-t.js'); });
17917
17873
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
17918
17874
  }
17919
17875
  async function loadSolanaMobileWalletProvider() {
17920
- const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-BrjPc7Wd.js'); });
17876
+ const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-DmBKAypM.js'); });
17921
17877
  return mod.SolanaMobileWalletProvider;
17922
17878
  }
17923
17879
  async function hotSwapToPrivyProvider(config) {
@@ -18247,17 +18203,17 @@ function setAuthProviderInstance(provider) {
18247
18203
  authProviderInstance = provider;
18248
18204
  }
18249
18205
 
18250
- var _a;
18206
+ var _a$1;
18251
18207
  // Whether we're in a server-side rendering context (no hooks allowed).
18252
18208
  // React Native has no `window` but DOES support hooks.
18253
18209
  // We detect Node SSR specifically via process.versions.node to avoid
18254
18210
  // false positives from Node 21+ which defines `navigator` globally.
18255
- const isSSR = typeof window === 'undefined'
18211
+ const isSSR$1 = typeof window === 'undefined'
18256
18212
  && typeof process !== 'undefined'
18257
- && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18213
+ && !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
18258
18214
  function useAuth() {
18259
18215
  // Provide a fallback so server render doesn't break
18260
- if (isSSR) {
18216
+ if (isSSR$1) {
18261
18217
  return {
18262
18218
  login: async () => undefined,
18263
18219
  logout: async () => undefined,
@@ -18317,6 +18273,79 @@ function useAuth() {
18317
18273
  };
18318
18274
  }
18319
18275
 
18276
+ var _a;
18277
+ const isSSR = typeof window === 'undefined'
18278
+ && typeof process !== 'undefined'
18279
+ && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18280
+ const EMPTY = {
18281
+ isMock: false,
18282
+ wallets: [],
18283
+ activeIndex: 0,
18284
+ switchWallet: async () => undefined,
18285
+ generateWallet: async () => undefined,
18286
+ refresh: async () => undefined,
18287
+ };
18288
+ /**
18289
+ * Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
18290
+ * template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
18291
+ * so callers can conditionally render the switch/generate controls.
18292
+ *
18293
+ * Reactive: re-reads whenever auth state changes (login / logout / wallet
18294
+ * switch all flow through setCurrentUser → onAuthStateChanged).
18295
+ */
18296
+ function usePoofnetWallet() {
18297
+ if (isSSR)
18298
+ return EMPTY;
18299
+ const [state, setState] = React__namespace.useState({
18300
+ isMock: false,
18301
+ wallets: [],
18302
+ activeIndex: 0,
18303
+ });
18304
+ const refresh = React__namespace.useCallback(async () => {
18305
+ const provider = getActiveMockPoofnetProvider();
18306
+ if (!provider) {
18307
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18308
+ return;
18309
+ }
18310
+ try {
18311
+ const { wallets, activeIndex } = await provider.getWalletState();
18312
+ setState({ isMock: true, wallets, activeIndex });
18313
+ }
18314
+ catch (_a) {
18315
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18316
+ }
18317
+ }, []);
18318
+ React__namespace.useEffect(() => {
18319
+ refresh();
18320
+ // setCurrentUser (login/logout/switch/generate) notifies these listeners.
18321
+ onAuthStateChanged(() => { refresh(); });
18322
+ // Note: onAuthStateChanged has no unsubscribe yet (same as useAuth) — fine
18323
+ // for a wallet button that mounts once.
18324
+ }, [refresh]);
18325
+ const switchWallet = React__namespace.useCallback(async (index) => {
18326
+ const provider = getActiveMockPoofnetProvider();
18327
+ if (provider) {
18328
+ await provider.switchWallet(index);
18329
+ await refresh();
18330
+ }
18331
+ }, [refresh]);
18332
+ const generateWallet = React__namespace.useCallback(async () => {
18333
+ const provider = getActiveMockPoofnetProvider();
18334
+ if (provider) {
18335
+ await provider.generateWallet();
18336
+ await refresh();
18337
+ }
18338
+ }, [refresh]);
18339
+ return {
18340
+ isMock: state.isMock,
18341
+ wallets: state.wallets,
18342
+ activeIndex: state.activeIndex,
18343
+ switchWallet,
18344
+ generateWallet,
18345
+ refresh,
18346
+ };
18347
+ }
18348
+
18320
18349
  async function deserializeTransaction(tx) {
18321
18350
  const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
18322
18351
  if ((buf[0] & 0x80) !== 0) {
@@ -19011,4 +19040,5 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
19011
19040
  exports.signTransaction = signTransaction;
19012
19041
  exports.subscribe = subscribe;
19013
19042
  exports.useAuth = useAuth;
19014
- //# sourceMappingURL=index.native-Cycwo-3I.js.map
19043
+ exports.usePoofnetWallet = usePoofnetWallet;
19044
+ //# sourceMappingURL=index.native-DzDWIHgW.js.map