UNPKG

@adonisjs/shield

Version:

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

26 lines (25 loc) 906 B
import type { Edge } from 'edge.js'; import type { HttpContext } from '@adonisjs/core/http'; import type { Encryption } from '@adonisjs/core/encryption'; import { noop } from '../noop.js'; import type { CsrfOptions } from '../types.js'; /** * A class to encapsulate the logic of verifying and generating * CSRF tokens. */ export declare class CsrfGuard { #private; constructor(options: CsrfOptions, encryption: Encryption, edge?: Edge); /** * Handle csrf verification. First, get the secret, * next, check if the request method should be * verified. Next, attach the newly generated * csrf token to the request object. */ handle(ctx: HttpContext): Promise<void>; } /** * A factory function that returns a new function to enforce CSRF * protection */ export declare function csrfFactory(options: CsrfOptions, encryption: Encryption, edge?: Edge): typeof noop;