Skip to Content

SiwxSessionStore

Defined in: siwx-server/src/types.ts:89 

Storage contract for durable sessions (Redis, SQL, KV…), used by createSiwxApiHandler and getSiwxServerSession. Implementations must be shared by every server instance. MemorySiwxSessionStore is an in-memory implementation for development and tests.

Methods

bindSubject()

bindSubject(id, subjectId): Promise<boolean>

Defined in: siwx-server/src/types.ts:113 

Binds one of your user IDs to the session. Not called by SIWX; use it after sign-in to link the wallet session to your own user record.

Parameters

id

string

The session ID.

subjectId

string

The user or subject ID.

Returns

Promise<boolean>

true if the session exists and was updated, false otherwise.


create()

create(input): Promise<SiwxSessionRecord>

Defined in: siwx-server/src/types.ts:97 

Creates and stores a new session record.

Parameters

input

The session to store.

session

SiwxSession

The verified session data.

ttlSeconds

number

Time-to-live in seconds.

Returns

Promise<SiwxSessionRecord>

The created record. Its id must be unguessable, because it becomes the session cookie value.


get()

get(id): Promise<SiwxSessionRecord | null>

Defined in: siwx-server/src/types.ts:104 

Retrieves a session record by its ID. Session expiry is enforced here: SIWX does not compare expiresAt itself.

Parameters

id

string

The session ID.

Returns

Promise<SiwxSessionRecord | null>

The session record, or null if it does not exist or has expired.


revoke()

revoke(id): Promise<void>

Defined in: siwx-server/src/types.ts:120 

Revokes a session. Must succeed when the session does not exist.

Parameters

id

string

The session ID.

Returns

Promise<void>

A promise that resolves once the session is removed.

Last updated on