Beignet API reference
    Preparing search index...

    Type Alias AuthHooksOptions<Ctx, AddedCtx, HeadersSchema>

    Options for route-scoped auth hooks.

    Auth additions must not include gate: the server re-attaches the gate declared by the context blueprint after every hook, so elevated identities are authorized against the updated context automatically.

    type AuthHooksOptions<
        Ctx,
        AddedCtx extends object & { gate?: never },
        HeadersSchema extends StandardSchema | undefined = undefined,
    > = {
        headers?: HeadersSchema;
        name?: string;
        resolve: (
            args: AuthHookArgs<Ctx, HeadersSchema>,
        ) => MaybePromise<AddedCtx | null>;
    }

    Type Parameters

    • Ctx
    • AddedCtx extends object & { gate?: never }
    • HeadersSchema extends StandardSchema | undefined = undefined
    Index
    headers?: HeadersSchema

    Optional Standard Schema for the credential headers this hook reads.

    The schema is validated against the raw lowercase request header record before resolve runs. On required() hooks a schema failure rejects the request with a framework-owned 401; on optional() hooks a schema failure skips auth resolution; public() hooks never parse headers.

    name?: string

    Hook name prefix used in diagnostics.

    resolve: (
        args: AuthHookArgs<Ctx, HeadersSchema>,
    ) => MaybePromise<AddedCtx | null>

    Resolve authenticated context additions for the current request.

    Return null when the request is unauthenticated. Required hooks will reject that request; optional hooks will add no auth context.