Skip to content
LogoLogo

MemorySessionStore

The default cache for policy-server sessions, held in process.

Usage

const  = await .(, {
  : { : 'https://node.example.org' },
  : new () 
})

Sessions are keyed by { nodeUri, did, serviceId, consumerAddress }, so re-accessing the same gated service does not repeat the exchange — while switching accounts, or reaching a service hosted on another node, does. A session id means nothing to a policy server that did not open it. consumerAddress is the address the node forwards to the policy server (OceanNodeClient.policySessionAddress): signer.getAddress() unchanged for a Signer, the token's address for a JWT. It is not case-folded: the policy server hashes the forwarded string into the session id, so a session opened for the checksummed address would be refused for the lower-cased one.

Only sessions the policy server opened, and the verifier accepted where a presentation was asked for, are stored. A refusal is never cached: the next call asks again.

Each entry is a SessionEntry:

FieldTypeMeaning
sessionIdstringThe session the policy server opened.
createdAtnumberWhen it was opened, in ms since the epoch (Date.now() before initiate).
presentedbooleanWhether the verifier accepted a presentation for it (an SSIpolicy session).

The store only keeps entries. PolicySessionResolver never reuses one older than sessionTtlMs (2 minutes by default), or with no valid createdAt, and checks a presented one with the policy server (checkSessionId) before reusing it; a stale entry is deleted and the session opened again.

See credential-gated assets.