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

funksie

v1.0.0

Published

A Feature Policy plugin for hapi

Downloads

1

Readme

Funksie

A Feature Policy plugin for hapi.

Why the Name Funksie?

In Afrikaans the word Funksie means feature and it sounds similar to blankie a repo from which a lot of the code was taken

What is Feature Policy?

Feature policy is a HTTP response header that when set allows you to control which origins can use which features, both in the top-level page and in embedded frames.

Feature Policy provides a mechanism to explicitly declare what functionality is used (or not used), throughout your website. With Feature Policy, you opt-in to a set of "policies" for the browser to enforce on specific features used throughout a website. These policies restrict what APIs the site can access or modify the browser's default behavior for certain features.

Examples of what you can do with Feature Policy:

  • Change the default behavior of autoplay on mobile and third party videos.
  • Restrict a site from using sensitive APIs like magnetometer or microphone.
  • Controls whether the current document is allowed to use the Payment Request API. All our products and services at Credit Karma is free so we can set this to block

Here's a link to the complete list.

Usage

This plugin depends on scooter to function.

To use it:

'use strict';

const Hapi = require('@hapi/hapi');
const Funksie = require('funksie');
const Scooter = require('@hapi/scooter');

const internals = {};

const server = Hapi.server();

internals.init = async () => {

    await server.register([Scooter, {
        plugin: Funksie,
        options: {} // specify options here
    }]);

    await server.start();
};

internals.init().catch((err) => {

    throw err;
});

Options may also be set on a per-route basis:

'use strict';

const Hapi = require('@hapi/hapi');
const Funksie = require('funksie');
const Scooter = require('@hapi/scooter');

const server = Hapi.server();

server.route({
    method: 'GET',
    path: '/capture',
    config: {
        handler: (request, h) => {

            return 'capturing this';
        },
        plugins: {
            funksie: {
                cameraSrc: 'self'
            }
        }
    }
});

Note that this setting will NOT be merged with your server-wide settings.

You may also set config.plugins.funksie equal to false on a route to disable Feature-Policy headers completely for that route.

Options

  • accelerometerSrc: Values for the accelerometer directive. Defaults to 'none'.
  • ambientLightSensorSrc: Values for the ambient-light-sensor directive.
  • autoplaySrc: Values for the autoplay directive.
  • batterySrc: Values for the battery directive. Defaults to 'none'.
  • cameraSrc: Values for the camera directive. Defaults to 'none'.
  • displayCaptureSrc: Values for the display-capture directive.
  • documentDomainSrc: Values for the document-domain directive.
  • encryptedMediaSrc: Values for the encrypted-media directive.
  • fullscreenSrc: Values for the fullscreen directive.
  • geolocationSrc: Values for the geolocation directive. Defaults to 'none'.
  • gyroscopeSrc: Values for the gyroscope directive. Defaults to 'none'.
  • layoutAnimationsSrc: Values for the layout-animations directive.
  • legacyImageFormatsSrc: Values for the legacy-image-formats directive.
  • magnetometerSrc: Values for the magnetometer directive. Defaults to 'none'.
  • microphoneSrc: Values for the microphone directive. Defaults to 'none'.
  • midiSrc: Values for the midi directive.
  • oversizedImagesSrc: Values for the oversized-images directive.
  • paymentSrc: Values for the payment directive. Defaults to 'none'.
  • pictureInPictureSrc: Values for the picture-in-picture directive.
  • publickeyCredentialsGetSrc: Values for the publickey-credentials-get directive.
  • syncXhrSrc: Values for the sync-xhr directive.
  • usbSrc: 'Values for the usb directive.
  • vrSrc: Values for the vr directive.
  • wakeLockSrc: Values for the wake-lock directive.
  • xrSpatialTrackingSrc: Values for the xr-spatial-tracking directive.
  • reportUri: Value for the report-uri directive. This should be the path to a route that accepts Feature-Policy violation reports.