@prismshadow/penguin-library-auth · library/auth/src/auth.ts:24

AuthSessions

interface

AuthSessions: the mechanism AuthSessionsRepo implements.

API

@Interface()
export abstract class AuthSessions {
  abstract issue(opts: {
      userId: string;
      via: SessionViaValue;
      now: Date;
      ttlMs: number;
      maxTtlMs?: number;
    }): { token: string; expiresAt: string };
  abstract insert(row: AuthSessionRow): void;
  abstract findByTokenHash(tokenHash: string): AuthSessionRow | null;
  abstract touch(tokenHash: string, expiresAt: string): void;
  abstract delete(tokenHash: string): void;
  abstract deleteExpired(nowIso: string): void;
  abstract deleteByUser(userId: string): void;
  abstract deleteByUserAndVia(userId: string, via: SessionViaValue): void;
}

Contract Topology

Static AST wiring across @Module / @Provide / @Use
@Moduleexported by
@Provideprovided by
@Useconsumed by (2)

Members (8)

issue

issue(opts: { userId: string; via: SessionViaValue; now: Date; ttlMs: number; maxTtlMs?: number; }): { token: string; expiresAt: string }
@paramopts{ userId: string; via: SessionViaValue; now: Date; ttlMs: number; maxTtlMs?: number; }
@returns{ token: string; expiresAt: string }

insert

insert(row: AuthSessionRow): void
@paramrowAuthSessionRow
@returnsvoid

findByTokenHash

findByTokenHash(tokenHash: string): AuthSessionRow | null
@paramtokenHashstring
@returnsAuthSessionRow | null

touch

touch(tokenHash: string, expiresAt: string): void
@paramtokenHashstring
@paramexpiresAtstring
@returnsvoid

delete

delete(tokenHash: string): void
@paramtokenHashstring
@returnsvoid

deleteExpired

deleteExpired(nowIso: string): void
@paramnowIsostring
@returnsvoid

deleteByUser

deleteByUser(userId: string): void
@paramuserIdstring
@returnsvoid

deleteByUserAndVia

deleteByUserAndVia(userId: string, via: SessionViaValue): void
@paramuserIdstring
@paramviaSessionViaValue
@returnsvoid