Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fastify-permissions-policy

JosephScript155MIT1.0.2TypeScript support: included

Fastify plugin for setting custom permissions policies.

permissions-policy, feature-policy, fastify, fastify-plugin, middleware

readme

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' })
  })