Skip to content

nooschain v0.1.0


nooschain / auth/session-tokens / InMemoryAuthSessionStore

Class: InMemoryAuthSessionStore

Defined in: auth/session-tokens.ts:109

In-memory implementation of AuthSessionStore.

It is suitable for local development, integration tests, and single-process API runs. Because challenges and sessions are process-local, restarting the node invalidates outstanding login challenges and bearer tokens.

Implements

Constructors

Constructor

new InMemoryAuthSessionStore(clock?, challengeTtlMs?, sessionTtlMs?): InMemoryAuthSessionStore

Defined in: auth/session-tokens.ts:113

Parameters

clock?

Clock = ...

challengeTtlMs?

number = AUTH_CHALLENGE_TTL_MS

sessionTtlMs?

number = AUTH_SESSION_TTL_MS

Returns

InMemoryAuthSessionStore

Methods

createAuthChallenge()

createAuthChallenge(publicKey): AuthChallenge

Defined in: auth/session-tokens.ts:122

Creates a random one-time challenge for the supplied public key.

Parameters

publicKey

string

Returns

AuthChallenge

Implementation of

AuthSessionStore.createAuthChallenge


loginWithChallenge()

loginWithChallenge(args): AuthSession

Defined in: auth/session-tokens.ts:149

Verifies the one-time challenge signature and mints a bearer session.

The challenge is consumed after successful verification. Expired challenges are removed before returning an expiry error, which keeps the in-memory challenge map from retaining unusable entries.

Parameters

args
challengeId

string

challengeSignature

string

publicKey

string

Returns

AuthSession

Implementation of

AuthSessionStore.loginWithChallenge


requireSessionPublicKey()

requireSessionPublicKey(authorizationHeader): string

Defined in: auth/session-tokens.ts:213

Parses and validates a bearer token, returning the bound public key.

Missing, malformed, unknown, and expired tokens are all rejected with distinct AuthError codes. Expired sessions are deleted immediately.

Parameters

authorizationHeader

string | undefined

Returns

string

Implementation of

AuthSessionStore.requireSessionPublicKey


resolveSessionPublicKey()

resolveSessionPublicKey(authorizationHeader): string | undefined

Defined in: auth/session-tokens.ts:199

Best-effort session lookup used by callers that allow anonymous fallback.

Parameters

authorizationHeader

string | undefined

Returns

string | undefined

Implementation of

AuthSessionStore.resolveSessionPublicKey

Audience-first NOOSChain documentation.