fastify-permissions-policy
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

fastify-permissions-policy

Set permissions-policy headers in Fastify easily.

See the list here: https://www.w3.org/TR/permissions-policy-1/

Mostly a wrapper around permissions-policy middleware.

To use:

  import fastify from 'fastify'
  import permissions from 'permissions-policy'

  const fastify = Fastify()
  fastify.register(permissions, {
    features: {
      interestCohort: [],
      fullscreen: ["self"],
      vibrate: ["none"],
      payment: ["self", '"example.com"'],
      syncXhr: [],
    },
  })

  fastify.get('/', (request, reply) => {
    console.log(reply.getHeader('permissions-policy'))
    // interest-cohort=(), fullscreen=(self), vibrate=(none), payment=(self "example.com"), sync-xhr=()
    reply.send({ hello: 'world' })
  })

Package Sidebar

Install

npm i fastify-permissions-policy

Weekly Downloads

89

Version

1.0.2

License

MIT

Unpacked Size

8.5 kB

Total Files

12

Last publish

Collaborators

  • josephscript