UNPKG

@adonisjs/shield

Version:

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

34 lines (33 loc) 864 B
import type { Edge } from 'edge.js'; import type { EncryptionService } from '@adonisjs/core/types'; import type { ShieldConfig } from './types.js'; import type { HttpContext } from '@adonisjs/core/http'; declare module '@adonisjs/core/http' { interface Request { csrfToken: string; } interface Response { nonce: string; } } /** * Extending the Node.js ServerResponse with * our new `nonce` property */ declare module 'node:http' { interface ServerResponse { nonce: string; } } /** * Shield middleware to protect web applications against common * web attacks */ export default class ShieldMiddleware { #private; constructor(config: ShieldConfig, encryption: EncryptionService, edge?: Edge); /** * Handle request */ handle(ctx: HttpContext, next: () => Promise<void>): Promise<void>; }