Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface UserSessionStorage<Device, Location, MetaData>

Storage where user sessions are stored.

Type parameters

  • Device: DeviceBase

    Type of the device.

  • Location

    Type of the location.

  • MetaData: UserSessionMetaData<Device, Location>

    Type of the session metadata.

Hierarchy

  • UserSessionStorage

Methods

delete

  • delete(subject: string, sessionId: string): Promise<void>
  • Deletes user session.

    Parameters

    • subject: string

      Subject.

    • sessionId: string

      Id of the session.
      Storage should treat sessionId as untrusted and perform SQLi and XSS validations before deleting meta data.

    Returns Promise<void>

deleteAll

  • deleteAll(subject: string): Promise<number>
  • Deletes all sessions of the subject.

    Parameters

    • subject: string

      Subject.

    Returns Promise<number>

    Number of deleted sessions.

insert

  • insert(subject: string, sessionId: string, metaData: MetaData, ttl: number): Promise<void>
  • Insert user session in the storage.

    IMPORTANT!
    It's highly advisable to hash sessionId before storing it in the database, especially if RDBMS is used.

    throws

    {Error} When session can't be inserted.

    Parameters

    • subject: string

      Subject.

    • sessionId: string

      Session id.

    • metaData: MetaData

      Session meta data.

    • ttl: number

      Session ttl (in seconds).

    Returns Promise<void>

read

  • read(subject: string, sessionId: string): Promise<undefined | null | MetaData>
  • Read session meta data from storage.

    Parameters

    • subject: string

      Subject.

    • sessionId: string

      Id of the session.
      Storage should treat sessionId as untrusted and perform SQLi and XSS validations before query meta data.

    Returns Promise<undefined | null | MetaData>

    User session meta data or null / undefined if not found.

readAll

  • readAll(subject: string): Promise<ReadonlyMap<string, Readonly<MetaData>>>
  • Read all of the active user sessions for subject.

    Parameters

    • subject: string

      Subject user sessions are belonging to.

    Returns Promise<ReadonlyMap<string, Readonly<MetaData>>>

    Session id with the session metadata.
    When subject has no active sessions, returns an empty map.