![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
twitch-ebs-tools
Advanced tools
Pack of useful functions for Twitch Extension Backend Services (EBS). It provides Twitch JWT verification methods and various validation strategies.
Primarily intended as a backend for a Fastify plugin for my StarCraft II Twitch extension, it can also be used as a standalone package or ported to other Node servers. Internally it uses jsonwebtoken for validating JWT tokens issued by Twitch.
npm install twitch-ebs-tools
git clone https://github.com/lukemnet/twitch-ebs-tools.git
cd twitch-ebs-tools
npm install
npm run build
Twitch-ebs-tools is also available as UMD module and it can be accessed via CDN:
// Using jsDelivr:
<script src="https://cdn.jsdelivr.net/npm/twitch-ebs-tools/dist/index.umd.js"></script>
// Using unpkg:
<script src="https://unpkg.com/twitch-ebs-tools/dist/index.umd.js"></script>
For methods starting with validate
class initialization is needed:
const { TwitchEbsTools } = require("twitch-ebs-tools");
/**
* Or using TypeScript / ES6 import:
* import { TwitchEbsTools } from 'twitch-ebs-tools';
*/
const twitchEbs = new TwitchEbsTools("twitch shared secret");
Methods starting with verify
are static, as they don't rely on Twitch shared secret.
Example:
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const validChannelId = TwitchEbsTools.verifyChannelId(payload, "123456789");
// true / false
Validates Twitch token by passing it to verify method of jsonwebtoken
. Returns decoded Twitch payload or throws an error for invalid token.
It is the most basic method that serves as a basis for more granular strategies.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const twitchEbs = new TwitchEbsTools("twitch shared secret");
const twitchPayload = twitchEbs.validateToken(token);
console.log(twitchPayload); // decoded Twitch payload
Validates whether supplied Twitch token:
validateToken
method)const { TwitchEbsTools } = require("twitch-ebs-tools");
const twitchEbs = new TwitchEbsTools("twitch shared secret");
const permissionValid = twitchEbs.validatePermission("token", "123456789", [
"viewer",
"broadcaster",
]);
console.log(permissionValid); // true or false
Parameters:
token
- JWT token issued by Twitch as stringchannelId
- Twitch channel ID used for validating the Twitch tokenrole
- Twitch role(s) to be used for validating supplied token. It accepts strings (e.g. viewer
) or arrays of string (e.g. ['viewer', 'broadcaster']
). In case of arrays one of the roles is needed to pass the validationignoreExpiration
(optional) - when true
, token expiration time will not be checkedThe following methods require decoded Twitch payload as one of their parameters. Payload can be supplied with validateToken
method or passed as a variable from an outside source.
Static methods can be used pretty much out-of-the-box. They are intended to be helpful while building more detailed validation strategies and integrate easily with other tools.
Verifies whether supplied Twitch payload contains channel ID passed as a string
parameter. Returns true
/ false
. If Twitch payload is malformed, it returns false
.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const validChannelId = TwitchEbsTools.verifyChannelId(payload, "123456789");
// true / false
Verifies whether supplied Twitch payload is time valid by comparing exp
property with current server time. Twitch tokens are valid for one hour since being issued.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const tokenNotExpired = TwitchEbsTools.verifyTokenNotExpired(payload);
// true / false
Verifies whether supplied Twitch payload contains valid role. It accepts Twitch role (viewer
or broadcaster
) as string.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const correctRole = TwitchEbsTools.verifyRole(payload, "viewer");
// true / false
Verifies whether supplied Twitch payload contains valid channel id and role. It accepts Twitch channel ID as string and Twitch role (viewer
or broadcaster
) as string.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const correctChannelIdAndRole = TwitchEbsTools.verifyChannelIdAndRole(
payload,
"viewer"
);
// true / false
Verifies whether supplied Twitch payload contains valid broadcaster role. This method is useful for verifying broadcaster-only routes (e.g. Twitch extension configuration sections).
Note that this only checks for a Twitch broadcaster
role and does not perform any further checks.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const correctBroadcasterRole = TwitchEbsTools.verifyBroadcaster(payload);
// true / false
Verifies whether supplied Twitch payload contains either broadcaster
(Twitch channel owner) or viewer
(channel viewer) role. This method is useful for verifying public routes (e.g. Twitch extension panels).
Note that checking for both roles is necessary for the extensions to work correctly. If you validate panel route against viewer
route only, the extension will not work correctly for channel broadcaster.
Note that this only checks for Twitch broadcaster
or viewer
roles and does not perform any further checks.
const { TwitchEbsTools } = require("twitch-ebs-tools");
const payload = new TwitchEbsTools("twitch shared secret").validateToken(
"token"
);
const correctViewerOrBroadcasterRole =
TwitchEbsTools.verifyViewerOrBroadcaster(payload);
// true / false
Contributions of any kind are welcome.
You can contribute to Twitch-ebs-tools by:
Before contributing be sure to read Contributing Guidelines and Code of Conduct.
To all who contribute code, improve documentation, submit issues or feature requests - thank you for making Twitch-ebs-tools even better!
We maintain an AUTHORS file where we keep a list of all project contributors. Please consider adding your name there with your next PR.
Licensed under MIT License. See LICENSE for more information.
This project is not authored, affiliated or endorsed in any way by Twitch.tv.
FAQs
Utility functions for Twitch Extension Backend Services (EBS)
The npm package twitch-ebs-tools receives a total of 0 weekly downloads. As such, twitch-ebs-tools popularity was classified as not popular.
We found that twitch-ebs-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.