Skip to main content

Module session

Module session 

Source
Expand description

Stateless, signed web-session tokens and their logout denylist.

A session token binds a SessionSubject — a persona-credential login (a persona_id) or a wallet-passkey login (a wallet_address, and optionally the persona it currently resolves to) — plus the SessionScopes it carries, to an issue/expiry window, and is signed by a dedicated SessionSigner. Verification needs only the role’s public key, so a session survives a cold restart of whatever process minted it: nothing here reads or writes a server-side session store. mint_session and verify_session are the mint/verify pair; RevokedTokens is the best-effort, in-memory logout denylist verify_session consults.

This module owns only the token’s cryptographic shape and the denylist — it mints no challenges, runs no login ceremony, and knows nothing about cookies or HTTP. A caller that needs those (e.g. a passkey-authenticated login flow) builds them on top, choosing its own token TTL and calling mint_session/verify_session directly.

C1.4 adds the replacement protocol through mint_authorized_session and verify_authorized_session. Its signed claims bind a stable bearer id and authorization epoch to the same subject/scopes/time window. Verification remains deliberately pure: a caller must check the resulting id and epoch against current State before authorizing a request. The v2 path remains live only until the coordinated caller cutover removes it.

See ADR 0007 (docs/decisions/0007-web-sessions-rooted-in-either-passkey.md) for why a session may be rooted in either credential, and why explorer-read/wallet-manage/agent-turn are independent claims rather than one all-or-nothing grant: revoking a persona-credential must never revoke a wallet’s own sessions, and vice versa.

Structs§

AuthorizedSessionClaims
Claims signed into a bearer whose current authorization lives in State.
RevokedTokens
Best-effort, in-memory logout denylist for session tokens.
SessionClaims
A verified session’s claims: who it’s bound to, what it authorizes, and its issue/expiry window.

Enums§

SessionScope
A capability a session token carries.
SessionSubject
Which credential rooted a session.

Functions§

mint_authorized_session
Mints a signed bearer bound to the durable record State already accepted.
mint_session
Mint a stateless, signed session token bound to subject, carrying scopes.
verify_authorized_session
Verifies only the signed and time-bounded half of a State-backed bearer.
verify_authorized_session_with_trust
Verifies a State-backed bearer against current and retired session keys.
verify_session
Verify a session token minted by mint_session, returning its SessionClaims on success.
verify_session_with_trust
Verifies a session against the role’s current and retired trust set.