opentok-jwt

0.1.5 • Public • Published

opentok-jwt

Tokbox is now known as Vonage

Node module to generate a JWT token given an apiKey and secret. Useful for automated tests against the Opentok API server or other scenarios when you might need to generate these tokens.

Install

npm install --save opentok-jwt

Usage

const { accountToken, generateToken, projectToken, verify } = require('opentok-jwt');

const apiKey = <yourAPIKey>;
const apiSecret = <yourAPISecret>;

const projectJWT = projectToken(apiKey, apiSecret);
const accountJWT = accountToken(apiKey, apiSecret);
// or
const projectJWT = generateToken(apiKey, secret, 'project');
const accountJWT = generateToken(apiKey, apiSecret, 'account');

// With custom expiry (Default 30 days)
const expires = Math.floor(new Date() / 1000) + (24 * 60 * 60); // Now + 1 day
const accountJWT = accountToken(apiKey, apiSecret, expires);
const projectJWT = projectToken(apiKey, apiSecret, expires);
// or
const accountJWT = generateToken(apiKey, apiSecret, 'account', expires);
const projectJWT = generateToken(apiKey, apiSecret, 'project', expires);

// Verify
const decoded = await verify(token, secret);

Development and Contributing

Interested in contributing? We ❤️ pull requests! See the Contribution guidelines.

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

Readme

Keywords

none

Package Sidebar

Install

npm i opentok-jwt

Weekly Downloads

28

Version

0.1.5

License

MIT

Unpacked Size

19.1 kB

Total Files

10

Last publish

Collaborators

  • opentok-owner
  • maikthomas
  • marcioaffonso