Nerdiest Political Manifesto
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

fastify-twitch-ebs-tools

1.2.1 • Public • Published

fastify-twitch-ebs-tools

npm (latest) Travis Build Status Maintainability Test Coverage

Fastify plugin providing utility functions for Twitch Extension Backend Services (EBS). Internally it uses twitch-ebs-tools.

Installation

npm install --save fastify-twitch-ebs-tools

Usage

Register as a plugin to get access to additional methods.

Example below assumes Twitch token to be sent via request headers.

const fastify = require('fastify');
 
fastify.register(require('fastify-twitch-ebs-tools'), {
  secret: 'twitch shared secret',
  disabled: false,
});
 
fastify.get('/config/:channelId', (req, reply) => {
  const { token } = req.headers;
  const { channelId } = req.params;
  const valid = fastify.twitchEbs.validatePermission(
    token,
    channelId,
    'broadcaster',
  );
 
  if (valid) {
    // do something and send the reply back
    reply.send(/* reply object */);
  } else {
    // error 400
  }
});
 
fastify.listen(3000, (error) => {
  if (error) throw error;
});

Options

  • secret - Twitch shared secret used to sign and verify JWTs (required). The plugin will throw an error if no secret is provided. Required.

  • disabled - if true, all validation methods will return true. Useful for temporarily disabling route authentication for debugging purposes. Does not affect validateToken() method. Defaults to false. Optional.

Usage

All plugin methods pass arguments to relevant methods of twitch-ebs-tools. Refer to twitch-ebs-tools documentation to get more details.

Available methods:

License

Licensed under MIT License. See LICENSE for more information.

Install

npm i fastify-twitch-ebs-tools

DownloadsWeekly Downloads

2

Version

1.2.1

License

MIT

Unpacked Size

11.7 kB

Total Files

6

Last publish

Collaborators

  • avatar