import type { ConnectionStatus, LockState, ThresholdSettings } from './types'; /** browser.storage.local key backing the lock state seam in the background script. */ export const LOCK_STATE_STORAGE_KEY = 'osias:lockState'; /** * Typed message contracts between background <-> content scripts <-> popup. * All lock-state reads go through these so no module reaches into storage * directly (see src/background/lock-state.ts). There is deliberately no * client-writable "set lock state" message: the backend is the sole source * of truth for lock state (see the WebSocket protocol's "Ownership" section * in ../../CLAUDE.md) — only the WS client (ws-client.ts) may apply a new * lock state, and only because the server told it to. */ export type OsiasMessage = | { type: 'osias:get-lock-state' } | { type: 'osias:lock-state-changed'; state: LockState } | { type: 'osias:get-connection-status' } | { type: 'osias:connection-status-changed'; status: ConnectionStatus } | { type: 'osias:open-popup' } // Wallet auth (content script <-> background). See // content-scripts/wallet-connect.ts and background/wallet-auth.ts. | { type: 'osias:wallet-connected'; walletAddress: string } | { type: 'osias:wallet-disconnected' } | { type: 'osias:wallet-sign-request'; nonce: string } | { type: 'osias:request-wallet-connect' } | { type: 'osias:wallet-disconnect-request' } | { type: 'osias:switch-account-request' } // Sign-out / switch account (popup -> background). See entrypoints/popup/App.tsx. | { type: 'osias:sign-out' } | { type: 'osias:switch-account' } // Loss-threshold settings (popup -> background -> GET/PATCH /me/settings). // See background/settings-client.ts and entrypoints/popup/App.tsx. | { type: 'osias:get-settings' } | { type: 'osias:update-settings'; settings: Partial }; /** Response shape for 'osias:get-settings'/'osias:update-settings', returned via sendResponse. */ export type SettingsResult = { settings: ThresholdSettings } | { error: string }; /** Response shape for 'osias:wallet-sign-request', returned via sendResponse (not a dispatched OsiasMessage). */ export type WalletSignResult = { signature: string } | { error: string };