UNPKG

@adonisjs/auth

Version:

Official authentication provider for Adonis framework

39 lines (38 loc) 1.35 kB
import type { ConfigProvider } from '@adonisjs/core/types'; import type { GuardConfigProvider, GuardFactory } from './types.ts'; /** * Config resolved by the "defineConfig" method */ export type ResolvedAuthConfig<KnownGuards extends Record<string, GuardFactory | GuardConfigProvider<GuardFactory>>> = { default: keyof KnownGuards; guards: { [K in keyof KnownGuards]: KnownGuards[K] extends GuardConfigProvider<infer A> ? A : KnownGuards[K]; }; }; /** * Define configuration for the auth package. The function returns * a config provider that is invoked inside the auth service * provider * * @param config - Configuration object with default guard and available guards * * @example * import { defineConfig } from '@adonisjs/auth' * import { sessionGuard, sessionUserProvider } from '@adonisjs/auth/session' * * const authConfig = defineConfig({ * default: 'web', * guards: { * web: sessionGuard({ * useRememberMeTokens: false, * provider: sessionUserProvider({ * model: () => import('#models/user') * }) * }) * } * }) */ export declare function defineConfig<KnownGuards extends Record<string, GuardFactory | GuardConfigProvider<GuardFactory>>>(config: { default: keyof KnownGuards; guards: KnownGuards; }): ConfigProvider<ResolvedAuthConfig<KnownGuards>>;