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 7.0.0 to 7.1.0

lib/constant.d.ts

5

lib/guards/jwt.guard.d.ts
import { CanActivate, ExecutionContext } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { JwtService } from '../services/jwt.service';
import { JwtConfigModel } from '../models/config.model';
export declare class JwtGuard implements CanActivate {
private readonly config;
private readonly reflector;
private readonly jwtService;
constructor(reflector: Reflector, jwtService: JwtService);
constructor(config: JwtConfigModel, reflector: Reflector, jwtService: JwtService);
canActivate(context: ExecutionContext): Promise<boolean>;
private isRouteWhitelisted;
}

17

lib/guards/jwt.guard.js

@@ -11,2 +11,5 @@ "use strict";

};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,4 +19,6 @@ const common_1 = require("@nestjs/common");

const jwt_service_1 = require("../services/jwt.service");
const constant_1 = require("../constant");
let JwtGuard = class JwtGuard {
constructor(reflector, jwtService) {
constructor(config, reflector, jwtService) {
this.config = config;
this.reflector = reflector;

@@ -28,2 +33,5 @@ this.jwtService = jwtService;

const req = context.switchToHttp().getRequest();
if (this.isRouteWhitelisted(req)) {
return true;
}
const tokenHeader = req.header('Authorization');

@@ -51,8 +59,13 @@ if (!tokenHeader) {

}
isRouteWhitelisted(req) {
var _a, _b, _c;
return (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.whitelist) === null || _b === void 0 ? void 0 : _b.controllers) === null || _c === void 0 ? void 0 : _c.some(x => req.url.startsWith(x));
}
};
JwtGuard = __decorate([
common_1.Injectable(),
__metadata("design:paramtypes", [core_1.Reflector,
__param(0, common_1.Inject(constant_1.JWT_CONFIG)),
__metadata("design:paramtypes", [Object, core_1.Reflector,
jwt_service_1.JwtService])
], JwtGuard);
exports.JwtGuard = JwtGuard;

@@ -0,2 +1,5 @@

import { DynamicModule } from '@nestjs/common';
import { JwtConfigModel } from './models/config.model';
export declare class JwtModule {
static forRoot(config?: JwtConfigModel): DynamicModule;
}

@@ -8,8 +8,23 @@ "use strict";

};
var JwtModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@nestjs/common");
const jwt_service_1 = require("./services/jwt.service");
let JwtModule = class JwtModule {
const constant_1 = require("./constant");
let JwtModule = JwtModule_1 = class JwtModule {
static forRoot(config) {
return {
module: JwtModule_1,
providers: [
{
provide: constant_1.JWT_CONFIG,
useValue: config,
},
],
exports: [constant_1.JWT_CONFIG],
};
}
};
JwtModule = __decorate([
JwtModule = JwtModule_1 = __decorate([
common_1.Global(),
common_1.Module({

@@ -16,0 +31,0 @@ providers: [

{
"name": "nestjs-jwt2",
"version": "7.0.0",
"version": "7.1.0",
"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