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

nestjs-jwt2

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-jwt2 - npm Package Compare versions

Comparing version 8.0.1 to 8.0.2

8

lib/services/jwt.service.d.ts

@@ -0,1 +1,6 @@

/// <reference types="node" />
export declare class ValidateTokenOptions {
issuers?: string[];
cert?: Buffer;
}
export declare class JwtService {

@@ -7,5 +12,6 @@ private readonly client;

constructor();
validateToken(token: string): Promise<boolean>;
validateToken(token: string, options?: ValidateTokenOptions): Promise<boolean>;
decodeToken(token: string): Promise<object>;
private getKey;
private getCertOrKey;
}

23

lib/services/jwt.service.js

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtService = void 0;
exports.JwtService = exports.ValidateTokenOptions = void 0;
const jwt = require("jsonwebtoken");

@@ -18,2 +18,5 @@ const jwksClient = require("jwks-rsa");

const common_1 = require("@nestjs/common");
class ValidateTokenOptions {
}
exports.ValidateTokenOptions = ValidateTokenOptions;
let JwtService = class JwtService {

@@ -38,3 +41,3 @@ constructor() {

rateLimit: true,
jwksRequestsPerMinute: 10,
jwksRequestsPerMinute: 10
});

@@ -50,8 +53,9 @@ }

}
validateToken(token) {
const certOrGetKey = this.cert ? this.cert : this.getKey.bind(this);
validateToken(token, options) {
const certOrGetKey = this.getCertOrKey(options);
return new Promise((resolve, reject) => {
var _a;
jwt.verify(token, certOrGetKey, {
audience: this.audiences,
issuer: this.issuers,
issuer: (_a = options === null || options === void 0 ? void 0 : options.issuers) !== null && _a !== void 0 ? _a : this.issuers
}, err => {

@@ -67,3 +71,3 @@ if (err) {

return jwt.decode(token, {
json: true,
json: true
});

@@ -81,2 +85,9 @@ }

}
getCertOrKey(options) {
var _a;
if (this.cert || (options === null || options === void 0 ? void 0 : options.cert)) {
return (_a = options === null || options === void 0 ? void 0 : options.cert) !== null && _a !== void 0 ? _a : this.cert;
}
return this.getKey.bind(this);
}
};

@@ -83,0 +94,0 @@ JwtService = __decorate([

{
"name": "nestjs-jwt2",
"version": "8.0.1",
"version": "8.0.2",
"description": "Jwt utils for nestjs",

@@ -5,0 +5,0 @@ "author": "Julien Dufresne",

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