npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@owasp-webshield/express

v2.0.0

Published

Express adapter for OWL (OWASP Webshield Library): middleware for authentication, access control, CSRF, validation, security headers, SSRF checks and security error handling

Readme

@owasp-webshield/express

Express adapter for OWL (OWASP Webshield Library). It provides middleware for authentication, access control, CSRF, input validation, security headers, SSRF checks and security error handling, built on @owasp-webshield/core and @owasp-webshield/node. It works with Express 4.18+ and 5.

Installation

npm install @owasp-webshield/core @owasp-webshield/express

An ES module with TypeScript declarations. It needs Node.js 20.19+ or 22.12+, which can also load it from CommonJS with require(). In TypeScript, the declarations add req.owl (session, outboundUrl) to Express's Request type.

Quick start

import express from "express";
import { createOwlClient, SecurityLogger } from "@owasp-webshield/core";
import {
  assertHardened,
  csrfProtection,
  errorHandler,
  requireAuth,
  requirePermission,
  securityHeaders,
  validate
} from "@owasp-webshield/express";

const logger = new SecurityLogger();
assertHardened({ debug: process.env.NODE_ENV !== "production" }, { logger }); // throws on unsafe config

const owl = createOwlClient({ roles: { editor: { permissions: ["write:reports"] } } });

const app = express();
app.use(securityHeaders());
app.use(express.json());
app.use(requireAuth({ verifyToken: (token) => sessionStore.lookup(token) })); // -> req.owl.session
app.use(csrfProtection());

app.post("/reports",
  requirePermission("write", "reports", owl),
  validate({ title: { required: true, type: "string", maxLength: 120 } }, { allowUnknownFields: false }),
  (req, res) => res.status(201).json(req.body)
);

app.use(errorHandler({ logger }));

verifyToken is called on every request, so sessions are never shared between users. Return the user's { userId, roles }, or null for an unknown or expired token.

Middleware

| Category | Export | |---|---| | A01 Access Control | requirePermission(action, resource, checker) | | A03 Injection Defense | validate(schema, options), sanitizeBody(fields, options) | | A05 Security Misconfiguration | securityHeaders(overrides), assertHardened(config, options) | | A07 Auth Session | requireAuth({ verifyToken }) | | A08 Data Integrity | csrfProtection(options), issueCsrfToken(res, options) | | A09 Logging Monitoring | errorHandler({ logger }) | | A10 SSRF Defense | guardOutboundUrl(getUrl, { guard }) |

Security failures become JSON responses (400/401/403, with the SecurityErrorCode in error). A 500 never includes the error's message.

Documentation

License

Apache-2.0. See the main repository for the full license text and contribution guidelines.