@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.
- package/dist/auth/hooks/usePoofnetWallet.d.ts +28 -0
- package/dist/auth/providers/mock-poofnet-provider.d.ts +10 -25
- package/dist/{index-Cgaz8U9W.esm.js → index-2wcE74zV.esm.js} +127 -87
- package/dist/index-2wcE74zV.esm.js.map +1 -0
- package/dist/{index-BLiaV7Dz.js → index-BbyEdrbT.js} +127 -86
- package/dist/index-BbyEdrbT.js.map +1 -0
- package/dist/{index-CXmcQaFm.js → index-BdtzCA9I.js} +2 -2
- package/dist/{index-CXmcQaFm.js.map → index-BdtzCA9I.js.map} +1 -1
- package/dist/{index-4JUcdcnk.esm.js → index-BosINgjL.esm.js} +2 -2
- package/dist/{index-4JUcdcnk.esm.js.map → index-BosINgjL.esm.js.map} +1 -1
- package/dist/{index-QJAj_nTx.js → index-D5KlQpzj.js} +2 -2
- package/dist/{index-QJAj_nTx.js.map → index-D5KlQpzj.js.map} +1 -1
- package/dist/{index-DQhWZskl.esm.js → index-TCh-Tz3A.esm.js} +2 -2
- package/dist/{index-DQhWZskl.esm.js.map → index-TCh-Tz3A.esm.js.map} +1 -1
- package/dist/{index.browser-CG2sQjrd.esm.js → index.browser-CQxdFuE2.esm.js} +2 -2
- package/dist/{index.browser-CG2sQjrd.esm.js.map → index.browser-CQxdFuE2.esm.js.map} +1 -1
- package/dist/{index.browser-kQdoMu7Y.esm.js → index.browser-CkaOa5gJ.esm.js} +2 -2
- package/dist/{index.browser-kQdoMu7Y.esm.js.map → index.browser-CkaOa5gJ.esm.js.map} +1 -1
- package/dist/{index.browser-B9NfvmrP.js → index.browser-DxjCzf2n.js} +2 -2
- package/dist/{index.browser-B9NfvmrP.js.map → index.browser-DxjCzf2n.js.map} +1 -1
- package/dist/{index.browser-UxB-zDuA.js → index.browser-dTW8LCID.js} +2 -2
- package/dist/{index.browser-UxB-zDuA.js.map → index.browser-dTW8LCID.js.map} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.native-CwpIbypp.esm.js → index.native-Ch6gsAP_.esm.js} +109 -85
- package/dist/index.native-Ch6gsAP_.esm.js.map +1 -0
- package/dist/{index.native-Cycwo-3I.js → index.native-K4hpch3o.js} +109 -84
- package/dist/index.native-K4hpch3o.js.map +1 -0
- package/dist/index.native.d.ts +2 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +2 -1
- package/dist/index.native.js.map +1 -1
- package/dist/{phantom-wallet-provider-BgDhrraw.js → phantom-wallet-provider-BOz9oPsO.js} +16 -3
- package/dist/phantom-wallet-provider-BOz9oPsO.js.map +1 -0
- package/dist/{phantom-wallet-provider-DM-96ILz.esm.js → phantom-wallet-provider-ieVw9iZ_.esm.js} +16 -3
- package/dist/phantom-wallet-provider-ieVw9iZ_.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-D4IYOUji.js → privy-wallet-provider-BlWvz1R6.js} +3 -3
- package/dist/{privy-wallet-provider-D4IYOUji.js.map → privy-wallet-provider-BlWvz1R6.js.map} +1 -1
- package/dist/{privy-wallet-provider-C70AIqHI.esm.js → privy-wallet-provider-CVVhV2RP.esm.js} +3 -3
- package/dist/{privy-wallet-provider-C70AIqHI.esm.js.map → privy-wallet-provider-CVVhV2RP.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-BrjPc7Wd.js → solana-mobile-wallet-provider-C8QDeO6I.js} +8 -5
- package/dist/solana-mobile-wallet-provider-C8QDeO6I.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-CXXw-pKg.esm.js → solana-mobile-wallet-provider-CHMZajIq.esm.js} +8 -5
- package/dist/solana-mobile-wallet-provider-CHMZajIq.esm.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-BLiaV7Dz.js.map +0 -1
- package/dist/index-Cgaz8U9W.esm.js.map +0 -1
- package/dist/index.native-CwpIbypp.esm.js.map +0 -1
- package/dist/index.native-Cycwo-3I.js.map +0 -1
- package/dist/phantom-wallet-provider-BgDhrraw.js.map +0 -1
- package/dist/phantom-wallet-provider-DM-96ILz.esm.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-BrjPc7Wd.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-CXXw-pKg.esm.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface PoofnetWallet {
|
|
2
|
+
index: number;
|
|
3
|
+
label: string;
|
|
4
|
+
address: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UsePoofnetWalletResult {
|
|
7
|
+
/** True when the active session is a simulated Poofnet (mock) wallet. */
|
|
8
|
+
isMock: boolean;
|
|
9
|
+
/** All mock wallets for this app/device (derived, no secrets stored). */
|
|
10
|
+
wallets: PoofnetWallet[];
|
|
11
|
+
/** Index of the currently-connected mock wallet. */
|
|
12
|
+
activeIndex: number;
|
|
13
|
+
/** Connect as an existing mock wallet by index (re-logins as it). */
|
|
14
|
+
switchWallet: (index: number) => Promise<void>;
|
|
15
|
+
/** Generate a brand-new mock wallet and connect as it. */
|
|
16
|
+
generateWallet: () => Promise<void>;
|
|
17
|
+
/** Re-read the wallet list (rarely needed — auth changes refresh automatically). */
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
|
|
22
|
+
* template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
|
|
23
|
+
* so callers can conditionally render the switch/generate controls.
|
|
24
|
+
*
|
|
25
|
+
* Reactive: re-reads whenever auth state changes (login / logout / wallet
|
|
26
|
+
* switch all flow through setCurrentUser → onAuthStateChanged).
|
|
27
|
+
*/
|
|
28
|
+
export declare function usePoofnetWallet(): UsePoofnetWalletResult;
|
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@pooflabs/core';
|
|
3
|
-
|
|
4
|
-
* MockPoofnetProvider — a *simulated* wallet for the Poofnet (offchain) preview
|
|
5
|
-
* environment. Lets a draft app be used without a real wallet round-trip: it
|
|
6
|
-
* derives a keypair locally and signs the canonical auth-nonce message itself,
|
|
7
|
-
* minting a genuine session through the normal /session flow (the backend
|
|
8
|
-
* verifier only checks signature + canonical message + nonce — never keypair
|
|
9
|
-
* provenance — so a derived key is accepted exactly like a real wallet).
|
|
10
|
-
*
|
|
11
|
-
* Identity model (no per-wallet secret is ever stored):
|
|
12
|
-
* - A random per-device id (`poofnet:deviceId`, generated once) is the entropy
|
|
13
|
-
* root, so two different users on a *direct* draft URL never collide.
|
|
14
|
-
* - Wallet #N = Keypair.fromSeed( sha256("poofnet-mock:" + deviceId + ":" + appId + ":" + N) )
|
|
15
|
-
* — deterministic, so wallets survive reloads and are re-derived on demand.
|
|
16
|
-
* - Per-app (appId in the seed) and per-device. Cross-device-same-user is a
|
|
17
|
-
* later layer (would mix in the poof platform address when available).
|
|
18
|
-
*
|
|
19
|
-
* Only ever constructed when chain === "offchain" (see auth/index.ts), and it is
|
|
20
|
-
* wrapped by OffchainAuthProvider so transaction mocking is unchanged. Mainnet
|
|
21
|
-
* never touches this class.
|
|
22
|
-
*/
|
|
3
|
+
export declare function getActiveMockPoofnetProvider(): MockPoofnetProvider | null;
|
|
23
4
|
export declare class MockPoofnetProvider implements AuthProvider {
|
|
24
5
|
/** The keypair for the currently-connected mock wallet (re-derived on login/switch/restore). */
|
|
25
6
|
private activeKeypair;
|
|
26
|
-
/** Floating wallet widget root (web only). */
|
|
27
|
-
private widgetEl;
|
|
28
|
-
private widgetExpanded;
|
|
29
7
|
private getDeviceId;
|
|
30
8
|
private getAppId;
|
|
31
9
|
private getWalletMeta;
|
|
@@ -47,12 +25,19 @@ export declare class MockPoofnetProvider implements AuthProvider {
|
|
|
47
25
|
switchWallet(index: number): Promise<User | null>;
|
|
48
26
|
/** Generate a brand-new mock wallet (next index) and connect as it. */
|
|
49
27
|
generateWallet(): Promise<User | null>;
|
|
28
|
+
/** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
|
|
29
|
+
getWalletState(): Promise<{
|
|
30
|
+
wallets: {
|
|
31
|
+
index: number;
|
|
32
|
+
label: string;
|
|
33
|
+
address: string;
|
|
34
|
+
}[];
|
|
35
|
+
activeIndex: number;
|
|
36
|
+
}>;
|
|
50
37
|
signMessage(message: string): Promise<string>;
|
|
51
38
|
signMessageMock(message: string): Promise<string>;
|
|
52
39
|
runTransaction(_evmTransactionData?: EVMTransaction, _solTransactionData?: SolTransaction, _options?: SetOptions): Promise<TransactionResult>;
|
|
53
40
|
signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
|
|
54
41
|
signAndSubmitTransaction(_transaction: Transaction | VersionedTransaction, _feePayer?: any): Promise<string>;
|
|
55
42
|
getNativeMethods(): Promise<any>;
|
|
56
|
-
private showWalletWidget;
|
|
57
|
-
private removeWalletWidget;
|
|
58
43
|
}
|
|
@@ -16874,13 +16874,19 @@ const AUTH_METHOD = 'poofnet-mock';
|
|
|
16874
16874
|
* wrapped by OffchainAuthProvider so transaction mocking is unchanged. Mainnet
|
|
16875
16875
|
* never touches this class.
|
|
16876
16876
|
*/
|
|
16877
|
+
/**
|
|
16878
|
+
* The active MockPoofnetProvider instance while mock-connected. Exposed so the
|
|
16879
|
+
* usePoofnetWallet() hook (and thus the app's own wallet UI, e.g. WalletButton)
|
|
16880
|
+
* can list/switch/generate mock wallets. Null when not mock-connected.
|
|
16881
|
+
*/
|
|
16882
|
+
let activeMockPoofnetInstance = null;
|
|
16883
|
+
function getActiveMockPoofnetProvider() {
|
|
16884
|
+
return activeMockPoofnetInstance;
|
|
16885
|
+
}
|
|
16877
16886
|
class MockPoofnetProvider {
|
|
16878
16887
|
constructor() {
|
|
16879
16888
|
/** The keypair for the currently-connected mock wallet (re-derived on login/switch/restore). */
|
|
16880
16889
|
this.activeKeypair = null;
|
|
16881
|
-
/** Floating wallet widget root (web only). */
|
|
16882
|
-
this.widgetEl = null;
|
|
16883
|
-
this.widgetExpanded = false;
|
|
16884
16890
|
}
|
|
16885
16891
|
// ============ Identity / derivation ============
|
|
16886
16892
|
getDeviceId() {
|
|
@@ -16980,20 +16986,20 @@ class MockPoofnetProvider {
|
|
|
16980
16986
|
const index = Math.min(meta.activeIndex, meta.count - 1);
|
|
16981
16987
|
this.activeKeypair = await this.deriveKeypair(appId, index);
|
|
16982
16988
|
const user = await this.mintSession(this.activeKeypair);
|
|
16983
|
-
|
|
16989
|
+
activeMockPoofnetInstance = this;
|
|
16984
16990
|
return user;
|
|
16985
16991
|
}
|
|
16986
16992
|
async restoreSession() {
|
|
16987
16993
|
const session = await WebSessionManager.getSession();
|
|
16988
16994
|
if (!session)
|
|
16989
16995
|
return null;
|
|
16990
|
-
// Re-derive the active keypair so signMessage works after a reload
|
|
16991
|
-
//
|
|
16996
|
+
// Re-derive the active keypair so signMessage works after a reload.
|
|
16997
|
+
// Best-effort — the session itself is authoritative.
|
|
16992
16998
|
try {
|
|
16993
16999
|
const appId = await this.getAppId();
|
|
16994
17000
|
const meta = this.getWalletMeta(appId);
|
|
16995
17001
|
this.activeKeypair = await this.deriveKeypair(appId, Math.min(meta.activeIndex, Math.max(0, meta.count - 1)));
|
|
16996
|
-
|
|
17002
|
+
activeMockPoofnetInstance = this;
|
|
16997
17003
|
}
|
|
16998
17004
|
catch ( /* noop */_a) { /* noop */ }
|
|
16999
17005
|
return { provider: this, address: session.address };
|
|
@@ -17002,7 +17008,7 @@ class MockPoofnetProvider {
|
|
|
17002
17008
|
WebSessionManager.clearSession();
|
|
17003
17009
|
setCurrentUser(null);
|
|
17004
17010
|
this.activeKeypair = null;
|
|
17005
|
-
|
|
17011
|
+
activeMockPoofnetInstance = null;
|
|
17006
17012
|
}
|
|
17007
17013
|
// ============ Multi-wallet management ============
|
|
17008
17014
|
/** Switch to (and connect as) an existing mock wallet by index. */
|
|
@@ -17017,7 +17023,7 @@ class MockPoofnetProvider {
|
|
|
17017
17023
|
WebSessionManager.clearSession();
|
|
17018
17024
|
this.activeKeypair = await this.deriveKeypair(appId, index);
|
|
17019
17025
|
const user = await this.mintSession(this.activeKeypair);
|
|
17020
|
-
|
|
17026
|
+
activeMockPoofnetInstance = this;
|
|
17021
17027
|
return user;
|
|
17022
17028
|
}
|
|
17023
17029
|
/** Generate a brand-new mock wallet (next index) and connect as it. */
|
|
@@ -17026,6 +17032,18 @@ class MockPoofnetProvider {
|
|
|
17026
17032
|
const meta = this.getWalletMeta(appId);
|
|
17027
17033
|
return this.switchWallet(meta.count);
|
|
17028
17034
|
}
|
|
17035
|
+
/** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
|
|
17036
|
+
async getWalletState() {
|
|
17037
|
+
const appId = await this.getAppId();
|
|
17038
|
+
const meta = this.getWalletMeta(appId);
|
|
17039
|
+
const count = Math.max(1, meta.count);
|
|
17040
|
+
const wallets = [];
|
|
17041
|
+
for (let i = 0; i < count; i++) {
|
|
17042
|
+
const kp = await this.deriveKeypair(appId, i);
|
|
17043
|
+
wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
|
|
17044
|
+
}
|
|
17045
|
+
return { wallets, activeIndex: Math.min(meta.activeIndex, count - 1) };
|
|
17046
|
+
}
|
|
17029
17047
|
// ============ AuthProvider interface (offchain-wrapped, mostly inert) ============
|
|
17030
17048
|
async signMessage(message) {
|
|
17031
17049
|
if (!this.activeKeypair)
|
|
@@ -17058,73 +17076,6 @@ class MockPoofnetProvider {
|
|
|
17058
17076
|
async getNativeMethods() {
|
|
17059
17077
|
return {};
|
|
17060
17078
|
}
|
|
17061
|
-
// ============ Floating wallet widget (web only) ============
|
|
17062
|
-
async showWalletWidget(appId) {
|
|
17063
|
-
if (!getPlatform().hasDOM || typeof document === 'undefined')
|
|
17064
|
-
return;
|
|
17065
|
-
const meta = this.getWalletMeta(appId);
|
|
17066
|
-
// Derive addresses for every wallet so the dropdown can show them.
|
|
17067
|
-
const wallets = [];
|
|
17068
|
-
for (let i = 0; i < meta.count; i++) {
|
|
17069
|
-
const kp = await this.deriveKeypair(appId, i);
|
|
17070
|
-
wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
|
|
17071
|
-
}
|
|
17072
|
-
const active = wallets[Math.min(meta.activeIndex, wallets.length - 1)] || wallets[0];
|
|
17073
|
-
if (!active)
|
|
17074
|
-
return;
|
|
17075
|
-
if (!this.widgetEl) {
|
|
17076
|
-
this.widgetEl = document.createElement('div');
|
|
17077
|
-
this.widgetEl.id = 'poofnet-wallet-widget';
|
|
17078
|
-
document.body.appendChild(this.widgetEl);
|
|
17079
|
-
}
|
|
17080
|
-
const short = (a) => `${a.slice(0, 4)}…${a.slice(-4)}`;
|
|
17081
|
-
const rows = wallets.map((w) => `
|
|
17082
|
-
<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;">
|
|
17083
|
-
<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>
|
|
17084
|
-
${w.index === active.index ? '<span style="color:#9945FF;">●</span>' : ''}
|
|
17085
|
-
</button>`).join('');
|
|
17086
|
-
this.widgetEl.innerHTML = `
|
|
17087
|
-
<div style="position:fixed;bottom:16px;right:16px;z-index:2147483600;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
|
|
17088
|
-
${this.widgetExpanded ? `
|
|
17089
|
-
<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);">
|
|
17090
|
-
<div style="padding:6px 10px 8px;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;color:#9945FF;font-weight:700;">Poofnet · Simulated</div>
|
|
17091
|
-
<div style="max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:2px;">${rows}</div>
|
|
17092
|
-
<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>
|
|
17093
|
-
</div>` : ''}
|
|
17094
|
-
<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);">
|
|
17095
|
-
<span style="width:8px;height:8px;border-radius:50%;background:#9945FF;box-shadow:0 0 8px #9945FF;"></span>
|
|
17096
|
-
<span style="font-weight:600;">${active.label}</span>
|
|
17097
|
-
<span style="opacity:0.55;font-family:monospace;font-size:12px;">${short(active.address)}</span>
|
|
17098
|
-
<span style="opacity:0.5;transform:rotate(${this.widgetExpanded ? '180deg' : '0deg'});">▾</span>
|
|
17099
|
-
</button>
|
|
17100
|
-
</div>`;
|
|
17101
|
-
// Wire handlers (re-bound each render).
|
|
17102
|
-
const toggle = this.widgetEl.querySelector('[data-poofnet-toggle]');
|
|
17103
|
-
if (toggle)
|
|
17104
|
-
toggle.onclick = () => { this.widgetExpanded = !this.widgetExpanded; this.showWalletWidget(appId).catch(() => { }); };
|
|
17105
|
-
this.widgetEl.querySelectorAll('[data-poofnet-switch]').forEach((btn) => {
|
|
17106
|
-
btn.onclick = async () => {
|
|
17107
|
-
const idx = parseInt(btn.getAttribute('data-poofnet-switch'), 10);
|
|
17108
|
-
this.widgetExpanded = false;
|
|
17109
|
-
if (idx !== active.index)
|
|
17110
|
-
await this.switchWallet(idx);
|
|
17111
|
-
else
|
|
17112
|
-
this.showWalletWidget(appId).catch(() => { });
|
|
17113
|
-
};
|
|
17114
|
-
});
|
|
17115
|
-
const gen = this.widgetEl.querySelector('[data-poofnet-generate]');
|
|
17116
|
-
if (gen)
|
|
17117
|
-
gen.onclick = async () => { this.widgetExpanded = false; await this.generateWallet(); };
|
|
17118
|
-
}
|
|
17119
|
-
removeWalletWidget() {
|
|
17120
|
-
try {
|
|
17121
|
-
if (this.widgetEl && this.widgetEl.parentNode)
|
|
17122
|
-
this.widgetEl.parentNode.removeChild(this.widgetEl);
|
|
17123
|
-
}
|
|
17124
|
-
catch ( /* noop */_a) { /* noop */ }
|
|
17125
|
-
this.widgetEl = null;
|
|
17126
|
-
this.widgetExpanded = false;
|
|
17127
|
-
}
|
|
17128
17079
|
}
|
|
17129
17080
|
|
|
17130
17081
|
/**
|
|
@@ -18226,17 +18177,17 @@ function setAuthProviderInstance(provider) {
|
|
|
18226
18177
|
authProviderInstance = provider;
|
|
18227
18178
|
}
|
|
18228
18179
|
|
|
18229
|
-
var _a;
|
|
18180
|
+
var _a$1;
|
|
18230
18181
|
// Whether we're in a server-side rendering context (no hooks allowed).
|
|
18231
18182
|
// React Native has no `window` but DOES support hooks.
|
|
18232
18183
|
// We detect Node SSR specifically via process.versions.node to avoid
|
|
18233
18184
|
// false positives from Node 21+ which defines `navigator` globally.
|
|
18234
|
-
const isSSR = typeof window === 'undefined'
|
|
18185
|
+
const isSSR$1 = typeof window === 'undefined'
|
|
18235
18186
|
&& typeof process !== 'undefined'
|
|
18236
|
-
&& !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
18187
|
+
&& !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
|
|
18237
18188
|
function useAuth() {
|
|
18238
18189
|
// Provide a fallback so server render doesn't break
|
|
18239
|
-
if (isSSR) {
|
|
18190
|
+
if (isSSR$1) {
|
|
18240
18191
|
return {
|
|
18241
18192
|
login: async () => undefined,
|
|
18242
18193
|
logout: async () => undefined,
|
|
@@ -18296,6 +18247,79 @@ function useAuth() {
|
|
|
18296
18247
|
};
|
|
18297
18248
|
}
|
|
18298
18249
|
|
|
18250
|
+
var _a;
|
|
18251
|
+
const isSSR = typeof window === 'undefined'
|
|
18252
|
+
&& typeof process !== 'undefined'
|
|
18253
|
+
&& !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
18254
|
+
const EMPTY = {
|
|
18255
|
+
isMock: false,
|
|
18256
|
+
wallets: [],
|
|
18257
|
+
activeIndex: 0,
|
|
18258
|
+
switchWallet: async () => undefined,
|
|
18259
|
+
generateWallet: async () => undefined,
|
|
18260
|
+
refresh: async () => undefined,
|
|
18261
|
+
};
|
|
18262
|
+
/**
|
|
18263
|
+
* Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
|
|
18264
|
+
* template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
|
|
18265
|
+
* so callers can conditionally render the switch/generate controls.
|
|
18266
|
+
*
|
|
18267
|
+
* Reactive: re-reads whenever auth state changes (login / logout / wallet
|
|
18268
|
+
* switch all flow through setCurrentUser → onAuthStateChanged).
|
|
18269
|
+
*/
|
|
18270
|
+
function usePoofnetWallet() {
|
|
18271
|
+
if (isSSR)
|
|
18272
|
+
return EMPTY;
|
|
18273
|
+
const [state, setState] = React$2.useState({
|
|
18274
|
+
isMock: false,
|
|
18275
|
+
wallets: [],
|
|
18276
|
+
activeIndex: 0,
|
|
18277
|
+
});
|
|
18278
|
+
const refresh = React$2.useCallback(async () => {
|
|
18279
|
+
const provider = getActiveMockPoofnetProvider();
|
|
18280
|
+
if (!provider) {
|
|
18281
|
+
setState({ isMock: false, wallets: [], activeIndex: 0 });
|
|
18282
|
+
return;
|
|
18283
|
+
}
|
|
18284
|
+
try {
|
|
18285
|
+
const { wallets, activeIndex } = await provider.getWalletState();
|
|
18286
|
+
setState({ isMock: true, wallets, activeIndex });
|
|
18287
|
+
}
|
|
18288
|
+
catch (_a) {
|
|
18289
|
+
setState({ isMock: false, wallets: [], activeIndex: 0 });
|
|
18290
|
+
}
|
|
18291
|
+
}, []);
|
|
18292
|
+
React$2.useEffect(() => {
|
|
18293
|
+
refresh();
|
|
18294
|
+
// setCurrentUser (login/logout/switch/generate) notifies these listeners.
|
|
18295
|
+
onAuthStateChanged(() => { refresh(); });
|
|
18296
|
+
// Note: onAuthStateChanged has no unsubscribe yet (same as useAuth) — fine
|
|
18297
|
+
// for a wallet button that mounts once.
|
|
18298
|
+
}, [refresh]);
|
|
18299
|
+
const switchWallet = React$2.useCallback(async (index) => {
|
|
18300
|
+
const provider = getActiveMockPoofnetProvider();
|
|
18301
|
+
if (provider) {
|
|
18302
|
+
await provider.switchWallet(index);
|
|
18303
|
+
await refresh();
|
|
18304
|
+
}
|
|
18305
|
+
}, [refresh]);
|
|
18306
|
+
const generateWallet = React$2.useCallback(async () => {
|
|
18307
|
+
const provider = getActiveMockPoofnetProvider();
|
|
18308
|
+
if (provider) {
|
|
18309
|
+
await provider.generateWallet();
|
|
18310
|
+
await refresh();
|
|
18311
|
+
}
|
|
18312
|
+
}, [refresh]);
|
|
18313
|
+
return {
|
|
18314
|
+
isMock: state.isMock,
|
|
18315
|
+
wallets: state.wallets,
|
|
18316
|
+
activeIndex: state.activeIndex,
|
|
18317
|
+
switchWallet,
|
|
18318
|
+
generateWallet,
|
|
18319
|
+
refresh,
|
|
18320
|
+
};
|
|
18321
|
+
}
|
|
18322
|
+
|
|
18299
18323
|
async function deserializeTransaction(tx) {
|
|
18300
18324
|
const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
|
|
18301
18325
|
if ((buf[0] & 0x80) !== 0) {
|
|
@@ -18427,7 +18451,7 @@ async function loadDependencies() {
|
|
|
18427
18451
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
18428
18452
|
import('react'),
|
|
18429
18453
|
import('react-dom/client'),
|
|
18430
|
-
import('./index-
|
|
18454
|
+
import('./index-TCh-Tz3A.esm.js')
|
|
18431
18455
|
]);
|
|
18432
18456
|
// Extract default export from ESM module namespace
|
|
18433
18457
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -18878,6 +18902,19 @@ class PhantomWalletProvider {
|
|
|
18878
18902
|
that.awaitTopLevelConnect();
|
|
18879
18903
|
return;
|
|
18880
18904
|
}
|
|
18905
|
+
// C2: pre-warm Chrome's Local Network Access permission inside the
|
|
18906
|
+
// tap gesture, so its prompt appears up-front instead of on return
|
|
18907
|
+
// from the wallet (MWA opens a ws://localhost reflector only after
|
|
18908
|
+
// the app-switch, which is why the prompt currently lands on return).
|
|
18909
|
+
// Best-effort, Android top-level only. DEVICE-TEST: confirm Chrome
|
|
18910
|
+
// grants this per-origin (so MWA's later random-port socket reuses
|
|
18911
|
+
// it). If LNA turns out to be per-port, this won't pre-grant — cut it.
|
|
18912
|
+
if (detectAndroid() && typeof WebSocket !== 'undefined') {
|
|
18913
|
+
try {
|
|
18914
|
+
new WebSocket('ws://localhost:1');
|
|
18915
|
+
}
|
|
18916
|
+
catch ( /* noop */_a) { /* noop */ }
|
|
18917
|
+
}
|
|
18881
18918
|
if (that.onSwitchToMWA) {
|
|
18882
18919
|
try {
|
|
18883
18920
|
const mwaProvider = await that.onSwitchToMWA();
|
|
@@ -24615,7 +24652,7 @@ async function registerMobileWalletAdapter(config) {
|
|
|
24615
24652
|
if (typeof window === 'undefined')
|
|
24616
24653
|
return;
|
|
24617
24654
|
try {
|
|
24618
|
-
const walletStandardMobile = await import('./index.browser-
|
|
24655
|
+
const walletStandardMobile = await import('./index.browser-CQxdFuE2.esm.js');
|
|
24619
24656
|
const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
|
|
24620
24657
|
if (!registerMwa) {
|
|
24621
24658
|
console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
|
|
@@ -24754,7 +24791,7 @@ class SolanaMobileWalletProvider {
|
|
|
24754
24791
|
async ensureWallet() {
|
|
24755
24792
|
if (this.wallet)
|
|
24756
24793
|
return this.wallet;
|
|
24757
|
-
const mod = await import('./index.browser-
|
|
24794
|
+
const mod = await import('./index.browser-CQxdFuE2.esm.js');
|
|
24758
24795
|
const chain = mapChainToWalletStandard(this.cluster);
|
|
24759
24796
|
this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
|
|
24760
24797
|
appIdentity: this.appIdentity,
|
|
@@ -24963,8 +25000,6 @@ class SolanaMobileWalletProvider {
|
|
|
24963
25000
|
return user;
|
|
24964
25001
|
}
|
|
24965
25002
|
}
|
|
24966
|
-
// Pre-fetch nonce while the wallet popup is not yet open.
|
|
24967
|
-
const nonce = await genAuthNonce();
|
|
24968
25003
|
// Wallet popup #1: standard:connect performs MWA authorize. This
|
|
24969
25004
|
// is where wallet-standard's checkLocalNetworkAccessPermission()
|
|
24970
25005
|
// fires the three-stage LNA UX (info modal → permission prompt →
|
|
@@ -25007,6 +25042,11 @@ class SolanaMobileWalletProvider {
|
|
|
25007
25042
|
// Insert a Tarobase modal: the user's tap on "Sign in" provides a
|
|
25008
25043
|
// fresh activation, and signMessage is invoked synchronously
|
|
25009
25044
|
// inside the click handler so the activation propagates.
|
|
25045
|
+
// C1: fetch the nonce HERE (after connect), not before — a pre-connect
|
|
25046
|
+
// network round-trip was decaying the Chrome user activation needed for
|
|
25047
|
+
// the connect's solana-wallet: navigation, intermittently causing
|
|
25048
|
+
// ERROR_WALLET_NOT_FOUND. The nonce is only needed for the message below.
|
|
25049
|
+
const nonce = await genAuthNonce();
|
|
25010
25050
|
const messageText = await genSolanaMessage(base58Addr, nonce);
|
|
25011
25051
|
const messageBytes = getPlatform().textEncode(messageText);
|
|
25012
25052
|
const signMessageFeat = getSignMessageFeature(wallet);
|
|
@@ -25943,5 +25983,5 @@ class PrivyExpoProvider {
|
|
|
25943
25983
|
}
|
|
25944
25984
|
}
|
|
25945
25985
|
|
|
25946
|
-
export {
|
|
25947
|
-
//# sourceMappingURL=index-
|
|
25986
|
+
export { genSolanaMessage as $, subscribe as A, useAuth as B, usePoofnetWallet as C, deserializeTransaction as D, getIdToken as E, setPlatform as F, getPlatform as G, PrivyWalletProvider as H, DEFAULT_TEST_ADDRESS as I, isMobileWalletAvailable as J, registerMobileWalletAdapter as K, PrivyExpoProvider as L, MockAuthProvider as M, InsufficientBalanceError as N, OffchainAuthProvider as O, PhantomWalletProvider as P, ServerSessionManager as Q, ReactNativeSessionManager as R, SolanaMobileWalletProvider as S, buildSetDocumentsTransaction as T, clearCache as U, closeAllSubscriptions as V, WebSessionManager as W, convertRemainingAccounts as X, createSessionWithPrivy as Y, createSessionWithSignature as Z, genAuthNonce as _, base58 as a, getCachedData as a0, getMany as a1, reconnectWithNewAuth as a2, refreshSession as a3, signSessionCreateMessage as a4, bufferExports as b, getCurrentUser as c, onAuthLoadingChanged as d, getAuthLoading as e, logout as f, getDefaultExportFromCjs$1 as g, getConfig as h, init as i, getAuthProvider as j, get as k, login as l, setMany as m, setFile as n, onAuthStateChanged as o, getFiles as p, runQueryMany as q, runQuery as r, set as s, runExpression as t, runExpressionMany as u, signMessage as v, signTransaction as w, signAndSubmitTransaction as x, count as y, aggregate as z };
|
|
25987
|
+
//# sourceMappingURL=index-2wcE74zV.esm.js.map
|