@pooflabs/web 0.0.89-rc2 → 0.0.89-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 (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-Cgaz8U9W.esm.js → index-2wcE74zV.esm.js} +127 -87
  4. package/dist/index-2wcE74zV.esm.js.map +1 -0
  5. package/dist/{index-BLiaV7Dz.js → index-BbyEdrbT.js} +127 -86
  6. package/dist/index-BbyEdrbT.js.map +1 -0
  7. package/dist/{index-CXmcQaFm.js → index-BdtzCA9I.js} +2 -2
  8. package/dist/{index-CXmcQaFm.js.map → index-BdtzCA9I.js.map} +1 -1
  9. package/dist/{index-4JUcdcnk.esm.js → index-BosINgjL.esm.js} +2 -2
  10. package/dist/{index-4JUcdcnk.esm.js.map → index-BosINgjL.esm.js.map} +1 -1
  11. package/dist/{index-QJAj_nTx.js → index-D5KlQpzj.js} +2 -2
  12. package/dist/{index-QJAj_nTx.js.map → index-D5KlQpzj.js.map} +1 -1
  13. package/dist/{index-DQhWZskl.esm.js → index-TCh-Tz3A.esm.js} +2 -2
  14. package/dist/{index-DQhWZskl.esm.js.map → index-TCh-Tz3A.esm.js.map} +1 -1
  15. package/dist/{index.browser-CG2sQjrd.esm.js → index.browser-CQxdFuE2.esm.js} +2 -2
  16. package/dist/{index.browser-CG2sQjrd.esm.js.map → index.browser-CQxdFuE2.esm.js.map} +1 -1
  17. package/dist/{index.browser-kQdoMu7Y.esm.js → index.browser-CkaOa5gJ.esm.js} +2 -2
  18. package/dist/{index.browser-kQdoMu7Y.esm.js.map → index.browser-CkaOa5gJ.esm.js.map} +1 -1
  19. package/dist/{index.browser-B9NfvmrP.js → index.browser-DxjCzf2n.js} +2 -2
  20. package/dist/{index.browser-B9NfvmrP.js.map → index.browser-DxjCzf2n.js.map} +1 -1
  21. package/dist/{index.browser-UxB-zDuA.js → index.browser-dTW8LCID.js} +2 -2
  22. package/dist/{index.browser-UxB-zDuA.js.map → index.browser-dTW8LCID.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-Ch6gsAP_.esm.js} +109 -85
  28. package/dist/index.native-Ch6gsAP_.esm.js.map +1 -0
  29. package/dist/{index.native-Cycwo-3I.js → index.native-K4hpch3o.js} +109 -84
  30. package/dist/index.native-K4hpch3o.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-BgDhrraw.js → phantom-wallet-provider-BOz9oPsO.js} +16 -3
  36. package/dist/phantom-wallet-provider-BOz9oPsO.js.map +1 -0
  37. package/dist/{phantom-wallet-provider-DM-96ILz.esm.js → phantom-wallet-provider-ieVw9iZ_.esm.js} +16 -3
  38. package/dist/phantom-wallet-provider-ieVw9iZ_.esm.js.map +1 -0
  39. package/dist/{privy-wallet-provider-D4IYOUji.js → privy-wallet-provider-BlWvz1R6.js} +3 -3
  40. package/dist/{privy-wallet-provider-D4IYOUji.js.map → privy-wallet-provider-BlWvz1R6.js.map} +1 -1
  41. package/dist/{privy-wallet-provider-C70AIqHI.esm.js → privy-wallet-provider-CVVhV2RP.esm.js} +3 -3
  42. package/dist/{privy-wallet-provider-C70AIqHI.esm.js.map → privy-wallet-provider-CVVhV2RP.esm.js.map} +1 -1
  43. package/dist/{solana-mobile-wallet-provider-BrjPc7Wd.js → solana-mobile-wallet-provider-C8QDeO6I.js} +8 -5
  44. package/dist/solana-mobile-wallet-provider-C8QDeO6I.js.map +1 -0
  45. package/dist/{solana-mobile-wallet-provider-CXXw-pKg.esm.js → solana-mobile-wallet-provider-CHMZajIq.esm.js} +8 -5
  46. package/dist/solana-mobile-wallet-provider-CHMZajIq.esm.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() {
@@ -17001,20 +17007,20 @@ class MockPoofnetProvider {
17001
17007
  const index = Math.min(meta.activeIndex, meta.count - 1);
17002
17008
  this.activeKeypair = await this.deriveKeypair(appId, index);
17003
17009
  const user = await this.mintSession(this.activeKeypair);
17004
- this.showWalletWidget(appId).catch(() => { });
17010
+ activeMockPoofnetInstance = this;
17005
17011
  return user;
17006
17012
  }
17007
17013
  async restoreSession() {
17008
17014
  const session = await WebSessionManager.getSession();
17009
17015
  if (!session)
17010
17016
  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.
17017
+ // Re-derive the active keypair so signMessage works after a reload.
17018
+ // Best-effort — the session itself is authoritative.
17013
17019
  try {
17014
17020
  const appId = await this.getAppId();
17015
17021
  const meta = this.getWalletMeta(appId);
17016
17022
  this.activeKeypair = await this.deriveKeypair(appId, Math.min(meta.activeIndex, Math.max(0, meta.count - 1)));
17017
- this.showWalletWidget(appId).catch(() => { });
17023
+ activeMockPoofnetInstance = this;
17018
17024
  }
17019
17025
  catch ( /* noop */_a) { /* noop */ }
17020
17026
  return { provider: this, address: session.address };
@@ -17023,7 +17029,7 @@ class MockPoofnetProvider {
17023
17029
  WebSessionManager.clearSession();
17024
17030
  setCurrentUser(null);
17025
17031
  this.activeKeypair = null;
17026
- this.removeWalletWidget();
17032
+ activeMockPoofnetInstance = null;
17027
17033
  }
17028
17034
  // ============ Multi-wallet management ============
17029
17035
  /** Switch to (and connect as) an existing mock wallet by index. */
@@ -17038,7 +17044,7 @@ class MockPoofnetProvider {
17038
17044
  WebSessionManager.clearSession();
17039
17045
  this.activeKeypair = await this.deriveKeypair(appId, index);
17040
17046
  const user = await this.mintSession(this.activeKeypair);
17041
- this.showWalletWidget(appId).catch(() => { });
17047
+ activeMockPoofnetInstance = this;
17042
17048
  return user;
17043
17049
  }
17044
17050
  /** Generate a brand-new mock wallet (next index) and connect as it. */
@@ -17047,6 +17053,18 @@ class MockPoofnetProvider {
17047
17053
  const meta = this.getWalletMeta(appId);
17048
17054
  return this.switchWallet(meta.count);
17049
17055
  }
17056
+ /** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
17057
+ async getWalletState() {
17058
+ const appId = await this.getAppId();
17059
+ const meta = this.getWalletMeta(appId);
17060
+ const count = Math.max(1, meta.count);
17061
+ const wallets = [];
17062
+ for (let i = 0; i < count; i++) {
17063
+ const kp = await this.deriveKeypair(appId, i);
17064
+ wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17065
+ }
17066
+ return { wallets, activeIndex: Math.min(meta.activeIndex, count - 1) };
17067
+ }
17050
17068
  // ============ AuthProvider interface (offchain-wrapped, mostly inert) ============
17051
17069
  async signMessage(message) {
17052
17070
  if (!this.activeKeypair)
@@ -17079,73 +17097,6 @@ class MockPoofnetProvider {
17079
17097
  async getNativeMethods() {
17080
17098
  return {};
17081
17099
  }
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
17100
  }
17150
17101
 
17151
17102
  /**
@@ -17909,15 +17860,15 @@ function clearIncompatibleSession() {
17909
17860
  // Lazy loaders for web-only providers.
17910
17861
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
17911
17862
  async function loadPrivyWalletProvider() {
17912
- const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-D4IYOUji.js'); });
17863
+ const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-BlWvz1R6.js'); });
17913
17864
  return mod.PrivyWalletProvider;
17914
17865
  }
17915
17866
  async function loadPhantomWalletProvider() {
17916
- const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-BgDhrraw.js'); });
17867
+ const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-BOz9oPsO.js'); });
17917
17868
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
17918
17869
  }
17919
17870
  async function loadSolanaMobileWalletProvider() {
17920
- const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-BrjPc7Wd.js'); });
17871
+ const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-C8QDeO6I.js'); });
17921
17872
  return mod.SolanaMobileWalletProvider;
17922
17873
  }
17923
17874
  async function hotSwapToPrivyProvider(config) {
@@ -18247,17 +18198,17 @@ function setAuthProviderInstance(provider) {
18247
18198
  authProviderInstance = provider;
18248
18199
  }
18249
18200
 
18250
- var _a;
18201
+ var _a$1;
18251
18202
  // Whether we're in a server-side rendering context (no hooks allowed).
18252
18203
  // React Native has no `window` but DOES support hooks.
18253
18204
  // We detect Node SSR specifically via process.versions.node to avoid
18254
18205
  // false positives from Node 21+ which defines `navigator` globally.
18255
- const isSSR = typeof window === 'undefined'
18206
+ const isSSR$1 = typeof window === 'undefined'
18256
18207
  && typeof process !== 'undefined'
18257
- && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18208
+ && !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
18258
18209
  function useAuth() {
18259
18210
  // Provide a fallback so server render doesn't break
18260
- if (isSSR) {
18211
+ if (isSSR$1) {
18261
18212
  return {
18262
18213
  login: async () => undefined,
18263
18214
  logout: async () => undefined,
@@ -18317,6 +18268,79 @@ function useAuth() {
18317
18268
  };
18318
18269
  }
18319
18270
 
18271
+ var _a;
18272
+ const isSSR = typeof window === 'undefined'
18273
+ && typeof process !== 'undefined'
18274
+ && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18275
+ const EMPTY = {
18276
+ isMock: false,
18277
+ wallets: [],
18278
+ activeIndex: 0,
18279
+ switchWallet: async () => undefined,
18280
+ generateWallet: async () => undefined,
18281
+ refresh: async () => undefined,
18282
+ };
18283
+ /**
18284
+ * Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
18285
+ * template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
18286
+ * so callers can conditionally render the switch/generate controls.
18287
+ *
18288
+ * Reactive: re-reads whenever auth state changes (login / logout / wallet
18289
+ * switch all flow through setCurrentUser → onAuthStateChanged).
18290
+ */
18291
+ function usePoofnetWallet() {
18292
+ if (isSSR)
18293
+ return EMPTY;
18294
+ const [state, setState] = React__namespace.useState({
18295
+ isMock: false,
18296
+ wallets: [],
18297
+ activeIndex: 0,
18298
+ });
18299
+ const refresh = React__namespace.useCallback(async () => {
18300
+ const provider = getActiveMockPoofnetProvider();
18301
+ if (!provider) {
18302
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18303
+ return;
18304
+ }
18305
+ try {
18306
+ const { wallets, activeIndex } = await provider.getWalletState();
18307
+ setState({ isMock: true, wallets, activeIndex });
18308
+ }
18309
+ catch (_a) {
18310
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18311
+ }
18312
+ }, []);
18313
+ React__namespace.useEffect(() => {
18314
+ refresh();
18315
+ // setCurrentUser (login/logout/switch/generate) notifies these listeners.
18316
+ onAuthStateChanged(() => { refresh(); });
18317
+ // Note: onAuthStateChanged has no unsubscribe yet (same as useAuth) — fine
18318
+ // for a wallet button that mounts once.
18319
+ }, [refresh]);
18320
+ const switchWallet = React__namespace.useCallback(async (index) => {
18321
+ const provider = getActiveMockPoofnetProvider();
18322
+ if (provider) {
18323
+ await provider.switchWallet(index);
18324
+ await refresh();
18325
+ }
18326
+ }, [refresh]);
18327
+ const generateWallet = React__namespace.useCallback(async () => {
18328
+ const provider = getActiveMockPoofnetProvider();
18329
+ if (provider) {
18330
+ await provider.generateWallet();
18331
+ await refresh();
18332
+ }
18333
+ }, [refresh]);
18334
+ return {
18335
+ isMock: state.isMock,
18336
+ wallets: state.wallets,
18337
+ activeIndex: state.activeIndex,
18338
+ switchWallet,
18339
+ generateWallet,
18340
+ refresh,
18341
+ };
18342
+ }
18343
+
18320
18344
  async function deserializeTransaction(tx) {
18321
18345
  const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
18322
18346
  if ((buf[0] & 0x80) !== 0) {
@@ -19011,4 +19035,5 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
19011
19035
  exports.signTransaction = signTransaction;
19012
19036
  exports.subscribe = subscribe;
19013
19037
  exports.useAuth = useAuth;
19014
- //# sourceMappingURL=index.native-Cycwo-3I.js.map
19038
+ exports.usePoofnetWallet = usePoofnetWallet;
19039
+ //# sourceMappingURL=index.native-K4hpch3o.js.map