Replace stub wallet keypair with real Phantom sign-in
Auth now goes through an actual connected Solana wallet instead of a locally-generated ed25519 keypair. Phantom's window.solana provider is only reachable from a page's own JS world, not an isolated-world content script, so this adds a second world:'MAIN' content script (wallet-bridge.content.ts + wallet-bridge/inject.ts) that talks to window.solana directly and relays to the isolated world via window CustomEvents (wallet-bridge/relay.ts), matched by request id. wallet-connect.ts orchestrates: try a silent onlyIfTrusted connect on load; if that fails, show an on-page banner (wallet-bridge/banner.ts) whose click handler is what actually calls connect() -- Phantom requires a real user gesture for the approval popup on a first-ever connect, which a click relayed from the extension popup wouldn't count as by the time it reaches the wallet. background/wallet-auth.ts runs the REST auth flow (nonce -> ask the tab's content script to sign it -> verify -> store session token) once a wallet reports connected. ws-client.ts no longer force-retries with a known-bad token on auth failure; it calls onAuthExpired instead (which clears the token and prompts a silent wallet reconnect) and exposes reconnectNow() so background.ts can short-circuit the backoff wait once a fresh token exists. identity.ts and its tweetnacl dependency are gone -- no more stub signer. Untested against real Phantom (no browser automation available this session) -- flagged in CLAUDE.md as needing manual verification, along with a note that world:'MAIN' needs Firefox 128+. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YXiHuScXrjxBh7yFGAPq3B
This commit is contained in:
@@ -17,4 +17,12 @@ export type NexaMessage =
|
||||
| { type: 'nexa:lock-state-changed'; state: LockState }
|
||||
| { type: 'nexa:get-connection-status' }
|
||||
| { type: 'nexa:connection-status-changed'; status: ConnectionStatus }
|
||||
| { type: 'nexa:open-popup' };
|
||||
| { type: 'nexa:open-popup' }
|
||||
// Wallet auth (content script <-> background). See
|
||||
// content-scripts/wallet-connect.ts and background/wallet-auth.ts.
|
||||
| { type: 'nexa:wallet-connected'; walletAddress: string }
|
||||
| { type: 'nexa:wallet-sign-request'; nonce: string }
|
||||
| { type: 'nexa:request-wallet-connect' };
|
||||
|
||||
/** Response shape for 'nexa:wallet-sign-request', returned via sendResponse (not a dispatched NexaMessage). */
|
||||
export type WalletSignResult = { signature: string } | { error: string };
|
||||
|
||||
Reference in New Issue
Block a user