/** * CSRF Handler * * Generates and validates CSRF tokens for cookie-based authentication. * * **Platform-Agnostic:** * This handler operates purely on NAuthRequest interface. * Context is managed by the adapter, not this handler. * * **Lazy Validation:** * CSRF errors are stored in request attributes instead of thrown immediately. * This allows public routes and requireAuth() to decide how to handle them. */ import { NAuthConfig, NAuthLogger } from '../index'; import { CsrfService } from '../services/csrf.service'; import { NAuthRequest, NAuthResponse } from '../platform/interfaces'; /** * CsrfHandler * * Handles CSRF token generation and validation for cookie-based authentication. */ export declare class CsrfHandler { private readonly csrfService; private readonly config; private readonly logger?; constructor(csrfService: CsrfService, config: NAuthConfig, logger?: NAuthLogger | undefined); /** * Handle request - generate or validate CSRF token * * Note: Context is managed by adapter. This handler assumes context is available. */ handle(req: NAuthRequest, res: NAuthResponse, next: () => Promise | void): Promise; /** * Generate CSRF token if not present in cookies */ private generateTokenIfMissing; /** * Validate CSRF token from request * * Uses lazy validation - stores error in attributes instead of throwing. * requireAuth() helper will throw if error exists. */ private validateToken; } //# sourceMappingURL=csrf.handler.d.ts.map