Scope
File: src/services/session.ts
Problem
When a user locks or disconnects their browser-based wallet, the backend API session remains active. A malicious actor with access to the unattended machine can continue to perform authenticated actions until the session timer expires.
Requirements
- Implement monitorWalletLock(address, onLocked) that polls wallet existence every 2 seconds and calls onLocked() immediately if gone.
- Implement createSession(address, network, ttlMs) storing { address, network, token, issuedAt, expiresAt }.
- Implement getSession() that checks expiry.
- Implement validateSession(address) checking address match and expiry.
- Implement destroySession() wiping storage.
- Implement refreshSession() extending by 30 min if within 5 min of expiry.
- Implement onSessionChange(fn) for React hook subscriptions.
Resolution Strategy
- Token format: st-{addressPrefix}-{timestamp-base36}.
- Auto-refresh timer every 60s.
- monitorWalletLock returns cleanup function for useEffect.
Tags
services, session, security, wallet
Scope
File:
src/services/session.tsProblem
When a user locks or disconnects their browser-based wallet, the backend API session remains active. A malicious actor with access to the unattended machine can continue to perform authenticated actions until the session timer expires.
Requirements
Resolution Strategy
Tags
services, session, security, wallet