UNPKG

@adonisjs/shield

Version:

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

35 lines (32 loc) 689 B
import { cspFactory, csrfFactory, frameGuardFactory, hstsFactory, noSniffFactory } from "./chunk-MON32NSL.js"; // src/shield_middleware.ts var ShieldMiddleware = class { #guards = []; constructor(config, encryption, edge) { this.#guards = [ csrfFactory(config.csrf || {}, encryption, edge), cspFactory(config.csp || {}), frameGuardFactory(config.xFrame || {}), hstsFactory(config.hsts || {}), noSniffFactory(config.contentTypeSniffing || {}) ]; } /** * Handle request */ async handle(ctx, next) { for (let action of this.#guards) { await action(ctx); } await next(); } }; export { ShieldMiddleware };