UNPKG

@adonisjs/shield

Version:

A middleware for AdonisJS to keep web applications secure from common web attacks

51 lines (50 loc) 1.69 kB
import { type HttpContext } from '@adonisjs/core/http'; /** * Exception class for invalid or expired CSRF tokens. * Handles CSRF validation failures by flashing errors and redirecting back. * * @example * throw new E_BAD_CSRF_TOKEN() */ export declare const E_BAD_CSRF_TOKEN: { new (message?: string, options?: ErrorOptions & { code?: string; status?: number; }): { code: string; status: number; message: string; identifier: string; /** * Returns the message to be sent in the HTTP response. * Feel free to override this method and return a custom * response. * * @param error - The error instance * @param ctx - The HTTP context */ getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string; /** * Handles the CSRF error by flashing session data and redirecting back. * For non-Inertia requests, flashes all session data except sensitive fields. * * @param error - The error instance * @param ctx - The HTTP context */ handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>; name: string; help?: string; toString(): string; get [Symbol.toStringTag](): string; stack?: string; cause?: unknown; }; help?: string; code?: string; status?: number; message?: string; isError(error: unknown): error is Error; captureStackTrace(targetObject: object, constructorOpt?: Function): void; prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any; stackTraceLimit: number; };