import { browser } from 'wxt/browser'; const SESSION_TOKEN_STORAGE_KEY = 'nexa:sessionToken'; /** * Session token storage. The token itself is obtained by wallet-auth.ts * (nonce -> Phantom signature -> verify) once a wallet connects — this * module just persists/retrieves it, since ws-client.ts and popup code * shouldn't know how a token was obtained. */ export async function getSessionToken(): Promise { const stored = await browser.storage.local.get(SESSION_TOKEN_STORAGE_KEY); const token = stored[SESSION_TOKEN_STORAGE_KEY] as string | undefined; if (!token) throw new Error('Not authenticated yet — connect a wallet on a supported trading site.'); return token; } export async function storeSessionToken(token: string): Promise { await browser.storage.local.set({ [SESSION_TOKEN_STORAGE_KEY]: token }); } export async function clearSessionToken(): Promise { await browser.storage.local.remove(SESSION_TOKEN_STORAGE_KEY); }