@vonage/jwt
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -1,2 +0,3 @@ | ||
export {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=acl.js.map |
@@ -1,2 +0,3 @@ | ||
export {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=common.js.map |
@@ -1,7 +0,11 @@ | ||
import { JWT } from './jwt'; | ||
export { JWT }; | ||
const instance = new JWT(); | ||
export function tokenGenerate(applicationId, privateKey, opts) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tokenGenerate = exports.JWT = void 0; | ||
const jwt_1 = require("./jwt"); | ||
Object.defineProperty(exports, "JWT", { enumerable: true, get: function () { return jwt_1.JWT; } }); | ||
const instance = new jwt_1.JWT(); | ||
function tokenGenerate(applicationId, privateKey, opts) { | ||
return instance.tokenGenerate(applicationId, privateKey, opts); | ||
} | ||
exports.tokenGenerate = tokenGenerate; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,7 @@ | ||
import { sign } from 'jsonwebtoken'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
export class JWT { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JWT = void 0; | ||
const jsonwebtoken_1 = require("jsonwebtoken"); | ||
const uuid_1 = require("uuid"); | ||
class JWT { | ||
tokenGenerate(applicationId, privateKey, opts) { | ||
@@ -15,3 +18,3 @@ if (!applicationId || !privateKey) | ||
claims.application_id = applicationId; | ||
return sign(claims, privateKey, { | ||
return (0, jsonwebtoken_1.sign)(claims, privateKey, { | ||
algorithm: 'RS256', | ||
@@ -24,20 +27,20 @@ header: { typ: 'JWT', alg: 'RS256' }, | ||
const claims = { | ||
jti: opts?.jti || uuidv4(), | ||
iat: opts?.issued_at || now, | ||
exp: now + (opts?.ttl || 900), | ||
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), | ||
}; | ||
if (opts?.jti) { | ||
if (opts === null || opts === void 0 ? void 0 : opts.jti) { | ||
delete opts.jti; | ||
} | ||
if (opts?.issued_at) { | ||
if (opts === null || opts === void 0 ? void 0 : opts.issued_at) { | ||
delete opts.issued_at; | ||
} | ||
if (opts?.ttl) { | ||
if (opts === null || opts === void 0 ? void 0 : opts.ttl) { | ||
delete opts.ttl; | ||
} | ||
if (opts?.subject) { | ||
if (opts === null || opts === void 0 ? void 0 : opts.subject) { | ||
claims.sub = opts.subject; | ||
delete opts.subject; | ||
} | ||
if (opts?.acl) { | ||
if (opts === null || opts === void 0 ? void 0 : opts.acl) { | ||
claims.acl = opts.acl; | ||
@@ -54,2 +57,3 @@ delete opts.acl; | ||
} | ||
exports.JWT = JWT; | ||
//# sourceMappingURL=jwt.js.map |
{ | ||
"name": "@vonage/jwt", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Vonage JWT package. Creates JWT tokens for Vonage API's", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/jwt#readme", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9508
107