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 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-xlusca

v1.0.0

Published

Web application security middleware for koa.

Downloads

2

Readme

koa-xlusca

NPM version build status Test coverage David deps npm download

Web application security middleware for the latest koa 2.x.

Fork from koa-lusca,

It's a pity that koa-lusca is out of maintenances for over 3 years, so i made this fork and re-released it as koa-xlusca, and let's keep it fresh.

Usage

const Koa = require('koa');
const lusca = require('koa-xlusca');
const app = new Koa();

app.use(lusca({
  csrf: true,
  csp: { /* ... */},
  xframe: 'SAMEORIGIN',
  p3p: 'ABCDEF',
  hsts: { maxAge: 31536000, includeSubDomains: true },
  xssProtection: true,
  referrerPolicy: 'same-origin'
}));

Setting any value to false will disable it. Alternately, you can opt into methods one by one:

app.use(lusca.csrf());
app.use(lusca.csp({/* ... */}));
app.use(lusca.xframe({ value: 'SAMEORIGIN' }));
app.use(lusca.p3p({ value: 'ABCDEF' }));
app.use(lusca.hsts({ maxAge: 31536000 });
app.use(lusca.xssProtection();
app.use(lusca.referrerPolicy('same-origin'));

API

lusca.csrf(options)

  • key String - Optional. The name of the CSRF token added to the model. Defaults to _csrf.
  • secret String - Optional. The key to place on the session object which maps to the server side token. Defaults to _csrfSecret.
  • impl Function - Optional. Custom implementation to generate a token.

Enables Cross Site Request Forgery (CSRF) headers.

If enabled, the CSRF token must be in the payload when modifying data or you will receive a 403 Forbidden. To send the token you'll need to echo back the _csrf value you received from the previous request.

lusca.csp(options)

  • options.policy Object - Object definition of policy.
  • options.policy String, Object, or an Array - Object definition of policy. Valid policies examples include:
    • {"default-src": "*"}
    • "referrer no-referrer"
    • [{ "img-src": "'self' http:" }, "block-all-mixed-content"]
  • options.reportOnly Boolean - Enable report only mode.
  • options.reportUri String - URI where to send the report data

Enables Content Security Policy (CSP) headers.

Example Options

// Everything but images can only come from own domain (excluding subdomains)
{
  policy: {
    'default-src': '\'self\'',
    'img-src': '*'
  }
}

See the MDN CSP usage page for more information on available policy options.

lusca.xframe(value)

  • value String - Required. The value for the header, e.g. DENY, SAMEORIGIN or ALLOW-FROM uri.

Enables X-FRAME-OPTIONS headers to help prevent Clickjacking.

lusca.p3p(value)

  • value String - Required. The compact privacy policy.

Enables Platform for Privacy Preferences Project (P3P) headers.

lusca.hsts(options)

  • options.maxAge Number - Required. Number of seconds HSTS is in effect.
  • options.includeSubDomains Boolean - Optional. Applies HSTS to all subdomains of the host

Enables HTTP Strict Transport Security for the host domain. The preload flag is required for HSTS domain submissions to Chrome's HSTS preload list

lusca.xssProtection(options)

  • options.enabled Boolean - Optional. If the header is enabled or not (see header docs). Defaults to 1.
  • options.mode String - Optional. Mode to set on the header (see header docs). Defaults to block.

Enables X-XSS-Protection headers to help prevent cross site scripting (XSS) attacks in older IE browsers (IE8)

lusca.cto()

Enables X-Content-Type-Options header to prevent MIME-sniffing a response away from the declared content-type.

lusca.referrerPolicy(value)

  • value String - Optional. The value for the header, e.g. origin, same-origin, no-referrer. Defaults to `` (empty string).

Enables Referrer-Policy header to control the Referer header.

License

  • Original License: Apache License, Version 2.0, Copyright (C) 2014 eBay Software Foundation
  • Now: MIT

Origin Contributors Of koa-lusca

Jeff Harrell [email protected] (https://github.com/jeffharrell) Jeff Harrell [email protected] Erik Toth [email protected] rragan [email protected] skoranga [email protected] Lenny Markus [email protected] (https://github.com/lmarkus) totherik [email protected] Lenny Markus [email protected] Trevor [email protected] Steve Stedman [email protected] AlexSantos [email protected] mstuart [email protected] swesthafer [email protected] Dmitry Shirokov [email protected] (https://github.com/runk) Sahat Yalkabov [email protected] fengmk2 [email protected] (https://github.com/fengmk2) Anant Singh [email protected] Aria Stewart [email protected] (https://github.com/aredridel) Jean-Charles Sisk [email protected] Matt Edelman [email protected] Ilya Radchenko [email protected] Poornima Venkat [email protected] ali-sdk [email protected] (https://github.com/ali-sdk) fundon [email protected] Christoffer Hallas [email protected] Geller [email protected] Marek Fajkus [email protected] (https://github.com/turboMaCk) Shawn [email protected] (https://github.com/shaoshuai0102) Chris Veness [email protected]