← @mortar-kit/auth

AuthMethodContextinterface

import { AuthMethodContext } from '@mortar-kit/auth'

interface AuthMethodContext

What a sign-in method gets from createAuth for each request.

Properties

readonly returnTo: string

Where to go after signing in: the request's returnTo parameter (a path on this site), or the admin.

readonly sealer: Sealer

The sealer over the app's secret: sign state, hash tokens.

url: (path?: "callback") => string

Absolute URL of this method's routes: url() is its start, url('callback') its callback.

signInUrl: (params?: Record<string, string | undefined>) => string

Absolute URL of the sign-in page with these search parameters (undefined ones left out).

allows: (identity: Identity) => Promise<boolean>

Whether identity may sign in (runs authorize), e.g. before sending an email.

fail: (error: AuthError, params?: Record<string, string | undefined>) => Response

Back to the sign-in page, showing error, with these search parameters too (e.g. to keep a code form open).

redirect: (location: string, cookies?: readonly string[]) => Response

A 303 redirect to location, setting these cookies.

setCookie: (value: string, maxAge: number) => string

A Set-Cookie header storing value for this method (its routes only) for maxAge seconds.

readCookie: () => string | undefined

The value setCookie stored, if the browser sent it back.