Skip to content
This repository has been archived by the owner on Nov 4, 2018. It is now read-only.

zacanger/koa-feature-policy

Repository files navigation

koa-feature-policy

Deprecated

Feature-Policy has been added to Helmet, so please use koa-helmet to add this header (and lots of other great security header fixes) to your Koa apps.


Small library for adding a Feature-Policy to Koa responses.

IMPORTANT Feature-Policy is experimental, so this library might change frequently until the new header is stable.


Installation

npm i koa-feature-policy

Usage

import featurePolicy from 'koa-feature-policy'

// set up koa

const options = {
  /* directive: allowlist */
  vibrate: ["'self'", 'https://example.com']
}

app.use(featurePolicy(options))

// call app.listen

See MDN for the full list of directives.

This library converts camelCase directives to lisp-case. So use ambientLightSensor, not 'ambient-light-sensor'.

License

MIT