Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vonage/jwt

Package Overview
Dependencies
Maintainers
37
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/jwt - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

2

dist/jwt.d.ts
/// <reference types="node" />
import { JWTInterface, GeneratorOptions } from './common';
export declare class JWT implements JWTInterface {
tokenGenerate<T>(applicationId: string, privateKey: string | Buffer, opts?: GeneratorOptions): string;
tokenGenerate(applicationId: string, privateKey: string | Buffer, opts?: GeneratorOptions): string;
private validateOptions;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,6 +9,11 @@ exports.JWT = void 0;

const uuid_1 = require("uuid");
const debug_1 = __importDefault(require("debug"));
const log = (0, debug_1.default)('vonage:jwt');
class JWT {
tokenGenerate(applicationId, privateKey, opts) {
if (!applicationId || !privateKey)
log(`Application id: ${applicationId}`);
log(`Provate key: ${privateKey}`);
if (!applicationId || !privateKey) {
throw new Error('Missing applicationId or privateKey');
}
if (typeof applicationId !== 'string') {

@@ -18,2 +26,3 @@ throw new Error('applicationId must be string');

const claims = this.validateOptions(opts);
log('Claims', claims);
claims.application_id = applicationId;

@@ -28,22 +37,12 @@ return (0, jsonwebtoken_1.sign)(claims, privateKey, {

const claims = {
jti: (opts === null || opts === void 0 ? void 0 : opts.jti) || (0, uuid_1.v4)(),
iat: (opts === null || opts === void 0 ? void 0 : opts.issued_at) || now,
exp: now + ((opts === null || opts === void 0 ? void 0 : opts.ttl) || 900),
...opts,
jti: opts?.jti || (0, uuid_1.v4)(),
iat: opts?.issued_at || now,
exp: now + (opts?.ttl || 900),
};
if (opts === null || opts === void 0 ? void 0 : opts.jti) {
delete opts.jti;
}
if (opts === null || opts === void 0 ? void 0 : opts.issued_at) {
delete opts.issued_at;
}
if (opts === null || opts === void 0 ? void 0 : opts.ttl) {
delete opts.ttl;
}
if (opts === null || opts === void 0 ? void 0 : opts.subject) {
if (opts?.subject) {
claims.sub = opts.subject;
delete opts.subject;
}
if (opts === null || opts === void 0 ? void 0 : opts.acl) {
if (opts?.acl) {
claims.acl = opts.acl;
delete opts.acl;
}

@@ -50,0 +49,0 @@ for (const property in opts) {

{
"name": "@vonage/jwt",
"version": "1.0.9",
"version": "1.0.10",
"description": "Vonage JWT package. Creates JWT tokens for Vonage API's",

@@ -26,2 +26,3 @@ "homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/jwt#readme",

"dependencies": {
"debug": "^4.3.4",
"jsonwebtoken": "^9.0.0",

@@ -28,0 +29,0 @@ "uuid": "^9.0.0"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc