Skip to content

NestAuth

The part of a createAuth result the module uses. Any createAuth(...) result fits, whatever its user type, session attributes or plugins.

U extends AuthUser = AuthUser

readonly context: object

readonly clock: Clock

readonly optional cookie?: SessionCookieConfig

The session cookie config. The CSRF, pre-session and blank session cookies take their SameSite from it, per request Origin, exactly as the session cookie does. Missing (a hand-made stand-in): Lax.

readonly logger: object

error(message, context?): void

string

Record<string, unknown>

void

readonly users: object

findById(id): Promise<U | null>

string

Promise<U | null>


readonly cookieName: string

optional flush(options?): Promise<void>

Waits for background work (mail sends); the module calls it on shutdown, bounded.

Duration

Promise<void>


logout(input): Promise<{ cookie: CookieSpec; }>

RequestMeta

string | null | undefined

Promise<{ cookie: CookieSpec; }>


readSessionToken(cookieHeader): string | null

string | null | undefined

string | null


requireFreshAuth(session): AuthResult<void>

StoredSession<unknown>

AuthResult<void>


validateRequest(input): Promise<AuthResult<ValidatedSession<unknown>>>

RequestMeta

string | null | undefined

boolean

Promise<AuthResult<ValidatedSession<unknown>>>