Skip to content

Issue 15: Session Lifespan Watches Synced Directly to Hardware Key Constraints #22

Description

@elizabetheonoja-art

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

  1. Implement monitorWalletLock(address, onLocked) that polls wallet existence every 2 seconds and calls onLocked() immediately if gone.
  2. Implement createSession(address, network, ttlMs) storing { address, network, token, issuedAt, expiresAt }.
  3. Implement getSession() that checks expiry.
  4. Implement validateSession(address) checking address match and expiry.
  5. Implement destroySession() wiping storage.
  6. Implement refreshSession() extending by 30 min if within 5 min of expiry.
  7. 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions