import { Type } from '@nestjs/common'; import { MFAOptions } from './mfa-options.interface'; import { IRateLimitOptions } from './rate-limit.interface'; import { HibpOptions } from '../../utils/password-policy.util'; import { CookieOptions, SessionOptions } from './session-options.interface'; import { BaseAuthProvider } from '../providers/base-auth.provider'; import { DebugLogOptions } from '../services/debug-logger.service'; import { NestAuthUser } from '../../user/entities/user.entity'; import { SessionPayload, JWTTokenPayload } from './token-payload.interface'; import { NestAuthSignupRequestDto } from '../../auth/dto/requests/signup.request.dto'; import { NestAuthLoginRequestDto } from '../../auth/dto/requests/login.request.dto'; import { INestAuthTenantOptions } from '@ackplus/nest-auth-contracts'; import { Request } from 'express'; import { EntityManager } from 'typeorm'; import { NestAuthPlatformAccess, NestAuthUserAccess } from '../entities'; export interface IDefaultTenantOptions { name: string; slug: string; description?: string; metadata?: Record; } export interface IRegistrationCollectProfileField { id: string; label: string; required: boolean; type: 'text' | 'email' | 'phone' | 'select' | 'checkbox' | 'password'; placeholder?: string; options?: Array<{ label: string; value: string; }>; } export interface IUserHooks { beforeCreate?: (userData: Partial, input: any) => Promise> | Partial; afterCreate?: (user: NestAuthUser, input: any, manager?: EntityManager) => Promise | void; beforeUpdate?: (user: NestAuthUser, changes: Partial, manager?: EntityManager) => Promise | void> | Partial | void; afterUpdate?: (user: NestAuthUser, changes: Partial, manager?: EntityManager) => Promise | void; beforeDelete?: (user: NestAuthUser, manager?: EntityManager) => Promise | void; afterDelete?: (user: NestAuthUser, manager?: EntityManager) => Promise | void; getSessionUserData?: (user: NestAuthUser) => Promise | any; sensitiveFields?: string[]; } export interface IAuthHooks { transformResponse?: (response: any, user: NestAuthUser, session: SessionPayload) => Promise | any; } export interface IBeforeSignupContext { request: Request; } export interface IOnSignupContext { request?: Request; manager?: EntityManager; } export interface IOnLoginContext { userAccess?: NestAuthUserAccess; platformAccess?: NestAuthPlatformAccess; request?: Request; provider?: BaseAuthProvider; manager?: EntityManager; } export interface IRegistrationHooks { beforeSignup?: (input: NestAuthSignupRequestDto, context: IBeforeSignupContext) => Promise | NestAuthSignupRequestDto; onSignup?: (user: NestAuthUser, input: NestAuthSignupRequestDto, context?: IOnSignupContext) => Promise | void; } export interface ILoginHooks { onLogin?: (user: NestAuthUser, input: NestAuthLoginRequestDto, context?: IOnLoginContext) => Promise | void; } export interface IPasswordlessOptions { enabled?: boolean; allowSignUp?: boolean; } export interface IOtpOptions { secret?: string; generate?: (length?: number, format?: 'numeric' | 'alphanumeric') => string | Promise; length?: number; format?: 'numeric' | 'alphanumeric'; codeExpiresIn?: number | string; maxAttempts?: number; } export interface IGuardHooks { beforeAuth?: (request: any, payload: JWTTokenPayload) => Promise; afterAuth?: (request: any, user: NestAuthUser, session: SessionPayload) => Promise | void; } export interface IAuthorizationHooks { resolveRoles?: (user: NestAuthUser) => Promise; resolvePermissions?: (user: NestAuthUser, roles: string[]) => Promise; } export interface IAuthAuditEvent { type: 'login' | 'login_failed' | 'logout' | 'signup' | 'password_change' | 'mfa_enable' | 'mfa_disable' | 'session_revoke'; userId?: string; ip?: string; userAgent?: string; success: boolean; metadata?: Record; timestamp: Date; } export interface IAuditOptions { enabled?: boolean; onEvent?: (event: IAuthAuditEvent) => Promise | void; } export interface IAuthModuleOptions { isGlobal?: boolean; appName: string; routePrefix?: string; enableAutoRefresh?: boolean; security?: { csrf?: { enabled?: boolean; allowedOrigins?: string[]; cookieName?: string; headerName?: string; }; rateLimit?: IRateLimitOptions; lockout?: { enabled?: boolean; maxFailedAttempts?: number; window?: number | string; lockDuration?: number | string; }; captcha?: { enabled?: boolean; verify?: (token: string, ctx: { ip?: string; route?: string; }) => boolean | Promise; headerName?: string; bodyField?: string; }; }; social?: { requireVerifiedEmailForLinking?: boolean; }; google?: { clientId: string; clientSecret: string; redirectUri: string; requireVerifiedEmail?: boolean; audiences?: string[]; }; facebook?: { appId: string; appSecret: string; redirectUri: string; }; apple?: { clientId: string; teamId: string; keyId: string; privateKey: string; privateKeyMethod?: string; redirectUri: string; audiences?: string[]; jwksUrl?: string; }; github?: { clientId: string; clientSecret: string; redirectUri: string; userApiUrl?: string; emailsApiUrl?: string; }; phoneAuth?: { enabled: boolean; }; emailAuth?: { enabled: boolean; disposable?: { enabled?: boolean; mode?: 'block' | 'flag'; allowlist?: string[]; }; }; passwordless?: IPasswordlessOptions; registration?: { enabled?: boolean; requireInvitation?: boolean; requireVerifiedEmail?: boolean; autoLoginAfterSignup?: boolean; collectProfileFields?: Array; }; clientConfig?: { factory?: (defaultConfig: import('@ackplus/nest-auth-contracts').IClientConfig, context: { configService: any; tenantService: any; }) => Promise | any; }; mfa?: MFAOptions; session?: SessionOptions; mustChangePassword?: { enforce?: boolean; }; customAuthProviders?: BaseAuthProvider[]; tenant?: INestAuthTenantOptions; roleGuards?: string[]; adminConsole?: IAdminConsoleOptions; debug?: DebugLogOptions; user?: IUserHooks; auth?: IAuthHooks; registrationHooks?: IRegistrationHooks; loginHooks?: ILoginHooks; guards?: IGuardHooks; password?: { passwordResetTokenExpiresIn?: number | string; hash?: (password: string) => Promise; verify?: (password: string, hash: string) => Promise; argon2?: { memoryCost?: number; timeCost?: number; parallelism?: number; }; policy?: IPasswordPolicyOptions; }; platformAccess?: { enabled?: boolean; validate?: (request: Request) => Promise | boolean; }; otp?: IOtpOptions; authorization?: IAuthorizationHooks; audit?: IAuditOptions; errorHandler?: (error: Error, context: 'login' | 'signup' | 'refresh' | 'mfa' | 'password_reset' | 'password_change') => any; resolveConfig?: (context: any) => Promise> | Partial; } export interface IPasswordPolicyOptions { enabled?: boolean; minLength?: number; maxLength?: number; blockCommonPasswords?: boolean; blocklist?: string[]; blockContainsIdentifier?: boolean; checkBreached?: boolean; hibp?: HibpOptions; } export interface IAdminConsoleOptions { enabled?: boolean; path?: string; basePath?: string; secretKey?: string; sessionSecret?: string; sessionCookieName?: string; sessionDuration?: string | number; cookie?: CookieOptions; allowAdminManagement?: boolean; bruteForce?: { enabled?: boolean; }; allowPublicSignupAfterFirstAdmin?: boolean; } export interface IAuthModuleAsyncOptions { isGlobal?: boolean; enableAutoRefresh?: boolean; imports?: any[]; useFactory?: (...args: any[]) => Promise | IAuthModuleOptions; inject?: any[]; useClass?: Type; useExisting?: Type; } export interface IAuthModuleOptionsFactory { createAuthModuleOptions(): Promise | IAuthModuleOptions; } //# sourceMappingURL=auth-module-options.interface.d.ts.map