Skip to content

TrpcAuth

A is the session attribute type of your createAuth call, inferred from it, so ctx.session goes back into the flows without a cast.

U extends AuthUser = AuthUser

A = unknown

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 throttle: object

hit(scope, rule): Promise<Hit>

string

RateLimitRule

Promise<Hit>

readonly users: object

findById(id): Promise<U | null>

string

Promise<U | null>

emit(event, meta): Promise<void>

AuthEvent

RequestMeta | undefined

Promise<void>

keyedHash(purpose, message): string

An HMAC of message under a key derived from the server secret for purpose. Names the user in a keyBy: 'user' rate limit key.

string

string

string


readonly cookieName: string

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

RequestMeta

string | null | undefined

Promise<{ cookie: CookieSpec; }>


readDeviceToken(cookieHeader): string | null

string | null | undefined

string | null


readSessionToken(cookieHeader): string | null

string | null | undefined

string | null


requireFreshAuth(session): AuthResult<void>

StoredSession<A>

AuthResult<void>


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

RequestMeta

string | null | undefined

boolean

Promise<AuthResult<ValidatedSession<A>>>