What is a session?
A session is a cryptographically secured context between a host and a client. It contains the shared encryption keys, granted capabilities, and connection state.Session creation
Sessions are created during pairing:Session structure
Session persistence
Sessions are persisted:- Host: In the keychain/encrypted file (paired device records)
- Client: In IndexedDB (encrypted at rest)
- Application restarts
- Network interruptions
- Browser tab closes (client reconnects)
- Explicit revocation (
server.revoke(deviceId)) - Client forgetting (
client.forget(appId)) - Identity key rotation
Session security
Forward secrecy
Every session uses fresh ephemeral keys. Compromising the long-term identity does not expose past sessions.Key isolation
Each session has independent keys:- Different ECDH shared secret
- Different HKDF derivation
- Different frame encryption keys
Capability binding
Capabilities are bound to the session at creation time:- Granted during pairing
- Persisted for the session lifetime
- Cannot be modified after creation (without re-pairing)
Session timeout
Sessions have no built-in timeout. The host can implement idle detection:Multiple sessions
A host can maintain multiple sessions:- Separate encryption keys
- Separate capability grants
- Separate connection state
Session cleanup
When a session ends:- Close the transport connection
- Remove the session from the active list
- Keep the paired device record (for reconnection)
- Emit a
sessionEndedevent