Beignet API reference
    Preparing search index...

    Type Alias AuthHooksOptions<Ctx, Session>

    Options for createAuthHooks(...).

    type AuthHooksOptions<Ctx, Session> = {
        assign?: (args: AuthHookAssignArgs<Ctx, Session>) => MaybePromise<Ctx>;
        getSession?: (args: AuthHookArgs<Ctx>) => MaybePromise<Session | null>;
        isAuthenticated?: (session: Session | null) => boolean;
        mode?: (args: AuthHookArgs<Ctx>) => MaybePromise<AuthHookModeInput>;
        name?: string;
        unauthorized?: (
            args: AuthHookUnauthorizedArgs<Ctx, Session>,
        ) => MaybePromise<HttpResponse>;
    }

    Type Parameters

    • Ctx
    • Session
    Index

    Properties

    assign?: (args: AuthHookAssignArgs<Ctx, Session>) => MaybePromise<Ctx>

    Return an updated context with auth/session fields attached.

    getSession?: (args: AuthHookArgs<Ctx>) => MaybePromise<Session | null>

    Custom session lookup. Required when context does not expose ctx.ports.auth.

    isAuthenticated?: (session: Session | null) => boolean

    Decide whether a resolved session counts as authenticated.

    mode?: (args: AuthHookArgs<Ctx>) => MaybePromise<AuthHookModeInput>

    Resolve whether the current contract is public, optional-auth, or required-auth.

    name?: string

    Hook name used in diagnostics.

    unauthorized?: (
        args: AuthHookUnauthorizedArgs<Ctx, Session>,
    ) => MaybePromise<HttpResponse>

    Return a custom unauthorized response for required-auth routes.